diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-09-02 23:09:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-09-02 23:09:36 -0400 |
commit | 60c1f89241d49bacf71035470684a8d7b4bb46ea (patch) | |
tree | f545bc7a0ddd189b956e65353f36661f4fc12ae1 | |
parent | 57361846b52bc686112da6ca5368d11210796804 (diff) | |
parent | 8c89ef7b6b64ba093239305f77a485905d03f7bf (diff) |
Merge tag 'dma-mapping-4.19-2' of git://git.infradead.org/users/hch/dma-mapping
Pull dma-mapping fixes from Christoph Hellwig:
"A few fixes for the fallout of being a little more pedantic about dma
masks"
* tag 'dma-mapping-4.19-2' of git://git.infradead.org/users/hch/dma-mapping:
of/platform: initialise AMBA default DMA masks
sparc: set a default 32-bit dma mask for OF devices
kernel/dma/direct: take DMA offset into account in dma_direct_supported
-rw-r--r-- | arch/sparc/kernel/of_device_32.c | 4 | ||||
-rw-r--r-- | arch/sparc/kernel/of_device_64.c | 3 | ||||
-rw-r--r-- | drivers/of/platform.c | 4 | ||||
-rw-r--r-- | kernel/dma/direct.c | 4 |
4 files changed, 13 insertions, 2 deletions
diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c index 3641a294ed54..e4abe9b8f97a 100644 --- a/arch/sparc/kernel/of_device_32.c +++ b/arch/sparc/kernel/of_device_32.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/irq.h> | 9 | #include <linux/irq.h> |
10 | #include <linux/of_device.h> | 10 | #include <linux/of_device.h> |
11 | #include <linux/of_platform.h> | 11 | #include <linux/of_platform.h> |
12 | #include <linux/dma-mapping.h> | ||
12 | #include <asm/leon.h> | 13 | #include <asm/leon.h> |
13 | #include <asm/leon_amba.h> | 14 | #include <asm/leon_amba.h> |
14 | 15 | ||
@@ -381,6 +382,9 @@ static struct platform_device * __init scan_one_device(struct device_node *dp, | |||
381 | else | 382 | else |
382 | dev_set_name(&op->dev, "%08x", dp->phandle); | 383 | dev_set_name(&op->dev, "%08x", dp->phandle); |
383 | 384 | ||
385 | op->dev.coherent_dma_mask = DMA_BIT_MASK(32); | ||
386 | op->dev.dma_mask = &op->dev.coherent_dma_mask; | ||
387 | |||
384 | if (of_device_register(op)) { | 388 | if (of_device_register(op)) { |
385 | printk("%s: Could not register of device.\n", | 389 | printk("%s: Could not register of device.\n", |
386 | dp->full_name); | 390 | dp->full_name); |
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c index 44e4d4435bed..6df6086968c6 100644 --- a/arch/sparc/kernel/of_device_64.c +++ b/arch/sparc/kernel/of_device_64.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <linux/string.h> | 2 | #include <linux/string.h> |
3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
4 | #include <linux/of.h> | 4 | #include <linux/of.h> |
5 | #include <linux/dma-mapping.h> | ||
5 | #include <linux/init.h> | 6 | #include <linux/init.h> |
6 | #include <linux/export.h> | 7 | #include <linux/export.h> |
7 | #include <linux/mod_devicetable.h> | 8 | #include <linux/mod_devicetable.h> |
@@ -675,6 +676,8 @@ static struct platform_device * __init scan_one_device(struct device_node *dp, | |||
675 | dev_set_name(&op->dev, "root"); | 676 | dev_set_name(&op->dev, "root"); |
676 | else | 677 | else |
677 | dev_set_name(&op->dev, "%08x", dp->phandle); | 678 | dev_set_name(&op->dev, "%08x", dp->phandle); |
679 | op->dev.coherent_dma_mask = DMA_BIT_MASK(32); | ||
680 | op->dev.dma_mask = &op->dev.coherent_dma_mask; | ||
678 | 681 | ||
679 | if (of_device_register(op)) { | 682 | if (of_device_register(op)) { |
680 | printk("%s: Could not register of device.\n", | 683 | printk("%s: Could not register of device.\n", |
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 7ba90c290a42..6c59673933e9 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
@@ -241,6 +241,10 @@ static struct amba_device *of_amba_device_create(struct device_node *node, | |||
241 | if (!dev) | 241 | if (!dev) |
242 | goto err_clear_flag; | 242 | goto err_clear_flag; |
243 | 243 | ||
244 | /* AMBA devices only support a single DMA mask */ | ||
245 | dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); | ||
246 | dev->dev.dma_mask = &dev->dev.coherent_dma_mask; | ||
247 | |||
244 | /* setup generic device info */ | 248 | /* setup generic device info */ |
245 | dev->dev.of_node = of_node_get(node); | 249 | dev->dev.of_node = of_node_get(node); |
246 | dev->dev.fwnode = &node->fwnode; | 250 | dev->dev.fwnode = &node->fwnode; |
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 1c35b7b945d0..de87b0282e74 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c | |||
@@ -168,7 +168,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents, | |||
168 | int dma_direct_supported(struct device *dev, u64 mask) | 168 | int dma_direct_supported(struct device *dev, u64 mask) |
169 | { | 169 | { |
170 | #ifdef CONFIG_ZONE_DMA | 170 | #ifdef CONFIG_ZONE_DMA |
171 | if (mask < DMA_BIT_MASK(ARCH_ZONE_DMA_BITS)) | 171 | if (mask < phys_to_dma(dev, DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))) |
172 | return 0; | 172 | return 0; |
173 | #else | 173 | #else |
174 | /* | 174 | /* |
@@ -177,7 +177,7 @@ int dma_direct_supported(struct device *dev, u64 mask) | |||
177 | * memory, or by providing a ZONE_DMA32. If neither is the case, the | 177 | * memory, or by providing a ZONE_DMA32. If neither is the case, the |
178 | * architecture needs to use an IOMMU instead of the direct mapping. | 178 | * architecture needs to use an IOMMU instead of the direct mapping. |
179 | */ | 179 | */ |
180 | if (mask < DMA_BIT_MASK(32)) | 180 | if (mask < phys_to_dma(dev, DMA_BIT_MASK(32))) |
181 | return 0; | 181 | return 0; |
182 | #endif | 182 | #endif |
183 | /* | 183 | /* |