All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] ARM64: PCI: inherit root controller's dma-coherent
@ 2014-11-27  5:41 Ming Lei
  2014-11-27  7:39 ` Jon Masters
  2014-11-27  9:03 ` Arnd Bergmann
  0 siblings, 2 replies; 15+ messages in thread
From: Ming Lei @ 2014-11-27  5:41 UTC (permalink / raw)
  To: linux-arm-kernel

This patch sets pci device's dma ops as coherent if the root
controller is dma-coherent.

This patch fixes the bug in below link:

	https://bugs.launchpad.net/bugs/1386490

Cc: Catalin Marinas <Catalin.Marinas@arm.com>
Cc: Jon Masters <jcm@redhat.com>
Cc: Dann Frazier <dann.frazier@canonical.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 arch/arm64/kernel/pci.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index ce5836c..4b6444a 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -16,6 +16,7 @@
 #include <linux/mm.h>
 #include <linux/of_pci.h>
 #include <linux/of_platform.h>
+#include <linux/of_address.h>
 #include <linux/slab.h>
 
 #include <asm/pci-bridge.h>
@@ -37,6 +38,21 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
 	return res->start;
 }
 
+/* Inherit root controller's dma coherent ops */
+static void pci_dma_config(struct pci_dev *dev)
+{
+	struct pci_bus *bus = dev->bus;
+	struct device *host;
+
+	while (!pci_is_root_bus(bus)) {
+		bus = bus->parent;
+	}
+
+	host = bus->dev.parent->parent;
+	if (of_dma_is_coherent(host->of_node))
+		set_arch_dma_coherent_ops(&dev->dev);
+}
+
 /*
  * Try to assign the IRQ number from DT when adding a new device
  */
@@ -44,6 +60,7 @@ int pcibios_add_device(struct pci_dev *dev)
 {
 	dev->irq = of_irq_parse_and_map_pci(dev, 0, 0);
 
+	pci_dma_config(dev);
 	return 0;
 }
 
-- 
1.7.9.5

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

end of thread, other threads:[~2014-12-10 16:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-27  5:41 [RFC PATCH] ARM64: PCI: inherit root controller's dma-coherent Ming Lei
2014-11-27  7:39 ` Jon Masters
2014-11-27  9:05   ` Arnd Bergmann
2014-11-27 11:36     ` Catalin Marinas
2014-11-27 11:53       ` Arnd Bergmann
2014-11-27  9:03 ` Arnd Bergmann
2014-11-27 10:14   ` Ming Lei
2014-11-27 10:14     ` Ming Lei
2014-11-27 10:22   ` Will Deacon
2014-12-04  3:40   ` Ming Lei
2014-12-05 13:26     ` Grygorii Strashko
2014-12-05 16:05       ` Arnd Bergmann
2014-12-09  2:53         ` Ming Lei
2014-12-10 16:06           ` Arnd Bergmann
2014-12-10 16:23             ` Robin Murphy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.