aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-13 17:55:21 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-13 17:55:21 -0500
commit8ceafbfa91ffbdbb2afaea5c24ccb519ffb8b587 (patch)
tree98c9ea93362536f1ddd73175b13b7847583350df /include/linux
parent42a2d923cc349583ebf6fdd52a7d35e1c2f7e6bd (diff)
parent26ba47b18318abe7dadbe9294a611c0e932651d8 (diff)
Merge branch 'for-linus-dma-masks' of git://git.linaro.org/people/rmk/linux-arm
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() ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/amba/bus.h2
-rw-r--r--include/linux/dma-mapping.h31
2 files changed, 31 insertions, 2 deletions
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index 43ec7e247a80..682df0e1954a 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -30,7 +30,6 @@ struct amba_device {
30 struct device dev; 30 struct device dev;
31 struct resource res; 31 struct resource res;
32 struct clk *pclk; 32 struct clk *pclk;
33 u64 dma_mask;
34 unsigned int periphid; 33 unsigned int periphid;
35 unsigned int irq[AMBA_NR_IRQS]; 34 unsigned int irq[AMBA_NR_IRQS];
36}; 35};
@@ -131,7 +130,6 @@ struct amba_device name##_device = { \
131struct amba_device name##_device = { \ 130struct amba_device name##_device = { \
132 .dev = __AMBA_DEV(busid, data, ~0ULL), \ 131 .dev = __AMBA_DEV(busid, data, ~0ULL), \
133 .res = DEFINE_RES_MEM(base, SZ_4K), \ 132 .res = DEFINE_RES_MEM(base, SZ_4K), \
134 .dma_mask = ~0ULL, \
135 .irq = irqs, \ 133 .irq = irqs, \
136 .periphid = id, \ 134 .periphid = id, \
137} 135}
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 3a8d0a2af607..fd4aee29ad10 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -97,6 +97,30 @@ static inline int dma_set_coherent_mask(struct device *dev, u64 mask)
97} 97}
98#endif 98#endif
99 99
100/*
101 * Set both the DMA mask and the coherent DMA mask to the same thing.
102 * Note that we don't check the return value from dma_set_coherent_mask()
103 * as the DMA API guarantees that the coherent DMA mask can be set to
104 * the same or smaller than the streaming DMA mask.
105 */
106static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
107{
108 int rc = dma_set_mask(dev, mask);
109 if (rc == 0)
110 dma_set_coherent_mask(dev, mask);
111 return rc;
112}
113
114/*
115 * Similar to the above, except it deals with the case where the device
116 * does not have dev->dma_mask appropriately setup.
117 */
118static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask)
119{
120 dev->dma_mask = &dev->coherent_dma_mask;
121 return dma_set_mask_and_coherent(dev, mask);
122}
123
100extern u64 dma_get_required_mask(struct device *dev); 124extern u64 dma_get_required_mask(struct device *dev);
101 125
102static inline unsigned int dma_get_max_seg_size(struct device *dev) 126static inline unsigned int dma_get_max_seg_size(struct device *dev)
@@ -129,6 +153,13 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask)
129 return -EIO; 153 return -EIO;
130} 154}
131 155
156#ifndef dma_max_pfn
157static inline unsigned long dma_max_pfn(struct device *dev)
158{
159 return *dev->dma_mask >> PAGE_SHIFT;
160}
161#endif
162
132static inline void *dma_zalloc_coherent(struct device *dev, size_t size, 163static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
133 dma_addr_t *dma_handle, gfp_t flag) 164 dma_addr_t *dma_handle, gfp_t flag)
134{ 165{