powerpc/eeh: Move vf_index out of pci_dn and into eeh_dev
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
This commit is contained in:
parent
d74ee8e9d1
commit
dffa91539e
|
@ -148,7 +148,10 @@ struct eeh_dev {
|
||||||
struct pci_dn *pdn; /* Associated PCI device node */
|
struct pci_dn *pdn; /* Associated PCI device node */
|
||||||
struct pci_dev *pdev; /* Associated PCI device */
|
struct pci_dev *pdev; /* Associated PCI device */
|
||||||
bool in_error; /* Error flag for edev */
|
bool in_error; /* Error flag for edev */
|
||||||
|
|
||||||
|
/* VF specific properties */
|
||||||
struct pci_dev *physfn; /* Associated SRIOV PF */
|
struct pci_dev *physfn; /* Associated SRIOV PF */
|
||||||
|
int vf_index; /* Index of this VF */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* "fmt" must be a simple literal string */
|
/* "fmt" must be a simple literal string */
|
||||||
|
|
|
@ -202,7 +202,6 @@ struct pci_dn {
|
||||||
#define IODA_INVALID_PE 0xFFFFFFFF
|
#define IODA_INVALID_PE 0xFFFFFFFF
|
||||||
unsigned int pe_number;
|
unsigned int pe_number;
|
||||||
#ifdef CONFIG_PCI_IOV
|
#ifdef CONFIG_PCI_IOV
|
||||||
int vf_index; /* VF index in the PF */
|
|
||||||
u16 vfs_expanded; /* number of VFs IOV BAR expanded */
|
u16 vfs_expanded; /* number of VFs IOV BAR expanded */
|
||||||
u16 num_vfs; /* number of VFs enabled*/
|
u16 num_vfs; /* number of VFs enabled*/
|
||||||
unsigned int *pe_num_map; /* PE# for the first VF PE or array */
|
unsigned int *pe_num_map; /* PE# for the first VF PE or array */
|
||||||
|
|
|
@ -477,7 +477,7 @@ static void *eeh_add_virt_device(struct eeh_dev *edev)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PCI_IOV
|
#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
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -521,9 +521,7 @@ static void eeh_rmv_device(struct eeh_dev *edev, void *userdata)
|
||||||
|
|
||||||
if (edev->physfn) {
|
if (edev->physfn) {
|
||||||
#ifdef CONFIG_PCI_IOV
|
#ifdef CONFIG_PCI_IOV
|
||||||
struct pci_dn *pdn = eeh_dev_to_pdn(edev);
|
pci_iov_remove_virtfn(edev->physfn, edev->vf_index);
|
||||||
|
|
||||||
pci_iov_remove_virtfn(edev->physfn, pdn->vf_index);
|
|
||||||
edev->pdev = NULL;
|
edev->pdev = NULL;
|
||||||
#endif
|
#endif
|
||||||
if (rmv_data)
|
if (rmv_data)
|
||||||
|
|
|
@ -146,7 +146,6 @@ static struct eeh_dev *eeh_dev_init(struct pci_dn *pdn)
|
||||||
|
|
||||||
#ifdef CONFIG_PCI_IOV
|
#ifdef CONFIG_PCI_IOV
|
||||||
static struct pci_dn *add_one_sriov_vf_pdn(struct pci_dn *parent,
|
static struct pci_dn *add_one_sriov_vf_pdn(struct pci_dn *parent,
|
||||||
int vf_index,
|
|
||||||
int busno, int devfn)
|
int busno, int devfn)
|
||||||
{
|
{
|
||||||
struct pci_dn *pdn;
|
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->parent = parent;
|
||||||
pdn->busno = busno;
|
pdn->busno = busno;
|
||||||
pdn->devfn = devfn;
|
pdn->devfn = devfn;
|
||||||
pdn->vf_index = vf_index;
|
|
||||||
pdn->pe_number = IODA_INVALID_PE;
|
pdn->pe_number = IODA_INVALID_PE;
|
||||||
INIT_LIST_HEAD(&pdn->child_list);
|
INIT_LIST_HEAD(&pdn->child_list);
|
||||||
INIT_LIST_HEAD(&pdn->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++) {
|
for (i = 0; i < pci_sriov_get_totalvfs(pdev); i++) {
|
||||||
struct eeh_dev *edev __maybe_unused;
|
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_bus(pdev, i),
|
||||||
pci_iov_virtfn_devfn(pdev, i));
|
pci_iov_virtfn_devfn(pdev, i));
|
||||||
if (!pdn) {
|
if (!pdn) {
|
||||||
|
@ -207,7 +205,10 @@ struct pci_dn *add_sriov_vf_pdns(struct pci_dev *pdev)
|
||||||
/* Create the EEH device for the VF */
|
/* Create the EEH device for the VF */
|
||||||
edev = eeh_dev_init(pdn);
|
edev = eeh_dev_init(pdn);
|
||||||
BUG_ON(!edev);
|
BUG_ON(!edev);
|
||||||
|
|
||||||
|
/* FIXME: these should probably be populated by the EEH probe */
|
||||||
edev->physfn = pdev;
|
edev->physfn = pdev;
|
||||||
|
edev->vf_index = i;
|
||||||
#endif /* CONFIG_EEH */
|
#endif /* CONFIG_EEH */
|
||||||
}
|
}
|
||||||
return pci_get_pdn(pdev);
|
return pci_get_pdn(pdev);
|
||||||
|
|
Loading…
Reference in New Issue