@@ -615,29 +615,50 @@ static int pseries_eeh_configure_bridge(struct eeh_pe *pe)
615615{
616616 int config_addr ;
617617 int ret ;
618+ /* Waiting 0.2s maximum before skipping configuration */
619+ int max_wait = 200 ;
618620
619621 /* Figure out the PE address */
620622 config_addr = pe -> config_addr ;
621623 if (pe -> addr )
622624 config_addr = pe -> addr ;
623625
624- /* Use new configure-pe function, if supported */
625- if (ibm_configure_pe != RTAS_UNKNOWN_SERVICE ) {
626- ret = rtas_call (ibm_configure_pe , 3 , 1 , NULL ,
627- config_addr , BUID_HI (pe -> phb -> buid ),
628- BUID_LO (pe -> phb -> buid ));
629- } else if (ibm_configure_bridge != RTAS_UNKNOWN_SERVICE ) {
630- ret = rtas_call (ibm_configure_bridge , 3 , 1 , NULL ,
631- config_addr , BUID_HI (pe -> phb -> buid ),
632- BUID_LO (pe -> phb -> buid ));
633- } else {
634- return - EFAULT ;
635- }
626+ while (max_wait > 0 ) {
627+ /* Use new configure-pe function, if supported */
628+ if (ibm_configure_pe != RTAS_UNKNOWN_SERVICE ) {
629+ ret = rtas_call (ibm_configure_pe , 3 , 1 , NULL ,
630+ config_addr , BUID_HI (pe -> phb -> buid ),
631+ BUID_LO (pe -> phb -> buid ));
632+ } else if (ibm_configure_bridge != RTAS_UNKNOWN_SERVICE ) {
633+ ret = rtas_call (ibm_configure_bridge , 3 , 1 , NULL ,
634+ config_addr , BUID_HI (pe -> phb -> buid ),
635+ BUID_LO (pe -> phb -> buid ));
636+ } else {
637+ return - EFAULT ;
638+ }
636639
637- if (ret )
638- pr_warn ("%s: Unable to configure bridge PHB#%d-PE#%x (%d)\n" ,
639- __func__ , pe -> phb -> global_number , pe -> addr , ret );
640+ if (!ret )
641+ return ret ;
642+
643+ /*
644+ * If RTAS returns a delay value that's above 100ms, cut it
645+ * down to 100ms in case firmware made a mistake. For more
646+ * on how these delay values work see rtas_busy_delay_time
647+ */
648+ if (ret > RTAS_EXTENDED_DELAY_MIN + 2 &&
649+ ret <= RTAS_EXTENDED_DELAY_MAX )
650+ ret = RTAS_EXTENDED_DELAY_MIN + 2 ;
651+
652+ max_wait -= rtas_busy_delay_time (ret );
653+
654+ if (max_wait < 0 )
655+ break ;
656+
657+ rtas_busy_delay (ret );
658+ }
640659
660+ pr_warn ("%s: Unable to configure bridge PHB#%d-PE#%x (%d)\n" ,
661+ __func__ , pe -> phb -> global_number , pe -> addr , ret );
641662 return ret ;
642663}
643664
0 commit comments