From patchwork Tue Feb 14 15:20:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 13140419 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 BA1A8C05027 for ; Tue, 14 Feb 2023 15:31:29 +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=k9QF9030jArn3U6xClmba+70aP24FxXVx5bykoJUrjA=; b=U0TJpjsaecfiFN F6aZlB5grIx7z5eElBj9kajD31K7JdTp4WFeDi+UdmZPdBh/mQNXFbb+1SlQ0oPlKgYYwS++U63IN WqaQL+BbItTD5dGYHM/YuW3XC3KZKOfnNJcdI7tof7KIidZBw8YrLloKu19l/mOvp0AoIN2JxaTzC uDK9ijTtmIP0GFG52a6QsvAfhLnJ9ejZmsh+WmBI9Oqpbl3HN6rMHuHaT2ZWO/YPLQ14oiT8NR1Pk vTH1Jo0TNP0Bxj21gySuAHY7GTHmb2frQcLAViA37hfo7iiI07K33cJPbXiwx1Vd/70diXaVUpQoB Q6ktQVX82YNWAXKcD5SA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRxG6-002aUo-VP; Tue, 14 Feb 2023 15:30:19 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRxG4-002aDh-0t for linux-arm-kernel@lists.infradead.org; Tue, 14 Feb 2023 15:30:17 +0000 Received: by mail-wr1-x436.google.com with SMTP id m10so7146283wrn.4 for ; Tue, 14 Feb 2023 07:30:12 -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=pZaj9uTvJGoga0iJH/48gNUnrybDI9fdV0k7oGNbvSE=; b=nO83UxELRVQF2lj+JaJMVun78CpOi5C9SnvM9yW0ivcYzX4Xhy16Vpf+YsZOhyojjd ZYWf7n9uXo4zM4DFCh5ZaYFTo6NBFPbmCaQAcBTe1O8NolN42m71efRl0LuMhmP14ra4 sY7DLtHExGbdzny9s9AQd6Y77ZFtYq8EDwJ5BB2jIDGL+bPhEr05Nq7cf2hjCAeVPu6d HCulzo7u+DTqOnt61r/kJb4FWneK60On/h42TpN/YDgqGk/xj0EgGJtGHGc+meeGfH3y 0at/RNbazjz5gvrgeWap+is1ShmqyxThDCvA67Jt3+nGqh/VG2qO1OYnntEhzUTFIgBk lkpg== 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=pZaj9uTvJGoga0iJH/48gNUnrybDI9fdV0k7oGNbvSE=; b=BInCIjNPUJwtAbQHBRlvLpNCe2rzjCcySkHJgNZwyCT+DJKZO97PfH8XdmfNaYqJwx ovrrQAWVVEUSsC1Dqpphnpv/u3G3EbzVcUNqLaHlhe/WGHwxQCkh9s5/ZzM0uVduSSLY DWUqy/g2eBgVPN3l1rmmDi4xoNsLpcRl7jTrT8zvUOtAha5hRtRu4I6W1yFgvAORpPwe Dru5hrNXSzg8OsDbNm7fDXOAoEvyDgACHyKh+5r/Leb8djZwihroy+INAS5l8eDA4kbw WrEA+nSOETnV1QAfIm5NUgdJeZHwd9XSCRlF0q/0aKcLjs9BEqK33MahCLQ1oR6S+WGp APSQ== X-Gm-Message-State: AO0yUKUoH/7/2IQYv4zB3TYk2WxdIPNhBw8oYFjiG6DQudKnsQfbe2Xv BXUYdi5hG5cElpmJVlfnuaq0Aw== X-Google-Smtp-Source: AK7set92kZLDRXgdUSfTasq0IR59Q8GBXr8dP8A5HltZe2YJ6SPVXK01up77huc+bLMAMOHhgPUldA== X-Received: by 2002:adf:dfcd:0:b0:2c3:f0ed:4beb with SMTP id q13-20020adfdfcd000000b002c3f0ed4bebmr2533044wrn.70.1676388611571; Tue, 14 Feb 2023 07:30:11 -0800 (PST) Received: from lmecxl1178.lme.st.com ([80.214.29.100]) by smtp.gmail.com with ESMTPSA id a4-20020adfeec4000000b002bfc0558ecdsm13224166wrp.113.2023.02.14.07.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 07:30:11 -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 v2 2/2] firmware: arm_scmi: optee: use optee system invocation Date: Tue, 14 Feb 2023 16:20:47 +0100 Message-Id: <20230214152047.1143106-2-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230214152047.1143106-1-etienne.carriere@linaro.org> References: <20230214152047.1143106-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-20230214_073016_079948_2602D253 X-CRM114-Status: GOOD ( 13.14 ) 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 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..fe91e2de3f9c 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; }