From: Huisong Li <lihuisong@huawei.com>
To: <linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <rafael@kernel.org>, <sudeep.holla@arm.com>,
<rafael.j.wysocki@intel.com>, <wanghuiqiang@huawei.com>,
<huangdaode@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH 1/2] ACPI: PCC: replace wait_for_completion()
Date: Tue, 20 Sep 2022 17:44:59 +0800 [thread overview]
Message-ID: <20220920094500.11283-2-lihuisong@huawei.com> (raw)
In-Reply-To: <20220920094500.11283-1-lihuisong@huawei.com>
Currently, the function waiting for completion of mailbox operation is
'wait_for_completion()'. The PCC method will be permanently blocked if
this mailbox message fails to execute. So this patch replaces it with
'wait_for_completion_timeout()'. And set the timeout interval to an
arbitrary retries on top of nominal to prevent the remote processor is
slow to respond to PCC commands.
Fixes: 77e2a04745ff ("ACPI: PCC: Implement OperationRegion handler for the PCC Type 3 subtype")
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
drivers/acpi/acpi_pcc.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/acpi_pcc.c b/drivers/acpi/acpi_pcc.c
index a12b55d81209..a1052fe998bf 100644
--- a/drivers/acpi/acpi_pcc.c
+++ b/drivers/acpi/acpi_pcc.c
@@ -23,6 +23,12 @@
#include <acpi/pcc.h>
+/*
+ * Arbitrary retries in case the remote processor is slow to respond
+ * to PCC commands
+ */
+#define PCC_CMD_WAIT_RETRIES_NUM 500
+
struct pcc_data {
struct pcc_mbox_chan *pcc_chan;
void __iomem *pcc_comm_addr;
@@ -86,6 +92,7 @@ acpi_pcc_address_space_handler(u32 function, acpi_physical_address addr,
{
int ret;
struct pcc_data *data = region_context;
+ u64 usecs_lat;
reinit_completion(&data->done);
@@ -96,8 +103,20 @@ acpi_pcc_address_space_handler(u32 function, acpi_physical_address addr,
if (ret < 0)
return AE_ERROR;
- if (data->pcc_chan->mchan->mbox->txdone_irq)
- wait_for_completion(&data->done);
+ if (data->pcc_chan->mchan->mbox->txdone_irq) {
+ /*
+ * pcc_chan->latency is just a Nominal value. In reality the remote
+ * processor could be much slower to reply. So add an arbitrary
+ * amount of wait on top of Nominal.
+ */
+ usecs_lat = PCC_CMD_WAIT_RETRIES_NUM * data->pcc_chan->latency;
+ ret = wait_for_completion_timeout(&data->done,
+ usecs_to_jiffies(usecs_lat));
+ if (ret == 0) {
+ pr_err("PCC command executed timeout!\n");
+ return AE_TIME;
+ }
+ }
mbox_client_txdone(data->pcc_chan->mchan, ret);
--
2.33.0
next prev parent reply other threads:[~2022-09-20 9:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 9:44 [PATCH 0/2] ACPI: PCC: add waiting timeout and fix Tx done interface Huisong Li
2022-09-20 9:44 ` Huisong Li [this message]
2022-09-21 15:47 ` [PATCH 1/2] ACPI: PCC: replace wait_for_completion() Sudeep Holla
2022-09-22 2:29 ` lihuisong (C)
2022-09-20 9:45 ` [PATCH 2/2] ACPI: PCC: fix Tx done interface in handler Huisong Li
2022-09-21 15:43 ` Sudeep Holla
2022-09-22 2:30 ` lihuisong (C)
2022-09-22 19:10 ` Rafael J. Wysocki
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=20220920094500.11283-2-lihuisong@huawei.com \
--to=lihuisong@huawei.com \
--cc=huangdaode@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=wanghuiqiang@huawei.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®