mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suma Hegde <Suma.Hegde@amd.com>
To: jake@hillion.co.uk,
	"Naveen Krishna Chatradhi" <naveenkrishna.chatradhi@amd.com>,
	"Carlos Bilbao" <carlos.bilbao@kernel.org>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, sched-ext@meta.com,
	Blaise Sanouillet <linux@blaise.sanouillet.com>
Subject: Re: [PATCH 1/2] x86/platform/amd: move final timeout check to after final sleep
Date: Wed, 4 Jun 2025 16:52:55 +0530	[thread overview]
Message-ID: <4bc3ebce-2b04-4686-b8a0-c08243a88d1b@amd.com> (raw)
In-Reply-To: <20250530-amd-hsmp-v1-1-3222bffa4008@hillion.co.uk>

Hi,


On 5/30/2025 9:45 PM, Jake Hillion via B4 Relay wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> From: Jake Hillion <jake@hillion.co.uk>
>
> __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>
> Signed-off-by: Jake Hillion <jake@hillion.co.uk>

Reviewed-by: Suma Hegde <suma.hegde@amd.com>
Tested-by: Suma Hegde <suma.hegde@amd.com>


> ---
>   drivers/platform/x86/amd/hsmp/hsmp.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c
> index e262e8a97b4542a389e09a82dad71f7d2e8b2449..f35c639457ac425e79dead2515c0eddea0759323 100644
> --- a/drivers/platform/x86/amd/hsmp/hsmp.c
> +++ b/drivers/platform/x86/amd/hsmp/hsmp.c
> @@ -99,7 +99,7 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
>          short_sleep = jiffies + msecs_to_jiffies(HSMP_SHORT_SLEEP);
>          timeout = jiffies + msecs_to_jiffies(HSMP_MSG_TIMEOUT);
>
> -       while (time_before(jiffies, timeout)) {
> +       while (true) {
>                  ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_RD);
>                  if (ret) {
>                          dev_err(sock->dev, "Error %d reading mailbox status\n", ret);
> @@ -108,6 +108,10 @@ static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
>
>                  if (mbox_status != HSMP_STATUS_NOT_READY)
>                          break;
> +
> +               if (!time_before(jiffies, timeout))
> +                       break;
> +
>                  if (time_before(jiffies, short_sleep))
>                          usleep_range(50, 100);
>                  else
>
> --
> 2.47.2
>
>
Thanks and Regards,

Suma


  reply	other threads:[~2025-06-04 11:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-30 16:15 [PATCH 0/2] x86/platform/amd: better handle scheduling delays in hsmp_send_message Jake Hillion via B4 Relay
2025-05-30 16:15 ` [PATCH 1/2] x86/platform/amd: move final timeout check to after final sleep Jake Hillion via B4 Relay
2025-06-04 11:22   ` Suma Hegde [this message]
2025-05-30 16:15 ` [PATCH 2/2] x86/platform/amd: replace down_timeout with down_interruptible Jake Hillion via B4 Relay
2025-06-04 11:25   ` Suma Hegde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4bc3ebce-2b04-4686-b8a0-c08243a88d1b@amd.com \
    --to=suma.hegde@amd.com \
    --cc=carlos.bilbao@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jake@hillion.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@blaise.sanouillet.com \
    --cc=naveenkrishna.chatradhi@amd.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sched-ext@meta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®