From patchwork Wed Feb 15 17:02:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 57635 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp305572wrn; Wed, 15 Feb 2023 09:04:45 -0800 (PST) X-Google-Smtp-Source: AK7set/qVOUBzt/FzFbUXjXymMD8ZKyEUz/LlCmf4KhTCxusJY2I6cT7vOt2HU9+EfE7A8YkoICa X-Received: by 2002:a17:907:a810:b0:88d:f759:15ae with SMTP id vo16-20020a170907a81000b0088df75915aemr3484438ejc.42.1676480685702; Wed, 15 Feb 2023 09:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676480685; cv=none; d=google.com; s=arc-20160816; b=bJfK7A9+fcOv+qoziZav60aYb/K52+0zRQJRXJmVt8lKj7CUwreW+UDpNoXTBKHEvK tpIxjg8x3tp/VEYxcm7r0+Si+5xlTJ9StR1XlJkSovUFISKeTFEt1kFtcigclDgu4NgV 6q2fvVMd7nhp/oCS8s6+OGXhwZ0YhddtfG0gQQrR6jc4MySAVbnvJL+Ygku3ZNPPbb+B wrg/dnYrhr+U8lZLVcSmEV4OTbqmAG3EKwapf0kk+UrFec9Z5IV9mGWeiYcG+RLQ/R0b 4Pl27hFIPgpPsRb3J5KjztcIR/cPLuiZJqIAawb76LP7VXqlDLQlJOV9a4sn44DmUXhc wUHQ== 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=WiZADvWOmxCdPIUazfbuTYmfEz/1yOYWessMhqvHszk=; b=eebt/7qGV86EQ7FbvxuZPpZpP2iBGhmoFQj83MQZ1C/QnyelZ3uXRXu0KGv05Lx6oC D8hmcUX9RfiHO7VtL560/jwLp0mGG72soQmieWnJ6t4Yu2K6SW8cKB3R8yU9bmFHm70C wKGptko22OdKAVRkrA3hQRASri6ugkaLQ24yr6S8Bxlku9va26qSGQqbgALViCvUaDaG p3SdIVQ7yR4hPk3Zj9UKiPHBeoHCo7OHdt3dwFM2iGbTlkrGUd1ihGmHahn/39Zem5Uf +MUlX3u7lwKNY8AYaNGp0n9RIa1ob6dz1M3puYprdlPNOpYUUt6YL+hNT+z9gAAblkIM i0Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dNPM7pL8; 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 z6-20020a17090674c600b008879a229030si24102397ejl.292.2023.02.15.09.04.21; Wed, 15 Feb 2023 09:04:45 -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=dNPM7pL8; 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 S229973AbjBORCy (ORCPT + 99 others); Wed, 15 Feb 2023 12:02:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbjBORCv (ORCPT ); Wed, 15 Feb 2023 12:02:51 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C2638A60 for ; Wed, 15 Feb 2023 09:02:48 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id f18-20020a7bcd12000000b003e206711347so1079911wmj.0 for ; Wed, 15 Feb 2023 09:02:48 -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=WiZADvWOmxCdPIUazfbuTYmfEz/1yOYWessMhqvHszk=; b=dNPM7pL8rUSgc2jImPNKjwMXskjKNPF92j+W7BvGiWNoCyqXMGJjeiJnsFASxSbw1x BdyBuBGuRhFCwAhQAqSZXbBE1sGpoHhlHQftxTw6iS2SG+QJ67KbSVywRG5zyZ6vlLvC h90CUmLnQF0kfM7LVwSlkL6X2yMtSG9T4rQSb4HIFhJK6svycNoFF5SsCZSlvdg38TnM xCBBzCckeLLK9WdbleYwoSGRErxGb9FpVB0CWIdvavHjxvQVLJ4ErHW6TjcHoMR/WNpr 16aZ6SqqlJhyOjK6TPHHzSZJ8ZRJUYHvK7fVSThJd0NR08URygAYQuAoExueg5M3XIhD dJvQ== 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=WiZADvWOmxCdPIUazfbuTYmfEz/1yOYWessMhqvHszk=; b=u1uJVBaep4coEGLIRmmPpcXNwA34aFX6TqMwmSZMYhO7Lf0SMlCihtZHOBkE8KjWRo IEOTQQVXjrqaeAqN74aiiJSskmONvRtuefY3AJTI8nwT9qbtc/sWXviG0WV+Dz5kRYF8 Oczio4cqDPN7Y8UpzVAx+bWS6NKaWv4hXZpRghte3YmqmL6AduCaRweQIXu1G+dNvM6l k5UcjaSImB9P3C6pbZoqEWt3Ik78PAMfqfc3lRygoIvci4UauEdVq+weV4dm9cZH+2sF rkgBPQ+WpY0HujonboqXPGJNHW7geVo6dI3fGqomgWKPQQFDnwHK0uzA/m+HSvRX/m2C OqHw== X-Gm-Message-State: AO0yUKWefRdpFw5su5Crq9T7wQCrG9xojgxCdhPL4h9sQ4iwl0fxqbph VhHzQZGFfXsR6+xsCfdOKunAO0+F8yKUJohv X-Received: by 2002:a05:600c:4488:b0:3d9:fb89:4e3d with SMTP id e8-20020a05600c448800b003d9fb894e3dmr2559026wmo.28.1676480566248; Wed, 15 Feb 2023 09:02:46 -0800 (PST) Received: from lmecxl1178.lme.st.com (176-165-102-236.abo.bbox.fr. [176.165.102.236]) by smtp.gmail.com with ESMTPSA id c2-20020a05600c0a4200b003e1fb31fc2bsm2941556wmq.37.2023.02.15.09.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 09:02:45 -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 v4 2/2] firmware: arm_scmi: optee: use optee system invocation Date: Wed, 15 Feb 2023 18:02:38 +0100 Message-Id: <20230215170238.1864311-2-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230215170238.1864311-1-etienne.carriere@linaro.org> References: <20230215170238.1864311-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?1757917411556862601?= X-GMAIL-MSGID: =?utf-8?q?1757917411556862601?= 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 --- No change since v3 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; }