Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp201274rdb; Thu, 2 Nov 2023 00:32:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGKfmi6EURXATeKKTRm06CYDyeqC0I6UJ5pMJ3L2gWTafxKaA9xo07d4kZmgHJTFP+MyCX X-Received: by 2002:a17:90a:f0d8:b0:27d:375a:e322 with SMTP id fa24-20020a17090af0d800b0027d375ae322mr14836754pjb.31.1698910327564; Thu, 02 Nov 2023 00:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698910327; cv=none; d=google.com; s=arc-20160816; b=SVDTE9Q0o1mKh66kKwMzTVCZ3LpIXdRxpeZDxcbPdeIX1CU2Y1XzN+OFwLXyWXZEiJ zZ0znCxSQ0tX0yNU3xZzjDkvxEmMsUYFHKGbvaTb/73AAok6ZiZRx/ovrkh2JxE/PMOC hu6ygR9e5DGeEOSG8kF5fYZFZi94fGWP472EqiVsnYXhafPtgLi7+piMkfqCCBHkjyPq SwWyzGNx7K/OXRWtfHUwDTjxY3LgiC8qtg5evHrPS0ZMzyrlRr3pMSMOjxu0a4OhQzBE j05y1H8585gx5x3BTF/n5Pdh8Dc0oIE6o/SmvStScn2VrwEdPBtHXmw68AcoIJ9jRgWy X8qA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=hpFooBRbxkfZ/wSEwus+JSRKBHYugcnutfyQXd2DWRE=; fh=kek5XU/v1RmPJHz1V6icIjoJC+ErwsKZ1swtKUy8acg=; b=Ktk01wWT01Ena1vP2oPdCdvQgKFh3oaJmDAU6FJEo1wqvZc+N7STdTic+7PgHBGvjS 0/HWZ1VhbcbAWHxctH1wkHpaZMXdRrwbchbCW3wfTLjdso9Ja2IHaKiFPkdYEv/LacQX H7wtC9VAziIvQcCiJbxFaBdqNLFMyMUkNhZ+vVcUnB9sjMrma5S7JEY0crLSmU57MQHJ 9LIPrEHalX8UEflQwCJvVk4EMu1chDJNGqo6ZjgcwuBSFHAp2k1Hrt+NNZ6feng7oL8F XGJ3BAYumIcPOB24YKGAdsz5mo/zopnR3B/mn+aZWx+0oZy8TIRMlY3hxekIM4HEBsZX ULTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vRhNbX5T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t20-20020a17090aba9400b00268a8e0cab3si2288739pjr.178.2023.11.02.00.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 00:32:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vRhNbX5T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A8380802A3DE; Thu, 2 Nov 2023 00:31:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344056AbjKBHbQ (ORCPT + 99 others); Thu, 2 Nov 2023 03:31:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344171AbjKBHbO (ORCPT ); Thu, 2 Nov 2023 03:31:14 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E5612C for ; Thu, 2 Nov 2023 00:31:08 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1cc0e78ec92so4474405ad.3 for ; Thu, 02 Nov 2023 00:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698910268; x=1699515068; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hpFooBRbxkfZ/wSEwus+JSRKBHYugcnutfyQXd2DWRE=; b=vRhNbX5TSmR7o8qiS6ew1j0iucB1YukWnlHkuCaNhsrTymCd/qQIl6HqkYBOMUAshI mEB96vVjPGG4vTZBIleCZBCRd0zI0pid/60bPBzUC6qu61DY0sCa3/9trhwxZmA+0nQW YCyuqWc/umFp+P05V9yXpOpFPv6IDvXc8enw5pxKCa4PTidHQlJCPngMWHK90N+JxNPT /sLxPTnvvRiOn8+1eFw6b95z1NrpKmBJGV3NenT2WwhK9O/ZUmr+eqi5Zo7i2j/8QSZC y+KALF39Knc31SwtxQOrC++2yfAGnfon897olzXPMcEIcbCz2CxfmOBp52Pc2Un5HNti cCKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698910268; x=1699515068; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hpFooBRbxkfZ/wSEwus+JSRKBHYugcnutfyQXd2DWRE=; b=WjhbEwetyE2jZpU5Ew6/jpq6AHiqmwD4geLVmaOe61UsqAtgi1IxCFQn0/3WV5H2Pe hhIm9XaQc/2Q4JGfF2tyPAN7kiq82bv6wMr0B84vxiuMLsd4bgTEfN/QEa6kWf7T47zJ q0mL0QnFYxunlVIbZkSWGHpMzb9a5szjPYe8bKHh/qY8pae9CfN+lzGdNoIqMcPqDbNU pL9oDlm5XCwY1p9FIQdJWbwhvU8JDTv1K81KYs8YiWWTtvddg/A48rvJQku9zlYyZbVb 3Tj+/Gro+wOM1/9vn7PfQOefyfabSOFHqHHYvOCUTDQ1sHl1WGUIUZL3ltJ+AyIsuaPB gFDw== X-Gm-Message-State: AOJu0Yz07bnngnhKKAHxnCZFKO14SODGqrlsgWoVmhi+FIZL9C5gj97e aZLqhC4zYvOv0T/KOrpGUBORNQ== X-Received: by 2002:a17:903:245:b0:1ca:e05a:93a2 with SMTP id j5-20020a170903024500b001cae05a93a2mr17857451plh.32.1698910267843; Thu, 02 Nov 2023 00:31:07 -0700 (PDT) Received: from sumit-X1.. ([223.178.210.245]) by smtp.gmail.com with ESMTPSA id 6-20020a170902c14600b001b03a1a3151sm2424104plj.70.2023.11.02.00.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 00:31:07 -0700 (PDT) From: Sumit Garg To: jens.wiklander@linaro.org, op-tee@lists.trustedfirmware.org Cc: jan.kiszka@siemens.com, arnd@linaro.org, ardb@kernel.org, jerome.forissier@linaro.org, ilias.apalodimas@linaro.org, masahisa.kojima@linaro.org, maxim.uvarov@linaro.org, jarkko.sakkinen@linux.intel.com, linux-kernel@vger.kernel.org, diogo.ivo@siemens.com, Sumit Garg Subject: [PATCH v4 0/2] tee: optee: Fixes for supplicant dependent enumeration Date: Thu, 2 Nov 2023 13:00:54 +0530 Message-Id: <20231102073056.174480-1-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 02 Nov 2023 00:31:49 -0700 (PDT) Currently supplicant dependent optee device enumeration only registers devices whenever tee-supplicant is invoked for the first time. But it forgets to remove devices when tee-supplicant daemon stops running and closes its context gracefully. This leads to following error for fTPM driver during reboot/shutdown: [ 73.466791] tpm tpm0: ftpm_tee_tpm_op_send: SUBMIT_COMMAND invoke error: 0xffff3024 Fix this by adding an attribute for supplicant dependent devices so that the user-space service can detect and detach supplicant devices before closing the supplicant: $ for dev in /sys/bus/tee/devices/*; do if [[ -f "$dev/need_supplicant" && -f "$dev/driver/unbind" ]]; \ then echo $(basename "$dev") > $dev/driver/unbind; fi done While at it use the global system workqueue for OP-TEE bus scanning work rather than our own custom one. Changes in v4: - Changing the device name would be an ABI break, rather switch to additional device attribute: "need_supplicant" to distinguish for ABI compatibility. - Dropped tested-by for patch #1, I would encourage folks to retest this. Changes in v3: - Split patch into 2 separate ones, one for supplicant fix and other for the workqueue. Changes in v2: - Use device names to separate out tee-supplicant dependent devices via this patch. - Since user-space service is aware about tee-supplicant lifespan, so allow the user-space service to unbind tee-supplicant dependent devices before killing the supplicant. Following command has to be added to the tee-supplicant service file. $ for dev in /sys/bus/tee/devices/*; do if [[ "$dev" == *"optee-ta-supp-"* ]]; \ then echo $(basename "$dev") > $dev/driver/unbind; fi done Sumit Garg (2): tee: optee: Fix supplicant based device enumeration tee: optee: Remove redundant custom workqueue .../ABI/testing/sysfs-bus-optee-devices | 9 +++++++++ drivers/tee/optee/core.c | 13 ++----------- drivers/tee/optee/device.c | 17 +++++++++++++++-- drivers/tee/optee/optee_private.h | 2 -- 4 files changed, 26 insertions(+), 15 deletions(-) -- 2.34.1