33
33
#include <asm/ppc-pci.h>
34
34
#include <asm/rtas.h>
35
35
36
- static int pseries_eeh_get_pe_addr (struct pci_dn * pdn );
37
-
38
36
/* RTAS tokens */
39
37
static int ibm_set_eeh_option ;
40
38
static int ibm_set_slot_reset ;
@@ -86,7 +84,8 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
86
84
87
85
88
86
/**
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
90
89
*
91
90
* Retrieve the assocated config address. Actually, there're 2 RTAS
92
91
* function calls dedicated for the purpose. We need implement
@@ -97,16 +96,17 @@ void pseries_pcibios_bus_add_device(struct pci_dev *pdev)
97
96
* It's notable that zero'ed return value means invalid PE config
98
97
* address.
99
98
*/
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 )
101
100
{
101
+ int config_addr = rtas_config_addr (pdn -> busno , pdn -> devfn , 0 );
102
+ struct pci_controller * phb = pdn -> phb ;
102
103
int ret = 0 ;
103
104
int rets [3 ];
104
105
105
106
if (ibm_get_config_addr_info2 != RTAS_UNKNOWN_SERVICE ) {
106
107
/*
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.
110
110
*/
111
111
ret = rtas_call (ibm_get_config_addr_info2 , 4 , 2 , rets ,
112
112
config_addr , BUID_HI (phb -> buid ),
@@ -429,7 +429,7 @@ void pseries_eeh_init_edev(struct pci_dn *pdn)
429
429
struct eeh_pe * parent ;
430
430
431
431
/* 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 );
433
433
pe .addr = edev -> pe_config_addr ;
434
434
435
435
/* 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)
548
548
return ret ;
549
549
}
550
550
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
-
609
551
/**
610
552
* pseries_eeh_get_state - Retrieve PE state
611
553
* @pe: EEH PE
@@ -907,7 +849,7 @@ static int __init eeh_pseries_init(void)
907
849
{
908
850
struct pci_controller * phb ;
909
851
struct pci_dn * pdn ;
910
- int ret , addr , config_addr ;
852
+ int ret , config_addr ;
911
853
912
854
/* figure out EEH RTAS function call tokens */
913
855
ibm_set_eeh_option = rtas_token ("ibm,set-eeh-option" );
@@ -965,8 +907,8 @@ static int __init eeh_pseries_init(void)
965
907
pr_info ("Issue PHB reset ...\n" );
966
908
list_for_each_entry (phb , & hose_list , list_node ) {
967
909
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
+
970
912
/* invalid PE config addr */
971
913
if (config_addr == 0 )
972
914
continue ;
0 commit comments