Skip to content

Commit f8afb12

Browse files
JakeHillionij-intel
authored andcommitted
x86/platform/amd: move final timeout check to after final sleep
__hsmp_send_message sleeps between result read attempts and has a timeout of 100ms. Under extreme load it's possible for these sleeps to take a long time, exceeding the 100ms. In this case the current code does not check the register and fails with ETIMEDOUT. Refactor the loop to ensure there is at least one read of the register after a sleep of any duration. This removes instances of ETIMEDOUT with a single caller, even with a misbehaving scheduler. Tested on AMD Bergamo machines. Suggested-by: Blaise Sanouillet <[email protected]> Reviewed-by: Suma Hegde <[email protected]> Tested-by: Suma Hegde <[email protected]> Signed-off-by: Jake Hillion <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 4dbd117 commit f8afb12

File tree

1 file changed

+5
-1
lines changed
  • drivers/platform/x86/amd/hsmp

1 file changed

+5
-1
lines changed

drivers/platform/x86/amd/hsmp/hsmp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
9797
short_sleep = jiffies + msecs_to_jiffies(HSMP_SHORT_SLEEP);
9898
timeout = jiffies + msecs_to_jiffies(HSMP_MSG_TIMEOUT);
9999

100-
while (time_before(jiffies, timeout)) {
100+
while (true) {
101101
ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_RD);
102102
if (ret) {
103103
dev_err(sock->dev, "Error %d reading mailbox status\n", ret);
@@ -106,6 +106,10 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
106106

107107
if (mbox_status != HSMP_STATUS_NOT_READY)
108108
break;
109+
110+
if (!time_before(jiffies, timeout))
111+
break;
112+
109113
if (time_before(jiffies, short_sleep))
110114
usleep_range(50, 100);
111115
else

0 commit comments

Comments
 (0)