From patchwork Thu Nov 10 01:50:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huisong Li X-Patchwork-Id: 17903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp670240wru; Wed, 9 Nov 2022 17:55:11 -0800 (PST) X-Google-Smtp-Source: AMsMyM6wbOHCeM+d9d8ZqqeAwW69jHLGBG1N9y38A2h8B9jblWFVnSS/orEWkTRn3M8H7Muq1APX X-Received: by 2002:a17:907:1b1f:b0:72f:56db:cce9 with SMTP id mp31-20020a1709071b1f00b0072f56dbcce9mr56889765ejc.605.1668045311296; Wed, 09 Nov 2022 17:55:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045311; cv=none; d=google.com; s=arc-20160816; b=uYKLkqMg0bwUEUI8xoadnHb54UDjrhflnHPkAu79LwoGJZGezEHvBmgx8sssiHyeo1 R4qxD2Vx5z1FFSBazyYvRJ2PqA8O3cbvKx5UoOtj/tIfb4luKu3lqWzWiRlI8+iFIXDz kv2lp8PA8/ZFG5IxvHgxuMP/RkB4KwKoc0WY6L6cV4OSmUiXqatey6wGKmZwvwFr2rsJ aV7gf7MAp79zU8FzxomqK10RweMwnDLyIMSyQEAsawSPpyZ1XBXq54GdGow0JGUbLfpJ qsi34D8Nv4gEfXuXJXbrIl7ymMHfrxLfky/ld5PYZ70P/bJ67HSj+0yuMTurI9149qAs j3Ag== 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=tDE2QwQVAu+A8jsdIDenhVHvQZ14jKqmHFyR6TkCK38=; b=BLCbNGJS1RFFXaYcoXBv8XV8wucuZi1LMsVBP2iXrtR9hJH14DehZT9171TNmfNT8+ kKbNZUh1v40//uPceTBx7AIDQhlv6GU44S2d7oqEkSojAmg0yH5Rd/48mT2Z1a/SbJQZ QByO7l+6X+aobNsevwxMIEj3zuyPI7y0Whi8he5JGKQ0oHPpHqnr4O7Vp4U1jQ87YKTI 0t4nbGFgdu0N49E8pmw7QddqqPobcRaGN8rV9xJr2Zk4G9FPaBiwGm2z7IzqDQKvFB+R FRXptuaFAVeA9+l0sGG1K6e1/qPUyjy5LQBLH80xf1GibxMmeFu8fbW4imgN3OtsaGio ItkQ== 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 du10-20020a17090772ca00b0078c6a12ff3dsi18372005ejc.215.2022.11.09.17.54.48; Wed, 09 Nov 2022 17:55:11 -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 S232306AbiKJBw4 (ORCPT + 99 others); Wed, 9 Nov 2022 20:52:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231830AbiKJBwu (ORCPT ); Wed, 9 Nov 2022 20:52:50 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35B4AB497; Wed, 9 Nov 2022 17:52:49 -0800 (PST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N74WQ34YlzpWKF; Thu, 10 Nov 2022 09:49:06 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 10 Nov 2022 09:52:47 +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; Thu, 10 Nov 2022 09:52:46 +0800 From: Huisong Li To: , CC: , , , , , , , , , , , Subject: [PATCH 1/3] mailbox: pcc: rename platform interrupt bit macro name Date: Thu, 10 Nov 2022 09:50:32 +0800 Message-ID: <20221110015034.7943-2-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20221110015034.7943-1-lihuisong@huawei.com> References: <20221110015034.7943-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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?1749072280261019973?= X-GMAIL-MSGID: =?utf-8?q?1749072280261019973?= Currently, the name of platform interrupt bit macro, ACPI_PCCT_DOORBELL, is not very appropriate. The doorbell is generally considered as an action when send mailbox data. Actually, the macro value comes from Platform Interrupt in Platform Communications Channel Global Flags. If the bit is '1', it means that the platform is capable of generating an interrupt to indicate completion of a command. Signed-off-by: Huisong Li --- drivers/mailbox/pcc.c | 2 +- include/acpi/actbl2.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 3c2bc0ca454c..7cee37dd3b73 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -665,7 +665,7 @@ static int pcc_mbox_probe(struct platform_device *pdev) (unsigned long) pcct_tbl + sizeof(struct acpi_table_pcct)); acpi_pcct_tbl = (struct acpi_table_pcct *) pcct_tbl; - if (acpi_pcct_tbl->flags & ACPI_PCCT_DOORBELL) + if (acpi_pcct_tbl->flags & BIT(ACPI_PCCT_FLAGS_PLAT_INTERRUPT_B)) pcc_mbox_ctrl->txdone_irq = true; for (i = 0; i < count; i++) { diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index 655102bc6d14..3840507fdc79 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -1810,7 +1810,7 @@ struct acpi_table_pcct { /* Values for Flags field above */ -#define ACPI_PCCT_DOORBELL 1 +#define ACPI_PCCT_FLAGS_PLAT_INTERRUPT_B 1 /* Values for subtable type in struct acpi_subtable_header */ From patchwork Thu Nov 10 01:50:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huisong Li X-Patchwork-Id: 17910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp670490wru; Wed, 9 Nov 2022 17:56:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf7sXLWYxb1GWokQg+itFfcYb5tsYDzk73CzcZyFgqHTzGDCRHr9/evscBoZrO7u1r9R9tpE X-Received: by 2002:a65:6556:0:b0:470:5b0c:1de2 with SMTP id a22-20020a656556000000b004705b0c1de2mr19783915pgw.286.1668045364872; Wed, 09 Nov 2022 17:56:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045364; cv=none; d=google.com; s=arc-20160816; b=rGwEz1e5i0E4GknRwSTIvWorMRoccDzGMMI0M+7mucB1WvPkEYpyb6pYXFF417xUZX AK1fNzSMkxKlk0QiPV9U8dAca5gBjZPpZd9QoRfZ79FgPSWlHa/w0DV6K4kLjFcZcL13 x3Pu1TQp+pRGSPwvuEq+MCQOU5fjyOS+TYp86Jl4b4wFpMk5HfakQo8s1kggf9N4P0l5 jCSNsH/CEkD/9eQTGiOUwasv9tBCJUzvBMSKPqFi0DtUTbqKdXhEKwro3Ney0KrKY0Ah WDePLt0nN9dxMGJGLNhuBXJznOBA5lXW46+s3b8wOIBuXB47EnnG+joCNEvxD6q6uzVa wMOA== 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=HKuz4bqofEwvNB02z7kpLMTfnVsWCfUHomnANZiFkBA=; b=lbgUDHVjnuOWq7tV6p6/IL7RzXD6GxBV73/vpd/UIN0bERhfXUaZ0wXcgbNapR9nnV nV19mBMQai0BBoTGnGto7M2j+rU7oMtnCdL33Bcn1YbjvA+sqsmzuSH+oHIJxsgJa1su Bw2fUdFbw88ZomAO0GDyDVyR8k7zGa7bbXKFAqlVwPlT1s9GOVJtf8LrGnEik0/sFzOA POHm55/bBTC/WXLEHxpQDFxvf8+++W5gs2ABatrS14jkBiG+0Z29T1cYZmF1VjMb41aR 2neGVaTb3DU7su7h+HdbaHHewlLBcJ+O5fQUuY64KbP3uY1jgh4FpGwkCMM8bgjQMp/1 ZGlg== 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 c8-20020a63d148000000b004619662fb00si5950568pgj.245.2022.11.09.17.55.51; Wed, 09 Nov 2022 17:56:04 -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 S229556AbiKJBxE (ORCPT + 99 others); Wed, 9 Nov 2022 20:53:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232093AbiKJBwu (ORCPT ); Wed, 9 Nov 2022 20:52:50 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4223BC1D; Wed, 9 Nov 2022 17:52:49 -0800 (PST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N74WQ6lFczpWLN; Thu, 10 Nov 2022 09:49:06 +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; Thu, 10 Nov 2022 09:52:48 +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; Thu, 10 Nov 2022 09:52:47 +0800 From: Huisong Li To: , CC: , , , , , , , , , , , Subject: [PATCH 2/3] ACPI: PCC: add check for platform interrupt Date: Thu, 10 Nov 2022 09:50:33 +0800 Message-ID: <20221110015034.7943-3-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20221110015034.7943-1-lihuisong@huawei.com> References: <20221110015034.7943-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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?1749072336852972996?= 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 --- 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); From patchwork Thu Nov 10 01:50:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huisong Li X-Patchwork-Id: 17904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp670242wru; Wed, 9 Nov 2022 17:55:12 -0800 (PST) X-Google-Smtp-Source: AMsMyM7DuXdxKmVo7IakxFmEnF+YeAjvoQo+Is65T1PDjIsSy3UXdilPwzPqyvGdcW5q1E4iQZGv X-Received: by 2002:a17:906:65c6:b0:73c:8897:65b0 with SMTP id z6-20020a17090665c600b0073c889765b0mr58844383ejn.322.1668045311864; Wed, 09 Nov 2022 17:55:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045311; cv=none; d=google.com; s=arc-20160816; b=RF6S7RG93Fgpmv5+v/sIgYcnr907TP68VA8iWs9I27wY3gDxA+6AhVbmu87egYdumd p1Ztgtl6tatRUc7zx3DdObO+EQDlR+cgfS7IKBo88ocyiJGR+iM2/oFD4yFjbs0XrGRu K5/dB+egq7jintoqEi5P4GazbvUfUmErBiMo//0AS3VcH9Kn3zsdDR0dNt10QrrFxCUw cFMQ7BlMXjAVwbQ0rSP31Kp9ETHhqwHmwJ7SgEA5rdRF9z/qmctKzR8Ya5oL9MpXZDrK bnUwuXCIrBlXjGaKiRaOc/xbCwTK/okKtk6NFWzUC63S1ulpEgu88tiShE2N1rdMQxN8 PBpw== 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=K0XdXqbqnX07GQiyNVYevlvuJHQS/aEz3KuFo5AcalU=; b=KET2Ud3Ra1rba/yF3ymrOO/foRPmQ/i6ukgUcppbNtFN0dw/uekVaUxvPRQtJRdUfg by76KKCx1eJEKe2hmRGLslcK8c3bBeaOR33yyQGdWX2GVyxWPzHfDydcC2zW/yilS8LS FMerw2y2riKOQmgsW6L5qBeIFdrVUcGPI0i0MaFqqmHmgc5QboLuPAzRzgSQ0d6KlgOR VYrqLixg4wemO32fitJEnSbk7jdWVc8x3rUdep9wVxnKsfN3SYuc3/ue2BnIAnQAEX8w OWaNO7+fWpOWHeAlH936YrnFbOfjnd+vnz5KIU7KVzNYSPpuFmCOMM2ssYbq6bsFhjtd 7MkA== 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 f12-20020a17090660cc00b007ad855bc09csi13636580ejk.595.2022.11.09.17.54.48; Wed, 09 Nov 2022 17:55:11 -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 S232322AbiKJBw7 (ORCPT + 99 others); Wed, 9 Nov 2022 20:52:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232142AbiKJBwu (ORCPT ); Wed, 9 Nov 2022 20:52:50 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 136ADBC85; Wed, 9 Nov 2022 17:52:50 -0800 (PST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N74XB2WGqzJnZL; Thu, 10 Nov 2022 09:49:46 +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; Thu, 10 Nov 2022 09:52:48 +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; Thu, 10 Nov 2022 09:52:47 +0800 From: Huisong Li To: , CC: , , , , , , , , , , , Subject: [PATCH 3/3] mailbox: pcc: fix 'pcc_chan_count' when fail to initialize PCC Date: Thu, 10 Nov 2022 09:50:34 +0800 Message-ID: <20221110015034.7943-4-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20221110015034.7943-1-lihuisong@huawei.com> References: <20221110015034.7943-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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?1749072280682433464?= X-GMAIL-MSGID: =?utf-8?q?1749072280682433464?= Currently, 'pcc_chan_count' is a non-zero value if PCC subspaces are parsed successfully and subsequent processes is failure during initializing PCC process. This may cause that pcc_mbox_request_channel() can still be executed successfully , which will misleads the caller that this channel is available. Fixes: ce028702ddbc ("mailbox: pcc: Move bulk of PCCT parsing into pcc_mbox_probe") Signed-off-by: Huisong Li --- drivers/mailbox/pcc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 7cee37dd3b73..47d70c5884e3 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -294,6 +294,7 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) pr_err("Channel not found for idx: %d\n", subspace_id); return ERR_PTR(-EBUSY); } + dev = chan->mbox->dev; spin_lock_irqsave(&chan->lock, flags); @@ -735,7 +736,8 @@ static int __init pcc_init(void) if (ret) { pr_debug("ACPI PCC probe failed.\n"); - return -ENODEV; + ret = -ENODEV; + goto out; } pcc_pdev = platform_create_bundle(&pcc_mbox_driver, @@ -743,10 +745,13 @@ static int __init pcc_init(void) if (IS_ERR(pcc_pdev)) { pr_debug("Err creating PCC platform bundle\n"); - return PTR_ERR(pcc_pdev); + ret = PTR_ERR(pcc_pdev); + goto out; } - return 0; +out: + pcc_chan_count = 0; + return ret; } /*