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 <tian.xianting@h3c.com> Message-Id: <20200916062129.26129-1-tian.xianting@h3c.com> [Moved GET_DEVICE_ID_MAX_RETRY to include/linux/ipmi.h, reworded some text.] Signed-off-by: Corey Minyard <cminyard@mvista.com>
This commit is contained in:
Родитель
a190db945b
Коммит
42d8a346c5
|
@ -62,8 +62,6 @@ enum ipmi_panic_event_op {
|
|||
#define IPMI_PANIC_DEFAULT IPMI_SEND_PANIC_EVENT_NONE
|
||||
#endif
|
||||
|
||||
#define GET_DEVICE_ID_MAX_RETRY 5
|
||||
|
||||
static enum ipmi_panic_event_op ipmi_send_panic_event = IPMI_PANIC_DEFAULT;
|
||||
|
||||
static int panic_op_write_handler(const char *val,
|
||||
|
|
|
@ -1316,6 +1316,7 @@ static int try_get_dev_id(struct smi_info *smi_info)
|
|||
unsigned char *resp;
|
||||
unsigned long resp_len;
|
||||
int rv = 0;
|
||||
unsigned int retry_count = 0;
|
||||
|
||||
resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
|
||||
if (!resp)
|
||||
|
@ -1327,6 +1328,8 @@ static int try_get_dev_id(struct smi_info *smi_info)
|
|||
*/
|
||||
msg[0] = IPMI_NETFN_APP_REQUEST << 2;
|
||||
msg[1] = IPMI_GET_DEVICE_ID_CMD;
|
||||
|
||||
retry:
|
||||
smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2);
|
||||
|
||||
rv = wait_for_msg_done(smi_info);
|
||||
|
@ -1339,6 +1342,20 @@ static int try_get_dev_id(struct smi_info *smi_info)
|
|||
/* Check and record info from the get device id, in case we need it. */
|
||||
rv = ipmi_demangle_device_id(resp[0] >> 2, resp[1],
|
||||
resp + 2, resp_len - 2, &smi_info->device_id);
|
||||
if (rv) {
|
||||
/* record completion code */
|
||||
char cc = *(resp + 2);
|
||||
|
||||
if ((cc == IPMI_DEVICE_IN_FW_UPDATE_ERR
|
||||
|| cc == IPMI_DEVICE_IN_INIT_ERR
|
||||
|| cc == IPMI_NOT_IN_MY_STATE_ERR)
|
||||
&& ++retry_count <= GET_DEVICE_ID_MAX_RETRY) {
|
||||
dev_warn(smi_info->io.dev,
|
||||
"BMC returned 0x%2.2x, retry get bmc device id\n",
|
||||
cc);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
kfree(resp);
|
||||
|
|
|
@ -333,4 +333,6 @@ struct ipmi_smi_info {
|
|||
/* This is to get the private info of struct ipmi_smi */
|
||||
extern int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data);
|
||||
|
||||
#define GET_DEVICE_ID_MAX_RETRY 5
|
||||
|
||||
#endif /* __LINUX_IPMI_H */
|
||||
|
|
Загрузка…
Ссылка в новой задаче