From patchwork Fri Nov 11 02:44:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huisong Li X-Patchwork-Id: 18397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp508137wru; Thu, 10 Nov 2022 19:04:33 -0800 (PST) X-Google-Smtp-Source: AMsMyM5z8nJLJ4VHSqLPePBs+E6sKbFSVtw5f8i1EDjyRntQCmHMfyuatTKFSvhMCZKx+AeExCw1 X-Received: by 2002:a17:90a:ad4a:b0:20a:aa74:175f with SMTP id w10-20020a17090aad4a00b0020aaa74175fmr3241767pjv.194.1668135873031; Thu, 10 Nov 2022 19:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668135873; cv=none; d=google.com; s=arc-20160816; b=bTV0r+deVZ3pdsu5X2DTlyt+2bBW1R3nr0GbySZB3aNjn8A5gq17rY7zmBmH6plWZS +QcytPcuW6IJgr7m+0ZEzzl9KvmSJQdD4li4/TnysOlouXs9B4/55gZ+HQouqQGfAw/a hLI91q4u12b1+sVb/LW1iM4tSEnJwGmNE1Az+YE568DDteHXnxoz9Y76k1iK+/EMzPvg kTLMoWmuJIi8irc13s2n53Pg6RRfwJqpzJHLpUB2vH0n/iFvUYGILOKbAkQhVueD/lic sA6tQBEIoTj+mfEMSw3XiQZ2blNhGeOzdahMrCtk5JmRU8mCXOV6lsg3AVPpWPuqkglR UM/A== 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=RtiC6jdaRLkpiIUZoRcsjEvG3LVaj0J23syxN+/Jzec=; b=TeaV5bzHbKtZN5EAuEjqdCWUYwNrT76J1MHICJpqQYOWVJ3d8icMtukKKrc2wWoghh nFNRKm9+rJ2dEd9PZkou2e2YJmMXLhbXR+MxRLzKJ7glunMh+jKXmudDDbJB01qrQc3p OjM+E/RQDtb7euUdhYAWrNLGvLcBUDD0ZX2LdUEEGqw4JOOc8FpRfS6SkJ5m6O2dqKng DiV7RsrjCyk6tM2/lVoYZef1uCQr1km5SnPrnriUNpWuqp8ycmqQd1WOUvy08XErx38C 4NyAHkuPP6lK3kqGTctr+RcM2hy34PorincYnYFFeJKzzX/9Tbf2mTwjMOHT1JXFUP/m Kh6w== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l192-20020a6391c9000000b0046fd9ddc689si1074964pge.571.2022.11.10.19.04.18; Thu, 10 Nov 2022 19:04:33 -0800 (PST) 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 S232685AbiKKCuA (ORCPT + 99 others); Thu, 10 Nov 2022 21:50:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233053AbiKKCth (ORCPT ); Thu, 10 Nov 2022 21:49:37 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14646DEA2; Thu, 10 Nov 2022 18:47:06 -0800 (PST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N7jlc5b9szRp5B; Fri, 11 Nov 2022 10:46:52 +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; Fri, 11 Nov 2022 10:47:04 +0800 Received: from localhost.localdomain (10.28.79.22) 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; Fri, 11 Nov 2022 10:47:03 +0800 From: Huisong Li To: , CC: , , , , , , , , , , , Subject: [PATCH V2 1/2] ACPI: PCC: add check for platform interrupt Date: Fri, 11 Nov 2022 10:44:47 +0800 Message-ID: <20221111024448.25012-2-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20221111024448.25012-1-lihuisong@huawei.com> References: <20221110015034.7943-1-lihuisong@huawei.com> <20221111024448.25012-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749072336852972996?= X-GMAIL-MSGID: =?utf-8?q?1749167240728690164?= Currently, PCC Operation Region driver senses the completion of command by interrupt way. If platform can not generate an interrupt when a command complete, the caller never gets the desired result. So let's reject the setup of the PCC address space on platform that do not support interrupt mode. Signed-off-by: Huisong Li Reviewed-by: Sudeep Holla --- drivers/acpi/acpi_pcc.c | 47 +++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/drivers/acpi/acpi_pcc.c b/drivers/acpi/acpi_pcc.c index 3e252be047b8..8efd08e469aa 100644 --- a/drivers/acpi/acpi_pcc.c +++ b/drivers/acpi/acpi_pcc.c @@ -53,6 +53,7 @@ acpi_pcc_address_space_setup(acpi_handle region_handle, u32 function, struct pcc_data *data; struct acpi_pcc_info *ctx = handler_context; struct pcc_mbox_chan *pcc_chan; + static acpi_status ret; data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) @@ -69,23 +70,35 @@ acpi_pcc_address_space_setup(acpi_handle region_handle, u32 function, if (IS_ERR(data->pcc_chan)) { pr_err("Failed to find PCC channel for subspace %d\n", ctx->subspace_id); - kfree(data); - return AE_NOT_FOUND; + ret = AE_NOT_FOUND; + goto request_channel_fail; } pcc_chan = data->pcc_chan; + if (!pcc_chan->mchan->mbox->txdone_irq) { + pr_err("This channel-%d does not support interrupt.\n", + ctx->subspace_id); + ret = AE_SUPPORT; + goto request_channel_fail; + } data->pcc_comm_addr = acpi_os_ioremap(pcc_chan->shmem_base_addr, pcc_chan->shmem_size); if (!data->pcc_comm_addr) { pr_err("Failed to ioremap PCC comm region mem for %d\n", ctx->subspace_id); - pcc_mbox_free_channel(data->pcc_chan); - kfree(data); - return AE_NO_MEMORY; + ret = AE_NO_MEMORY; + goto ioremap_fail; } *region_context = data; return AE_OK; + +ioremap_fail: + pcc_mbox_free_channel(data->pcc_chan); +request_channel_fail: + kfree(data); + + return ret; } static acpi_status @@ -106,19 +119,17 @@ 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) { - /* - * 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; - } + /* + * 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_chan_txdone(data->pcc_chan->mchan, ret);