* [PATCH v2 0/3] Add ADSP and CDSP support on Kaanapali SoC
@ 2025-10-15 4:56 Kumari Pallavi
2025-10-15 4:57 ` [PATCH v2 1/3] misc: fastrpc: Rename phys to dma_addr for clarity Kumari Pallavi
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Kumari Pallavi @ 2025-10-15 4:56 UTC (permalink / raw)
To: kpallavi, srini, amahesh, arnd, gregkh
Cc: Kumari Pallavi, quic_bkumar, ekansh.gupta, linux-kernel,
quic_chennak, dri-devel, linux-arm-msm, jingyi.wang, aiqun.yu,
ktadakam
Introduces support for new DSP IOVA formatting and hardware-specific
configuration required to enable ADSP and CDSP functionality on the
Kaanapali SoC.
Add support for a new IOVA formatting scheme by adding a sid_pos to the DSP
driver. Sid_pos standardizes the placement of the stream ID (SID) within the
physical address, which is required for DSPs to operate correctly on
Kaanapali. DSP currently supports 32-bit IOVA (32-bit PA + 4-bit SID) for
both Q6 and user DMA (uDMA) access.
This is being upgraded to 34-bit PA + 4-bit SID due to a hardware revision
in CDSP for Kaanapali SoC, which expands the DMA addressable range.
To support CDSP operation, this series updates the DMA mask configuration
to reflect the expanded DMA addressable range.
Patch [v1]: https://lore.kernel.org/all/20250924-knp-fastrpc-v1-0-4b40f8bfce1d@oss.qualcomm.com/
Changes in v2:
- Rename phys to dma_addr for clarity
- Remove iova_format, add soc_data with sid_pos in channel ctx
- Remove sid_pos and pa_bits from the session ctx
Kumari Pallavi (3):
misc: fastrpc: Rename phys to dma_addr for clarity
misc: fastrpc: Add support for new DSP IOVA formatting
misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC
drivers/misc/fastrpc.c | 126 ++++++++++++++++++++++++++++-------------
1 file changed, 88 insertions(+), 38 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 1/3] misc: fastrpc: Rename phys to dma_addr for clarity
2025-10-15 4:56 [PATCH v2 0/3] Add ADSP and CDSP support on Kaanapali SoC Kumari Pallavi
@ 2025-10-15 4:57 ` Kumari Pallavi
2025-10-15 7:20 ` Arnd Bergmann
2025-10-15 10:07 ` Dmitry Baryshkov
2025-10-15 4:57 ` [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting Kumari Pallavi
2025-10-15 4:57 ` [PATCH v2 3/3] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC Kumari Pallavi
2 siblings, 2 replies; 18+ messages in thread
From: Kumari Pallavi @ 2025-10-15 4:57 UTC (permalink / raw)
To: kpallavi, srini, amahesh, arnd, gregkh
Cc: Kumari Pallavi, quic_bkumar, ekansh.gupta, linux-kernel,
quic_chennak, dri-devel, linux-arm-msm, jingyi.wang, aiqun.yu,
ktadakam
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;
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;
u64 size;
void *va;
u64 len;
@@ -320,11 +320,11 @@ static void fastrpc_free_map(struct kref *ref)
perm.vmid = QCOM_SCM_VMID_HLOS;
perm.perm = QCOM_SCM_PERM_RWX;
- err = qcom_scm_assign_mem(map->phys, map->len,
+ err = 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 0x%llx size 0x%llx err %d\n",
+ map->dma_addr, map->len, err);
return;
}
}
@@ -387,7 +387,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);
}
@@ -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 (!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);
if (ret < 0) {
dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
kfree(a);
@@ -731,7 +731,7 @@ static int fastrpc_mmap(struct dma_buf *dmabuf,
dma_resv_assert_held(dmabuf->resv);
return dma_mmap_coherent(buf->dev, vma, buf->virt,
- FASTRPC_PHYS(buf->phys), size);
+ FASTRPC_PHYS(buf->dma_addr), size);
}
static const struct dma_buf_ops fastrpc_dma_buf_ops = {
@@ -783,10 +783,10 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
map->table = table;
if (attr & FASTRPC_ATTR_SECUREMAP) {
- map->phys = sg_phys(map->table->sgl);
+ map->dma_addr = sg_phys(map->table->sgl);
} else {
- map->phys = sg_dma_address(map->table->sgl);
- map->phys += ((u64)fl->sctx->sid << 32);
+ map->dma_addr = sg_dma_address(map->table->sgl);
+ map->dma_addr += ((u64)fl->sctx->sid << 32);
}
for_each_sg(map->table->sgl, sgl, map->table->nents,
sgl_index)
@@ -813,10 +813,10 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
dst_perms[1].vmid = fl->cctx->vmperms[0].vmid;
dst_perms[1].perm = QCOM_SCM_PERM_RWX;
map->attr = attr;
- err = qcom_scm_assign_mem(map->phys, (u64)map->len, &src_perms, dst_perms, 2);
+ err = qcom_scm_assign_mem(map->dma_addr, (u64)map->len, &src_perms, dst_perms, 2);
if (err) {
- dev_err(sess->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d\n",
- map->phys, map->len, err);
+ dev_err(sess->dev, "Failed to assign memory with dma_addr 0x%llx size 0x%llx err %d\n",
+ map->dma_addr, map->len, err);
goto map_err;
}
}
@@ -1007,7 +1007,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
struct vm_area_struct *vma = NULL;
rpra[i].buf.pv = (u64) ctx->args[i].ptr;
- pages[i].addr = ctx->maps[i]->phys;
+ pages[i].addr = ctx->maps[i]->dma_addr;
mmap_read_lock(current->mm);
vma = find_vma(current->mm, ctx->args[i].ptr);
@@ -1034,7 +1034,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
goto bail;
rpra[i].buf.pv = args - ctx->olaps[oix].offset;
- pages[i].addr = ctx->buf->phys -
+ pages[i].addr = ctx->buf->dma_addr -
ctx->olaps[oix].offset +
(pkt_size - rlen);
pages[i].addr = pages[i].addr & PAGE_MASK;
@@ -1066,7 +1066,7 @@ static int fastrpc_get_args(u32 kernel, struct fastrpc_invoke_ctx *ctx)
list[i].num = ctx->args[i].length ? 1 : 0;
list[i].pgidx = i;
if (ctx->maps[i]) {
- pages[i].addr = ctx->maps[i]->phys;
+ pages[i].addr = ctx->maps[i]->dma_addr;
pages[i].size = ctx->maps[i]->size;
}
rpra[i].dma.fd = ctx->args[i].fd;
@@ -1148,7 +1148,7 @@ static int fastrpc_invoke_send(struct fastrpc_session_ctx *sctx,
msg->ctx = ctx->ctxid | fl->pd;
msg->handle = handle;
msg->sc = ctx->sc;
- msg->addr = ctx->buf ? ctx->buf->phys : 0;
+ msg->addr = ctx->buf ? ctx->buf->dma_addr : 0;
msg->size = roundup(ctx->msg_sz, PAGE_SIZE);
fastrpc_context_get(ctx);
@@ -1304,13 +1304,13 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
if (fl->cctx->vmcount) {
u64 src_perms = BIT(QCOM_SCM_VMID_HLOS);
- err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys,
+ err = 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 0x%llx size 0x%llx err %d\n",
+ fl->cctx->remote_heap->dma_addr, fl->cctx->remote_heap->size, err);
goto err_map;
}
scm_done = true;
@@ -1330,7 +1330,7 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
args[1].length = inbuf.namelen;
args[1].fd = -1;
- pages[0].addr = fl->cctx->remote_heap->phys;
+ pages[0].addr = fl->cctx->remote_heap->dma_addr;
pages[0].size = fl->cctx->remote_heap->size;
args[2].ptr = (u64)(uintptr_t) pages;
@@ -1359,12 +1359,12 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
dst_perms.vmid = QCOM_SCM_VMID_HLOS;
dst_perms.perm = QCOM_SCM_PERM_RWX;
- err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys,
+ err = 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 0x%llx size 0x%llx err %d\n",
+ fl->cctx->remote_heap->dma_addr, fl->cctx->remote_heap->size, err);
}
err_map:
fastrpc_buf_free(fl->cctx->remote_heap);
@@ -1453,7 +1453,7 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
args[2].length = inbuf.filelen;
args[2].fd = init.filefd;
- pages[0].addr = imem->phys;
+ pages[0].addr = imem->dma_addr;
pages[0].size = imem->size;
args[3].ptr = (u64)(uintptr_t) pages;
@@ -1911,7 +1911,7 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
args[0].ptr = (u64) (uintptr_t) &req_msg;
args[0].length = sizeof(req_msg);
- pages.addr = buf->phys;
+ pages.addr = buf->dma_addr;
pages.size = buf->size;
args[1].ptr = (u64) (uintptr_t) &pages;
@@ -1939,11 +1939,11 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) {
u64 src_perms = BIT(QCOM_SCM_VMID_HLOS);
- err = qcom_scm_assign_mem(buf->phys, (u64)buf->size,
+ err = 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 0x%llx size 0x%llx err %d",
+ buf->dma_addr, buf->size, err);
goto err_assign;
}
}
@@ -2057,7 +2057,7 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
args[0].ptr = (u64) (uintptr_t) &req_msg;
args[0].length = sizeof(req_msg);
- pages.addr = map->phys;
+ pages.addr = map->dma_addr;
pages.size = map->len;
args[1].ptr = (u64) (uintptr_t) &pages;
--
2.34.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting
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 4:57 ` Kumari Pallavi
2025-10-15 7:09 ` Arnd Bergmann
` (2 more replies)
2025-10-15 4:57 ` [PATCH v2 3/3] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC Kumari Pallavi
2 siblings, 3 replies; 18+ messages in thread
From: Kumari Pallavi @ 2025-10-15 4:57 UTC (permalink / raw)
To: kpallavi, srini, amahesh, arnd, gregkh
Cc: Kumari Pallavi, quic_bkumar, ekansh.gupta, linux-kernel,
quic_chennak, dri-devel, linux-arm-msm, jingyi.wang, aiqun.yu,
ktadakam
Implement the new IOVA formatting required by the DSP architecture change
on Kaanapali SoC. Place the SID for DSP DMA transactions at bit 56 in the
physical address. This placement is necessary for the DSPs to correctly
identify streams and operate as intended.
To address this, set SID position to bit 56 based on SoC-specific compatible
string from the root node within the physical address; otherwise, default to
legacy 32-bit placement.
This change ensures consistent SID placement across DSPs.
Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 59 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 52 insertions(+), 7 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 975be54a2491..1a5d620b23f2 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -33,7 +33,6 @@
#define FASTRPC_ALIGN 128
#define FASTRPC_MAX_FDLIST 16
#define FASTRPC_MAX_CRCLIST 64
-#define FASTRPC_PHYS(p) ((p) & 0xffffffff)
#define FASTRPC_CTX_MAX (256)
#define FASTRPC_INIT_HANDLE 1
#define FASTRPC_DSP_UTILITIES_HANDLE 2
@@ -105,6 +104,15 @@
#define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev)
+/* Extract smmu pa from consolidated iova */
+#define IPA_TO_DMA_ADDR(iova, sid_pos) (iova & ((1ULL << sid_pos) - 1ULL))
+/*
+ * Prepare the consolidated iova to send to dsp by prepending the sid
+ * to smmu pa at the appropriate position
+ */
+#define IOVA_FROM_SID_PA(sid, phys, sid_pos) \
+ (phys += sid << sid_pos)
+
struct fastrpc_phy_page {
u64 addr; /* physical address */
u64 size; /* size of contiguous region */
@@ -257,6 +265,10 @@ struct fastrpc_session_ctx {
bool valid;
};
+struct fastrpc_soc_data {
+ u32 sid_pos;
+};
+
struct fastrpc_channel_ctx {
int domain_id;
int sesscount;
@@ -278,6 +290,7 @@ struct fastrpc_channel_ctx {
bool secure;
bool unsigned_support;
u64 dma_mask;
+ const struct fastrpc_soc_data *soc_data;
};
struct fastrpc_device {
@@ -387,7 +400,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->dma_addr));
+ IPA_TO_DMA_ADDR(buf->dma_addr, buf->fl->cctx->soc_data->sid_pos));
kfree(buf);
}
@@ -437,8 +450,7 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev,
buf = *obuf;
if (fl->sctx && fl->sctx->sid)
- buf->dma_addr += ((u64)fl->sctx->sid << 32);
-
+ IOVA_FROM_SID_PA((u64)fl->sctx->sid, buf->dma_addr, fl->cctx->soc_data->sid_pos);
return 0;
}
@@ -682,7 +694,8 @@ 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->dma_addr), buffer->size);
+ IPA_TO_DMA_ADDR(buffer->dma_addr, buffer->fl->cctx->soc_data->sid_pos),
+ buffer->size);
if (ret < 0) {
dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
kfree(a);
@@ -731,7 +744,8 @@ static int fastrpc_mmap(struct dma_buf *dmabuf,
dma_resv_assert_held(dmabuf->resv);
return dma_mmap_coherent(buf->dev, vma, buf->virt,
- FASTRPC_PHYS(buf->dma_addr), size);
+ IPA_TO_DMA_ADDR(buf->dma_addr,
+ buf->fl->cctx->soc_data->sid_pos), size);
}
static const struct dma_buf_ops fastrpc_dma_buf_ops = {
@@ -786,7 +800,8 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
map->dma_addr = sg_phys(map->table->sgl);
} else {
map->dma_addr = sg_dma_address(map->table->sgl);
- map->dma_addr += ((u64)fl->sctx->sid << 32);
+ IOVA_FROM_SID_PA((u64)fl->sctx->sid,
+ map->dma_addr, fl->cctx->soc_data->sid_pos);
}
for_each_sg(map->table->sgl, sgl, map->table->nents,
sgl_index)
@@ -2283,6 +2298,19 @@ static int fastrpc_get_domain_id(const char *domain)
return -EINVAL;
}
+static const struct fastrpc_soc_data kaanapali_soc_data = {
+ .sid_pos = 56,
+};
+
+static const struct fastrpc_soc_data default_soc_data = {
+ .sid_pos = 32,
+};
+
+static const struct of_device_id qcom_soc_match_table[] = {
+ { .compatible = "qcom,kaanapali", .data = &kaanapali_soc_data },
+ { },
+};
+
static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
{
struct device *rdev = &rpdev->dev;
@@ -2291,6 +2319,22 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
const char *domain;
bool secure_dsp;
unsigned int vmids[FASTRPC_MAX_VMIDS];
+ struct device_node *root;
+ const struct of_device_id *match;
+ const struct fastrpc_soc_data *soc_data = NULL;
+
+ root = of_find_node_by_path("/");
+ if (!root)
+ return -ENODEV;
+
+ match = of_match_node(qcom_soc_match_table, root);
+ of_node_put(root);
+ if (!match || !match->data) {
+ soc_data = &default_soc_data;
+ dev_dbg(rdev, "no compatible SoC found at root node\n");
+ } else {
+ soc_data = match->data;
+ }
err = of_property_read_string(rdev->of_node, "label", &domain);
if (err) {
@@ -2343,6 +2387,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain"));
data->secure = secure_dsp;
+ data->soc_data = soc_data;
switch (domain_id) {
case ADSP_DOMAIN_ID:
--
2.34.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 3/3] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC
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 4:57 ` [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting Kumari Pallavi
@ 2025-10-15 4:57 ` Kumari Pallavi
2025-10-15 7:06 ` Arnd Bergmann
2025-10-15 9:25 ` Srinivas Kandagatla
2 siblings, 2 replies; 18+ messages in thread
From: Kumari Pallavi @ 2025-10-15 4:57 UTC (permalink / raw)
To: kpallavi, srini, amahesh, arnd, gregkh
Cc: Kumari Pallavi, quic_bkumar, ekansh.gupta, linux-kernel,
quic_chennak, dri-devel, linux-arm-msm, jingyi.wang, aiqun.yu,
ktadakam
DSP currently supports 32-bit IOVA (32-bit PA + 4-bit SID) for
both Q6 and user DMA (uDMA) access. This is being upgraded to
34-bit PA + 4-bit SID due to a hardware revision in CDSP for
Kaanapali SoC, which expands the DMA addressable range.
Update DMA mask configuration in the driver to support CDSP on
Kaanapali SoC. Set the default `dma_mask` to 32-bit and update
it to 34-bit based on CDSP and SoC-specific compatible string.
Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 1a5d620b23f2..f2e5e53e9067 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -267,6 +267,7 @@ struct fastrpc_session_ctx {
struct fastrpc_soc_data {
u32 sid_pos;
+ u32 cdsp_dma_mask;
};
struct fastrpc_channel_ctx {
@@ -2178,6 +2179,7 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
int i, sessions = 0;
unsigned long flags;
int rc;
+ u32 dma_mask = 32;
cctx = dev_get_drvdata(dev->parent);
if (!cctx)
@@ -2197,6 +2199,9 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
sess->dev = dev;
dev_set_drvdata(dev, sess);
+ if (cctx->domain_id == CDSP_DOMAIN_ID)
+ dma_mask = cctx->soc_data->cdsp_dma_mask;
+
if (of_property_read_u32(dev->of_node, "reg", &sess->sid))
dev_info(dev, "FastRPC Session ID not specified in DT\n");
@@ -2211,9 +2216,9 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
}
}
spin_unlock_irqrestore(&cctx->lock, flags);
- rc = dma_set_mask(dev, DMA_BIT_MASK(32));
+ rc = dma_set_mask(dev, DMA_BIT_MASK(dma_mask));
if (rc) {
- dev_err(dev, "32-bit DMA enable failed\n");
+ dev_err(dev, "%u-bit DMA enable failed\n", dma_mask);
return rc;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 3/3] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC
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
1 sibling, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2025-10-15 7:06 UTC (permalink / raw)
To: Kumari Pallavi, kpallavi, Srinivas Kandagatla, Amol Maheshwari,
Greg Kroah-Hartman
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, Jingyi Wang, aiqun.yu, ktadakam
On Wed, Oct 15, 2025, at 06:57, Kumari Pallavi wrote:
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 1a5d620b23f2..f2e5e53e9067 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -267,6 +267,7 @@ struct fastrpc_session_ctx {
>
> struct fastrpc_soc_data {
> u32 sid_pos;
> + u32 cdsp_dma_mask;
> };
I see that you add the field here, but it is not initialized
anywhere. Did the initialization get lost in a rebase?
Also, this is not the mask but the address width,
so maybe rename it to cdsp_dma_bits?
Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting
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-18 17:24 ` Krzysztof Kozlowski
2 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2025-10-15 7:09 UTC (permalink / raw)
To: Kumari Pallavi, kpallavi, Srinivas Kandagatla, Amol Maheshwari,
Greg Kroah-Hartman
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, Jingyi Wang, aiqun.yu, ktadakam
On Wed, Oct 15, 2025, at 06:57, Kumari Pallavi wrote:
> @@ -2291,6 +2319,22 @@ static int fastrpc_rpmsg_probe(struct
> rpmsg_device *rpdev)
> const char *domain;
> bool secure_dsp;
> unsigned int vmids[FASTRPC_MAX_VMIDS];
> + struct device_node *root;
> + const struct of_device_id *match;
> + const struct fastrpc_soc_data *soc_data = NULL;
> +
> + root = of_find_node_by_path("/");
> + if (!root)
> + return -ENODEV;
> +
> + match = of_match_node(qcom_soc_match_table, root);
> + of_node_put(root);
> + if (!match || !match->data) {
> + soc_data = &default_soc_data;
> + dev_dbg(rdev, "no compatible SoC found at root node\n");
> + } else {
> + soc_data = match->data;
> + }
>
Matching on the type of the root node is not great, as this
is both a layering violation and does not scale if you need
to do the same thing for future chip generations.
Normally this should be matched on the device compatible
string itself, or possibly based on one of its properties.
If this fails because there are already dtb files in the
open that have to keep getting supported and there is no
identifier in the fastrpc device itself, you can use
soc_device_match() as a last resort to match on the the
soc.
Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/3] misc: fastrpc: Rename phys to dma_addr for clarity
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
1 sibling, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2025-10-15 7:20 UTC (permalink / raw)
To: Kumari Pallavi, kpallavi, Srinivas Kandagatla, Amol Maheshwari,
Greg Kroah-Hartman
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, Jingyi Wang, aiqun.yu, ktadakam
On Wed, Oct 15, 2025, at 06:57, 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>
Thanks for the update!
> &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
> 0x%llx size 0x%llx err %d\n",
> + map->dma_addr, map->len, err);
> return;
Note that using %llx is not a portable way to print a dma_addr_t,
you should use %pad instead even if your method works on all
arm64 configurations.
%pad requires passing the dma_addr_t variable by reference though.
> @@ -783,10 +783,10 @@ static int fastrpc_map_attach(struct fastrpc_user
> *fl, int fd,
> map->table = table;
>
> if (attr & FASTRPC_ATTR_SECUREMAP) {
> - map->phys = sg_phys(map->table->sgl);
> + map->dma_addr = sg_phys(map->table->sgl);
> } else {
This is technically still wrong, because sg_phys() returns
a phys_addr_t that is only the same as the dma_addr_t value
if there is no iommu or dma offset.
At the minimum, this requires a comment explaining what you
are doing here, and I would add a '(dma_addr_t)' cast as
well.
If possible, use sg_dma_address() instead of sg_phys() for
portability if they produce the same bit value.
> @@ -813,10 +813,10 @@ static int fastrpc_map_attach(struct fastrpc_user
> *fl, int fd,
> dst_perms[1].vmid = fl->cctx->vmperms[0].vmid;
> dst_perms[1].perm = QCOM_SCM_PERM_RWX;
> map->attr = attr;
> - err = qcom_scm_assign_mem(map->phys, (u64)map->len, &src_perms,
> dst_perms, 2);
> + err = qcom_scm_assign_mem(map->dma_addr, (u64)map->len, &src_perms,
This one has the reverse problem, as qcom_scm_assign_mem() takes
a phys_addr_t instead of a dma_addr_t, again relying on the
absence of an iommu.
> dst_perms, 2);
> if (err) {
> - dev_err(sess->dev, "Failed to assign memory with phys 0x%llx size
> 0x%llx err %d\n",
> - map->phys, map->len, err);
> + dev_err(sess->dev, "Failed to assign memory with dma_addr 0x%llx
> size 0x%llx err %d\n",
> + map->dma_addr, map->len, err);
> goto map_err;
%pad
> }
> }
> @@ -1007,7 +1007,7 @@ static int fastrpc_get_args(u32 kernel, struct
> fastrpc_invoke_ctx *ctx)
> struct vm_area_struct *vma = NULL;
>
> rpra[i].buf.pv = (u64) ctx->args[i].ptr;
> - pages[i].addr = ctx->maps[i]->phys;
> + pages[i].addr = ctx->maps[i]->dma_addr;
>
pages[i].addr is declared as
"u64 addr; /* physical address */"
I guess the other side of this is the same CPU in a different
exception level instead of an external device, right? This
could also use a clarification.
Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting
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:24 ` Krzysztof Kozlowski
2 siblings, 1 reply; 18+ messages in thread
From: Srinivas Kandagatla @ 2025-10-15 8:52 UTC (permalink / raw)
To: Kumari Pallavi, kpallavi, srini, amahesh, arnd, gregkh
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, jingyi.wang, aiqun.yu, ktadakam
On 10/15/25 5:57 AM, Kumari Pallavi wrote:
> Implement the new IOVA formatting required by the DSP architecture change
> on Kaanapali SoC. Place the SID for DSP DMA transactions at bit 56 in the
> physical address. This placement is necessary for the DSPs to correctly
> identify streams and operate as intended.
> To address this, set SID position to bit 56 based on SoC-specific compatible
> string from the root node within the physical address; otherwise, default to
> legacy 32-bit placement.
> This change ensures consistent SID placement across DSPs.
>
> Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
> ---
> drivers/misc/fastrpc.c | 59 +++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 52 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 975be54a2491..1a5d620b23f2 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -33,7 +33,6 @@
> #define FASTRPC_ALIGN 128
> #define FASTRPC_MAX_FDLIST 16
> #define FASTRPC_MAX_CRCLIST 64
> -#define FASTRPC_PHYS(p) ((p) & 0xffffffff)
> #define FASTRPC_CTX_MAX (256)
> #define FASTRPC_INIT_HANDLE 1
> #define FASTRPC_DSP_UTILITIES_HANDLE 2
> @@ -105,6 +104,15 @@
>
> #define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev)
>
> +/* Extract smmu pa from consolidated iova */
> +#define IPA_TO_DMA_ADDR(iova, sid_pos) (iova & ((1ULL << sid_pos) - 1ULL))
> +/*
> + * Prepare the consolidated iova to send to dsp by prepending the sid
> + * to smmu pa at the appropriate position
> + */
> +#define IOVA_FROM_SID_PA(sid, phys, sid_pos) \
> + (phys += sid << sid_pos)
> +
> struct fastrpc_phy_page {
> u64 addr; /* physical address */
> u64 size; /* size of contiguous region */
> @@ -257,6 +265,10 @@ struct fastrpc_session_ctx {
> bool valid;
> };
>
> +struct fastrpc_soc_data {
> + u32 sid_pos;
> +};
> +
> struct fastrpc_channel_ctx {
> int domain_id;
> int sesscount;
> @@ -278,6 +290,7 @@ struct fastrpc_channel_ctx {
> bool secure;
> bool unsigned_support;
> u64 dma_mask;
> + const struct fastrpc_soc_data *soc_data;
> };
>
> struct fastrpc_device {
> @@ -387,7 +400,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->dma_addr));
> + IPA_TO_DMA_ADDR(buf->dma_addr, buf->fl->cctx->soc_data->sid_pos));
> kfree(buf);
> }
>
> @@ -437,8 +450,7 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev,
> buf = *obuf;
>
> if (fl->sctx && fl->sctx->sid)
> - buf->dma_addr += ((u64)fl->sctx->sid << 32);
> -
> + IOVA_FROM_SID_PA((u64)fl->sctx->sid, buf->dma_addr, fl->cctx->soc_data->sid_pos);
deleted an empty line for no reason.
> return 0;
> }
>
> @@ -682,7 +694,8 @@ 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->dma_addr), buffer->size);
> + IPA_TO_DMA_ADDR(buffer->dma_addr, buffer->fl->cctx->soc_data->sid_pos),
> + buffer->size);
> if (ret < 0) {
> dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
> kfree(a);
> @@ -731,7 +744,8 @@ static int fastrpc_mmap(struct dma_buf *dmabuf,
> dma_resv_assert_held(dmabuf->resv);
>
> return dma_mmap_coherent(buf->dev, vma, buf->virt,
> - FASTRPC_PHYS(buf->dma_addr), size);
> + IPA_TO_DMA_ADDR(buf->dma_addr,
> + buf->fl->cctx->soc_data->sid_pos), size);
> }
>
> static const struct dma_buf_ops fastrpc_dma_buf_ops = {
> @@ -786,7 +800,8 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
> map->dma_addr = sg_phys(map->table->sgl);
> } else {
> map->dma_addr = sg_dma_address(map->table->sgl);
> - map->dma_addr += ((u64)fl->sctx->sid << 32);
> + IOVA_FROM_SID_PA((u64)fl->sctx->sid,
> + map->dma_addr, fl->cctx->soc_data->sid_pos);
> }
> for_each_sg(map->table->sgl, sgl, map->table->nents,
> sgl_index)
> @@ -2283,6 +2298,19 @@ static int fastrpc_get_domain_id(const char *domain)
> return -EINVAL;
> }
>
> +static const struct fastrpc_soc_data kaanapali_soc_data = {
> + .sid_pos = 56,
> +};
> +
> +static const struct fastrpc_soc_data default_soc_data = {
> + .sid_pos = 32,
> +};
> +
> +static const struct of_device_id qcom_soc_match_table[] = {
> + { .compatible = "qcom,kaanapali", .data = &kaanapali_soc_data },
> + { },
> +};
> +
> static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> {
> struct device *rdev = &rpdev->dev;
> @@ -2291,6 +2319,22 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> const char *domain;
> bool secure_dsp;
> unsigned int vmids[FASTRPC_MAX_VMIDS];
> + struct device_node *root;
> + const struct of_device_id *match;
> + const struct fastrpc_soc_data *soc_data = NULL;
> +
> + root = of_find_node_by_path("/");
> + if (!root)
> + return -ENODEV;
> +
> + match = of_match_node(qcom_soc_match_table, root);
> + of_node_put(root);
> + if (!match || !match->data) {
> + soc_data = &default_soc_data;
> + dev_dbg(rdev, "no compatible SoC found at root node\n");
> + } else {
> + soc_data = match->data;
> + }
>
I think you will be better off moving this to below helper function,
this will simplify the code to:
soc_data = of_machine_get_match_data(qcom_soc_match_table);
if (!soc_data)
soc_data = &default_soc_data;
------------------------>cut<-----------------
Author: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Date: Sat Oct 4 15:09:46 2025 +0100
of: base: add of_machine_get_match_data helper function
There are atleast 3 instances of this code in drivers, add a helper
function of_machine_get_match_data to avoid code duplication and better
error handling.
Signed-off-by: Srinivas Kandagatla
<srinivas.kandagatla@oss.qualcomm.com>
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 7043acd971a0..ac4b965f06b6 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -434,6 +434,32 @@ bool of_machine_compatible_match(const char *const
*compats)
}
EXPORT_SYMBOL(of_machine_compatible_match);
+/**
+ * of_machine_get_match_data - Test root of device tree against a
compatible array
+ * and return data associated with match.
+ * @compats: NULL terminated array of compatible strings to look for in
root node's compatible property.
+ *
+ * Returns match data if the root node has any of the given compatible
values in its or NULL if
+ * compatible property nodes not match with compats.
+ */
+const void *of_machine_get_match_data(const char *const *compats)
+{
+ const struct of_device_id *match = NULL;
+ struct device_node *root;
+
+ root = of_find_node_by_path("/");
+ if (root) {
+ match = of_match_node(compats, root);
+ of_node_put(root);
+ }
+
+ if (!match)
+ return NULL;
+
+ return match->data;
+}
+EXPORT_SYMBOL(of_machine_get_match_data);
+
static bool __of_device_is_status(const struct device_node *device,
const char * const*strings)
{
diff --git a/include/linux/of.h b/include/linux/of.h
index a62154aeda1b..4d6792abf5f7 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -407,6 +407,7 @@ extern int of_alias_get_id(const struct device_node
*np, const char *stem);
extern int of_alias_get_highest_id(const char *stem);
bool of_machine_compatible_match(const char *const *compats);
+void *of_machine_get_match_data(const char *const *compats);
/**
* of_machine_is_compatible - Test root of device tree for a given
compatible value
------------------------>cut<-----------------
> err = of_property_read_string(rdev->of_node, "label", &domain);
> if (err) {
> @@ -2343,6 +2387,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>
> secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain"));
> data->secure = secure_dsp;
> + data->soc_data = soc_data;
>
> switch (domain_id) {
> case ADSP_DOMAIN_ID:
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v2 3/3] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC
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
1 sibling, 1 reply; 18+ messages in thread
From: Srinivas Kandagatla @ 2025-10-15 9:25 UTC (permalink / raw)
To: Kumari Pallavi, kpallavi, srini, amahesh, arnd, gregkh
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, jingyi.wang, aiqun.yu, ktadakam
On 10/15/25 5:57 AM, Kumari Pallavi wrote:
> DSP currently supports 32-bit IOVA (32-bit PA + 4-bit SID) for
> both Q6 and user DMA (uDMA) access. This is being upgraded to
> 34-bit PA + 4-bit SID due to a hardware revision in CDSP for
> Kaanapali SoC, which expands the DMA addressable range.
> Update DMA mask configuration in the driver to support CDSP on
> Kaanapali SoC. Set the default `dma_mask` to 32-bit and update
> it to 34-bit based on CDSP and SoC-specific compatible string.
>
> Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
> ---
> drivers/misc/fastrpc.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 1a5d620b23f2..f2e5e53e9067 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -267,6 +267,7 @@ struct fastrpc_session_ctx {
>
> struct fastrpc_soc_data {
> u32 sid_pos;
> + u32 cdsp_dma_mask;
How about making this an actual dmamask ex:
u64 cdsp_dma_mask == DMA_BIT_MASK(64),
u64 dma_mask == DMA_BIT_MASK(32),
This will give more clear picture of what is going on,
BTW, these values are not set in the patch for some reason for both
default and soc specific soc data>
> struct fastrpc_channel_ctx {
> @@ -2178,6 +2179,7 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
> int i, sessions = 0;
> unsigned long flags;
> int rc;
> + u32 dma_mask = 32;this should come from default soc_data, do not hardcode this here.
u64 dma_mask = default_soc_data->dma_mask;>
> cctx = dev_get_drvdata(dev->parent);
> if (!cctx)
> @@ -2197,6 +2199,9 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
> sess->dev = dev;
> dev_set_drvdata(dev, sess);> + if (cctx->domain_id == CDSP_DOMAIN_ID)
> + dma_mask = cctx->soc_data->cdsp_dma_mask;
> +
> if (of_property_read_u32(dev->of_node, "reg", &sess->sid))
> dev_info(dev, "FastRPC Session ID not specified in DT\n");
>
> @@ -2211,9 +2216,9 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
> }
> }
> spin_unlock_irqrestore(&cctx->lock, flags);
> - rc = dma_set_mask(dev, DMA_BIT_MASK(32));
> + rc = dma_set_mask(dev, DMA_BIT_MASK(dma_mask));
> if (rc) {
> - dev_err(dev, "32-bit DMA enable failed\n");
> + dev_err(dev, "%u-bit DMA enable failed\n", dma_mask);
> return rc;
> }
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/3] misc: fastrpc: Rename phys to dma_addr for clarity
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:07 ` Dmitry Baryshkov
2025-10-23 7:20 ` Kumari Pallavi
1 sibling, 1 reply; 18+ messages in thread
From: Dmitry Baryshkov @ 2025-10-15 10:07 UTC (permalink / raw)
To: Kumari Pallavi
Cc: kpallavi, srini, amahesh, arnd, gregkh, quic_bkumar, ekansh.gupta,
linux-kernel, quic_chennak, dri-devel, linux-arm-msm, jingyi.wang,
aiqun.yu, ktadakam
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?
> 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?
> if (ret < 0) {
> dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
> kfree(a);
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting
2025-10-15 8:52 ` Srinivas Kandagatla
@ 2025-10-15 10:47 ` Kumari Pallavi
2025-10-18 17:25 ` Krzysztof Kozlowski
0 siblings, 1 reply; 18+ messages in thread
From: Kumari Pallavi @ 2025-10-15 10:47 UTC (permalink / raw)
To: Srinivas Kandagatla, kpallavi, amahesh, arnd, gregkh
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, jingyi.wang, aiqun.yu, ktadakam
On 10/15/2025 2:22 PM, Srinivas Kandagatla wrote:
>
>
> On 10/15/25 5:57 AM, Kumari Pallavi wrote:
>> Implement the new IOVA formatting required by the DSP architecture change
>> on Kaanapali SoC. Place the SID for DSP DMA transactions at bit 56 in the
>> physical address. This placement is necessary for the DSPs to correctly
>> identify streams and operate as intended.
>> To address this, set SID position to bit 56 based on SoC-specific compatible
>> string from the root node within the physical address; otherwise, default to
>> legacy 32-bit placement.
>> This change ensures consistent SID placement across DSPs.
>>
>> Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
>> ---
>> drivers/misc/fastrpc.c | 59 +++++++++++++++++++++++++++++++++++++-----
>> 1 file changed, 52 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
>> index 975be54a2491..1a5d620b23f2 100644
>> --- a/drivers/misc/fastrpc.c
>> +++ b/drivers/misc/fastrpc.c
>> @@ -33,7 +33,6 @@
>> #define FASTRPC_ALIGN 128
>> #define FASTRPC_MAX_FDLIST 16
>> #define FASTRPC_MAX_CRCLIST 64
>> -#define FASTRPC_PHYS(p) ((p) & 0xffffffff)
>> #define FASTRPC_CTX_MAX (256)
>> #define FASTRPC_INIT_HANDLE 1
>> #define FASTRPC_DSP_UTILITIES_HANDLE 2
>> @@ -105,6 +104,15 @@
>>
>> #define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev)
>>
>> +/* Extract smmu pa from consolidated iova */
>> +#define IPA_TO_DMA_ADDR(iova, sid_pos) (iova & ((1ULL << sid_pos) - 1ULL))
>> +/*
>> + * Prepare the consolidated iova to send to dsp by prepending the sid
>> + * to smmu pa at the appropriate position
>> + */
>> +#define IOVA_FROM_SID_PA(sid, phys, sid_pos) \
>> + (phys += sid << sid_pos)
>> +
>> struct fastrpc_phy_page {
>> u64 addr; /* physical address */
>> u64 size; /* size of contiguous region */
>> @@ -257,6 +265,10 @@ struct fastrpc_session_ctx {
>> bool valid;
>> };
>>
>> +struct fastrpc_soc_data {
>> + u32 sid_pos;
>> +};
>> +
>> struct fastrpc_channel_ctx {
>> int domain_id;
>> int sesscount;
>> @@ -278,6 +290,7 @@ struct fastrpc_channel_ctx {
>> bool secure;
>> bool unsigned_support;
>> u64 dma_mask;
>> + const struct fastrpc_soc_data *soc_data;
>> };
>>
>> struct fastrpc_device {
>> @@ -387,7 +400,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->dma_addr));
>> + IPA_TO_DMA_ADDR(buf->dma_addr, buf->fl->cctx->soc_data->sid_pos));
>> kfree(buf);
>> }
>>
>> @@ -437,8 +450,7 @@ static int fastrpc_buf_alloc(struct fastrpc_user *fl, struct device *dev,
>> buf = *obuf;
>>
>> if (fl->sctx && fl->sctx->sid)
>> - buf->dma_addr += ((u64)fl->sctx->sid << 32);
>> -
>> + IOVA_FROM_SID_PA((u64)fl->sctx->sid, buf->dma_addr, fl->cctx->soc_data->sid_pos);
>
> deleted an empty line for no reason.
>
Ack.
>> return 0;
>> }
>>
>> @@ -682,7 +694,8 @@ 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->dma_addr), buffer->size);
>> + IPA_TO_DMA_ADDR(buffer->dma_addr, buffer->fl->cctx->soc_data->sid_pos),
>> + buffer->size);
>> if (ret < 0) {
>> dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
>> kfree(a);
>> @@ -731,7 +744,8 @@ static int fastrpc_mmap(struct dma_buf *dmabuf,
>> dma_resv_assert_held(dmabuf->resv);
>>
>> return dma_mmap_coherent(buf->dev, vma, buf->virt,
>> - FASTRPC_PHYS(buf->dma_addr), size);
>> + IPA_TO_DMA_ADDR(buf->dma_addr,
>> + buf->fl->cctx->soc_data->sid_pos), size);
>> }
>>
>> static const struct dma_buf_ops fastrpc_dma_buf_ops = {
>> @@ -786,7 +800,8 @@ static int fastrpc_map_attach(struct fastrpc_user *fl, int fd,
>> map->dma_addr = sg_phys(map->table->sgl);
>> } else {
>> map->dma_addr = sg_dma_address(map->table->sgl);
>> - map->dma_addr += ((u64)fl->sctx->sid << 32);
>> + IOVA_FROM_SID_PA((u64)fl->sctx->sid,
>> + map->dma_addr, fl->cctx->soc_data->sid_pos);
>> }
>> for_each_sg(map->table->sgl, sgl, map->table->nents,
>> sgl_index)
>> @@ -2283,6 +2298,19 @@ static int fastrpc_get_domain_id(const char *domain)
>> return -EINVAL;
>> }
>>
>> +static const struct fastrpc_soc_data kaanapali_soc_data = {
>> + .sid_pos = 56,
>> +};
>> +
>> +static const struct fastrpc_soc_data default_soc_data = {
>> + .sid_pos = 32,
>> +};
>> +
>> +static const struct of_device_id qcom_soc_match_table[] = {
>> + { .compatible = "qcom,kaanapali", .data = &kaanapali_soc_data },
>> + { },
>> +};
>> +
>> static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>> {
>> struct device *rdev = &rpdev->dev;
>> @@ -2291,6 +2319,22 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>> const char *domain;
>> bool secure_dsp;
>> unsigned int vmids[FASTRPC_MAX_VMIDS];
>> + struct device_node *root;
>> + const struct of_device_id *match;
>> + const struct fastrpc_soc_data *soc_data = NULL;
>> +
>> + root = of_find_node_by_path("/");
>> + if (!root)
>> + return -ENODEV;
>> +
>> + match = of_match_node(qcom_soc_match_table, root);
>> + of_node_put(root);
>> + if (!match || !match->data) {
>> + soc_data = &default_soc_data;
>> + dev_dbg(rdev, "no compatible SoC found at root node\n");
>> + } else {
>> + soc_data = match->data;
>> + }
>>
>
> I think you will be better off moving this to below helper function,
> this will simplify the code to:
>
> soc_data = of_machine_get_match_data(qcom_soc_match_table);
> if (!soc_data)
> soc_data = &default_soc_data;
>
> ------------------------>cut<-----------------
> Author: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
> Date: Sat Oct 4 15:09:46 2025 +0100
>
> of: base: add of_machine_get_match_data helper function
>
> There are atleast 3 instances of this code in drivers, add a helper
> function of_machine_get_match_data to avoid code duplication and better
> error handling.
>
> Signed-off-by: Srinivas Kandagatla
> <srinivas.kandagatla@oss.qualcomm.com>
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 7043acd971a0..ac4b965f06b6 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -434,6 +434,32 @@ bool of_machine_compatible_match(const char *const
> *compats)
> }
> EXPORT_SYMBOL(of_machine_compatible_match);
>
> +/**
> + * of_machine_get_match_data - Test root of device tree against a
> compatible array
> + * and return data associated with match.
> + * @compats: NULL terminated array of compatible strings to look for in
> root node's compatible property.
> + *
> + * Returns match data if the root node has any of the given compatible
> values in its or NULL if
> + * compatible property nodes not match with compats.
> + */
> +const void *of_machine_get_match_data(const char *const *compats)
> +{
> + const struct of_device_id *match = NULL;
> + struct device_node *root;
> +
> + root = of_find_node_by_path("/");
> + if (root) {
> + match = of_match_node(compats, root);
> + of_node_put(root);
> + }
> +
> + if (!match)
> + return NULL;
> +
> + return match->data;
> +}
> +EXPORT_SYMBOL(of_machine_get_match_data);
> +
> static bool __of_device_is_status(const struct device_node *device,
> const char * const*strings)
> {
> diff --git a/include/linux/of.h b/include/linux/of.h
> index a62154aeda1b..4d6792abf5f7 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -407,6 +407,7 @@ extern int of_alias_get_id(const struct device_node
> *np, const char *stem);
> extern int of_alias_get_highest_id(const char *stem);
>
> bool of_machine_compatible_match(const char *const *compats);
> +void *of_machine_get_match_data(const char *const *compats);
>
> /**
> * of_machine_is_compatible - Test root of device tree for a given
> compatible value
>
> ------------------------>cut<-----------------
>
Ack.
>> err = of_property_read_string(rdev->of_node, "label", &domain);
>> if (err) {
>> @@ -2343,6 +2387,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>>
>> secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain"));
>> data->secure = secure_dsp;
>> + data->soc_data = soc_data;
>>
>> switch (domain_id) {
>> case ADSP_DOMAIN_ID:
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 3/3] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC
2025-10-15 9:25 ` Srinivas Kandagatla
@ 2025-10-15 10:47 ` Kumari Pallavi
0 siblings, 0 replies; 18+ messages in thread
From: Kumari Pallavi @ 2025-10-15 10:47 UTC (permalink / raw)
To: Srinivas Kandagatla, kpallavi, amahesh, arnd, gregkh
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, jingyi.wang, aiqun.yu, ktadakam
On 10/15/2025 2:55 PM, Srinivas Kandagatla wrote:
>
>
> On 10/15/25 5:57 AM, Kumari Pallavi wrote:
>> DSP currently supports 32-bit IOVA (32-bit PA + 4-bit SID) for
>> both Q6 and user DMA (uDMA) access. This is being upgraded to
>> 34-bit PA + 4-bit SID due to a hardware revision in CDSP for
>> Kaanapali SoC, which expands the DMA addressable range.
>> Update DMA mask configuration in the driver to support CDSP on
>> Kaanapali SoC. Set the default `dma_mask` to 32-bit and update
>> it to 34-bit based on CDSP and SoC-specific compatible string.
>>
>> Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
>> ---
>> drivers/misc/fastrpc.c | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
>> index 1a5d620b23f2..f2e5e53e9067 100644
>> --- a/drivers/misc/fastrpc.c
>> +++ b/drivers/misc/fastrpc.c
>> @@ -267,6 +267,7 @@ struct fastrpc_session_ctx {
>>
>> struct fastrpc_soc_data {
>> u32 sid_pos;
>> + u32 cdsp_dma_mask;
> How about making this an actual dmamask ex:
>
> u64 cdsp_dma_mask == DMA_BIT_MASK(64),
> u64 dma_mask == DMA_BIT_MASK(32),
>
> This will give more clear picture of what is going on,
>
The current approach of assigning a value to cdsp_dma_mask allows for
adaptable logging behavior, making it easier to trace.
> BTW, these values are not set in the patch for some reason for both
> default and soc specific soc data>
Ack.
>> struct fastrpc_channel_ctx {
>> @@ -2178,6 +2179,7 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
>> int i, sessions = 0;
>> unsigned long flags;
>> int rc;
>> + u32 dma_mask = 32;this should come from default soc_data, do not hardcode this here.
> u64 dma_mask = default_soc_data->dma_mask;>
Ack.
>> cctx = dev_get_drvdata(dev->parent);
>> if (!cctx)
>> @@ -2197,6 +2199,9 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
>> sess->dev = dev;
>> dev_set_drvdata(dev, sess);> + if (cctx->domain_id == CDSP_DOMAIN_ID)
>> + dma_mask = cctx->soc_data->cdsp_dma_mask;
>> +
>
>> if (of_property_read_u32(dev->of_node, "reg", &sess->sid))
>> dev_info(dev, "FastRPC Session ID not specified in DT\n");
>>
>> @@ -2211,9 +2216,9 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
>> }
>> }
>> spin_unlock_irqrestore(&cctx->lock, flags);
>> - rc = dma_set_mask(dev, DMA_BIT_MASK(32));
>> + rc = dma_set_mask(dev, DMA_BIT_MASK(dma_mask));
>> if (rc) {
>> - dev_err(dev, "32-bit DMA enable failed\n");
>> + dev_err(dev, "%u-bit DMA enable failed\n", dma_mask);
>> return rc;
>> }
>>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/3] misc: fastrpc: Rename phys to dma_addr for clarity
2025-10-15 7:20 ` Arnd Bergmann
@ 2025-10-15 10:49 ` Kumari Pallavi
0 siblings, 0 replies; 18+ messages in thread
From: Kumari Pallavi @ 2025-10-15 10:49 UTC (permalink / raw)
To: Arnd Bergmann, kpallavi, Srinivas Kandagatla, Amol Maheshwari,
Greg Kroah-Hartman
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, Jingyi Wang, aiqun.yu, ktadakam
On 10/15/2025 12:50 PM, Arnd Bergmann wrote:
> On Wed, Oct 15, 2025, at 06:57, 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>
>
> Thanks for the update!
>
>> &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
>> 0x%llx size 0x%llx err %d\n",
>> + map->dma_addr, map->len, err);
>> return;
>
> Note that using %llx is not a portable way to print a dma_addr_t,
> you should use %pad instead even if your method works on all
> arm64 configurations.
>
> %pad requires passing the dma_addr_t variable by reference though.
>
Ack.
>> @@ -783,10 +783,10 @@ static int fastrpc_map_attach(struct fastrpc_user
>> *fl, int fd,
>> map->table = table;
>>
>> if (attr & FASTRPC_ATTR_SECUREMAP) {
>> - map->phys = sg_phys(map->table->sgl);
>> + map->dma_addr = sg_phys(map->table->sgl);
>> } else {
>
> This is technically still wrong, because sg_phys() returns
> a phys_addr_t that is only the same as the dma_addr_t value
> if there is no iommu or dma offset.
>
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
> At the minimum, this requires a comment explaining what you
> are doing here, and I would add a '(dma_addr_t)' cast as
> well.
>
To ensure clarity, i will add the comment. Adding '(dma_addr_t)' cast
result in incorrect behavior due to potential offsets.
> If possible, use sg_dma_address() instead of sg_phys() for
> portability if they produce the same bit value.
>
>> @@ -813,10 +813,10 @@ static int fastrpc_map_attach(struct fastrpc_user
>> *fl, int fd,
>> dst_perms[1].vmid = fl->cctx->vmperms[0].vmid;
>> dst_perms[1].perm = QCOM_SCM_PERM_RWX;
>> map->attr = attr;
>> - err = qcom_scm_assign_mem(map->phys, (u64)map->len, &src_perms,
>> dst_perms, 2);
>> + err = qcom_scm_assign_mem(map->dma_addr, (u64)map->len, &src_perms,
>
> This one has the reverse problem, as qcom_scm_assign_mem() takes
> a phys_addr_t instead of a dma_addr_t, again relying on the
> absence of an iommu.
>
>> dst_perms, 2);
>> if (err) {
>> - dev_err(sess->dev, "Failed to assign memory with phys 0x%llx size
>> 0x%llx err %d\n",
>> - map->phys, map->len, err);
>> + dev_err(sess->dev, "Failed to assign memory with dma_addr 0x%llx
>> size 0x%llx err %d\n",
>> + map->dma_addr, map->len, err);
>> goto map_err;
>
> %pad
>
Ack
>> }
>> }
>> @@ -1007,7 +1007,7 @@ static int fastrpc_get_args(u32 kernel, struct
>> fastrpc_invoke_ctx *ctx)
>> struct vm_area_struct *vma = NULL;
>>
>> rpra[i].buf.pv = (u64) ctx->args[i].ptr;
>> - pages[i].addr = ctx->maps[i]->phys;
>> + pages[i].addr = ctx->maps[i]->dma_addr;
>>
>
> pages[i].addr is declared as
>
> "u64 addr; /* physical address */"
>
> I guess the other side of this is the same CPU in a different
> exception level instead of an external device, right? This
> could also use a clarification.
>
Ack
> Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting
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-18 17:24 ` Krzysztof Kozlowski
2025-10-23 8:35 ` Kumari Pallavi
2 siblings, 1 reply; 18+ messages in thread
From: Krzysztof Kozlowski @ 2025-10-18 17:24 UTC (permalink / raw)
To: Kumari Pallavi, kpallavi, srini, amahesh, arnd, gregkh
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, jingyi.wang, aiqun.yu, ktadakam
On 15/10/2025 06:57, Kumari Pallavi wrote:
> static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> {
> struct device *rdev = &rpdev->dev;
> @@ -2291,6 +2319,22 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> const char *domain;
> bool secure_dsp;
> unsigned int vmids[FASTRPC_MAX_VMIDS];
> + struct device_node *root;
> + const struct of_device_id *match;
> + const struct fastrpc_soc_data *soc_data = NULL;
> +
> + root = of_find_node_by_path("/");
> + if (!root)
> + return -ENODEV;
> +
> + match = of_match_node(qcom_soc_match_table, root);
This is really odd way of doing things. You want to check machine, not
some node. Use proper API for that.
OTOH, I don't understand why you are checking machine in the first
place. If your device is different, then please follow writing bindings
- it explains exactly this case here.
> + of_node_put(root);
> + if (!match || !match->data) {
> + soc_data = &default_soc_data;
> + dev_dbg(rdev, "no compatible SoC found at root node\n");
> + } else {
> + soc_data = match->data;
> + }
>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting
2025-10-15 10:47 ` Kumari Pallavi
@ 2025-10-18 17:25 ` Krzysztof Kozlowski
0 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2025-10-18 17:25 UTC (permalink / raw)
To: Kumari Pallavi, Srinivas Kandagatla, kpallavi, amahesh, arnd,
gregkh
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, jingyi.wang, aiqun.yu, ktadakam
On 15/10/2025 12:47, Kumari Pallavi wrote:
>> /**
>> * of_machine_is_compatible - Test root of device tree for a given
>> compatible value
>>
>> ------------------------>cut<-----------------
>>
>
> Ack.
No. Read carefully other comments.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 1/3] misc: fastrpc: Rename phys to dma_addr for clarity
2025-10-15 10:07 ` Dmitry Baryshkov
@ 2025-10-23 7:20 ` Kumari Pallavi
0 siblings, 0 replies; 18+ messages in thread
From: Kumari Pallavi @ 2025-10-23 7:20 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: kpallavi, srini, amahesh, arnd, gregkh, quic_bkumar, ekansh.gupta,
linux-kernel, quic_chennak, dri-devel, linux-arm-msm, jingyi.wang,
aiqun.yu, ktadakam
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting
2025-10-18 17:24 ` Krzysztof Kozlowski
@ 2025-10-23 8:35 ` Kumari Pallavi
2025-10-23 8:41 ` Krzysztof Kozlowski
0 siblings, 1 reply; 18+ messages in thread
From: Kumari Pallavi @ 2025-10-23 8:35 UTC (permalink / raw)
To: Krzysztof Kozlowski, kpallavi, srini, amahesh, arnd, gregkh
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, jingyi.wang, aiqun.yu, ktadakam
On 10/18/2025 10:54 PM, Krzysztof Kozlowski wrote:
> On 15/10/2025 06:57, Kumari Pallavi wrote:
>> static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>> {
>> struct device *rdev = &rpdev->dev;
>> @@ -2291,6 +2319,22 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>> const char *domain;
>> bool secure_dsp;
>> unsigned int vmids[FASTRPC_MAX_VMIDS];
>> + struct device_node *root;
>> + const struct of_device_id *match;
>> + const struct fastrpc_soc_data *soc_data = NULL;
>> +
>> + root = of_find_node_by_path("/");
>> + if (!root)
>> + return -ENODEV;
>> +
>> + match = of_match_node(qcom_soc_match_table, root);
>
> This is really odd way of doing things. You want to check machine, not
> some node. Use proper API for that.
>
> OTOH, I don't understand why you are checking machine in the first
> place. If your device is different, then please follow writing bindings
> - it explains exactly this case here.
>
On the Kaanapali SoC, enabling ADSP and CDSP functionality requires new
DSP IOVA formatting and hardware-specific configuration. Going forward,
SoC will support the updated IOVA format.
To handle this, we referred to the implementation in
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/soc/qcom/qcom_pd_mapper.c,
which aligns well with the requirements and serves as a suitable
reference for our use case.
If there are alternative approaches or suggestions for handling this
more effectively, we’re happy to discuss and consider them.
>> + of_node_put(root);
>> + if (!match || !match->data) {
>> + soc_data = &default_soc_data;
>> + dev_dbg(rdev, "no compatible SoC found at root node\n");
>> + } else {
>> + soc_data = match->data;
>> + }
>>
>
>
> Best regards,
> Krzysztof
Thanks,
Pallavi
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v2 2/3] misc: fastrpc: Add support for new DSP IOVA formatting
2025-10-23 8:35 ` Kumari Pallavi
@ 2025-10-23 8:41 ` Krzysztof Kozlowski
0 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2025-10-23 8:41 UTC (permalink / raw)
To: Kumari Pallavi, kpallavi, srini, amahesh, arnd, gregkh
Cc: quic_bkumar, ekansh.gupta, linux-kernel, quic_chennak, dri-devel,
linux-arm-msm, jingyi.wang, aiqun.yu, ktadakam
On 23/10/2025 10:35, Kumari Pallavi wrote:
>
>
> On 10/18/2025 10:54 PM, Krzysztof Kozlowski wrote:
>> On 15/10/2025 06:57, Kumari Pallavi wrote:
>>> static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>>> {
>>> struct device *rdev = &rpdev->dev;
>>> @@ -2291,6 +2319,22 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>>> const char *domain;
>>> bool secure_dsp;
>>> unsigned int vmids[FASTRPC_MAX_VMIDS];
>>> + struct device_node *root;
>>> + const struct of_device_id *match;
>>> + const struct fastrpc_soc_data *soc_data = NULL;
>>> +
>>> + root = of_find_node_by_path("/");
>>> + if (!root)
>>> + return -ENODEV;
>>> +
>>> + match = of_match_node(qcom_soc_match_table, root);
>>
>> This is really odd way of doing things. You want to check machine, not
>> some node. Use proper API for that.
>>
>> OTOH, I don't understand why you are checking machine in the first
>> place. If your device is different, then please follow writing bindings
>> - it explains exactly this case here.
>>
>
> On the Kaanapali SoC, enabling ADSP and CDSP functionality requires new
> DSP IOVA formatting and hardware-specific configuration. Going forward,
> SoC will support the updated IOVA format.
> To handle this, we referred to the implementation in
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/soc/qcom/qcom_pd_mapper.c,
Please don't point random files...
> which aligns well with the requirements and serves as a suitable
> reference for our use case.
Nor use corpo language.
> If there are alternative approaches or suggestions for handling this
> more effectively, we’re happy to discuss and consider them.
See writing bindings. They cover this case.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-10-23 8:41 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).