linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* mvebu DMA fix
@ 2022-10-06  7:48 Christoph Hellwig
  2022-10-06  7:48 ` [PATCH 1/2] ARM/dma-mappіng: don't override ->dma_coherent when set from a bus notifier Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christoph Hellwig @ 2022-10-06  7:48 UTC (permalink / raw)
  To: Russell King; +Cc: Robin Murphy, linux-arm-kernel, iommu, Marek Behún

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.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] ARM/dma-mappіng: don't override ->dma_coherent when set from a bus notifier
  2022-10-06  7:48 mvebu DMA fix Christoph Hellwig
@ 2022-10-06  7:48 ` Christoph Hellwig
  2022-10-06  7:48 ` [PATCH 2/2] ARM/dma-mapping: remove the dma_coherent member of struct dev_archdata Christoph Hellwig
  2022-10-06 11:52 ` mvebu DMA fix Russell King (Oracle)
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2022-10-06  7:48 UTC (permalink / raw)
  To: Russell King; +Cc: Robin Murphy, linux-arm-kernel, iommu, Marek Behún

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().

Fixes: ae626eb97376 ("ARM/dma-mapping: use dma-direct unconditionally")
Reported-by: Marek Behún <kabel@kernel.org>
Tested-by: Marek Behún <kabel@kernel.org>
---
 arch/arm/mm/dma-mapping.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 089c9c644cce2..bfc7476f14114 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -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
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ARM/dma-mapping: remove the dma_coherent member of struct dev_archdata
  2022-10-06  7:48 mvebu DMA fix Christoph Hellwig
  2022-10-06  7:48 ` [PATCH 1/2] ARM/dma-mappіng: don't override ->dma_coherent when set from a bus notifier Christoph Hellwig
@ 2022-10-06  7:48 ` Christoph Hellwig
  2022-10-06 11:52 ` mvebu DMA fix Russell King (Oracle)
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2022-10-06  7:48 UTC (permalink / raw)
  To: Russell King; +Cc: Robin Murphy, linux-arm-kernel, iommu, Marek Behún

Since 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/arm/include/asm/device.h | 1 -
 arch/arm/mm/dma-mapping.c     | 4 +---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/device.h b/arch/arm/include/asm/device.h
index 8754c0f5fc904..c6beb1708c64b 100644
--- a/arch/arm/include/asm/device.h
+++ b/arch/arm/include/asm/device.h
@@ -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;
 };
 
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index bfc7476f14114..f60d6b4afe5df 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -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
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: mvebu DMA fix
  2022-10-06  7:48 mvebu DMA fix Christoph Hellwig
  2022-10-06  7:48 ` [PATCH 1/2] ARM/dma-mappіng: don't override ->dma_coherent when set from a bus notifier Christoph Hellwig
  2022-10-06  7:48 ` [PATCH 2/2] ARM/dma-mapping: remove the dma_coherent member of struct dev_archdata Christoph Hellwig
@ 2022-10-06 11:52 ` Russell King (Oracle)
  2 siblings, 0 replies; 4+ messages in thread
From: Russell King (Oracle) @ 2022-10-06 11:52 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Robin Murphy, linux-arm-kernel, iommu, Marek Behún

On Thu, Oct 06, 2022 at 09:48:22AM +0200, Christoph Hellwig wrote:
> 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:

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Thanks for fixing this!

-- 
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
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-06 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06  7:48 mvebu DMA fix Christoph Hellwig
2022-10-06  7:48 ` [PATCH 1/2] ARM/dma-mappіng: don't override ->dma_coherent when set from a bus notifier Christoph Hellwig
2022-10-06  7:48 ` [PATCH 2/2] ARM/dma-mapping: remove the dma_coherent member of struct dev_archdata Christoph Hellwig
2022-10-06 11:52 ` mvebu DMA fix Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).