Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3662123rwb; Tue, 20 Sep 2022 02:55:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6xd7SBTI+9vIwO6sYo9bP31XGdQS/C5wmF9lpVwEEjN56jR4IfejOcKOM6FJT7ETTbu3ka X-Received: by 2002:a17:907:2672:b0:781:dc01:6c5a with SMTP id ci18-20020a170907267200b00781dc016c5amr530041ejc.191.1663667756912; Tue, 20 Sep 2022 02:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663667756; cv=none; d=google.com; s=arc-20160816; b=G2H/bR2O+eYc3F0HyapFkVCCAaCB7kfybo9ncqPdEKT6PDRQg4qML5dPteXQo8btuh h5jykb8z426qb9KQFp+XKXB/ofYthgbPVWv++hPCHPLjlkI3UXzcBSOwblb6qWW8ANw1 laDFnxCMmuqSfI8LwiFQALRPUNpSSznJEZNr4KzKfk2UWQkSpj5aM1yPRH129tiwCkU0 eejDLWDu+sVgHcsDv3KhqvxTjFBB2jRnNH78S5gLkyunzqBc/0AVoIEV11vebXy0eMrW xeKgCKX4pw3HvvW70nXgaMXglTltBt0GeM51oKrBKhpk3hGxzU0i3cPCm1xJQQd5tk3u KAJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kjJsmZLrEm0E14GxgtEtwn0ufmFfZ2BYYW9ckF7Nm5Q=; b=q5ttZzFgJt5svabCnQMdkDGZIUxzxIrEdQ0uoR4OkFvrgVXGYAkgyapVMefOYwsihW 8/PvskrCyT4A3Citzvr21klgvaq4dDYDAtyXQKeOQ17YVjaTwl6p63Mmlj9ym4pxqdtB kvAIycTSYPh6u6F9ekK+609I2H5V9GdaP/7L7QJnOWtet/o/WpploCg6qrflH/Qr4/u3 kfcZ1akR95DV6QiL9+tFkO/rs4ZSALwzrfM61Zm3lbQMA05rnJ48oIfPatiWjgIMhjRW 3lkoCITG4pOTlDVrwYRgj6i/hCFxg/wKA49G2d4gRisKPTk8TMxRfDKZlgOFA9CeD9C0 IHKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a10-20020a1709063e8a00b0073d6c39d4bcsi870676ejj.653.2022.09.20.02.55.30; Tue, 20 Sep 2022 02:55:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230315AbiITJsD (ORCPT + 99 others); Tue, 20 Sep 2022 05:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230300AbiITJrx (ORCPT ); Tue, 20 Sep 2022 05:47:53 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F7FD6F554; Tue, 20 Sep 2022 02:47:46 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MWxV14DnlzpTDQ; Tue, 20 Sep 2022 17:44:57 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 20 Sep 2022 17:47:45 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 20 Sep 2022 17:47:44 +0800 From: Huisong Li To: , CC: , , , , , Subject: [PATCH 1/2] ACPI: PCC: replace wait_for_completion() Date: Tue, 20 Sep 2022 17:44:59 +0800 Message-ID: <20220920094500.11283-2-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220920094500.11283-1-lihuisong@huawei.com> References: <20220920094500.11283-1-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 +/* + * 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