From: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: kpallavi@qti.qualcomm.com, srini@kernel.org,
amahesh@qti.qualcomm.com, arnd@arndb.de,
gregkh@linuxfoundation.org, 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, jingyi.wang@oss.qualcomm.com,
aiqun.yu@oss.qualcomm.com, ktadakam@qti.qualcomm.com
Subject: Re: [PATCH v2 1/3] misc: fastrpc: Rename phys to dma_addr for clarity
Date: Thu, 23 Oct 2025 12:50:13 +0530 [thread overview]
Message-ID: <75f6bbad-49a0-4a15-b976-a0450f66a4dc@oss.qualcomm.com> (raw)
In-Reply-To: <svekpvatqpymzxprc5n2tlndqlwze3tj6kr3bzszjnoay7oulk@zslcxpsyuzdo>
On 10/15/2025 3:37 PM, Dmitry Baryshkov wrote:
> On Wed, Oct 15, 2025 at 10:27:00AM +0530, Kumari Pallavi wrote:
>> Update all references of buf->phys and map->phys to buf->dma_addr and
>> map->dma_addr to accurately represent that these fields store DMA
>> addresses, not physical addresses. This change improves code clarity
>> and aligns with kernel conventions for dma_addr_t usage.
>>
>> Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
>> ---
>> drivers/misc/fastrpc.c | 68 +++++++++++++++++++++---------------------
>> 1 file changed, 34 insertions(+), 34 deletions(-)
>>
>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
>> index 621bce7e101c..975be54a2491 100644
>> --- a/drivers/misc/fastrpc.c
>> +++ b/drivers/misc/fastrpc.c
>> @@ -194,7 +194,7 @@ struct fastrpc_buf {
>> struct dma_buf *dmabuf;
>> struct device *dev;
>> void *virt;
>> - u64 phys;
>> + u64 dma_addr;
>
> If it is dma_addr, why isn't it dma_addr_t?
>
While the field is named dma_addr, it is not strictly limited to holding
a DMA address.
Based on historical behavior, when the FASTRPC_ATTR_SECUREMAP flag is
set, S2 mapping expects a physical address to be passed to the
qcom_scm_assign_mem() API.
reference-
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/misc/fastrpc.c?id=e90d911906196bf987492c94e38f10ca611dfd7b
>
>> 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;
>> + u64 dma_addr;
>
> And this one.
>
>> u64 size;
>> void *va;
>> u64 len;
>> @@ -406,12 +406,12 @@ static int __fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev,
>>
>> buf->fl = fl;
>> buf->virt = NULL;
>> - buf->phys = 0;
>> + buf->dma_addr = 0;
>> buf->size = size;
>> buf->dev = dev;
>> buf->raddr = 0;
>>
>> - buf->virt = dma_alloc_coherent(dev, buf->size, (dma_addr_t *)&buf->phys,
>> + buf->virt = dma_alloc_coherent(dev, buf->size, (dma_addr_t *)&buf->dma_addr,
>> GFP_KERNEL);
>
> If it was dma_addr_t, you wouldn't have had to typecast here.
>
>> if (!buf->virt) {
>> mutex_destroy(&buf->lock);
>> @@ -437,7 +437,7 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev,
>> buf = *obuf;
>>
>> if (fl->sctx && fl->sctx->sid)
>> - buf->phys += ((u64)fl->sctx->sid << 32);
>> + buf->dma_addr += ((u64)fl->sctx->sid << 32);
>>
>> return 0;
>> }
>> @@ -682,7 +682,7 @@ static int fastrpc_dma_buf_attach(struct dma_buf *dmabuf,
>> return -ENOMEM;
>>
>> ret = dma_get_sgtable(buffer->dev, &a->sgt, buffer->virt,
>> - FASTRPC_PHYS(buffer->phys), buffer->size);
>> + FASTRPC_PHYS(buffer->dma_addr), buffer->size);
>
> FASTRPC_PHYS trunates addr to 32 bits. Is it expected? Is it a DMA
> address on the Linux or on the DSP side?
>
Yes, it is expected as the device can address up to 32 bit memory range.
It is a DMA address on the Linux.
>> if (ret < 0) {
>> dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
>> kfree(a);
>
Thanks,
Pallavi
next prev parent reply other threads:[~2025-10-23 7:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 4:56 [PATCH v2 0/3] Add ADSP and CDSP support on Kaanapali SoC Kumari Pallavi
2025-10-15 4:57 ` [PATCH v2 1/3] misc: fastrpc: Rename phys to dma_addr for clarity Kumari Pallavi
2025-10-15 7:20 ` Arnd Bergmann
2025-10-15 10:49 ` Kumari Pallavi
2025-10-15 10:07 ` Dmitry Baryshkov
2025-10-23 7:20 ` Kumari Pallavi [this message]
2025-10-15 4:57 ` [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting Kumari Pallavi
2025-10-15 7:09 ` Arnd Bergmann
2025-10-15 8:52 ` Srinivas Kandagatla
2025-10-15 10:47 ` Kumari Pallavi
2025-10-18 17:25 ` Krzysztof Kozlowski
2025-10-18 17:24 ` Krzysztof Kozlowski
2025-10-23 8:35 ` Kumari Pallavi
2025-10-23 8:41 ` Krzysztof Kozlowski
2025-10-15 4:57 ` [PATCH v2 3/3] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC Kumari Pallavi
2025-10-15 7:06 ` Arnd Bergmann
2025-10-15 9:25 ` Srinivas Kandagatla
2025-10-15 10:47 ` Kumari Pallavi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=75f6bbad-49a0-4a15-b976-a0450f66a4dc@oss.qualcomm.com \
--to=kumari.pallavi@oss.qualcomm.com \
--cc=aiqun.yu@oss.qualcomm.com \
--cc=amahesh@qti.qualcomm.com \
--cc=arnd@arndb.de \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ekansh.gupta@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=jingyi.wang@oss.qualcomm.com \
--cc=kpallavi@qti.qualcomm.com \
--cc=ktadakam@qti.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_bkumar@quicinc.com \
--cc=quic_chennak@quicinc.com \
--cc=srini@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®