aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of/device.c')
-rw-r--r--drivers/of/device.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 28e743888402..20c1332a0018 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -90,10 +90,11 @@ void of_dma_configure(struct device *dev, struct device_node *np)
90 struct iommu_ops *iommu; 90 struct iommu_ops *iommu;
91 91
92 /* 92 /*
93 * Set default dma-mask to 32 bit. Drivers are expected to setup 93 * Set default coherent_dma_mask to 32 bit. Drivers are expected to
94 * the correct supported dma_mask. 94 * setup the correct supported mask.
95 */ 95 */
96 dev->coherent_dma_mask = DMA_BIT_MASK(32); 96 if (!dev->coherent_dma_mask)
97 dev->coherent_dma_mask = DMA_BIT_MASK(32);
97 98
98 /* 99 /*
99 * Set it to coherent_dma_mask by default if the architecture 100 * Set it to coherent_dma_mask by default if the architecture
@@ -128,6 +129,15 @@ void of_dma_configure(struct device *dev, struct device_node *np)
128 129
129 dev->dma_pfn_offset = offset; 130 dev->dma_pfn_offset = offset;
130 131
132 /*
133 * Limit coherent and dma mask based on size and default mask
134 * set by the driver.
135 */
136 dev->coherent_dma_mask = min(dev->coherent_dma_mask,
137 DMA_BIT_MASK(ilog2(dma_addr + size)));
138 *dev->dma_mask = min((*dev->dma_mask),
139 DMA_BIT_MASK(ilog2(dma_addr + size)));
140
131 coherent = of_dma_is_coherent(np); 141 coherent = of_dma_is_coherent(np);
132 dev_dbg(dev, "device is%sdma coherent\n", 142 dev_dbg(dev, "device is%sdma coherent\n",
133 coherent ? " " : " not "); 143 coherent ? " " : " not ");