SR-IOV Enablement on PowerVM
Subsystems (3)
v4 cover SR-IOV Enablement on PowerVM
This patch series will enable SR-IOV on PowerVM. A specific set of lids for PFW/PHYP is required. They are planned to release with 920 at the moment.
For IBM internal testers let me know of a system you want to test on and we can put on the lids required or we can provide a system to run the tests.
This patch depends on the three patches:988fc3ba5653278a8c14d6ccf687371775930d2bdae7253f9f78a731755ca20c66b2d2c40b86baea608c0d8804ef3ca4cda8ec6ad914e47deb283d7b
v1 - Initial Patch
v2 - Addressed Alexey and Russell's comments
v3 - Unify the call of .error_detected()
v4 - Fixed subject and change log per Bjorn's comments and
fixed Alexey's comments
Bryant G. Ly (7):
platform/pseries: Update VF config space after EEH linux/pci: Add uevents in AER and EEH error/resume platforms/pseries: Set eeh_pe of EEH_PE_VF type powerpc/kernel Add EEH operations to notify resume powerpc/kernel: Add EEH notify resume sysfs pseries/pci: Associate PEs to VFs in configure SR-IOV pseries/setup: Add Initialization of VF Bars
arch/powerpc/include/asm/eeh.h | 2 + arch/powerpc/include/asm/pci-bridge.h | 5 +- arch/powerpc/include/asm/pci.h | 2 + arch/powerpc/kernel/eeh.c | 59 ++++++++++ arch/powerpc/kernel/eeh_driver.c | 6 + arch/powerpc/kernel/eeh_sysfs.c | 45 ++++++++ arch/powerpc/kernel/pci_of_scan.c | 2 +- arch/powerpc/platforms/powernv/eeh-powernv.c | 68 +---------- arch/powerpc/platforms/pseries/eeh_pseries.c | 137 +++++++++++++++++++++- arch/powerpc/platforms/pseries/pci.c | 150 +++++++++++++++++++++++- arch/powerpc/platforms/pseries/setup.c | 164 +++++++++++++++++++++++++++ drivers/pci/pcie/aer/aerdrv_core.c | 3 + include/linux/pci.h | 36 ++++++ 13 files changed, 611 insertions(+), 68 deletions(-)
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH v4 1/7 platform/pseries: Update VF config space after EEH
Add EEH platform operations for pseries to update VF config space. With this change after EEH, the VF will have updated config space for pseries platform.
--- arch/powerpc/include/asm/eeh.h | 1 + arch/powerpc/kernel/eeh.c | 59 +++++++++++++++++++++++++ arch/powerpc/platforms/powernv/eeh-powernv.c | 65 ++-------------------------- arch/powerpc/platforms/pseries/eeh_pseries.c | 26 ++++++++++- 4 files changed, 88 insertions(+), 63 deletions(-)
arch/powerpc/include/asm/eeh.h +1 -0
@@ -297,6 +297,7 @@ int eeh_pe_reset(struct eeh_pe *pe, int option);int eeh_pe_configure (struct eeh_pe *pe);int eeh_pe_inject_err (struct eeh_pe *pe,int type,int func,unsigned long addr,unsigned long mask); +int eeh_restore_vf_config (struct pci_dn *pdn);/** * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
arch/powerpc/kernel/eeh.c +59 -0
65 lines not on this page · raw message
arch/powerpc/platforms/powernv/eeh-powernv.c +3 -62
87 lines not on this page · raw message
arch/powerpc/platforms/pseries/eeh_pseries.c +25 -1
@@ -708,6 +708,30 @@ static int pseries_eeh_write_config(struct pci_dn *pdn, int where, int size, u32return rtas_write_config (pdn, where, size, val); } +static int pseries_eeh_restore_config (struct pci_dn *pdn) +{ +struct eeh_dev *edev =pdn_to_eeh_dev (pdn); +s64 ret =0 ; + +if (!edev) +return -EEXIST ; + +/* +* FIXME: The MPS, error routing rules, timeout setting are worthy +* to be exported by firmware in extendible way. +*/ +if (edev->physfn) + ret =eeh_restore_vf_config (pdn); + +if (ret) { +pr_warn ("%s: Can't reinit PCI dev 0x%x (%lld)\n" , + __func__, edev->pe_config_addr, ret); +return -EIO ; + } + +return ret; +} +static struct eeh_ops pseries_eeh_ops = { .name ="pseries" , .init = pseries_eeh_init,
@@ -723,7 +747,7 @@ static struct eeh_ops pseries_eeh_ops = { .read_config = pseries_eeh_read_config, .write_config = pseries_eeh_write_config, .next_error = NULL, - .restore_config = NULL + .restore_config = pseries_eeh_restore_config };/**
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH v4 2/7 linux/pci: Add uevents in AER and EEH error/resume
In reply to Bryant G. LyDevices can go offline when erors reported. This patch adds a change to the kernel object and lets udev know of error. When device resumes, a change is also set reporting device as online. Therefore, EEH and AER events are better propagated to user space for PCI devices in all arches.
--- arch/powerpc/kernel/eeh_driver.c | 6 ++++++ drivers/pci/pcie/aer/aerdrv_core.c | 3 +++ include/linux/pci.h | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+)
arch/powerpc/kernel/eeh_driver.c +6 -0
@@ -228,6 +228,7 @@ static void *eeh_report_error(void *data, void *userdata) edev->in_error = true;eeh_pcid_put (dev); +pci_uevent_ers (dev,PCI_ERS_RESULT_NONE );return NULL ; }
@@ -381,6 +382,10 @@ static void *eeh_report_resume(void *data, void *userdata) driver->err_handler->resume (dev);eeh_pcid_put (dev); +pci_uevent_ers (dev,PCI_ERS_RESULT_RECOVERED ); +#ifdef CONFIG_PCI_IOV + eeh_ops->notify_resume (eeh_dev_to_pdn (edev)); +#endif return NULL ; }
@@ -416,6 +421,7 @@ static void *eeh_report_failure(void *data, void *userdata) driver->err_handler->error_detected (dev, pci_channel_io_perm_failure);eeh_pcid_put (dev); +pci_uevent_ers (dev,PCI_ERS_RESULT_DISCONNECT );return NULL ; }
drivers/pci/pcie/aer/aerdrv_core.c +3 -0
@@ -278,6 +278,7 @@ static int report_error_detected(struct pci_dev *dev, void *data) }else { err_handler = dev->driver->err_handler; vote = err_handler->error_detected (dev, result_data->state); +pci_uevent_ers (dev,PCI_ERS_RESULT_NONE ); } result_data->result =merge_result (result_data->result, vote);
@@ -341,6 +342,7 @@ static int report_resume(struct pci_dev *dev, void *data) err_handler = dev->driver->err_handler; err_handler->resume (dev); +pci_uevent_ers (dev,PCI_ERS_RESULT_RECOVERED ); out:device_unlock (&dev->dev);return 0 ;
@@ -541,6 +543,7 @@ static void do_recovery(struct pci_dev *dev, int severity)return ; failed: +pci_uevent_ers (dev,PCI_ERS_RESULT_DISCONNECT );/* TODO: Should kernel panic here? */ dev_info (&dev->dev,"AER: Device recovery failed\n" ); }
include/linux/pci.h +36 -0
@@ -2277,6 +2277,42 @@ static inline bool pci_is_thunderbolt_attached(struct pci_dev *pdev)return false; } +/** +* pci_uevent_ers - emit a uevent during recovery path of pci device +* @pdev: pci device to check +* @err_type: type of error event +* +*/ +static inline void pci_uevent_ers (struct pci_dev *pdev, +enum pci_ers_result err_type) +{ +int idx =0 ; +char *envp[3 ]; + +switch (err_type) { +case PCI_ERS_RESULT_NONE : +case PCI_ERS_RESULT_CAN_RECOVER : + envp[idx++] ="ERROR_EVENT=BEGIN_RECOVERY" ; + envp[idx++] ="DEVICE_ONLINE=0" ; +break ; +case PCI_ERS_RESULT_RECOVERED : + envp[idx++] ="ERROR_EVENT=SUCCESSFUL_RECOVERY" ; + envp[idx++] ="DEVICE_ONLINE=1" ; +break ; +case PCI_ERS_RESULT_DISCONNECT : + envp[idx++] ="ERROR_EVENT=FAILED_RECOVERY" ; + envp[idx++] ="DEVICE_ONLINE=0" ; +break ; +default : +break ; + } + +if (idx >0 ) { + envp[idx++] =NULL ; +kobject_uevent_env (&pdev->dev.kobj,KOBJ_CHANGE , envp); + } +} +/* provide the legacy pci_dma_* API */ #include <linux/pci-dma-compat.h>
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH v4 3/7 platforms/pseries: Set eeh_pe of EEH_PE_VF type
In reply to Bryant G. LyTo correctly use EEH code one has to make sure that the EEH_PE_VF is set for dynamic created VFs. Therefore this patch allocates an eeh_pe of eeh type EEH_PE_VF and associates PE with parent.
--- arch/powerpc/include/asm/pci-bridge.h | 5 ++++- arch/powerpc/platforms/pseries/eeh_pseries.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/pci-bridge.h +4 -1
@@ -211,7 +211,10 @@ struct pci_dn {unsigned int *pe_num_map;/* PE# for the first VF PE or array */ bool m64_single_mode;/* Use M64 BAR in Single Mode */ #define IODA_INVALID_M64 (-1) -int (*m64_map)[PCI_SRIOV_NUM_BARS ]; +union { +int (*m64_map)[PCI_SRIOV_NUM_BARS ];/*Only used in powernv */ +int last_allow_rc;/* Only used in pSeries */ + };#endif /* CONFIG_PCI_IOV */ int mps;/* Maximum Payload Size */ struct list_head child_list;
arch/powerpc/platforms/pseries/eeh_pseries.c +17 -0
@@ -55,9 +55,12 @@ static int ibm_get_config_addr_info;static int ibm_get_config_addr_info2;static int ibm_configure_pe; +#ifdef CONFIG_PCI_IOV void pseries_pcibios_bus_add_device (struct pci_dev *pdev) {struct pci_dn *pdn =pci_get_pdn (pdev); +struct pci_dn *physfn_pdn; +struct eeh_dev *edev;if (!pdev->is_virtfn)return ;
@@ -65,6 +68,14 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev) pdn->device_id = pdev->device; pdn->vendor_id = pdev->vendor; pdn->class_code = pdev->class; +/* Last allow unfreeze return code used for retrieval +* by user space in eeh-sysfs to show the last command +* completion from platform +*/ + pdn->last_allow_rc =0 ; + physfn_pdn =pci_get_pdn (pdev->physfn); + pdn->pe_number = physfn_pdn->pe_num_map[pdn->vf_index]; + edev =pdn_to_eeh_dev (pdn);/* * The following operations will fail if VF's sysfs files
@@ -72,9 +83,13 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)*/ eeh_add_device_early (pdn);eeh_add_device_late (pdev); + edev->pe_config_addr = (pdn->busno <<16 ) | (pdn->devfn <<8 ); +eeh_rmv_from_parent_pe (edev);/* Remove as it is adding to bus pe */ +eeh_add_to_parent_pe (edev);/* Add as VF PE type */ eeh_sysfs_add_device(pdev); } +#endif /* * Buffer for reporting slot-error-detail rtas calls. Its here
@@ -141,8 +156,10 @@ static int pseries_eeh_init(void)/* Set EEH probe mode */ eeh_add_flag (EEH_PROBE_MODE_DEVTREE |EEH_ENABLE_IO_FOR_LOG ); +#ifdef CONFIG_PCI_IOV /* Set EEH machine dependent code */ ppc_md.pcibios_bus_add_device = pseries_pcibios_bus_add_device; +#endif return 0 ; }
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH v4 4/7 powerpc/kernel Add EEH operations to notify resume
In reply to Bryant G. LyWhen pseries SR-IOV is enabled and after a PF driver has resumed from EEH, platform has to be notified of the event so the child VFs can be allowed to resume their normal recovery path.
This patch makes the EEH operation allow unfreeze platform dependent code and adds the call to pseries EEH code.
--- arch/powerpc/include/asm/eeh.h | 1 + arch/powerpc/platforms/powernv/eeh-powernv.c | 3 +- arch/powerpc/platforms/pseries/eeh_pseries.c | 96 +++++++++++++++++++++++++++- 3 files changed, 98 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/eeh.h +1 -0
@@ -214,6 +214,7 @@ struct eeh_ops {int (*write_config)(struct pci_dn *pdn,int where,int size,u32 val);int (*next_error)(struct eeh_pe **pe);int (*restore_config)(struct pci_dn *pdn); +int (*notify_resume)(struct pci_dn *pdn); };extern int eeh_subsystem_flags;
arch/powerpc/platforms/powernv/eeh-powernv.c +2 -1
@@ -1704,7 +1704,8 @@ static struct eeh_ops pnv_eeh_ops = { .read_config = pnv_eeh_read_config, .write_config = pnv_eeh_write_config, .next_error = pnv_eeh_next_error, - .restore_config = pnv_eeh_restore_config + .restore_config = pnv_eeh_restore_config, + .notify_resume = NULL };#ifdef CONFIG_PCI_IOV
arch/powerpc/platforms/pseries/eeh_pseries.c +95 -1
108 lines not on this page · raw message
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH v4 5/7 powerpc/kernel: Add EEH notify resume sysfs
In reply to Bryant G. LyIntroduce a method for notify resume to be
called from sysfs. In this patch one can
now call notify resume from sysfs when
is supported by platform.
--- arch/powerpc/kernel/eeh_sysfs.c | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
arch/powerpc/kernel/eeh_sysfs.c +45 -0
@@ -90,6 +90,38 @@ static ssize_t eeh_pe_state_store(struct device *dev,static DEVICE_ATTR_RW (eeh_pe_state); +#ifdef CONFIG_PCI_IOV +static ssize_t eeh_notify_resume_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct eeh_dev *edev =pci_dev_to_eeh_dev (pdev); +struct pci_dn *pdn =pci_get_pdn (pdev); + +if (!edev || !edev->pe) +return -ENODEV ; + + pdn =pci_get_pdn (pdev); +return sprintf (buf,"%d\n" , pdn->last_allow_rc); +} + +static ssize_t eeh_notify_resume_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct eeh_dev *edev =pci_dev_to_eeh_dev (pdev); + +if (!edev || !edev->pe) +return -ENODEV ; + +if (eeh_ops->notify_resume (pci_get_pdn (pdev))) +return -EIO ; +return count; +} +static DEVICE_ATTR_RW (eeh_notify_resume); +#endif +void eeh_sysfs_add_device (struct pci_dev *pdev) {struct eeh_dev *edev =pci_dev_to_eeh_dev (pdev);
@@ -105,6 +137,13 @@ void eeh_sysfs_add_device(struct pci_dev *pdev) rc +=device_create_file (&pdev->dev, &dev_attr_eeh_pe_config_addr); rc +=device_create_file (&pdev->dev, &dev_attr_eeh_pe_state); +#ifdef CONFIG_PCI_IOV +if (of_get_property (pci_device_to_OF_node + ((pdev->is_physfn ? pdev : pdev->physfn)), +"ibm,is-open-sriov-pf" ,NULL )) + rc +=device_create_file (&pdev->dev, + &dev_attr_eeh_notify_resume); +#endif if (rc)pr_warn ("EEH: Unable to create sysfs entries\n" );else if (edev)
@@ -128,6 +167,12 @@ void eeh_sysfs_remove_device(struct pci_dev *pdev)device_remove_file (&pdev->dev, &dev_attr_eeh_mode);device_remove_file (&pdev->dev, &dev_attr_eeh_pe_config_addr);device_remove_file (&pdev->dev, &dev_attr_eeh_pe_state); +#ifdef CONFIG_PCI_IOV +if (of_get_property (pci_device_to_OF_node + ((pdev->is_physfn ? pdev : pdev->physfn)), +"ibm,is-open-sriov-pf" ,NULL )) +device_remove_file (&pdev->dev, &dev_attr_eeh_notify_resume); +#endif if (edev) edev->mode &= ~EEH_DEV_SYSFS ;
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH v4 6/7 pseries/pci: Associate PEs to VFs in configure SR-IOV
In reply to Bryant G. LyAfter initial validation of SR-IOV resources, firmware will associate PEs to the dynamic VFs created within this call. This patch adds the association of PEs to the PF array of PE numbers indexed by VF.
--- arch/powerpc/platforms/pseries/pci.c | 150 ++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/pci.c +148 -2
@@ -59,16 +59,162 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device);#endif #ifdef CONFIG_PCI_IOV +#define MAX_VFS_FOR_MAP_PE 256 +struct pe_map_bar_entry { +__be64 bar;/* Input: Virtual Function BAR */ +__be16 rid;/* Input: Virtual Function Router ID */ +__be16 pe_num;/* Output: Virtual Function PE Number */ +__be32 reserved;/* Reserved Space */ +}; + +int pseries_send_map_pe (struct pci_dev *pdev, +u16 num_vfs, +struct pe_map_bar_entry *vf_pe_array) +{ +struct pci_dn *pdn; +int rc; +unsigned long buid, addr; +int ibm_map_pes =rtas_token ("ibm,open-sriov-map-pe-number" ); + +if (ibm_map_pes ==RTAS_UNKNOWN_SERVICE ) +return -EINVAL ; + + pdn =pci_get_pdn (pdev); + addr =rtas_config_addr (pdn->busno, pdn->devfn,0 ); + buid = pdn->phb->buid; +spin_lock (&rtas_data_buf_lock); +memcpy (rtas_data_buf, vf_pe_array, +RTAS_DATA_BUF_SIZE ); + rc =rtas_call (ibm_map_pes,5 ,1 ,NULL , addr, +BUID_HI (buid),BUID_LO (buid), + rtas_data_buf, + num_vfs *sizeof (struct pe_map_bar_entry )); +memcpy (vf_pe_array, rtas_data_buf,RTAS_DATA_BUF_SIZE ); +spin_unlock (&rtas_data_buf_lock); + +if (rc) +dev_err (&pdev->dev, +"%s: Failed to associate pes PE#%lx, rc=%x\n" , + __func__, addr, rc); + +return rc; +} + +void pseries_set_pe_num (struct pci_dev *pdev,u16 vf_index,__be16 pe_num) +{ +struct pci_dn *pdn; + + pdn =pci_get_pdn (pdev); + pdn->pe_num_map[vf_index] =be16_to_cpu (pe_num); +dev_dbg (&pdev->dev,"VF %04x:%02x:%02x.%x associated with PE#%x\n" , +pci_domain_nr (pdev->bus), + pdev->bus->number, +PCI_SLOT (pci_iov_virtfn_devfn (pdev, vf_index)), +PCI_FUNC (pci_iov_virtfn_devfn (pdev, vf_index)), + pdn->pe_num_map[vf_index]); +} + +int pseries_associate_pes (struct pci_dev *pdev,u16 num_vfs) +{ +struct pci_dn *pdn; +int i, rc, vf_index; +struct pe_map_bar_entry *vf_pe_array; +struct resource *res; +u64 size; + + vf_pe_array =kzalloc (RTAS_DATA_BUF_SIZE ,GFP_KERNEL ); +if (!vf_pe_array) +return -ENOMEM ; + + pdn =pci_get_pdn (pdev); +/* create firmware structure to associate pes */ +for (vf_index =0 ; vf_index < num_vfs; vf_index++) { + pdn->pe_num_map[vf_index] =IODA_INVALID_PE ; +for (i =0 ; i <PCI_SRIOV_NUM_BARS ; i++) { + res = &pdev->resource[i +PCI_IOV_RESOURCES ]; +if (!res->parent) +continue ; + size =pcibios_iov_resource_alignment (pdev, i + +PCI_IOV_RESOURCES ); + vf_pe_array[vf_index].bar = +cpu_to_be64 (res->start + size * vf_index); + vf_pe_array[vf_index].rid = +cpu_to_be16 ((pci_iov_virtfn_bus (pdev, vf_index) + <<8 ) |pci_iov_virtfn_devfn (pdev, + vf_index)); + vf_pe_array[vf_index].pe_num = +cpu_to_be16 (IODA_INVALID_PE ); + } + } + + rc =pseries_send_map_pe (pdev, num_vfs, vf_pe_array); +/* Only zero is success */ +if (!rc) +for (vf_index =0 ; vf_index < num_vfs; vf_index++) +pseries_set_pe_num (pdev, vf_index, + vf_pe_array[vf_index].pe_num); + +kfree (vf_pe_array); +return rc; +} + +int pseries_pci_sriov_enable (struct pci_dev *pdev,u16 num_vfs) +{ +struct pci_dn *pdn; +int rc; +const int *max_vfs; +int max_config_vfs; +struct device_node *dn =pci_device_to_OF_node (pdev); + + max_vfs =of_get_property (dn,"ibm,number-of-configurable-vfs" ,NULL ); + +if (!max_vfs) +return -EINVAL ; + +/* First integer stores max config */ + max_config_vfs =of_read_number (&max_vfs[0 ],1 ); +if (max_config_vfs < num_vfs && num_vfs >MAX_VFS_FOR_MAP_PE ) { +dev_err (&pdev->dev, +"Num VFs %x > %x Configurable VFs\n" , + num_vfs, (num_vfs >MAX_VFS_FOR_MAP_PE ) ? +MAX_VFS_FOR_MAP_PE : max_config_vfs); +return -EINVAL ; + } + + pdn =pci_get_pdn (pdev); + pdn->pe_num_map =kmalloc_array (num_vfs, +sizeof (*pdn->pe_num_map), +GFP_KERNEL ); +if (!pdn->pe_num_map) +return -ENOMEM ; + + rc =pseries_associate_pes (pdev, num_vfs); + +/* Anything other than zero is failure */ +if (rc) { +dev_err (&pdev->dev,"Failure to enable sriov: %x\n" , rc); +kfree (pdn->pe_num_map); + }else { +pci_vf_drivers_autoprobe (pdev, false); + } + +return rc; +} +int pseries_pcibios_sriov_enable (struct pci_dev *pdev,u16 num_vfs) {/* Allocate PCI data */ add_dev_pci_data (pdev); -pci_vf_drivers_autoprobe (pdev, false); -return 0 ; +return pseries_pci_sriov_enable (pdev, num_vfs); }int pseries_pcibios_sriov_disable (struct pci_dev *pdev) { +struct pci_dn *pdn; + + pdn =pci_get_pdn (pdev); +/* Releasing pe_num_map */ +kfree (pdn->pe_num_map);/* Release PCI data */ remove_dev_pci_data (pdev);pci_vf_drivers_autoprobe (pdev, true);
Signature · 1 line
2.14.3 (Apple Git-98)
PATCH v4 7/7 pseries/setup: Add Initialization of VF Bars
In reply to Bryant G. LyWhen enabling SR-IOV in pseries platform,
the VF bar properties for a PF are reported on the device node in the device tree.
This patch adds the IOV Bar resources to Linux structures from the device tree for later use when configuring SR-IOV by PF driver.
--- arch/powerpc/include/asm/pci.h | 2 + arch/powerpc/kernel/pci_of_scan.c | 2 +- arch/powerpc/platforms/pseries/setup.c | 164 +++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/pci.h +2 -0
@@ -121,6 +121,8 @@ extern int remove_phb_dynamic(struct pci_controller *phb);extern struct pci_dev *of_create_pci_dev (struct device_node *node,struct pci_bus *bus,int devfn); +extern unsigned int pci_parse_of_flags (u32 addr0,int bridge); +extern void of_scan_pci_bridge (struct pci_dev *dev);extern void of_scan_bus (struct device_node *node,struct pci_bus *bus);
arch/powerpc/kernel/pci_of_scan.c +1 -1
@@ -38,7 +38,7 @@ static u32 get_int_prop(struct device_node *np, const char *name, u32 def)* @addr0: value of 1st cell of a device tree PCI address. * @bridge: Set this flag if the address is from a bridge 'ranges' property */ -static unsigned int pci_parse_of_flags (u32 addr0,int bridge) +unsigned int pci_parse_of_flags (u32 addr0,int bridge) {unsigned int flags =0 ;
arch/powerpc/platforms/pseries/setup.c +164 -0
176 lines not on this page · raw message
Signature · 1 line
2.14.3 (Apple Git-98)
Re: [PATCH v4 2/7] linux/pci: Add uevents in AER and EEH error/resume
In reply to Bryant G. LyI doubt "linux/pci: " matches the powerpc convention and I know it doesn't match the drivers/pci convention.
I'd suggest matching one or the other. In drivers/pci I would be using "PCI/AER: ".
Quoted 138 lines · Bryant G. Ly
Devices can go offline when erors reported. This patch adds a change to the kernel object and lets udev know of error. When device resumes, a change is also set reporting device as online. Therefore, EEH and AER events are better propagated to user space for PCI devices in all arches.
Signed-off-by Bryant G. Ly <[email protected]>Signed-off-by Juan J. Alvarez <[email protected]>Acked-by Bjorn Helgaas <[email protected]>--- arch/powerpc/kernel/eeh_driver.c | 6 ++++++ drivers/pci/pcie/aer/aerdrv_core.c | 3 +++ include/linux/pci.h | 36 ++++++++++++++++++++++++++++++ ++++++ 3 files changed, 45 insertions(+)arch/powerpc/kernel/eeh_ renamed from arch/powerpc/kernel/eeh_driver.c +0
-0
driver.c
index3c0fa99c5533..beea2182d754100644arch/powerpc/kernel/eeh_driver.c +6
-0@@ -228,6 +228,7 @@ static void *eeh_report_error(void *data, void *userdata) edev->in_error = true;eeh_pcid_put (dev); +pci_uevent_ers (dev,PCI_ERS_RESULT_NONE );return NULL ; }@@ -381,6 +382,10 @@ static void *eeh_report_resume(void *data, void *userdata) driver->err_handler->resume (dev);eeh_pcid_put (dev); +pci_uevent_ers (dev,PCI_ERS_RESULT_RECOVERED ); +#ifdef CONFIG_PCI_IOV + eeh_ops->notify_resume (eeh_dev_to_pdn (edev)); +#endif return NULL ; }@@ -416,6 +421,7 @@ static void *eeh_report_failure(void *data, void *userdata) driver->err_handler->error_detected (dev, pci_channel_io_perm_failure);eeh_pcid_put (dev); +pci_uevent_ers (dev,PCI_ERS_RESULT_DISCONNECT );return NULL ;}
drivers/pci/pcie/aer/aerdrv_core.c +1
-0@@ -278,6 +278,7 @@ static int report_error_detected(struct pci_dev *dev, void *data) }else { err_handler = dev->driver->err_handler; vote = err_handler->error_detected (dev, result_data->state); +pci_uevent_ers (dev,PCI_ERS_RESULT_NONE ); }result_data->result = merge_result(result_data->result, vote);drivers/pci/pcie/aer/aerdrv_core.c +1
-0@@ -341,6 +342,7 @@ static int report_resume(struct pci_dev *dev, void *data) err_handler = dev->driver->err_handler; err_handler->resume (dev); +pci_uevent_ers (dev,PCI_ERS_RESULT_RECOVERED ); out:device_unlock (&dev->dev);return 0;drivers/pci/pcie/aer/aerdrv_core.c +1
-0@@ -541,6 +543,7 @@ static void do_recovery(struct pci_dev *dev, int severity)return ; failed: +pci_uevent_ers (dev,PCI_ERS_RESULT_DISCONNECT );/* TODO: Should kernel panic here? */ dev_info (&dev->dev,"AER: Device recovery failed\n" );}
include/linux/pci.h +36
-1@@ -2277,6 +2277,42 @@ static inline bool pci_is_thunderbolt_attached(struct pci_dev *pdev)return false; } +/** +* pci_uevent_ers - emit a uevent during recovery path of pci device +* @pdev: pci device to check +* @err_type: type of error event +* +*/ +static inline void pci_uevent_ers (struct pci_dev *pdev, +enum pci_ers_result err_type) +{ +int idx =0 ; +char *envp[3 ]; + +switch (err_type) { +case PCI_ERS_RESULT_NONE : +case PCI_ERS_RESULT_CAN_RECOVER : + envp[idx++] ="ERROR_EVENT=BEGIN_RECOVERY" ; + envp[idx++] ="DEVICE_ONLINE=0" ; +break ; +case PCI_ERS_RESULT_RECOVERED : + envp[idx++] ="ERROR_EVENT=SUCCESSFUL_RECOVERY" ; + envp[idx++] ="DEVICE_ONLINE=1" ; +break ; +case PCI_ERS_RESULT_DISCONNECT : + envp[idx++] ="ERROR_EVENT=FAILED_RECOVERY" ; + envp[idx++] ="DEVICE_ONLINE=0" ; +break ; +default : +break ; + } + +if (idx >0 ) { + envp[idx++] =NULL ; +kobject_uevent_env (&pdev->dev.kobj,KOBJ_CHANGE , envp); + } +} +/* provide the legacy pci_dma_* API */ #include <linux/pci-dma-compat.h> --2.14.3 (Apple Git-98)
Mike Ellerman/Ben,
Do you know if we can make 4.16 with this?
-Bryant
Quoted 43 lines · Bryant G. Ly
This patch series will enable SR-IOV on PowerVM. A specific set of lids for PFW/PHYP is required. They are planned to release with 920 at the moment.
For IBM internal testers let me know of a system you want to test on and we can put on the lids required or we can provide a system to run the tests.
This patch depends on the three patches:
988fc3ba5653278a8c14d6ccf687371775930d2bdae7253f9f78a731755ca20c66b2d2c40b86baea608c0d8804ef3ca4cda8ec6ad914e47deb283d7bv1 - Initial Patch
v2 - Addressed Alexey and Russell's comments
v3 - Unify the call of .error_detected()
v4 - Fixed subject and change log per Bjorn's comments and
fixed Alexey's commentsBryant G. Ly (7):
platform/pseries: Update VF config space after EEH linux/pci: Add uevents in AER and EEH error/resume platforms/pseries: Seteeh_peofEEH_PE_VFtype powerpc/kernel Add EEH operations to notify resume powerpc/kernel: Add EEH notify resume sysfs pseries/pci: Associate PEs to VFs in configure SR-IOV pseries/setup: Add Initialization of VF Barsarch/powerpc/include/asm/eeh.h | 2 + arch/powerpc/include/asm/pci-bridge.h | 5 +- arch/powerpc/include/asm/pci.h | 2 + arch/powerpc/kernel/eeh.c | 59 ++++++++++ arch/powerpc/kernel/eeh_driver.c | 6 + arch/powerpc/kernel/eeh_sysfs.c | 45 ++++++++ arch/powerpc/kernel/pci_of_scan.c | 2 +- arch/powerpc/platforms/powernv/eeh-powernv.c | 68 +---------- arch/powerpc/platforms/pseries/eeh_pseries.c | 137 +++++++++++++++++++++- arch/powerpc/platforms/pseries/pci.c | 150 +++++++++++++++++++++++- arch/powerpc/platforms/pseries/setup.c | 164 +++++++++++++++++++++++++++ drivers/pci/pcie/aer/aerdrv_core.c | 3 + include/linux/pci.h | 36 ++++++ 13 files changed, 611 insertions(+), 68 deletions(-)
Michael Ellerman
reviewerRe: [PATCH v4 3/7] platforms/pseries: Set eeh_pe of EEH_PE_VF type
In reply to Bryant G. LyQuoted 18 lines · Bryant G. Ly
To correctly use EEH code one has to make sure that the
EEH_PE_VFis set for dynamic created VFs. Therefore this patch allocates aneeh_peof eeh typeEEH_PE_VFand associates PE with parent.Signed-off-by Bryant G. Ly <[email protected]>Signed-off-by Juan J. Alvarez <[email protected]>--- arch/powerpc/include/asm/pci-bridge.h | 5 ++++- arch/powerpc/platforms/pseries/eeh_pseries.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)arch/powerpc/include/asm/pci-bridge.h +0
-0@@ -211,7 +211,10 @@ struct pci_dn {unsigned int *pe_num_map;/* PE# for the first VF PE or array */
arch/powerpc/include/asm/pci-bridge.h struct pci_dn { · line 220
Quoted 10 lines
arch/powerpc/include/asm/pci-bridge.h +4
-1bool m64_single_mode;/* Use M64 BAR in Single Mode */ #define IODA_INVALID_M64 (-1) -int (*m64_map)[PCI_SRIOV_NUM_BARS ]; +union { +int (*m64_map)[PCI_SRIOV_NUM_BARS ];/*Only used in powernv */ +int last_allow_rc;/* Only used in pSeries */ + };#endif /* CONFIG_PCI_IOV */ int mps;/* Maximum Payload Size */ struct list_head child_list;
I don't see the point of using a union to save 4 bytes.
And if you look at the current layout of the struct there's actually a 4 byte hole after mps, so it doesn't actually save any space at all.
I can remove it before applying, unless there's some compelling reason for it I'm not seeing.
cheers
Quoted 13 lines · Bryant G. Ly
This patch series will enable SR-IOV on PowerVM. A specific set of lids for PFW/PHYP is required. They are planned to release with 920 at the moment.
For IBM internal testers let me know of a system you want to test on and we can put on the lids required or we can provide a system to run the tests.
This patch depends on the three patches:
988fc3ba5653278a8c14d6ccf687371775930d2bdae7253f9f78a731755ca20c66b2d2c40b86baea608c0d8804ef3ca4cda8ec6ad914e47deb283d7b
Quoted 5 lines
v1 - Initial Patch
v2 - Addressed Alexey and Russell's comments
v3 - Unify the call of .error_detected()
v4 - Fixed subject and change log per Bjorn's comments and
fixed Alexey's comments
For the whole series:
Re: [PATCH v4 3/7] platforms/pseries: Set eeh_pe of EEH_PE_VF type
In reply to Michael EllermanQuoted 32 lines · Michael Ellerman
Quoted 18 lines · Bryant G. Ly
To correctly use EEH code one has to make sure that the
EEH_PE_VFis set for dynamic created VFs. Therefore this patch allocates aneeh_peof eeh typeEEH_PE_VFand associates PE with parent.Signed-off-by Bryant G. Ly <[email protected]>Signed-off-by Juan J. Alvarez <[email protected]>--- arch/powerpc/include/asm/pci-bridge.h | 5 ++++- arch/powerpc/platforms/pseries/eeh_pseries.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)arch/powerpc/include/asm/pci-bridge.h +0
-0@@ -211,7 +211,10 @@ struct pci_dn {unsigned int *pe_num_map;/* PE# for the first VF PE or array */ arch/powerpc/include/asm/pci-bridge.h struct pci_dn { · line 220
Quoted 10 lines
arch/powerpc/include/asm/pci-bridge.h +4
-1bool m64_single_mode;/* Use M64 BAR in Single Mode */ #define IODA_INVALID_M64 (-1) -int (*m64_map)[PCI_SRIOV_NUM_BARS ]; +union { +int (*m64_map)[PCI_SRIOV_NUM_BARS ];/*Only used in powernv */ +int last_allow_rc;/* Only used in pSeries */ + };#endif /* CONFIG_PCI_IOV */ int mps;/* Maximum Payload Size */ struct list_head child_list;I don't see the point of using a union to save 4 bytes.
Quoted 7 lines
And if you look at the current layout of the struct there's actually a 4 byte hole after mps, so it doesn't actually save any space at all.
I can remove it before applying, unless there's some compelling reason for it I'm not seeing.
cheers
No specific reason for the union, you can go ahead and remove it before applying.
Thanks!
Bryant
Re: [v4,1/7] platform/pseries: Update VF config space after EEH
In reply to Bryant G. LyQuoted 6 lines · Bryant G. Ly
Add EEH platform operations for pseries to update VF config space. With this change after EEH, the VF will have updated config space for pseries platform.
Signed-off-by Bryant G. Ly <[email protected]>Signed-off-by Juan J. Alvarez <[email protected]>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/64ba3dc7bf7cb0cbc89821db54edfe
cheers
Michael Ellerman
AppliedRe: [v4,7/7] pseries/setup: Add Initialization of VF Bars
In reply to Bryant G. LyQuoted 10 lines · Bryant G. Ly
When enabling SR-IOV in pseries platform,
the VF bar properties for a PF are reported on the device node in the device tree.This patch adds the IOV Bar resources to Linux structures from the device tree for later use when configuring SR-IOV by PF driver.
Signed-off-by Bryant G. Ly <[email protected]>Signed-off-by Juan J. Alvarez <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/fc5f622163637308a3d520a3155274
cheers