@@ -59,8 +59,6 @@ enum bt_states {
59
59
BT_STATE_RESET3 ,
60
60
BT_STATE_RESTART ,
61
61
BT_STATE_PRINTME ,
62
- BT_STATE_CAPABILITIES_BEGIN ,
63
- BT_STATE_CAPABILITIES_END ,
64
62
BT_STATE_LONG_BUSY /* BT doesn't get hosed :-) */
65
63
};
66
64
@@ -86,7 +84,6 @@ struct si_sm_data {
86
84
int error_retries ; /* end of "common" fields */
87
85
int nonzero_status ; /* hung BMCs stay all 0 */
88
86
enum bt_states complete ; /* to divert the state machine */
89
- int BT_CAP_outreqs ;
90
87
long BT_CAP_req2rsp ;
91
88
int BT_CAP_retries ; /* Recommended retries */
92
89
};
@@ -137,8 +134,6 @@ static char *state2txt(unsigned char state)
137
134
case BT_STATE_RESET3 : return ("RESET3" );
138
135
case BT_STATE_RESTART : return ("RESTART" );
139
136
case BT_STATE_LONG_BUSY : return ("LONG_BUSY" );
140
- case BT_STATE_CAPABILITIES_BEGIN : return ("CAP_BEGIN" );
141
- case BT_STATE_CAPABILITIES_END : return ("CAP_END" );
142
137
}
143
138
return ("BAD STATE" );
144
139
}
@@ -185,7 +180,6 @@ static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io)
185
180
bt -> complete = BT_STATE_IDLE ; /* end here */
186
181
bt -> BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * USEC_PER_SEC ;
187
182
bt -> BT_CAP_retries = BT_NORMAL_RETRY_LIMIT ;
188
- /* BT_CAP_outreqs == zero is a flag to read BT Capabilities */
189
183
return 3 ; /* We claim 3 bytes of space; ought to check SPMI table */
190
184
}
191
185
@@ -451,7 +445,7 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt,
451
445
452
446
static enum si_sm_result bt_event (struct si_sm_data * bt , long time )
453
447
{
454
- unsigned char status , BT_CAP [ 8 ] ;
448
+ unsigned char status ;
455
449
static enum bt_states last_printed = BT_STATE_PRINTME ;
456
450
int i ;
457
451
@@ -504,12 +498,6 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
504
498
if (status & BT_H_BUSY ) /* clear a leftover H_BUSY */
505
499
BT_CONTROL (BT_H_BUSY );
506
500
507
- bt -> timeout = bt -> BT_CAP_req2rsp ;
508
-
509
- /* Read BT capabilities if it hasn't been done yet */
510
- if (!bt -> BT_CAP_outreqs )
511
- BT_STATE_CHANGE (BT_STATE_CAPABILITIES_BEGIN ,
512
- SI_SM_CALL_WITHOUT_DELAY );
513
501
BT_SI_SM_RETURN (SI_SM_IDLE );
514
502
515
503
case BT_STATE_XACTION_START :
@@ -614,37 +602,6 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
614
602
BT_STATE_CHANGE (BT_STATE_XACTION_START ,
615
603
SI_SM_CALL_WITH_DELAY );
616
604
617
- /*
618
- * Get BT Capabilities, using timing of upper level state machine.
619
- * Set outreqs to prevent infinite loop on timeout.
620
- */
621
- case BT_STATE_CAPABILITIES_BEGIN :
622
- bt -> BT_CAP_outreqs = 1 ;
623
- {
624
- unsigned char GetBT_CAP [] = { 0x18 , 0x36 };
625
- bt -> state = BT_STATE_IDLE ;
626
- bt_start_transaction (bt , GetBT_CAP , sizeof (GetBT_CAP ));
627
- }
628
- bt -> complete = BT_STATE_CAPABILITIES_END ;
629
- BT_STATE_CHANGE (BT_STATE_XACTION_START ,
630
- SI_SM_CALL_WITH_DELAY );
631
-
632
- case BT_STATE_CAPABILITIES_END :
633
- i = bt_get_result (bt , BT_CAP , sizeof (BT_CAP ));
634
- bt_init_data (bt , bt -> io );
635
- if ((i == 8 ) && !BT_CAP [2 ]) {
636
- bt -> BT_CAP_outreqs = BT_CAP [3 ];
637
- bt -> BT_CAP_req2rsp = BT_CAP [6 ] * USEC_PER_SEC ;
638
- bt -> BT_CAP_retries = BT_CAP [7 ];
639
- } else
640
- printk (KERN_WARNING "IPMI BT: using default values\n" );
641
- if (!bt -> BT_CAP_outreqs )
642
- bt -> BT_CAP_outreqs = 1 ;
643
- printk (KERN_WARNING "IPMI BT: req2rsp=%ld secs retries=%d\n" ,
644
- bt -> BT_CAP_req2rsp / USEC_PER_SEC , bt -> BT_CAP_retries );
645
- bt -> timeout = bt -> BT_CAP_req2rsp ;
646
- return SI_SM_CALL_WITHOUT_DELAY ;
647
-
648
605
default : /* should never occur */
649
606
return error_recovery (bt ,
650
607
status ,
@@ -655,6 +612,11 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
655
612
656
613
static int bt_detect (struct si_sm_data * bt )
657
614
{
615
+ unsigned char GetBT_CAP [] = { 0x18 , 0x36 };
616
+ unsigned char BT_CAP [8 ];
617
+ enum si_sm_result smi_result ;
618
+ int rv ;
619
+
658
620
/*
659
621
* It's impossible for the BT status and interrupt registers to be
660
622
* all 1's, (assuming a properly functioning, self-initialized BMC)
@@ -665,6 +627,48 @@ static int bt_detect(struct si_sm_data *bt)
665
627
if ((BT_STATUS == 0xFF ) && (BT_INTMASK_R == 0xFF ))
666
628
return 1 ;
667
629
reset_flags (bt );
630
+
631
+ /*
632
+ * Try getting the BT capabilities here.
633
+ */
634
+ rv = bt_start_transaction (bt , GetBT_CAP , sizeof (GetBT_CAP ));
635
+ if (rv ) {
636
+ dev_warn (bt -> io -> dev ,
637
+ "Can't start capabilities transaction: %d\n" , rv );
638
+ goto out_no_bt_cap ;
639
+ }
640
+
641
+ smi_result = SI_SM_CALL_WITHOUT_DELAY ;
642
+ for (;;) {
643
+ if (smi_result == SI_SM_CALL_WITH_DELAY ||
644
+ smi_result == SI_SM_CALL_WITH_TICK_DELAY ) {
645
+ schedule_timeout_uninterruptible (1 );
646
+ smi_result = bt_event (bt , jiffies_to_usecs (1 ));
647
+ } else if (smi_result == SI_SM_CALL_WITHOUT_DELAY ) {
648
+ smi_result = bt_event (bt , 0 );
649
+ } else
650
+ break ;
651
+ }
652
+
653
+ rv = bt_get_result (bt , BT_CAP , sizeof (BT_CAP ));
654
+ bt_init_data (bt , bt -> io );
655
+ if (rv < 8 ) {
656
+ dev_warn (bt -> io -> dev , "bt cap response too short: %d\n" , rv );
657
+ goto out_no_bt_cap ;
658
+ }
659
+
660
+ if (BT_CAP [2 ]) {
661
+ dev_warn (bt -> io -> dev , "Error fetching bt cap: %x\n" , BT_CAP [2 ]);
662
+ out_no_bt_cap :
663
+ dev_warn (bt -> io -> dev , "using default values\n" );
664
+ } else {
665
+ bt -> BT_CAP_req2rsp = BT_CAP [6 ] * USEC_PER_SEC ;
666
+ bt -> BT_CAP_retries = BT_CAP [7 ];
667
+ }
668
+
669
+ dev_info (bt -> io -> dev , "req2rsp=%ld secs retries=%d\n" ,
670
+ bt -> BT_CAP_req2rsp / USEC_PER_SEC , bt -> BT_CAP_retries );
671
+
668
672
return 0 ;
669
673
}
670
674
0 commit comments