projects/linux·commit 8ceafbfa

Merge branch 'for-linus-dma-masks' of git://git.linaro.org/people/rmk/linux-arm

8ceafbfa · Linus Torvalds <[email protected]> · 2013-11-14 07:55:21 +09:00

Pull DMA mask updates from Russell King:
 "This series cleans up the handling of DMA masks in a lot of drivers,
  fixing some bugs as we go.

  Some of the more serious errors include:
   - drivers which only set their coherent DMA mask if the attempt to
     set the streaming mask fails.
   - drivers which test for a NULL dma mask pointer, and then set the
     dma mask pointer to a location in their module .data section -
     which will cause problems if the module is reloaded.

  To counter these, I have introduced two helper functions:
   - dma_set_mask_and_coherent() takes care of setting both the
     streaming and coherent masks at the same time, with the correct
     error handling as specified by the API.
   - dma_coerce_mask_and_coherent() which resolves the problem of
     drivers forcefully setting DMA masks.  This is more a marker for
     future work to further clean these locations up - the code which
     creates the devices really should be initialising these, but to fix
     that in one go along with this change could potentially be very
     disruptive.

  The last thing this series does is prise away some of Linux's addition
  to "DMA addresses are physical addresses and RAM always starts at
  zero".  We have ARM LPAE systems where all system memory is above 4GB
  physical, hence having DMA masks interpreted by (eg) the block layers
  as describing physical addresses in the range 0..DMAMASK fails on
  these platforms.  Santosh Shilimkar addresses this in this series; the
  patches were copied to the appropriate people multiple times but were
  ignored.

  Fixing this also gets rid of some ARM weirdness in the setup of the
  max*pfn variables, and brings ARM into line with every other Linux
  architecture as far as those go"

* 'for-linus-dma-masks' of git://git.linaro.org/people/rmk/linux-arm: (52 commits)
  ARM: 7805/1: mm: change max*pfn to include the physical offset of memory
  ARM: 7797/1: mmc: Use dma_max_pfn(dev) helper for bounce_limit calculations
  ARM: 7796/1: scsi: Use dma_max_pfn(dev) helper for bounce_limit calculations
  ARM: 7795/1: mm: dma-mapping: Add dma_max_pfn(dev) helper function
  ARM: 7794/1: block: Rename parameter dma_mask to max_addr for blk_queue_bounce_limit()
  ARM: DMA-API: better handing of DMA masks for coherent allocations
  ARM: 7857/1: dma: imx-sdma: setup dma mask
  DMA-API: firmware/google/gsmi.c: avoid direct access to DMA masks
  DMA-API: dcdbas: update DMA mask handing
  DMA-API: dma: edma.c: no need to explicitly initialize DMA masks
  DMA-API: usb: musb: use platform_device_register_full() to avoid directly messing with dma masks
  DMA-API: crypto: remove last references to 'static struct device *dev'
  DMA-API: crypto: fix ixp4xx crypto platform device support
  DMA-API: others: use dma_set_coherent_mask()
  DMA-API: staging: use dma_set_coherent_mask()
  DMA-API: usb: use new dma_coerce_mask_and_coherent()
  DMA-API: usb: use dma_set_coherent_mask()
  DMA-API: parport: parport_pc.c: use dma_coerce_mask_and_coherent()
  DMA-API: net: octeon: use dma_coerce_mask_and_coherent()
  DMA-API: net: nxp/lpc_eth: use dma_coerce_mask_and_coherent()
  ...
Commit
8ceafbfa91ffbdbb2afaea5c24ccb519ffb8b587
Parents
42a2d923 · 26ba47b1

Merge commit. Changes below are compared with the first parent: 42a2d923.

Changes

91 files changed · +447 −448

FileStatusAddDelContent
Documentation/DMA-API-HOWTO.txtmodified+22−15View file
Documentation/DMA-API.txtmodified+8−0View file
arch/arm/include/asm/dma-mapping.hmodified+8−0View file
arch/arm/mm/dma-mapping.cmodified+45−6View file
arch/arm/mm/init.cmodified+6−6View file
arch/arm/mm/mm.hmodified+2−0View file
arch/powerpc/kernel/vio.cmodified+1−2View file
block/blk-settings.cmodified+4−4View file
drivers/amba/bus.cmodified+1−5View file
drivers/ata/pata_ixp4xx_cf.cmodified+4−1View file
drivers/ata/pata_octeon_cf.cmodified+3−2View file
drivers/block/nvme-core.cmodified+4−6View file
drivers/crypto/ixp4xx_crypto.cmodified+24−24View file
drivers/dma/amba-pl08x.cmodified+5−0View file
drivers/dma/dw/platform.cmodified+3−5View file
drivers/dma/edma.cmodified+6−4View file
drivers/dma/imx-sdma.cmodified+4−0View file
drivers/dma/pl330.cmodified+4−0View file
drivers/firmware/dcdbas.cmodified+19−13View file
drivers/firmware/google/gsmi.cmodified+8−5View file
drivers/gpu/drm/exynos/exynos_drm_drv.cmodified+5−1View file
drivers/gpu/drm/omapdrm/omap_dmm_tiler.cmodified+3−2View file
drivers/media/platform/omap3isp/isp.cmodified+3−3View file
drivers/media/platform/omap3isp/isp.hmodified+0−3View file
drivers/mmc/card/queue.cmodified+2−1View file
drivers/mmc/host/sdhci-acpi.cmodified+3−2View file
drivers/net/ethernet/broadcom/b44.cmodified+1−2View file
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.cmodified+2−6View file
drivers/net/ethernet/brocade/bna/bnad.cmodified+4−9View file
drivers/net/ethernet/emulex/benet/be_main.cmodified+2−10View file
drivers/net/ethernet/intel/e1000/e1000_main.cmodified+2−7View file
drivers/net/ethernet/intel/e1000e/netdev.cmodified+6−12View file
drivers/net/ethernet/intel/igb/igb_main.cmodified+6−12View file
drivers/net/ethernet/intel/igbvf/netdev.cmodified+6−12View file
drivers/net/ethernet/intel/ixgb/ixgb_main.cmodified+5−11View file
drivers/net/ethernet/intel/ixgbe/ixgbe_main.cmodified+5−10View file
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.cmodified+5−10View file
drivers/net/ethernet/nxp/lpc_eth.cmodified+4−2View file
drivers/net/ethernet/octeon/octeon_mgmt.cmodified+3−2View file
drivers/net/ethernet/sfc/efx.cmodified+1−11View file
drivers/net/wireless/b43/dma.cmodified+3−6View file
drivers/net/wireless/b43legacy/dma.cmodified+3−6View file
drivers/of/platform.cmodified+0−3View file
drivers/parport/parport_pc.cmodified+6−2View file
drivers/scsi/scsi_lib.cmodified+1−1View file
drivers/staging/dwc2/platform.cmodified+3−2View file
drivers/staging/et131x/et131x.cmodified+2−15View file
drivers/staging/imx-drm/imx-drm-core.cmodified+6−2View file
drivers/staging/imx-drm/ipuv3-crtc.cmodified+3−1View file
drivers/staging/media/dt3155v4l/dt3155v4l.cmodified+1−4View file
drivers/usb/chipidea/ci_hdrc_imx.cmodified+3−4View file
drivers/usb/dwc3/dwc3-exynos.cmodified+3−4View file
drivers/usb/gadget/lpc32xx_udc.cmodified+3−1View file
drivers/usb/host/bcma-hcd.cmodified+1−2View file
drivers/usb/host/ehci-atmel.cmodified+3−4View file
drivers/usb/host/ehci-exynos.cmodified+3−4View file
drivers/usb/host/ehci-octeon.cmodified+3−1View file
drivers/usb/host/ehci-omap.cmodified+5−5View file
drivers/usb/host/ehci-orion.cmodified+3−4View file
drivers/usb/host/ehci-platform.cmodified+5−5View file
drivers/usb/host/ehci-spear.cmodified+3−4View file
drivers/usb/host/ehci-tegra.cmodified+3−4View file
drivers/usb/host/ohci-at91.cmodified+4−5View file
drivers/usb/host/ohci-exynos.cmodified+3−4View file
drivers/usb/host/ohci-nxp.cmodified+3−2View file
drivers/usb/host/ohci-octeon.cmodified+3−2View file
drivers/usb/host/ohci-omap3.cmodified+5−5View file
drivers/usb/host/ohci-pxa27x.cmodified+4−4View file
drivers/usb/host/ohci-sa1111.cmodified+6−0View file
drivers/usb/host/ohci-spear.cmodified+3−4View file
drivers/usb/host/ssb-hcd.cmodified+1−2View file
drivers/usb/host/uhci-platform.cmodified+3−4View file
drivers/video/amba-clcd.cmodified+5−0View file
include/linux/amba/bus.hmodified+0−2View file
include/linux/dma-mapping.hmodified+31−0View file
sound/arm/pxa2xx-pcm.cmodified+4−6View file
sound/soc/atmel/atmel-pcm.cmodified+4−7View file
sound/soc/blackfin/bf5xx-ac97-pcm.cmodified+4−7View file
sound/soc/blackfin/bf5xx-i2s-pcm.cmodified+4−6View file
sound/soc/davinci/davinci-pcm.cmodified+3−6View file
sound/soc/fsl/fsl_dma.cmodified+3−6View file
sound/soc/fsl/imx-pcm-fiq.cmodified+5−7View file
sound/soc/fsl/mpc5200_dma.cmodified+4−6View file
sound/soc/jz4740/jz4740-pcm.cmodified+4−8View file
sound/soc/kirkwood/kirkwood-dma.cmodified+3−6View file
sound/soc/nuc900/nuc900-pcm.cmodified+4−5View file
sound/soc/omap/omap-pcm.cmodified+4−7View file
sound/soc/pxa/pxa2xx-pcm.cmodified+4−7View file
sound/soc/s6000/s6000-pcm.cmodified+3−6View file
sound/soc/samsung/dma.cmodified+4−7View file
sound/soc/samsung/idma.cmodified+4−7View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/DMA-API-HOWTO.txt

View file
diff --git a/Documentation/DMA-API-HOWTO.txt b/Documentation/DMA-API-HOWTO.txt
index 14129f1..5e98303 100644
--- a/Documentation/DMA-API-HOWTO.txt
+++ b/Documentation/DMA-API-HOWTO.txt
@@ -101,14 +101,23 @@ style to do this even if your device holds the default setting,
because this shows that you did think about these issues wrt. your
device.
-The query is performed via a call to dma_set_mask():
+The query is performed via a call to dma_set_mask_and_coherent():
- int dma_set_mask(struct device *dev, u64 mask);
+ int dma_set_mask_and_coherent(struct device *dev, u64 mask);
-The query for consistent allocations is performed via a call to
-dma_set_coherent_mask():
+which will query the mask for both streaming and coherent APIs together.
+If you have some special requirements, then the following two separate
+queries can be used instead:
- int dma_set_coherent_mask(struct device *dev, u64 mask);
+ The query for streaming mappings is performed via a call to
+ dma_set_mask():
+
+ int dma_set_mask(struct device *dev, u64 mask);
+
+ The query for consistent allocations is performed via a call
+ to dma_set_coherent_mask():
+
+ int dma_set_coherent_mask(struct device *dev, u64 mask);
Here, dev is a pointer to the device struct of your device, and mask
is a bit mask describing which bits of an address your device
@@ -137,7 +146,7 @@ exactly why.
The standard 32-bit addressing device would do something like this:
- if (dma_set_mask(dev, DMA_BIT_MASK(32))) {
+ if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
printk(KERN_WARNING
"mydev: No suitable DMA available.\n");
goto ignore_this_device;
@@ -171,22 +180,20 @@ the case would look like this:
int using_dac, consistent_using_dac;
- if (!dma_set_mask(dev, DMA_BIT_MASK(64))) {
+ if (!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
using_dac = 1;
consistent_using_dac = 1;
- dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
- } else if (!dma_set_mask(dev, DMA_BIT_MASK(32))) {
+ } else if (!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
using_dac = 0;
consistent_using_dac = 0;
- dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
} else {
printk(KERN_WARNING
"mydev: No suitable DMA available.\n");
goto ignore_this_device;
}
-dma_set_coherent_mask() will always be able to set the same or a
-smaller mask as dma_set_mask(). However for the rare case that a
+The coherent coherent mask will always be able to set the same or a
+smaller mask as the streaming mask. However for the rare case that a
device driver only uses consistent allocations, one would have to
check the return value from dma_set_coherent_mask().
@@ -199,9 +206,9 @@ address you might do something like:
goto ignore_this_device;
}
-When dma_set_mask() is successful, and returns zero, the kernel saves
-away this mask you have provided. The kernel will use this
-information later when you make DMA mappings.
+When dma_set_mask() or dma_set_mask_and_coherent() is successful, and
+returns zero, the kernel saves away this mask you have provided. The
+kernel will use this information later when you make DMA mappings.
There is a case which we are aware of at this time, which is worth
mentioning in this documentation. If your device supports multiple

Documentation/DMA-API.txt

View file
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 78a6c56..e865279 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -142,6 +142,14 @@ internal API for use by the platform than an external API for use by
driver writers.
int
+dma_set_mask_and_coherent(struct device *dev, u64 mask)
+
+Checks to see if the mask is possible and updates the device
+streaming and coherent DMA mask parameters if it is.
+
+Returns: 0 if successful and a negative error if not.
+
+int
dma_set_mask(struct device *dev, u64 mask)
Checks to see if the mask is possible and updates the device

arch/arm/include/asm/dma-mapping.h

View file
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 5b579b9..863cd84 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -64,6 +64,7 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
{
return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
}
+
#else
static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
{
@@ -86,6 +87,13 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
}
#endif
+/* The ARM override for dma_max_pfn() */
+static inline unsigned long dma_max_pfn(struct device *dev)
+{
+ return PHYS_PFN_OFFSET + dma_to_pfn(dev, *dev->dma_mask);
+}
+#define dma_max_pfn(dev) dma_max_pfn(dev)
+
/*
* DMA errors are defined by all-bits-set in the DMA address.
*/

arch/arm/mm/dma-mapping.c

View file
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 1272ed2..644d91f 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -159,7 +159,7 @@ EXPORT_SYMBOL(arm_coherent_dma_ops);
static u64 get_coherent_dma_mask(struct device *dev)
{
- u64 mask = (u64)arm_dma_limit;
+ u64 mask = (u64)DMA_BIT_MASK(32);
if (dev) {
mask = dev->coherent_dma_mask;
@@ -173,10 +173,30 @@ static u64 get_coherent_dma_mask(struct device *dev)
return 0;
}
- if ((~mask) & (u64)arm_dma_limit) {
- dev_warn(dev, "coherent DMA mask %#llx is smaller "
- "than system GFP_DMA mask %#llx\n",
- mask, (u64)arm_dma_limit);
+ /*
+ * If the mask allows for more memory than we can address,
+ * and we actually have that much memory, then fail the
+ * allocation.
+ */
+ if (sizeof(mask) != sizeof(dma_addr_t) &&
+ mask > (dma_addr_t)~0 &&
+ dma_to_pfn(dev, ~0) > arm_dma_pfn_limit) {
+ dev_warn(dev, "Coherent DMA mask %#llx is larger than dma_addr_t allows\n",
+ mask);
+ dev_warn(dev, "Driver did not use or check the return value from dma_set_coherent_mask()?\n");
+ return 0;
+ }
+
+ /*
+ * Now check that the mask, when translated to a PFN,
+ * fits within the allowable addresses which we can
+ * allocate.
+ */
+ if (dma_to_pfn(dev, mask) < arm_dma_pfn_limit) {
+ dev_warn(dev, "Coherent DMA mask %#llx (pfn %#lx-%#lx) covers a smaller range of system memory than the DMA zone pfn 0x0-%#lx\n",
+ mask,
+ dma_to_pfn(dev, 0), dma_to_pfn(dev, mask) + 1,
+ arm_dma_pfn_limit + 1);
return 0;
}
}
@@ -1007,8 +1027,27 @@ void arm_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
*/
int dma_supported(struct device *dev, u64 mask)
{
- if (mask < (u64)arm_dma_limit)
+ unsigned long limit;
+
+ /*
+ * If the mask allows for more memory than we can address,
+ * and we actually have that much memory, then we must
+ * indicate that DMA to this device is not supported.
+ */
+ if (sizeof(mask) != sizeof(dma_addr_t) &&
+ mask > (dma_addr_t)~0 &&
+ dma_to_pfn(dev, ~0) > arm_dma_pfn_limit)
+ return 0;
+
+ /*
+ * Translate the device's DMA mask to a PFN limit. This
+ * PFN number includes the page which we can DMA to.
+ */
+ limit = dma_to_pfn(dev, mask);
+
+ if (limit < arm_dma_pfn_limit)
return 0;
+
return 1;
}
EXPORT_SYMBOL(dma_supported);

arch/arm/mm/init.c

View file
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index ca907f8..3e8f106 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -209,6 +209,7 @@ EXPORT_SYMBOL(arm_dma_zone_size);
* so a successful GFP_DMA allocation will always satisfy this.
*/
phys_addr_t arm_dma_limit;
+unsigned long arm_dma_pfn_limit;
static void __init arm_adjust_dma_zone(unsigned long *size, unsigned long *hole,
unsigned long dma_size)
@@ -231,6 +232,7 @@ void __init setup_dma_zone(const struct machine_desc *mdesc)
arm_dma_limit = PHYS_OFFSET + arm_dma_zone_size - 1;
} else
arm_dma_limit = 0xffffffff;
+ arm_dma_pfn_limit = arm_dma_limit >> PAGE_SHIFT;
#endif
}
@@ -418,12 +420,10 @@ void __init bootmem_init(void)
* This doesn't seem to be used by the Linux memory manager any
* more, but is used by ll_rw_block. If we can get rid of it, we
* also get rid of some of the stuff above as well.
- *
- * Note: max_low_pfn and max_pfn reflect the number of _pages_ in
- * the system, not the maximum PFN.
*/
- max_low_pfn = max_low - PHYS_PFN_OFFSET;
- max_pfn = max_high - PHYS_PFN_OFFSET;
+ min_low_pfn = min;
+ max_low_pfn = max_low;
+ max_pfn = max_high;
}
/*
@@ -529,7 +529,7 @@ static inline void free_area_high(unsigned long pfn, unsigned long end)
static void __init free_highpages(void)
{
#ifdef CONFIG_HIGHMEM
- unsigned long max_low = max_low_pfn + PHYS_PFN_OFFSET;
+ unsigned long max_low = max_low_pfn;
struct memblock_region *mem, *res;
/* set highmem page free */

arch/arm/mm/mm.h

View file
diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h
index d5a4e9a..d5a982d 100644
--- a/arch/arm/mm/mm.h
+++ b/arch/arm/mm/mm.h
@@ -81,8 +81,10 @@ extern __init void add_static_vm_early(struct static_vm *svm);
#ifdef CONFIG_ZONE_DMA
extern phys_addr_t arm_dma_limit;
+extern unsigned long arm_dma_pfn_limit;
#else
#define arm_dma_limit ((phys_addr_t)~0)
+#define arm_dma_pfn_limit (~0ul >> PAGE_SHIFT)
#endif
extern phys_addr_t arm_lowmem_limit;

arch/powerpc/kernel/vio.c

View file
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index f99cefb..e7d0c88 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -1419,8 +1419,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
/* needed to ensure proper operation of coherent allocations
* later, in case driver doesn't set it explicitly */
- dma_set_mask(&viodev->dev, DMA_BIT_MASK(64));
- dma_set_coherent_mask(&viodev->dev, DMA_BIT_MASK(64));
+ dma_set_mask_and_coherent(&viodev->dev, DMA_BIT_MASK(64));
}
/* register with generic device framework */

block/blk-settings.c

View file
diff --git a/block/blk-settings.c b/block/blk-settings.c
index c50ecf0..026c151 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -195,17 +195,17 @@ EXPORT_SYMBOL(blk_queue_make_request);
/**
* blk_queue_bounce_limit - set bounce buffer limit for queue
* @q: the request queue for the device
- * @dma_mask: the maximum address the device can handle
+ * @max_addr: the maximum address the device can handle
*
* Description:
* Different hardware can have different requirements as to what pages
* it can do I/O directly to. A low level driver can call
* blk_queue_bounce_limit to have lower memory pages allocated as bounce
- * buffers for doing I/O to pages residing above @dma_mask.
+ * buffers for doing I/O to pages residing above @max_addr.
**/
-void blk_queue_bounce_limit(struct request_queue *q, u64 dma_mask)
+void blk_queue_bounce_limit(struct request_queue *q, u64 max_addr)
{
- unsigned long b_pfn = dma_mask >> PAGE_SHIFT;
+ unsigned long b_pfn = max_addr >> PAGE_SHIFT;
int dma = 0;
q->bounce_gfp = GFP_NOIO;

drivers/amba/bus.c

View file
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index c670727..c4876ac 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -552,7 +552,6 @@ amba_aphb_device_add(struct device *parent, const char *name,
if (!dev)
return ERR_PTR(-ENOMEM);
- dev->dma_mask = dma_mask;
dev->dev.coherent_dma_mask = dma_mask;
dev->irq[0] = irq1;
dev->irq[1] = irq2;
@@ -619,7 +618,7 @@ static void amba_device_initialize(struct amba_device *dev, const char *name)
dev_set_name(&dev->dev, "%s", name);
dev->dev.release = amba_device_release;
dev->dev.bus = &amba_bustype;
- dev->dev.dma_mask = &dev->dma_mask;
+ dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
dev->res.name = dev_name(&dev->dev);
}
@@ -663,9 +662,6 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
amba_device_initialize(dev, dev->dev.init_name);
dev->dev.init_name = NULL;
- if (!dev->dev.coherent_dma_mask && dev->dma_mask)
- dev_warn(&dev->dev, "coherent dma mask is unset\n");
-
return amba_device_add(dev, parent);
}

drivers/ata/pata_ixp4xx_cf.c

View file
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index 1ec53f8..ddf470c 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -144,6 +144,7 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)
struct ata_host *host;
struct ata_port *ap;
struct ixp4xx_pata_data *data = dev_get_platdata(&pdev->dev);
+ int ret;
cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -157,7 +158,9 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)
return -ENOMEM;
/* acquire resources and fill host */
- pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+ ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+ if (ret)
+ return ret;
data->cs0 = devm_ioremap(&pdev->dev, cs0->start, 0x1000);
data->cs1 = devm_ioremap(&pdev->dev, cs1->start, 0x1000);

drivers/ata/pata_octeon_cf.c

View file
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index c51bbb9..83c4ddb 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -1014,8 +1014,9 @@ static int octeon_cf_probe(struct platform_device *pdev)
}
cf_port->c0 = ap->ioaddr.ctl_addr;
- pdev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
- pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
+ rv = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+ if (rv)
+ return rv;
ata_port_desc(ap, "cmd %p ctl %p", base, ap->ioaddr.ctl_addr);

drivers/block/nvme-core.c

View file
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index da52092..26d03fa 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1949,12 +1949,9 @@ static int nvme_dev_map(struct nvme_dev *dev)
if (pci_request_selected_regions(pdev, bars, "nvme"))
goto disable_pci;
- if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)))
- dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
- else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)))
- dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
- else
- goto disable_pci;
+ if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) &&
+ dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
+ goto disable;
pci_set_drvdata(pdev, dev);
dev->bar = ioremap(pci_resource_start(pdev, 0), 8192);
@@ -2168,6 +2165,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
INIT_LIST_HEAD(&dev->namespaces);
dev->pci_dev = pdev;
+
result = nvme_set_instance(dev);
if (result)
goto free;

drivers/crypto/ixp4xx_crypto.c

View file
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 21180d6..214357e 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -218,23 +218,9 @@ static dma_addr_t crypt_phys;
static int support_aes = 1;
-static void dev_release(struct device *dev)
-{
- return;
-}
-
#define DRIVER_NAME "ixp4xx_crypto"
-static struct platform_device pseudo_dev = {
- .name = DRIVER_NAME,
- .id = 0,
- .num_resources = 0,
- .dev = {
- .coherent_dma_mask = DMA_BIT_MASK(32),
- .release = dev_release,
- }
-};
-static struct device *dev = &pseudo_dev.dev;
+static struct platform_device *pdev;
static inline dma_addr_t crypt_virt2phys(struct crypt_ctl *virt)
{
@@ -263,6 +249,7 @@ static inline const struct ix_hash_algo *ix_hash(struct crypto_tfm *tfm)
static int setup_crypt_desc(void)
{
+ struct device *dev = &pdev->dev;
BUILD_BUG_ON(sizeof(struct crypt_ctl) != 64);
crypt_virt = dma_alloc_coherent(dev,
NPE_QLEN * sizeof(struct crypt_ctl),
@@ -363,6 +350,7 @@ static void finish_scattered_hmac(struct crypt_ctl *crypt)
static void one_packet(dma_addr_t phys)
{
+ struct device *dev = &pdev->dev;
struct crypt_ctl *crypt;
struct ixp_ctx *ctx;
int failed;
@@ -432,7 +420,7 @@ static void crypto_done_action(unsigned long arg)
tasklet_schedule(&crypto_done_tasklet);
}
-static int init_ixp_crypto(void)
+static int init_ixp_crypto(struct device *dev)
{
int ret = -ENODEV;
u32 msg[2] = { 0, 0 };
@@ -519,7 +507,7 @@ err:
return ret;
}
-static void release_ixp_crypto(void)
+static void release_ixp_crypto(struct device *dev)
{
qmgr_disable_irq(RECV_QID);
tasklet_kill(&crypto_done_tasklet);
@@ -886,6 +874,7 @@ static int ablk_perform(struct ablkcipher_request *req, int encrypt)
enum dma_data_direction src_direction = DMA_BIDIRECTIONAL;
struct ablk_ctx *req_ctx = ablkcipher_request_ctx(req);
struct buffer_desc src_hook;
+ struct device *dev = &pdev->dev;
gfp_t flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ?
GFP_KERNEL : GFP_ATOMIC;
@@ -1010,6 +999,7 @@ static int aead_perform(struct aead_request *req, int encrypt,
unsigned int cryptlen;
struct buffer_desc *buf, src_hook;
struct aead_ctx *req_ctx = aead_request_ctx(req);
+ struct device *dev = &pdev->dev;
gfp_t flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ?
GFP_KERNEL : GFP_ATOMIC;
@@ -1418,20 +1408,30 @@ static struct ixp_alg ixp4xx_algos[] = {
} };
#define IXP_POSTFIX "-ixp4xx"
+
+static const struct platform_device_info ixp_dev_info __initdata = {
+ .name = DRIVER_NAME,
+ .id = 0,
+ .dma_mask = DMA_BIT_MASK(32),
+};
+
static int __init ixp_module_init(void)
{
int num = ARRAY_SIZE(ixp4xx_algos);
- int i,err ;
+ int i, err ;
- if (platform_device_register(&pseudo_dev))
- return -ENODEV;
+ pdev = platform_device_register_full(&ixp_dev_info);
+ if (IS_ERR(pdev))
+ return PTR_ERR(pdev);
+
+ dev = &pdev->dev;
spin_lock_init(&desc_lock);
spin_lock_init(&emerg_lock);
- err = init_ixp_crypto();
+ err = init_ixp_crypto(&pdev->dev);
if (err) {
- platform_device_unregister(&pseudo_dev);
+ platform_device_unregister(pdev);
return err;
}
for (i=0; i< num; i++) {
@@ -1495,8 +1495,8 @@ static void __exit ixp_module_exit(void)
if (ixp4xx_algos[i].registered)
crypto_unregister_alg(&ixp4xx_algos[i].crypto);
}
- release_ixp_crypto();
- platform_device_unregister(&pseudo_dev);
+ release_ixp_crypto(&pdev->dev);
+ platform_device_unregister(pdev);
}
module_init(ixp_module_init);

drivers/dma/amba-pl08x.c

View file
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index fce46c5..e51a983 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -2055,6 +2055,11 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
if (ret)
return ret;
+ /* Ensure that we can do DMA */
+ ret = dma_set_mask_and_coherent(&adev->dev, DMA_BIT_MASK(32));
+ if (ret)
+ goto out_no_pl08x;
+
/* Create the driver state holder */
pl08x = kzalloc(sizeof(*pl08x), GFP_KERNEL);
if (!pl08x) {

drivers/dma/dw/platform.c

View file
diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index e35d975..453822c 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -191,11 +191,9 @@ static int dw_probe(struct platform_device *pdev)
if (IS_ERR(chip->regs))
return PTR_ERR(chip->regs);
- /* Apply default dma_mask if needed */
- if (!dev->dma_mask) {
- dev->dma_mask = &dev->coherent_dma_mask;
- dev->coherent_dma_mask = DMA_BIT_MASK(32);
- }
+ err = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+ if (err)
+ return err;
pdata = dev_get_platdata(dev);
if (!pdata)

drivers/dma/edma.c

View file
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index 10b577f..bef8a36 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -634,6 +634,10 @@ static int edma_probe(struct platform_device *pdev)
struct edma_cc *ecc;
int ret;
+ ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+ if (ret)
+ return ret;
+
ecc = devm_kzalloc(&pdev->dev, sizeof(*ecc), GFP_KERNEL);
if (!ecc) {
dev_err(&pdev->dev, "Can't allocate controller\n");
@@ -705,11 +709,13 @@ static struct platform_device *pdev0, *pdev1;
static const struct platform_device_info edma_dev_info0 = {
.name = "edma-dma-engine",
.id = 0,
+ .dma_mask = DMA_BIT_MASK(32),
};
static const struct platform_device_info edma_dev_info1 = {
.name = "edma-dma-engine",
.id = 1,
+ .dma_mask = DMA_BIT_MASK(32),
};
static int edma_init(void)
@@ -723,8 +729,6 @@ static int edma_init(void)
ret = PTR_ERR(pdev0);
goto out;
}
- pdev0->dev.dma_mask = &pdev0->dev.coherent_dma_mask;
- pdev0->dev.coherent_dma_mask = DMA_BIT_MASK(32);
}

This diff is incomplete. Download the complete patch.

drivers/dma/imx-sdma.c

View file

This diff is incomplete. Download the complete patch.

drivers/dma/pl330.c

View file

This diff is incomplete. Download the complete patch.

drivers/firmware/dcdbas.c

View file

This diff is incomplete. Download the complete patch.

drivers/firmware/google/gsmi.c

View file

This diff is incomplete. Download the complete patch.

drivers/gpu/drm/exynos/exynos_drm_drv.c

View file

This diff is incomplete. Download the complete patch.

drivers/gpu/drm/omapdrm/omap_dmm_tiler.c

View file

This diff is incomplete. Download the complete patch.

drivers/media/platform/omap3isp/isp.c

View file

This diff is incomplete. Download the complete patch.

drivers/media/platform/omap3isp/isp.h

View file

This diff is incomplete. Download the complete patch.

drivers/mmc/card/queue.c

View file

This diff is incomplete. Download the complete patch.

drivers/mmc/host/sdhci-acpi.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/broadcom/b44.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/brocade/bna/bnad.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/emulex/benet/be_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/intel/e1000/e1000_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/intel/e1000e/netdev.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/intel/igb/igb_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/intel/igbvf/netdev.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/intel/ixgb/ixgb_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/nxp/lpc_eth.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/octeon/octeon_mgmt.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/ethernet/sfc/efx.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/wireless/b43/dma.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/wireless/b43legacy/dma.c

View file

This diff is incomplete. Download the complete patch.

drivers/of/platform.c

View file

This diff is incomplete. Download the complete patch.

drivers/parport/parport_pc.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/scsi_lib.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/dwc2/platform.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/et131x/et131x.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/imx-drm/imx-drm-core.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/imx-drm/ipuv3-crtc.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/media/dt3155v4l/dt3155v4l.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/chipidea/ci_hdrc_imx.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/dwc3/dwc3-exynos.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/gadget/lpc32xx_udc.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/bcma-hcd.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ehci-atmel.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ehci-exynos.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ehci-octeon.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ehci-omap.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ehci-orion.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ehci-platform.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ehci-spear.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ehci-tegra.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ohci-at91.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ohci-exynos.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ohci-nxp.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ohci-octeon.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ohci-omap3.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ohci-pxa27x.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ohci-sa1111.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ohci-spear.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/ssb-hcd.c

View file

This diff is incomplete. Download the complete patch.

drivers/usb/host/uhci-platform.c

View file

This diff is incomplete. Download the complete patch.

drivers/video/amba-clcd.c

View file

This diff is incomplete. Download the complete patch.

include/linux/amba/bus.h

View file

This diff is incomplete. Download the complete patch.

include/linux/dma-mapping.h

View file

This diff is incomplete. Download the complete patch.

sound/arm/pxa2xx-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/atmel/atmel-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/blackfin/bf5xx-ac97-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/blackfin/bf5xx-i2s-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/davinci/davinci-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/fsl/fsl_dma.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/fsl/imx-pcm-fiq.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/fsl/mpc5200_dma.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/jz4740/jz4740-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/kirkwood/kirkwood-dma.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/nuc900/nuc900-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/omap/omap-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/pxa/pxa2xx-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/s6000/s6000-pcm.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/samsung/dma.c

View file

This diff is incomplete. Download the complete patch.

sound/soc/samsung/idma.c

View file

This diff is incomplete. Download the complete patch.