From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 EFBE2446836 for ; Tue, 4 Aug 2026 10:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785838276; cv=none; b=pu/ZHVu8yBHbZGiXuvKIt53UqMZKXZFKhM62ph25jnT+e5pTw7iCL5+HhNia/sLza4rOn17WNyekPqQJYilXl9XK5z16c2LOTDgPcf0U+WAIEvwLquR58gq5uVglnYFi/S+9fa4OMQzDXqOudQdxfWAS2TZrWjDWnmvk5oMMwM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785838276; c=relaxed/simple; bh=ZIN4AB3H19EpeGemtzBMBcHpqh6iylI9p/IA4nT1UOc=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:Cc: In-Reply-To:Content-Type; b=dBq8ak79O5cbzFHXXAb65wbB7vLycAQix/ttu4vBGRU63NKhP/lmpnRxYDLqWCBj+eKUPvUPm1IkLt23UxI81ZKwgfWAldhMzqdTDuGgfcYywIHCcJ3XaoikBENhrUlZxXzMXYTMa7fN+DX6vfE9f5WPHWd48Km/Ikg6OV7tOew= 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=W5PNkzpG; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=kxtXk2Ko; arc=none smtp.client-ip=205.220.180.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="W5PNkzpG"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="kxtXk2Ko" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6748CG7g3546093 for ; Tue, 4 Aug 2026 10:11:13 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= 7S4tgahxOSinB3HPtJChGJl3G77hB4eJuWb6cUOxp18=; b=W5PNkzpGuM+eYUXQ I00oa4RlGj1L4i3AIS4ObH6GVLJiu55Gfoxgi0OfJ+uzRmh5p63pLp6qa1zLlcrb 75Hwqt2HvbFubeEdsRkDkeLvKj88y+4a1LrIQ6MTcNVAn6FsMAKtAF86gxlYKh7K ScmxbF9H7wU5VHGM05X0JBpJKfA3xeVfdnnR3V4B/Mo4cD2e9sc9tFs4mh0A34nc ADBsiFPaU+/rO16nrSpm377cd7R9YkJOXTqS2fUSo/bgunx0rXryY/riDgMye0f6 lE+4YhwotpyktqnQa2nz9HogsvuxE0M2gAc94tGSyqcV8FSt0HUv5GWfKD6iYB+z j5An5w== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fu3vs2dk0-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 04 Aug 2026 10:11:13 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-848474825ffso1148414b3a.0 for ; Tue, 04 Aug 2026 03:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1785838273; x=1786443073; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:cc:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=7S4tgahxOSinB3HPtJChGJl3G77hB4eJuWb6cUOxp18=; b=kxtXk2KouLge80vEjEpRaVB+TtN6LbYIV9ZIpy7/SqpmrDvMlG2BIE1AlJAAHamqJ9 jlSt7sU10pLOknCi/7fBeI0/5xpZlJRdpz24uk4XXWOIlUcgkZuvMqG16/DwAbWCB+nf Q+LxRl3lkjn/kHyLHDtbtJGcx3474p9NbUJBIs0Kv9doVUvw9pj4wO2IfrYs5GFTxuz0 Vd1eJTfjMyPpyA3GrBsQN5Zc3l77g3zkv+6t7B8XlUbK8b+NrPBWig8AIH6O51Br5qKw BvQMRzgau2E8yr6j6eKz1mK3aVF6+E7vjOu/L6+zH9bOHHd23zdsg2v+c40zp4KSaftk 7AXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785838273; x=1786443073; h=content-transfer-encoding:content-type:in-reply-to:cc:from :content-language:references: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=7S4tgahxOSinB3HPtJChGJl3G77hB4eJuWb6cUOxp18=; b=mr718lWGGhSx4k+GeSGUYrdUKVRxoHr2OixKqQWXkkZJDptmiziGpgxzNup9rCJ4Cr U3pkYPFbswGtqDjrRqBFF6MJCD9dmFnkGblsDz/Q1pfj3+57MdWWl26j9JDO5fEEa7St WuXXnUW7G4U6B3uyGh5Y6ExUUi7v1j9cMbxQcCFW+PWyRKC6qXyZRqAhYtX9sgLpAGKc SLUgtOhUpAfQuAhMSp25zBBzgzuVethExSj330aiXWwaF8vjw+xPaNNaRB4RsYqJjwGD ia/PZ8jSIriD9GSB2LZtsvosrvpuNQEIvSMkF1GYEJwJdZwnVFbnK+urK87lZvd60d2I N8Pw== X-Forwarded-Encrypted: i=1; AHgh+RrBv4Q3T+R5mhOESK/2sw2xy/KddYaTEi4n3MwqvHly7a79YnCo+z1RhdJDBdpk0/ImEHVtQb4P+zEl48U=@vger.kernel.org X-Gm-Message-State: AOJu0YyCK6t8Su9b3dZLC2bFYJQgT9NiGXCBznM4ww1DxyyCTkia4mW7 FaqNWVsLsyJ2hL/WCoBeINM0uovAiUJ1jeK1dQKB220G/X9fSVqD+G+XD3mR9t+FazLQzDRJpVg gWcYzAf83sxpOwHVGQdZtrJx+9iQhHMbufxi1PUAMrOmItYjNHVo/xaObZ9Ix5mjLAeY= X-Gm-Gg: AR+sD127UpPrDUOXw7Q+A62GZ11dhc8gQ7DAXzeGW65hl1QDW6fiZwfQxIm4JMR2DiN RckfJRM0BO8Mj/6tT7pSyyNC46VBNS6fLrglwyJ4Qp85aSoGY/27KOc9aP8yH7cyOcFWZH+MLTJ zMqKK8KoIHQG45fCthJ8IYdvncOkcPWyvbjemRA0684VfA7vcLvjV8kTlw1OARCI52iGbABtcVE egASHvVsmSp8J6dlhDpd5ev5xjGqSNfw9RNNw5BdEdww+5yOjDHnugn0NROXBmuoSjTQUFArUqu w4BFY3srWOBTbWlRpC9Q8kMWJIDjwcqYnKGoauy/yW6ecRG0CaR815P49iPd09K8+bl3pT8kCb3 Ud6yLPzMb0Kx+Hmgkuoq+OY7+tkh3Ms76df/HACOhdBmzGt1HQOHdhpAcETQtFmoA9iaybA== X-Received: by 2002:a05:6a00:9a6:b0:848:48d0:934 with SMTP id d2e1a72fcca58-84f1cb6b1e1mr2636469b3a.18.1785838272654; Tue, 04 Aug 2026 03:11:12 -0700 (PDT) X-Received: by 2002:a05:6a00:9a6:b0:848:48d0:934 with SMTP id d2e1a72fcca58-84f1cb6b1e1mr2636435b3a.18.1785838272142; Tue, 04 Aug 2026 03:11:12 -0700 (PDT) Received: from [10.249.10.23] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cbe396ea57dsm5003406a12.21.2026.08.04.03.11.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Aug 2026 03:11:11 -0700 (PDT) Message-ID: <2da7893d-96e3-4f80-966d-3632329c3e27@oss.qualcomm.com> Date: Tue, 4 Aug 2026 18:11:06 +0800 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 v11] misc: fastrpc: Allocate entire reserved memory for Audio PD in probe To: Dmitry Baryshkov References: <20260731093210.473-1-jianping.li@oss.qualcomm.com> Content-Language: en-US From: Jianping Cc: srini@kernel.org, Ekansh Gupta , arnd@arndb.de, Greg KH , abelvesa@kernel.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, quic_chennak@quicinc.com, stable@kernel.org In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODA0MDA4MCBTYWx0ZWRfX6+gI2PRZHhvj PzrwOddPkmlB6ViJYdTgtho37FDt/K0HbcKA/e3O+QF/cv6EKz+GJH/1TUr/woNNSjzWc+NzYNQ ZCE6a/MaJ/aa135sC0Y8Q9RDgSXujw7qvq9xKBxmEqTI59KRpDo90sQNzfdwWFMxBYuaLpKv1UP AoxafHTSybMST1yovO0+MYEku/ZhJDPDh6Buub64HSR1M2VJ8K56ril4lIzLcTc6lI+trtidgVy AMYfxHcBs4mqBH/67fB6x7zm84zIj4F3FYN4z1R/EIfjZPL1YxKgDafRns48eSrtURn9vJtE/NV 0yleiwDW21CSql4IEnkEW4jXraPdDDgnUUclbrov2QSg8QjbkWvz0qqF7Zg/WhkFJjONen3kE1V vbIyATt4Zg+JVlNGesT+H+X142vT8hlbzyOPPUOnVUUdR3m4SH5gE6wbpBn48hFk9bnGZAi0t9u e7Lt72i7oLFnLDiriXg== X-Proofpoint-ORIG-GUID: yFmLcaYrzANbqmoexkHwVUErsb170TpA X-Proofpoint-Spam-Info: AW1haW4tMjYwODA0MDA4MCBTYWx0ZWRfX+s6GLvxFL6HH C/Se9v3CcIFJccHW08uUOiQR1Gl9bL8v5dHAfwVEjR6f/UAoQE0wDJWfYdVDkJtcyCxKEvV8sTp AZZEThF4ZdZbVwtXIglmdm9Nwl/cMYg= X-Authority-Analysis: v=2.4 cv=EK82FVZC c=1 sm=1 tr=0 ts=6a71bac1 cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=4ZsVrytpSORdhRWgdAsA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=2VI0MkxyNR6bbpdq8BZq:22 X-Proofpoint-GUID: yFmLcaYrzANbqmoexkHwVUErsb170TpA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-04_02,2026-08-03_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608040080 在 2026/7/31 22:17, Dmitry Baryshkov 写道: > On Fri, Jul 31, 2026 at 05:32:10PM +0800, Jianping Li wrote: >> Allocating and freeing Audio PD memory from userspace is unsafe because >> the kernel cannot reliably determine when the DSP has finished using the >> memory. Userspace may free buffers while they are still in use by the DSP, >> and remote free requests cannot be safely trusted. >> >> Additionally, the current implementation allows userspace to repeatedly >> grow the Audio PD heap, but does not support shrinking it. This can lead >> to unbounded memory usage over time, effectively causing a memory leak. >> >> Fix this by allocating the entire Audio PD reserved-memory region during >> rpmsg probe and tying its lifetime to the rpmsg channel. This removes >> userspace-controlled alloc/free and ensures that memory is reclaimed only >> when the DSP process is torn down. >> >> Validate the presence of the Audio PD reserved-memory region during > > This will break compatibility with existing DTs, which is a no-go. > Existing DTs _must_ continue to work. You're right. I'll keep the existing behavior and only use the reserved-memory region when it is present, instead of failing the probe. Also move the check to create_static_process > >> rpmsg probe and fail early if it is missing, so that a misconfigured >> device tree is caught at probe time instead of at process creation. >> >> Fixes: 0871561055e66 ("misc: fastrpc: Add support for audiopd") >> Cc: stable@kernel.org >> Signed-off-by: Jianping Li >> >> Patch [v10]: https://lore.kernel.org/all/20260716095847.479-1-jianping.li@oss.qualcomm.com/ > > All of this should go under the --- line. Ack, I'll move the version history below the --- line. > >> >> @@ -2584,12 +2547,22 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) >> } >> } >> >> - if (domain_id == SDSP_DOMAIN_ID) { >> + if (domain_id == SDSP_DOMAIN_ID || domain_id == ADSP_DOMAIN_ID) { >> struct resource res; >> u64 src_perms; >> >> err = of_reserved_mem_region_to_resource(rdev->of_node, 0, &res); >> + >> + if (err && domain_id == ADSP_DOMAIN_ID) { >> + dev_err(rdev, "missing mandatory remote heap memory-region\n"); >> + goto err_free_data; >> + } > > This is what I mean. This has been working beforehand. It must continue > to work. ACK. Will remove the checks in probe and ensure probe can continue to execute. > >> + >> if (!err) { >> + if (domain_id == ADSP_DOMAIN_ID) { >> + data->remote_heap_addr = res.start; >> + data->remote_heap_size = resource_size(&res); >> + } > > Too much of the spaghetty code. Can we replace all domain checks with > the functions? I agree. I'll look at introducing helper functions describing the per-domain capabilities instead of open-coding ADSP/SDSP checks throughout the driver. > >> src_perms = BIT(QCOM_SCM_VMID_HLOS); >> >> err = qcom_scm_assign_mem(res.start, resource_size(&res), &src_perms, >