Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Akshay Gupta and committed by
Greg Kroah-Hartman
587d2c62 013f7e71

+4 -15
+4 -15
drivers/misc/amd-sbi/rmi-core.c
··· 23 23 struct sbrmi_mailbox_msg *msg) 24 24 { 25 25 unsigned int bytes; 26 - int i, ret, retry = 10; 26 + int i, ret; 27 27 int sw_status; 28 28 u8 byte; 29 29 ··· 64 64 * an ALERT (if enabled) to initiator (BMC) to indicate completion 65 65 * of the requested command 66 66 */ 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) 80 70 goto exit_unlock; 81 - } 82 71 83 72 /* 84 73 * For a read operation, the initiator (BMC) reads the firmware