diff options
author | Daniel Axtens <dja@axtens.net> | 2015-03-31 01:00:56 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-04-11 06:49:18 -0400 |
commit | 467efc2e4fdc44e6cd4be7dd4adf01c14b3d148e (patch) | |
tree | d8702b30db2eedb190e82beb802ac30275af6ea7 | |
parent | 9c1368fc50e78ff862a05d1a0995ce44413c49e2 (diff) |
powerpc: Remove shims for pci_controller_ops operations
Remove shims, patch callsites to use pci_controller_ops
versions instead.
Also move back the probe mode defines, as explained in the patch
for pci_probe_mode.
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/include/asm/machdep.h | 14 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pci-bridge.h | 84 | ||||
-rw-r--r-- | arch/powerpc/include/asm/pci.h | 5 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci-common.c | 43 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci-hotplug.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_of_scan.c | 6 | ||||
-rw-r--r-- | arch/powerpc/sysdev/dart_iommu.c | 5 |
7 files changed, 50 insertions, 113 deletions
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index e29f058c0903..5c19ac527a8e 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h | |||
@@ -103,9 +103,6 @@ struct machdep_calls { | |||
103 | #endif | 103 | #endif |
104 | #endif /* CONFIG_PPC64 */ | 104 | #endif /* CONFIG_PPC64 */ |
105 | 105 | ||
106 | void (*pci_dma_dev_setup)(struct pci_dev *dev); | ||
107 | void (*pci_dma_bus_setup)(struct pci_bus *bus); | ||
108 | |||
109 | /* Platform set_dma_mask and dma_get_required_mask overrides */ | 106 | /* Platform set_dma_mask and dma_get_required_mask overrides */ |
110 | int (*dma_set_mask)(struct device *dev, u64 dma_mask); | 107 | int (*dma_set_mask)(struct device *dev, u64 dma_mask); |
111 | u64 (*dma_get_required_mask)(struct device *dev); | 108 | u64 (*dma_get_required_mask)(struct device *dev); |
@@ -127,7 +124,6 @@ struct machdep_calls { | |||
127 | /* PCI stuff */ | 124 | /* PCI stuff */ |
128 | /* Called after allocating resources */ | 125 | /* Called after allocating resources */ |
129 | void (*pcibios_fixup)(void); | 126 | void (*pcibios_fixup)(void); |
130 | int (*pci_probe_mode)(struct pci_bus *); | ||
131 | void (*pci_irq_fixup)(struct pci_dev *dev); | 127 | void (*pci_irq_fixup)(struct pci_dev *dev); |
132 | int (*pcibios_root_bridge_prepare)(struct pci_host_bridge | 128 | int (*pcibios_root_bridge_prepare)(struct pci_host_bridge |
133 | *bridge); | 129 | *bridge); |
@@ -237,19 +233,9 @@ struct machdep_calls { | |||
237 | /* Called for each PCI bus in the system when it's probed */ | 233 | /* Called for each PCI bus in the system when it's probed */ |
238 | void (*pcibios_fixup_bus)(struct pci_bus *); | 234 | void (*pcibios_fixup_bus)(struct pci_bus *); |
239 | 235 | ||
240 | /* Called when pci_enable_device() is called. Returns true to | ||
241 | * allow assignment/enabling of the device. */ | ||
242 | bool (*pcibios_enable_device_hook)(struct pci_dev *); | ||
243 | |||
244 | /* Called after scan and before resource survey */ | 236 | /* Called after scan and before resource survey */ |
245 | void (*pcibios_fixup_phb)(struct pci_controller *hose); | 237 | void (*pcibios_fixup_phb)(struct pci_controller *hose); |
246 | 238 | ||
247 | /* Called during PCI resource reassignment */ | ||
248 | resource_size_t (*pcibios_window_alignment)(struct pci_bus *, unsigned long type); | ||
249 | |||
250 | /* Reset the secondary bus of bridge */ | ||
251 | void (*pcibios_reset_secondary_bus)(struct pci_dev *dev); | ||
252 | |||
253 | /* Called to shutdown machine specific hardware not already controlled | 239 | /* Called to shutdown machine specific hardware not already controlled |
254 | * by other drivers. | 240 | * by other drivers. |
255 | */ | 241 | */ |
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h index bb34b1eebfbe..7d972bc85638 100644 --- a/arch/powerpc/include/asm/pci-bridge.h +++ b/arch/powerpc/include/asm/pci-bridge.h | |||
@@ -12,11 +12,6 @@ | |||
12 | #include <linux/ioport.h> | 12 | #include <linux/ioport.h> |
13 | #include <asm-generic/pci-bridge.h> | 13 | #include <asm-generic/pci-bridge.h> |
14 | 14 | ||
15 | /* Return values for pci_controller_ops.probe_mode function */ | ||
16 | #define PCI_PROBE_NONE -1 /* Don't look at this bus at all */ | ||
17 | #define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */ | ||
18 | #define PCI_PROBE_DEVTREE 1 /* Instantiate from device tree */ | ||
19 | |||
20 | struct device_node; | 15 | struct device_node; |
21 | 16 | ||
22 | /* | 17 | /* |
@@ -284,84 +279,5 @@ static inline int pcibios_vaddr_is_ioport(void __iomem *address) | |||
284 | } | 279 | } |
285 | #endif /* CONFIG_PCI */ | 280 | #endif /* CONFIG_PCI */ |
286 | 281 | ||
287 | /* | ||
288 | * Shims to prefer pci_controller version over ppc_md where available. | ||
289 | */ | ||
290 | static inline void pci_dma_dev_setup(struct pci_dev *dev) | ||
291 | { | ||
292 | struct pci_controller *phb = pci_bus_to_host(dev->bus); | ||
293 | |||
294 | if (phb->controller_ops.dma_dev_setup) | ||
295 | phb->controller_ops.dma_dev_setup(dev); | ||
296 | else if (ppc_md.pci_dma_dev_setup) | ||
297 | ppc_md.pci_dma_dev_setup(dev); | ||
298 | } | ||
299 | |||
300 | static inline void pci_dma_bus_setup(struct pci_bus *bus) | ||
301 | { | ||
302 | struct pci_controller *phb = pci_bus_to_host(bus); | ||
303 | |||
304 | if (phb->controller_ops.dma_bus_setup) | ||
305 | phb->controller_ops.dma_bus_setup(bus); | ||
306 | else if (ppc_md.pci_dma_bus_setup) | ||
307 | ppc_md.pci_dma_bus_setup(bus); | ||
308 | } | ||
309 | |||
310 | static inline int pci_probe_mode(struct pci_bus *bus) | ||
311 | { | ||
312 | struct pci_controller *phb = pci_bus_to_host(bus); | ||
313 | |||
314 | if (phb->controller_ops.probe_mode) | ||
315 | return phb->controller_ops.probe_mode(bus); | ||
316 | if (ppc_md.pci_probe_mode) | ||
317 | return ppc_md.pci_probe_mode(bus); | ||
318 | return PCI_PROBE_NORMAL; | ||
319 | } | ||
320 | |||
321 | static inline bool pcibios_enable_device_hook(struct pci_dev *dev) | ||
322 | { | ||
323 | struct pci_controller *phb = pci_bus_to_host(dev->bus); | ||
324 | |||
325 | if (phb->controller_ops.enable_device_hook) | ||
326 | return phb->controller_ops.enable_device_hook(dev); | ||
327 | if (ppc_md.pcibios_enable_device_hook) | ||
328 | return ppc_md.pcibios_enable_device_hook(dev); | ||
329 | return true; | ||
330 | } | ||
331 | |||
332 | static inline resource_size_t pci_window_alignment(struct pci_bus *bus, | ||
333 | unsigned long type) | ||
334 | { | ||
335 | struct pci_controller *phb = pci_bus_to_host(bus); | ||
336 | |||
337 | if (phb->controller_ops.window_alignment) | ||
338 | return phb->controller_ops.window_alignment(bus, type); | ||
339 | if (ppc_md.pcibios_window_alignment) | ||
340 | return ppc_md.pcibios_window_alignment(bus, type); | ||
341 | |||
342 | /* | ||
343 | * PCI core will figure out the default | ||
344 | * alignment: 4KiB for I/O and 1MiB for | ||
345 | * memory window. | ||
346 | */ | ||
347 | return 1; | ||
348 | } | ||
349 | |||
350 | static inline void pcibios_reset_secondary_bus_shim(struct pci_dev *dev) | ||
351 | { | ||
352 | struct pci_controller *phb = pci_bus_to_host(dev->bus); | ||
353 | |||
354 | if (phb->controller_ops.reset_secondary_bus) | ||
355 | phb->controller_ops.reset_secondary_bus(dev); | ||
356 | else if (ppc_md.pcibios_reset_secondary_bus) | ||
357 | ppc_md.pcibios_reset_secondary_bus(dev); | ||
358 | else | ||
359 | /* | ||
360 | * Fallback to the generic function if no | ||
361 | * platform-specific one is provided | ||
362 | */ | ||
363 | pci_reset_secondary_bus(dev); | ||
364 | } | ||
365 | |||
366 | #endif /* __KERNEL__ */ | 282 | #endif /* __KERNEL__ */ |
367 | #endif /* _ASM_POWERPC_PCI_BRIDGE_H */ | 283 | #endif /* _ASM_POWERPC_PCI_BRIDGE_H */ |
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index 8745067ac702..4aef8d660999 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h | |||
@@ -22,6 +22,11 @@ | |||
22 | 22 | ||
23 | #include <asm-generic/pci-dma-compat.h> | 23 | #include <asm-generic/pci-dma-compat.h> |
24 | 24 | ||
25 | /* Return values for pci_controller_ops.probe_mode function */ | ||
26 | #define PCI_PROBE_NONE -1 /* Don't look at this bus at all */ | ||
27 | #define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */ | ||
28 | #define PCI_PROBE_DEVTREE 1 /* Instantiate from device tree */ | ||
29 | |||
25 | #define PCIBIOS_MIN_IO 0x1000 | 30 | #define PCIBIOS_MIN_IO 0x1000 |
26 | #define PCIBIOS_MIN_MEM 0x10000000 | 31 | #define PCIBIOS_MIN_MEM 0x10000000 |
27 | 32 | ||
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 759eb1c87638..9052b4fbc41f 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
@@ -109,12 +109,29 @@ void pcibios_free_controller(struct pci_controller *phb) | |||
109 | resource_size_t pcibios_window_alignment(struct pci_bus *bus, | 109 | resource_size_t pcibios_window_alignment(struct pci_bus *bus, |
110 | unsigned long type) | 110 | unsigned long type) |
111 | { | 111 | { |
112 | return pci_window_alignment(bus, type); | 112 | struct pci_controller *phb = pci_bus_to_host(bus); |
113 | |||
114 | if (phb->controller_ops.window_alignment) | ||
115 | return phb->controller_ops.window_alignment(bus, type); | ||
116 | |||
117 | /* | ||
118 | * PCI core will figure out the default | ||
119 | * alignment: 4KiB for I/O and 1MiB for | ||
120 | * memory window. | ||
121 | */ | ||
122 | return 1; | ||
113 | } | 123 | } |
114 | 124 | ||
115 | void pcibios_reset_secondary_bus(struct pci_dev *dev) | 125 | void pcibios_reset_secondary_bus(struct pci_dev *dev) |
116 | { | 126 | { |
117 | pcibios_reset_secondary_bus_shim(dev); | 127 | struct pci_controller *phb = pci_bus_to_host(dev->bus); |
128 | |||
129 | if (phb->controller_ops.reset_secondary_bus) { | ||
130 | phb->controller_ops.reset_secondary_bus(dev); | ||
131 | return; | ||
132 | } | ||
133 | |||
134 | pci_reset_secondary_bus(dev); | ||
118 | } | 135 | } |
119 | 136 | ||
120 | static resource_size_t pcibios_io_size(const struct pci_controller *hose) | 137 | static resource_size_t pcibios_io_size(const struct pci_controller *hose) |
@@ -929,6 +946,8 @@ static void pcibios_fixup_bridge(struct pci_bus *bus) | |||
929 | 946 | ||
930 | void pcibios_setup_bus_self(struct pci_bus *bus) | 947 | void pcibios_setup_bus_self(struct pci_bus *bus) |
931 | { | 948 | { |
949 | struct pci_controller *phb; | ||
950 | |||
932 | /* Fix up the bus resources for P2P bridges */ | 951 | /* Fix up the bus resources for P2P bridges */ |
933 | if (bus->self != NULL) | 952 | if (bus->self != NULL) |
934 | pcibios_fixup_bridge(bus); | 953 | pcibios_fixup_bridge(bus); |
@@ -940,11 +959,14 @@ void pcibios_setup_bus_self(struct pci_bus *bus) | |||
940 | ppc_md.pcibios_fixup_bus(bus); | 959 | ppc_md.pcibios_fixup_bus(bus); |
941 | 960 | ||
942 | /* Setup bus DMA mappings */ | 961 | /* Setup bus DMA mappings */ |
943 | pci_dma_bus_setup(bus); | 962 | phb = pci_bus_to_host(bus); |
963 | if (phb->controller_ops.dma_bus_setup) | ||
964 | phb->controller_ops.dma_bus_setup(bus); | ||
944 | } | 965 | } |
945 | 966 | ||
946 | static void pcibios_setup_device(struct pci_dev *dev) | 967 | static void pcibios_setup_device(struct pci_dev *dev) |
947 | { | 968 | { |
969 | struct pci_controller *phb; | ||
948 | /* Fixup NUMA node as it may not be setup yet by the generic | 970 | /* Fixup NUMA node as it may not be setup yet by the generic |
949 | * code and is needed by the DMA init | 971 | * code and is needed by the DMA init |
950 | */ | 972 | */ |
@@ -955,7 +977,9 @@ static void pcibios_setup_device(struct pci_dev *dev) | |||
955 | set_dma_offset(&dev->dev, PCI_DRAM_OFFSET); | 977 | set_dma_offset(&dev->dev, PCI_DRAM_OFFSET); |
956 | 978 | ||
957 | /* Additional platform DMA/iommu setup */ | 979 | /* Additional platform DMA/iommu setup */ |
958 | pci_dma_dev_setup(dev); | 980 | phb = pci_bus_to_host(dev->bus); |
981 | if (phb->controller_ops.dma_dev_setup) | ||
982 | phb->controller_ops.dma_dev_setup(dev); | ||
959 | 983 | ||
960 | /* Read default IRQs and fixup if necessary */ | 984 | /* Read default IRQs and fixup if necessary */ |
961 | pci_read_irq_line(dev); | 985 | pci_read_irq_line(dev); |
@@ -1435,8 +1459,11 @@ EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus); | |||
1435 | 1459 | ||
1436 | int pcibios_enable_device(struct pci_dev *dev, int mask) | 1460 | int pcibios_enable_device(struct pci_dev *dev, int mask) |
1437 | { | 1461 | { |
1438 | if (!pcibios_enable_device_hook(dev)) | 1462 | struct pci_controller *phb = pci_bus_to_host(dev->bus); |
1439 | return -EINVAL; | 1463 | |
1464 | if (phb->controller_ops.enable_device_hook) | ||
1465 | if (!phb->controller_ops.enable_device_hook(dev)) | ||
1466 | return -EINVAL; | ||
1440 | 1467 | ||
1441 | return pci_enable_resources(dev, mask); | 1468 | return pci_enable_resources(dev, mask); |
1442 | } | 1469 | } |
@@ -1608,8 +1635,8 @@ void pcibios_scan_phb(struct pci_controller *hose) | |||
1608 | 1635 | ||
1609 | /* Get probe mode and perform scan */ | 1636 | /* Get probe mode and perform scan */ |
1610 | mode = PCI_PROBE_NORMAL; | 1637 | mode = PCI_PROBE_NORMAL; |
1611 | if (node) | 1638 | if (node && hose->controller_ops.probe_mode) |
1612 | mode = pci_probe_mode(bus); | 1639 | mode = hose->controller_ops.probe_mode(bus); |
1613 | pr_debug(" probe mode: %d\n", mode); | 1640 | pr_debug(" probe mode: %d\n", mode); |
1614 | if (mode == PCI_PROBE_DEVTREE) | 1641 | if (mode == PCI_PROBE_DEVTREE) |
1615 | of_scan_bus(node, bus); | 1642 | of_scan_bus(node, bus); |
diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c index 27116b1b2d14..7ed85a69a9c2 100644 --- a/arch/powerpc/kernel/pci-hotplug.c +++ b/arch/powerpc/kernel/pci-hotplug.c | |||
@@ -73,12 +73,16 @@ void pcibios_add_pci_devices(struct pci_bus * bus) | |||
73 | { | 73 | { |
74 | int slotno, mode, pass, max; | 74 | int slotno, mode, pass, max; |
75 | struct pci_dev *dev; | 75 | struct pci_dev *dev; |
76 | struct pci_controller *phb; | ||
76 | struct device_node *dn = pci_bus_to_OF_node(bus); | 77 | struct device_node *dn = pci_bus_to_OF_node(bus); |
77 | 78 | ||
78 | eeh_add_device_tree_early(PCI_DN(dn)); | 79 | eeh_add_device_tree_early(PCI_DN(dn)); |
79 | 80 | ||
81 | phb = pci_bus_to_host(bus); | ||
82 | |||
80 | mode = PCI_PROBE_NORMAL; | 83 | mode = PCI_PROBE_NORMAL; |
81 | mode = pci_probe_mode(bus); | 84 | if (phb->controller_ops.probe_mode) |
85 | mode = phb->controller_ops.probe_mode(bus); | ||
82 | 86 | ||
83 | if (mode == PCI_PROBE_DEVTREE) { | 87 | if (mode == PCI_PROBE_DEVTREE) { |
84 | /* use ofdt-based probe */ | 88 | /* use ofdt-based probe */ |
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index 4ee63c4f077e..42e02a2d570b 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c | |||
@@ -207,6 +207,7 @@ void of_scan_pci_bridge(struct pci_dev *dev) | |||
207 | { | 207 | { |
208 | struct device_node *node = dev->dev.of_node; | 208 | struct device_node *node = dev->dev.of_node; |
209 | struct pci_bus *bus; | 209 | struct pci_bus *bus; |
210 | struct pci_controller *phb; | ||
210 | const __be32 *busrange, *ranges; | 211 | const __be32 *busrange, *ranges; |
211 | int len, i, mode; | 212 | int len, i, mode; |
212 | struct pci_bus_region region; | 213 | struct pci_bus_region region; |
@@ -286,8 +287,11 @@ void of_scan_pci_bridge(struct pci_dev *dev) | |||
286 | bus->number); | 287 | bus->number); |
287 | pr_debug(" bus name: %s\n", bus->name); | 288 | pr_debug(" bus name: %s\n", bus->name); |
288 | 289 | ||
290 | phb = pci_bus_to_host(bus); | ||
291 | |||
289 | mode = PCI_PROBE_NORMAL; | 292 | mode = PCI_PROBE_NORMAL; |
290 | mode = pci_probe_mode(bus); | 293 | if (phb->controller_ops.probe_mode) |
294 | mode = phb->controller_ops.probe_mode(bus); | ||
291 | pr_debug(" probe mode: %d\n", mode); | 295 | pr_debug(" probe mode: %d\n", mode); |
292 | 296 | ||
293 | if (mode == PCI_PROBE_DEVTREE) | 297 | if (mode == PCI_PROBE_DEVTREE) |
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c index 120e96a9e2cb..87b80009bc9f 100644 --- a/arch/powerpc/sysdev/dart_iommu.c +++ b/arch/powerpc/sysdev/dart_iommu.c | |||
@@ -398,9 +398,6 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops) | |||
398 | if (controller_ops) { | 398 | if (controller_ops) { |
399 | controller_ops->dma_dev_setup = pci_dma_dev_setup_dart; | 399 | controller_ops->dma_dev_setup = pci_dma_dev_setup_dart; |
400 | controller_ops->dma_bus_setup = pci_dma_bus_setup_dart; | 400 | controller_ops->dma_bus_setup = pci_dma_bus_setup_dart; |
401 | } else { | ||
402 | ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_dart; | ||
403 | ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_dart; | ||
404 | } | 401 | } |
405 | /* Setup pci_dma ops */ | 402 | /* Setup pci_dma ops */ |
406 | set_pci_dma_ops(&dma_iommu_ops); | 403 | set_pci_dma_ops(&dma_iommu_ops); |
@@ -412,8 +409,6 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops) | |||
412 | controller_ops->dma_dev_setup = NULL; | 409 | controller_ops->dma_dev_setup = NULL; |
413 | controller_ops->dma_bus_setup = NULL; | 410 | controller_ops->dma_bus_setup = NULL; |
414 | } | 411 | } |
415 | ppc_md.pci_dma_dev_setup = NULL; | ||
416 | ppc_md.pci_dma_bus_setup = NULL; | ||
417 | 412 | ||
418 | /* Setup pci_dma ops */ | 413 | /* Setup pci_dma ops */ |
419 | set_pci_dma_ops(&dma_direct_ops); | 414 | set_pci_dma_ops(&dma_direct_ops); |