From nobody Fri Jun 12 11:28:12 2026 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 662C4360EFF for ; Tue, 9 Jun 2026 02:59:54 +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=1780973995; cv=none; b=iVsmZEY90huRhAvkBfTozMZ9sPrOmm5a3R1KUEMWTySGDMYZcoBQyRhnVtgTjC+OiP6qtzls8w3qlWQ+NQ39uTbZRE88ByakvSCLkuXobXkvr3fLQgDP2+gaQSlSAqnUuuqYdXSOrA+1pLwLh4kz/Y/+YD2LSR2O3CyXUeHCwe8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780973995; c=relaxed/simple; bh=4ulHOYGeyAaC+y+8rxA9T8W7h0nJpUcBKdMft56n4jE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PLOdMzS1WrCMqDugC9jVph8G5Wc/q7Qv0sBJKczQYLLQZ1LO6GF/mbFH0Jp2aufGx2RyU/iwjvtC2AYmDBUjvJ1UQSuM8B3qvS/tFUYLYH2vBSpmnPefDsteBFcGNIrs0Ga8DWNDjyoigydMkc/JdsZrxQKuFq7ztF/BU22I5G8= 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=dGE99MM/; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ZWj5uHEy; 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="dGE99MM/"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ZWj5uHEy" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6590s4wa995988 for ; Tue, 9 Jun 2026 02:59:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=IJDGglN97rh Rw4+XmxNVKbWIstzQQy65lHqMCInbHtI=; b=dGE99MM/oChVybdXdmUi7Nz0qDk 90aaTHO3oDtMpnhajzqDa5znAJXJBHqZKr0UdoSmeXJ0rQGzkaOJ5rC9kVJZfaEV xn8HY21OVj0Eeq12oKe+cgtSZOr3t/WoJZAr5bLekqMIJEo5yrwlI9h4fk3jBvOV B/GxHST5SJNu3tWY02gBB+6BLMu8ZVlUwFxRiXOnah776zhsQNxwwJMTe2tEiZwG Soz6y6xlr0cudwaFtT0pAYLy/BY8OD2q1TaqCmUur/QFfoEXK87cPGgxgTTjqxJB SV2AivpCZoqN6dIIQoEoCvjf4k+8tKZVto6CJQWlncUfV4hMmPhboNoNUUg== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4enx2rudy9-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 09 Jun 2026 02:59:53 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-36b982ec338so5869116a91.0 for ; Mon, 08 Jun 2026 19:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1780973992; x=1781578792; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IJDGglN97rhRw4+XmxNVKbWIstzQQy65lHqMCInbHtI=; b=ZWj5uHEyo6fx2I3ZuzplF83yvd9cqxu9FUV66ZYrJgWtBUqrbQ6XHwrzpIeVPyUFcH NOX6OYB0FfMEuBfHOrUk81nebz7soQkaay6j4dxbfsxTKNIa1hNhao7NEd0eGo0+mblp xog4zCTXJvJujXqd9srMsxgfgp+nBYSOOi2/Iu1hyYoVPg5bSQmLCTDmXjs/1qJXB9zM GsJj4kSXLYpGeDamWv9ynuG55HwPaPc3HFwH/g5c9OGYrwUW/p2rlGJtj0W+KyIfn2gG wNdBsb5+npi5rRVWRsxi78s5Ae+A+5nAuAOsVqS2sWuD58FNuo8CeTGWsEsa1OR2CVeC 90hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780973992; x=1781578792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=IJDGglN97rhRw4+XmxNVKbWIstzQQy65lHqMCInbHtI=; b=mE0hEUiaNsuflYwCuy4i9FOs+1LeQ9rbbrAec08wI4R4ebrA/498sTGRGf5QN8uhJo QnE56v5PW/g6meXs0FxwKXSSM0MaQ1tPc+/+LIwuBeLOhHHREDfPWds9rRzui1xKmFsf rrCnrJ1qXRLEYh7Wqoj3Wkf+7Z0gxuhbWeusgpfHYfF6uOqNya0HgP6WOuvHHjONzMtB 1stANNrIj1pOq2G6fPu/yQMOQRPJqzqPW8UKarlV2TLZn0gWlU+RKZn6YO00pPW9B3kX HhSZWb2hT0i2D+s+3t9LHMlgObTXh9bE/iVoZu4hFnE9ofUex1J3c0LQYIMJ6PN1TzaA JSpA== X-Forwarded-Encrypted: i=1; AFNElJ+mpXglcvME6zfP40hCCZUSokDpXoYIkR+BcDfLKqMnXtPCsEIyn4ftJlkJ2GvD1AjVNez5Q6I6bUSBp8g=@vger.kernel.org X-Gm-Message-State: AOJu0YxwMGG4vdKQSPZTG1A+A34PyBOOcHzUZizmYnkcuCNXnP+D3o+D QdxX0b+y1uMHEc+4EV+ZA80BLc0EKCHoWpaHF9F8TY0TCLiLVDRs0Vd0koDQjWLqFQBHyXkXv2f 168ThSk7+SUGpnAdzYxLiRR51sR1XgGmEy39g4bDpTkeNK+0wOKJhXaNSfYSni4R/P0Y= X-Gm-Gg: Acq92OFjTSZpanWmD6t/WTSfg2dggo/dSOfEnmKwYHLReZQ/5KKU+H/zJmBDFa78uzI dErERWkDtZRliFo4PFJ1tj2ct1FgD9PvsynTzzNK+B73i3uF9/sF04NNJqCDsQ7+mNgXYQ9upB8 LU1P35USf/qPAxHB4AB4GFZ9zQlVJwpjwkV1bsauai4+vLI3oiHBHLh4Z+mzIBdy+SBeJYTTOT9 o+02ktfcryns0/QnM6AxTfJ04Wj/h6PZA+CxI9Vg6CQvMYRgC2dm7vRp1eFSJ2xgUX2kW6M+Gve hxiwtcH6t5Vmol8VA06vDWZfyPFCYuVwfU9Khmw8KQb8CL7aoLYslv5wyI92lUd0f6Mjkzovwk6 0dr/ksfMh7EUAkYvI4AdqSoMlYQ8jwLnYgqomX+aFZHRy/b5l4VV5BwFbr8HuFAjjmn2MeTBCTb gGTIZ2WfpGz0/OHfuoqtpnf5wk+BMm X-Received: by 2002:a17:90b:1801:b0:36b:bbee:fb28 with SMTP id 98e67ed59e1d1-370ee33d0bcmr19282619a91.2.1780973992236; Mon, 08 Jun 2026 19:59:52 -0700 (PDT) X-Received: by 2002:a17:90b:1801:b0:36b:bbee:fb28 with SMTP id 98e67ed59e1d1-370ee33d0bcmr19282595a91.2.1780973991684; Mon, 08 Jun 2026 19:59:51 -0700 (PDT) Received: from QCOM-SocCW5bzXR.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3712fcb2607sm8713835a91.0.2026.06.08.19.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 19:59:51 -0700 (PDT) From: Jianping Li To: Srinivas Kandagatla , Amol Maheshwari Cc: Ekansh Gupta , Arnd Bergmann , Greg Kroah-Hartman , Abel Vesa , Jorge Ramirez-Ortiz , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, quic_chennak@quicinc.com, stable@kernel.org, Dmitry Baryshkov , Jianping Li Subject: [PATCH v8 1/4] misc: fastrpc: Fix initial memory allocation for Audio PD memory pool Date: Tue, 9 Jun 2026 10:59:35 +0800 Message-Id: <20260609025938.457-2-jianping.li@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260609025938.457-1-jianping.li@oss.qualcomm.com> References: <20260609025938.457-1-jianping.li@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: MpQix5AenkH3c6KDPdnZ-AqBGpH5NbyV X-Proofpoint-ORIG-GUID: MpQix5AenkH3c6KDPdnZ-AqBGpH5NbyV X-Authority-Analysis: v=2.4 cv=JdqMa0KV c=1 sm=1 tr=0 ts=6a2781a9 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=VwQbUJbxAAAA:8 a=bIEaOLAPTWlh-3IGMggA:9 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA5MDAyNSBTYWx0ZWRfX8O8R7vJlm7vz wmP1SxOViQdblhFvAHSpFN7aiTjj+SMm/Y/fn6hEqZB3g4Qg64NcLBU4R91U93Wuu5Nvp0wefDs JesP9QFae9qwHwzTeW+Zk9cbxzLz5N+RKvwUSMAqJLSLE/Uw87C8z9+WEyJdn/ZaqxhrdTT/fUs uZEjk3VSlBqoqflZaFYsgVoEvAlLXnwZ01obd4jHqE00UQno/f5Fy9b+JGDIraL71XppkqOpeEP oacPACMBa1qQtdFSdK+km6gzqDYtf4qdIXDjZSaUBt/hBq+WI2BbSrUAoA4dE5CXvXORswH7RRF GV8LyJaGCNaWzTzsNKhB26/MADJjOxuNGmk+p1GMwcb3pDpTShUtnytZh0e6Q1ddstX3jt3Os0K JNIR49D3gNTGPeZ2OAQlHXBGR9L4yr5KluPFUCfhK/k08N8qXL9c9jxj8pwcwTh6N26hkFmO9ma DigeMw1G1m39pNAqYGg== 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-08_06,2026-06-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 phishscore=0 adultscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606090025 Content-Type: text/plain; charset="utf-8" From: Ekansh Gupta The initial buffer allocated for the Audio PD memory pool is never added to the pool because pageslen is set to 0. As a result, the buffer is not registered with Audio PD and is never used, causing a memory leak. Audio PD immediately falls back to allocating memory from the remote heap since the pool starts out empty. Fix this by setting pageslen to 1 so that the initially allocated buffer is correctly registered and becomes part of the Audio PD memory pool. Fixes: 0871561055e66 ("misc: fastrpc: Add support for audiopd") Cc: stable@kernel.org Reviewed-by: Dmitry Baryshkov Signed-off-by: Ekansh Gupta Signed-off-by: Jianping Li --- drivers/misc/fastrpc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index a9b2ae44c06f..96961217b856 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1370,7 +1370,9 @@ static int fastrpc_init_create_static_process(struct = fastrpc_user *fl, err =3D PTR_ERR(name); goto err; } - + inbuf.client_id =3D fl->client_id; + inbuf.namelen =3D init.namelen; + inbuf.pageslen =3D 0; if (!fl->cctx->remote_heap) { err =3D fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen, &fl->cctx->remote_heap); @@ -1393,12 +1395,10 @@ static int fastrpc_init_create_static_process(struc= t fastrpc_user *fl, goto err_map; } scm_done =3D true; + inbuf.pageslen =3D 1; } } =20 - inbuf.client_id =3D fl->client_id; - inbuf.namelen =3D init.namelen; - inbuf.pageslen =3D 0; fl->pd =3D USER_PD; =20 args[0].ptr =3D (u64)(uintptr_t)&inbuf; --=20 2.43.0 From nobody Fri Jun 12 11:28:12 2026 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 6171D35E94E for ; Tue, 9 Jun 2026 02:59:59 +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=1780974000; cv=none; b=nvXiOmj1Nk4eLD1IpDX5t9vhnBsOS/3ADiFQeKaEj3NPZCajr8VTrhnCFYCjrPCGuu1oybdJuyrKTsbqRDBfRWN4mbRXGA5vnTVdklEhijYUa5ox7ZXfhzKOkzRoxIzWeV5E1NSLbeFYoQVk0ke8FM8ZoSjEFsA5aCcDzCAiTgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780974000; c=relaxed/simple; bh=J9nj17thOlGzPahnaTqDVNfO8rb0kLcDs2KR7R3KsRo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RWZJYdCQUKJWC54oqkCa8zVI/byyovw/Tv1fKnqDaROA1Xwy2wQ67qjhAbqxA0LhTbgdjHZZcWnZdgMAHm3pnVfzpK7WRjTTG4vBymVPOM1N0eKRrb9E6t4wxbN3UH6n+i4goKGRRsEhDjUmMlfQ/A5MXyZppHDlTaXK4hpdY1g= 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=QT6cHTm9; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=jkrHqh9w; 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="QT6cHTm9"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="jkrHqh9w" 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 6590sGX71074587 for ; Tue, 9 Jun 2026 02:59:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=ElYvFMoGdW9 Bjq7mp/Mwc7VFbd+iwp1MQ9hRnfKtsl0=; b=QT6cHTm9kd3vTgLWiwXDjrQp42F vSktu05K//kW+kT1GQCCh2KF68IvTIaBW/boH+OYex8ZDklrq7be68h2kRVZAryw 8uKlYYZVneuNsgAWTTwW/5VdEyVUlChbosaPTY+SJOQqYX3A+NQAq19z4tJ8xrWk 5W+AeN/0tOI8rFqzWDwS4XyT6dpjfkAbxqY1Jt1ywSJo6fmQjKaPfE+frkxRJl+q PZ2aTgYrQMSXVLvy1nZw84HI334Mi4LPHv1An6rbNBg8sCsdl64D+3bbna1dX5fe aYKpDryfpYyJCKGSviwSrXP0tT6iSYfpq6r4KR3DjnuRiyD0jCt+Vg1I+Qw== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4entr0mc1x-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 09 Jun 2026 02:59:58 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-36d98b76d12so3482646a91.2 for ; Mon, 08 Jun 2026 19:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1780973997; x=1781578797; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ElYvFMoGdW9Bjq7mp/Mwc7VFbd+iwp1MQ9hRnfKtsl0=; b=jkrHqh9wl0g6s1ZYoMBmbUUCG1ldwXg3Oj8bDraUCh0zGqF+V68g3jnqwqA1ZCfsmh iyKpuIFoQM8k0sF2IUEdgxoe6mP0iv7JkHwmi7Au5WetWEIQTDqIAqXLM5I0GHpfb/nT lz5qv32jevhcACBm0d+01/vgaR+zFmBhiHiSmBZAmVkQ3zs6nBoveU/f/n1aTAFjSfKI i6eX5pohvxX2PNano28xlus01iY8Cgnx9vwilVM6vxWc04NX4ZIe7ZaWlvbWz1mPATKh OaKtI0Z8gQog7ftp+qxnzIOL1hMyqNK2W3QLcrLRZvqSh/T49djd8pO8X/iClcOQrhsr 8hWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780973997; x=1781578797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ElYvFMoGdW9Bjq7mp/Mwc7VFbd+iwp1MQ9hRnfKtsl0=; b=B0TqU7hYe98MtDCge6Xad5onGx/KVO74zqZHRwyxj51j3eaInPIfk0SaIGxxyB55BD dKfWL4QybJ+kiyBgZh0xnwwtOZAF9imeXFMKSC3D1t3I42Ur1TWGJenUtNgMPCQVwuO2 8kjpYbMmd09IP9l8ip0tf+q8WaYNQfEORKGPca90xFQ7Ubf9RMige0Y+NtfMrOYKtHaS sHhGfXTktPWe25SnJ3PAnrODY17lUTUVMR6JjoYDmoLFOT5W5QKS9/3aSMhkvy1HmzAW pXNAGXQ+s+FAgwavQTZsGP8b31Xutn3th6yERGGaUPUJSnCn7buJFlrOWfeSTH1/eFKv FXgg== X-Forwarded-Encrypted: i=1; AFNElJ8Z5t04SFtTTfL7wKIamn5QcQ8R8x0eqQfB6kVLdc7zrpAa4a9i/pv5YD+8dXYSehML5K7DC4/c9Dib7OE=@vger.kernel.org X-Gm-Message-State: AOJu0Yzab/LlXJww6A250VgxgxNdjgzDpk3Nj83zGSrJQYk3M7aNyWHj y5CRImQPHXrA2nDVTrk1wNFKUvN2ubhSvpH2fyklf6ut8Iv66mOUbXk0sHDIBRLjtPxgMWzd4uw 0uFGpuKch+7IZfVdGEYfpQ3njxMPSogQXzLEziVIIMLp8Boz8QxbJAP1jUlWTL4fy9O8= X-Gm-Gg: Acq92OFKaMMTLUiKhvfTcEyL7ccuML2i0X0ZbcKu3WWtzXLfirNMlQ5fib/7YI7aDoh 2CODpIKClTXkOo0Sm3ksAn+MqcDmGqiMBTXgDdnYP8WNYT0fUSzOGAxANie3mIaI4+rXLbu8E0O bL0n/YbPorEleUcqm63Lfpqqs9oT/V90vX0L5DK1ICId2H597gNJueTd9XxBlYmifN8az47X7SU rt0zld7/tnn4lf5rLZoykli7Brk94wYU3RA4kH+mnJARsdzwTzuCFEiGOpI5+buol5CBydxtcBr sropTnjr4BKCN91tLeBUjL5YEQQyPmUPphoeiGGuZwvPsA0r28EPKCbawQywU3Jo9BBnttNTqE3 S4ShoGXBl3WRt66nATnY1HSW52BEtwXholimno861iT+BhkllEkzl87IK5PkT4a+5/lkEiCmGdc FMxBjAJQRyuO6S8LCoJI4z07+q9/iw X-Received: by 2002:a17:90b:390e:b0:36b:9835:cf96 with SMTP id 98e67ed59e1d1-370ee643691mr18535153a91.2.1780973997401; Mon, 08 Jun 2026 19:59:57 -0700 (PDT) X-Received: by 2002:a17:90b:390e:b0:36b:9835:cf96 with SMTP id 98e67ed59e1d1-370ee643691mr18535114a91.2.1780973996941; Mon, 08 Jun 2026 19:59:56 -0700 (PDT) Received: from QCOM-SocCW5bzXR.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3712fcb2607sm8713835a91.0.2026.06.08.19.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 19:59:56 -0700 (PDT) From: Jianping Li To: Srinivas Kandagatla , Amol Maheshwari Cc: Ekansh Gupta , Arnd Bergmann , Greg Kroah-Hartman , Abel Vesa , Jorge Ramirez-Ortiz , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, quic_chennak@quicinc.com, stable@kernel.org, Dmitry Baryshkov , Jianping Li Subject: [PATCH v8 2/4] misc: fastrpc: Remove buffer from list prior to unmap operation Date: Tue, 9 Jun 2026 10:59:36 +0800 Message-Id: <20260609025938.457-3-jianping.li@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260609025938.457-1-jianping.li@oss.qualcomm.com> References: <20260609025938.457-1-jianping.li@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA5MDAyNSBTYWx0ZWRfX5iFW4LiINeh4 FeATXN15+IEmxITsepQ2d3dWLOJgtL6ZQODaxcktUYAwYcqRAtN2NCoTyB5VefSPyR/NUpobAGa 3HPMorG3myVrnKRQDMC53l795m51bkRY3IITwLAfnEhOyVwm5FuOwqDQkLDWqXCrfAVaLMkWOMg lgf5DfiuqWRVP7BUL6oV525iLq3KMOsQzmcyUapFDcN0wp8Fp42M1i1hr1X8ZbJj+aFcKUbg9WD xF0Dlqwfkqi3VbhJ3zgA9kKVfDZUS7A0zN/nt83Rl/ttHR5RnWN7nQehLii2ssDHRymg9cR/7+A 4Lfr+zkgAogSnfGESZAsj/NyDgJz8chTFttPSVvZ6rtSYcuM9mELB5mw1/3l0fX9taj7RyoKi21 psXNg44MROjhmkyVwAcINDOp6nyyaHIx72EhiV9xViCjpy1eS+4Z/NnCMTravmX5sb59/PEvaLW aWtnh/lVSZxfx7szxYw== X-Proofpoint-ORIG-GUID: v5HJpEhImp7QJOhGI5i9MzZGEi0uLfoP X-Proofpoint-GUID: v5HJpEhImp7QJOhGI5i9MzZGEi0uLfoP X-Authority-Analysis: v=2.4 cv=VowTxe2n c=1 sm=1 tr=0 ts=6a2781ae cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=VwQbUJbxAAAA:8 a=8ZZxLbFAX5vHFMKIXQAA:9 a=mQ_c8vxmzFEMiUWkPHU9:22 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-08_06,2026-06-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 suspectscore=0 bulkscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606090025 Content-Type: text/plain; charset="utf-8" From: Ekansh Gupta fastrpc_req_munmap_impl() is called to unmap any buffer. The buffer is getting removed from the list after it is unmapped from DSP. This can create potential race conditions if multiple threads invoke unmap concurrently, where one thread may remove the entry from the list while another thread's unmap operation is still ongoing. Fix this by removing the buffer entry from the list before calling the unmap operation. If the unmap fails, the entry is re-added to the list so that userspace can retry the unmap, or alternatively, the buffer will be cleaned up during device release when the DSP process is torn down and all DSP-side mappings are freed along with remaining buffers in the list. Fixes: 2419e55e532de ("misc: fastrpc: add mmap/unmap support") Cc: stable@kernel.org Reviewed-by: Dmitry Baryshkov Signed-off-by: Ekansh Gupta Signed-off-by: Jianping Li --- drivers/misc/fastrpc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 96961217b856..517884000331 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1889,9 +1889,6 @@ static int fastrpc_req_munmap_impl(struct fastrpc_use= r *fl, struct fastrpc_buf * &args[0]); if (!err) { dev_dbg(dev, "unmmap\tpt 0x%09lx OK\n", buf->raddr); - spin_lock(&fl->lock); - list_del(&buf->node); - spin_unlock(&fl->lock); fastrpc_buf_free(buf); } else { dev_err(dev, "unmmap\tpt 0x%09lx ERROR\n", buf->raddr); @@ -1905,6 +1902,7 @@ static int fastrpc_req_munmap(struct fastrpc_user *fl= , char __user *argp) struct fastrpc_buf *buf =3D NULL, *iter, *b; struct fastrpc_req_munmap req; struct device *dev =3D fl->sctx->dev; + int err; =20 if (copy_from_user(&req, argp, sizeof(req))) return -EFAULT; @@ -1912,6 +1910,7 @@ static int fastrpc_req_munmap(struct fastrpc_user *fl= , char __user *argp) spin_lock(&fl->lock); list_for_each_entry_safe(iter, b, &fl->mmaps, node) { if ((iter->raddr =3D=3D req.vaddrout) && (iter->size =3D=3D req.size)) { + list_del(&iter->node); buf =3D iter; break; } @@ -1924,7 +1923,14 @@ static int fastrpc_req_munmap(struct fastrpc_user *f= l, char __user *argp) return -EINVAL; } =20 - return fastrpc_req_munmap_impl(fl, buf); + err =3D fastrpc_req_munmap_impl(fl, buf); + if (err) { + spin_lock(&fl->lock); + list_add_tail(&buf->node, &fl->mmaps); + spin_unlock(&fl->lock); + } + + return err; } =20 static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) --=20 2.43.0 From nobody Fri Jun 12 11:28:12 2026 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 DE3E5363089 for ; Tue, 9 Jun 2026 03:00:03 +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=1780974005; cv=none; b=dPiM7P+5xst9Y3tAueYH9DX8hdanlHKfI6ZXnP2WaICngdDEFsreOwHnaNhtb0hvPaC2qq5ILqpz4UuGnyr4Y3ReIjoW1AOe5uT1VdXeYYwF96Y3zLwxn+GEBrY2VhY3rZK+uVtGMfYnvRcq2KaYCuk6lrThQ0JqCadSrW8rAFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780974005; c=relaxed/simple; bh=022V/Cninx7cx1gH4fuokyrh/R4pQocRQgib6USyBTc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WtruLXtgj0csaLecbQp+1umptH0myyRg4oPjCA/NNl0tI5aGqtyQvS+st711nwf/J2ZGRbcSKcdqJ8M8I++Q220fQGHwsgAPoltigKb4x59uAdxP4d2sSK/CcRgvYaXWQ9hOe/c4c9QS5sDfqfrVj3pSCLvR3yTTtBoIPMabHj4= 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=kYTtSGuO; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=S8Ohoo3b; 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="kYTtSGuO"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="S8Ohoo3b" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6590sDZR591948 for ; Tue, 9 Jun 2026 03:00:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=CcVm4LVbeat o9ydc4x9yKkM2AgVmwI4Qp9HLKCz00oo=; b=kYTtSGuOf387a+MlDoOvtQwDhNa bgo7bM/w7cKEw+5Ta+P5ybyKxHiAlYeGZwxLtsqjfUTp8izU2B+EwGh52gad0chK Gx8ewTIrMJWCAaw3+Lx9O4A8L/SGG9dIVoh4DQ9RBZ+d0LE/vZeQdzPrJnTfnOgB YTbAp710EqOX/YJmvKzP3QPTyBrOuu1z16OsHJSrEl1kRpo213kA0Vsu+gD7TJxg oyB9/8pXF9ktDvjQEPx0KDygmysKieKMqrHqbtSubJz3Jpt4u4/wTKMe35Qw3tOD J7zEOVQySVb8A/Xm9Yq/ZKxtfTeLAsj7ukX+ok8kXs+z37sWvhFgaM+Hqfw== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4entrkvc23-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 09 Jun 2026 03:00:03 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-36b7c55406bso3627461a91.2 for ; Mon, 08 Jun 2026 20:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1780974002; x=1781578802; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CcVm4LVbeato9ydc4x9yKkM2AgVmwI4Qp9HLKCz00oo=; b=S8Ohoo3bVVJFYBltExmeBn36WRYnH6hlZZ3gNI1Q1gFRlqBtbxYvyQNwq1M+2pSz3L YP32EgJGyudObl+Jazso0ZyagbRLZX6mZJ+mfu+354ZrHCKHUutY2JMjG4OzaCp/CDc7 ch/hB7WM61I0YWzshSqvnnxqQKdoSUVMS2D2tDmcNmUOa7Df9QMr5UaIcYh3OSa8uqi7 /FCWegkuZ1p3X5BFL91LsvQjBVOQsylHPnNjS6VBhivvtf66zvnWASaO77MpmnqJ8jEf 9x33/1MiIeZCF8kKjdBpeH4CTQQpPblkqOVcQ90UXR/t4AOWS2rPDPXybvJGCR/jbejh Fjsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780974002; x=1781578802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CcVm4LVbeato9ydc4x9yKkM2AgVmwI4Qp9HLKCz00oo=; b=PiKq6eHPispTBET7cthc0Hwhu7rjbiTQwD72FVHr+HwVPNHVZGUuAGqihhlf+DZPaP DCbypkeOzylOxyTHwysm5bZhFsRyKy6zQdu6ogaTG8yeRdeqcZXNpkmadbq3LLsVny9b lQVdBJP2i7Xf83SL4otL334BuAdp6dyLA72nr5qydsos9zOqNl8IRpNNNkS+PUSkwpkn 87k4tRGtN9F8Ou6Q5IK5fJQajjDjViEbKgibDYmrprJskdOK4iWLwXO0Z1yn0HZXcsTF wa+30undlx5YjCPcf4VYpDUU4POEHViMXALOtDDzw3QmBbrISlX39qS4MGSg2OGXqZOh feaA== X-Forwarded-Encrypted: i=1; AFNElJ+WYdCEV979pmdHiPwlPyY+ZOH2HGYLVVhhqBYwMd/ssd1qO8jp9nRVlEt297OTdSz9yaX5BFzzNxWVz0k=@vger.kernel.org X-Gm-Message-State: AOJu0YxkjVja5K2aUFknVg/rAqFpX0O+FtLghZJnDPdskzrq5P97eXFV AzGpjePCKEynIHBqgdCvM4cJVCs0U3dMe0rqg+LqFI4qN5iIUwn48x+qRP9ylQ9z9kGwBEw3+Eb N+mWAYCHMBnvA0ZQE4VLWLS/HCPO6E6XRg2JX99EB05TsnfBgNkiQVBOM2sRX+rnB5Yk= X-Gm-Gg: Acq92OG8IF/v7OtTMYeLlrY6WVlcYG7GM3UzMhMM4gYR7oOLoMsaYfhX0PIMhpoB0gq l7o0NDf8AKn0D3dfCxEWHU/kZOg+uEcS8mnGkOMy3qwCBFDibwYy8NaJeQmaqkd1Zw9N4gBvMO3 JrESefWj3vaxbHoXfER3QkdYKRvrYSMRGnpawlUiQCiuJ7yAmy22c76U8URrEhQzH273XVKTjj4 zv4bz3Jpg+K+0rBEuNNoMkc1vs3detur3HWwDuV3Cz+X85BUr70A4+fYyBJb6ApFRezjUiVQZov JC4+UEzllqC9p7It7bVGZCQE+02O1te6X3daUu2AT8gcRQFpwscVY2kg6V4I2vrmF67vZhi1PLP 2uRf0LdhCUBkfOPLRwztP7SyJ7b7Oot5NTiqrvmBS7dDhAK9KabMCxGtsuNt5LpUGfbvCWbl8m/ 7dN8cjO5rGe7GuJx5sE86pqhwZ0bH0 X-Received: by 2002:a17:90a:d606:b0:36b:5b82:4834 with SMTP id 98e67ed59e1d1-370ee547414mr18903636a91.7.1780974002437; Mon, 08 Jun 2026 20:00:02 -0700 (PDT) X-Received: by 2002:a17:90a:d606:b0:36b:5b82:4834 with SMTP id 98e67ed59e1d1-370ee547414mr18903604a91.7.1780974001960; Mon, 08 Jun 2026 20:00:01 -0700 (PDT) Received: from QCOM-SocCW5bzXR.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3712fcb2607sm8713835a91.0.2026.06.08.19.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 20:00:01 -0700 (PDT) From: Jianping Li To: Srinivas Kandagatla , Amol Maheshwari Cc: Jianping Li , Arnd Bergmann , Greg Kroah-Hartman , Abel Vesa , Jorge Ramirez-Ortiz , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, ekansh.gupta@oss.qualcomm.com, quic_chennak@quicinc.com, stable@kernel.org Subject: [PATCH v8 3/4] misc: fastrpc: Allocate entire reserved memory for Audio PD in probe Date: Tue, 9 Jun 2026 10:59:37 +0800 Message-Id: <20260609025938.457-4-jianping.li@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260609025938.457-1-jianping.li@oss.qualcomm.com> References: <20260609025938.457-1-jianping.li@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: k26xTx-WeUi9zx1RfmgIrTNp4E-pUo8c X-Authority-Analysis: v=2.4 cv=Z+3c2nRA c=1 sm=1 tr=0 ts=6a2781b3 cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=c8cBMUidy7NAwe8AhH0A:9 a=iS9zxrgQBfv6-_F4QbHw:22 X-Proofpoint-GUID: k26xTx-WeUi9zx1RfmgIrTNp4E-pUo8c X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA5MDAyNSBTYWx0ZWRfX7LeHP0Er6YVH jeC5FKKzDAyKpDQv2GKLdgquOg/KH2pjXT32sb6wS56bEdNmr5zh1bfUVxgsuT42mUVWsRqxfu1 FUhg1cnh6KzXi2+F+HGStfdVheaDXxS8zX52sozF+B45oMKplW7HutnxL/LL0NoSWA3ovHjMFOK hozVcCdnrzxDAyzUSaZm27xE5dqajLOmBXBOUm/S53WqIo2r6UPWVwyCWGnF9/EWhWnBFg4sc5D a3f1eQl21rV6HMU0bkJB0H5WA4tQBAF2UKC95u0kvnh49hszd7Mrgv1gXuz8QJV4Lpm1yn2L5xU aC5QXSuILribtMk9AsUg+f30mmLm6JiN8xi00DDjVNUocWBHuRzXRU0MYXTDOwm7PdC/qtHdSVY TwiiKGGZHkgWIzEqyGFyhg766sxA6EF/l8sDEBl6SVUDTY7MM4F7cM3O/74Bh/ZV/MlZR9gSfJg rZo1Tt7WKo9ohld42SQ== 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-08_06,2026-06-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=0 clxscore=1015 adultscore=0 priorityscore=1501 spamscore=0 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606090025 Content-Type: text/plain; charset="utf-8" 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. Add explicit validation for remote_heap presence and size before sending the memory to DSP, and fail early if the reserved-memory region is missing or incomplete. Fixes: 0871561055e66 ("misc: fastrpc: Add support for audiopd") Cc: stable@kernel.org Signed-off-by: Jianping Li --- drivers/misc/fastrpc.c | 112 ++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 53 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 517884000331..1942e74535e5 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -276,6 +276,8 @@ struct fastrpc_channel_ctx { struct kref refcount; /* Flag if dsp attributes are cached */ bool valid_attributes; + /* Flag if audio PD init mem was allocated */ + bool audio_init_mem; u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES]; struct fastrpc_device *secure_fdevice; struct fastrpc_device *fdevice; @@ -1341,15 +1343,24 @@ static int fastrpc_init_create_static_process(struc= t fastrpc_user *fl, struct fastrpc_init_create_static init; struct fastrpc_invoke_args *args; struct fastrpc_phy_page pages[1]; + struct fastrpc_channel_ctx *cctx =3D fl->cctx; char *name; int err; - bool scm_done =3D false; struct { int client_id; u32 namelen; u32 pageslen; } inbuf; u32 sc; + unsigned long flags; + + if (!cctx->remote_heap || !cctx->remote_heap->dma_addr || + !cctx->remote_heap->size) { + err =3D -ENOMEM; + dev_err(fl->sctx->dev, + "remote heap memory region is not added\n"); + return err; + } =20 args =3D kzalloc_objs(*args, FASTRPC_CREATE_STATIC_PROCESS_NARGS); if (!args) @@ -1373,31 +1384,6 @@ static int fastrpc_init_create_static_process(struct= fastrpc_user *fl, inbuf.client_id =3D fl->client_id; inbuf.namelen =3D init.namelen; inbuf.pageslen =3D 0; - if (!fl->cctx->remote_heap) { - err =3D fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen, - &fl->cctx->remote_heap); - if (err) - goto err_name; - - /* Map if we have any heap VMIDs associated with this ADSP Static Proces= s. */ - if (fl->cctx->vmcount) { - u64 src_perms =3D BIT(QCOM_SCM_VMID_HLOS); - - err =3D qcom_scm_assign_mem(fl->cctx->remote_heap->dma_addr, - (u64)fl->cctx->remote_heap->size, - &src_perms, - fl->cctx->vmperms, fl->cctx->vmcount); - if (err) { - dev_err(fl->sctx->dev, - "Failed to assign memory with dma_addr %pad size 0x%llx err %d\n", - &fl->cctx->remote_heap->dma_addr, - fl->cctx->remote_heap->size, err); - goto err_map; - } - scm_done =3D true; - inbuf.pageslen =3D 1; - } - } =20 fl->pd =3D USER_PD; =20 @@ -1409,8 +1395,17 @@ static int fastrpc_init_create_static_process(struct= fastrpc_user *fl, args[1].length =3D inbuf.namelen; args[1].fd =3D -1; =20 - pages[0].addr =3D fl->cctx->remote_heap->dma_addr; - pages[0].size =3D fl->cctx->remote_heap->size; + spin_lock_irqsave(&cctx->lock, flags); + if (!cctx->audio_init_mem) { + pages[0].addr =3D cctx->remote_heap->dma_addr; + pages[0].size =3D cctx->remote_heap->size; + cctx->audio_init_mem =3D true; + inbuf.pageslen =3D 1; + } else { + pages[0].addr =3D 0; + pages[0].size =3D 0; + } + spin_unlock_irqrestore(&cctx->lock, flags); =20 args[2].ptr =3D (u64)(uintptr_t) pages; args[2].length =3D sizeof(*pages); @@ -1428,27 +1423,7 @@ static int fastrpc_init_create_static_process(struct= fastrpc_user *fl, =20 return 0; err_invoke: - if (fl->cctx->vmcount && scm_done) { - u64 src_perms =3D 0; - struct qcom_scm_vmperm dst_perms; - u32 i; - - for (i =3D 0; i < fl->cctx->vmcount; i++) - src_perms |=3D BIT(fl->cctx->vmperms[i].vmid); - - dst_perms.vmid =3D QCOM_SCM_VMID_HLOS; - dst_perms.perm =3D QCOM_SCM_PERM_RWX; - err =3D qcom_scm_assign_mem(fl->cctx->remote_heap->dma_addr, - (u64)fl->cctx->remote_heap->size, - &src_perms, &dst_perms, 1); - if (err) - dev_err(fl->sctx->dev, "Failed to assign memory dma_addr %pad size 0x%l= lx err %d\n", - &fl->cctx->remote_heap->dma_addr, fl->cctx->remote_heap->size, err); - } -err_map: - fastrpc_buf_free(fl->cctx->remote_heap); - fl->cctx->remote_heap =3D NULL; -err_name: + cctx->audio_init_mem =3D false; kfree(name); err: kfree(args); @@ -2415,12 +2390,23 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device = *rpdev) } } =20 - if (domain_id =3D=3D SDSP_DOMAIN_ID) { + if (domain_id =3D=3D SDSP_DOMAIN_ID || domain_id =3D=3D ADSP_DOMAIN_ID) { struct resource res; u64 src_perms; =20 err =3D of_reserved_mem_region_to_resource(rdev->of_node, 0, &res); if (!err) { + if (domain_id =3D=3D ADSP_DOMAIN_ID) { + data->remote_heap =3D + kzalloc_obj(*data->remote_heap, GFP_KERNEL); + if (!data->remote_heap) { + err =3D -ENOMEM; + goto err_free_data; + } + + data->remote_heap->dma_addr =3D res.start; + data->remote_heap->size =3D resource_size(&res); + } src_perms =3D BIT(QCOM_SCM_VMID_HLOS); =20 err =3D qcom_scm_assign_mem(res.start, resource_size(&res), &src_perms, @@ -2428,7 +2414,6 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *r= pdev) if (err) goto err_free_data; } - } =20 secure_dsp =3D !(of_property_read_bool(rdev->of_node, "qcom,non-secure-do= main")); @@ -2487,6 +2472,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *r= pdev) misc_deregister(&data->secure_fdevice->miscdev); =20 err_free_data: + kfree(data->remote_heap); kfree(data); return err; } @@ -2509,6 +2495,7 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device = *rpdev) struct fastrpc_buf *buf, *b; struct fastrpc_user *user; unsigned long flags; + int err; =20 /* No invocations past this point */ spin_lock_irqsave(&cctx->lock, flags); @@ -2526,8 +2513,27 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device= *rpdev) list_for_each_entry_safe(buf, b, &cctx->invoke_interrupted_mmaps, node) list_del(&buf->node); =20 - if (cctx->remote_heap) - fastrpc_buf_free(cctx->remote_heap); + if (cctx->remote_heap && cctx->vmcount) { + u64 src_perms =3D 0; + struct qcom_scm_vmperm dst_perms; + + for (u32 i =3D 0; i < cctx->vmcount; i++) + src_perms |=3D BIT(cctx->vmperms[i].vmid); + + dst_perms.vmid =3D QCOM_SCM_VMID_HLOS; + dst_perms.perm =3D QCOM_SCM_PERM_RWX; + + err =3D qcom_scm_assign_mem(cctx->remote_heap->dma_addr, + cctx->remote_heap->size, &src_perms, + &dst_perms, 1); + if (err) + dev_err(&rpdev->dev, + "Failed to assign memory back to HLOS: dma_addr %pad size %#llx err %d= \n", + &cctx->remote_heap->dma_addr, cctx->remote_heap->size, err); + } + + kfree(cctx->remote_heap); + cctx->remote_heap =3D NULL; =20 of_platform_depopulate(&rpdev->dev); =20 --=20 2.43.0 From nobody Fri Jun 12 11:28:12 2026 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 C374C3630BF for ; Tue, 9 Jun 2026 03:00:09 +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=1780974010; cv=none; b=N2Os6t2Qi400QDKiWHP18CFeCgAYXZnjDddSkBtV0fi5Ul6fB4IW4ISLMfNsfR/3cSpV+n1kbNYWdOYSJigdmy6d6fVVLoYbZnfcFisNNYpGZryJAkwxjV5ohpIhJnEFv+ieYx1eLdGvyOnrGI9J/UiLdKcy8B63XTfj2phIEa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780974010; c=relaxed/simple; bh=eWIeTYW7FeOdq0GfLYC8itEcxTSMTfbyp2U9xoYqsA0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HFgeiJrVjQIiMe/syS2JkQ/uEbvhJ05jUcCdx3dfpbxp2qO81R3alqAXzvSCqA7NJSz8uempFT/p4YOoy1yrlct2LG6mw3gnKt0f9uP6OHuP1CAKLebdKUSB+EHWl6T2/q8U+B/1ePh7uBzVK5ygMBzzSG5OTqICKyeYNUjC8y0= 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=jb2u3vtw; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=hMw/83Xo; 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="jb2u3vtw"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="hMw/83Xo" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6590sN96543501 for ; Tue, 9 Jun 2026 03:00:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=cisBsGwi1YI qjwGwTWwgeZV3iNbu+JN7OENdgw6CMME=; b=jb2u3vtwrbQWTMWOcQwac7zgp+G sBqfS0J4rid2VVUfbvrJx6v08YnQnMUaIkYdByNR8UtHlLsYbTehF7e6QdYb3jvO dQgOFRZSKgl4JhRGizhXY0GLXM9u0nMiBVyIAzRvx4rVZ+w0uUlb635rePAGCeqJ 52MqCQimWDY4CuyaeqFzMAHrfnfJ3ilIcIvjjuzJQVgoSv+Oznp4aSOP4BFnD+8Q NRtPugewMW4SM3rCgetyw0AmE+Yu3MDh0mO1OMCzHIODhPRDl6jmUb37dLO2utld t9sHcJjFH2Okqu9HYTiuR90bxa0mkywLekebN95GC9pW8Z2h0zeog1SOMyA== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4enxx433mg-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 09 Jun 2026 03:00:09 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-36bc02d28b6so3771318a91.3 for ; Mon, 08 Jun 2026 20:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1780974008; x=1781578808; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cisBsGwi1YIqjwGwTWwgeZV3iNbu+JN7OENdgw6CMME=; b=hMw/83Xo3DhC57zzhAGYQYVwDXbUsbO4Z06M/aFRRG5EYzkfOEgyKDpXHND4kGizqY 65zNaiuT3UtPizPC8AazLvXdytBXcgh6qAU8IsiBRPPVFUpsQ1t6bDYurTzkDw6ap7k4 o9EzmcEr9GrOB0LtJTizey8El9JVqEHokn/x31i8lB1oRB2gdJdnARBMt9Sqz3Wf5SMT CEoUo3AdkvqNYB20Np7DdTHNY9sftCEVpP2TQtrYSHhH9MNZR9m7kQs4lgN7Iy+RDT8E aXnNBH8Fl5aIHwHp2TtzIMOvGnhvS4ADQ8yo8YXbKYPlhRiKMZCJxxBOPYXNFs+Xqrnw FlmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780974008; x=1781578808; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cisBsGwi1YIqjwGwTWwgeZV3iNbu+JN7OENdgw6CMME=; b=bHN3UYRuepKbOB7M18HNlV6BntATtqIJQCh298RHJH3gN4Me6yqppyg4LDpk1p5wB4 BiOuGnMNkAXAiTQmytH2ouqIN2+j9dem17LvhHqm62pnvUGlR5oOvUxlFttBSGxIGrsq ngR8jdSh45wbbnfYDZMwIcTXRPS0NT9r9SuIySCnt/Enehl7AwkT73e7FzfRB4fBQsHc +nGjJRn+dOlidKBp6uylWr6WXtz/0zqiWZ6WKDWF2GcQJYXKr/+ioEBZOzQmlNegSzdx gk0nrsdR3TAbvF3qwhE23tQsfV2ciIq7nuFf/AHgKN9UV0TVI15nM7hnMDVDMkUl6iYD +D2w== X-Forwarded-Encrypted: i=1; AFNElJ+MhmC4k9WHq/0k4zgzWosNp8GBtQA7N8AFdtGWZVa+Bk7iXDdySnWTuZEBE5Q6WRWC6Db075RNPJX2+Zc=@vger.kernel.org X-Gm-Message-State: AOJu0YwCD4Q8uTvNgu1LbpDRglxc25cY1Bx9NBHA6h41ptnWtjLnblYK /xLeWVIAEj9hjCTcnRwBrE9xvjFymdUi6B2UxlWKY2Dpv0c2/gSfhV15b77v8DEwR+WfNBcZ3WI s4tF/B1DQd3Nz2Kp5gIOncN3VkXp4+bpsghSQ+RX2IQB2U75OfEE+883T2KEkfOJ2vRo= X-Gm-Gg: Acq92OH7LwKVNI7zMPlEgbK1RmNdVN6+7bx/QPgD1jwDD4hc0kuO6vyUq/B40NnYfmM nHgNn7YsqZ2FEPYVrP4wsw8hos17h+Xx6h7YG0WWLEzzwNhpWm3RqqcuBHDYBs0xFsVH8rfl3Oe Bk3E7+Bhy7MhxMnc7K3rTJ6fErJTxalu9va/ZQyuCRWYDq3MJ4/Uicyc7QAhX3x3JaLVltTUfqf zkKkqgjsyjaKayLPQ+SNuGbXYYNTYF5hA1TkPCWVLsjULUt7ze0nNJnjWrw1wn3TzopNC0rC+az doQWrQ6k78wuwG+hDsQ6nPvein8Zb2o9oz53w5Grxcjj+21Kv5sa4fm3OgJVeFzj33yMrLdMUmH ylw+22tqL0a6Ct875osiJQHYFRFv37Jg861OAvr333qB7zLl1ndK+Yy7U60ySniVca9aH/injBH GpDMkmSknjUuqpwz5clUUO4cXBBQvx X-Received: by 2002:a17:90b:4990:b0:36b:b9c7:35fb with SMTP id 98e67ed59e1d1-370f0579a1bmr17907734a91.14.1780974008359; Mon, 08 Jun 2026 20:00:08 -0700 (PDT) X-Received: by 2002:a17:90b:4990:b0:36b:b9c7:35fb with SMTP id 98e67ed59e1d1-370f0579a1bmr17907685a91.14.1780974007681; Mon, 08 Jun 2026 20:00:07 -0700 (PDT) Received: from QCOM-SocCW5bzXR.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3712fcb2607sm8713835a91.0.2026.06.08.20.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 20:00:07 -0700 (PDT) From: Jianping Li To: Srinivas Kandagatla , Amol Maheshwari Cc: Ekansh Gupta , Arnd Bergmann , Greg Kroah-Hartman , Abel Vesa , Jorge Ramirez-Ortiz , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, quic_chennak@quicinc.com, Dmitry Baryshkov , Jianping Li Subject: [PATCH v8 4/4] misc: fastrpc: Allow fastrpc_buf_free() to accept NULL Date: Tue, 9 Jun 2026 10:59:38 +0800 Message-Id: <20260609025938.457-5-jianping.li@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260609025938.457-1-jianping.li@oss.qualcomm.com> References: <20260609025938.457-1-jianping.li@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=cverVV4i c=1 sm=1 tr=0 ts=6a2781b9 cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=XYmfcRj0Jzm9BuThv0sA:9 a=iS9zxrgQBfv6-_F4QbHw:22 X-Proofpoint-ORIG-GUID: 0KfthYb031xc1vfz7MXMWpGLHqNBbBkY X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA5MDAyNSBTYWx0ZWRfXxfTuf16kch+O 2Z68vRy5TVVjqz8N3Y/bE6Bkhv9avpbqW/WFy9FqKYkOdlqgdTio+fRso/emmon7kSomVey+YXN nOvoUokdAAPm/600Zvoq+Msx2U4aExYitOy4wJQj6/ll2wylS4ryiw+SUJG/UiRfzewVfWCZDiD t1c3f/OZUJ9MdZJ1FXH+EncrFTdq3MUWOFE1hN8UTIqLUMs9vnY+CL6bTTT76MartKOo2AH9yeW UeE1F35sbZdMpmV1Mz6KNmNCiJ75h2l89Cuwez/wT4gwMmMgEPh4sPfRHliGUkJiUjuiZ+LRYUW YuFz43Dia8FK/+C07J68LJgVHGozxoVDDqV2JzXDqmDnownevij6haIEqoMtxXOugjMZtVNFOyQ sAuscsqTogQQLKSDZsu5etxKm9if2zMEBj6wa5D35yvyymXqubO8MoOgU3whxEdGZj0iR315cgm uS0NZWO7Y5K1zqSQ2oA== X-Proofpoint-GUID: 0KfthYb031xc1vfz7MXMWpGLHqNBbBkY 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-08_06,2026-06-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 clxscore=1015 impostorscore=0 suspectscore=0 priorityscore=1501 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606090025 Content-Type: text/plain; charset="utf-8" From: Ekansh Gupta Make fastrpc_buf_free() a no-op when passed a NULL pointer, allowing callers to avoid open-coded NULL checks. Reviewed-by: Dmitry Baryshkov Signed-off-by: Ekansh Gupta Signed-off-by: Jianping Li --- drivers/misc/fastrpc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 1942e74535e5..b4912b443b98 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -424,6 +424,9 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, = int fd, =20 static void fastrpc_buf_free(struct fastrpc_buf *buf) { + if (!buf) + return; + dma_free_coherent(buf->dev, buf->size, buf->virt, fastrpc_ipa_to_dma_addr(buf->fl->cctx, buf->dma_addr)); kfree(buf); @@ -516,8 +519,7 @@ static void fastrpc_user_free(struct kref *ref) struct fastrpc_map *map, *m; struct fastrpc_buf *buf, *b; =20 - if (fl->init_mem) - fastrpc_buf_free(fl->init_mem); + fastrpc_buf_free(fl->init_mem); =20 list_for_each_entry_safe(ctx, n, &fl->pending, node) { list_del(&ctx->node); @@ -562,8 +564,7 @@ static void fastrpc_context_free(struct kref *ref) for (i =3D 0; i < ctx->nbufs; i++) fastrpc_map_put(ctx->maps[i]); =20 - if (ctx->buf) - fastrpc_buf_free(ctx->buf); + fastrpc_buf_free(ctx->buf); =20 spin_lock_irqsave(&cctx->lock, flags); idr_remove(&cctx->ctx_idr, ctx->ctxid >> 4); --=20 2.43.0