[PATCH 07/29] ARM: dma-mapping: arm_iommu_attach_device: automatically set max_seg_size

From: Marek Szyprowski
Date: Tue Aug 05 2014 - 06:57:31 EST


If device has no max_seg_size set, we assume that there is no limit and
force it to DMA_BIT_MASK(32) to always use contiguous mappings in DMA
address space.

Signed-off-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
---
arch/arm/mm/dma-mapping.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 7a996aa..8161102 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -2051,6 +2051,22 @@ int arm_iommu_attach_device(struct device *dev,
{
int err;

+ /*
+ * if device has no max_seg_size set, we assume that there is no limit
+ * and force it to DMA_BIT_MASK(32) to always use contiguous mappings
+ * in DMA address space
+ */
+ if (!dev->dma_parms) {
+ dev->dma_parms = kzalloc(sizeof(*dev->dma_parms), GFP_KERNEL);
+ if (!dev->dma_parms)
+ return -ENOMEM;
+ }
+ if (!dev->dma_parms->max_segment_size) {
+ err = dma_set_max_seg_size(dev, DMA_BIT_MASK(32));
+ if (err)
+ return err;
+ }
+
err = iommu_attach_device(mapping->domain, dev);
if (err)
return err;
--
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/