Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pci: Make both ppc32 and ppc64 use sysdata for pci_controller

Currently, ppc32 uses sysdata for the pci_controller pointer, and
ppc64 uses it to hold the device_node pointer. This patch moves the
of_node pointer into (struct pci_bus*)->dev.of_node and
(struct pci_dev*)->dev.of_node so that sysdata can be converted to always
use the pci_controller pointer instead. It also fixes up the
allocating of pci devices so that the of_node pointer gets assigned
consistently and increments the ref count.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

+24 -42
+1
arch/microblaze/pci/pci_32.c
··· 332 332 hose->global_number); 333 333 return; 334 334 } 335 + bus.dev->of_node = of_node_get(node); 335 336 bus->secondary = hose->first_busno; 336 337 hose->bus = bus; 337 338
+5 -22
arch/powerpc/include/asm/pci-bridge.h
··· 164 164 resource_size_t cfg_addr, 165 165 resource_size_t cfg_data, u32 flags); 166 166 167 - #ifndef CONFIG_PPC64 168 - 169 167 static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus) 170 168 { 171 169 return bus->sysdata; 172 170 } 171 + 172 + #ifndef CONFIG_PPC64 173 173 174 174 static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus) 175 175 { ··· 228 228 229 229 /* Get a device_node from a pci_dev. This code must be fast except 230 230 * in the case where the sysdata is incorrect and needs to be fixed 231 - * up (this will only happen once). 232 - * In this case the sysdata will have been inherited from a PCI host 233 - * bridge or a PCI-PCI bridge further up the tree, so it will point 234 - * to a valid struct pci_dn, just not the one we want. 235 - */ 231 + * up (this will only happen once). */ 236 232 static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev) 237 233 { 238 - struct device_node *dn = dev->sysdata; 239 - struct pci_dn *pdn = dn->data; 240 - 241 - if (pdn && pdn->devfn == dev->devfn && pdn->busno == dev->bus->number) 242 - return dn; /* fast path. sysdata is good */ 243 - return fetch_dev_dn(dev); 234 + return dev->dev.of_node ? dev->dev.of_node : fetch_dev_dn(dev); 244 235 } 245 236 246 237 static inline int pci_device_from_OF_node(struct device_node *np, ··· 249 258 if (bus->self) 250 259 return pci_device_to_OF_node(bus->self); 251 260 else 252 - return bus->sysdata; /* Must be root bus (PHB) */ 261 + return bus->dev.of_node; /* Must be root bus (PHB) */ 253 262 } 254 263 255 264 /** Find the bus corresponding to the indicated device node */ ··· 260 269 261 270 /** Discover new pci devices under this bus, and add them */ 262 271 extern void pcibios_add_pci_devices(struct pci_bus *bus); 263 - 264 - static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus) 265 - { 266 - struct device_node *busdn = bus->sysdata; 267 - 268 - BUG_ON(busdn == NULL); 269 - return PCI_DN(busdn)->phb; 270 - } 271 272 272 273 273 274 extern void isa_bridge_find_early(struct pci_controller *hose);
+1 -1
arch/powerpc/include/asm/pci.h
··· 201 201 extern void pcibios_setup_bus_devices(struct pci_bus *bus); 202 202 extern void pcibios_setup_bus_self(struct pci_bus *bus); 203 203 extern void pcibios_setup_phb_io_space(struct pci_controller *hose); 204 - extern void pcibios_scan_phb(struct pci_controller *hose, void *sysdata); 204 + extern void pcibios_scan_phb(struct pci_controller *hose); 205 205 206 206 #endif /* __KERNEL__ */ 207 207 #endif /* __ASM_POWERPC_PCI_H */
+1 -1
arch/powerpc/kernel/of_platform.c
··· 74 74 #endif /* CONFIG_EEH */ 75 75 76 76 /* Scan the bus */ 77 - pcibios_scan_phb(phb, dev->dev.of_node); 77 + pcibios_scan_phb(phb); 78 78 if (phb->bus == NULL) 79 79 return -ENXIO; 80 80
+3 -8
arch/powerpc/kernel/pci-common.c
··· 1688 1688 /** 1689 1689 * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus 1690 1690 * @hose: Pointer to the PCI host controller instance structure 1691 - * @sysdata: value to use for sysdata pointer. ppc32 and ppc64 differ here 1692 - * 1693 - * Note: the 'data' pointer is a temporary measure. As 32 and 64 bit 1694 - * pci code gets merged, this parameter should become unnecessary because 1695 - * both will use the same value. 1696 1691 */ 1697 - void __devinit pcibios_scan_phb(struct pci_controller *hose, void *sysdata) 1692 + void __devinit pcibios_scan_phb(struct pci_controller *hose) 1698 1693 { 1699 1694 struct pci_bus *bus; 1700 1695 struct device_node *node = hose->dn; ··· 1699 1704 node ? node->full_name : "<NO NAME>"); 1700 1705 1701 1706 /* Create an empty bus for the toplevel */ 1702 - bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, 1703 - sysdata); 1707 + bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose); 1704 1708 if (bus == NULL) { 1705 1709 pr_err("Failed to create bus for PCI domain %04x\n", 1706 1710 hose->global_number); 1707 1711 return; 1708 1712 } 1713 + bus->dev.of_node = of_node_get(node); 1709 1714 bus->secondary = hose->first_busno; 1710 1715 hose->bus = bus; 1711 1716
+1 -1
arch/powerpc/kernel/pci_32.c
··· 381 381 if (pci_assign_all_buses) 382 382 hose->first_busno = next_busno; 383 383 hose->last_busno = 0xff; 384 - pcibios_scan_phb(hose, hose); 384 + pcibios_scan_phb(hose); 385 385 pci_bus_add_devices(hose->bus); 386 386 if (pci_assign_all_buses || next_busno <= hose->last_busno) 387 387 next_busno = hose->last_busno + pcibios_assign_bus_offset;
+3 -3
arch/powerpc/kernel/pci_64.c
··· 64 64 65 65 /* Scan all of the recorded PCI controllers. */ 66 66 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { 67 - pcibios_scan_phb(hose, hose->dn); 67 + pcibios_scan_phb(hose); 68 68 pci_bus_add_devices(hose->bus); 69 69 } 70 70 ··· 242 242 break; 243 243 bus = NULL; 244 244 } 245 - if (bus == NULL || bus->sysdata == NULL) 245 + if (bus == NULL || bus->dev.of_node == NULL) 246 246 return -ENODEV; 247 247 248 - hose_node = (struct device_node *)bus->sysdata; 248 + hose_node = bus->dev.of_node; 249 249 hose = PCI_DN(hose_node)->phb; 250 250 251 251 switch (which) {
+6 -3
arch/powerpc/kernel/pci_dn.c
··· 161 161 /* 162 162 * This is the "slow" path for looking up a device_node from a 163 163 * pci_dev. It will hunt for the device under its parent's 164 - * phb and then update sysdata for a future fastpath. 164 + * phb and then update of_node pointer. 165 165 * 166 166 * It may also do fixups on the actual device since this happens 167 167 * on the first read/write. ··· 170 170 * In this case it may probe for real hardware ("just in case") 171 171 * and add a device_node to the device tree if necessary. 172 172 * 173 + * Is this function necessary anymore now that dev->dev.of_node is 174 + * used to store the node pointer? 175 + * 173 176 */ 174 177 struct device_node *fetch_dev_dn(struct pci_dev *dev) 175 178 { 176 - struct device_node *orig_dn = dev->sysdata; 179 + struct device_node *orig_dn = dev->dev.of_node; 177 180 struct device_node *dn; 178 181 unsigned long searchval = (dev->bus->number << 8) | dev->devfn; 179 182 180 183 dn = traverse_pci_devices(orig_dn, is_devfn_node, (void *)searchval); 181 184 if (dn) 182 - dev->sysdata = dn; 185 + dev->dev.of_node = dn; 183 186 return dn; 184 187 } 185 188 EXPORT_SYMBOL(fetch_dev_dn);
+2 -2
arch/powerpc/kernel/pci_of_scan.c
··· 135 135 pr_debug(" create device, devfn: %x, type: %s\n", devfn, type); 136 136 137 137 dev->bus = bus; 138 - dev->sysdata = node; 138 + dev->dev.of_node = of_node_get(node); 139 139 dev->dev.parent = bus->bridge; 140 140 dev->dev.bus = &pci_bus_type; 141 141 dev->devfn = devfn; ··· 238 238 bus->primary = dev->bus->number; 239 239 bus->subordinate = busrange[1]; 240 240 bus->bridge_ctl = 0; 241 - bus->sysdata = node; 241 + bus->dev.of_node = of_node_get(node); 242 242 243 243 /* parse ranges property */ 244 244 /* PCI #address-cells == 3 and #size-cells == 2 always */
+1 -1
arch/powerpc/platforms/pseries/pci_dlpar.c
··· 149 149 if (dn->child) 150 150 eeh_add_device_tree_early(dn); 151 151 152 - pcibios_scan_phb(phb, dn); 152 + pcibios_scan_phb(phb); 153 153 pcibios_finish_adding_to_bus(phb->bus); 154 154 155 155 return phb;