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

powerpc/pcidn: Make VF pci_dn management CONFIG_PCI_IOV specific

The powerpc PCI code requires that a pci_dn structure exists for all
devices in the system. This is fine for real devices since at boot a pci_dn
is created for each PCI device in the DT and it's fine for hotplugged devices
since the hotplug slot driver will manage the pci_dn's devices in hotplug
slots. For SR-IOV, we need the platform / pcibios to manage the pci_dn for
virtual functions since firmware is unaware of VFs, and they aren't
"hot plugged" in the traditional sense.

Management of the pci_dn is handled by the, poorly named, functions:
add_pci_dev_data() and remove_pci_dev_data(). The entire body of these
functions is #ifdef`ed around CONFIG_PCI_IOV and they cannot be used
in any other context, so make them only available when CONFIG_PCI_IOV
is selected, and rename them to reflect their actual usage rather than
having them masquerade as generic code.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Sam Bobroff <sbobroff@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190821062655.19735-2-oohall@gmail.com

authored by

Oliver O'Halloran and committed by
Michael Ellerman
8cd6aacc 1fb4124c

+14 -16
+5 -2
arch/powerpc/include/asm/pci-bridge.h
··· 223 223 extern struct pci_dn *pci_get_pdn_by_devfn(struct pci_bus *bus, 224 224 int devfn); 225 225 extern struct pci_dn *pci_get_pdn(struct pci_dev *pdev); 226 - extern struct pci_dn *add_dev_pci_data(struct pci_dev *pdev); 227 - extern void remove_dev_pci_data(struct pci_dev *pdev); 228 226 extern struct pci_dn *pci_add_device_node_info(struct pci_controller *hose, 229 227 struct device_node *dn); 230 228 extern void pci_remove_device_node_info(struct device_node *dn); 229 + 230 + #ifdef CONFIG_PCI_IOV 231 + struct pci_dn *add_sriov_vf_pdns(struct pci_dev *pdev); 232 + void remove_sriov_vf_pdns(struct pci_dev *pdev); 233 + #endif 231 234 232 235 static inline int pci_device_from_OF_node(struct device_node *np, 233 236 u8 *bus, u8 *devfn)
+5 -10
arch/powerpc/kernel/pci_dn.c
··· 125 125 } 126 126 127 127 #ifdef CONFIG_PCI_IOV 128 - static struct pci_dn *add_one_dev_pci_data(struct pci_dn *parent, 128 + static struct pci_dn *add_one_sriov_vf_pdn(struct pci_dn *parent, 129 129 int vf_index, 130 130 int busno, int devfn) 131 131 { ··· 151 151 152 152 return pdn; 153 153 } 154 - #endif 155 154 156 - struct pci_dn *add_dev_pci_data(struct pci_dev *pdev) 155 + struct pci_dn *add_sriov_vf_pdns(struct pci_dev *pdev) 157 156 { 158 - #ifdef CONFIG_PCI_IOV 159 157 struct pci_dn *parent, *pdn; 160 158 int i; 161 159 ··· 174 176 for (i = 0; i < pci_sriov_get_totalvfs(pdev); i++) { 175 177 struct eeh_dev *edev __maybe_unused; 176 178 177 - pdn = add_one_dev_pci_data(parent, i, 179 + pdn = add_one_sriov_vf_pdn(parent, i, 178 180 pci_iov_virtfn_bus(pdev, i), 179 181 pci_iov_virtfn_devfn(pdev, i)); 180 182 if (!pdn) { ··· 190 192 edev->physfn = pdev; 191 193 #endif /* CONFIG_EEH */ 192 194 } 193 - #endif /* CONFIG_PCI_IOV */ 194 - 195 195 return pci_get_pdn(pdev); 196 196 } 197 197 198 - void remove_dev_pci_data(struct pci_dev *pdev) 198 + void remove_sriov_vf_pdns(struct pci_dev *pdev) 199 199 { 200 - #ifdef CONFIG_PCI_IOV 201 200 struct pci_dn *parent; 202 201 struct pci_dn *pdn, *tmp; 203 202 int i; ··· 266 271 kfree(pdn); 267 272 } 268 273 } 269 - #endif /* CONFIG_PCI_IOV */ 270 274 } 275 + #endif /* CONFIG_PCI_IOV */ 271 276 272 277 struct pci_dn *pci_add_device_node_info(struct pci_controller *hose, 273 278 struct device_node *dn)
+2 -2
arch/powerpc/platforms/powernv/pci-ioda.c
··· 1747 1747 pnv_pci_sriov_disable(pdev); 1748 1748 1749 1749 /* Release PCI data */ 1750 - remove_dev_pci_data(pdev); 1750 + remove_sriov_vf_pdns(pdev); 1751 1751 return 0; 1752 1752 } 1753 1753 1754 1754 int pnv_pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs) 1755 1755 { 1756 1756 /* Allocate PCI data */ 1757 - add_dev_pci_data(pdev); 1757 + add_sriov_vf_pdns(pdev); 1758 1758 1759 1759 return pnv_pci_sriov_enable(pdev, num_vfs); 1760 1760 }
+2 -2
arch/powerpc/platforms/pseries/pci.c
··· 192 192 int pseries_pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs) 193 193 { 194 194 /* Allocate PCI data */ 195 - add_dev_pci_data(pdev); 195 + add_sriov_vf_pdns(pdev); 196 196 return pseries_pci_sriov_enable(pdev, num_vfs); 197 197 } 198 198 ··· 204 204 /* Releasing pe_num_map */ 205 205 kfree(pdn->pe_num_map); 206 206 /* Release PCI data */ 207 - remove_dev_pci_data(pdev); 207 + remove_sriov_vf_pdns(pdev); 208 208 pci_vf_drivers_autoprobe(pdev, true); 209 209 return 0; 210 210 }