diff options
author | Ming Lei <ming.lei@canonical.com> | 2015-03-10 17:15:45 +0000 |
---|---|---|
committer | Ben Dooks <ben.dooks@codethink.co.uk> | 2015-03-10 17:15:51 +0000 |
commit | 11238ff114f0320335320d66d4edcaa8f497612b (patch) | |
tree | 782829e7f408c31ba5ffd8674df21244849bcb1c | |
parent | 876e0cb3af66bdc4bef99bc331c457e5b808227e (diff) | |
download | linux-baserock/bjdooks/m400-be2.tar.gz |
ARM64: PCI: inherit root controller's dma-coherentbaserock/bjdooks/m400-be2
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
[ben.dooks@codethink.co.uk: updated for 4.0-rc3]
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>
-rw-r--r-- | arch/arm64/kernel/pci.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 6f93c24ca801..902093ef6f5c 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -15,6 +15,7 @@ #include <linux/kernel.h> #include <linux/mm.h> #include <linux/of_pci.h> +#include <linux/of_address.h> #include <linux/of_platform.h> #include <linux/slab.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)) + dev->dev.archdata.dma_coherent = true; +} + /* * Try to assign the IRQ number from DT when adding a new device */ @@ -44,5 +60,6 @@ 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; } |