From patchwork Wed Feb 15 11:04:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 57482 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp127574wrn; Wed, 15 Feb 2023 03:10:04 -0800 (PST) X-Google-Smtp-Source: AK7set+OgXHe/pRDbq3mBgz44+1zig+PcGc9dzeKEyFTLv6raAlDitTdwL9kxn/P1wJmlzRdhnwt X-Received: by 2002:a17:906:b84b:b0:7c9:6e0e:1427 with SMTP id ga11-20020a170906b84b00b007c96e0e1427mr2144176ejb.6.1676459404620; Wed, 15 Feb 2023 03:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676459404; cv=none; d=google.com; s=arc-20160816; b=O3pGohgEVLKOmWjUKN1DXq7fjatNLA0dhR2L+JjTJznBqGtxN5DzPswYG3rCkWvXbL rtTNOQ2vbfcQxtu9WYAIpgGJMiUmoD/wRj9DImrolA7Oj895xGv67Xr3x3mjNMXnMEVs OmmIgd1exMfghCJEsgW8aT8wyk6eV4EskfcixbOrDYJSvZNUIwc8F70EC9UbfUV150wA O0mrQtZbJVfxRR/nUyDzsxPxemsFDN6m+Ws9GOvo8h1TyRBnMJRbfEdAvYv+FimkwMRE tqCiS0n1hyyK5rvkDvOwii45quxweProx8EJ3a39d4BTt0b87pVuKprT2JZUjBWUx+8E f7eQ== 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 :dkim-signature; bh=acqka9R/vT4zXe+0BPN9/ZwtFH80tExv/tQK17XMr2k=; b=kCPHdkw4IIa3mqEiCDnUBIYjLlRawtG3mqtzqe8Vl7c70SAUbzH7BfEvPF7O9MrAGh xeCZs/fUG7vfU0JVZWCAdpLJDxS4sUMMpEB56Nqrh4mosjnyG6HbeUapHW3SkR/3YpRO eUSvokfoTOJyLlsRHzs/8z3z2dwPKmT9wvgzN7X3VkaEG3Bsoam5GO2KL9pIXQTmYJZO BNQwZHWuCK7+64Hso8TUPO0BcaKTDRXKP4SOTMZfOExjpbuZBWpywGg/Y9JYnOsUwXBL 8q48zneDB0SYcbgSWnwWENXqYdV1cGKo156Fp7ZNKTFxnOYcd3ayN6QBThXkGSVI37eY c1QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ci2ObqN3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020a170906109100b008b132b83f62si5330442eju.684.2023.02.15.03.09.41; Wed, 15 Feb 2023 03:10: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; dkim=pass header.i=@linaro.org header.s=google header.b=Ci2ObqN3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbjBOLEv (ORCPT + 99 others); Wed, 15 Feb 2023 06:04:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbjBOLEo (ORCPT ); Wed, 15 Feb 2023 06:04:44 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B52271715 for ; Wed, 15 Feb 2023 03:04:43 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id s13so993152wrw.3 for ; Wed, 15 Feb 2023 03:04:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=acqka9R/vT4zXe+0BPN9/ZwtFH80tExv/tQK17XMr2k=; b=Ci2ObqN3csJOleKlnTMv8t4Gz1Wa5HkgUJGLJGL8sRZsLOhdpGc0pvoq5LAIVXC1Rp Qum3hNrvQm53hkIYBE8CWXF9onkJ3VHfJSgGh/UG1TTvmJZ2ZU7M+fVaO8AJv+XjdIl8 XNS6mdzBTcZxdGffNIoMKtf8710Ph7TZdyU9SlIzdoNWV4myk/fGm9W1DpwpebC9Yvaf cJrwhFXb3laE7/7YOEeB7hHQAiJnFLmtpC5w2M69jyBOGBS9CiNfCIF705AE+cddaG28 dQxhkYsETQABHr25nzFeUIohaqnRgMZDdPKAb+pLdLkjQW3BzobQyKoGqTBbs5EuoOuc zZjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=acqka9R/vT4zXe+0BPN9/ZwtFH80tExv/tQK17XMr2k=; b=4JYuwfpFZ11kVmQDbSd9Lig0LP+i8KBoIiNd3wpkMwFHzz5e6akEGakNUTI/lzzgew skqq7DzVcs0YwvnsrbUdUMvDbjI6Dyjy/ZA628Txd48+vR/hTm+7O/GPDEQu2y9VepOf S8px6sBZhdsMIbRjMAu89EjoaydTiFy5lEZdOFnukXzE7G91UVOqc5VBwSGDmBJISH36 x+L405MVySMgvK9RY5scRGFTDYjeEf7MjLmLZlfRpSPR2a5UynF0K4wJJ0y8mALhII5U +PQgIt1QPIK25NGPQrEyeHEwHSmdhAltDvZdlj/k66eHoA3QslGP2LuSa2fYNESf8mis Z36A== X-Gm-Message-State: AO0yUKX4VuV8hhiAivoBnWfdinlz6iyAzqvH5rAJL6YqPkBoNSKZyT6Q UEiXO04nF29wtcMQAn2fcALiDuIvfOFxB2ns X-Received: by 2002:a5d:65cb:0:b0:2c5:594f:121d with SMTP id e11-20020a5d65cb000000b002c5594f121dmr1401169wrw.12.1676459082018; Wed, 15 Feb 2023 03:04:42 -0800 (PST) Received: from lmecxl1178.lme.st.com (176-165-103-159.abo.bbox.fr. [176.165.103.159]) by smtp.gmail.com with ESMTPSA id h10-20020adfe98a000000b002c5501a5803sm10419916wrm.65.2023.02.15.03.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 03:04:41 -0800 (PST) From: Etienne Carriere To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Jens Wiklander , Sumit Garg , op-tee@lists.trustedfirmware.org, Cristian Marussi , Etienne Carriere Subject: [PATCH v3 2/2] firmware: arm_scmi: optee: use optee system invocation Date: Wed, 15 Feb 2023 12:04:36 +0100 Message-Id: <20230215110436.1454781-2-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230215110436.1454781-1-etienne.carriere@linaro.org> References: <20230215110436.1454781-1-etienne.carriere@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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?1757895096614538744?= X-GMAIL-MSGID: =?utf-8?q?1757895096614538744?= Changes SCMI optee transport to request an OP-TEE system invocation context per SCMI channel. This prevents possible deadlock when many Linux clients invoke OP-TEE are all suspended waiting for an OP-TEE RPC request access an SCMI resource through the SCMI OP-TEE PTA service. Signed-off-by: Etienne Carriere --- Changes since v2: - Fixed syntax issues (missing ';' chars), reported by kernel test robot. Changes since v1: - Updated to use new tee API functions tee_client_request_system_context() and tee_client_release_system_context(). --- drivers/firmware/arm_scmi/optee.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/optee.c b/drivers/firmware/arm_scmi/optee.c index 2a7aeab40e54..28a006348e1c 100644 --- a/drivers/firmware/arm_scmi/optee.c +++ b/drivers/firmware/arm_scmi/optee.c @@ -119,6 +119,7 @@ struct scmi_optee_channel { u32 tee_session; u32 caps; u32 rx_len; + bool sys_thread; struct mutex mu; struct scmi_chan_info *cinfo; union { @@ -432,9 +433,15 @@ static int scmi_optee_chan_setup(struct scmi_chan_info *cinfo, struct device *de channel->channel_id = channel_id; mutex_init(&channel->mu); + ret = tee_client_request_system_context(scmi_optee_private->tee_ctx); + if (ret) + dev_warn(dev, "Couldn't provision an OP-TEE system context\n"); + else + channel->sys_thread = true; + ret = setup_shmem(dev, cinfo, channel); if (ret) - return ret; + goto err_release_sysctx; ret = open_session(scmi_optee_private, &channel->tee_session); if (ret) @@ -458,6 +465,9 @@ static int scmi_optee_chan_setup(struct scmi_chan_info *cinfo, struct device *de err_free_shm: if (channel->tee_shm) tee_shm_free(channel->tee_shm); +err_release_sysctx: + if (channel->sys_thread) + tee_client_release_system_context(scmi_optee_private->tee_ctx); return ret; } @@ -483,6 +493,9 @@ static int scmi_optee_chan_free(int id, void *p, void *data) scmi_free_channel(cinfo, data, id); + if (channel->sys_thread) + tee_client_release_system_context(scmi_optee_private->tee_ctx); + return 0; }