From mboxrd@z Thu Jan 1 00:00:00 1970 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 317EE3F54BF for ; Tue, 30 Jun 2026 10:39:18 +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=1782815961; cv=none; b=ddD4VvvoBgNXAJYntlT8Fjb5PcArBhp2ifcdtemXHVdMTbyQnz1watrwS+5XM8EH0WOulWBdZni5tL3uOuYaKK4hwVnGUJvm7YSFTVDKtsmfi7SRjgZAsj2j21UxzLRB+aWmR3PfFnf7VmmYkopwSI2yzzSgm554V73TwNezcQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782815961; c=relaxed/simple; bh=SSgV13BOWb5nS2Fpmd/8MZ5Xw/5W1uB5JUh+6AiJA7M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iz6FNV66/D56Lj3qB32+tf1Drox8EHG4LuDmGZZLSus1MWCoVk10x6p47cybcdgg4V0tB4qiB11c6C/buWkjCi8oJZ2q/Mt+2PiGZISiVHcgCF5IVsG4BQL71If3oag3nGT3ZyM9U6/gYSankNzp7L2d8SRHsexXHzJhR7V9/18= 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=hHoJy0Gd; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=g79XJbTg; 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="hHoJy0Gd"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="g79XJbTg" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65U9mnHQ1541498 for ; Tue, 30 Jun 2026 10:39:17 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= u+IixcZnrCq0YCBcT04603GxKzb/cwi1U8yD4nVob/w=; b=hHoJy0GdpI7sLRRp KdIXFy54L+WbOkJuva/pydKLahhMIbTrT7EOhyvxEcyKU+kcideHKBtKSLS4iOxn NCrfvAQXRkTUaKYfB8FdYIGkJGgR2uB7lui6QOOqsbvTlgPckoDLTgvQ3RmCpcUV KYxAGg/nARMOdXydXvycoyNfaNTO3wqtuNyn3C7UPPLZmwJRhuj/EY4icm8RjKwh 0ZnFk6fM/DjAcUywvO57E6/taLYAFWB2yaVKu3Lkw2yl2v5Vc998/H1sHRI10Jqw JUY6sZb3/TOeczq3WpbwYpJ4TjFf8mRl+jpeZ0WTkW/o2vw4kXvQJ4L6gqcrD/+z AYx4tw== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4f44wp1xwu-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 30 Jun 2026 10:39:17 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-92b79cc1f21so112714085a.1 for ; Tue, 30 Jun 2026 03:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1782815956; x=1783420756; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=u+IixcZnrCq0YCBcT04603GxKzb/cwi1U8yD4nVob/w=; b=g79XJbTgTFexJZFDoRNQ60kIsPDQB77x3IpVj4bV8cdpumnkIBvHDeArnw7iSx37tA du9JlspbNAwjLM2xk0QIJWbJ5pvd1tYcdENbSj8iuO8KVT/VUCPOvdnmJnZtCqGcUAuK 4oHU4ubHAbfkuIjEvSTEdP8hiPgX/teVp+aeGQMPXtRL60HI2xp/bAYsLv0RaeFfMai4 K3OrfSJ6Op/thI8vIyoZs/Sz0Dx0AMsJE46bPCHvR7VbWmSKWqxrmu9yfmTk4TS6iU4+ w/R2XnbBW9lhUbH8TuhEEsmv2K6h4Trl7ANvLc730Y/zKcPVCHiNguziK2M3caIdh8PV RuNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782815956; x=1783420756; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=u+IixcZnrCq0YCBcT04603GxKzb/cwi1U8yD4nVob/w=; b=B/BBN4dBn+sgI8EHLHd7rf4H2tv9vJC8Y9mAz3u5DyU6i2XuUxu3nAp+D3gjDs+Qrd 6QOJtVWnYanxWk4NeTf/M7500Zo0+0BvH4o3DCpjUZW1kO/FgEReEYQwARnGe5eKD7mV crHPHSq4RGdhTbFjQ2mnpdpsojNLoPY+8ThMNPVCKwQkxHK/iR57jLRICwpC4EHhg/cn 4pNINJClf59x0hCcQ6B7SH3ilkIQ/sQwzQLe18Nz0VWfCH1sT9SlvQv+o0yBe776vWPx eN85w/5D1WeBLBX64JvgqrnniftW7TPpczfdlNyTx47HRZ7+0Pub0m+n4dQx3SNSFFWw KkuQ== X-Forwarded-Encrypted: i=1; AFNElJ+m8YCuNaBcOZpn0pzt7GMYjNbPbyOqUSuCDRaBe/lEfB5em2Z5f572bWzu8Mqxr8auQePHxthBZkxL/m8=@vger.kernel.org X-Gm-Message-State: AOJu0YxdyPoAskOvsrNFRZL7H4t0e2VwOs1qdVERewejWswyRa3KFJjl W6pEZodZNLckuwF1jv2Ds/n5rl5OSDkTchtWyNPmSjfiJyfLzeTyD+Jaku8M5IIdUAQjA4MhgE4 cn+28pA+nNMBqnY8q7NAsFeLnURLxJ3AqodYyT7feRD68yUS8HR4FaqiLHVJaVai9FEY= X-Gm-Gg: AfdE7cnibzEqhvgFk/Xcfpv1hnijG/x/kXvKXj6C7xZUE7R137+RPF38t5mOLIimRU4 4gDLYWiEp7LtsJy82cXsBIBaKvJPudh4f93KUzp3Rqdfru4CwBJB8hyVNO/IMFV8nKDppuulcJS qRHYNOhhSbblsFGadT2s8a/pTBPBZsF7roi54lTd9e1tHbm+LhTq+zCuszIEeD/9Z5F3kwUMyKf A57jSxLSBdFbeR7D4DtSb27oA57ACq68h3Y+owpN5ERW0J0OtTleNrEIV7Yjc77/v6QxoLAZpBq 4u+DZ1hgRIAd77FKveGVRIfEBTeLJUBTZi/WVqjV6uthzgxIICHw+kcDTKG/2DNMp386Ezy4ulM Ce9sjV0iXrDrDkUP8EHXMGx/4GpveBECu1pw= X-Received: by 2002:ac8:5e52:0:b0:51c:f3e:781e with SMTP id d75a77b69052e-51c108197a8mr23711121cf.6.1782815956083; Tue, 30 Jun 2026 03:39:16 -0700 (PDT) X-Received: by 2002:ac8:5e52:0:b0:51c:f3e:781e with SMTP id d75a77b69052e-51c108197a8mr23710881cf.6.1782815955621; Tue, 30 Jun 2026 03:39:15 -0700 (PDT) Received: from [192.168.120.170] ([178.235.128.140]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1288f47394sm101229866b.43.2026.06.30.03.39.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Jun 2026 03:39:14 -0700 (PDT) Message-ID: <1c5c6399-e4cb-4d33-8fb7-fdfde0b33e19@oss.qualcomm.com> Date: Tue, 30 Jun 2026 12:39:12 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 6/6] firmware: qcom: scm: introduce keep_mdt_buf flag in PAS context To: Mukesh Ojha , Bjorn Andersson , Konrad Dybcio , Mathieu Poirier Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org References: <20260430191253.4052025-1-mukesh.ojha@oss.qualcomm.com> <20260430191253.4052025-7-mukesh.ojha@oss.qualcomm.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20260430191253.4052025-7-mukesh.ojha@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: zJXDb9Bpn4i7DSMUSTBxOkjhzfI9wZiM X-Authority-Analysis: v=2.4 cv=AtDeGu9P c=1 sm=1 tr=0 ts=6a439cd5 cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==:117 a=PRfkaYvzSr8QmIIGAkY2Sg==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=I3VYQ2l06oOMjfKrlQAA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=IoWCM6iH3mJn3m4BftBB:22 X-Proofpoint-ORIG-GUID: zJXDb9Bpn4i7DSMUSTBxOkjhzfI9wZiM X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjMwMDA5NiBTYWx0ZWRfX2PCjiLEPUvUp MZpBvIH9fO/erwTPmRx6D5RBgt+MPhhkO2ZRsnMlWj0iq1gzS49irVTT+iUcd+dLzOOS5RrgTKN ztzo/W+si5YIubX3+jLx7faKTTS5cQ7Mal+u5xwgfCNMUTfdQBTtdBgstpQOvViSqNZ4KirGgG+ U5HhmJ6GjJefOHd1LoFA3dlZNtkQCKXUOKK1qAwdAvad9fx+JQ3SNMtFhovWm1lpLR6aWK8Vv0x SUr1L+07kCLMH2I0d+NMREQAXXHQVvhipF1fRkFuymwx2iaf/iEwk7Zzi3rQYXRRmlYN/8ITPsm 1tpICcNWStMHj2RGgnJMTmQhbm8mU6VJEJvEMoN2K/IcwvSHqiAR7he9DJ4unFSrtCCQakYam3x FYPDBcbzFJt2SfGaW6x3UnGLja8qHDXJzTTBFPD4BTpo8SHbdU4qi4SEMLww7AmL+TsrbsjxBr/ ucZSXlKbf9eE6hBgJVA== X-Proofpoint-Spam-Info: AW1haW4tMjYwNjMwMDA5NiBTYWx0ZWRfX2H1tzEBiJaWK Qjjrrnpb0EuQ+HsjLJJ7ysSNkU9y47tdI5EJMnAU8YOU8Hk85EacVTlg4DPwa0cQCP5IoDwf65/ 2T5/Xin0C2dbUBLPAtAtRE2EvN+7RRA= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-30_03,2026-06-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 adultscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606300096 On 4/30/26 9:12 PM, Mukesh Ojha wrote: > The PAS image initialization path always retains the metadata buffer > when a valid qcom_scm_pas_context is provided, even if the caller does > not require it. This implicit behavior leads to unclear buffer ownership > and forces new users of qcom_mdt_pas_load() to manually release > metadata, which is error‑ prone and incorrect. > > Add a keep_mdt_buf flag to struct qcom_scm_pas_context to make metadata > retention explicit. Metadata buffers are now freed by default and are > only preserved when this flag is set. qcom_q6v5_pas enables this during > probe for contexts that require retained metadata for subsequent PAS > operations, while existing callers continue to work unchanged. > > Signed-off-by: Mukesh Ojha > --- [...] > ret = __qcom_scm_pas_init_image(pas_id, mdata_phys, &res); > - if (ret < 0 || !ctx) { > + > + /* > + * Some clients still pass the PAS context as NULL. Until all clients > + * switch to qcom_mdt_pas_load() and provide a valid PAS context, check > + * for NULL before dereferencing it. > + * > + * When a valid context is provided, metadata handling differs across > + * clients. For example, modem clients pass metadata to TrustZone that > + * must not be freed until the authentication and reset SMCs are > + * invoked, as the buffers remain locked until then. > + * > + * Other clients free their metadata immediately after the PAS_INIT > + * SMC call. Therefore, keep_mdt_buf should be set to true for modem > + * clients and false for others. You say this... [...] > --- a/drivers/remoteproc/qcom_q6v5_pas.c > +++ b/drivers/remoteproc/qcom_q6v5_pas.c > @@ -669,6 +669,7 @@ static int qcom_pas_alloc_memory_region(struct qcom_pas *pas) > return PTR_ERR(pas->pas_ctx); > > pas->pas_ctx->use_tzmem = rproc->has_iommu; > + pas->pas_ctx->keep_mdt_buf = true; > if (!pas->dtb_pas_id) > return 0; > > @@ -688,6 +689,7 @@ static int qcom_pas_alloc_memory_region(struct qcom_pas *pas) > return PTR_ERR(pas->dtb_pas_ctx); > > pas->dtb_pas_ctx->use_tzmem = rproc->has_iommu; > + pas->dtb_pas_ctx->keep_mdt_buf = true; And you set it globally for all PAS rprocs Konrad