Skip to content

Commit f61c859

Browse files
oohalmpe
authored andcommitted
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 <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 395ee2a commit f61c859

File tree

1 file changed

+11
-69
lines changed

1 file changed

+11
-69
lines changed

arch/powerpc/platforms/pseries/eeh_pseries.c

Lines changed: 11 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#include <asm/ppc-pci.h>
3434
#include <asm/rtas.h>
3535

36-
static int pseries_eeh_get_pe_addr(struct pci_dn *pdn);
37-
3836
/* RTAS tokens */
3937
static int ibm_set_eeh_option;
4038
static int ibm_set_slot_reset;
@@ -86,7 +84,8 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
8684

8785

8886
/**
89-
* pseries_eeh_get_config_addr - Retrieve config address
87+
* pseries_eeh_get_pe_config_addr - Find the pe_config_addr for a device
88+
* @pdn: pci_dn of the input device
9089
*
9190
* Retrieve the assocated config address. Actually, there're 2 RTAS
9291
* function calls dedicated for the purpose. We need implement
@@ -97,16 +96,17 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
9796
* It's notable that zero'ed return value means invalid PE config
9897
* address.
9998
*/
100-
static int pseries_eeh_get_config_addr(struct pci_controller *phb, int config_addr)
99+
static int pseries_eeh_get_pe_config_addr(struct pci_dn *pdn)
101100
{
101+
int config_addr = rtas_config_addr(pdn->busno, pdn->devfn, 0);
102+
struct pci_controller *phb = pdn->phb;
102103
int ret = 0;
103104
int rets[3];
104105

105106
if (ibm_get_config_addr_info2 != RTAS_UNKNOWN_SERVICE) {
106107
/*
107-
* First of all, we need to make sure there has one PE
108-
* associated with the device. Otherwise, PE address is
109-
* meaningless.
108+
* First of all, use function 1 to determine if this device is
109+
* part of a PE or not. ret[0] being zero indicates it's not.
110110
*/
111111
ret = rtas_call(ibm_get_config_addr_info2, 4, 2, rets,
112112
config_addr, BUID_HI(phb->buid),
@@ -429,7 +429,7 @@ void pseries_eeh_init_edev(struct pci_dn *pdn)
429429
struct eeh_pe *parent;
430430

431431
/* Retrieve PE address */
432-
edev->pe_config_addr = pseries_eeh_get_pe_addr(pdn);
432+
edev->pe_config_addr = pseries_eeh_get_pe_config_addr(pdn);
433433
pe.addr = edev->pe_config_addr;
434434

435435
/* 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)
548548
return ret;
549549
}
550550

551-
/**
552-
* pseries_eeh_get_pe_addr - Retrieve PE address
553-
* @pe: EEH PE
554-
*
555-
* Retrieve the assocated PE address. Actually, there're 2 RTAS
556-
* function calls dedicated for the purpose. We need implement
557-
* it through the new function and then the old one. Besides,
558-
* you should make sure the config address is figured out from
559-
* FDT node before calling the function.
560-
*
561-
* It's notable that zero'ed return value means invalid PE config
562-
* address.
563-
*/
564-
static int pseries_eeh_get_pe_addr(struct pci_dn *pdn)
565-
{
566-
int config_addr = rtas_config_addr(pdn->busno, pdn->devfn, 0);
567-
unsigned long buid = pdn->phb->buid;
568-
int ret = 0;
569-
int rets[3];
570-
571-
if (ibm_get_config_addr_info2 != RTAS_UNKNOWN_SERVICE) {
572-
/*
573-
* First of all, we need to make sure there has one PE
574-
* associated with the device. Otherwise, PE address is
575-
* meaningless.
576-
*/
577-
ret = rtas_call(ibm_get_config_addr_info2, 4, 2, rets,
578-
config_addr, BUID_HI(buid), BUID_LO(buid), 1);
579-
if (ret || (rets[0] == 0))
580-
return 0;
581-
582-
/* Retrieve the associated PE config address */
583-
ret = rtas_call(ibm_get_config_addr_info2, 4, 2, rets,
584-
config_addr, BUID_HI(buid), BUID_LO(buid), 0);
585-
if (ret) {
586-
pr_warn("%s: Failed to get address for PHB#%x-PE#%x\n",
587-
__func__, pdn->phb->global_number, config_addr);
588-
return 0;
589-
}
590-
591-
return rets[0];
592-
}
593-
594-
if (ibm_get_config_addr_info != RTAS_UNKNOWN_SERVICE) {
595-
ret = rtas_call(ibm_get_config_addr_info, 4, 2, rets,
596-
config_addr, BUID_HI(buid), BUID_LO(buid), 0);
597-
if (ret) {
598-
pr_warn("%s: Failed to get address for PHB#%x-PE#%x\n",
599-
__func__, pdn->phb->global_number, config_addr);
600-
return 0;
601-
}
602-
603-
return rets[0];
604-
}
605-
606-
return ret;
607-
}
608-
609551
/**
610552
* pseries_eeh_get_state - Retrieve PE state
611553
* @pe: EEH PE
@@ -907,7 +849,7 @@ static int __init eeh_pseries_init(void)
907849
{
908850
struct pci_controller *phb;
909851
struct pci_dn *pdn;
910-
int ret, addr, config_addr;
852+
int ret, config_addr;
911853

912854
/* figure out EEH RTAS function call tokens */
913855
ibm_set_eeh_option = rtas_token("ibm,set-eeh-option");
@@ -965,8 +907,8 @@ static int __init eeh_pseries_init(void)
965907
pr_info("Issue PHB reset ...\n");
966908
list_for_each_entry(phb, &hose_list, list_node) {
967909
pdn = list_first_entry(&PCI_DN(phb->dn)->child_list, struct pci_dn, list);
968-
addr = (pdn->busno << 16) | (pdn->devfn << 8);
969-
config_addr = pseries_eeh_get_config_addr(phb, addr);
910+
config_addr = pseries_eeh_get_pe_config_addr(pdn);
911+
970912
/* invalid PE config addr */
971913
if (config_addr == 0)
972914
continue;

0 commit comments

Comments
 (0)