Skip to content

Commit 911dfb8

Browse files
committed
x86/platform/amd: move final timeout check to after final sleep
JIRA: https://issues.redhat.com/browse/RHEL-102859 commit f8afb12 Author: Jake Hillion <jake@hillion.co.uk> Date: Thu Jun 5 19:09:26 2025 +0100 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 <linux@blaise.sanouillet.com> Reviewed-by: Suma Hegde <suma.hegde@amd.com> Tested-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Jake Hillion <jake@hillion.co.uk> Link: https://lore.kernel.org/r/20250605-amd-hsmp-v2-1-a811bc3dd74a@hillion.co.uk Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent 655b820 commit 911dfb8

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)