From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
To: <hdegoede@redhat.com>, <mgross@linux.intel.com>
Cc: <platform-driver-x86@vger.kernel.org>,
Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Subject: [PATCH v2 1/7] platform/x86: amd-pmc: Fix command completion code
Date: Thu, 24 Jun 2021 01:31:43 +0530 [thread overview]
Message-ID: <20210623200149.2518885-2-Shyam-sundar.S-k@amd.com> (raw)
In-Reply-To: <20210623200149.2518885-1-Shyam-sundar.S-k@amd.com>
The protocol to submit a job request to SMU is to wait for
AMD_PMC_REGISTER_RESPONSE to return 1,meaning SMU is ready to take
requests. PMC driver has to make sure that the response code is always
AMD_PMC_RESULT_OK before making any command submissions.
Also, when we submit a message to SMU, we have to wait until it processes
the request. Adding a read_poll_timeout() check as this was missing in
the existing code.
Fixes: 156ec4731cb2 ("platform/x86: amd-pmc: Add AMD platform support for S2Idle")
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
v2: no change
drivers/platform/x86/amd-pmc.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c
index b9da58ee9b1e..9c8a53120767 100644
--- a/drivers/platform/x86/amd-pmc.c
+++ b/drivers/platform/x86/amd-pmc.c
@@ -140,7 +140,7 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, bool set)
/* Wait until we get a valid response */
rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE,
- val, val > 0, PMC_MSG_DELAY_MIN_US,
+ val, val == AMD_PMC_RESULT_OK, PMC_MSG_DELAY_MIN_US,
PMC_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX);
if (rc) {
dev_err(dev->dev, "failed to talk to SMU\n");
@@ -156,6 +156,14 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, bool set)
/* Write message ID to message ID register */
msg = (dev->cpu_id == AMD_CPU_ID_RN) ? MSG_OS_HINT_RN : MSG_OS_HINT_PCO;
amd_pmc_reg_write(dev, AMD_PMC_REGISTER_MESSAGE, msg);
+ /* Wait until we get a valid response */
+ rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE,
+ val, val == AMD_PMC_RESULT_OK, PMC_MSG_DELAY_MIN_US,
+ PMC_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX);
+ if (rc) {
+ dev_err(dev->dev, "SMU response timed out\n");
+ return rc;
+ }
return 0;
}
--
2.25.1
next prev parent reply other threads:[~2021-06-23 20:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 20:01 [PATCH v2 0/7] updates to amd-pmc driver Shyam Sundar S K
2021-06-23 20:01 ` Shyam Sundar S K [this message]
2021-06-23 20:01 ` [PATCH v2 2/7] platform/x86: amd-pmc: Fix SMU firmware reporting mechanism Shyam Sundar S K
2021-06-23 20:01 ` [PATCH v2 3/7] platform/x86: amd-pmc: call dump registers only once Shyam Sundar S K
2021-06-23 20:01 ` [PATCH v2 4/7] platform/x86: amd-pmc: Add support for logging SMU metrics Shyam Sundar S K
2021-06-23 20:01 ` [PATCH v2 5/7] platform/x86: amd-pmc: Add support for logging s0ix counters Shyam Sundar S K
2021-06-23 20:01 ` [PATCH v2 6/7] platform/x86: amd-pmc: Add support for ACPI ID AMDI0006 Shyam Sundar S K
2021-06-23 20:01 ` [PATCH v2 7/7] platform/x86: amd-pmc: Add new acpi id for future PMC controllers Shyam Sundar S K
2021-06-23 20:44 ` [PATCH v2 0/7] updates to amd-pmc driver Hans de Goede
2021-06-24 5:42 ` Shyam Sundar S K
2021-06-25 14:25 ` Hans de Goede
2021-06-25 14:59 ` Raul Rangel
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=20210623200149.2518885-2-Shyam-sundar.S-k@amd.com \
--to=shyam-sundar.s-k@amd.com \
--cc=hdegoede@redhat.com \
--cc=mgross@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).