From patchwork Mon Sep 11 19:43:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikunj Kela X-Patchwork-Id: 722225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7549CA0ECF for ; Mon, 11 Sep 2023 21:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344527AbjIKVOV (ORCPT ); Mon, 11 Sep 2023 17:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244234AbjIKToe (ORCPT ); Mon, 11 Sep 2023 15:44:34 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0459193; Mon, 11 Sep 2023 12:44:29 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38BItcaL010300; Mon, 11 Sep 2023 19:44:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=dXwgTS0Ny2g6neMSgxKdQVcCV0LjZUdNUt2cZfL22BE=; b=VqyYXp8ScPWdHqxOz7JvPyR9IH3PzQ0i1qzpGzwtPt6qjFf/y6ZCO20NUuv4xW8aSCD7 eI0Yle6CEWsvMTcGoC45tjx+gWee4GExiSNPdju5Rq0NNqa+7v7reM5Ri0gw6JrPHm0X noGpWoolFv7udF1s/pJKZnQNFGtUs6lSnEpJMQxq+E9XHra5kPkbw2XXG6WL6VG42wmN kydjSpfEaxxkzvLU2/kUdBCMHVDTdmLc/M4zTSXlqKq1wfDSXJczBGf26PexDGTqLWhP oDfi804rVDQdmwEy/lnVkBVACwPjjO3i+1oYl1C3zf294X8kMr36yhyONWbqnsrsBVEW lQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t25yx0hjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Sep 2023 19:44:21 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38BJiKEb017325 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Sep 2023 19:44:20 GMT Received: from car-linux11.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 11 Sep 2023 12:44:19 -0700 From: Nikunj Kela To: CC: , , , , , , , , , , Nikunj Kela Subject: [PATCH v4 1/4] firmware: arm_scmi: Add polling support for completion in smc Date: Mon, 11 Sep 2023 12:43:56 -0700 Message-ID: <20230911194359.27547-2-quic_nkela@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230911194359.27547-1-quic_nkela@quicinc.com> References: <20230718160833.36397-1-quic_nkela@quicinc.com> <20230911194359.27547-1-quic_nkela@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: lrtdTWT63XNV9I3c9CssayZBTRrk_Q3r X-Proofpoint-GUID: lrtdTWT63XNV9I3c9CssayZBTRrk_Q3r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-11_15,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309110180 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Currently, the return from the smc call assumes the completion of the scmi request. However this may not be true in virtual platforms that are using hvc doorbell. This change adds a Kconfig to enable the polling for the request completion. Signed-off-by: Nikunj Kela --- drivers/firmware/arm_scmi/Kconfig | 14 ++++++++++++++ drivers/firmware/arm_scmi/smc.c | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig index ea0f5083ac47..771d60f8319f 100644 --- a/drivers/firmware/arm_scmi/Kconfig +++ b/drivers/firmware/arm_scmi/Kconfig @@ -125,6 +125,20 @@ config ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE in atomic context too, at the price of using a number of busy-waiting primitives all over instead. If unsure say N. +config ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION + bool "Enable polling support for SCMI SMC transport" + depends on ARM_SCMI_TRANSPORT_SMC + help + Enable completion polling support for SCMI SMC based transport. + + If you want the SCMI SMC based transport to poll for the completion, + answer Y. + Enabling completion polling might be desired in the absence of the a2p + irq when the return from smc/hvc call doesn't indicate the completion + of the SCMI requests. This might be useful for instances used in + virtual platforms. + If unsure say N. + config ARM_SCMI_TRANSPORT_VIRTIO bool "SCMI transport based on VirtIO" depends on VIRTIO=y || VIRTIO=ARM_SCMI_PROTOCOL diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c index c193516a254d..0a0b7e401159 100644 --- a/drivers/firmware/arm_scmi/smc.c +++ b/drivers/firmware/arm_scmi/smc.c @@ -250,6 +250,16 @@ static void smc_mark_txdone(struct scmi_chan_info *cinfo, int ret, smc_channel_lock_release(scmi_info); } +#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION +static bool +smc_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer) +{ + struct scmi_smc *scmi_info = cinfo->transport_info; + + return shmem_poll_done(scmi_info->shmem, xfer); +} +#endif + static const struct scmi_transport_ops scmi_smc_ops = { .chan_available = smc_chan_available, .chan_setup = smc_chan_setup, @@ -257,6 +267,9 @@ static const struct scmi_transport_ops scmi_smc_ops = { .send_message = smc_send_message, .mark_txdone = smc_mark_txdone, .fetch_response = smc_fetch_response, +#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION + .poll_done = smc_poll_done, +#endif }; const struct scmi_desc scmi_smc_desc = { @@ -272,6 +285,6 @@ const struct scmi_desc scmi_smc_desc = { * for the issued command will be immmediately ready to be fetched * from the shared memory area. */ - .sync_cmds_completed_on_ret = true, + .sync_cmds_completed_on_ret = !IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION), .atomic_enabled = IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE), }; From patchwork Mon Sep 11 19:43:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikunj Kela X-Patchwork-Id: 721531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B44CCA0EC4 for ; Mon, 11 Sep 2023 21:19:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344040AbjIKVNH (ORCPT ); Mon, 11 Sep 2023 17:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244236AbjIKTog (ORCPT ); Mon, 11 Sep 2023 15:44:36 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ADC918D; Mon, 11 Sep 2023 12:44:31 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38BHilZZ017083; Mon, 11 Sep 2023 19:44:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=mi+xMMZfbqMADnJGJ0QFgmIXamVRysXxN19hN2cy6go=; b=g5pa3v7lyh84KXopfAjb3HmrdogYrWk9HbY3Kn9GBcFBBY3znSeun5rOZHFpyBS/pXhr pCGvfSEeMmtXnzwgrtlEsH1bsuOI+0GBS5zFmz8pMKJxbGRr7FxWfO8TV4h+uX1Z94TS 5hDiE2fSKoO24gL7c1o8HuRX7tJztv1wd2m3Ftf/NdOBDejwFSmYd5HwpribxeuIG0mL G5WnoD949kfRJtOslF6XT/pxjha8yO7I0Rrzq2gGe6dfhNyKJCruiJbs8oDQASfnzO96 16k7kF9hCSELN5a3iT0h1pHgg6MUmf9k9JcsouauLpoPvR/JDkfWIkbpMBlg2x+lL3zq mg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t20yy18eh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Sep 2023 19:44:23 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38BJiMZs015309 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Sep 2023 19:44:22 GMT Received: from car-linux11.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 11 Sep 2023 12:44:21 -0700 From: Nikunj Kela To: CC: , , , , , , , , , , Nikunj Kela Subject: [PATCH v4 2/4] dt-bindings: arm: convert nested if-else construct to allOf Date: Mon, 11 Sep 2023 12:43:57 -0700 Message-ID: <20230911194359.27547-3-quic_nkela@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230911194359.27547-1-quic_nkela@quicinc.com> References: <20230718160833.36397-1-quic_nkela@quicinc.com> <20230911194359.27547-1-quic_nkela@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: gK5mL4YjAYKfgFLs6p9j8mCfnrvkyiCk X-Proofpoint-GUID: gK5mL4YjAYKfgFLs6p9j8mCfnrvkyiCk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-11_15,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 clxscore=1015 spamscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309110181 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Nested if-else construct is not scalable therefore, convert it to allOf:if-else. Signed-off-by: Nikunj Kela Suggested-by: Krzysztof Kozlowski Reviewed-by: Krzysztof Kozlowski --- .../bindings/firmware/arm,scmi.yaml | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml index b138f3d23df8..8d54ea768d38 100644 --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml @@ -284,35 +284,34 @@ $defs: required: - compatible -if: - properties: - compatible: - contains: - const: arm,scmi -then: - properties: - interrupts: false - interrupt-names: false - - required: - - mboxes - - shmem - -else: - if: - properties: - compatible: - contains: - enum: - - arm,scmi-smc - - arm,scmi-smc-param - then: - required: - - arm,smc-id - - shmem +allOf: + - if: + properties: + compatible: + contains: + const: arm,scmi + then: + properties: + interrupts: false + interrupt-names: false + + required: + - mboxes + - shmem + + - if: + properties: + compatible: + contains: + enum: + - arm,scmi-smc + - arm,scmi-smc-param + then: + required: + - arm,smc-id + - shmem - else: - if: + - if: properties: compatible: contains: From patchwork Mon Sep 11 19:43:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikunj Kela X-Patchwork-Id: 722233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 934E3CA0EC9 for ; Mon, 11 Sep 2023 21:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344821AbjIKVOu (ORCPT ); Mon, 11 Sep 2023 17:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244237AbjIKToi (ORCPT ); Mon, 11 Sep 2023 15:44:38 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D86918D; Mon, 11 Sep 2023 12:44:34 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38BJSpZs016187; Mon, 11 Sep 2023 19:44:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=kxo6YzH9eE3FtnDbczOy69opAxVkAeFdpBT9zrHMX8k=; b=VVCD2qLS2EaiPntJh/5eoW52dbhaFAmU0KtPa7ufTQQ6yvhMqfsdlqxTsk6m0knt+vdC nsBc8P5kg3fED/U2UV36oue6of0IG5L4DuaAFGpqj1g80dB2xHWZGwKT3UpcZVCr6ytb zti1GbB5Ur77ZxNpnL3tr53XTex21ItFZMWUYzXOVncPzL5UDwhtFrg+JQ0GYtRG/BZ4 cWirOatNBuDNUNN2lPyYbtQ58NSv/sCxobp26L5qLeCVT7saKtbhYYA7rEVvf0IptMuC 6jAytRFwuCEwuDq1NZE3AQrxnS3NMacXWcf2boApmwtmkZIAMMLtkAxr7LMjMBNt46Ev 7Q== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t25yx0hjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Sep 2023 19:44:26 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38BJiPUh022547 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Sep 2023 19:44:25 GMT Received: from car-linux11.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 11 Sep 2023 12:44:24 -0700 From: Nikunj Kela To: CC: , , , , , , , , , , Nikunj Kela Subject: [PATCH v4 3/4] dt-bindings: arm: Add new compatible for smc/hvc transport for SCMI Date: Mon, 11 Sep 2023 12:43:58 -0700 Message-ID: <20230911194359.27547-4-quic_nkela@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230911194359.27547-1-quic_nkela@quicinc.com> References: <20230718160833.36397-1-quic_nkela@quicinc.com> <20230911194359.27547-1-quic_nkela@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: qF5iy2JemLgJWWScj9h8d_OVYnJgXrbw X-Proofpoint-GUID: qF5iy2JemLgJWWScj9h8d_OVYnJgXrbw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-11_15,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309110180 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Introduce compatible "qcom,scmi-hvc-shmem" for SCMI smc/hvc transport channel for Qualcomm virtual platforms. The compatible mandates a shared memory channel. Signed-off-by: Nikunj Kela Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/firmware/arm,scmi.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml index 8d54ea768d38..4090240f45b1 100644 --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml @@ -45,6 +45,9 @@ properties: - description: SCMI compliant firmware with OP-TEE transport items: - const: linaro,scmi-optee + - description: SCMI compliant firmware with Qualcomm hvc/shmem transport + items: + - const: qcom,scmi-hvc-shmem interrupts: description: @@ -320,6 +323,15 @@ allOf: required: - linaro,optee-channel-id + - if: + properties: + compatible: + contains: + const: qcom,scmi-hvc-shmem + then: + required: + - shmem + examples: - | firmware { From patchwork Mon Sep 11 19:43:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikunj Kela X-Patchwork-Id: 721519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7D98CA0EC3 for ; Mon, 11 Sep 2023 21:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344426AbjIKVOF (ORCPT ); Mon, 11 Sep 2023 17:14:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244240AbjIKTom (ORCPT ); Mon, 11 Sep 2023 15:44:42 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0F3018D; Mon, 11 Sep 2023 12:44:37 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38BFumkc012994; Mon, 11 Sep 2023 19:44:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=mgi3HTFjixu9MZpChz8Nvq4m/bMxQQbtlB2jCrztIyo=; b=j5nQZ8nqVmdsJwiShQBDI2T2RS/xm3MJkfDl3YVEWFxVqNmA0WV2SE7XuCHDpRLH9+g4 6bcRtVyzB4NYGwLy3JhzXxS9hpC9HXh7Z+Ut+iGpEEqLxj3m2b4HnYvf3GhHl2rvX8Sj OTPIehKpoXod7aDgQgdmmSubP98wzqfqe76El42A+tUPhxph8oKk9MXLu6TRerKS0zES 8fOZiBT0dFhN+XaTpKSnxy8FKj4Tq6Z2snlwR6VnzJG6LRQA2lFPCHwMQr7yU1vuSzxO xtriTQ7WB6CHrF9741fS/wl9Z7EioGawWvehL/9oLiTrgMxoRhgHrbjBYaeLSPw2hFlv Ig== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t25yx0hk2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Sep 2023 19:44:29 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38BJiS9s015364 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Sep 2023 19:44:28 GMT Received: from car-linux11.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Mon, 11 Sep 2023 12:44:28 -0700 From: Nikunj Kela To: CC: , , , , , , , , , , Nikunj Kela Subject: [PATCH v4 4/4] firmware: arm_scmi: Add qcom hvc/shmem transport support Date: Mon, 11 Sep 2023 12:43:59 -0700 Message-ID: <20230911194359.27547-5-quic_nkela@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230911194359.27547-1-quic_nkela@quicinc.com> References: <20230718160833.36397-1-quic_nkela@quicinc.com> <20230911194359.27547-1-quic_nkela@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: cWCo3C-4s9oE985TCAboIMaTT-9qrCzp X-Proofpoint-GUID: cWCo3C-4s9oE985TCAboIMaTT-9qrCzp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-11_15,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 adultscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309110180 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This change adds the support for SCMI message exchange on Qualcomm virtual platforms. The hypervisor associates an object-id also known as capability-id with each hvc doorbell object. The capability-id is used to identify the doorbell from the VM's capability namespace, similar to a file-descriptor. The hypervisor, in addition to the function-id, expects the capability-id to be passed in x1 register when HVC call is invoked. The function-id & capability-id are allocated by the hypervisor on bootup and are stored in the shmem region by the firmware before starting Linux. Signed-off-by: Nikunj Kela --- drivers/firmware/arm_scmi/driver.c | 1 + drivers/firmware/arm_scmi/smc.c | 47 ++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 87383c05424b..ea344bc6ae49 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = { #ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc}, { .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc}, + { .compatible = "qcom,scmi-hvc-shmem", .data = &scmi_smc_desc}, #endif #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc}, diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c index 0a0b7e401159..94ec07fdc14a 100644 --- a/drivers/firmware/arm_scmi/smc.c +++ b/drivers/firmware/arm_scmi/smc.c @@ -50,6 +50,9 @@ * @func_id: smc/hvc call function id * @param_page: 4K page number of the shmem channel * @param_offset: Offset within the 4K page of the shmem channel + * @cap_id: hvc doorbell's capability id to be used on Qualcomm virtual + * platforms + * @qcom_xport: Flag to indicate the transport on Qualcomm virtual platforms */ struct scmi_smc { @@ -63,6 +66,8 @@ struct scmi_smc { u32 func_id; u32 param_page; u32 param_offset; + u64 cap_id; + bool qcom_xport; }; static irqreturn_t smc_msg_done_isr(int irq, void *data) @@ -129,6 +134,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, struct resource res; struct device_node *np; u32 func_id; + u64 cap_id; int ret; if (!tx) @@ -158,9 +164,34 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, return -EADDRNOTAVAIL; } - ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id); - if (ret < 0) - return ret; + if (of_device_is_compatible(dev->of_node, "qcom,scmi-hvc-shmem")) { + scmi_info->qcom_xport = true; + + /* The func-id & capability-id are kept in last 16 bytes of shmem. + * +-------+ + * | | + * | shmem | + * | | + * | | + * +-------+ <-- (size - 16) + * | funcId| + * +-------+ <-- (size - 8) + * | capId | + * +-------+ <-- size + */ + + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16); +#ifdef CONFIG_ARM64 + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8); +#else + /* capability-id is 32 bit wide on 32bit machines */ + cap_id = readl((void __iomem *)(scmi_info->shmem) + size - 8); +#endif + } else { + ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id); + if (ret < 0) + return ret; + } if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) { scmi_info->param_page = SHMEM_PAGE(res.start); @@ -184,6 +215,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, } scmi_info->func_id = func_id; + scmi_info->cap_id = cap_id; scmi_info->cinfo = cinfo; smc_channel_lock_init(scmi_info); cinfo->transport_info = scmi_info; @@ -213,6 +245,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo, struct arm_smccc_res res; unsigned long page = scmi_info->param_page; unsigned long offset = scmi_info->param_offset; + unsigned long cap_id = (unsigned long)scmi_info->cap_id; /* * Channel will be released only once response has been @@ -222,8 +255,12 @@ static int smc_send_message(struct scmi_chan_info *cinfo, shmem_tx_prepare(scmi_info->shmem, xfer, cinfo); - arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0, - &res); + if (scmi_info->qcom_xport) + arm_smccc_1_1_hvc(scmi_info->func_id, cap_id, 0, 0, 0, 0, 0, 0, + &res); + else + arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, + 0, 0, &res); /* Only SMCCC_RET_NOT_SUPPORTED is valid error code */ if (res.a0) {