Skip to contentSkip to conversation

ARM: mvebu: use hardware I/O coherency also for PCI devices

PATCH Superseded Thomas Petazzoni 2 participants 5 messages May 13, 2014 – May 16, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ARM: mvebu: use hardware I/O coherency also for PCI devices

Since the beginning of the introduction of hardware I/O coherency support for Armada 370 and Armada XP, the special DMA operations should have applied to all DMA capable devices. Unfortunately, while the original code properly took into account platform devices, it didn't take into account PCI devices, which can also be DMA masters.

This commit fixes that by registering a bus notifier on pci_bus_type, to register our custom DMA operations, like is already done for platform devices. While doing this, we also rename mvebu_hwcc_platform_notifier() to mvebu_hwcc_notifier() and mvebu_hwcc_platform_nb to mvebu_hwcc_nb because they are no longer specific to platform devices.

Fixes e60304f8cb7b ("arm: mvebu: Add hardware I/O Coherency support")
Cc <[email protected]> # v3.8+

---
Changes since v1:
* Fix stupid tab vs. space problem

Applies to mvebu/soc.

Whether this commit qualifies as stable material can be discussed. Technically, it was a mistake from the original I/O coherency implementation. But in practice, besides not using the I/O coherency, I don't think it's causing any specific problem other than DMA transactions on PCI devices triggering unneeded cache maintenance operations. So I'll leave it to the mvebu maintainers to decide whether this qualifies as stable material or not. I've included the relevant Fixes: and Cc: fields, but don't hesitate to rip them out if you don't think this should go to stable.

---
 arch/arm/mach-mvebu/coherency.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/coherency.c +16 -5
index d5a975b..5723178 100644
@@ -29,6 +29,7 @@
 #include <linux/slab.h>
 #include <linux/mbus.h>
 #include <linux/clk.h>
+#include <linux/pci.h>
 #include <asm/smp_plat.h>
 #include <asm/cacheflush.h>
 #include "armada-370-xp.h"
@@ -274,8 +275,8 @@ static struct dma_map_ops mvebu_hwcc_dma_ops = {
 	.set_dma_mask		= arm_dma_set_mask,
 };
 
-static int mvebu_hwcc_platform_notifier(struct notifier_block *nb,
-				       unsigned long event, void *__dev)
+static int mvebu_hwcc_notifier(struct notifier_block *nb,
+			       unsigned long event, void *__dev)
 {
 	struct device *dev = __dev;
 
@@ -286,8 +287,8 @@ static int mvebu_hwcc_platform_notifier(struct notifier_block *nb,
 	return NOTIFY_OK;
 }
 
-static struct notifier_block mvebu_hwcc_platform_nb = {
-	.notifier_call = mvebu_hwcc_platform_notifier,
+static struct notifier_block mvebu_hwcc_nb = {
+	.notifier_call = mvebu_hwcc_notifier,
 };
 
 static void __init armada_370_coherency_init(struct device_node *np)
@@ -375,9 +376,19 @@ static int __init coherency_late_init(void)
 	}
 
 	bus_register_notifier(&platform_bus_type,
-			      &mvebu_hwcc_platform_nb);
+			      &mvebu_hwcc_nb);
 
 	return 0;
 }
 
 postcore_initcall(coherency_late_init);
+
+static int __init coherency_pci_init(void)
+{
+	if (coherency_available())
+		bus_register_notifier(&pci_bus_type,
+				       &mvebu_hwcc_nb);
+	return 0;
+}
+
+arch_initcall(coherency_pci_init);
Signature · 1 line
1.9.2
#1 lore raw

PATCH v2 1/1 ARM: mvebu: use hardware I/O coherency also for PCI devices

Quoted 22 lines · Thomas Petazzoni

Since the beginning of the introduction of hardware I/O coherency support for Armada 370 and Armada XP, the special DMA operations should have applied to all DMA capable devices. Unfortunately, while the original code properly took into account platform devices, it didn't take into account PCI devices, which can also be DMA masters.

This commit fixes that by registering a bus notifier on pci_bus_type, to register our custom DMA operations, like is already done for platform devices. While doing this, we also rename mvebu_hwcc_platform_notifier() to mvebu_hwcc_notifier() and mvebu_hwcc_platform_nb to mvebu_hwcc_nb because they are no longer specific to platform devices.

Fixes e60304f8cb7b ("arm: mvebu: Add hardware I/O Coherency support")
Cc <[email protected]> # v3.8+

---
Changes since v1:
* Fix stupid tab vs. space problem

Applies to mvebu/soc.

Quoted 9 lines

Whether this commit qualifies as stable material can be discussed. Technically, it was a mistake from the original I/O coherency implementation. But in practice, besides not using the I/O coherency, I don't think it's causing any specific problem other than DMA transactions on PCI devices triggering unneeded cache maintenance operations. So I'll leave it to the mvebu maintainers to decide whether this qualifies as stable material or not. I've included the relevant Fixes: and Cc: fields, but don't hesitate to rip them out if you don't think this should go to stable.

If nothing is broken for users, I see no point backporting it. Feel free to convince me otherwise...

thx,

Jason.

#2 lore raw

PATCH v2 1/1 ARM: mvebu: use hardware I/O coherency also for PCI devices

Dear Jason Cooper,

Quoted 10 lines · Jason Cooper
Quoted 9 lines

Whether this commit qualifies as stable material can be discussed. Technically, it was a mistake from the original I/O coherency implementation. But in practice, besides not using the I/O coherency, I don't think it's causing any specific problem other than DMA transactions on PCI devices triggering unneeded cache maintenance operations. So I'll leave it to the mvebu maintainers to decide whether this qualifies as stable material or not. I've included the relevant Fixes: and Cc: fields, but don't hesitate to rip them out if you don't think this should go to stable.

Quoted 2 lines

If nothing is broken for users, I see no point backporting it. Feel free to convince me otherwise...

As far as I can remember, it isn't broken, it's just sub-optimal. The only situation where it would cause problem is on Armada 375/Armada 38x with SMP support, due to the SMP/PCIe/PL310 deadlock for which I've sent a v2 of the patches today on LAKML. In this case, not using our specific DMA operations would cause many PL310 cache maintenance operations, and therefore a high chance of hitting the deadlock. However, this is only a new problem in 3.16, which has the SMP support for Armada 375/Armada 38x.

So, as I said, feel free to drop the stable tags :)

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Applied
#3 lore raw

PATCH v2 1/1 ARM: mvebu: use hardware I/O coherency also for PCI devices

In reply to Thomas Petazzoni
Quoted 31 lines · Thomas Petazzoni

Since the beginning of the introduction of hardware I/O coherency support for Armada 370 and Armada XP, the special DMA operations should have applied to all DMA capable devices. Unfortunately, while the original code properly took into account platform devices, it didn't take into account PCI devices, which can also be DMA masters.

This commit fixes that by registering a bus notifier on pci_bus_type, to register our custom DMA operations, like is already done for platform devices. While doing this, we also rename mvebu_hwcc_platform_notifier() to mvebu_hwcc_notifier() and mvebu_hwcc_platform_nb to mvebu_hwcc_nb because they are no longer specific to platform devices.

Fixes e60304f8cb7b ("arm: mvebu: Add hardware I/O Coherency support")
Cc <[email protected]> # v3.8+

---
Changes since v1:
* Fix stupid tab vs. space problem

Applies to mvebu/soc.

Whether this commit qualifies as stable material can be discussed. Technically, it was a mistake from the original I/O coherency implementation. But in practice, besides not using the I/O coherency, I don't think it's causing any specific problem other than DMA transactions on PCI devices triggering unneeded cache maintenance operations. So I'll leave it to the mvebu maintainers to decide whether this qualifies as stable material or not. I've included the relevant Fixes: and Cc: fields, but don't hesitate to rip them out if you don't think this should go to stable.

Quoted 3 lines
---
 arch/arm/mach-mvebu/coherency.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

Applied to mvebu/soc w/o the stable tags.

thx,

Jason.

Applied
#4 lore raw

PATCH v2 1/1 ARM: mvebu: use hardware I/O coherency also for PCI devices

In reply to Thomas Petazzoni
Quoted 31 lines · Thomas Petazzoni

Since the beginning of the introduction of hardware I/O coherency support for Armada 370 and Armada XP, the special DMA operations should have applied to all DMA capable devices. Unfortunately, while the original code properly took into account platform devices, it didn't take into account PCI devices, which can also be DMA masters.

This commit fixes that by registering a bus notifier on pci_bus_type, to register our custom DMA operations, like is already done for platform devices. While doing this, we also rename mvebu_hwcc_platform_notifier() to mvebu_hwcc_notifier() and mvebu_hwcc_platform_nb to mvebu_hwcc_nb because they are no longer specific to platform devices.

Fixes e60304f8cb7b ("arm: mvebu: Add hardware I/O Coherency support")
Cc <[email protected]> # v3.8+

---
Changes since v1:
* Fix stupid tab vs. space problem

Applies to mvebu/soc.

Whether this commit qualifies as stable material can be discussed. Technically, it was a mistake from the original I/O coherency implementation. But in practice, besides not using the I/O coherency, I don't think it's causing any specific problem other than DMA transactions on PCI devices triggering unneeded cache maintenance operations. So I'll leave it to the mvebu maintainers to decide whether this qualifies as stable material or not. I've included the relevant Fixes: and Cc: fields, but don't hesitate to rip them out if you don't think this should go to stable.

Quoted 3 lines
---
 arch/arm/mach-mvebu/coherency.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

Applied to mvebu/soc w/o the stable tags.

thx,

Jason.