VF EEH on Power8
Subsystems (3)
v8 cover VF EEH on Power8
This patchset enables EEH on SRIOV VFs. The general idea is to create proper VF edev and VF PE and handle them properly.
Different from the Bus PE, VF PE just contain one VF. This introduces the difference of EEH error handling on a VF PE. Generally, it has several differences.
First, the VF's removal and re-enumerate rely on its PF. VF has a tight relationship between its PF. This is not proper to enumerate a VF by usual scan procedure. That's why virtfn_add/virtfn_remove are exported in this patch set.
Second, the reset/restore of a VF is done in kernel space. FW is not aware of the VF, this means the usual reset function done in FW will not work. One of the patch will imitate the reset/restore function in kernel space.
Third, the VF may be removed during the PF's error_detected function. In this case, the original error_detected->slot_reset->resume sequence is not proper to those removed VFs, since they are re-created by PF in a fresh state. A flag in eeh_dev is introduce to mark the eeh_dev is in error state. By doing so, we track whether this device needs to be reset or not.
This has been tested both on host and in guest on Power8 with latest kernel version.
v8:
* fix on checking the return value of pnv_eeh_do_flr()
* introduced a weak function pcibios_bus_add_device() to create PE for VFs
* rebase it on v4.1-rc8
v7:
* fix compile error when PCI_IOV is not set
v6:
* code / commit log refactor by Gavin
v5:
* remove the compound field, iterate on Master VF PE instead
* some code refine on PCI config restore and reset on VF
the wait time for assert and deassert
PCI device address format
check on edev->pcie_cap and edev->aer_cap before access them
v4:
* refine the change logs, comment and code style
* change pnv_pci_fixup_vf_eeh() to pnv_eeh_vf_final_fixup() and remove the CONFIG_PCI_IOV macro
* reorder patch 5/6 to make the logic more reasonable
* remove remove_dev_pci_data()
* remove the EEH_DEV_VF flag, use edev->physfn to identify a VF EEH DEV and remove related CONFIG_PCI_IOV macro
* add the option for VF reset
* fix the pnv_eeh_cfg_blocked() logic
* replace pnv_pci_cfg_{read,write} with eeh_ops->{read,write}_config in pnv_eeh_vf_restore_config()
* rename pnv_eeh_vf_restore_config() to pnv_eeh_restore_vf_config()
* rename pnv_pci_fixup_vf_caps() to pnv_pci_vf_header_fixup() and move it to arch/powerpc/platforms/powernv/pci.c
* add a field compound in pnv_ioda_pe to link compound PEs
* handle compound PE for VF PEs
v3:
* add back vf_index in pci_dn to track the VF's index
* rename ppdev in eeh_dev to physfn for consistency
* move edev->physfn assignment before dev->dev.archdata.edev is set
* move pnv_pci_fixup_vf_eeh() and pnv_pci_fixup_vf_caps() to eeh-powernv.c
* more clear and detail in commit log and comment in code
* merge eeh_rmv_virt_device() with eeh_rmv_device()
* move the cfg_blocked check logic from pnv_eeh_read/write_config() to pnv_eeh_cfg_blocked()
* move the vf reset/restore logic into its own patch, two patches are created.
powerpc/powernv: Support PCI config restore for VFs powerpc/powernv: Support EEH reset for VFs
* simplify the vf reset logic
v2:
* add prefix pci_iov_ to virtfn_add/virtfn_remove
* use EEH_DEV_VF as a flag for a VF's eeh_dev
* use eeh_dev instead of edev in change log
* remove vf_index in eeh_dev, calculate it from pdn->busno and devfn
* do eeh_add_device_late() and eeh_sysfs_add_device() both after pci_dev is well initialized
* do FLR to reset a VF PE
* imitate the restore function in FW for VF
* remove the reverse order patch, since it is still under discussion
Wei Yang (10):
PCI/IOV: Rename and export virtfn_add/virtfn_remove powerpc/pci: Cache VF index in pci_dn powerpc/pci: Remove VFs prior to PF powerpc/eeh: Cache only BARs, not windows or IOV BARs powerpc/powernv: EEH device for VF powerpc/eeh: Create PE for VFs powerpc/powernv: Support EEH reset for VF PE powerpc/powernv: Support PCI config restore for VFs powerpc/eeh: Support error recovery for VF PE powerpc/powernv: compound PE for VFs
arch/powerpc/include/asm/eeh.h | 4 + arch/powerpc/include/asm/pci-bridge.h | 2 + arch/powerpc/kernel/eeh.c | 8 + arch/powerpc/kernel/eeh_cache.c | 6 +- arch/powerpc/kernel/eeh_driver.c | 100 +++++++++--- arch/powerpc/kernel/eeh_pe.c | 13 +- arch/powerpc/kernel/pci-hotplug.c | 2 +- arch/powerpc/kernel/pci_dn.c | 16 +- arch/powerpc/platforms/powernv/eeh-powernv.c | 220 +++++++++++++++++++++++++- arch/powerpc/platforms/powernv/pci-ioda.c | 46 +++++- arch/powerpc/platforms/powernv/pci.c | 35 +++- drivers/pci/bus.c | 2 + drivers/pci/iov.c | 10 +- include/linux/pci.h | 8 + 14 files changed, 427 insertions(+), 45 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v8 1/10 PCI/IOV: Rename and export virtfn_add/virtfn_remove
During EEH recovery, hotplug is applied to the devices which don't have drivers or their drivers don't support EEH. However, the hotplug, which was implemented based on PCI bus, can't be applied to VF directly.
The patch renames virtn_{add,remove}() and exports them so that they can be used in PCI hotplug during EEH recovery.
--- drivers/pci/iov.c | 10 +++++----- include/linux/pci.h | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/pci/iov.c +5 -5
@@ -108,7 +108,7 @@ resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno)return dev->sriov->barsz[resno -PCI_IOV_RESOURCES ]; } -static int virtfn_add (struct pci_dev *dev,int id,int reset) +int pci_iov_virtfn_add (struct pci_dev *dev,int id,int reset) {int i;int rc = -ENOMEM ;
@@ -183,7 +183,7 @@ failed:return rc; } -static void virtfn_remove (struct pci_dev *dev,int id,int reset) +void pci_iov_virtfn_remove (struct pci_dev *dev,int id,int reset) {char buf[VIRTFN_ID_LEN ];struct pci_dev *virtfn;
@@ -320,7 +320,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) }for (i =0 ; i < initial; i++) { - rc =virtfn_add (dev, i,0 ); + rc =pci_iov_virtfn_add (dev, i,0 );if (rc) goto failed; }
@@ -332,7 +332,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) failed:for (j =0 ; j < i; j++) -virtfn_remove (dev, j,0 ); +pci_iov_virtfn_remove (dev, j,0 ); iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE |PCI_SRIOV_CTRL_MSE );pci_cfg_access_lock (dev);
@@ -361,7 +361,7 @@ static void sriov_disable(struct pci_dev *dev)return ;for (i =0 ; i < iov->num_VFs; i++) -virtfn_remove (dev, i,0 ); +pci_iov_virtfn_remove (dev, i,0 );pcibios_sriov_disable (dev);
include/linux/pci.h +8 -0
@@ -1679,6 +1679,8 @@ int pci_iov_virtfn_devfn(struct pci_dev *dev, int id);int pci_enable_sriov (struct pci_dev *dev,int nr_virtfn);void pci_disable_sriov (struct pci_dev *dev); +int pci_iov_virtfn_add (struct pci_dev *dev,int id,int reset); +void pci_iov_virtfn_remove (struct pci_dev *dev,int id,int reset);int pci_num_vf (struct pci_dev *dev);int pci_vfs_assigned (struct pci_dev *dev);int pci_sriov_set_totalvfs (struct pci_dev *dev,u16 numvfs);
@@ -1696,6 +1698,12 @@ static inline int pci_iov_virtfn_devfn(struct pci_dev *dev, int id)static inline int pci_enable_sriov (struct pci_dev *dev,int nr_virtfn) {return -ENODEV ; }static inline void pci_disable_sriov (struct pci_dev *dev) { } +static inline int pci_iov_virtfn_add (struct pci_dev *dev,int id,int reset) +{ +return -ENOSYS ; +} +static inline void pci_iov_virtfn_remove (struct pci_dev *dev,int id,int reset) +{ }static inline int pci_num_vf (struct pci_dev *dev) {return 0 ; }static inline int pci_vfs_assigned (struct pci_dev *dev) {return 0 ; }
Signature · 1 line
1.7.9.5
PATCH v8 2/10 powerpc/pci: Cache VF index in pci_dn
In reply to Wei YangThe patch caches the VF index in pci_dn, which can be used to calculate VF's bus, device and function number. Those information helps to locate the VF's PCI device instance when doing hotplug during EEH recovery if necessary.
--- arch/powerpc/include/asm/pci-bridge.h | 1 + arch/powerpc/kernel/pci_dn.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/pci-bridge.h +1 -0
@@ -196,6 +196,7 @@ struct pci_dn {#define IODA_INVALID_PE (-1)#ifdef CONFIG_PPC_POWERNV int pe_number; +int vf_index;/* VF index in the PF */ #ifdef CONFIG_PCI_IOV u16 vfs_expanded;/* number of VFs IOV BAR expanded */ u16 num_vfs;/* number of VFs enabled*/
arch/powerpc/kernel/pci_dn.c +3 -1
@@ -139,6 +139,7 @@ struct pci_dn *pci_get_pdn(struct pci_dev *pdev)#ifdef CONFIG_PCI_IOV static struct pci_dn *add_one_dev_pci_data (struct pci_dn *parent,struct pci_dev *pdev, +int vf_index,int busno,int devfn) {struct pci_dn *pdn;
@@ -157,6 +158,7 @@ static struct pci_dn *add_one_dev_pci_data(struct pci_dn *parent, pdn->parent = parent; pdn->busno = busno; pdn->devfn = devfn; + pdn->vf_index = vf_index;#ifdef CONFIG_PPC_POWERNV pdn->pe_number =IODA_INVALID_PE ;#endif
@@ -196,7 +198,7 @@ struct pci_dn *add_dev_pci_data(struct pci_dev *pdev)return NULL ;for (i =0 ; i <pci_sriov_get_totalvfs (pdev); i++) { - pdn =add_one_dev_pci_data (parent,NULL , + pdn =add_one_dev_pci_data (parent,NULL , i,pci_iov_virtfn_bus (pdev, i),pci_iov_virtfn_devfn (pdev, i));if (!pdn) {
Signature · 1 line
1.7.9.5
PATCH v8 3/10 powerpc/pci: Remove VFs prior to PF
In reply to Wei YangAs commit ac205b7bb72f ("PCI: make sriov work with hotplug remove") indicates, VFs, which might be hooked to same PCI bus as their PF should be removed before the PF. Otherwise, the PCI hot unplugging on the PCI bus would cause kernel crash.
The patch applies the above pattern to PowerPC PCI hotplug path.
--- arch/powerpc/kernel/pci-hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/pci-hotplug.c +1 -1
@@ -50,7 +50,7 @@ void pcibios_remove_pci_devices(struct pci_bus *bus)pr_debug ("PCI: Removing devices on bus %04x:%02x\n" ,pci_domain_nr (bus), bus->number); -list_for_each_entry_safe (dev, tmp, &bus->devices, bus_list) { +list_for_each_entry_safe_reverse (dev, tmp, &bus->devices, bus_list) {pr_debug (" Removing %s...\n" ,pci_name (dev));pci_stop_and_remove_bus_device (dev); }
Signature · 1 line
1.7.9.5
PATCH v8 5/10 powerpc/powernv: EEH device for VF
In reply to Wei YangVFs and their corresponding pci_dn instances are created and released dynamically as their PF's SRIOV capability is enabled and disabled. The patch creates and releases EEH devices for VFs when creating and releasing their pci_dn instances, which means EEH devices and pci_dn instances have same life cycle. Also, VF's EEH device is identified by (struct eeh_dev::physfn).
--- arch/powerpc/include/asm/eeh.h | 1 + arch/powerpc/kernel/pci_dn.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
arch/powerpc/include/asm/eeh.h +1 -0
@@ -138,6 +138,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 PF PORT */ struct pci_bus *bus;/* PCI bus for partial hotplug */ };
arch/powerpc/kernel/pci_dn.c +12 -0
@@ -180,7 +180,9 @@ static struct pci_dn *add_one_dev_pci_data(struct pci_dn *parent,struct pci_dn *add_dev_pci_data (struct pci_dev *pdev) {#ifdef CONFIG_PCI_IOV +struct pci_controller *hose =pci_bus_to_host (pdev->bus);struct pci_dn *parent, *pdn; +struct eeh_dev *edev;int i;/* Only support IOV for now */
@@ -206,6 +208,9 @@ struct pci_dn *add_dev_pci_data(struct pci_dev *pdev) __func__, i); return NULL; } +eeh_dev_init (pdn, hose); + edev =pdn_to_eeh_dev (pdn); + edev->physfn = pdev; }#endif /* CONFIG_PCI_IOV */
@@ -254,10 +259,17 @@ void remove_dev_pci_data(struct pci_dev *pdev)for (i =0 ; i <pci_sriov_get_totalvfs (pdev); i++) {list_for_each_entry_safe (pdn, tmp, &parent->child_list, list) { +struct eeh_dev *edev;if (pdn->busno !=pci_iov_virtfn_bus (pdev, i) || pdn->devfn !=pci_iov_virtfn_devfn (pdev, i))continue ; + edev =pdn_to_eeh_dev (pdn); +if (edev) { + pdn->edev =NULL ; +kfree (edev); + } +if (!list_empty (&pdn->list))list_del (&pdn->list);
Signature · 1 line
1.7.9.5
PATCH v8 4/10 powerpc/eeh: Cache only BARs, not windows or IOV BARs
In reply to Wei YangEEH address cache, which helps to locate the PCI device according to the given (physical) MMIO address, didn't cover PCI bridges. Also, it shouldn't return PF with address in PF's IOV BARs. Instead, the VFs should be returned.
Also, by doing so, it removes the type check in eeh_addr_cache_insert_dev(), since bridge's window would not be cached.
The patch restricts the address cache to cover first 7 BARs for the above purposes.
--- arch/powerpc/kernel/eeh_cache.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
arch/powerpc/kernel/eeh_cache.c +1 -5
@@ -196,7 +196,7 @@ static void __eeh_addr_cache_insert_dev(struct pci_dev *dev) }/* Walk resources on this device, poke them into the tree */ -for (i =0 ; i <DEVICE_COUNT_RESOURCE ; i++) { +for (i =0 ; i <=PCI_ROM_RESOURCE ; i++) {unsigned long start =pci_resource_start (dev,i);unsigned long end =pci_resource_end (dev,i);unsigned int flags =pci_resource_flags (dev,i);
@@ -222,10 +222,6 @@ void eeh_addr_cache_insert_dev(struct pci_dev *dev) {unsigned long flags; -/* Ignore PCI bridges */ -if ((dev->class >>16 ) ==PCI_BASE_CLASS_BRIDGE ) -return ; -spin_lock_irqsave (&pci_io_addr_cache_root.piar_lock, flags);__eeh_addr_cache_insert_dev (dev);spin_unlock_irqrestore (&pci_io_addr_cache_root.piar_lock, flags);
Signature · 1 line
1.7.9.5
PATCH v8 6/10 powerpc/eeh: Create PE for VFs
In reply to Wei YangCurrent EEH recovery code works with the assumption: the PE has primary bus. Unfortunately, that's not true for VF PEs, which generally contains one or multiple VFs (for VF group case).
The patch introduces a weak function pcibios_bus_add_device() which is called by pci_bus_add_device(). In this function, we creates PEs for VFs. Those PEs for VFs are identified with newly introduced flag EEH_PE_VF so that we handle them differently during EEH recovery.
--- arch/powerpc/include/asm/eeh.h | 1 + arch/powerpc/kernel/eeh_pe.c | 10 ++++++++-- arch/powerpc/platforms/powernv/eeh-powernv.c | 16 ++++++++++++++++ drivers/pci/bus.c | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/eeh.h +1 -0
@@ -70,6 +70,7 @@ struct pci_dn;#define EEH_PE_PHB (1 << 1)/* PHB PE */ #define EEH_PE_DEVICE (1 << 2)/* Device PE */ #define EEH_PE_BUS (1 << 3)/* Bus PE */ +#define EEH_PE_VF (1 << 4)/* VF PE */ #define EEH_PE_ISOLATED (1 << 0)/* Isolated PE */ #define EEH_PE_RECOVERING (1 << 1)/* Recovering PE */
arch/powerpc/kernel/eeh_pe.c +8 -2
@@ -299,7 +299,10 @@ static struct eeh_pe *eeh_pe_get_parent(struct eeh_dev *edev)* EEH device already having associated PE, but * the direct parent EEH device doesn't have yet. */ - pdn = pdn ? pdn->parent :NULL ; +if (edev->physfn) + pdn =pci_get_pdn (edev->physfn); +else + pdn = pdn ? pdn->parent :NULL ;while (pdn) {/* We're poking out of PCI territory */ parent =pdn_to_eeh_dev (pdn);
@@ -382,7 +385,10 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev) }/* Create a new EEH PE */ - pe =eeh_pe_alloc (edev->phb,EEH_PE_DEVICE ); +if (edev->physfn) + pe =eeh_pe_alloc (edev->phb,EEH_PE_VF ); +else + pe =eeh_pe_alloc (edev->phb,EEH_PE_DEVICE );if (!pe) {pr_err ("%s: out of memory!\n" , __func__);return -ENOMEM ;
arch/powerpc/platforms/powernv/eeh-powernv.c +16 -0
@@ -1520,6 +1520,22 @@ static struct eeh_ops pnv_eeh_ops = { .restore_config = pnv_eeh_restore_config }; +void pcibios_bus_add_device (struct pci_dev *pdev) +{ +struct pci_dn *pdn =pci_get_pdn (pdev); + +if (!pdev->is_virtfn) +return ; + +/* +* The following operations will fail if VF's sysfs files +* aren't created or its resources aren't finalized. +*/ +eeh_add_device_early (pdn); +eeh_add_device_late (pdev); +eeh_sysfs_add_device (pdev); +} +/** * eeh_powernv_init - Register platform dependent EEH operations *
drivers/pci/bus.c +2 -0
@@ -267,6 +267,7 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx)void __weak pcibios_resource_survey_bus (struct pci_bus *bus) { } +void __weak pcibios_bus_add_device (struct pci_dev *dev) { }/** * pci_bus_add_device - start driver for a single device * @dev: device to add
@@ -277,6 +278,7 @@ void pci_bus_add_device(struct pci_dev *dev) {int retval; +pcibios_bus_add_device (dev);/* * Can not put in pci_device_add yet because resources * are not assigned yet for some devices.
Signature · 1 line
1.7.9.5
PATCH v8 8/10 powerpc/powernv: Support PCI config restore for VFs
In reply to Wei YangAfter PE reset, OPAL API opal_pci_reinit() is called on all devices contained in the PE to reinitialize them. However, VFs can't be seen from skiboot firmware. We have to implement the functions, similar those in skiboot firmware, to reinitialize VFs after reset on PE for VFs.
--- arch/powerpc/include/asm/pci-bridge.h | 1 + arch/powerpc/platforms/powernv/eeh-powernv.c | 70 +++++++++++++++++++++++++- arch/powerpc/platforms/powernv/pci.c | 18 +++++++ 3 files changed, 88 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/pci-bridge.h +1 -0
@@ -206,6 +206,7 @@ struct pci_dn {#define IODA_INVALID_M64 (-1)int m64_wins[PCI_SRIOV_NUM_BARS ][M64_PER_IOV ];#endif /* CONFIG_PCI_IOV */ +int mps;#endif struct list_head child_list;struct list_head list;
arch/powerpc/platforms/powernv/eeh-powernv.c +69 -1
82 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci.c +18 -0
@@ -729,6 +729,24 @@ static void pnv_p7ioc_rc_quirk(struct pci_dev *dev) }DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_IBM ,0x3b9 , pnv_p7ioc_rc_quirk); +#ifdef CONFIG_PCI_IOV +static void pnv_pci_fixup_vf_mps (struct pci_dev *pdev) +{ +struct pci_dn *pdn =pci_get_pdn (pdev); +int parent_mps; + +if (!pdev->is_virtfn) +return ; + +/* Synchronize MPS for VF and PF */ + parent_mps =pcie_get_mps (pdev->physfn); +if ((128 << pdev->pcie_mpss) >= parent_mps) +pcie_set_mps (pdev, parent_mps); + pdn->mps =pcie_get_mps (pdev); +} +DECLARE_PCI_FIXUP_HEADER (PCI_ANY_ID ,PCI_ANY_ID , pnv_pci_fixup_vf_mps); +#endif /* CONFIG_PCI_IOV */ +void __init pnv_pci_init (void ) {struct device_node *np;
Signature · 1 line
1.7.9.5
PATCH v8 9/10 powerpc/eeh: Support error recovery for VF PE
In reply to Wei YangDifferent from PCI bus dependent PE, PE for VFs doesn't have the primary bus, on which the PCI hotplug is implemented. The patch supports error recovery, especially the PCI hotplug for VF's PE. The hotplug on VF's PE is implemented based on VFs, instead of PCI bus any more.
--- arch/powerpc/include/asm/eeh.h | 1 + arch/powerpc/kernel/eeh.c | 8 +++ arch/powerpc/kernel/eeh_driver.c | 100 ++++++++++++++++++++++++++++++-------- arch/powerpc/kernel/eeh_pe.c | 3 +- 4 files changed, 90 insertions(+), 22 deletions(-)
arch/powerpc/include/asm/eeh.h +1 -0
@@ -140,6 +140,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 */ +int in_error;/* Error flag for eeh_dev */ struct pci_dev *physfn;/* Associated PF PORT */ struct pci_bus *bus;/* PCI bus for partial hotplug */ };
arch/powerpc/kernel/eeh.c +8 -0
@@ -1229,6 +1229,14 @@ void eeh_remove_device(struct pci_dev *dev)* from the parent PE during the BAR resotre. */ edev->pdev =NULL ; + +/* +* The flag "in_error" is used to trace EEH devices for VFs +* in error state or not. It's set in eeh_report_error(). If +* it's not set, eeh_report_{reset,resume}() won't be called +* for the VF EEH device. +*/ + edev->in_error =0 ; dev->dev.archdata.edev =NULL ;if (!(edev->pe->state &EEH_PE_KEEP ))eeh_rmv_from_parent_pe (edev);
arch/powerpc/kernel/eeh_driver.c +79 -21
179 lines not on this page · raw message
arch/powerpc/kernel/eeh_pe.c +2 -1
@@ -914,7 +914,8 @@ struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe)if (pe->type &EEH_PE_PHB ) { bus = pe->phb->bus; }else if (pe->type &EEH_PE_BUS || - pe->type &EEH_PE_DEVICE ) { + pe->type &EEH_PE_DEVICE || + pe->type &EEH_PE_VF ) {if (pe->bus) { bus = pe->bus; goto out;
Signature · 1 line
1.7.9.5
PATCH v8 10/10 powerpc/powernv: compound PE for VFs
In reply to Wei YangWhen VF BAR size is larger than 64MB, we group VFs in terms of M64 BAR, which means those VFs in a group should form a compound PE.
This patch links those VF PEs into compound PE in this case.
--- arch/powerpc/platforms/powernv/pci-ioda.c | 46 +++++++++++++++++++++++++---- arch/powerpc/platforms/powernv/pci.c | 17 +++++++++-- 2 files changed, 56 insertions(+), 7 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +41 -5
@@ -1363,9 +1363,20 @@ static void pnv_ioda_release_vf_PE(struct pci_dev *pdev, u16 num_vfs) }list_for_each_entry_safe (pe, pe_n, &phb->ioda.pe_list, list) { +struct pnv_ioda_pe *s, *sn;if (pe->parent_dev != pdev)continue ; +if ((pe->flags &PNV_IODA_PE_MASTER ) && + (pe->flags &PNV_IODA_PE_VF )) { +list_for_each_entry_safe (s, sn, &pe->slaves, list) { +pnv_pci_ioda2_release_dma_pe (pdev, s); +list_del (&s->list); +pnv_ioda_deconfigure_pe (phb, s); +pnv_ioda_free_pe (phb, s->pe_number); + } + } +pnv_pci_ioda2_release_dma_pe (pdev, pe);/* Remove from list */
@@ -1418,7 +1429,7 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs)struct pci_bus *bus;struct pci_controller *hose;struct pnv_phb *phb; -struct pnv_ioda_pe *pe; +struct pnv_ioda_pe *pe, *master_pe;int pe_num;u16 vf_index;struct pci_dn *pdn;
@@ -1464,10 +1475,13 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs) GFP_KERNEL, hose->node); pe->tce32_table->data = pe; -/* Put PE to the list */ -mutex_lock (&phb->ioda.pe_list_mutex); -list_add_tail (&pe->list, &phb->ioda.pe_list); -mutex_unlock (&phb->ioda.pe_list_mutex); +/* Put PE to the list, or postpone it for compound PEs */ +if ((pdn->m64_per_iov !=M64_PER_IOV ) || + (num_vfs <=M64_PER_IOV )) { +mutex_lock (&phb->ioda.pe_list_mutex); +list_add_tail (&pe->list, &phb->ioda.pe_list); +mutex_unlock (&phb->ioda.pe_list_mutex); + }pnv_pci_ioda2_setup_dma_pe (phb, pe); }
@@ -1480,10 +1494,32 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs) vf_per_group =roundup_pow_of_two (num_vfs) / pdn->m64_per_iov;for (vf_group =0 ; vf_group <M64_PER_IOV ; vf_group++) { + master_pe =NULL ; +for (vf_index = vf_group * vf_per_group; vf_index < (vf_group +1 ) * vf_per_group && vf_index < num_vfs; vf_index++) { + +/* +* Figure out the master PE and put all slave +* PEs to master PE's list. +*/ + pe = &phb->ioda.pe_array[pdn->offset + vf_index]; +if (!master_pe) { + pe->flags |=PNV_IODA_PE_MASTER ; +INIT_LIST_HEAD (&pe->slaves); + master_pe = pe; +mutex_lock (&phb->ioda.pe_list_mutex); +list_add_tail (&pe->list, &phb->ioda.pe_list); +mutex_unlock (&phb->ioda.pe_list_mutex); + }else { + pe->flags |=PNV_IODA_PE_SLAVE ; + pe->master = master_pe; +list_add_tail (&pe->list, + &master_pe->slaves); + } + for (vf_index1 = vf_group * vf_per_group; vf_index1 < (vf_group + 1) * vf_per_group && vf_index1 < num_vfs;
arch/powerpc/platforms/powernv/pci.c +15 -2
@@ -667,7 +667,7 @@ static void pnv_pci_dma_dev_setup(struct pci_dev *pdev)struct pci_controller *hose =pci_bus_to_host (pdev->bus);struct pnv_phb *phb = hose->private_data;#ifdef CONFIG_PCI_IOV -struct pnv_ioda_pe *pe; +struct pnv_ioda_pe *pe, *slave;struct pci_dn *pdn;/* Fix the VF pdn PE number */
@@ -679,10 +679,23 @@ static void pnv_pci_dma_dev_setup(struct pci_dev *pdev) (pdev->devfn & 0xff))) { pdn->pe_number = pe->pe_number; pe->pdev = pdev; -break ; + goto found; + } + +if ((pe->flags &PNV_IODA_PE_MASTER ) && + (pe->flags &PNV_IODA_PE_VF )) { +list_for_each_entry (slave, &pe->slaves, list) { +if (slave->rid == ((pdev->bus->number <<8 ) + | (pdev->devfn &0xff ))) { + pdn->pe_number = slave->pe_number; + slave->pdev = pdev; + goto found; + } + } } } } +found: #endif /* CONFIG_PCI_IOV */if (phb && phb->dma_dev_setup)
Signature · 1 line
1.7.9.5
PATCH v8 7/10 powerpc/powernv: Support EEH reset for VF PE
In reply to Wei YangPEs for VFs don't have primary bus. So they have to have their own reset backend, which is used during EEH recovery. The patch implements the reset backend for VF's PE by issuing FLR or AF FLR to the VFs, which are contained in the PE.
--- arch/powerpc/include/asm/eeh.h | 1 + arch/powerpc/platforms/powernv/eeh-powernv.c | 134 +++++++++++++++++++++++++- 2 files changed, 134 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/eeh.h +1 -0
@@ -134,6 +134,7 @@ struct eeh_dev {int pcix_cap;/* Saved PCIx capability */ int pcie_cap;/* Saved PCIe capability */ int aer_cap;/* Saved AER capability */ +int af_cap;/* Saved AF capability */ struct eeh_pe *pe;/* Associated PE */ struct list_head list;/* Form link list in the PE */ struct pci_controller *phb;/* Associated PHB */
arch/powerpc/platforms/powernv/eeh-powernv.c +133 -1
158 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Bjorn Helgaas
maintainerRe: [PATCH V8 06/10] powerpc/eeh: Create PE for VFs
In reply to Wei YangQuoted 99 lines · Wei Yang
Current EEH recovery code works with the assumption: the PE has primary bus. Unfortunately, that's not true for VF PEs, which generally contains one or multiple VFs (for VF group case).
The patch introduces a weak function
pcibios_bus_add_device()which is called bypci_bus_add_device(). In this function, we creates PEs for VFs. Those PEs for VFs are identified with newly introduced flagEEH_PE_VFso that we handle them differently during EEH recovery.[gwshan: changelog and code refactoring]Signed-off-by Wei Yang <[email protected]>Acked-by Gavin Shan <[email protected]>--- arch/powerpc/include/asm/eeh.h | 1 + arch/powerpc/kernel/eeh_pe.c | 10 ++++++++-- arch/powerpc/platforms/powernv/eeh-powernv.c | 16 ++++++++++++++++ drivers/pci/bus.c | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-)arch/powerpc/include/asm/eeh.h +1
-0@@ -70,6 +70,7 @@ struct pci_dn;#define EEH_PE_PHB (1 << 1)/* PHB PE */ #define EEH_PE_DEVICE (1 << 2)/* Device PE */ #define EEH_PE_BUS (1 << 3)/* Bus PE */ +#define EEH_PE_VF (1 << 4)/* VF PE */ #define EEH_PE_ISOLATED (1 << 0)/* Isolated PE */ #define EEH_PE_RECOVERING (1 << 1)/* Recovering PE */ arch/powerpc/kernel/eeh_pe.c +8
-2@@ -299,7 +299,10 @@ static struct eeh_pe *eeh_pe_get_parent(struct eeh_dev *edev)* EEH device already having associated PE, but * the direct parent EEH device doesn't have yet. */ - pdn = pdn ? pdn->parent :NULL ; +if (edev->physfn) + pdn =pci_get_pdn (edev->physfn); +else + pdn = pdn ? pdn->parent :NULL ;while (pdn) {/* We're poking out of PCI territory */ parent =pdn_to_eeh_dev (pdn);@@ -382,7 +385,10 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev) }/* Create a new EEH PE */ - pe =eeh_pe_alloc (edev->phb,EEH_PE_DEVICE ); +if (edev->physfn) + pe =eeh_pe_alloc (edev->phb,EEH_PE_VF ); +else + pe =eeh_pe_alloc (edev->phb,EEH_PE_DEVICE );if (!pe) {pr_err ("%s: out of memory!\n" , __func__);return -ENOMEM ;arch/powerpc/platforms/powernv/eeh-powernv.c +16
-0@@ -1520,6 +1520,22 @@ static struct eeh_ops pnv_eeh_ops = { .restore_config = pnv_eeh_restore_config }; +void pcibios_bus_add_device (struct pci_dev *pdev) +{ +struct pci_dn *pdn =pci_get_pdn (pdev); + +if (!pdev->is_virtfn) +return ; + +/* +* The following operations will fail if VF's sysfs files +* aren't created or its resources aren't finalized. +*/ +eeh_add_device_early (pdn); +eeh_add_device_late (pdev); +eeh_sysfs_add_device (pdev); +} +/** * eeh_powernv_init - Register platform dependent EEH operations * drivers/pci/bus.c +1
-0@@ -267,6 +267,7 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx)void __weak pcibios_resource_survey_bus (struct pci_bus *bus) { } +void __weak pcibios_bus_add_device (struct pci_dev *dev) { }/** * pci_bus_add_device - start driver for a single device * @dev: device to add
drivers/pci/bus.c void pci_bus_add_device(struct pci_dev *dev) · line 281
Quoted 4 lines
drivers/pci/bus.c +1
-0@@ -277,6 +278,7 @@ void pci_bus_add_device(struct pci_dev *dev) {int retval; +pcibios_bus_add_device (dev);
Add a blank line here.
drivers/pci/bus.c void pci_bus_add_device(struct pci_dev *dev) · line 284
Quoted 3 lines
drivers/pci/bus.c +0
-0/* * Can not put in pci_device_add yet because resources * are not assigned yet for some devices.
Please put the drivers/pci/bus.c change in a separate patch so it's clear that we're changing the PCI core here, not just the powerpc code. That will also make it possible to revert the powerpc change if necessary without breaking any other pcibios_bus_add_device() users that may be added.
You can add my Acked-by: to the new drivers/pci/bus.c patch.
Bjorn