aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkshay Gupta <[email protected]>2025-04-28 06:30:29 +0000
committerGreg Kroah-Hartman <[email protected]>2025-05-21 12:44:40 +0000
commit587d2c625146c7ff62325ebb9a8668e666400dc4 (patch)
tree8d75b291d58ae3de3e90dad9a8cb14167d45af19
parentmisc: amd-sbi: Use regmap subsystem (diff)
downloadkernel-587d2c625146c7ff62325ebb9a8668e666400dc4.tar.gz
kernel-587d2c625146c7ff62325ebb9a8668e666400dc4.zip
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]>
-rw-r--r--drivers/misc/amd-sbi/rmi-core.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/drivers/misc/amd-sbi/rmi-core.c b/drivers/misc/amd-sbi/rmi-core.c
index 663ab9176d95..1d5e2556ab88 100644
--- a/drivers/misc/amd-sbi/rmi-core.c
+++ b/drivers/misc/amd-sbi/rmi-core.c
@@ -23,7 +23,7 @@ int rmi_mailbox_xfer(struct sbrmi_data *data,
struct sbrmi_mailbox_msg *msg)
{
unsigned int bytes;
- int i, ret, retry = 10;
+ int i, ret;
int sw_status;
u8 byte;
@@ -64,21 +64,10 @@ int rmi_mailbox_xfer(struct sbrmi_data *data,
* an ALERT (if enabled) to initiator (BMC) to indicate completion
* of the requested command
*/
- do {
- ret = regmap_read(data->regmap, SBRMI_STATUS, &sw_status);
- if (sw_status < 0) {
- ret = sw_status;
- goto exit_unlock;
- }
- if (sw_status & SW_ALERT_MASK)
- break;
- usleep_range(50, 100);
- } while (retry--);
-
- if (retry < 0) {
- ret = -EIO;
+ ret = regmap_read_poll_timeout(data->regmap, SBRMI_STATUS, sw_status,
+ sw_status & SW_ALERT_MASK, 500, 2000000);
+ if (ret)
goto exit_unlock;
- }
/*
* For a read operation, the initiator (BMC) reads the firmware