Message ID | 20230214152047.1143106-2-etienne.carriere@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3051004wrn; Tue, 14 Feb 2023 07:46:15 -0800 (PST) X-Google-Smtp-Source: AK7set/pfJBftllBU/lIGe+L/ij2PSAsR6ORpdL+OQlaW1UDU7we4cbGo36mM95aho00O+j4J6/m X-Received: by 2002:a17:906:3c0f:b0:8b1:383d:cd50 with SMTP id h15-20020a1709063c0f00b008b1383dcd50mr1198034ejg.48.1676389575556; Tue, 14 Feb 2023 07:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676389575; cv=none; d=google.com; s=arc-20160816; b=Sed7kdELJ0tZaoojDNKyIC/zfW6wT3ECcGT2mJN950LGhNCueQmP8v7dp8xqiCs/6R Zu/tbtDAoiBjx3lVngrz/8Pniy7gbsSdgt2CGSF64RkmB0fOoq1J3M7Yo966UITuMJaX Sbi2pvyMSdrY7u9CObAxV9uW6pz7Mc8Me8ESyaLJF0yXBqsj5b/3YHi+Qq2b/TiSfgYR qy4vLevaM1dQLGu1g4UYZhji8YbeXHOPtqkXtdCbHZxXrfehc5Sf6ijKVHrINwbWvSba NE/Z7erHtx0gTBhF5rpOMQGSv+5toPl/UEKE1o454l6lJbPHbTP299VcnQ+8G+7GS/H6 y3Eg== 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=pZaj9uTvJGoga0iJH/48gNUnrybDI9fdV0k7oGNbvSE=; b=zy6vz+ae6uHZHN4PL8tJR2pfqQV1Hh9RUk5jSH5DSMTKEltXUXjP8hAnVZ8gZCbZEC DE5rB9ngMFWNKDRHImwtRBmVHtNJsoG7o64wWhpYFrsQd/Jddjw5EBX4AX/69KqyVow9 4U+9HPd6kJSgxIordjemz2569WoIq/dzr5i1Htnu7NKB9QaSKUXDOp1NPRvq1QIKk1iP 1WvID7mULPzrIhp0rhqY2KAI/qn3y9xb895LnYLXL0kIC2iwnERqJOirR7V1JTeWzeS0 IutPZZ3s8cyo5uhlNXWBm7wZEppxiKPIn9dvzN30h53PpAGGrplBkSSoXEvb5MFteWsi yiwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nO83UxEL; 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 16-20020a170906021000b0088b669590absi17694637ejd.104.2023.02.14.07.45.52; Tue, 14 Feb 2023 07:46:15 -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=nO83UxEL; 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 S232723AbjBNPaR (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Tue, 14 Feb 2023 10:30:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbjBNPaO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Feb 2023 10:30:14 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AC19252A6 for <linux-kernel@vger.kernel.org>; Tue, 14 Feb 2023 07:30:13 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id o18so16084377wrj.3 for <linux-kernel@vger.kernel.org>; Tue, 14 Feb 2023 07:30:13 -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=G8WLyblyf3t2gzA0yk5NUK5XypHz7MHcxywJFl/ekYlQxDlT57R+cbv0ykxHQ+Fzev g3g3x8GKTLVxQ/O4ZzV3R3l+hcMCDLUw6HnTYcbL2Jdy9gZLouRF50gu3InLRXYAS2vu oCzhG9mHUA1EuWNyV4p2vJQr2rBCdJZX+wZnRmJ2/NtjN0icw/U9GjZgD19G+IklNTMW pejZFZhjl9dOOxlZxG71ECTOwExcZUloMZlRIh1lOPEasHGhV6mYuAAg0ku63UGQVDBV yayZH5al23iYqbxDfeaa9DzJtAXim6zSFiifN7ZPP3lobp3GkQt8r9STHgBnjcvg96OT rzYw== X-Gm-Message-State: AO0yUKUTfHeqEQrBKdllefl+e5v5V/OaPZ2x27xfuEe1+4wZoNDTFlfU gbUMCat6gADrSOhL5gd8QBGYYOx9jWkH8s/4 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 <etienne.carriere@linaro.org> To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Jens Wiklander <jens.wiklander@linaro.org>, Sumit Garg <sumit.garg@linaro.org>, op-tee@lists.trustedfirmware.org, Cristian Marussi <cristian.marussi@arm.com>, Etienne Carriere <etienne.carriere@linaro.org> 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 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757821875673311369?= X-GMAIL-MSGID: =?utf-8?q?1757821875673311369?= |
Series |
[v2,1/2] tee: system invocation
|
|
Commit Message
Etienne Carriere
Feb. 14, 2023, 3:20 p.m. UTC
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 <etienne.carriere@linaro.org>
--
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(-)
Comments
Hi Etienne, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v6.2-rc8] [cannot apply to soc/for-next next-20230215] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Etienne-Carriere/firmware-arm_scmi-optee-use-optee-system-invocation/20230214-233230 patch link: https://lore.kernel.org/r/20230214152047.1143106-2-etienne.carriere%40linaro.org patch subject: [PATCH v2 2/2] firmware: arm_scmi: optee: use optee system invocation config: arm-allyesconfig compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/7a2f7bc17be8c4a18d32c439458d2f0f99e18cd6 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Etienne-Carriere/firmware-arm_scmi-optee-use-optee-system-invocation/20230214-233230 git checkout 7a2f7bc17be8c4a18d32c439458d2f0f99e18cd6 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202302151710.KAq1hph3-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/firmware/arm_scmi/optee.c: In function 'scmi_optee_chan_setup': >> drivers/firmware/arm_scmi/optee.c:436:77: error: expected ';' before 'if' 436 | ret = tee_client_request_system_context(scmi_optee_private->tee_ctx) | ^ | ; 437 | if (ret) | ~~ >> drivers/firmware/arm_scmi/optee.c:439:9: error: 'else' without a previous 'if' 439 | else | ^~~~ >> drivers/firmware/arm_scmi/optee.c:470:79: error: expected ';' before 'return' 470 | tee_client_release_system_context(scmi_optee_private->tee_ctx) | ^ | ; 471 | 472 | return ret; | ~~~~~~ drivers/firmware/arm_scmi/optee.c: In function 'scmi_optee_chan_free': drivers/firmware/arm_scmi/optee.c:497:79: error: expected ';' before 'return' 497 | tee_client_release_system_context(scmi_optee_private->tee_ctx) | ^ | ; 498 | 499 | return 0; | ~~~~~~ drivers/firmware/arm_scmi/optee.c:500:1: error: no return statement in function returning non-void [-Werror=return-type] 500 | } | ^ drivers/firmware/arm_scmi/optee.c: In function 'scmi_optee_chan_setup': drivers/firmware/arm_scmi/optee.c:473:1: error: control reaches end of non-void function [-Werror=return-type] 473 | } | ^ cc1: some warnings being treated as errors vim +436 drivers/firmware/arm_scmi/optee.c 412 413 static int scmi_optee_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, bool tx) 414 { 415 struct scmi_optee_channel *channel; 416 uint32_t channel_id; 417 int ret; 418 419 if (!tx) 420 return -ENODEV; 421 422 channel = devm_kzalloc(dev, sizeof(*channel), GFP_KERNEL); 423 if (!channel) 424 return -ENOMEM; 425 426 ret = of_property_read_u32_index(cinfo->dev->of_node, "linaro,optee-channel-id", 427 0, &channel_id); 428 if (ret) 429 return ret; 430 431 cinfo->transport_info = channel; 432 channel->cinfo = cinfo; 433 channel->channel_id = channel_id; 434 mutex_init(&channel->mu); 435 > 436 ret = tee_client_request_system_context(scmi_optee_private->tee_ctx) 437 if (ret) 438 dev_warn(dev, "Couldn't provision an OP-TEE system context\n"); > 439 else 440 channel->sys_thread = true; 441 442 ret = setup_shmem(dev, cinfo, channel); 443 if (ret) 444 goto err_release_sysctx; 445 446 ret = open_session(scmi_optee_private, &channel->tee_session); 447 if (ret) 448 goto err_free_shm; 449 450 ret = get_channel(channel); 451 if (ret) 452 goto err_close_sess; 453 454 /* Enable polling */ 455 cinfo->no_completion_irq = true; 456 457 mutex_lock(&scmi_optee_private->mu); 458 list_add(&channel->link, &scmi_optee_private->channel_list); 459 mutex_unlock(&scmi_optee_private->mu); 460 461 return 0; 462 463 err_close_sess: 464 close_session(scmi_optee_private, channel->tee_session); 465 err_free_shm: 466 if (channel->tee_shm) 467 tee_shm_free(channel->tee_shm); 468 err_release_sysctx: 469 if (channel->sys_thread) > 470 tee_client_release_system_context(scmi_optee_private->tee_ctx) 471 472 return ret; 473 } 474
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; }