powerpc/pseries/eeh: Clean up pe_config_addr lookups
De-duplicate, and fix up the comments, and make the prototype just take a pci_dn since the job of the function is to return the pe_config_addr of the PE which contains a given device. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200918093050.37344-6-oohall@gmail.com
This commit is contained in:
committed by
Michael Ellerman
parent
395ee2a2a1
commit
f61c859feb
@@ -33,8 +33,6 @@
|
|||||||
#include <asm/ppc-pci.h>
|
#include <asm/ppc-pci.h>
|
||||||
#include <asm/rtas.h>
|
#include <asm/rtas.h>
|
||||||
|
|
||||||
static int pseries_eeh_get_pe_addr(struct pci_dn *pdn);
|
|
||||||
|
|
||||||
/* RTAS tokens */
|
/* RTAS tokens */
|
||||||
static int ibm_set_eeh_option;
|
static int ibm_set_eeh_option;
|
||||||
static int ibm_set_slot_reset;
|
static int ibm_set_slot_reset;
|
||||||
@@ -86,7 +84,8 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pseries_eeh_get_config_addr - Retrieve config address
|
* pseries_eeh_get_pe_config_addr - Find the pe_config_addr for a device
|
||||||
|
* @pdn: pci_dn of the input device
|
||||||
*
|
*
|
||||||
* Retrieve the assocated config address. Actually, there're 2 RTAS
|
* Retrieve the assocated config address. Actually, there're 2 RTAS
|
||||||
* function calls dedicated for the purpose. We need implement
|
* function calls dedicated for the purpose. We need implement
|
||||||
@@ -97,16 +96,17 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
|
|||||||
* It's notable that zero'ed return value means invalid PE config
|
* It's notable that zero'ed return value means invalid PE config
|
||||||
* address.
|
* address.
|
||||||
*/
|
*/
|
||||||
static int pseries_eeh_get_config_addr(struct pci_controller *phb, int config_addr)
|
static int pseries_eeh_get_pe_config_addr(struct pci_dn *pdn)
|
||||||
{
|
{
|
||||||
|
int config_addr = rtas_config_addr(pdn->busno, pdn->devfn, 0);
|
||||||
|
struct pci_controller *phb = pdn->phb;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int rets[3];
|
int rets[3];
|
||||||
|
|
||||||
if (ibm_get_config_addr_info2 != RTAS_UNKNOWN_SERVICE) {
|
if (ibm_get_config_addr_info2 != RTAS_UNKNOWN_SERVICE) {
|
||||||
/*
|
/*
|
||||||
* First of all, we need to make sure there has one PE
|
* First of all, use function 1 to determine if this device is
|
||||||
* associated with the device. Otherwise, PE address is
|
* part of a PE or not. ret[0] being zero indicates it's not.
|
||||||
* meaningless.
|
|
||||||
*/
|
*/
|
||||||
ret = rtas_call(ibm_get_config_addr_info2, 4, 2, rets,
|
ret = rtas_call(ibm_get_config_addr_info2, 4, 2, rets,
|
||||||
config_addr, BUID_HI(phb->buid),
|
config_addr, BUID_HI(phb->buid),
|
||||||
@@ -429,7 +429,7 @@ void pseries_eeh_init_edev(struct pci_dn *pdn)
|
|||||||
struct eeh_pe *parent;
|
struct eeh_pe *parent;
|
||||||
|
|
||||||
/* Retrieve PE address */
|
/* Retrieve PE address */
|
||||||
edev->pe_config_addr = pseries_eeh_get_pe_addr(pdn);
|
edev->pe_config_addr = pseries_eeh_get_pe_config_addr(pdn);
|
||||||
pe.addr = edev->pe_config_addr;
|
pe.addr = edev->pe_config_addr;
|
||||||
|
|
||||||
/* Some older systems (Power4) allow the ibm,set-eeh-option
|
/* Some older systems (Power4) allow the ibm,set-eeh-option
|
||||||
@@ -548,64 +548,6 @@ static int pseries_eeh_set_option(struct eeh_pe *pe, int option)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* pseries_eeh_get_pe_addr - Retrieve PE address
|
|
||||||
* @pe: EEH PE
|
|
||||||
*
|
|
||||||
* Retrieve the assocated PE address. Actually, there're 2 RTAS
|
|
||||||
* function calls dedicated for the purpose. We need implement
|
|
||||||
* it through the new function and then the old one. Besides,
|
|
||||||
* you should make sure the config address is figured out from
|
|
||||||
* FDT node before calling the function.
|
|
||||||
*
|
|
||||||
* It's notable that zero'ed return value means invalid PE config
|
|
||||||
* address.
|
|
||||||
*/
|
|
||||||
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];
|
|
||||||
|
|
||||||
if (ibm_get_config_addr_info2 != RTAS_UNKNOWN_SERVICE) {
|
|
||||||
/*
|
|
||||||
* First of all, we need to make sure there has one PE
|
|
||||||
* associated with the device. Otherwise, PE address is
|
|
||||||
* meaningless.
|
|
||||||
*/
|
|
||||||
ret = rtas_call(ibm_get_config_addr_info2, 4, 2, rets,
|
|
||||||
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,
|
|
||||||
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__, pdn->phb->global_number, config_addr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rets[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ibm_get_config_addr_info != RTAS_UNKNOWN_SERVICE) {
|
|
||||||
ret = rtas_call(ibm_get_config_addr_info, 4, 2, rets,
|
|
||||||
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__, pdn->phb->global_number, config_addr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rets[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pseries_eeh_get_state - Retrieve PE state
|
* pseries_eeh_get_state - Retrieve PE state
|
||||||
* @pe: EEH PE
|
* @pe: EEH PE
|
||||||
@@ -907,7 +849,7 @@ static int __init eeh_pseries_init(void)
|
|||||||
{
|
{
|
||||||
struct pci_controller *phb;
|
struct pci_controller *phb;
|
||||||
struct pci_dn *pdn;
|
struct pci_dn *pdn;
|
||||||
int ret, addr, config_addr;
|
int ret, config_addr;
|
||||||
|
|
||||||
/* figure out EEH RTAS function call tokens */
|
/* figure out EEH RTAS function call tokens */
|
||||||
ibm_set_eeh_option = rtas_token("ibm,set-eeh-option");
|
ibm_set_eeh_option = rtas_token("ibm,set-eeh-option");
|
||||||
@@ -965,8 +907,8 @@ static int __init eeh_pseries_init(void)
|
|||||||
pr_info("Issue PHB reset ...\n");
|
pr_info("Issue PHB reset ...\n");
|
||||||
list_for_each_entry(phb, &hose_list, list_node) {
|
list_for_each_entry(phb, &hose_list, list_node) {
|
||||||
pdn = list_first_entry(&PCI_DN(phb->dn)->child_list, struct pci_dn, list);
|
pdn = list_first_entry(&PCI_DN(phb->dn)->child_list, struct pci_dn, list);
|
||||||
addr = (pdn->busno << 16) | (pdn->devfn << 8);
|
config_addr = pseries_eeh_get_pe_config_addr(pdn);
|
||||||
config_addr = pseries_eeh_get_config_addr(phb, addr);
|
|
||||||
/* invalid PE config addr */
|
/* invalid PE config addr */
|
||||||
if (config_addr == 0)
|
if (config_addr == 0)
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user