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: 13141524 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8A6DC636D4 for ; Wed, 15 Feb 2023 11:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EcfoMp/5hz8B5OXACIoGwdk0XoavqtNeJq2DSSSBk4I=; b=ZI7CbuZQBAAFOw e6AV72e7v91Bg8Y0GMB2wDP6xtirvvRI5EXHdtrFqMDT//17JJZg/wlOI7QTYUuRPWlV9hzMsToKr 8nonTpdaabDKqPY1Stk0eNlXjRkD/yONKT2bIzcR5ZJKky0e6TaqWBmuwyWSAIURffV/odI0VVXSY r4qWDTcULSC+fB1hN/9ek68Wo2L6VC8yfriSwVvyIdg50+YsFHZC+JG8kXliRCU3hvGafMQGrc0kV DeALOewTxpSAIgR3iNHHVOGAn08U2tCzfPedTRx9bZEN8AkXgMjQuYy3OCQNXIV/8YDPLynhosIfR dpC7asw0NCl+vpuJ+wnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSFap-005XQ7-CE; Wed, 15 Feb 2023 11:04:55 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSFaf-005XNC-Lj for linux-arm-kernel@lists.infradead.org; Wed, 15 Feb 2023 11:04:47 +0000 Received: by mail-wr1-x429.google.com with SMTP id h16so18696092wrz.12 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=7meiuo652ChV+qUAzUweBrhjoAZ5wGislI3GOxlFTYQyKiwVj8FFsmAT3GhiyXw9Ga +MLIt3YWgaooJUQ4Kw+4qKD/eTo6EWWh7AtpPGeVzyUA/NVxppsxM9kQHalS5naXFccc JbUTfOxv4bMq/mjyy52mRre6vDrh70JBREVQALD66RVbmgIOJ37h03sfYUjtjx1cVdTu NycsgoXXQM7APZWUtUUAA4uufrHn0ifouZjy8ldelOhSBTbzvZmn01Zum2OJCRniX2ZW y8Pqxzyqlydz1F0ZlRCVdOqIG/N/idXTXcAtaKNvPaaLVjVawcWiTSo4bfoGmaI/tx9P Z9Bw== X-Gm-Message-State: AO0yUKX8SSuXZEPGJwx9MehitcZwqP30QHNySDhjSaqHK5lNA0UXhlwF WVeee5PuMqqZxVwhKlSTwIrBkA== X-Google-Smtp-Source: AK7set/nL9zc6sMzHOD+0vfKrXaroh5awNKeEV4ufdTKmKhF4GzOiZSQSOaHj8kUx9ck/0dNvKe7BQ== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_030445_728734_D15E9840 X-CRM114-Status: GOOD ( 13.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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; }