Skip to content

Commit 91cefef

Browse files
LiHuiSong1rafaeljw
authored andcommitted
ACPI: PCC: replace wait_for_completion()
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: 77e2a04 ("ACPI: PCC: Implement OperationRegion handler for the PCC Type 3 subtype") Signed-off-by: Huisong Li <[email protected]> Reviewed-by: Sudeep Holla <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent f890157 commit 91cefef

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

drivers/acpi/acpi_pcc.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323

2424
#include <acpi/pcc.h>
2525

26+
/*
27+
* Arbitrary retries in case the remote processor is slow to respond
28+
* to PCC commands
29+
*/
30+
#define PCC_CMD_WAIT_RETRIES_NUM 500
31+
2632
struct pcc_data {
2733
struct pcc_mbox_chan *pcc_chan;
2834
void __iomem *pcc_comm_addr;
@@ -89,6 +95,7 @@ acpi_pcc_address_space_handler(u32 function, acpi_physical_address addr,
8995
{
9096
int ret;
9197
struct pcc_data *data = region_context;
98+
u64 usecs_lat;
9299

93100
reinit_completion(&data->done);
94101

@@ -99,8 +106,20 @@ acpi_pcc_address_space_handler(u32 function, acpi_physical_address addr,
99106
if (ret < 0)
100107
return AE_ERROR;
101108

102-
if (data->pcc_chan->mchan->mbox->txdone_irq)
103-
wait_for_completion(&data->done);
109+
if (data->pcc_chan->mchan->mbox->txdone_irq) {
110+
/*
111+
* pcc_chan->latency is just a Nominal value. In reality the remote
112+
* processor could be much slower to reply. So add an arbitrary
113+
* amount of wait on top of Nominal.
114+
*/
115+
usecs_lat = PCC_CMD_WAIT_RETRIES_NUM * data->pcc_chan->latency;
116+
ret = wait_for_completion_timeout(&data->done,
117+
usecs_to_jiffies(usecs_lat));
118+
if (ret == 0) {
119+
pr_err("PCC command executed timeout!\n");
120+
return AE_TIME;
121+
}
122+
}
104123

105124
mbox_client_txdone(data->pcc_chan->mchan, ret);
106125

0 commit comments

Comments
 (0)