From nobody Tue Dec 2 01:48:30 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 900783491D5 for ; Fri, 21 Nov 2025 11:01:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763722904; cv=none; b=udohqvs1KfqE2RvFWAUTGMYG73bv4y3BBMRLjbOKXNHA0rkS+cncCqkRtbK5aZCGNP75CGuDE/GeUTf0yJECo8zpBgp1zcBqPGGouq/bdY+1pd4ktHlQHvURv35tocW4A2jqLibezcZ/gWrfFvpnFwrHarnuLJlJIigrjuRjvjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763722904; c=relaxed/simple; bh=atRUbTe1wqlw66lPTwU2h2uX5zOo7TURemVlkzfSfrQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CWSSXsuz9oWstnh+GTaGIWQBvZdMk4jjq4v8biMvW/4IM4cFc5YU2dNBI0uXBTJiC3b41m/lXrxFZfSWJdexFRdcA/qhi32I76gfUCDAL1Wr72OtmyctEVBYppIufuvBoxv24StSlGhQfr6khJ3XVfURXpNyeIIIU0j9CfaL4HU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=P9qJAf/u; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=MJmrF/3X; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="P9qJAf/u"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="MJmrF/3X" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5AL8YuHJ3139659 for ; Fri, 21 Nov 2025 11:01:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= gGMHteN96D+kdzeh+oroZ90SMRQswPS3eyagrABl0U8=; b=P9qJAf/uka3Y281l oBnIVLQn5yirzjIadTqJYSCgqNpQPfzc0SGMe+bj/6riFGxNm51yjrP4cgrujCPq bU1M+6hvvXB2t9XjyNuoOEj2SCaXMpMgfoOis2Tk0h8xA0ChmVvkEwd+rmLXb+6O +5ums39EIPU/52vHiFXJnY9gX4GFEeXXkVJZmvdsOZwvmkilzSN56BWdX21yW23M 3QZN64ad0rX1HU1xS0zMcejP5AW+zjtBAOgIYBVpfqMrGDZXVaxJXZDwNxx3TMeh oiL4i7ZROoHvIXNVM+HPU89EyVJPjL8+Vpz+lrS0Zw8oQOU8mBibHS15/DPF+ngW unTkXA== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ajmppgm20-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 21 Nov 2025 11:01:41 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3436d81a532so3931818a91.3 for ; Fri, 21 Nov 2025 03:01:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1763722901; x=1764327701; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gGMHteN96D+kdzeh+oroZ90SMRQswPS3eyagrABl0U8=; b=MJmrF/3XLDCopRjTXlV3o+9ZPNdq371tEuXQGjNzYzdBQNjeI8JupbZXQktTQwEbHR hIiRn/qCC2BZipi0N7YJhCSP5C+gQYSFovXZoIlzBkqLJuLAr6mS3rpRnmuzr6OUY58a fdKWPKACZylp20NeVLF72OVHQlyVDYnf25zJw72UG/TLBcoZ/MpjQtK5hXt4v0IFhajf 18Eq1aUBq+43AzeA0zLqYOBM16f3gZn8PYmqfqI5oPaPjasskB/Qz9v1gXfJ/OY1sdkE SW17aYNVzPseDhs2NVpibtNeMTRMvA7WQMlSQJ0T8EwmANx/WGVOUuvDHLb4w3xqhb7+ DAEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763722901; x=1764327701; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=gGMHteN96D+kdzeh+oroZ90SMRQswPS3eyagrABl0U8=; b=WzgKQ5wyAoTHJv67ngBLWw/0ZCQBEkxu9Ib4Svf/eBEnXQBj9RTA3InNpVK6ra80kD KVEMvcuuy2S6xwJdp+VgPxR4RpEY8DtBx+uvRlnHDMLqyim0hbzyM6JzZfR4yLay/7aU bQUU8uBJ2vJs7QrRFFeFcLuz126O7A4MhJZcK7UJleBXYnJKoel6kIwC13U1bAN6QNLt lFr6fDii6+iCjbAIaS+HDwD3P9egWUTao4u7wucu9Jyq0VVKJSQz+naNRHdya7oVCtKh cn7WVDrVSf9SDjI8WCW16QSO5zwjpwXoatkfqMbqLsq6jaABHbzUyOBN7hk3B59sHvE/ AMdg== X-Forwarded-Encrypted: i=1; AJvYcCXVJHzvDDpJfl7z6cL2kxLshR8DbDUESzWEA6i3plCXS3NsEIt1BPTXftyq8/iRkgMG6Ft7YwllUsfEWgk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1nnIkya7EcuMPxWxAdVA7AM6c31ZhEDitJaxGqC99Zax7TD70 bwiE7s7D6w/ykRjHB3FSyh0ByDe9K/C8O1Xr5qPKXfsNaPhCUaLQsS7OFwbAtnQr8dMZdEp9dsf bTVrRvs0nFzTxJ4zoIEZ2/qsRPey4JDftriohSwO1HvtdfE4rDqVStLsAI0StusBMAMs= X-Gm-Gg: ASbGncsADS3V62b3oTpC4M9j0SIxApwVLoHUJx0BoS/skJyto5kJH9k1PR1G9G4NVx7 G3weULapx6n0a86H+639hy2Z1vR8SkUEKp/ES41/bzP34USNTmX+6hWfP4WJ25kBC917c3kAziH CGkLLRWvLX8V/bPJ7Zue4vxGPxXtn3am3NQHntFqO+91ygTGycA6bOlTKKkHht9IRFHeOgyT5Yn lRdhNsmJrgyhLgAzXXQ4tU6TODbbfJG4k4Bp2JF+UrSsORzPw7dyDzg3ruFLRhLPiQ9Udca59LI eEEQ/AqGe1jhjSepOgnAcFHgfl3iZiCxdhx286hTLdnsW+LHd8P35rdG2odoy8bKTnkjMDJQyiz EthJPD4FgIXe3bRqcsDPsPpMKhMWs3JOdb8Yu X-Received: by 2002:a17:90b:2f4b:b0:341:8bda:d0ae with SMTP id 98e67ed59e1d1-34733f2de45mr2302145a91.20.1763722899584; Fri, 21 Nov 2025 03:01:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHun6eTxQZztKqbKIy4EXfyv4Laf/KztaRT+F0JNkqQRthBtd5FcxMQdybDyeVSM2bhhR66sQ== X-Received: by 2002:a17:90b:2f4b:b0:341:8bda:d0ae with SMTP id 98e67ed59e1d1-34733f2de45mr2302072a91.20.1763722898933; Fri, 21 Nov 2025 03:01:38 -0800 (PST) Received: from hu-mojha-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34727d5208csm5191165a91.15.2025.11.21.03.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Nov 2025 03:01:38 -0800 (PST) From: Mukesh Ojha Date: Fri, 21 Nov 2025 16:31:06 +0530 Subject: [PATCH v8 04/14] firmware: qcom_scm: Introduce PAS context initialization helper function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251121-kvm_rproc_v8-v8-4-8e8e9fb0eca0@oss.qualcomm.com> References: <20251121-kvm_rproc_v8-v8-0-8e8e9fb0eca0@oss.qualcomm.com> In-Reply-To: <20251121-kvm_rproc_v8-v8-0-8e8e9fb0eca0@oss.qualcomm.com> To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mukesh Ojha X-Mailer: b4 0.14-dev-f7c49 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763722879; l=4059; i=mukesh.ojha@oss.qualcomm.com; s=20250708; h=from:subject:message-id; bh=atRUbTe1wqlw66lPTwU2h2uX5zOo7TURemVlkzfSfrQ=; b=bHlSlo92n3VgckL++DWPpGBDbCq4f5xm9w2gE7vSUVmjL7bmjBaXcP/cS2TVKuaTmB74lmOPv 6UqD0RSxxo2BaXHGvpphrEyeIlCv6Uj1EDZiQZ0ovWA3gJLlWIEVh7W X-Developer-Key: i=mukesh.ojha@oss.qualcomm.com; a=ed25519; pk=eX8dr/7d4HJz/HEXZIpe3c+Ukopa/wZmxH+5YV3gdNc= X-Proofpoint-ORIG-GUID: os-Z1CVAwUCUhtRtc1kDRewoSQ2LJqAc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIxMDA4NCBTYWx0ZWRfXyoJC0dlPCOjS R/ZFoPslqumUTHBD3qseFoip+YWF8dBYNzaocYjE1RPEFGEj7LgUtN3H05jGApcGJd3pm7c7EZ0 1uu57GJ+XH+ixXXSLd3w5n2DBA87wuE+6P9/gZUm8dWSiV/P8eN741XIwsn+KE/1tY78PnI0xRl deEWUG3K1EahzH9QQGvaguZR1JAMG6FwLUuXNahPgzBeqUGORNdT66BcyZWwr/Qh4UdXu9Mxm2P D2hnVJfRZoyTwYDRXVKWbzNf6SwobEZMritMQblFKKhi0U2iMGMn0O8nyIEYSTpSXF4Z85lK0/t XPlceV2JHyvZatxOizheqPMx6VpGA5F83P8SRQPXuFu6Msl0eMOISvS71GwYP0xL3qCqXX6tKfs dkGGzRX3jS41Vx1/ltSiredWvdWSaw== X-Proofpoint-GUID: os-Z1CVAwUCUhtRtc1kDRewoSQ2LJqAc X-Authority-Analysis: v=2.4 cv=CK4nnBrD c=1 sm=1 tr=0 ts=69204695 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=FtZ2CgB1kwCBZN0VdloA:9 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-21_03,2025-11-20_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511210084 When the Peripheral Authentication Service (PAS) method runs on a SoC where Linux operates at EL2 (i.e., without the Gunyah hypervisor), the reset sequences are handled by TrustZone. In such cases, Linux must perform additional steps before invoking PAS SMC calls, such as creating a SHM bridge. Therefore, PAS SMC calls require awareness and handling of these additional steps when Linux runs at EL2. To support this, there is a need for a data structure that can be initialized prior to invoking any SMC or MDT functions. This structure allows those functions to determine whether they are operating in the presence or absence of the Gunyah hypervisor and behave accordingly. Currently, remoteproc and non-remoteproc subsystems use different variants of the MDT loader helper API, primarily due to differences in metadata context handling. Remoteproc subsystems retain the metadata context until authentication and reset are completed, while non-remoteproc subsystems (e.g., video, graphics, IPA, etc.) do not retain the metadata context and can free it within the qcom_scm_pas_init() call by passing a NULL context parameter and due to these differences, it is not possible to extend metadata context handling to support remoteproc and non remoteproc subsystem use PAS operations, when Linux operates at EL2. Add PAS context data structure and initialization helper function. Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom/qcom_scm.c | 34 ++++++++++++++++++++++++++++++= ++++ include/linux/firmware/qcom/qcom_scm.h | 14 ++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_= scm.c index 0a0c48fca7cf..e9e9d03ea36a 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -558,6 +558,40 @@ static void qcom_scm_set_download_mode(u32 dload_mode) dev_err(__scm->dev, "failed to set download mode: %d\n", ret); } =20 +/** + * devm_qcom_scm_pas_context_init() - Initialize peripheral authentication= service + * context for a given peripheral + * + * PAS context is device-resource managed, so the caller does not need + * to worry about freeing the context memory. + * + * @dev: PAS firmware device + * @pas_id: peripheral authentication service id + * @mem_phys: Subsystem reserve memory start address + * @mem_size: Subsystem reserve memory size + * + * Upon successful, returns the PAS context or ERR_PTR() of the error othe= rwise. + */ +struct qcom_scm_pas_context *devm_qcom_scm_pas_context_init(struct device = *dev, + u32 pas_id, + phys_addr_t mem_phys, + size_t mem_size) +{ + struct qcom_scm_pas_context *ctx; + + ctx =3D devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return ERR_PTR(-ENOMEM); + + ctx->dev =3D dev; + ctx->pas_id =3D pas_id; + ctx->mem_phys =3D mem_phys; + ctx->mem_size =3D mem_size; + + return ctx; +} +EXPORT_SYMBOL_GPL(devm_qcom_scm_pas_context_init); + /** * qcom_scm_pas_init_image() - Initialize peripheral authentication service * state machine for a given peripheral, using the diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmwar= e/qcom/qcom_scm.h index a13f703b16cd..4a57fa676513 100644 --- a/include/linux/firmware/qcom/qcom_scm.h +++ b/include/linux/firmware/qcom/qcom_scm.h @@ -72,6 +72,20 @@ struct qcom_scm_pas_metadata { ssize_t size; }; =20 +struct qcom_scm_pas_context { + struct device *dev; + u32 pas_id; + phys_addr_t mem_phys; + size_t mem_size; + void *ptr; + dma_addr_t phys; + ssize_t size; +}; + +struct qcom_scm_pas_context *devm_qcom_scm_pas_context_init(struct device = *dev, + u32 pas_id, + phys_addr_t mem_phys, + size_t mem_size); int qcom_scm_pas_init_image(u32 pas_id, const void *metadata, size_t size, struct qcom_scm_pas_metadata *ctx); void qcom_scm_pas_metadata_release(struct qcom_scm_pas_metadata *ctx); --=20 2.50.1