From nobody Tue Dec 16 21:12:36 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 AD5302FF67A; Thu, 11 Dec 2025 10:09:51 +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=1765447793; cv=none; b=XPPc2xKwnQEAq+920PuKGv5Kakv9CNmGaT+T7Iwio1s2dAix8lNGtbYowNQwAKlOx1tLp58DfEIP53Rw5kl+HolBjfHxcEGE4yc+Odb3BE0qeoq7lyL1jqN5LcgM57SzhkfM+R0kOneaaVP2dD8+7iEKp7owBrUWb+Jbwhqncj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765447793; c=relaxed/simple; bh=v2rICkGIgWFUwBarnib6MwKkf/CQrFHzC3C5QtfXYzc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RC0c3gI8EL7gEqjbpfXyFaBEOxBV8P1LV96QyzLpxXlsWmKkWUU3L/LIFz1e6oqcwPDb0nMx4TcDA+glDpKCRe+udwK/Sb9dtyJ0vM7Bf1jw3lnEevWff3lu8lFXXAHfNj3HRyerZ89y+5j44F6R8qfOidy1bfTHeR4Qmks7+6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=g7IieW+U; 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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="g7IieW+U" 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 5BB9ZUeq1083601; Thu, 11 Dec 2025 10:09:46 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=SM1lw0jWL2v Ri4HkhhXnp3AaNnHf6OGNTnj1/ZF/cK4=; b=g7IieW+UV9gN7OUUpBq8IYajoWA Ls1nimQJoPGrY8MFHVZh+6K6oFoGfwZUuPDZpP4AJLgMpFaWNHBnr4v1Zphw+fRe RYJ/vABpGcptCR5LmCAwbK4f42frq8hbhBiilCukBjgXgr/bxAtXAZuJd2hDQELk v3JMF1sO8SlZ8E5L2GmBucvmbCcUr6GfyaHWt3aOi1Q342Y3Av6K5HvzwvLBqHqT k30GTMynWJ8mxJkzeQlbgP2/TyAzoJyMOa4l45HqRp2CHB25+dsDoQZZ3vTV5gm8 17COL6BDpt5XNBDQUSllAZ7g2pkFfpxzNPf020YKh6qO/oeQPwABQO1ee0Q== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ayg0pt3hy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Dec 2025 10:09:45 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 5BBA9eq9013858; Thu, 11 Dec 2025 10:09:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4avdjnupp9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Dec 2025 10:09:41 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5BBA9fwG013870; Thu, 11 Dec 2025 10:09:41 GMT Received: from hu-devc-hyd-u22-c.qualcomm.com (hu-kpallavi-hyd.qualcomm.com [10.147.243.7]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 5BBA9fKO013865 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Dec 2025 10:09:41 +0000 Received: by hu-devc-hyd-u22-c.qualcomm.com (Postfix, from userid 4720299) id 6C3A356A; Thu, 11 Dec 2025 15:39:40 +0530 (+0530) From: Kumari Pallavi To: kpallavi@qti.qualcomm.com, srini@kernel.org, amahesh@qti.qualcomm.com, arnd@arndb.de, gregkh@linuxfoundation.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: Kumari Pallavi , quic_bkumar@quicinc.com, ekansh.gupta@oss.qualcomm.com, linux-kernel@vger.kernel.org, quic_chennak@quicinc.com, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, jingyi.wang@oss.qualcomm.com, aiqun.yu@oss.qualcomm.com, ktadakam@qti.qualcomm.com Subject: [PATCH v6 2/4] misc: fastrpc: Rename phys to dma_addr for clarity Date: Thu, 11 Dec 2025 15:39:31 +0530 Message-Id: <20251211100933.1285093-3-kumari.pallavi@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251211100933.1285093-1-kumari.pallavi@oss.qualcomm.com> References: <20251211100933.1285093-1-kumari.pallavi@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-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: GIs6gvUQiQQvrchOvj4HOx-M0HnA-ApP X-Authority-Analysis: v=2.4 cv=b46/I9Gx c=1 sm=1 tr=0 ts=693a986a cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=UZbHtQxcIr1JeRqDSmcA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjExMDA3NyBTYWx0ZWRfX6Nt1uknLs09w dIoUdpcB6IPjR1dNpJHsItMhIDStGLPQBtdyRggwxZ5it2/E1TnskRl7W2AxnMAUg+vlG8diKLi ZXlVwuqh7ouy3SBh9EwerT21gCzRtAnJe7F7QnSQVtbOSC63Hd8DcDohKxq98DIembD5IPZaMXi iLoFsdg2bCKH+LwOoOimuQZZ4o9Zp/kF01j2bHbTjkWJXdIszuc+pqGe4ixbdSdALHSZwPJrd7c o8ioGtGBJb/M2J9TL2hUzDgIA4rV6Nm1UeR7SYyvi3+EiLuOc9wCDJVTyrFSaUmcqnK1cDBCuZq U0bEA7jnDmxddWSTC4+i6hh1bImCNTLkjkN0Uz9P1aqTZNJ6TCSHuOxqSQBSOBiMzC7V1QMJXTM d2mRs3AgpTplcUf07S+C1KGOaFKcLQ== X-Proofpoint-GUID: GIs6gvUQiQQvrchOvj4HOx-M0HnA-ApP 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-12-10_03,2025-12-09_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 clxscore=1015 adultscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512110077 Content-Type: text/plain; charset="utf-8" The fields buf->phys and map->phys currently store DMA addresses returned by dma_map_*() APIs, not physical addresses. This naming is misleading and may lead to incorrect assumptions about the address type and its translation. Rename these fields from phys to dma_addr to improve code clarity and align with kernel conventions for dma_addr_t usage. Signed-off-by: Kumari Pallavi --- drivers/misc/fastrpc.c | 77 ++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index ee652ef01534..eb9501fe79bc 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -106,7 +106,7 @@ #define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscd= ev) =20 struct fastrpc_phy_page { - u64 addr; /* physical address */ + dma_addr_t addr; /* dma address */ u64 size; /* size of contiguous region */ }; =20 @@ -171,7 +171,7 @@ struct fastrpc_msg { u64 ctx; /* invoke caller context */ u32 handle; /* handle to invoke */ u32 sc; /* scalars structure describing the data */ - u64 addr; /* physical address */ + dma_addr_t addr; /* dma address */ u64 size; /* size of contiguous region */ }; =20 @@ -194,7 +194,7 @@ struct fastrpc_buf { struct dma_buf *dmabuf; struct device *dev; void *virt; - u64 phys; + dma_addr_t dma_addr; u64 size; /* Lock for dma buf attachments */ struct mutex lock; @@ -217,7 +217,7 @@ struct fastrpc_map { struct dma_buf *buf; struct sg_table *table; struct dma_buf_attachment *attach; - u64 phys; + dma_addr_t dma_addr; u64 size; void *va; u64 len; @@ -320,11 +320,12 @@ static void fastrpc_free_map(struct kref *ref) =20 perm.vmid =3D QCOM_SCM_VMID_HLOS; perm.perm =3D QCOM_SCM_PERM_RWX; - err =3D qcom_scm_assign_mem(map->phys, map->len, + err =3D qcom_scm_assign_mem(map->dma_addr, map->len, &src_perms, &perm, 1); if (err) { - dev_err(map->fl->sctx->dev, "Failed to assign memory phys 0x%llx size = 0x%llx err %d\n", - map->phys, map->len, err); + dev_err(map->fl->sctx->dev, + "Failed to assign memory dma_addr %pad size 0x%llx err %d\n", + &map->dma_addr, map->len, err); return; } } @@ -389,7 +390,7 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, = int fd, static void fastrpc_buf_free(struct fastrpc_buf *buf) { dma_free_coherent(buf->dev, buf->size, buf->virt, - FASTRPC_PHYS(buf->phys)); + FASTRPC_PHYS(buf->dma_addr)); kfree(buf); } =20 @@ -408,12 +409,12 @@ static int __fastrpc_buf_alloc(struct fastrpc_user *f= l, struct device *dev, =20 buf->fl =3D fl; buf->virt =3D NULL; - buf->phys =3D 0; + buf->dma_addr =3D 0; buf->size =3D size; buf->dev =3D dev; buf->raddr =3D 0; =20 - buf->virt =3D dma_alloc_coherent(dev, buf->size, (dma_addr_t *)&buf->phys, + buf->virt =3D dma_alloc_coherent(dev, buf->size, &buf->dma_addr, GFP_KERNEL); if (!buf->virt) { mutex_destroy(&buf->lock); @@ -439,7 +440,7 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl, s= truct device *dev, buf =3D *obuf; =20 if (fl->sctx && fl->sctx->sid) - buf->phys +=3D ((u64)fl->sctx->sid << 32); + buf->dma_addr +=3D ((u64)fl->sctx->sid << 32); =20 return 0; } @@ -684,7 +685,7 @@ static int fastrpc_dma_buf_attach(struct dma_buf *dmabu= f, return -ENOMEM; =20 ret =3D dma_get_sgtable(buffer->dev, &a->sgt, buffer->virt, - FASTRPC_PHYS(buffer->phys), buffer->size); + FASTRPC_PHYS(buffer->dma_addr), buffer->size); if (ret < 0) { dev_err(buffer->dev, "failed to get scatterlist from DMA API\n"); kfree(a); @@ -733,7 +734,7 @@ static int fastrpc_mmap(struct dma_buf *dmabuf, dma_resv_assert_held(dmabuf->resv); =20 return dma_mmap_coherent(buf->dev, vma, buf->virt, - FASTRPC_PHYS(buf->phys), size); + FASTRPC_PHYS(buf->dma_addr), size); } =20 static const struct dma_buf_ops fastrpc_dma_buf_ops =3D { @@ -785,10 +786,10 @@ static int fastrpc_map_attach(struct fastrpc_user *fl= , int fd, map->table =3D table; =20 if (attr & FASTRPC_ATTR_SECUREMAP) { - map->phys =3D sg_phys(map->table->sgl); + map->dma_addr =3D sg_phys(map->table->sgl); } else { - map->phys =3D sg_dma_address(map->table->sgl); - map->phys +=3D ((u64)fl->sctx->sid << 32); + map->dma_addr =3D sg_dma_address(map->table->sgl); + map->dma_addr +=3D ((u64)fl->sctx->sid << 32); } for_each_sg(map->table->sgl, sgl, map->table->nents, sgl_index) @@ -815,10 +816,11 @@ static int fastrpc_map_attach(struct fastrpc_user *fl= , int fd, dst_perms[1].vmid =3D fl->cctx->vmperms[0].vmid; dst_perms[1].perm =3D QCOM_SCM_PERM_RWX; map->attr =3D attr; - err =3D qcom_scm_assign_mem(map->phys, (u64)map->len, &src_perms, dst_pe= rms, 2); + err =3D qcom_scm_assign_mem(map->dma_addr, (u64)map->len, &src_perms, ds= t_perms, 2); if (err) { - dev_err(sess->dev, "Failed to assign memory with phys 0x%llx size 0x%ll= x err %d\n", - map->phys, map->len, err); + dev_err(sess->dev, + "Failed to assign memory with dma_addr %pad size 0x%llx err %d\n", + &map->dma_addr, map->len, err); goto map_err; } } @@ -1009,7 +1011,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrp= c_invoke_ctx *ctx) struct vm_area_struct *vma =3D NULL; =20 rpra[i].buf.pv =3D (u64) ctx->args[i].ptr; - pages[i].addr =3D ctx->maps[i]->phys; + pages[i].addr =3D ctx->maps[i]->dma_addr; =20 mmap_read_lock(current->mm); vma =3D find_vma(current->mm, ctx->args[i].ptr); @@ -1036,7 +1038,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrp= c_invoke_ctx *ctx) goto bail; =20 rpra[i].buf.pv =3D args - ctx->olaps[oix].offset; - pages[i].addr =3D ctx->buf->phys - + pages[i].addr =3D ctx->buf->dma_addr - ctx->olaps[oix].offset + (pkt_size - rlen); pages[i].addr =3D pages[i].addr & PAGE_MASK; @@ -1068,7 +1070,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrp= c_invoke_ctx *ctx) list[i].num =3D ctx->args[i].length ? 1 : 0; list[i].pgidx =3D i; if (ctx->maps[i]) { - pages[i].addr =3D ctx->maps[i]->phys; + pages[i].addr =3D ctx->maps[i]->dma_addr; pages[i].size =3D ctx->maps[i]->size; } rpra[i].dma.fd =3D ctx->args[i].fd; @@ -1150,7 +1152,7 @@ static int fastrpc_invoke_send(struct fastrpc_session= _ctx *sctx, msg->ctx =3D ctx->ctxid | fl->pd; msg->handle =3D handle; msg->sc =3D ctx->sc; - msg->addr =3D ctx->buf ? ctx->buf->phys : 0; + msg->addr =3D ctx->buf ? ctx->buf->dma_addr : 0; msg->size =3D roundup(ctx->msg_sz, PAGE_SIZE); fastrpc_context_get(ctx); =20 @@ -1306,13 +1308,15 @@ static int fastrpc_init_create_static_process(struc= t fastrpc_user *fl, if (fl->cctx->vmcount) { u64 src_perms =3D BIT(QCOM_SCM_VMID_HLOS); =20 - err =3D qcom_scm_assign_mem(fl->cctx->remote_heap->phys, + 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 phys 0x%llx size = 0x%llx err %d\n", - fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, 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; @@ -1332,7 +1336,7 @@ 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->phys; + pages[0].addr =3D fl->cctx->remote_heap->dma_addr; pages[0].size =3D fl->cctx->remote_heap->size; =20 args[2].ptr =3D (u64)(uintptr_t) pages; @@ -1361,12 +1365,12 @@ static int fastrpc_init_create_static_process(struc= t fastrpc_user *fl, =20 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->phys, + 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 phys 0x%llx size 0x%llx= err %d\n", - fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, 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); @@ -1455,7 +1459,7 @@ static int fastrpc_init_create_process(struct fastrpc= _user *fl, args[2].length =3D inbuf.filelen; args[2].fd =3D init.filefd; =20 - pages[0].addr =3D imem->phys; + pages[0].addr =3D imem->dma_addr; pages[0].size =3D imem->size; =20 args[3].ptr =3D (u64)(uintptr_t) pages; @@ -1913,7 +1917,7 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, = char __user *argp) args[0].ptr =3D (u64) (uintptr_t) &req_msg; args[0].length =3D sizeof(req_msg); =20 - pages.addr =3D buf->phys; + pages.addr =3D buf->dma_addr; pages.size =3D buf->size; =20 args[1].ptr =3D (u64) (uintptr_t) &pages; @@ -1941,11 +1945,12 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl= , char __user *argp) if (req.flags =3D=3D ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { u64 src_perms =3D BIT(QCOM_SCM_VMID_HLOS); =20 - err =3D qcom_scm_assign_mem(buf->phys, (u64)buf->size, + err =3D qcom_scm_assign_mem(buf->dma_addr, (u64)buf->size, &src_perms, fl->cctx->vmperms, fl->cctx->vmcount); if (err) { - dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx= err %d", - buf->phys, buf->size, err); + dev_err(fl->sctx->dev, + "Failed to assign memory dma_addr %pad size 0x%llx err %d", + &buf->dma_addr, buf->size, err); goto err_assign; } } @@ -2059,7 +2064,7 @@ static int fastrpc_req_mem_map(struct fastrpc_user *f= l, char __user *argp) args[0].ptr =3D (u64) (uintptr_t) &req_msg; args[0].length =3D sizeof(req_msg); =20 - pages.addr =3D map->phys; + pages.addr =3D map->dma_addr; pages.size =3D map->len; =20 args[1].ptr =3D (u64) (uintptr_t) &pages; --=20 2.34.1