From mboxrd@z Thu Jan 1 00:00:00 1970 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 6CDF6EF36F2 for ; Mon, 9 Mar 2026 07:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AbakGSVv0qWOHkeWhXiiHdtDgYrbLPFWAAM1pHrMKSo=; b=mBJstCDYzrhTDgR9OY3UFgNlBf tZ7nH8kxvQsxplMG8gZkdWbNiBOGmjab+TGeab7B4hsDXjsNRvpKPljxho4W5iIzizfIGvqidOuAC M0axtoKYyK35smDmyEcFTOPZLvL/szFH73KYWygNoH96t2YSPxp9bzTXyEe57dEmK6ZcU/g1H3/nm O42TGMsKYI+MlVT7JuDD1wV68e9W77332315iBlR7s6GigGQJQwxjreRc0VrzMy4Q0p50w0ev/jd7 5KOXQNsn6Q6ZnDSTtgPB1T/x5txtu1jG3rl/gw8R/KY4448/TTGSTDvGRds9VsESKkDDNnjxrNZMo ZcCj2wmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vzUkr-00000006mjM-0a7N; Mon, 09 Mar 2026 07:10:17 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vzUko-00000006mj0-3YKb for ath12k@lists.infradead.org; Mon, 09 Mar 2026 07:10:15 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id A6BCD444A5; Mon, 9 Mar 2026 07:10:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 385D9C4CEF7; Mon, 9 Mar 2026 07:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773040213; bh=anlN1bEDwp6gLpu0DonpgNFMrOv9gQCkQqPDDRuD4yI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=r76hKJ2I8YnvEycbUdZhv3g4ZucMWG3DrU/7k2lN54BJlvJ1k+RWM2uZ3aJSJ9Bvs xT1zlcdhrrmQV7f4CLWxjW03zc4ThseHDIAIiVkonas0A+h/Lyy7mMZ648MJQ+ys5X Ja+NdpjGJULQu2/t0UPF3ktQR7UfWEO73PisRIs11xG8jnLqb536sgyaa1ZIkoehhl KVeE4Efci2tVhO1rugF34+VUY8HL56nyceKWM2XFL9OSHxMfNKuChpv4OEbTA9WVXP 7B/3EnhTlmPySluWf2X7hhhMMH7cy00+R1sZ0omJQDo/qmsY9KBTKlk/XnExxVhniT vRKhDcgeTwEDQ== Message-ID: <52cd78c2-95e2-4f56-9adc-242b6cf3baab@kernel.org> Date: Mon, 9 Mar 2026 08:10:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/14] firmware: qcom: Add a generic PAS service To: Sumit Garg Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-media@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, linux-remoteproc@vger.kernel.org, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, robin.clark@oss.qualcomm.com, sean@poorly.run, akhilpo@oss.qualcomm.com, lumag@kernel.org, abhinav.kumar@linux.dev, jesszhan0024@gmail.com, marijn.suijten@somainline.org, airlied@gmail.com, simona@ffwll.ch, vikash.garodia@oss.qualcomm.com, dikshita.agarwal@oss.qualcomm.com, bod@kernel.org, mchehab@kernel.org, elder@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jjohnson@kernel.org, mathieu.poirier@linaro.org, trilokkumar.soni@oss.qualcomm.com, mukesh.ojha@oss.qualcomm.com, pavan.kondeti@oss.qualcomm.com, jorge.ramirez@oss.qualcomm.com, tonyh@qti.qualcomm.com, vignesh.viswanathan@oss.qualcomm.com, srinivas.kandagatla@oss.qualcomm.com, amirreza.zarrabi@oss.qualcomm.com, jens.wiklander@linaro.org, op-tee@lists.trustedfirmware.org, apurupa@qti.qualcomm.com, skare@qti.qualcomm.com, Sumit Garg References: <20260306105027.290375-1-sumit.garg@kernel.org> <20260306105027.290375-3-sumit.garg@kernel.org> <5dab61a6-d8cc-431d-b59e-744d98195d90@kernel.org> From: Krzysztof Kozlowski Content-Language: en-US Autocrypt: addr=krzk@kernel.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kWvN79 cFgcqTTuNHjAvxtUG8pQgGTHAObYs6xeYJtjUH0ZX6ndJ33FJYf5V3yXqqjcZ30FgHzJCFUu JMp7PSyMPzpUXfU12yfcRYVEMQrmplNZssmYhiTeVicuOOypWugZKVLGNm0IweVCaZ/DJDIH gNbpvVwjcKYrx85m9cBVEBUGaQP6AT7qlVCkrf50v8bofSIyVa2xmubbAwwFA1oxoOusjPIE J3iadrwpFvsZjF5uHAKS+7wHLoW9hVzOnLbX6ajk5Hf8Pb1m+VH/E8bPBNNYKkfTtypTDUCj NYcd27tjnXfG+SDs/EXNUAIRefC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IzQisg Dgv76tnEv3YHV8Jn9mi/Bu0FURF+5kpdMfgo1sq6RXNQ//TVf8yFgRtTUdXxW/qHjlYURrm2 H4kutobVEIxiyu6m05q3e9eZB/TaMMNVORx+1kM3j7f0rwtEYUFzY1ygQfpcMDPl7pRYoJjB dSsm0ZuzDaCwaxg2t8hqQJBzJCezTOIkjHUsWAK+tEbU4Z4SnNpCyM3fBqsgYdJxjyC/tWVT AQ18NRLtPw7tK1rdcwCl0GFQHwSwk5pDpz1NH40e6lU+NcXSeiqkDDRkHlftKPV/dV+lQXiu jWt87ecuHlpL3uuQ0ZZNWqHgZoQLXoqC2ZV5KrtKWb/jyiFX/sxSrodALf0zf+tfHv0FZWT2 zHjUqd0t4njD/UOsuIMOQn4Ig0SdivYPfZukb5cdasKJukG1NOpbW7yRNivaCnfZz6dTawXw XRIV/KDsHQiyVxKvN73bThKhONkcX2LWuD928tAR6XMM2G5ovxLe09vuOzzfTWQDsm++9UKF a/A= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260309_001014_938006_2980808D X-CRM114-Status: GOOD ( 29.81 ) X-BeenThere: ath12k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath12k" Errors-To: ath12k-bounces+ath12k=archiver.kernel.org@lists.infradead.org On 09/03/2026 05:55, Sumit Garg wrote: > On Fri, Mar 06, 2026 at 12:15:01PM +0100, Krzysztof Kozlowski wrote: >> On 06/03/2026 11:50, Sumit Garg wrote: >>> From: Sumit Garg >>> >>> Qcom platforms has the legacy of using non-standard SCM calls >>> splintered over the various kernel drivers. These SCM calls aren't >>> compliant with the standard SMC calling conventions which is a >>> prerequisite to enable migration to the FF-A specifications from >>> Arm. >>> >>> OP-TEE as an alternative trusted OS to QTEE can't support these non- >>> standard SCM calls. And even for newer architectures QTEE won't be able >>> to support SCM calls either with FF-A requirements coming in. And with >>> both OP-TEE and QTEE drivers well integrated in the TEE subsystem, it >>> makes further sense to reuse the TEE bus client drivers infrastructure. >>> >>> The added benefit of TEE bus infrastructure is that there is support >>> for discoverable/enumerable services. With that client drivers don't >>> have to manually invoke a special SCM call to know the service status. >>> >>> So enable the generic Peripheral Authentication Service (PAS) provided >>> by the firmware. It acts as the common layer with different TZ >>> backends plugged in whether it's an SCM implementation or a proper >>> TEE bus based PAS service implementation. >>> >>> Signed-off-by: Sumit Garg >>> --- >>> drivers/firmware/qcom/Kconfig | 8 + >>> drivers/firmware/qcom/Makefile | 1 + >>> drivers/firmware/qcom/qcom_pas.c | 295 +++++++++++++++++++++++++ >>> drivers/firmware/qcom/qcom_pas.h | 53 +++++ >>> include/linux/firmware/qcom/qcom_pas.h | 41 ++++ >>> 5 files changed, 398 insertions(+) >>> create mode 100644 drivers/firmware/qcom/qcom_pas.c >>> create mode 100644 drivers/firmware/qcom/qcom_pas.h >>> create mode 100644 include/linux/firmware/qcom/qcom_pas.h >>> >>> diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig >>> index b477d54b495a..8653639d06db 100644 >>> --- a/drivers/firmware/qcom/Kconfig >>> +++ b/drivers/firmware/qcom/Kconfig >>> @@ -6,6 +6,14 @@ >>> >>> menu "Qualcomm firmware drivers" >>> >>> +config QCOM_PAS >>> + tristate >>> + help >>> + Enable the generic Peripheral Authentication Service (PAS) provided >>> + by the firmware. It acts as the common layer with different TZ >>> + backends plugged in whether it's an SCM implementation or a proper >>> + TEE bus based PAS service implementation. >>> + >>> config QCOM_SCM >>> select QCOM_TZMEM >>> tristate >>> diff --git a/drivers/firmware/qcom/Makefile b/drivers/firmware/qcom/Makefile >>> index 0be40a1abc13..dc5ab45f906a 100644 >>> --- a/drivers/firmware/qcom/Makefile >>> +++ b/drivers/firmware/qcom/Makefile >>> @@ -8,3 +8,4 @@ qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o >>> obj-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o >>> obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o >>> obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o >>> +obj-$(CONFIG_QCOM_PAS) += qcom_pas.o >>> diff --git a/drivers/firmware/qcom/qcom_pas.c b/drivers/firmware/qcom/qcom_pas.c >>> new file mode 100644 >>> index 000000000000..dc04ff1b6be0 >>> --- /dev/null >>> +++ b/drivers/firmware/qcom/qcom_pas.c >>> @@ -0,0 +1,295 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +/* >>> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. >>> + */ >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include "qcom_pas.h" >>> +#include "qcom_scm.h" >>> + >>> +static struct qcom_pas_ops *ops_ptr; >> >> I really dislike this singleton design. And it is not even needed! If >> you were storing here some allocated instance of SCM/PAS I could >> understand, but singleton for only ops? Just implement one driver (so >> SCM + whatever you have here) which will decide which ops to use, >> through the probe. Really, this is neither needed nor beneficial. > > The motivation here is rather quite opposite to the single monolithic > SCM driver design. The TZ services like PAS, ICE and so on are going to > be implemented as independent discoverable devices on TEE bus which > rather needs independent kernel client drivers. You still have singleton here. So if you think you do opposite to singleton, then drop this static. > > Also, the single driver probe can't work here since the SCM driver is > bound to the platform bus whereas the TEE PAS driver is bound to the TEE > bus. So there is a reason for the current design. > >> >> It actually leads to more problems with this barrier handling, see >> further comments. > > The barrier handling is something that I carried over from existing > implmentation but I can't see a reason why it can't be replaced with a > simple mutex. See diff below for mutex. > >> ... >> >>> + >>> +/** >>> + * qcom_pas_shutdown() - Shut down the remote processor >>> + * @pas_id: peripheral authentication service id >>> + * >>> + * Returns 0 on success. >>> + */ >>> +int qcom_pas_shutdown(u32 pas_id) >>> +{ >>> + if (ops_ptr) >>> + return ops_ptr->shutdown(ops_ptr->dev, pas_id); >>> + >>> + return -ENODEV; >>> +} >>> +EXPORT_SYMBOL_GPL(qcom_pas_shutdown); >>> + >>> +/** >>> + * qcom_pas_supported() - Check if the peripheral authentication service is >>> + * available for the given peripheral >>> + * @pas_id: peripheral authentication service id >>> + * >>> + * Returns true if PAS is supported for this peripheral, otherwise false. >>> + */ >>> +bool qcom_pas_supported(u32 pas_id) >>> +{ >>> + if (ops_ptr) >> >> Lack of barriers here is not looking right. Existing/old code is not a >> good example, I fixed only the obvious issue, but new code should be >> correct from the beginning. >> >> Barriers should normally be always paired, unless you have some clear >> path no concurrent execution can happen here, but such explanation is >> missing, look: > > Actually concurrent execution is rather required here since TZ can > support parallel bring-up of co-processors. The synchonization is only > needed when PAS client drivers are performing a deferred probe waiting > for the service to be available. However, you are right explanation is > missing here which I will add in the next version. Hm? Existing comments are completely useless. Your comment said just "barrier" basically... That's nothing useful. Best regards, Krzysztof From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.trustedfirmware.org (lists.trustedfirmware.org [18.214.241.189]) (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 002E5EF36F2 for ; Mon, 9 Mar 2026 07:10:34 +0000 (UTC) Received: from lists.trustedfirmware.org (localhost [127.0.0.1]) by lists.trustedfirmware.org (Postfix) with ESMTP id 3ACFA438AB for ; Mon, 9 Mar 2026 07:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.trustedfirmware.org; s=2024; t=1773040234; bh=anlN1bEDwp6gLpu0DonpgNFMrOv9gQCkQqPDDRuD4yI=; h=Date:Subject:To:References:In-Reply-To:CC:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Reply-To:From; b=Pq9p1Q5I1hgRuPm0o34UPzXMi68WHbFwNedLhvYww+LJv588jCzbFCNXSR/8xFdXu Br+Ac/w3yB/vl1ETovoatRTNlsqf1Yv0duQfKOTodxbuRkMjfu+of5aSHz8qx9l7LP yw/fiALf4obcI0oXi92aQT4XtmSxgf4G/Ft+vc9fIEk+oY/jkIm9hZgfMNKDC3odlv //pKIbPAcn7FFMg9In7J4eT0k1To1SNlmmyrs75qEEqYAPBX1FWolsmjbRBaOk7N5v utgj8MiwI+g7BJ7fXe36SFmSDgl51JSDRfKBIhpmOnUGlvnJKPQm/4yqdaQ9Rdc43e zYzaMueSpAxTg== Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by lists.trustedfirmware.org (Postfix) with ESMTPS id 8BC9F431B3 for ; Mon, 9 Mar 2026 07:10:14 +0000 (UTC) Authentication-Results: lists.trustedfirmware.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=r76hKJ2I; dkim-atps=neutral Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id A6BCD444A5; Mon, 9 Mar 2026 07:10:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 385D9C4CEF7; Mon, 9 Mar 2026 07:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773040213; bh=anlN1bEDwp6gLpu0DonpgNFMrOv9gQCkQqPDDRuD4yI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=r76hKJ2I8YnvEycbUdZhv3g4ZucMWG3DrU/7k2lN54BJlvJ1k+RWM2uZ3aJSJ9Bvs xT1zlcdhrrmQV7f4CLWxjW03zc4ThseHDIAIiVkonas0A+h/Lyy7mMZ648MJQ+ys5X Ja+NdpjGJULQu2/t0UPF3ktQR7UfWEO73PisRIs11xG8jnLqb536sgyaa1ZIkoehhl KVeE4Efci2tVhO1rugF34+VUY8HL56nyceKWM2XFL9OSHxMfNKuChpv4OEbTA9WVXP 7B/3EnhTlmPySluWf2X7hhhMMH7cy00+R1sZ0omJQDo/qmsY9KBTKlk/XnExxVhniT vRKhDcgeTwEDQ== Message-ID: <52cd78c2-95e2-4f56-9adc-242b6cf3baab@kernel.org> Date: Mon, 9 Mar 2026 08:10:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/14] firmware: qcom: Add a generic PAS service To: Sumit Garg References: <20260306105027.290375-1-sumit.garg@kernel.org> <20260306105027.290375-3-sumit.garg@kernel.org> <5dab61a6-d8cc-431d-b59e-744d98195d90@kernel.org> Content-Language: en-US Autocrypt: addr=krzk@kernel.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kWvN79 cFgcqTTuNHjAvxtUG8pQgGTHAObYs6xeYJtjUH0ZX6ndJ33FJYf5V3yXqqjcZ30FgHzJCFUu JMp7PSyMPzpUXfU12yfcRYVEMQrmplNZssmYhiTeVicuOOypWugZKVLGNm0IweVCaZ/DJDIH gNbpvVwjcKYrx85m9cBVEBUGaQP6AT7qlVCkrf50v8bofSIyVa2xmubbAwwFA1oxoOusjPIE J3iadrwpFvsZjF5uHAKS+7wHLoW9hVzOnLbX6ajk5Hf8Pb1m+VH/E8bPBNNYKkfTtypTDUCj NYcd27tjnXfG+SDs/EXNUAIRefCyvaRG7oRYF3Ec+2RgQDRnmmjCjoQNbFrJvJkFHlPeHaeS BosGY+XWKydnmsfY7SSnjAzLUGAFhLd/XDVpb1Een2XucPpKvt9ORF+48gy12FA5GduRLhQU vK4tU7ojoem/G23PcowM1CwPurC8sAVsQb9KmwTGh7rVz3ks3w/zfGBy3+WmLg++C2Wct6nM Pd8/6CBVjEWqD06/RjI2AnjIq5fSEH/BIfXXfC68nMp9BZoy3So4Z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tK1rdcwCl0GFQHwSwk5pDpz1NH40e6lU+NcXSeiqkDDRkHlftKPV/dV+lQXiu jWt87ecuHlpL3uuQ0ZZNWqHgZoQLXoqC2ZV5KrtKWb/jyiFX/sxSrodALf0zf+tfHv0FZWT2 zHjUqd0t4njD/UOsuIMOQn4Ig0SdivYPfZukb5cdasKJukG1NOpbW7yRNivaCnfZz6dTawXw XRIV/KDsHQiyVxKvN73bThKhONkcX2LWuD928tAR6XMM2G5ovxLe09vuOzzfTWQDsm++9UKF a/A= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Action: no action X-Spamd-Result: default: False [-2.50 / 15.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_ALLOW(-0.50)[kernel.org,quarantine]; R_DKIM_ALLOW(-0.20)[kernel.org:s=k20201202]; R_SPF_ALLOW(-0.20)[+ip4:172.234.252.31]; MIME_GOOD(-0.10)[text/plain]; TAGGED_RCPT(0.00)[dt,netdev]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[49]; DWL_DNSWL_BLOCKED(0.00)[kernel.org:dkim]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; MID_RHS_MATCH_FROM(0.00)[]; NEURAL_HAM(-0.00)[-1.000]; ALIAS_RESOLVED(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[vger.kernel.org,lists.freedesktop.org,lists.infradead.org,kernel.org,oss.qualcomm.com,poorly.run,linux.dev,gmail.com,somainline.org,ffwll.ch,lunn.ch,davemloft.net,google.com,redhat.com,linaro.org,qti.qualcomm.com,lists.trustedfirmware.org]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DNSWL_BLOCKED(0.00)[100.75.92.58:received]; RCVD_TLS_LAST(0.00)[]; DKIM_TRACE(0.00)[kernel.org:+] X-Rspamd-Server: lists.trustedfirmware.org X-Rspamd-Queue-Id: 8BC9F431B3 X-Spamd-Bar: -- Message-ID-Hash: I3P3KCZ3JRJCN3KIB7NHH2HZZYUUZA4Y X-Message-ID-Hash: I3P3KCZ3JRJCN3KIB7NHH2HZZYUUZA4Y X-MailFrom: krzk@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-op-tee.lists.trustedfirmware.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-media@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, linux-remoteproc@vger.kernel.org, andersson@kernel.org, konradybcio@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, robin.clark@oss.qualcomm.com, sean@poorly.run, akhilpo@oss.qualcomm.com, lumag@kernel.org, abhinav.kumar@linux.dev, jesszhan0024@gmail.com, marijn.suijten@somainline.org, airlied@gmail.com, simona@ffwll.ch, vikash.garodia@oss.qualcomm.com, dikshita.agarwal@oss.qualcomm.com, bod@kernel.org, mchehab@kernel.org, elder@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jjohnson@kernel.org, mathieu.poirier@linaro.org, trilokkumar.soni@oss.qualcomm.com, mukesh.ojha@oss.qualcomm.com, pavan.kondeti@oss.qualcomm.com, jorge.ramirez@oss.qualcomm.com, tonyh@qti. qualcomm.com, vignesh.viswanathan@oss.qualcomm.com, srinivas.kandagatla@oss.qualcomm.com, amirreza.zarrabi@oss.qualcomm.com, op-tee@lists.trustedfirmware.org, apurupa@qti.qualcomm.com, skare@qti.qualcomm.com, Sumit Garg X-Mailman-Version: 3.3.5 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Krzysztof Kozlowski via OP-TEE Reply-To: Krzysztof Kozlowski On 09/03/2026 05:55, Sumit Garg wrote: > On Fri, Mar 06, 2026 at 12:15:01PM +0100, Krzysztof Kozlowski wrote: >> On 06/03/2026 11:50, Sumit Garg wrote: >>> From: Sumit Garg >>> >>> Qcom platforms has the legacy of using non-standard SCM calls >>> splintered over the various kernel drivers. These SCM calls aren't >>> compliant with the standard SMC calling conventions which is a >>> prerequisite to enable migration to the FF-A specifications from >>> Arm. >>> >>> OP-TEE as an alternative trusted OS to QTEE can't support these non- >>> standard SCM calls. And even for newer architectures QTEE won't be able >>> to support SCM calls either with FF-A requirements coming in. And with >>> both OP-TEE and QTEE drivers well integrated in the TEE subsystem, it >>> makes further sense to reuse the TEE bus client drivers infrastructure. >>> >>> The added benefit of TEE bus infrastructure is that there is support >>> for discoverable/enumerable services. With that client drivers don't >>> have to manually invoke a special SCM call to know the service status. >>> >>> So enable the generic Peripheral Authentication Service (PAS) provided >>> by the firmware. It acts as the common layer with different TZ >>> backends plugged in whether it's an SCM implementation or a proper >>> TEE bus based PAS service implementation. >>> >>> Signed-off-by: Sumit Garg >>> --- >>> drivers/firmware/qcom/Kconfig | 8 + >>> drivers/firmware/qcom/Makefile | 1 + >>> drivers/firmware/qcom/qcom_pas.c | 295 +++++++++++++++++++++++++ >>> drivers/firmware/qcom/qcom_pas.h | 53 +++++ >>> include/linux/firmware/qcom/qcom_pas.h | 41 ++++ >>> 5 files changed, 398 insertions(+) >>> create mode 100644 drivers/firmware/qcom/qcom_pas.c >>> create mode 100644 drivers/firmware/qcom/qcom_pas.h >>> create mode 100644 include/linux/firmware/qcom/qcom_pas.h >>> >>> diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig >>> index b477d54b495a..8653639d06db 100644 >>> --- a/drivers/firmware/qcom/Kconfig >>> +++ b/drivers/firmware/qcom/Kconfig >>> @@ -6,6 +6,14 @@ >>> >>> menu "Qualcomm firmware drivers" >>> >>> +config QCOM_PAS >>> + tristate >>> + help >>> + Enable the generic Peripheral Authentication Service (PAS) provided >>> + by the firmware. It acts as the common layer with different TZ >>> + backends plugged in whether it's an SCM implementation or a proper >>> + TEE bus based PAS service implementation. >>> + >>> config QCOM_SCM >>> select QCOM_TZMEM >>> tristate >>> diff --git a/drivers/firmware/qcom/Makefile b/drivers/firmware/qcom/Makefile >>> index 0be40a1abc13..dc5ab45f906a 100644 >>> --- a/drivers/firmware/qcom/Makefile >>> +++ b/drivers/firmware/qcom/Makefile >>> @@ -8,3 +8,4 @@ qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o >>> obj-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o >>> obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o >>> obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o >>> +obj-$(CONFIG_QCOM_PAS) += qcom_pas.o >>> diff --git a/drivers/firmware/qcom/qcom_pas.c b/drivers/firmware/qcom/qcom_pas.c >>> new file mode 100644 >>> index 000000000000..dc04ff1b6be0 >>> --- /dev/null >>> +++ b/drivers/firmware/qcom/qcom_pas.c >>> @@ -0,0 +1,295 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +/* >>> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. >>> + */ >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include "qcom_pas.h" >>> +#include "qcom_scm.h" >>> + >>> +static struct qcom_pas_ops *ops_ptr; >> >> I really dislike this singleton design. And it is not even needed! If >> you were storing here some allocated instance of SCM/PAS I could >> understand, but singleton for only ops? Just implement one driver (so >> SCM + whatever you have here) which will decide which ops to use, >> through the probe. Really, this is neither needed nor beneficial. > > The motivation here is rather quite opposite to the single monolithic > SCM driver design. The TZ services like PAS, ICE and so on are going to > be implemented as independent discoverable devices on TEE bus which > rather needs independent kernel client drivers. You still have singleton here. So if you think you do opposite to singleton, then drop this static. > > Also, the single driver probe can't work here since the SCM driver is > bound to the platform bus whereas the TEE PAS driver is bound to the TEE > bus. So there is a reason for the current design. > >> >> It actually leads to more problems with this barrier handling, see >> further comments. > > The barrier handling is something that I carried over from existing > implmentation but I can't see a reason why it can't be replaced with a > simple mutex. See diff below for mutex. > >> ... >> >>> + >>> +/** >>> + * qcom_pas_shutdown() - Shut down the remote processor >>> + * @pas_id: peripheral authentication service id >>> + * >>> + * Returns 0 on success. >>> + */ >>> +int qcom_pas_shutdown(u32 pas_id) >>> +{ >>> + if (ops_ptr) >>> + return ops_ptr->shutdown(ops_ptr->dev, pas_id); >>> + >>> + return -ENODEV; >>> +} >>> +EXPORT_SYMBOL_GPL(qcom_pas_shutdown); >>> + >>> +/** >>> + * qcom_pas_supported() - Check if the peripheral authentication service is >>> + * available for the given peripheral >>> + * @pas_id: peripheral authentication service id >>> + * >>> + * Returns true if PAS is supported for this peripheral, otherwise false. >>> + */ >>> +bool qcom_pas_supported(u32 pas_id) >>> +{ >>> + if (ops_ptr) >> >> Lack of barriers here is not looking right. Existing/old code is not a >> good example, I fixed only the obvious issue, but new code should be >> correct from the beginning. >> >> Barriers should normally be always paired, unless you have some clear >> path no concurrent execution can happen here, but such explanation is >> missing, look: > > Actually concurrent execution is rather required here since TZ can > support parallel bring-up of co-processors. The synchonization is only > needed when PAS client drivers are performing a deferred probe waiting > for the service to be available. However, you are right explanation is > missing here which I will add in the next version. Hm? Existing comments are completely useless. Your comment said just "barrier" basically... That's nothing useful. Best regards, Krzysztof