Skip to content

Commit 42d8a34

Browse files
Xianting Tiancminyard
authored andcommitted
ipmi: add retry in try_get_dev_id()
Use a retry machanism to give the BMC more opportunities to correctly respond when we receive specific completion codes. This is similar to what is done in __get_device_id(). Signed-off-by: Xianting Tian <[email protected]> Message-Id: <[email protected]> [Moved GET_DEVICE_ID_MAX_RETRY to include/linux/ipmi.h, reworded some text.] Signed-off-by: Corey Minyard <[email protected]>
1 parent a190db9 commit 42d8a34

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ enum ipmi_panic_event_op {
6262
#define IPMI_PANIC_DEFAULT IPMI_SEND_PANIC_EVENT_NONE
6363
#endif
6464

65-
#define GET_DEVICE_ID_MAX_RETRY 5
66-
6765
static enum ipmi_panic_event_op ipmi_send_panic_event = IPMI_PANIC_DEFAULT;
6866

6967
static int panic_op_write_handler(const char *val,

drivers/char/ipmi/ipmi_si_intf.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,7 @@ static int try_get_dev_id(struct smi_info *smi_info)
13161316
unsigned char *resp;
13171317
unsigned long resp_len;
13181318
int rv = 0;
1319+
unsigned int retry_count = 0;
13191320

13201321
resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
13211322
if (!resp)
@@ -1327,6 +1328,8 @@ static int try_get_dev_id(struct smi_info *smi_info)
13271328
*/
13281329
msg[0] = IPMI_NETFN_APP_REQUEST << 2;
13291330
msg[1] = IPMI_GET_DEVICE_ID_CMD;
1331+
1332+
retry:
13301333
smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2);
13311334

13321335
rv = wait_for_msg_done(smi_info);
@@ -1339,6 +1342,20 @@ static int try_get_dev_id(struct smi_info *smi_info)
13391342
/* Check and record info from the get device id, in case we need it. */
13401343
rv = ipmi_demangle_device_id(resp[0] >> 2, resp[1],
13411344
resp + 2, resp_len - 2, &smi_info->device_id);
1345+
if (rv) {
1346+
/* record completion code */
1347+
char cc = *(resp + 2);
1348+
1349+
if ((cc == IPMI_DEVICE_IN_FW_UPDATE_ERR
1350+
|| cc == IPMI_DEVICE_IN_INIT_ERR
1351+
|| cc == IPMI_NOT_IN_MY_STATE_ERR)
1352+
&& ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
1353+
dev_warn(smi_info->io.dev,
1354+
"BMC returned 0x%2.2x, retry get bmc device id\n",
1355+
cc);
1356+
goto retry;
1357+
}
1358+
}
13421359

13431360
out:
13441361
kfree(resp);

include/linux/ipmi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,6 @@ struct ipmi_smi_info {
333333
/* This is to get the private info of struct ipmi_smi */
334334
extern int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data);
335335

336+
#define GET_DEVICE_ID_MAX_RETRY 5
337+
336338
#endif /* __LINUX_IPMI_H */

0 commit comments

Comments
 (0)