Skip to content

Commit

Permalink
powerpc/eeh: EEH device for VF
Browse files Browse the repository at this point in the history
VFs and their corresponding pdn are created and released dynamically
when their PF's SRIOV capability is enabled and disabled. This creates
and releases EEH devices for VFs when creating and releasing their pdn
instances, which means EEH devices and pdn instances have same life
cycle. Also, VF's EEH device is identified by (struct eeh_dev::physfn).

Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
Acked-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Wei Yang authored and Michael Ellerman committed Mar 8, 2016
1 parent 51c0e87 commit 39218cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/eeh.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ struct eeh_dev {
struct pci_controller *phb; /* Associated PHB */
struct pci_dn *pdn; /* Associated PCI device node */
struct pci_dev *pdev; /* Associated PCI device */
struct pci_dev *physfn; /* Associated SRIOV PF */
struct pci_bus *bus; /* PCI bus for partial hotplug */
};

Expand Down
15 changes: 15 additions & 0 deletions arch/powerpc/kernel/pci_dn.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ struct pci_dn *add_dev_pci_data(struct pci_dev *pdev)
{
#ifdef CONFIG_PCI_IOV
struct pci_dn *parent, *pdn;
struct eeh_dev *edev;
int i;

/* Only support IOV for now */
Expand All @@ -204,6 +205,12 @@ struct pci_dn *add_dev_pci_data(struct pci_dev *pdev)
__func__, i);
return NULL;
}

/* Create the EEH device for the VF */
eeh_dev_init(pdn, pci_bus_to_host(pdev->bus));
edev = pdn_to_eeh_dev(pdn);
BUG_ON(!edev);
edev->physfn = pdev;
}
#endif /* CONFIG_PCI_IOV */

Expand All @@ -215,6 +222,7 @@ void remove_dev_pci_data(struct pci_dev *pdev)
#ifdef CONFIG_PCI_IOV
struct pci_dn *parent;
struct pci_dn *pdn, *tmp;
struct eeh_dev *edev;
int i;

/*
Expand Down Expand Up @@ -256,6 +264,13 @@ void remove_dev_pci_data(struct pci_dev *pdev)
pdn->devfn != pci_iov_virtfn_devfn(pdev, i))
continue;

/* Release EEH device for the VF */
edev = pdn_to_eeh_dev(pdn);
if (edev) {
pdn->edev = NULL;
kfree(edev);
}

if (!list_empty(&pdn->list))
list_del(&pdn->list);

Expand Down

0 comments on commit 39218cd

Please sign in to comment.