Skip to content

Commit 587d2c6

Browse files
akky16gregkh
authored andcommitted
misc: amd-sbi: Optimize the wait condition for mailbox command completion
- optimize the wait condition to indicate command completion by replacing the do while loop with regmap subsystem API regmap_read_poll_timeout() Reviewed-by: Naveen Krishna Chatradhi <[email protected]> Signed-off-by: Akshay Gupta <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 013f7e7 commit 587d2c6

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

drivers/misc/amd-sbi/rmi-core.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int rmi_mailbox_xfer(struct sbrmi_data *data,
2323
struct sbrmi_mailbox_msg *msg)
2424
{
2525
unsigned int bytes;
26-
int i, ret, retry = 10;
26+
int i, ret;
2727
int sw_status;
2828
u8 byte;
2929

@@ -64,21 +64,10 @@ int rmi_mailbox_xfer(struct sbrmi_data *data,
6464
* an ALERT (if enabled) to initiator (BMC) to indicate completion
6565
* of the requested command
6666
*/
67-
do {
68-
ret = regmap_read(data->regmap, SBRMI_STATUS, &sw_status);
69-
if (sw_status < 0) {
70-
ret = sw_status;
71-
goto exit_unlock;
72-
}
73-
if (sw_status & SW_ALERT_MASK)
74-
break;
75-
usleep_range(50, 100);
76-
} while (retry--);
77-
78-
if (retry < 0) {
79-
ret = -EIO;
67+
ret = regmap_read_poll_timeout(data->regmap, SBRMI_STATUS, sw_status,
68+
sw_status & SW_ALERT_MASK, 500, 2000000);
69+
if (ret)
8070
goto exit_unlock;
81-
}
8271

8372
/*
8473
* For a read operation, the initiator (BMC) reads the firmware

0 commit comments

Comments
 (0)