From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04F8927B343; Mon, 9 Mar 2026 07:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773040214; cv=none; b=ML7gTGEi0pggAJ3ve0nR1NF/KHiBxeeqgwcv8M9IRT0OGJW7l3rcWpEBFxav8D9NkMV59VfMBlUhYv318wPo9XwcSc+55Slr8efQRFasfKwas5ZwaahYWE5m332bEog/9DxNBOWwdXevPlKdyZstrcH9a4rEolLAiSKt90jnXSw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773040214; c=relaxed/simple; bh=anlN1bEDwp6gLpu0DonpgNFMrOv9gQCkQqPDDRuD4yI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CjvvIQE2Vka9tFLRJvRjH4YRlxU8gnnOTDkHJbulStdezeCGXOfl9AX0S2M9Ahl6NOpVa3YEnMf79PRMh33CZvOi/zbiuzpf6DyCA0FlOQrr2wcRIUZ6rmeGxikVD1ro+EDzXmMmJUxqlkVv1/hL6Rll5Zqy8zyDif0C8thdqzI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r76hKJ2I; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r76hKJ2I" 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 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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/EXNUAIRefCyvaRG7oRYF3Ec+2RgQDRnmmjCjoQNbFrJvJkFHlPeHaeS BosGY+XWKydnmsfY7SSnjAzLUGAFhLd/XDVpb1Een2XucPpKvt9ORF+48gy12FA5GduRLhQU vK4tU7ojoem/G23PcowM1CwPurC8sAVsQb9KmwTGh7rVz3ks3w/zfGBy3+WmLg++C2Wct6nM Pd8/6CBVjEWqD06/RjI2AnjIq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BqsgYdJxjyC/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 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