mirror of https://gitee.com/openkylin/linux.git
of/device: Update dma_range_map only when dev has valid dma-ranges
The commite0d072782c
("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset") always update dma_range_map even though it was already set, like in the sunxi_mbus driver. the issue is reported at [1]. This patch avoid this(Updating it only when dev has valid dma-ranges). Meanwhile, dma_range_map contains the devices' dma_ranges information, This patch moves dma_range_map before of_iommu_configure. The iommu driver may need to know the dma_address requirements of its iommu consumer devices. [1] https://lore.kernel.org/linux-arm-kernel/5c7946f3-b56e-da00-a750-be097c7ceb32@arm.com/ CC: Frank Rowand <frowand.list@gmail.com> Fixes:e0d072782c
("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset"), Suggested-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Yong Wu <yong.wu@mediatek.com> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Reviewed-by: Rob Herring <robh@kernel.org> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20210119105203.15530-1-yong.wu@mediatek.com
This commit is contained in:
parent
30596ae054
commit
89c7cb1608
|
@ -162,9 +162,11 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
|
|||
mask = DMA_BIT_MASK(ilog2(end) + 1);
|
||||
dev->coherent_dma_mask &= mask;
|
||||
*dev->dma_mask &= mask;
|
||||
/* ...but only set bus limit if we found valid dma-ranges earlier */
|
||||
if (!ret)
|
||||
/* ...but only set bus limit and range map if we found valid dma-ranges earlier */
|
||||
if (!ret) {
|
||||
dev->bus_dma_limit = end;
|
||||
dev->dma_range_map = map;
|
||||
}
|
||||
|
||||
coherent = of_dma_is_coherent(np);
|
||||
dev_dbg(dev, "device is%sdma coherent\n",
|
||||
|
@ -172,6 +174,9 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
|
|||
|
||||
iommu = of_iommu_configure(dev, np, id);
|
||||
if (PTR_ERR(iommu) == -EPROBE_DEFER) {
|
||||
/* Don't touch range map if it wasn't set from a valid dma-ranges */
|
||||
if (!ret)
|
||||
dev->dma_range_map = NULL;
|
||||
kfree(map);
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
|
@ -181,7 +186,6 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
|
|||
|
||||
arch_setup_dma_ops(dev, dma_start, size, iommu, coherent);
|
||||
|
||||
dev->dma_range_map = map;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_dma_configure_id);
|
||||
|
|
Loading…
Reference in New Issue