powerpc/eeh: Remove eeh_dev_phb_init_dynamic()
Subsystems (2)
Oliver O'Halloran
reviewerPATCH v2 1/14 powerpc/eeh: Remove eeh_dev_phb_init_dynamic()
This function is a one line wrapper around eeh_phb_pe_create() and despite the name it doesn't create any eeh_dev structures. Replace it with direct calls to eeh_phb_pe_create() since that does what it says on the tin and removes a layer of indirection.
---
v2: Added sub prototype of eeh_phb_pe_create() for the !CONFIG_EEH case.
--- arch/powerpc/include/asm/eeh.h | 3 ++- arch/powerpc/kernel/eeh.c | 2 +- arch/powerpc/kernel/eeh_dev.c | 13 ------------- arch/powerpc/kernel/of_platform.c | 4 ++-- arch/powerpc/platforms/pseries/pci_dlpar.c | 2 +- 5 files changed, 6 insertions(+), 18 deletions(-)
arch/powerpc/include/asm/eeh.h +2 -1
@@ -294,7 +294,6 @@ const char *eeh_pe_loc_get(struct eeh_pe *pe);struct pci_bus *eeh_pe_bus_get (struct eeh_pe *pe);struct eeh_dev *eeh_dev_init (struct pci_dn *pdn); -void eeh_dev_phb_init_dynamic (struct pci_controller *phb);void eeh_show_enabled (void );int __init eeh_ops_register (struct eeh_ops *ops); int __exit eeh_ops_unregister(const char *name);
@@ -370,6 +369,8 @@ void pseries_eeh_init_edev_recursive(struct pci_dn *pdn);#else static inline void pseries_eeh_add_device_early (struct pci_dn *pdn) { }static inline void pseries_eeh_add_device_tree_early (struct pci_dn *pdn) { } + +static inline int eeh_phb_pe_create (struct pci_controller *phb) {return 0 ; }#endif #ifdef CONFIG_PPC64
arch/powerpc/kernel/eeh.c +1 -1
@@ -1096,7 +1096,7 @@ static int eeh_init(void)/* Initialize PHB PEs */ list_for_each_entry_safe (hose, tmp, &hose_list, list_node) -eeh_dev_phb_init_dynamic (hose); +eeh_phb_pe_create (hose);eeh_addr_cache_init ();
arch/powerpc/kernel/eeh_dev.c +0 -13
@@ -52,16 +52,3 @@ struct eeh_dev *eeh_dev_init(struct pci_dn *pdn)return edev; } - -/** -* eeh_dev_phb_init_dynamic - Create EEH devices for devices included in PHB -* @phb: PHB -* -* Scan the PHB OF node and its child association, then create the -* EEH devices accordingly -*/ -void eeh_dev_phb_init_dynamic (struct pci_controller *phb) -{ -/* EEH PE for PHB */ -eeh_phb_pe_create (phb); -}
arch/powerpc/kernel/of_platform.c +2 -2
@@ -62,8 +62,8 @@ static int of_pci_phb_probe(struct platform_device *dev)/* Init pci_dn data structures */ pci_devs_phb_init_dynamic (phb); -/* Create EEH PEs for the PHB */ -eeh_dev_phb_init_dynamic (phb); +/* Create EEH PE for the PHB */ +eeh_phb_pe_create (phb);/* Scan the bus */ pcibios_scan_phb (phb);
arch/powerpc/platforms/pseries/pci_dlpar.c +1 -1
@@ -34,7 +34,7 @@ struct pci_controller *init_phb_dynamic(struct device_node *dn)pci_devs_phb_init_dynamic (phb);/* Create EEH devices for the PHB */ -eeh_dev_phb_init_dynamic (phb); +eeh_phb_pe_create (phb);if (dn->child)pseries_eeh_init_edev_recursive (PCI_DN (dn));
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 2/14 powerpc/eeh: Remove eeh_dev.c
The only thing in this file is eeh_dev_init() which is allocates and initialises an eeh_dev based on a pci_dn. This is only ever called from pci_dn.c so move it into there and remove the file.
---
v2: no change
--- arch/powerpc/include/asm/eeh.h | 6 ---- arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/eeh_dev.c | 54 ---------------------------------- arch/powerpc/kernel/pci_dn.c | 20 +++++++++++++ 4 files changed, 21 insertions(+), 61 deletions(-) delete mode 100644 arch/powerpc/kernel/eeh_dev.c
arch/powerpc/include/asm/eeh.h +0 -6
@@ -293,7 +293,6 @@ void eeh_pe_restore_bars(struct eeh_pe *pe);const char *eeh_pe_loc_get (struct eeh_pe *pe);struct pci_bus *eeh_pe_bus_get (struct eeh_pe *pe); -struct eeh_dev *eeh_dev_init (struct pci_dn *pdn);void eeh_show_enabled (void );int __init eeh_ops_register (struct eeh_ops *ops); int __exit eeh_ops_unregister(const char *name);
@@ -339,11 +338,6 @@ static inline bool eeh_enabled(void)static inline void eeh_show_enabled (void ) { } -static inline void *eeh_dev_init (struct pci_dn *pdn,void *data) -{ -return NULL ; -} -static inline void eeh_dev_phb_init_dynamic (struct pci_controller *phb) { }static inline int eeh_check_failure (const volatile void __iomem *token)
arch/powerpc/kernel/Makefile +1 -1
@@ -71,7 +71,7 @@ obj-$(CONFIG_PPC_RTAS_DAEMON) += rtasd.o obj-$(CONFIG_RTAS_FLASH) += rtas_flash.o obj-$(CONFIG_RTAS_PROC) += rtas-proc.o obj-$(CONFIG_PPC_DT_CPU_FTRS) += dt_cpu_ftrs.o -obj-$(CONFIG_EEH) += eeh.o eeh_pe.o eeh_dev.o eeh_cache.o \ +obj-$(CONFIG_EEH) += eeh.o eeh_pe.o eeh_cache.o \ eeh_driver.o eeh_event.o eeh_sysfs.o obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
arch/powerpc/kernel/eeh_dev.c deleted +0 -54
54 lines not on this page · raw message
arch/powerpc/kernel/pci_dn.c +20 -0
@@ -124,6 +124,26 @@ struct pci_dn *pci_get_pdn(struct pci_dev *pdev)return NULL ; } +#ifdef CONFIG_EEH +static struct eeh_dev *eeh_dev_init (struct pci_dn *pdn) +{ +struct eeh_dev *edev; + +/* Allocate EEH device */ + edev =kzalloc (sizeof (*edev),GFP_KERNEL ); +if (!edev) +return NULL ; + +/* Associate EEH device with OF node */ + pdn->edev = edev; + edev->pdn = pdn; + edev->bdfn = (pdn->busno <<8 ) | pdn->devfn; + edev->controller = pdn->phb; + +return edev; +} +#endif /* CONFIG_EEH */ +#ifdef CONFIG_PCI_IOV static struct pci_dn *add_one_sriov_vf_pdn(struct pci_dn *parent, int vf_index,
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 3/14 powerpc/eeh: Move vf_index out of pci_dn and into eeh_dev
In reply to Oliver O'HalloranDrivers 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.
---
v2: Commit message fixup
--- arch/powerpc/include/asm/eeh.h | 3 +++ arch/powerpc/include/asm/pci-bridge.h | 1 - arch/powerpc/kernel/eeh_driver.c | 6 ++---- arch/powerpc/kernel/pci_dn.c | 7 ++++--- 4 files changed, 9 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/eeh.h +3 -0
@@ -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 */
arch/powerpc/include/asm/pci-bridge.h +0 -1
@@ -202,7 +202,6 @@ struct pci_dn {#define IODA_INVALID_PE 0xFFFFFFFFunsigned 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 */
arch/powerpc/kernel/eeh_driver.c +2 -4
@@ -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)
arch/powerpc/kernel/pci_dn.c +4 -3
@@ -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);
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 4/14 powerpc/pseries: Stop using pdn->pe_number
In reply to Oliver O'HalloranThe pci_dn->pe_number field is mainly used to track the IODA PE number of a device on PowerNV. At some point it grew a user in the pseries SR-IOV support which muddies the waters a bit, so remove it.
---
v2: no change
--- arch/powerpc/platforms/pseries/eeh_pseries.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/powerpc/platforms/pseries/eeh_pseries.c +4 -6
@@ -52,8 +52,6 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)dev_dbg (&pdev->dev,"EEH: Setting up device\n" );#ifdef CONFIG_PCI_IOV if (pdev->is_virtfn) { -struct pci_dn *physfn_pdn; - pdn->device_id = pdev->device; pdn->vendor_id = pdev->vendor; pdn->class_code = pdev->class;
@@ -63,8 +61,6 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)* 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]; }#endif pseries_eeh_init_edev (pdn);
@@ -772,8 +768,8 @@ int pseries_send_allow_unfreeze(struct pci_dn *pdn,static int pseries_call_allow_unfreeze (struct eeh_dev *edev) { +int cur_vfs =0 , rc =0 , vf_index, bus, devfn, vf_pe_num;struct pci_dn *pdn, *tmp, *parent, *physfn_pdn; -int cur_vfs =0 , rc =0 , vf_index, bus, devfn;u16 *vf_pe_array; vf_pe_array =kzalloc (RTAS_DATA_BUF_SIZE ,GFP_KERNEL );
@@ -806,8 +802,10 @@ static int pseries_call_allow_unfreeze(struct eeh_dev *edev) } }else { pdn =pci_get_pdn (edev->pdev); - vf_pe_array[0 ] =cpu_to_be16 (pdn->pe_number); physfn_pdn =pci_get_pdn (edev->physfn); + + vf_pe_num = physfn_pdn->pe_num_map[edev->vf_index]; + vf_pe_array[0 ] =cpu_to_be16 (vf_pe_num); rc =pseries_send_allow_unfreeze (physfn_pdn, vf_pe_array,1 ); pdn->last_allow_rc = rc;
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 5/14 powerpc/eeh: Kill off eeh_ops->get_pe_addr()
In reply to Oliver O'HalloranThis is used in precisely one place which is in pseries specific platform code. There's no need to have the callback in eeh_ops since the platform chooses the EEH PE addresses anyway. The PowerNV implementation has always been a stub too so remove it.
---
v2: Made "buid" in pseries_eeh_get_pe_addr() an unsigned long to match
the pci_controller type.
--- arch/powerpc/include/asm/eeh.h | 1 - arch/powerpc/platforms/powernv/eeh-powernv.c | 13 ------------ arch/powerpc/platforms/pseries/eeh_pseries.c | 22 ++++++++++---------- 3 files changed, 11 insertions(+), 25 deletions(-)
arch/powerpc/include/asm/eeh.h +0 -1
@@ -220,7 +220,6 @@ struct eeh_ops {int (*init)(void );struct eeh_dev *(*probe)(struct pci_dev *pdev);int (*set_option)(struct eeh_pe *pe,int option); -int (*get_pe_addr)(struct eeh_pe *pe);int (*get_state)(struct eeh_pe *pe,int *delay);int (*reset)(struct eeh_pe *pe,int option);int (*get_log)(struct eeh_pe *pe,int severity,char *drv_log,unsigned long len);
arch/powerpc/platforms/powernv/eeh-powernv.c +0 -13
@@ -535,18 +535,6 @@ static int pnv_eeh_set_option(struct eeh_pe *pe, int option)return 0 ; } -/** -* pnv_eeh_get_pe_addr - Retrieve PE address -* @pe: EEH PE -* -* Retrieve the PE address according to the given tranditional -* PCI BDF (Bus/Device/Function) address. -*/ -static int pnv_eeh_get_pe_addr (struct eeh_pe *pe) -{ -return pe->addr; -} -static void pnv_eeh_get_phb_diag (struct eeh_pe *pe) {struct pnv_phb *phb = pe->phb->private_data;
@@ -1670,7 +1658,6 @@ static struct eeh_ops pnv_eeh_ops = { .init = pnv_eeh_init, .probe = pnv_eeh_probe, .set_option = pnv_eeh_set_option, - .get_pe_addr = pnv_eeh_get_pe_addr, .get_state = pnv_eeh_get_state, .reset = pnv_eeh_reset, .get_log = pnv_eeh_get_log,
arch/powerpc/platforms/pseries/eeh_pseries.c +11 -11
@@ -32,6 +32,8 @@#include <asm/ppc-pci.h> #include <asm/rtas.h> +static int pseries_eeh_get_pe_addr (struct pci_dn *pdn); +/* RTAS tokens */ static int ibm_set_eeh_option;static int ibm_set_slot_reset;
@@ -301,7 +303,7 @@ void pseries_eeh_init_edev(struct pci_dn *pdn)eeh_edev_dbg (edev,"EEH failed to enable on device (code %d)\n" , ret); }else {/* Retrieve PE address */ - edev->pe_config_addr = eeh_ops->get_pe_addr (&pe); + edev->pe_config_addr =pseries_eeh_get_pe_addr (pdn); pe.addr = edev->pe_config_addr;/* Some older systems (Power4) allow the ibm,set-eeh-option
@@ -431,8 +433,10 @@ static int pseries_eeh_set_option(struct eeh_pe *pe, int option)* It's notable that zero'ed return value means invalid PE config * address. */ -static int pseries_eeh_get_pe_addr (struct eeh_pe *pe) +static int pseries_eeh_get_pe_addr (struct pci_dn *pdn) { +int config_addr =rtas_config_addr (pdn->busno, pdn->devfn,0 ); +unsigned long buid = pdn->phb->buid;int ret =0 ;int rets[3 ];
@@ -443,18 +447,16 @@ static int pseries_eeh_get_pe_addr(struct eeh_pe *pe)* meaningless. */ ret =rtas_call (ibm_get_config_addr_info2,4 ,2 , rets, - pe->config_addr,BUID_HI (pe->phb->buid), -BUID_LO (pe->phb->buid),1 ); + config_addr,BUID_HI (buid),BUID_LO (buid),1 );if (ret || (rets[0 ] ==0 ))return 0 ;/* Retrieve the associated PE config address */ ret =rtas_call (ibm_get_config_addr_info2,4 ,2 , rets, - pe->config_addr,BUID_HI (pe->phb->buid), -BUID_LO (pe->phb->buid),0 ); + config_addr,BUID_HI (buid),BUID_LO (buid),0 );if (ret) {pr_warn ("%s: Failed to get address for PHB#%x-PE#%x\n" , - __func__, pe->phb->global_number, pe->config_addr); + __func__, pdn->phb->global_number, config_addr);return 0 ; }
@@ -463,11 +465,10 @@ static int pseries_eeh_get_pe_addr(struct eeh_pe *pe)if (ibm_get_config_addr_info !=RTAS_UNKNOWN_SERVICE ) { ret =rtas_call (ibm_get_config_addr_info,4 ,2 , rets, - pe->config_addr,BUID_HI (pe->phb->buid), -BUID_LO (pe->phb->buid),0 ); + config_addr,BUID_HI (buid),BUID_LO (buid),0 );if (ret) {pr_warn ("%s: Failed to get address for PHB#%x-PE#%x\n" , - __func__, pe->phb->global_number, pe->config_addr); + __func__, pdn->phb->global_number, config_addr);return 0 ; }
@@ -839,7 +840,6 @@ static struct eeh_ops pseries_eeh_ops = { .init = pseries_eeh_init, .probe = pseries_eeh_probe, .set_option = pseries_eeh_set_option, - .get_pe_addr = pseries_eeh_get_pe_addr, .get_state = pseries_eeh_get_state, .reset = pseries_eeh_reset, .get_log = pseries_eeh_get_log,
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 6/14 powerpc/eeh: Remove VF config space restoration
In reply to Oliver O'HalloranThere's a bunch of strange things about this code. First up is that none of the fields being written to are functional for a VF. The SR-IOV specification lists then as "Reserved, but OS should preserve" so writing new values to them doesn't do anything and is clearly wrong from a correctness perspective.
However, since VFs are designed to be managed by the OS there is an argument to be made that we should be saving and restoring some parts of config space. We already sort of do that by saving the first 64 bytes of config space in the eeh_dev (see eeh_dev->config_space[]). This is inadequate since it doesn't even consider saving and restoring the PCI capability structures. However, this is a problem with EEH in general and that needs to be fixed for non-VF devices too.
There's no real reason to keep around this around so delete it.
---
v2: no changes
--- arch/powerpc/include/asm/eeh.h | 1 - arch/powerpc/kernel/eeh.c | 59 -------------------- arch/powerpc/platforms/powernv/eeh-powernv.c | 20 ++----- arch/powerpc/platforms/pseries/eeh_pseries.c | 26 +-------- 4 files changed, 7 insertions(+), 99 deletions(-)
arch/powerpc/include/asm/eeh.h +0 -1
@@ -314,7 +314,6 @@ int eeh_pe_reset(struct eeh_pe *pe, int option, bool include_passed);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 +0 -59
65 lines not on this page · raw message
arch/powerpc/platforms/powernv/eeh-powernv.c +6 -14
@@ -1629,20 +1629,12 @@ static int pnv_eeh_restore_config(struct pci_dn *pdn)if (!edev)return -EEXIST ; -/* -* We have to restore the PCI config space after reset since the -* firmware can't see SRIOV VFs. -* -* 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); - }else { - phb = pdn->phb->private_data; - ret =opal_pci_reinit (phb->opal_id, -OPAL_REINIT_PCI_DEV , config_addr); - } +if (edev->physfn) +return 0 ; + + phb = edev->controller->private_data; + ret =opal_pci_reinit (phb->opal_id, +OPAL_REINIT_PCI_DEV , edev->bdfn);if (ret) { pr_warn("%s: Can't reinit PCI dev 0x%x (%lld)\n",
arch/powerpc/platforms/pseries/eeh_pseries.c +1 -25
@@ -718,30 +718,6 @@ 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; -} -#ifdef CONFIG_PCI_IOV int pseries_send_allow_unfreeze (struct pci_dn *pdn,u16 *vf_pe_array,int cur_vfs)
@@ -848,7 +824,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 = pseries_eeh_restore_config, + .restore_config =NULL ,/* NB: configure_bridge() does this */ #ifdef CONFIG_PCI_IOV .notify_resume = pseries_notify_resume #endif
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 7/14 powerpc/eeh: Pass eeh_dev to eeh_ops->restore_config()
In reply to Oliver O'HalloranMechanical conversion of the eeh_ops interfaces to use eeh_dev to reference a specific device rather than pci_dn. No functional changes.
---
v2: no changes
--- arch/powerpc/include/asm/eeh.h | 2 +- arch/powerpc/kernel/eeh.c | 5 ++--- arch/powerpc/kernel/eeh_pe.c | 6 ++---- arch/powerpc/platforms/powernv/eeh-powernv.c | 6 ++---- 4 files changed, 7 insertions(+), 12 deletions(-)
arch/powerpc/include/asm/eeh.h +1 -1
@@ -229,7 +229,7 @@ struct eeh_ops {int (*read_config)(struct pci_dn *pdn,int where,int size,u32 *val);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 (*restore_config)(struct eeh_dev *edev);int (*notify_resume)(struct pci_dn *pdn); };
arch/powerpc/kernel/eeh.c +2 -3
@@ -726,7 +726,6 @@ static void eeh_disable_and_save_dev_state(struct eeh_dev *edev,static void eeh_restore_dev_state (struct eeh_dev *edev,void *userdata) { -struct pci_dn *pdn =eeh_dev_to_pdn (edev);struct pci_dev *pdev =eeh_dev_to_pci_dev (edev);struct pci_dev *dev = userdata;
@@ -734,8 +733,8 @@ static void eeh_restore_dev_state(struct eeh_dev *edev, void *userdata)return ;/* Apply customization from firmware */ -if (pdn && eeh_ops->restore_config) - eeh_ops->restore_config (pdn); +if (eeh_ops->restore_config) + eeh_ops->restore_config (edev);/* The caller should restore state for the specified device */ if (pdev != dev)
arch/powerpc/kernel/eeh_pe.c +2 -4
@@ -843,16 +843,14 @@ static void eeh_restore_device_bars(struct eeh_dev *edev)*/ static void eeh_restore_one_device_bars (struct eeh_dev *edev,void *flag) { -struct pci_dn *pdn =eeh_dev_to_pdn (edev); -/* Do special restore for bridges */ if (edev->mode &EEH_DEV_BRIDGE )eeh_restore_bridge_bars (edev);else eeh_restore_device_bars (edev); -if (eeh_ops->restore_config && pdn) - eeh_ops->restore_config (pdn); +if (eeh_ops->restore_config) + eeh_ops->restore_config (edev); }/**
arch/powerpc/platforms/powernv/eeh-powernv.c +2 -4
@@ -1619,12 +1619,10 @@ static int pnv_eeh_next_error(struct eeh_pe **pe)return ret; } -static int pnv_eeh_restore_config (struct pci_dn *pdn) +static int pnv_eeh_restore_config (struct eeh_dev *edev) { -struct eeh_dev *edev =pdn_to_eeh_dev (pdn);struct pnv_phb *phb;s64 ret =0 ; -int config_addr = (pdn->busno <<8 ) | (pdn->devfn);if (!edev)return -EEXIST ;
@@ -1638,7 +1636,7 @@ static int pnv_eeh_restore_config(struct pci_dn *pdn)if (ret) {pr_warn ("%s: Can't reinit PCI dev 0x%x (%lld)\n" , - __func__, config_addr, ret); + __func__, edev->bdfn, ret);return -EIO ; }
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 8/14 powerpc/eeh: Pass eeh_dev to eeh_ops->resume_notify()
In reply to Oliver O'HalloranMechanical conversion of the eeh_ops interfaces to use eeh_dev to reference a specific device rather than pci_dn. No functional changes.
---
v2: no changes
--- arch/powerpc/include/asm/eeh.h | 2 +- arch/powerpc/kernel/eeh_driver.c | 4 ++-- arch/powerpc/kernel/eeh_sysfs.c | 2 +- arch/powerpc/platforms/pseries/eeh_pseries.c | 4 +--- 4 files changed, 5 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/eeh.h +1 -1
@@ -230,7 +230,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 eeh_dev *edev); -int (*notify_resume)(struct pci_dn *pdn); +int (*notify_resume)(struct eeh_dev *edev); };extern int eeh_subsystem_flags;
arch/powerpc/kernel/eeh_driver.c +2 -2
@@ -425,8 +425,8 @@ static enum pci_ers_result eeh_report_resume(struct eeh_dev *edev,pci_uevent_ers (edev->pdev,PCI_ERS_RESULT_RECOVERED );#ifdef CONFIG_PCI_IOV -if (eeh_ops->notify_resume &&eeh_dev_to_pdn (edev)) - eeh_ops->notify_resume (eeh_dev_to_pdn (edev)); +if (eeh_ops->notify_resume) + eeh_ops->notify_resume (edev);#endif return PCI_ERS_RESULT_NONE ; }
arch/powerpc/kernel/eeh_sysfs.c +1 -1
@@ -99,7 +99,7 @@ static ssize_t eeh_notify_resume_store(struct device *dev,if (!edev || !edev->pe || !eeh_ops->notify_resume)return -ENODEV ; -if (eeh_ops->notify_resume (pci_get_pdn (pdev))) +if (eeh_ops->notify_resume (edev))return -EIO ;return count;
arch/powerpc/platforms/pseries/eeh_pseries.c +1 -3
@@ -793,10 +793,8 @@ static int pseries_call_allow_unfreeze(struct eeh_dev *edev)return rc; } -static int pseries_notify_resume (struct pci_dn *pdn) +static int pseries_notify_resume (struct eeh_dev *edev) { -struct eeh_dev *edev =pdn_to_eeh_dev (pdn); -if (!edev)return -EEXIST ;
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 9/14 powerpc/eeh: Pass eeh_dev to eeh_ops->{read|write}_config()
In reply to Oliver O'HalloranMechanical conversion of the eeh_ops interfaces to use eeh_dev to reference a specific device rather than pci_dn. No functional changes.
---
v2: no change
--- arch/powerpc/include/asm/eeh.h | 4 +- arch/powerpc/kernel/eeh.c | 22 +++++---- arch/powerpc/kernel/eeh_pe.c | 47 +++++++++----------- arch/powerpc/platforms/powernv/eeh-powernv.c | 43 ++++++++++-------- arch/powerpc/platforms/pseries/eeh_pseries.c | 16 ++++--- 5 files changed, 68 insertions(+), 64 deletions(-)
arch/powerpc/include/asm/eeh.h +2 -2
@@ -226,8 +226,8 @@ struct eeh_ops {int (*configure_bridge)(struct eeh_pe *pe);int (*err_inject)(struct eeh_pe *pe,int type,int func,unsigned long addr,unsigned long mask); -int (*read_config)(struct pci_dn *pdn,int where,int size,u32 *val); -int (*write_config)(struct pci_dn *pdn,int where,int size,u32 val); +int (*read_config)(struct eeh_dev *edev,int where,int size,u32 *val); +int (*write_config)(struct eeh_dev *edev,int where,int size,u32 val);int (*next_error)(struct eeh_pe **pe);int (*restore_config)(struct eeh_dev *edev);int (*notify_resume)(struct eeh_dev *edev);
arch/powerpc/kernel/eeh.c +10 -12
@@ -185,21 +185,21 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len) pdn->phb->global_number, pdn->busno, PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn)); - eeh_ops->read_config (pdn,PCI_VENDOR_ID ,4 , &cfg); + eeh_ops->read_config (edev,PCI_VENDOR_ID ,4 , &cfg); n +=scnprintf (buf+n, len-n,"dev/vend:%08x\n" , cfg);pr_warn ("EEH: PCI device/vendor: %08x\n" , cfg); - eeh_ops->read_config (pdn,PCI_COMMAND ,4 , &cfg); + eeh_ops->read_config (edev,PCI_COMMAND ,4 , &cfg); n +=scnprintf (buf+n, len-n,"cmd/stat:%x\n" , cfg);pr_warn ("EEH: PCI cmd/status register: %08x\n" , cfg);/* Gather bridge-specific registers */ if (edev->mode &EEH_DEV_BRIDGE ) { - eeh_ops->read_config (pdn,PCI_SEC_STATUS ,2 , &cfg); + eeh_ops->read_config (edev,PCI_SEC_STATUS ,2 , &cfg); n +=scnprintf (buf+n, len-n,"sec stat:%x\n" , cfg);pr_warn ("EEH: Bridge secondary status: %04x\n" , cfg); - eeh_ops->read_config (pdn,PCI_BRIDGE_CONTROL ,2 , &cfg); + eeh_ops->read_config (edev,PCI_BRIDGE_CONTROL ,2 , &cfg); n +=scnprintf (buf+n, len-n,"brdg ctl:%x\n" , cfg);pr_warn ("EEH: Bridge control: %04x\n" , cfg); }
@@ -207,11 +207,11 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len)/* Dump out the PCI-X command and status regs */ cap = edev->pcix_cap;if (cap) { - eeh_ops->read_config (pdn, cap,4 , &cfg); + eeh_ops->read_config (edev, cap,4 , &cfg); n +=scnprintf (buf+n, len-n,"pcix-cmd:%x\n" , cfg);pr_warn ("EEH: PCI-X cmd: %08x\n" , cfg); - eeh_ops->read_config (pdn, cap+4 ,4 , &cfg); + eeh_ops->read_config (edev, cap+4 ,4 , &cfg); n +=scnprintf (buf+n, len-n,"pcix-stat:%x\n" , cfg);pr_warn ("EEH: PCI-X status: %08x\n" , cfg); }
@@ -223,7 +223,7 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len)pr_warn ("EEH: PCI-E capabilities and status follow:\n" );for (i=0 ; i<=8 ; i++) { - eeh_ops->read_config (pdn, cap+4 *i,4 , &cfg); + eeh_ops->read_config (edev, cap+4 *i,4 , &cfg); n +=scnprintf (buf+n, len-n,"%02x:%x\n" ,4 *i, cfg);if ((i %4 ) ==0 ) {
@@ -250,7 +250,7 @@ static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len)pr_warn ("EEH: PCI-E AER capability register set follows:\n" );for (i=0 ; i<=13 ; i++) { - eeh_ops->read_config (pdn, cap+4 *i,4 , &cfg); + eeh_ops->read_config (edev, cap+4 *i,4 , &cfg); n +=scnprintf (buf+n, len-n,"%02x:%x\n" ,4 *i, cfg);if ((i %4 ) ==0 ) {
@@ -917,15 +917,13 @@ int eeh_pe_reset_full(struct eeh_pe *pe, bool include_passed)*/ void eeh_save_bars (struct eeh_dev *edev) { -struct pci_dn *pdn;int i; - pdn =eeh_dev_to_pdn (edev); -if (!pdn) +if (!edev)return ;for (i =0 ; i <16 ; i++) - eeh_ops->read_config (pdn, i *4 ,4 , &edev->config_space[i]); + eeh_ops->read_config (edev, i *4 ,4 , &edev->config_space[i]);/* * For PCI bridges including root port, we need enable bus
arch/powerpc/kernel/eeh_pe.c +22 -25
130 lines not on this page · raw message
arch/powerpc/platforms/powernv/eeh-powernv.c +24 -19
129 lines not on this page · raw message
arch/powerpc/platforms/pseries/eeh_pseries.c +10 -6
@@ -692,29 +692,33 @@ static int pseries_eeh_configure_bridge(struct eeh_pe *pe)/** * pseries_eeh_read_config - Read PCI config space -* @pdn: PCI device node -* @where: PCI address +* @edev: EEH device handle +* @where: PCI config space offset * @size: size to read * @val: return value * * Read config space from the speicifed device */ -static int pseries_eeh_read_config (struct pci_dn *pdn,int where,int size,u32 *val) +static int pseries_eeh_read_config (struct eeh_dev *edev,int where,int size,u32 *val) { +struct pci_dn *pdn =eeh_dev_to_pdn (edev); +return rtas_read_config (pdn, where, size, val); }/** * pseries_eeh_write_config - Write PCI config space -* @pdn: PCI device node -* @where: PCI address +* @edev: EEH device handle +* @where: PCI config space offset * @size: size to write * @val: value to be written * * Write config space to the specified device */ -static int pseries_eeh_write_config (struct pci_dn *pdn,int where,int size,u32 val) +static int pseries_eeh_write_config (struct eeh_dev *edev,int where,int size,u32 val) { +struct pci_dn *pdn =eeh_dev_to_pdn (edev); +return rtas_write_config (pdn, where, size, val); }
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 10/14 powerpc/eeh: Remove spurious use of pci_dn in eeh_dump_dev_log
In reply to Oliver O'HalloranRetrieve the domain, bus, device, and function numbers from the edev.
---
v2: no change
--- arch/powerpc/kernel/eeh.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
arch/powerpc/kernel/eeh.c +4 -10
@@ -167,23 +167,17 @@ void eeh_show_enabled(void)*/ static size_t eeh_dump_dev_log (struct eeh_dev *edev,char *buf,size_t len) { -struct pci_dn *pdn =eeh_dev_to_pdn (edev);u32 cfg;int cap, i;int n =0 , l =0 ;char buffer[128 ]; -if (!pdn) { -pr_warn ("EEH: Note: No error log for absent device.\n" ); -return 0 ; - } - n +=scnprintf (buf+n, len-n,"%04x:%02x:%02x.%01x\n" , - pdn->phb->global_number, pdn->busno, -PCI_SLOT (pdn->devfn),PCI_FUNC (pdn->devfn)); + edev->pe->phb->global_number, edev->bdfn >>8 , +PCI_SLOT (edev->bdfn),PCI_FUNC (edev->bdfn));pr_warn ("EEH: of node=%04x:%02x:%02x.%01x\n" , - pdn->phb->global_number, pdn->busno, -PCI_SLOT (pdn->devfn),PCI_FUNC (pdn->devfn)); + edev->pe->phb->global_number, edev->bdfn >>8 , +PCI_SLOT (edev->bdfn),PCI_FUNC (edev->bdfn)); eeh_ops->read_config (edev,PCI_VENDOR_ID ,4 , &cfg); n +=scnprintf (buf+n, len-n,"dev/vend:%08x\n" , cfg);
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 11/14 powerpc/eeh: Remove class code field from edev
In reply to Oliver O'HalloranThe edev->class_code field is never referenced anywhere except for the platform specific probe functions. The same information is available in the pci_dev for PowerNV and in the pci_dn on pseries so we can remove the field.
---
v2: no changes
--- arch/powerpc/include/asm/eeh.h | 1 - arch/powerpc/platforms/powernv/eeh-powernv.c | 5 ++--- arch/powerpc/platforms/pseries/eeh_pseries.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/eeh.h +0 -1
@@ -133,7 +133,6 @@ static inline bool eeh_pe_passed(struct eeh_pe *pe)struct eeh_dev {int mode;/* EEH mode */ -int class_code;/* Class code of the device */ int bdfn;/* bdfn of device (for cfg ops) */ struct pci_controller *controller;int pe_config_addr;/* PE config address */
arch/powerpc/platforms/powernv/eeh-powernv.c +2 -3
@@ -372,19 +372,18 @@ static struct eeh_dev *pnv_eeh_probe(struct pci_dev *pdev) }/* Skip for PCI-ISA bridge */ -if ((pdn->class_code >>8 ) ==PCI_CLASS_BRIDGE_ISA ) +if ((pdev->class >>8 ) ==PCI_CLASS_BRIDGE_ISA )return NULL ;eeh_edev_dbg (edev,"Probing device\n" );/* Initialize eeh device */ - edev->class_code = pdn->class_code; edev->mode &=0xFFFFFF00 ; edev->pcix_cap =pnv_eeh_find_cap (pdn,PCI_CAP_ID_PCIX ); edev->pcie_cap =pnv_eeh_find_cap (pdn,PCI_CAP_ID_EXP ); edev->af_cap =pnv_eeh_find_cap (pdn,PCI_CAP_ID_AF ); edev->aer_cap =pnv_eeh_find_ecap (pdn,PCI_EXT_CAP_ID_ERR ); -if ((edev->class_code >>8 ) ==PCI_CLASS_BRIDGE_PCI ) { +if ((pdev->class >>8 ) ==PCI_CLASS_BRIDGE_PCI ) { edev->mode |=EEH_DEV_BRIDGE ;if (edev->pcie_cap) { pnv_pci_cfg_read(pdn, edev->pcie_cap + PCI_EXP_FLAGS,
arch/powerpc/platforms/pseries/eeh_pseries.c +1 -2
@@ -273,12 +273,11 @@ void pseries_eeh_init_edev(struct pci_dn *pdn)* correctly reflects that current device is root port * or PCIe switch downstream port. */ - edev->class_code = pdn->class_code; edev->pcix_cap =pseries_eeh_find_cap (pdn,PCI_CAP_ID_PCIX ); edev->pcie_cap =pseries_eeh_find_cap (pdn,PCI_CAP_ID_EXP ); edev->aer_cap =pseries_eeh_find_ecap (pdn,PCI_EXT_CAP_ID_ERR ); edev->mode &=0xFFFFFF00 ; -if ((edev->class_code >>8 ) ==PCI_CLASS_BRIDGE_PCI ) { +if ((pdn->class_code >>8 ) ==PCI_CLASS_BRIDGE_PCI ) { edev->mode |=EEH_DEV_BRIDGE ;if (edev->pcie_cap) { rtas_read_config(pdn, edev->pcie_cap + PCI_EXP_FLAGS,
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 12/14 powerpc/eeh: Rename eeh_{add_to|remove_from}_parent_pe()
In reply to Oliver O'HalloranThe naming of eeh_{add_to|remove_from}_parent_pe() doesn't really reflect what they actually do. If the PE referred to be edev->pe_config_addr already exists under that PHB then the edev is added to that PE. However, if the PE doesn't exist the a new one is created for the edev.
The bulk of the implementation of eeh_add_to_parent_pe() covers that second case. Similarly, most of eeh_remove_from_parent_pe() is determining when it's safe to delete a PE.
---
v2: no changes
--- arch/powerpc/include/asm/eeh.h | 4 ++-- arch/powerpc/kernel/eeh.c | 4 ++-- arch/powerpc/kernel/eeh_driver.c | 2 +- arch/powerpc/kernel/eeh_pe.c | 8 ++++---- arch/powerpc/kernel/pci_dn.c | 2 +- arch/powerpc/platforms/powernv/eeh-powernv.c | 2 +- arch/powerpc/platforms/pseries/eeh_pseries.c | 8 ++++---- 7 files changed, 15 insertions(+), 15 deletions(-)
arch/powerpc/include/asm/eeh.h +2 -2
@@ -283,8 +283,8 @@ struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb);struct eeh_pe *eeh_pe_next (struct eeh_pe *pe,struct eeh_pe *root);struct eeh_pe *eeh_pe_get (struct pci_controller *phb,int pe_no,int config_addr); -int eeh_add_to_parent_pe (struct eeh_dev *edev); -int eeh_rmv_from_parent_pe (struct eeh_dev *edev); +int eeh_pe_tree_insert (struct eeh_dev *edev); +int eeh_pe_tree_remove (struct eeh_dev *edev);void eeh_pe_update_time_stamp (struct eeh_pe *pe);void *eeh_pe_traverse (struct eeh_pe *root,eeh_pe_traverse_func fn,void *flag);
arch/powerpc/kernel/eeh.c +2 -2
@@ -1107,7 +1107,7 @@ void eeh_probe_device(struct pci_dev *dev)* FIXME: HEY MA, LOOK AT ME, NO LOCKING! */ if (edev->pdev && edev->pdev != dev) { -eeh_rmv_from_parent_pe (edev); +eeh_pe_tree_remove (edev);eeh_addr_cache_rmv_dev (edev->pdev);eeh_sysfs_remove_device (edev->pdev);
@@ -1186,7 +1186,7 @@ void eeh_remove_device(struct pci_dev *dev) edev->in_error = false; dev->dev.archdata.edev =NULL ;if (!(edev->pe->state &EEH_PE_KEEP )) -eeh_rmv_from_parent_pe (edev); +eeh_pe_tree_remove (edev);else edev->mode |=EEH_DEV_DISCONNECTED ; }
arch/powerpc/kernel/eeh_driver.c +1 -1
@@ -542,7 +542,7 @@ static void *eeh_pe_detach_dev(struct eeh_pe *pe, void *userdata)continue ; edev->mode &= ~(EEH_DEV_DISCONNECTED |EEH_DEV_IRQ_DISABLED ); -eeh_rmv_from_parent_pe (edev); +eeh_pe_tree_remove (edev); }return NULL ;
arch/powerpc/kernel/eeh_pe.c +4 -4
@@ -356,7 +356,7 @@ static struct eeh_pe *eeh_pe_get_parent(struct eeh_dev *edev) }/** -* eeh_add_to_parent_pe - Add EEH device to parent PE +* eeh_pe_tree_insert - Add EEH device to parent PE * @edev: EEH device * * Add EEH device to the parent PE. If the parent PE already
@@ -364,7 +364,7 @@ static struct eeh_pe *eeh_pe_get_parent(struct eeh_dev *edev)* we have to create new PE to hold the EEH device and the new * PE will be linked to its parent PE as well. */ -int eeh_add_to_parent_pe (struct eeh_dev *edev) +int eeh_pe_tree_insert (struct eeh_dev *edev) {struct eeh_pe *pe, *parent;struct pci_dn *pdn =eeh_dev_to_pdn (edev);
@@ -459,7 +459,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev) }/** -* eeh_rmv_from_parent_pe - Remove one EEH device from the associated PE +* eeh_pe_tree_remove - Remove one EEH device from the associated PE * @edev: EEH device * * The PE hierarchy tree might be changed when doing PCI hotplug.
@@ -467,7 +467,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)* during EEH recovery. So we have to call the function remove the * corresponding PE accordingly if necessary. */ -int eeh_rmv_from_parent_pe (struct eeh_dev *edev) +int eeh_pe_tree_remove (struct eeh_dev *edev) {struct eeh_pe *pe, *parent, *child;bool keep, recover;
arch/powerpc/kernel/pci_dn.c +1 -1
@@ -263,7 +263,7 @@ void remove_sriov_vf_pdns(struct pci_dev *pdev)* have a configured PE. */ if (edev->pe) -eeh_rmv_from_parent_pe (edev); +eeh_pe_tree_remove (edev); pdn->edev =NULL ;kfree (edev);
arch/powerpc/platforms/powernv/eeh-powernv.c +1 -1
@@ -399,7 +399,7 @@ static struct eeh_dev *pnv_eeh_probe(struct pci_dev *pdev) edev->pe_config_addr = phb->ioda.pe_rmap[config_addr];/* Create PE */ - ret =eeh_add_to_parent_pe (edev); + ret =eeh_pe_tree_insert (edev);if (ret) {eeh_edev_warn (edev,"Failed to add device to PE (code %d)\n" , ret);return NULL ;
arch/powerpc/platforms/pseries/eeh_pseries.c +4 -4
@@ -71,8 +71,8 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)struct eeh_dev *edev =pdn_to_eeh_dev (pdn); 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_pe_tree_remove (edev);/* Remove as it is adding to bus pe */ + eeh_pe_tree_insert(edev); /* Add as VF PE type */ }#endif eeh_probe_device (pdev);
@@ -315,14 +315,14 @@ void pseries_eeh_init_edev(struct pci_dn *pdn)if (enable) {eeh_add_flag (EEH_ENABLED ); -eeh_add_to_parent_pe (edev); +eeh_pe_tree_insert (edev); }else if (pdn->parent &&pdn_to_eeh_dev (pdn->parent) && (pdn_to_eeh_dev (pdn->parent))->pe) {/* This device doesn't support EEH, but it may have an * EEH parent, in which case we mark it as supported. */ edev->pe_config_addr =pdn_to_eeh_dev (pdn->parent)->pe_config_addr; -eeh_add_to_parent_pe (edev); +eeh_pe_tree_insert (edev); }eeh_edev_dbg (edev,"EEH is %s on device (code %d)\n" , (enable ?"enabled" :"unsupported" ), ret);
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 13/14 powerpc/eeh: Drop pdn use in eeh_pe_tree_insert()
In reply to Oliver O'HalloranThis is mostly just to make the subsequent diffs less noisy. No functional changes.
One thing that needs calling out is the removal of the "config_addr" variable and replacing it with edev->bdfn. The contents of edev->bdfn are the same, however it's worth pointing out that what RTAS calls a "config_addr" isn't the same as the bdfn. The config_addr is supposed to
be: <bus><devfn><reg> with each field being an 8 bit number. Various parts of the EEH code use BDFN and "config_addr" as interchangeable quantities even though they aren't really.
---
v2: no changes
--- arch/powerpc/kernel/eeh_pe.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
arch/powerpc/kernel/eeh_pe.c +7 -8
@@ -366,9 +366,8 @@ static struct eeh_pe *eeh_pe_get_parent(struct eeh_dev *edev)*/ int eeh_pe_tree_insert (struct eeh_dev *edev) { +struct pci_controller *hose = edev->controller;struct eeh_pe *pe, *parent; -struct pci_dn *pdn =eeh_dev_to_pdn (edev); -int config_addr = (pdn->busno <<8 ) | (pdn->devfn);/* Check if the PE number is valid */ if (!eeh_has_flag (EEH_VALID_PE_ZERO ) && !edev->pe_config_addr) {
@@ -382,7 +381,7 @@ int eeh_pe_tree_insert(struct eeh_dev *edev)* PE should be composed of PCI bus and its subordinate * components. */ - pe =eeh_pe_get (pdn->phb, edev->pe_config_addr, config_addr); + pe =eeh_pe_get (hose, edev->pe_config_addr, edev->bdfn);if (pe) {if (pe->type &EEH_PE_INVALID ) {list_add_tail (&edev->entry, &pe->edevs);
@@ -416,15 +415,15 @@ int eeh_pe_tree_insert(struct eeh_dev *edev)/* Create a new EEH PE */ if (edev->physfn) - pe =eeh_pe_alloc (pdn->phb,EEH_PE_VF ); + pe =eeh_pe_alloc (hose,EEH_PE_VF );else - pe =eeh_pe_alloc (pdn->phb,EEH_PE_DEVICE ); + pe =eeh_pe_alloc (hose,EEH_PE_DEVICE );if (!pe) {pr_err ("%s: out of memory!\n" , __func__);return -ENOMEM ; } pe->addr = edev->pe_config_addr; - pe->config_addr = config_addr; + pe->config_addr = edev->bdfn;/* * Put the new EEH PE into hierarchy tree. If the parent
@@ -434,10 +433,10 @@ int eeh_pe_tree_insert(struct eeh_dev *edev)*/ parent =eeh_pe_get_parent (edev);if (!parent) { - parent =eeh_phb_pe_get (pdn->phb); + parent =eeh_phb_pe_get (hose);if (!parent) {pr_err ("%s: No PHB PE is found (PHB Domain=%d)\n" , - __func__, pdn->phb->global_number); + __func__, hose->global_number); edev->pe =NULL ;kfree (pe);return -EEXIST ;
Signature · 1 line
2.26.2
Oliver O'Halloran
reviewerPATCH v2 14/14 powerpc/eeh: Move PE tree setup into the platform
In reply to Oliver O'HalloranThe EEH core has a concept of a "PE tree" to support PowerNV. The PE tree follows the PCI bus structures because a reset asserted on an upstream bridge will be propagated to the downstream bridges. On pseries there's a 1-1 correspondence between what the guest sees are a PHB and a PE so the "tree" is really just a single node.
Current the EEH core is reponsible for setting up this PE tree which it does by traversing the pci_dn tree. The structure of the pci_dn tree matches the bus tree on PowerNV which leads to the PE tree being "correct" this setup method doesn't make a whole lot of sense and it's actively confusing for the pseries case where it doesn't really do anything.
We want to remove the dependence on pci_dn anyway so this patch move choosing where to insert a new PE into the platform code rather than being part of the generic EEH code. For PowerNV this simplifies the tree building logic and removes the use of pci_dn. For pseries we keep the existing logic. I'm not really convinced it does anything due to the 1-1 PE-to-PHB correspondence so every device under that PHB should be in the same PE, but I'd rather not remove it entirely until we've had a chance to look at it more deeply.
---
v2: Reworked pseries PE setup slightly. NOT DONE YET. mostly done needs test
--- arch/powerpc/include/asm/eeh.h | 2 +- arch/powerpc/kernel/eeh_pe.c | 70 ++++++-------------- arch/powerpc/platforms/powernv/eeh-powernv.c | 27 +++++++- arch/powerpc/platforms/pseries/eeh_pseries.c | 66 +++++++++++++++--- 4 files changed, 102 insertions(+), 63 deletions(-)
arch/powerpc/include/asm/eeh.h +1 -1
@@ -283,7 +283,7 @@ struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb);struct eeh_pe *eeh_pe_next (struct eeh_pe *pe,struct eeh_pe *root);struct eeh_pe *eeh_pe_get (struct pci_controller *phb,int pe_no,int config_addr); -int eeh_pe_tree_insert (struct eeh_dev *edev); +int eeh_pe_tree_insert (struct eeh_dev *edev,struct eeh_pe *new_pe_parent);int eeh_pe_tree_remove (struct eeh_dev *edev);void eeh_pe_update_time_stamp (struct eeh_pe *pe); void *eeh_pe_traverse(struct eeh_pe *root,
arch/powerpc/kernel/eeh_pe.c +19 -51
106 lines not on this page · raw message
arch/powerpc/platforms/powernv/eeh-powernv.c +26 -1
@@ -338,6 +338,28 @@ static int pnv_eeh_find_ecap(struct pci_dn *pdn, int cap)return 0 ; } +static struct eeh_pe *pnv_eeh_get_upstream_pe (struct pci_dev *pdev) +{ +struct pci_controller *hose = pdev->bus->sysdata; +struct pnv_phb *phb = hose->private_data; +struct pci_dev *parent = pdev->bus->self; + +#ifdef CONFIG_PCI_IOV +/* for VFs we use the PF's PE as the upstream PE */ +if (pdev->is_virtfn) + parent = pdev->physfn; +#endif + +/* otherwise use the PE of our parent bridge */ +if (parent) { +struct pnv_ioda_pe *ioda_pe =pnv_ioda_get_pe (parent); + +return eeh_pe_get (phb->hose, ioda_pe->pe_number,0 ); + } + +return NULL ; +} +/** * pnv_eeh_probe - Do probe on PCI device * @pdev: pci_dev to probe
@@ -350,6 +372,7 @@ static struct eeh_dev *pnv_eeh_probe(struct pci_dev *pdev)struct pci_controller *hose = pdn->phb;struct pnv_phb *phb = hose->private_data;struct eeh_dev *edev =pdn_to_eeh_dev (pdn); +struct eeh_pe *upstream_pe;uint32_t pcie_flags;int ret;int config_addr = (pdn->busno <<8 ) | (pdn->devfn);
@@ -398,8 +421,10 @@ static struct eeh_dev *pnv_eeh_probe(struct pci_dev *pdev) edev->pe_config_addr = phb->ioda.pe_rmap[config_addr]; + upstream_pe =pnv_eeh_get_upstream_pe (pdev); +/* Create PE */ - ret =eeh_pe_tree_insert (edev); + ret =eeh_pe_tree_insert (edev, upstream_pe);if (ret) {eeh_edev_warn (edev,"Failed to add device to PE (code %d)\n" , ret);return NULL ;
arch/powerpc/platforms/pseries/eeh_pseries.c +56 -10
95 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [PATCH v2 14/14] powerpc/eeh: Move PE tree setup into the platform
Quoted 21 lines · Oliver O'Halloran
The EEH core has a concept of a "PE tree" to support PowerNV. The PE tree follows the PCI bus structures because a reset asserted on an upstream bridge will be propagated to the downstream bridges. On pseries there's a 1-1 correspondence between what the guest sees are a PHB and a PE so the "tree" is really just a single node.
Current the EEH core is reponsible for setting up this PE tree which it does by traversing the
pci_dntree. The structure of thepci_dntree matches the bus tree on PowerNV which leads to the PE tree being "correct" this setup method doesn't make a whole lot of sense and it's actively confusing for the pseries case where it doesn't really do anything.We want to remove the dependence on
pci_dnanyway so this patch move choosing where to insert a new PE into the platform code rather than being part of the generic EEH code. For PowerNV this simplifies the tree building logic and removes the use ofpci_dn. For pseries we keep the existing logic. I'm not really convinced it does anything due to the 1-1 PE-to-PHB correspondence so every device under that PHB should be in the same PE, but I'd rather not remove it entirely until we've had a chance to look at it more deeply.
Quoted 4 lines
Signed-off-by Oliver O'Halloran <[email protected]>Reviewed-by Alexey Kardashevskiy <[email protected]>---
v2: Reworked pseries PE setup slightly. NOT DONE YET. mostly done needs test
So far it was looking good and now this :)
When is it going to be done? Is this the broken stuff you mentioned elsewhere?
Signature · 1 line
Alexey
Oliver O'Halloran
reviewerRe: [PATCH v2 14/14] powerpc/eeh: Move PE tree setup into the platform
Quoted 30 lines · Alexey Kardashevskiy
Quoted 21 lines · Oliver O'Halloran
The EEH core has a concept of a "PE tree" to support PowerNV. The PE tree follows the PCI bus structures because a reset asserted on an upstream bridge will be propagated to the downstream bridges. On pseries there's a 1-1 correspondence between what the guest sees are a PHB and a PE so the "tree" is really just a single node.
Current the EEH core is reponsible for setting up this PE tree which it does by traversing the
pci_dntree. The structure of thepci_dntree matches the bus tree on PowerNV which leads to the PE tree being "correct" this setup method doesn't make a whole lot of sense and it's actively confusing for the pseries case where it doesn't really do anything.We want to remove the dependence on
pci_dnanyway so this patch move choosing where to insert a new PE into the platform code rather than being part of the generic EEH code. For PowerNV this simplifies the tree building logic and removes the use ofpci_dn. For pseries we keep the existing logic. I'm not really convinced it does anything due to the 1-1 PE-to-PHB correspondence so every device under that PHB should be in the same PE, but I'd rather not remove it entirely until we've had a chance to look at it more deeply.Quoted 4 lines
Signed-off-by Oliver O'Halloran <[email protected]>Reviewed-by Alexey Kardashevskiy <[email protected]>---
v2: Reworked pseries PE setup slightly. NOT DONE YET. mostly done needs test
Quoted 4 lines
So far it was looking good and now this :)
When is it going to be done? Is this the broken stuff you mentioned elsewhere?
I am a dumb.
I put those in there to remind myself what I have / haven't done when respinning a series. I added that before I tested it and forgot to remove the comment.
Quoted 4 lines
--
Alexey
Quoted 2 lines · Oliver O'Halloran
This function is a one line wrapper around
eeh_phb_pe_create()and despite the name it doesn't create anyeeh_devstructures.
The "eeh_dev_phb_init_dynamic" name does not suggest anything really but the comment does.
Quoted 99 lines
Replace it with direct
calls toeeh_phb_pe_create()since that does what it says on the tin and removes a layer of indirection.Signed-off-by Oliver O'Halloran <[email protected]>---
v2: Added sub prototype ofeeh_phb_pe_create()for the !CONFIG_EEH case.--- arch/powerpc/include/asm/eeh.h | 3 ++- arch/powerpc/kernel/eeh.c | 2 +- arch/powerpc/kernel/eeh_dev.c | 13 ------------- arch/powerpc/kernel/of_platform.c | 4 ++-- arch/powerpc/platforms/pseries/pci_dlpar.c | 2 +- 5 files changed, 6 insertions(+), 18 deletions(-)arch/powerpc/include/asm/eeh.h +2
-1@@ -294,7 +294,6 @@ const char *eeh_pe_loc_get(struct eeh_pe *pe);struct pci_bus *eeh_pe_bus_get (struct eeh_pe *pe);struct eeh_dev *eeh_dev_init (struct pci_dn *pdn); -void eeh_dev_phb_init_dynamic (struct pci_controller *phb);void eeh_show_enabled (void );int __init eeh_ops_register (struct eeh_ops *ops); int __exit eeh_ops_unregister(const char *name);@@ -370,6 +369,8 @@ void pseries_eeh_init_edev_recursive(struct pci_dn *pdn);#else static inline void pseries_eeh_add_device_early (struct pci_dn *pdn) { }static inline void pseries_eeh_add_device_tree_early (struct pci_dn *pdn) { } + +static inline int eeh_phb_pe_create (struct pci_controller *phb) {return 0 ; }#endif #ifdef CONFIG_PPC64 arch/powerpc/kernel/eeh.c +1
-1@@ -1096,7 +1096,7 @@ static int eeh_init(void)/* Initialize PHB PEs */ list_for_each_entry_safe (hose, tmp, &hose_list, list_node) -eeh_dev_phb_init_dynamic (hose); +eeh_phb_pe_create (hose);eeh_addr_cache_init ();arch/powerpc/kernel/eeh_dev.c +0
-13@@ -52,16 +52,3 @@ struct eeh_dev *eeh_dev_init(struct pci_dn *pdn)return edev; } - -/** -* eeh_dev_phb_init_dynamic - Create EEH devices for devices included in PHB -* @phb: PHB -* -* Scan the PHB OF node and its child association, then create the -* EEH devices accordingly -*/ -void eeh_dev_phb_init_dynamic (struct pci_controller *phb) -{ -/* EEH PE for PHB */ -eeh_phb_pe_create (phb); -}arch/powerpc/kernel/of_platform.c +2
-2@@ -62,8 +62,8 @@ static int of_pci_phb_probe(struct platform_device *dev)/* Init pci_dn data structures */ pci_devs_phb_init_dynamic (phb); -/* Create EEH PEs for the PHB */ -eeh_dev_phb_init_dynamic (phb); +/* Create EEH PE for the PHB */ +eeh_phb_pe_create (phb);/* Scan the bus */ pcibios_scan_phb (phb);arch/powerpc/platforms/pseries/pci_dlpar.c +1
-1@@ -34,7 +34,7 @@ struct pci_controller *init_phb_dynamic(struct device_node *dn)pci_devs_phb_init_dynamic (phb);/* Create EEH devices for the PHB */ -eeh_dev_phb_init_dynamic (phb); +eeh_phb_pe_create (phb);if (dn->child)pseries_eeh_init_edev_recursive (PCI_DN (dn));
Signature · 1 line
Alexey
Michael Ellerman
AppliedQuoted 4 lines · Oliver O'Halloran
This function is a one line wrapper around
eeh_phb_pe_create()and despite the name it doesn't create anyeeh_devstructures. Replace it with direct calls toeeh_phb_pe_create()since that does what it says on the tin and removes a layer of indirection.
Applied to powerpc/next.
[01/14] powerpc/eeh: Remove eeh_dev_phb_init_dynamic()
https://git.kernel.org/powerpc/c/475028efc708880e16e61cc4cbbc00af784cb39b [02/14] powerpc/eeh: Remove eeh_dev.c https://git.kernel.org/powerpc/c/d74ee8e9d12e2071014ecec96a1ce2744f77639d [03/14] powerpc/eeh: Move vf_index out of pci_dn and into eeh_dev https://git.kernel.org/powerpc/c/dffa91539e80355402c0716a91af17fc8ddd1abf [04/14] powerpc/pseries: Stop using pdn->pe_number https://git.kernel.org/powerpc/c/c408ce9075b8e1533f30fd3a113b75fb745f722f [05/14] powerpc/eeh: Kill off eeh_ops->get_pe_addr() https://git.kernel.org/powerpc/c/a40db934312cb2a4bef16b3edc962bc8c7f6462f [06/14] powerpc/eeh: Remove VF config space restoration https://git.kernel.org/powerpc/c/21b43bd59c7838825b94eea288333affb53dd399 [07/14] powerpc/eeh: Pass eeh_dev to eeh_ops->restore_config() https://git.kernel.org/powerpc/c/0c2c76523c04ac184c7d7bbb8756f603375b7fc4 [08/14] powerpc/eeh: Pass eeh_dev to eeh_ops->resume_notify() https://git.kernel.org/powerpc/c/8225d543dc0170e5b61af8559af07ec4f26f0bd6 [09/14] powerpc/eeh: Pass eeh_dev to eeh_ops->{read|write}_config() https://git.kernel.org/powerpc/c/17d2a4870467bc8e8966304c08980571da943558 [10/14] powerpc/eeh: Remove spurious use of pci_dn in eeh_dump_dev_log https://git.kernel.org/powerpc/c/1a303d8844d082ef58ff5fc3005b99621a3263ba [11/14] powerpc/eeh: Remove class code field from edev https://git.kernel.org/powerpc/c/768a42845b9ecdb28ba1991e17088b7eeb23a3eb [12/14] powerpc/eeh: Rename eeh_{add_to|remove_from}_parent_pe() https://git.kernel.org/powerpc/c/d923ab7a96fcc2b46aac9b2fc38ffdca72436fd1 [13/14] powerpc/eeh: Drop pdn use in eeh_pe_tree_insert() https://git.kernel.org/powerpc/c/31595ae5aece519be5faa2e2013278ce45894d26 [14/14] powerpc/eeh: Move PE tree setup into the platform https://git.kernel.org/powerpc/c/a131bfc69bc868083a6c7f9b5dad1331902a3534
cheers
Michael Ellerman
reviewerQuoted 10 lines · Michael Ellerman
Quoted 4 lines · Oliver O'Halloran
This function is a one line wrapper around
eeh_phb_pe_create()and despite the name it doesn't create anyeeh_devstructures. Replace it with direct calls toeeh_phb_pe_create()since that does what it says on the tin and removes a layer of indirection.Applied to powerpc/next.
[01/14] powerpc/eeh: Remove
eeh_dev_phb_init_dynamic()https://git.kernel.org/powerpc/c/475028efc708880e16e61cc4cbbc00af784cb39b
Something weird happened with the "thanks" script. Pretty sure I applied v3.
I think I applied this version previously and the script just matched the subjects?
Anyway, ignore this mail.
cheers