mvebu DMA fix
Hi Russell,
the first patch fixes the regression that overwrites ->dma_coherent after the mvebu notifier set it, and the second one removes a now unused field in the arm arch_devdata.
Let me know if you want to take these, or if I should route them through the dma-mapping tree that introduced this problem.
PATCH 1/2 ARM/dma-mappіng: don't override ->dma_coherent when set from a bus notifier
Commit ae626eb97376 ("ARM/dma-mapping: use dma-direct unconditionally") caused a regression on the mvebu platform, wherein devices that are dma-coherent are marked as dma-noncoherent, because although mvebu_hwcc_notifier() after that commit still marks then as coherent, the arm_coherent_dma_ops() function, which is called later, overwrites this setting, since it is being called from drivers/of/device.c with coherency parameter determined by of_dma_is_coherent(), and the device-trees do not declare the 'dma-coherent' property.
Fix this by defaulting never clearing the dma_coherent flag in arm_coherent_dma_ops().
--- arch/arm/mm/dma-mapping.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/arm/mm/dma-mapping.c +10 -2
@@ -1769,8 +1769,16 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) { }void arch_setup_dma_ops (struct device *dev,u64 dma_base,u64 size,const struct iommu_ops *iommu,bool coherent) { - dev->archdata.dma_coherent = coherent; - dev->dma_coherent = coherent; +/* +* Due to legacy code that sets the ->dma_coherent flag from a bus +* notifier we can't just assign coherent to the ->dma_coherent flag +* here, but instead have to make sure we only set but never clear it +* for now. +*/ +if (coherent) { + dev->archdata.dma_coherent = true; + dev->dma_coherent = true; + }/* * Don't override the dma_ops if they have already been set. Ideally
Signature · 1 line
2.30.2
PATCH 2/2 ARM/dma-mapping: remove the dma_coherent member of struct dev_archdata
In reply to Christoph HellwigSince commit ae626eb97376 ("ARM/dma-mapping: use dma-direct unconditionally") only the dma_coherent flag in struct device is used, so remove the now write only flag in struct dev_archdata.
--- arch/arm/include/asm/device.h | 1 - arch/arm/mm/dma-mapping.c | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-)
arch/arm/include/asm/device.h +0 -1
@@ -9,7 +9,6 @@ struct dev_archdata {#ifdef CONFIG_ARM_DMA_USE_IOMMU struct dma_iommu_mapping *mapping;#endif - unsigned int dma_coherent:1; unsigned int dma_ops_setup:1; };
arch/arm/mm/dma-mapping.c +1 -3
@@ -1775,10 +1775,8 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,* here, but instead have to make sure we only set but never clear it * for now. */ -if (coherent) { - dev->archdata.dma_coherent = true; +if (coherent) dev->dma_coherent = true; - }/* * Don't override the dma_ops if they have already been set. Ideally
Signature · 1 line
2.30.2
Quoted 8 lines · Christoph Hellwig
Hi Russell,
the first patch fixes the regression that overwrites ->dma_coherent after the mvebu notifier set it, and the second one removes a now unused field in the arm
arch_devdata.Let me know if you want to take these, or if I should route them through the dma-mapping tree that introduced this problem.
I think it would make sense to send them through the dma-mapping tree, so for the series:
Thanks for fixing this!
Signature · 7 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel