]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
powerpc: fsl_pci, swiotlb: Move controller ops from ppc_md to controller_ops
authorDaniel Axtens <dja@axtens.net>
Fri, 10 Apr 2015 03:15:47 +0000 (13:15 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 11 Apr 2015 10:49:17 +0000 (20:49 +1000)
Move the installation of DMA operations out of swiotlb's subsys
initcall, and into the generic PCI controller operations struct.

These ops are installed conditionally, based on the ppc_swiotlb_enable
global. The global can be set in two places:
 - swiotlb_detect_4g, which is always called at the arch initcall level
 - setup_pci_atmu, which is called as part of the fsl_add_bridge and
fsl_pci_syscore_do_resume.

fsl_pci_syscore_do_resume is called late enough that any changes as a
result of that call will have no effect.

As such, if we test the global and set the operations as part of
fsl_add_bridge, after the call to setup_pci_atmu, we can be confident
that it will cover all the PCI implementations affected by the changes
to dma-swiotlb.c.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Acked-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/dma-swiotlb.c
arch/powerpc/sysdev/fsl_pci.c

index 735979764cd4ce6b9100051b88e947b02bc4f9b2..6e8d764ce47bc22ee2c721ea9da6edf6dd01a400 100644 (file)
@@ -116,16 +116,13 @@ void __init swiotlb_detect_4g(void)
        }
 }
 
-static int __init swiotlb_late_init(void)
+static int __init check_swiotlb_enabled(void)
 {
-       if (ppc_swiotlb_enable) {
+       if (ppc_swiotlb_enable)
                swiotlb_print_info();
-               set_pci_dma_ops(&swiotlb_dma_ops);
-               ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-       } else {
+       else
                swiotlb_free();
-       }
 
        return 0;
 }
-subsys_initcall(swiotlb_late_init);
+subsys_initcall(check_swiotlb_enabled);
index 4b74c276e427e49ccf7cc748f496a7d6ba650a6e..9a8fcf0d79d7e1b42a875b386a7458f49f26867b 100644 (file)
@@ -111,6 +111,18 @@ static struct pci_ops fsl_indirect_pcie_ops =
 #define MAX_PHYS_ADDR_BITS     40
 static u64 pci64_dma_offset = 1ull << MAX_PHYS_ADDR_BITS;
 
+#ifdef CONFIG_SWIOTLB
+static void setup_swiotlb_ops(struct pci_controller *hose)
+{
+       if (ppc_swiotlb_enable) {
+               hose->controller_ops.dma_dev_setup = pci_dma_dev_setup_swiotlb;
+               set_pci_dma_ops(&swiotlb_dma_ops);
+       }
+}
+#else
+static inline void setup_swiotlb_ops(struct pci_controller *hose) {}
+#endif
+
 static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)
 {
        if (!dev->dma_mask || !dma_supported(dev, dma_mask))
@@ -548,6 +560,9 @@ int fsl_add_bridge(struct platform_device *pdev, int is_primary)
        /* Setup PEX window registers */
        setup_pci_atmu(hose);
 
+       /* Set up controller operations */
+       setup_swiotlb_ops(hose);
+
        return 0;
 
 no_bridge: