]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
misc: amd-sbi: Optimize the wait condition for mailbox command completion
authorAkshay Gupta <akshay.gupta@amd.com>
Mon, 28 Apr 2025 06:30:29 +0000 (06:30 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 May 2025 12:44:40 +0000 (14:44 +0200)
- 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 <naveenkrishna.chatradhi@amd.com>
Signed-off-by: Akshay Gupta <akshay.gupta@amd.com>
Link: https://lore.kernel.org/r/20250428063034.2145566-6-akshay.gupta@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/amd-sbi/rmi-core.c

index 663ab9176d9551a8d616a90ff28aef43287a2b1a..1d5e2556ab88f0e430a9185254cdbe0886e66ac6 100644 (file)
@@ -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