]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
powerpc/eeh: Move vf_index out of pci_dn and into eeh_dev
authorOliver O'Halloran <oohall@gmail.com>
Sat, 25 Jul 2020 08:12:20 +0000 (18:12 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 26 Jul 2020 13:34:20 +0000 (23:34 +1000)
Drivers that do not support the PCI error handling callbacks are handled by
tearing down the device and re-probing them. If the device being removed is
a virtual function then we need to know the VF index so it can be removed
using the pci_iov_{add|remove}_virtfn() API.

Currently this is handled by looking up the pci_dn, and using the vf_index
that was stashed there when the pci_dn for the VF was created in
pcibios_sriov_enable(). We would like to eliminate the use of pci_dn
outside of pseries though so we need to provide the generic EEH code with
some other way to find the vf_index.

The easiest thing to do here is move the vf_index field out of pci_dn and
into eeh_dev.  Currently pci_dn and eeh_dev are allocated and initialized
together so this is a fairly minimal change in preparation for splitting
pci_dn and eeh_dev in the future.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200725081231.39076-3-oohall@gmail.com
arch/powerpc/include/asm/eeh.h
arch/powerpc/include/asm/pci-bridge.h
arch/powerpc/kernel/eeh_driver.c
arch/powerpc/kernel/pci_dn.c

index dd7dd55db7dc7daf77b07963db5b1c0a2dba49fb..2a935db72198e165f5b6dca6c7a2b2c73f063fda 100644 (file)
@@ -148,7 +148,10 @@ struct eeh_dev {
        struct pci_dn *pdn;             /* Associated PCI device node   */
        struct pci_dev *pdev;           /* Associated PCI device        */
        bool in_error;                  /* Error flag for edev          */
+
+       /* VF specific properties */
        struct pci_dev *physfn;         /* Associated SRIOV PF          */
+       int vf_index;                   /* Index of this VF             */
 };
 
 /* "fmt" must be a simple literal string */
index b92e81b256e58172bb795da36fb1daf2eebbbe63..d2a2a14e56f91e07b7c4b673030f7f60e4be406b 100644 (file)
@@ -202,7 +202,6 @@ struct pci_dn {
 #define IODA_INVALID_PE                0xFFFFFFFF
        unsigned int pe_number;
 #ifdef CONFIG_PCI_IOV
-       int     vf_index;               /* VF index in the PF */
        u16     vfs_expanded;           /* number of VFs IOV BAR expanded */
        u16     num_vfs;                /* number of VFs enabled*/
        unsigned int *pe_num_map;       /* PE# for the first VF PE or array */
index 7b048cee767c746fefe8a75cb991fb94fe757164..b70b9273f45a5270376b040755be15430abcbdc9 100644 (file)
@@ -477,7 +477,7 @@ static void *eeh_add_virt_device(struct eeh_dev *edev)
        }
 
 #ifdef CONFIG_PCI_IOV
-       pci_iov_add_virtfn(edev->physfn, eeh_dev_to_pdn(edev)->vf_index);
+       pci_iov_add_virtfn(edev->physfn, edev->vf_index);
 #endif
        return NULL;
 }
@@ -521,9 +521,7 @@ static void eeh_rmv_device(struct eeh_dev *edev, void *userdata)
 
        if (edev->physfn) {
 #ifdef CONFIG_PCI_IOV
-               struct pci_dn *pdn = eeh_dev_to_pdn(edev);
-
-               pci_iov_remove_virtfn(edev->physfn, pdn->vf_index);
+               pci_iov_remove_virtfn(edev->physfn, edev->vf_index);
                edev->pdev = NULL;
 #endif
                if (rmv_data)
index f790a8d06f50e781b4906a46e633c7dc13ba7c10..bf11ac8427acd12f9530d890b6b845199e230bf9 100644 (file)
@@ -146,7 +146,6 @@ static struct eeh_dev *eeh_dev_init(struct pci_dn *pdn)
 
 #ifdef CONFIG_PCI_IOV
 static struct pci_dn *add_one_sriov_vf_pdn(struct pci_dn *parent,
-                                          int vf_index,
                                           int busno, int devfn)
 {
        struct pci_dn *pdn;
@@ -163,7 +162,6 @@ static struct pci_dn *add_one_sriov_vf_pdn(struct pci_dn *parent,
        pdn->parent = parent;
        pdn->busno = busno;
        pdn->devfn = devfn;
-       pdn->vf_index = vf_index;
        pdn->pe_number = IODA_INVALID_PE;
        INIT_LIST_HEAD(&pdn->child_list);
        INIT_LIST_HEAD(&pdn->list);
@@ -194,7 +192,7 @@ struct pci_dn *add_sriov_vf_pdns(struct pci_dev *pdev)
        for (i = 0; i < pci_sriov_get_totalvfs(pdev); i++) {
                struct eeh_dev *edev __maybe_unused;
 
-               pdn = add_one_sriov_vf_pdn(parent, i,
+               pdn = add_one_sriov_vf_pdn(parent,
                                           pci_iov_virtfn_bus(pdev, i),
                                           pci_iov_virtfn_devfn(pdev, i));
                if (!pdn) {
@@ -207,7 +205,10 @@ struct pci_dn *add_sriov_vf_pdns(struct pci_dev *pdev)
                /* Create the EEH device for the VF */
                edev = eeh_dev_init(pdn);
                BUG_ON(!edev);
+
+               /* FIXME: these should probably be populated by the EEH probe */
                edev->physfn = pdev;
+               edev->vf_index = i;
 #endif /* CONFIG_EEH */
        }
        return pci_get_pdn(pdev);