* [PATCH 0/2] Add ADSP and CDSP support on Kaanapali SoC
@ 2025-09-24 23:46 Jingyi Wang
2025-09-24 23:46 ` [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting Jingyi Wang
2025-09-24 23:46 ` [PATCH 2/2] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC Jingyi Wang
0 siblings, 2 replies; 11+ messages in thread
From: Jingyi Wang @ 2025-09-24 23:46 UTC (permalink / raw)
To: Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman
Cc: aiqun.yu, tingwei.zhang, trilok.soni, yijie.yang, linux-arm-msm,
dri-devel, linux-kernel, Jingyi Wang, Kumari Pallavi
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 an `iova_format
flag to the DSP driver. This flag 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, the series updates the DMA mask configuration to reflect the
expanded DMA addressable range.
Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
---
Kumari Pallavi (2):
misc: fastrpc: Add support for new DSP IOVA formatting
misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC
drivers/misc/fastrpc.c | 86 ++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 76 insertions(+), 10 deletions(-)
---
base-commit: ae2d20002576d2893ecaff25db3d7ef9190ac0b6
change-id: 20250918-knp-fastrpc-a1479674d113
Best regards,
--
Jingyi Wang <jingyi.wang@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting
2025-09-24 23:46 [PATCH 0/2] Add ADSP and CDSP support on Kaanapali SoC Jingyi Wang
@ 2025-09-24 23:46 ` Jingyi Wang
2025-09-25 2:25 ` Dmitry Baryshkov
` (3 more replies)
2025-09-24 23:46 ` [PATCH 2/2] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC Jingyi Wang
1 sibling, 4 replies; 11+ messages in thread
From: Jingyi Wang @ 2025-09-24 23:46 UTC (permalink / raw)
To: Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman
Cc: aiqun.yu, tingwei.zhang, trilok.soni, yijie.yang, linux-arm-msm,
dri-devel, linux-kernel, Jingyi Wang, Kumari Pallavi
From: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
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, add an iova-format flag which determines the SID position
within the physical address. Set SID position to bit 56 when iova_format
is enabled; otherwise, default to legacy 32-bit placement.
Initialize the flag to 0 and update to 1 based on SoC-specific compatible
string from the root node.
This change ensures consistent SID placement across DSPs.
Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 76 ++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 68 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 8e1d97873423..db396241b8ce 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,26 @@
#define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev)
+/*
+ * By default, the sid will be prepended adjacent to smmu pa before sending
+ * to DSP. But if the compatible Soc found at root node specifies the new
+ * addressing format to handle pa's of longer widths, then the sid will be
+ * prepended at the position specified in this macro.
+ */
+#define SID_POS_IN_IOVA 56
+
+/* Default width of pa bus from dsp */
+#define DSP_DEFAULT_BUS_WIDTH 32
+
+/* Extract smmu pa from consolidated iova */
+#define IOVA_TO_PHYS(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 */
@@ -255,6 +274,7 @@ struct fastrpc_session_ctx {
int sid;
bool used;
bool valid;
+ u32 sid_pos;
};
struct fastrpc_channel_ctx {
@@ -278,6 +298,7 @@ struct fastrpc_channel_ctx {
bool secure;
bool unsigned_support;
u64 dma_mask;
+ u32 iova_format;
};
struct fastrpc_device {
@@ -391,8 +412,11 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
static void fastrpc_buf_free(struct fastrpc_buf *buf)
{
+ uint32_t sid_pos = (buf->fl->sctx ? buf->fl->sctx->sid_pos :
+ DSP_DEFAULT_BUS_WIDTH);
+
dma_free_coherent(buf->dev, buf->size, buf->virt,
- FASTRPC_PHYS(buf->phys));
+ IOVA_TO_PHYS(buf->phys, sid_pos));
kfree(buf);
}
@@ -442,7 +466,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);
+ IOVA_FROM_SID_PA((u64)fl->sctx->sid, buf->phys, fl->sctx->sid_pos);
return 0;
}
@@ -687,7 +711,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->phys), buffer->size);
+ IOVA_TO_PHYS(buffer->phys, buffer->fl->sctx->sid_pos),
+ buffer->size);
if (ret < 0) {
dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
kfree(a);
@@ -736,7 +761,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);
+ IOVA_TO_PHYS(buf->phys, buf->fl->sctx->sid_pos), size);
}
static const struct dma_buf_ops fastrpc_dma_buf_ops = {
@@ -793,7 +818,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
map->phys = sg_phys(map->table->sgl);
} else {
map->phys = sg_dma_address(map->table->sgl);
- map->phys += ((u64)fl->sctx->sid << 32);
+ IOVA_FROM_SID_PA((u64)fl->sctx->sid, map->phys,
+ fl->sctx->sid_pos);
}
map->size = len;
map->va = sg_virt(map->table->sgl);
@@ -2153,11 +2179,14 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
sess->used = false;
sess->valid = true;
sess->dev = dev;
- dev_set_drvdata(dev, sess);
+ /* Configure where sid will be prepended to pa */
+ sess->sid_pos =
+ (cctx->iova_format ? SID_POS_IN_IOVA : DSP_DEFAULT_BUS_WIDTH);
if (of_property_read_u32(dev->of_node, "reg", &sess->sid))
dev_info(dev, "FastRPC Session ID not specified in DT\n");
+ dev_set_drvdata(dev, sess);
if (sessions > 0) {
struct fastrpc_session_ctx *dup_sess;
@@ -2256,6 +2285,19 @@ static int fastrpc_get_domain_id(const char *domain)
return -EINVAL;
}
+struct fastrpc_soc_data {
+ u32 dsp_iova_format;
+};
+
+static const struct fastrpc_soc_data kaanapali_soc_data = {
+ .dsp_iova_format = 1,
+};
+
+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;
@@ -2264,6 +2306,23 @@ 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;
+ u32 iova_format = 0;
+
+ 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) {
+ dev_dbg(rdev, "no compatible SoC found at root node\n");
+ } else {
+ soc_data = match->data;
+ iova_format = soc_data->dsp_iova_format;
+ }
err = of_property_read_string(rdev->of_node, "label", &domain);
if (err) {
@@ -2343,7 +2402,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
err = -EINVAL;
goto err_free_data;
}
-
+ /* determine where sid needs to be prepended to pa based on iova_format */
+ data->iova_format = iova_format;
kref_init(&data->refcount);
dev_set_drvdata(&rpdev->dev, data);
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/2] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC
2025-09-24 23:46 [PATCH 0/2] Add ADSP and CDSP support on Kaanapali SoC Jingyi Wang
2025-09-24 23:46 ` [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting Jingyi Wang
@ 2025-09-24 23:46 ` Jingyi Wang
2025-09-25 2:57 ` Dmitry Baryshkov
2025-10-04 18:36 ` Srinivas Kandagatla
1 sibling, 2 replies; 11+ messages in thread
From: Jingyi Wang @ 2025-09-24 23:46 UTC (permalink / raw)
To: Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman
Cc: aiqun.yu, tingwei.zhang, trilok.soni, yijie.yang, linux-arm-msm,
dri-devel, linux-kernel, Jingyi Wang, Kumari Pallavi
From: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
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>
Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
---
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 db396241b8ce..e019163eb265 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -275,6 +275,7 @@ struct fastrpc_session_ctx {
bool used;
bool valid;
u32 sid_pos;
+ u32 pa_bits;
};
struct fastrpc_channel_ctx {
@@ -2179,9 +2180,9 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
sess->used = false;
sess->valid = true;
sess->dev = dev;
+ sess->pa_bits = cctx->dma_mask;
/* Configure where sid will be prepended to pa */
- sess->sid_pos =
- (cctx->iova_format ? SID_POS_IN_IOVA : DSP_DEFAULT_BUS_WIDTH);
+ sess->sid_pos = (cctx->iova_format ? SID_POS_IN_IOVA : sess->pa_bits);
if (of_property_read_u32(dev->of_node, "reg", &sess->sid))
dev_info(dev, "FastRPC Session ID not specified in DT\n");
@@ -2198,9 +2199,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(sess->pa_bits));
if (rc) {
- dev_err(dev, "32-bit DMA enable failed\n");
+ dev_err(dev, "%u-bit DMA enable failed\n", sess->pa_bits);
return rc;
}
@@ -2287,10 +2288,12 @@ static int fastrpc_get_domain_id(const char *domain)
struct fastrpc_soc_data {
u32 dsp_iova_format;
+ u32 cdsp_dma_mask;
};
static const struct fastrpc_soc_data kaanapali_soc_data = {
.dsp_iova_format = 1,
+ .cdsp_dma_mask = 34,
};
static const struct of_device_id qcom_soc_match_table[] = {
@@ -2310,6 +2313,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
const struct of_device_id *match;
const struct fastrpc_soc_data *soc_data = NULL;
u32 iova_format = 0;
+ u32 ubs = DSP_DEFAULT_BUS_WIDTH;
root = of_find_node_by_path("/");
if (!root)
@@ -2322,6 +2326,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
} else {
soc_data = match->data;
iova_format = soc_data->dsp_iova_format;
+ ubs = soc_data->cdsp_dma_mask;
}
err = of_property_read_string(rdev->of_node, "label", &domain);
@@ -2404,6 +2409,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
}
/* determine where sid needs to be prepended to pa based on iova_format */
data->iova_format = iova_format;
+ data->dma_mask = (domain_id == CDSP_DOMAIN_ID ? ubs : DSP_DEFAULT_BUS_WIDTH);
kref_init(&data->refcount);
dev_set_drvdata(&rpdev->dev, data);
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting
2025-09-24 23:46 ` [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting Jingyi Wang
@ 2025-09-25 2:25 ` Dmitry Baryshkov
2025-09-30 4:43 ` Kumari Pallavi
2025-09-25 6:24 ` Arnd Bergmann
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Dmitry Baryshkov @ 2025-09-25 2:25 UTC (permalink / raw)
To: Jingyi Wang
Cc: Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman, aiqun.yu, tingwei.zhang, trilok.soni,
yijie.yang, linux-arm-msm, dri-devel, linux-kernel,
Kumari Pallavi
On Wed, Sep 24, 2025 at 04:46:36PM -0700, Jingyi Wang wrote:
> From: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
>
> 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, add an iova-format flag which determines the SID position
> within the physical address. Set SID position to bit 56 when iova_format
> is enabled; otherwise, default to legacy 32-bit placement.
> Initialize the flag to 0 and update to 1 based on SoC-specific compatible
> string from the root node.
> This change ensures consistent SID placement across DSPs.
>
> Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
> Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
> ---
> drivers/misc/fastrpc.c | 76 ++++++++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 68 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 8e1d97873423..db396241b8ce 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,26 @@
>
> #define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev)
>
> +/*
> + * By default, the sid will be prepended adjacent to smmu pa before sending
> + * to DSP. But if the compatible Soc found at root node specifies the new
> + * addressing format to handle pa's of longer widths, then the sid will be
> + * prepended at the position specified in this macro.
> + */
> +#define SID_POS_IN_IOVA 56
> +
> +/* Default width of pa bus from dsp */
> +#define DSP_DEFAULT_BUS_WIDTH 32
> +
> +/* Extract smmu pa from consolidated iova */
> +#define IOVA_TO_PHYS(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 */
> @@ -255,6 +274,7 @@ struct fastrpc_session_ctx {
> int sid;
> bool used;
> bool valid;
> + u32 sid_pos;
> };
>
> struct fastrpc_channel_ctx {
> @@ -278,6 +298,7 @@ struct fastrpc_channel_ctx {
> bool secure;
> bool unsigned_support;
> u64 dma_mask;
> + u32 iova_format;
> };
>
> struct fastrpc_device {
> @@ -391,8 +412,11 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
>
> static void fastrpc_buf_free(struct fastrpc_buf *buf)
> {
> + uint32_t sid_pos = (buf->fl->sctx ? buf->fl->sctx->sid_pos :
> + DSP_DEFAULT_BUS_WIDTH);
> +
> dma_free_coherent(buf->dev, buf->size, buf->virt,
> - FASTRPC_PHYS(buf->phys));
> + IOVA_TO_PHYS(buf->phys, sid_pos));
> kfree(buf);
> }
>
> @@ -442,7 +466,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);
> + IOVA_FROM_SID_PA((u64)fl->sctx->sid, buf->phys, fl->sctx->sid_pos);
>
> return 0;
> }
> @@ -687,7 +711,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->phys), buffer->size);
> + IOVA_TO_PHYS(buffer->phys, buffer->fl->sctx->sid_pos),
> + buffer->size);
> if (ret < 0) {
> dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
> kfree(a);
> @@ -736,7 +761,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);
> + IOVA_TO_PHYS(buf->phys, buf->fl->sctx->sid_pos), size);
> }
>
> static const struct dma_buf_ops fastrpc_dma_buf_ops = {
> @@ -793,7 +818,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
> map->phys = sg_phys(map->table->sgl);
> } else {
> map->phys = sg_dma_address(map->table->sgl);
> - map->phys += ((u64)fl->sctx->sid << 32);
> + IOVA_FROM_SID_PA((u64)fl->sctx->sid, map->phys,
> + fl->sctx->sid_pos);
> }
> map->size = len;
> map->va = sg_virt(map->table->sgl);
> @@ -2153,11 +2179,14 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
> sess->used = false;
> sess->valid = true;
> sess->dev = dev;
> - dev_set_drvdata(dev, sess);
> + /* Configure where sid will be prepended to pa */
> + sess->sid_pos =
> + (cctx->iova_format ? SID_POS_IN_IOVA : DSP_DEFAULT_BUS_WIDTH);
You are using iova_format as a flag. Rename it to something more
sensible and turn it into a boolean flag.
>
> if (of_property_read_u32(dev->of_node, "reg", &sess->sid))
> dev_info(dev, "FastRPC Session ID not specified in DT\n");
>
> + dev_set_drvdata(dev, sess);
> if (sessions > 0) {
> struct fastrpc_session_ctx *dup_sess;
>
> @@ -2256,6 +2285,19 @@ static int fastrpc_get_domain_id(const char *domain)
> return -EINVAL;
> }
>
> +struct fastrpc_soc_data {
> + u32 dsp_iova_format;
> +};
> +
> +static const struct fastrpc_soc_data kaanapali_soc_data = {
> + .dsp_iova_format = 1,
> +};
> +
> +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;
> @@ -2264,6 +2306,23 @@ 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;
> + u32 iova_format = 0;
> +
> + 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) {
> + dev_dbg(rdev, "no compatible SoC found at root node\n");
> + } else {
> + soc_data = match->data;
> + iova_format = soc_data->dsp_iova_format;
> + }
>
> err = of_property_read_string(rdev->of_node, "label", &domain);
> if (err) {
> @@ -2343,7 +2402,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> err = -EINVAL;
> goto err_free_data;
> }
> -
> + /* determine where sid needs to be prepended to pa based on iova_format */
> + data->iova_format = iova_format;
> kref_init(&data->refcount);
>
> dev_set_drvdata(&rpdev->dev, data);
>
> --
> 2.25.1
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC
2025-09-24 23:46 ` [PATCH 2/2] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC Jingyi Wang
@ 2025-09-25 2:57 ` Dmitry Baryshkov
2025-10-04 18:36 ` Srinivas Kandagatla
1 sibling, 0 replies; 11+ messages in thread
From: Dmitry Baryshkov @ 2025-09-25 2:57 UTC (permalink / raw)
To: Jingyi Wang
Cc: Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman, aiqun.yu, tingwei.zhang, trilok.soni,
yijie.yang, linux-arm-msm, dri-devel, linux-kernel,
Kumari Pallavi
On Wed, Sep 24, 2025 at 04:46:37PM -0700, Jingyi Wang wrote:
> From: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
>
> 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>
> Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
> ---
> drivers/misc/fastrpc.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting
2025-09-24 23:46 ` [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting Jingyi Wang
2025-09-25 2:25 ` Dmitry Baryshkov
@ 2025-09-25 6:24 ` Arnd Bergmann
2025-09-30 4:40 ` Kumari Pallavi
2025-09-26 0:08 ` kernel test robot
2025-10-04 18:25 ` Srinivas Kandagatla
3 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2025-09-25 6:24 UTC (permalink / raw)
To: Jingyi Wang, Srinivas Kandagatla, Amol Maheshwari,
Greg Kroah-Hartman
Cc: aiqun.yu, tingwei.zhang, trilok.soni, yijie.yang, linux-arm-msm,
dri-devel, linux-kernel, Kumari Pallavi
On Thu, Sep 25, 2025, at 01:46, Jingyi Wang wrote:
> dma_free_coherent(buf->dev, buf->size, buf->virt,
> - FASTRPC_PHYS(buf->phys));
> + IOVA_TO_PHYS(buf->phys, sid_pos));
> kfree(buf);
> }
I understand what you are doing, but the naming of the macros
seems a bit confusing: dma_free_coherent() and the related
functions are designed to take an IOVA argument, not a physical
address, so calling IOVA_TO_PHYS() before passing the
address sounds wrong. This is made worse by the naming
of 'buf->phys' that is not a physical address at all
but already transformed twice into a dma_addr_t and
from there into a dma_addr+sid tuple.
Ideally the SID handling would be abstracted behind a custom
dma_map_ops implementation that treats this as a custom
iommu, but if the fastrpc device is the only user of this
address format, I can understand you want to keep this as
a local hack in this driver.
Can you try to come up with some better naming here, and
replace the 'phys' bits with something that is more fitting
for an iova/dma_addr_t?
Arnd
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting
2025-09-24 23:46 ` [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting Jingyi Wang
2025-09-25 2:25 ` Dmitry Baryshkov
2025-09-25 6:24 ` Arnd Bergmann
@ 2025-09-26 0:08 ` kernel test robot
2025-10-04 18:25 ` Srinivas Kandagatla
3 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2025-09-26 0:08 UTC (permalink / raw)
To: Jingyi Wang, Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman
Cc: oe-kbuild-all, aiqun.yu, tingwei.zhang, trilok.soni, yijie.yang,
linux-arm-msm, dri-devel, linux-kernel, Jingyi Wang,
Kumari Pallavi
Hi Jingyi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on ae2d20002576d2893ecaff25db3d7ef9190ac0b6]
url: https://github.com/intel-lab-lkp/linux/commits/Jingyi-Wang/misc-fastrpc-Add-support-for-new-DSP-IOVA-formatting/20250925-074855
base: ae2d20002576d2893ecaff25db3d7ef9190ac0b6
patch link: https://lore.kernel.org/r/20250924-knp-fastrpc-v1-1-4b40f8bfce1d%40oss.qualcomm.com
patch subject: [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting
config: x86_64-buildonly-randconfig-005-20250926 (https://download.01.org/0day-ci/archive/20250926/202509260727.MrXkGDmN-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250926/202509260727.MrXkGDmN-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509260727.MrXkGDmN-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/misc/fastrpc.c:2296:34: warning: 'qcom_soc_match_table' defined but not used [-Wunused-const-variable=]
2296 | static const struct of_device_id qcom_soc_match_table[] = {
| ^~~~~~~~~~~~~~~~~~~~
vim +/qcom_soc_match_table +2296 drivers/misc/fastrpc.c
2295
> 2296 static const struct of_device_id qcom_soc_match_table[] = {
2297 { .compatible = "qcom,kaanapali", .data = &kaanapali_soc_data },
2298 {},
2299 };
2300
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting
2025-09-25 6:24 ` Arnd Bergmann
@ 2025-09-30 4:40 ` Kumari Pallavi
0 siblings, 0 replies; 11+ messages in thread
From: Kumari Pallavi @ 2025-09-30 4:40 UTC (permalink / raw)
To: Arnd Bergmann, Jingyi Wang, Srinivas Kandagatla, Amol Maheshwari,
Greg Kroah-Hartman
Cc: aiqun.yu, tingwei.zhang, trilok.soni, yijie.yang, linux-arm-msm,
dri-devel, linux-kernel
On 9/25/2025 11:54 AM, Arnd Bergmann wrote:
> On Thu, Sep 25, 2025, at 01:46, Jingyi Wang wrote:
>
>> dma_free_coherent(buf->dev, buf->size, buf->virt,
>> - FASTRPC_PHYS(buf->phys));
>> + IOVA_TO_PHYS(buf->phys, sid_pos));
>> kfree(buf);
>> }
>
> I understand what you are doing, but the naming of the macros
> seems a bit confusing: dma_free_coherent() and the related
> functions are designed to take an IOVA argument, not a physical
> address, so calling IOVA_TO_PHYS() before passing the
> address sounds wrong. This is made worse by the naming
> of 'buf->phys' that is not a physical address at all
> but already transformed twice into a dma_addr_t and
> from there into a dma_addr+sid tuple.
>
> Ideally the SID handling would be abstracted behind a custom
> dma_map_ops implementation that treats this as a custom
> iommu, but if the fastrpc device is the only user of this
> address format, I can understand you want to keep this as
> a local hack in this driver.
>
> Can you try to come up with some better naming here, and
> replace the 'phys' bits with something that is more fitting
> for an iova/dma_addr_t?
>
I will improve the naming for better clarity:
- Replace buf->phys with buf->dma_addr throughout the code.
- Rename the macro IOVA_TO_PHYS() to something more appropriate, like
IPA_TO_DMA_ADDR()
> Arnd
Thanks,
Pallavi
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting
2025-09-25 2:25 ` Dmitry Baryshkov
@ 2025-09-30 4:43 ` Kumari Pallavi
0 siblings, 0 replies; 11+ messages in thread
From: Kumari Pallavi @ 2025-09-30 4:43 UTC (permalink / raw)
To: Dmitry Baryshkov, Jingyi Wang
Cc: Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman, aiqun.yu, tingwei.zhang, trilok.soni,
yijie.yang, linux-arm-msm, dri-devel, linux-kernel
On 9/25/2025 7:55 AM, Dmitry Baryshkov wrote:
> On Wed, Sep 24, 2025 at 04:46:36PM -0700, Jingyi Wang wrote:
>> From: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
>>
>> 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, add an iova-format flag which determines the SID position
>> within the physical address. Set SID position to bit 56 when iova_format
>> is enabled; otherwise, default to legacy 32-bit placement.
>> Initialize the flag to 0 and update to 1 based on SoC-specific compatible
>> string from the root node.
>> This change ensures consistent SID placement across DSPs.
>>
>> Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
>> Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
>> ---
>> drivers/misc/fastrpc.c | 76 ++++++++++++++++++++++++++++++++++++++++++++------
>> 1 file changed, 68 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
>> index 8e1d97873423..db396241b8ce 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,26 @@
>>
>> #define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev)
>>
>> +/*
>> + * By default, the sid will be prepended adjacent to smmu pa before sending
>> + * to DSP. But if the compatible Soc found at root node specifies the new
>> + * addressing format to handle pa's of longer widths, then the sid will be
>> + * prepended at the position specified in this macro.
>> + */
>> +#define SID_POS_IN_IOVA 56
>> +
>> +/* Default width of pa bus from dsp */
>> +#define DSP_DEFAULT_BUS_WIDTH 32
>> +
>> +/* Extract smmu pa from consolidated iova */
>> +#define IOVA_TO_PHYS(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 */
>> @@ -255,6 +274,7 @@ struct fastrpc_session_ctx {
>> int sid;
>> bool used;
>> bool valid;
>> + u32 sid_pos;
>> };
>>
>> struct fastrpc_channel_ctx {
>> @@ -278,6 +298,7 @@ struct fastrpc_channel_ctx {
>> bool secure;
>> bool unsigned_support;
>> u64 dma_mask;
>> + u32 iova_format;
>> };
>>
>> struct fastrpc_device {
>> @@ -391,8 +412,11 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
>>
>> static void fastrpc_buf_free(struct fastrpc_buf *buf)
>> {
>> + uint32_t sid_pos = (buf->fl->sctx ? buf->fl->sctx->sid_pos :
>> + DSP_DEFAULT_BUS_WIDTH);
>> +
>> dma_free_coherent(buf->dev, buf->size, buf->virt,
>> - FASTRPC_PHYS(buf->phys));
>> + IOVA_TO_PHYS(buf->phys, sid_pos));
>> kfree(buf);
>> }
>>
>> @@ -442,7 +466,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);
>> + IOVA_FROM_SID_PA((u64)fl->sctx->sid, buf->phys, fl->sctx->sid_pos);
>>
>> return 0;
>> }
>> @@ -687,7 +711,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->phys), buffer->size);
>> + IOVA_TO_PHYS(buffer->phys, buffer->fl->sctx->sid_pos),
>> + buffer->size);
>> if (ret < 0) {
>> dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
>> kfree(a);
>> @@ -736,7 +761,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);
>> + IOVA_TO_PHYS(buf->phys, buf->fl->sctx->sid_pos), size);
>> }
>>
>> static const struct dma_buf_ops fastrpc_dma_buf_ops = {
>> @@ -793,7 +818,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
>> map->phys = sg_phys(map->table->sgl);
>> } else {
>> map->phys = sg_dma_address(map->table->sgl);
>> - map->phys += ((u64)fl->sctx->sid << 32);
>> + IOVA_FROM_SID_PA((u64)fl->sctx->sid, map->phys,
>> + fl->sctx->sid_pos);
>> }
>> map->size = len;
>> map->va = sg_virt(map->table->sgl);
>> @@ -2153,11 +2179,14 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
>> sess->used = false;
>> sess->valid = true;
>> sess->dev = dev;
>> - dev_set_drvdata(dev, sess);
>> + /* Configure where sid will be prepended to pa */
>> + sess->sid_pos =
>> + (cctx->iova_format ? SID_POS_IN_IOVA : DSP_DEFAULT_BUS_WIDTH);
>
> You are using iova_format as a flag. Rename it to something more
> sensible and turn it into a boolean flag.
>
Sure, I'll take it up in next patch series.
>>
>> if (of_property_read_u32(dev->of_node, "reg", &sess->sid))
>> dev_info(dev, "FastRPC Session ID not specified in DT\n");
>>
>> + dev_set_drvdata(dev, sess);
>> if (sessions > 0) {
>> struct fastrpc_session_ctx *dup_sess;
>>
>> @@ -2256,6 +2285,19 @@ static int fastrpc_get_domain_id(const char *domain)
>> return -EINVAL;
>> }
>>
>> +struct fastrpc_soc_data {
>> + u32 dsp_iova_format;
>> +};
>> +
>> +static const struct fastrpc_soc_data kaanapali_soc_data = {
>> + .dsp_iova_format = 1,
>> +};
>> +
>> +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;
>> @@ -2264,6 +2306,23 @@ 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;
>> + u32 iova_format = 0;
>> +
>> + 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) {
>> + dev_dbg(rdev, "no compatible SoC found at root node\n");
>> + } else {
>> + soc_data = match->data;
>> + iova_format = soc_data->dsp_iova_format;
>> + }
>>
>> err = of_property_read_string(rdev->of_node, "label", &domain);
>> if (err) {
>> @@ -2343,7 +2402,8 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>> err = -EINVAL;
>> goto err_free_data;
>> }
>> -
>> + /* determine where sid needs to be prepended to pa based on iova_format */
>> + data->iova_format = iova_format;
>> kref_init(&data->refcount);
>>
>> dev_set_drvdata(&rpdev->dev, data);
>>
>> --
>> 2.25.1
>>
>
Thanks,
Pallavi
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting
2025-09-24 23:46 ` [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting Jingyi Wang
` (2 preceding siblings ...)
2025-09-26 0:08 ` kernel test robot
@ 2025-10-04 18:25 ` Srinivas Kandagatla
3 siblings, 0 replies; 11+ messages in thread
From: Srinivas Kandagatla @ 2025-10-04 18:25 UTC (permalink / raw)
To: Jingyi Wang, Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman
Cc: aiqun.yu, tingwei.zhang, trilok.soni, yijie.yang, linux-arm-msm,
dri-devel, linux-kernel, Kumari Pallavi
On 9/25/25 12:46 AM, Jingyi Wang wrote:
> From: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
>
> 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, add an iova-format flag which determines the SID position
> within the physical address. Set SID position to bit 56 when iova_format
> is enabled; otherwise, default to legacy 32-bit placement.
> Initialize the flag to 0 and update to 1 based on SoC-specific compatible
> string from the root node.
> This change ensures consistent SID placement across DSPs.
>
> Signed-off-by: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
> Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
> ---
> drivers/misc/fastrpc.c | 76 ++++++++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 68 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 8e1d97873423..db396241b8ce 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,26 @@
>
> #define miscdev_to_fdevice(d) container_of(d, struct fastrpc_device, miscdev)
>
> +/*
> + * By default, the sid will be prepended adjacent to smmu pa before sending
> + * to DSP. But if the compatible Soc found at root node specifies the new
> + * addressing format to handle pa's of longer widths, then the sid will be
> + * prepended at the position specified in this macro.
> + */
> +#define SID_POS_IN_IOVA 56
> +
> +/* Default width of pa bus from dsp */
> +#define DSP_DEFAULT_BUS_WIDTH 32
I dont see any point in defining these both here, this should be part of
the fastrpc_soc_data and a fallback fastrpc_soc_data.
> +
> +/* Extract smmu pa from consolidated iova */
> +#define IOVA_TO_PHYS(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 */
> @@ -255,6 +274,7 @@ struct fastrpc_session_ctx {
> int sid;
> bool used;
> bool valid;
> + u32 sid_pos;
Why is this in session context? are you expecting this to be different
for each session? move it to channel_ctx.
> };
>
> struct fastrpc_channel_ctx {
> @@ -278,6 +298,7 @@ struct fastrpc_channel_ctx {
> bool secure;
> bool unsigned_support;
> u64 dma_mask;
> + u32 iova_format;
Format is very much misleading, And this is totally redundant if you add
sid_pos to soc_data.
Please add soc_data struct here, so that we dont have to keep adding
members to this and it also makes it clear what are soc specific bits in
this.
> };
>
> struct fastrpc_device {
> @@ -391,8 +412,11 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
>
> static void fastrpc_buf_free(struct fastrpc_buf *buf)
> {
> + uint32_t sid_pos = (buf->fl->sctx ? buf->fl->sctx->sid_pos :
> + DSP_DEFAULT_BUS_WIDTH);
Why this new check added?
> +
> dma_free_coherent(buf->dev, buf->size, buf->virt,
> - FASTRPC_PHYS(buf->phys));
> + IOVA_TO_PHYS(buf->phys, sid_pos));
> kfree(buf);
> }
>
> @@ -442,7 +466,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);
> + IOVA_FROM_SID_PA((u64)fl->sctx->sid, buf->phys, fl->sctx->sid_pos);
>
> return 0;
> }
> @@ -687,7 +711,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->phys), buffer->size);
> + IOVA_TO_PHYS(buffer->phys, buffer->fl->sctx->sid_pos),
> + buffer->size);
> if (ret < 0) {
> dev_err(buffer->dev, "failed to get scatterlist from DMA API\n");
> kfree(a);
> @@ -736,7 +761,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);
> + IOVA_TO_PHYS(buf->phys, buf->fl->sctx->sid_pos), size);
> }
>
> static const struct dma_buf_ops fastrpc_dma_buf_ops = {
> @@ -793,7 +818,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
> map->phys = sg_phys(map->table->sgl);
> } else {
> map->phys = sg_dma_address(map->table->sgl);
> - map->phys += ((u64)fl->sctx->sid << 32);
> + IOVA_FROM_SID_PA((u64)fl->sctx->sid, map->phys,
> + fl->sctx->sid_pos);
> }
> map->size = len;
> map->va = sg_virt(map->table->sgl);
> @@ -2153,11 +2179,14 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
> sess->used = false;
> sess->valid = true;
> sess->dev = dev;
> - dev_set_drvdata(dev, sess);
> + /* Configure where sid will be prepended to pa */
unnessary comment here.
> + sess->sid_pos =
> + (cctx->iova_format ? SID_POS_IN_IOVA : DSP_DEFAULT_BUS_WIDTH);
as commented eariler, replace iova_format from soc_data with pos.
>
> if (of_property_read_u32(dev->of_node, "reg", &sess->sid))
> dev_info(dev, "FastRPC Session ID not specified in DT\n");
>
> + dev_set_drvdata(dev, sess);
why this line moved in this patch?
> if (sessions > 0) {
> struct fastrpc_session_ctx *dup_sess;
>
> @@ -2256,6 +2285,19 @@ static int fastrpc_get_domain_id(const char *domain)
> return -EINVAL;
> }
>
> +struct fastrpc_soc_data {
> + u32 dsp_iova_format;
s/dsp_iova_format/sid_pos
> +};
> +
> +static const struct fastrpc_soc_data kaanapali_soc_data = {
> + .dsp_iova_format = 1,
.sid_pos = 54,
> +};
> +
> +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;
> @@ -2264,6 +2306,23 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> const char *domain;
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/2] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC
2025-09-24 23:46 ` [PATCH 2/2] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC Jingyi Wang
2025-09-25 2:57 ` Dmitry Baryshkov
@ 2025-10-04 18:36 ` Srinivas Kandagatla
1 sibling, 0 replies; 11+ messages in thread
From: Srinivas Kandagatla @ 2025-10-04 18:36 UTC (permalink / raw)
To: Jingyi Wang, Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman
Cc: aiqun.yu, tingwei.zhang, trilok.soni, yijie.yang, linux-arm-msm,
dri-devel, linux-kernel, Kumari Pallavi
On 9/25/25 12:46 AM, Jingyi Wang wrote:
> From: Kumari Pallavi <kumari.pallavi@oss.qualcomm.com>
>
> 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>
> Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
> ---
> 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 db396241b8ce..e019163eb265 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -275,6 +275,7 @@ struct fastrpc_session_ctx {
> bool used;
> bool valid;
> u32 sid_pos;
> + u32 pa_bits;
same comments as in patch 1 move to channel ctx, also why do we even
need this to be stored in the first place as dma mask is set in
probe,we will not need it after wards.
> };
>
> struct fastrpc_channel_ctx {
> @@ -2179,9 +2180,9 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
> sess->used = false;
> sess->valid = true;
> sess->dev = dev;
> + sess->pa_bits = cctx->dma_mask;
> /* Configure where sid will be prepended to pa */
> - sess->sid_pos =
> - (cctx->iova_format ? SID_POS_IN_IOVA : DSP_DEFAULT_BUS_WIDTH);
> + sess->sid_pos = (cctx->iova_format ? SID_POS_IN_IOVA : sess->pa_bits);
>
> if (of_property_read_u32(dev->of_node, "reg", &sess->sid))
> dev_info(dev, "FastRPC Session ID not specified in DT\n");
> @@ -2198,9 +2199,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(sess->pa_bits));
> if (rc) {
> - dev_err(dev, "32-bit DMA enable failed\n");
> + dev_err(dev, "%u-bit DMA enable failed\n", sess->pa_bits);
> return rc;
> }
>
> @@ -2287,10 +2288,12 @@ static int fastrpc_get_domain_id(const char *domain)
>
> struct fastrpc_soc_data {
> u32 dsp_iova_format;
> + u32 cdsp_dma_mask;
> };
>
> static const struct fastrpc_soc_data kaanapali_soc_data = {
> .dsp_iova_format = 1,
> + .cdsp_dma_mask = 34,
> };
>
> static const struct of_device_id qcom_soc_match_table[] = {
> @@ -2310,6 +2313,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> const struct of_device_id *match;
> const struct fastrpc_soc_data *soc_data = NULL;
> u32 iova_format = 0;
> + u32 ubs = DSP_DEFAULT_BUS_WIDTH;
>
> root = of_find_node_by_path("/");
> if (!root)
> @@ -2322,6 +2326,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> } else {
> soc_data = match->data;
> iova_format = soc_data->dsp_iova_format;
> + ubs = soc_data->cdsp_dma_mask;
> }
>
> err = of_property_read_string(rdev->of_node, "label", &domain);
> @@ -2404,6 +2409,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> }
> /* determine where sid needs to be prepended to pa based on iova_format */
> data->iova_format = iova_format;
> + data->dma_mask = (domain_id == CDSP_DOMAIN_ID ? ubs : DSP_DEFAULT_BUS_WIDTH);
set the default of 32 and move this inside switch case where we have
domain id checks.
> kref_init(&data->refcount);
>
> dev_set_drvdata(&rpdev->dev, data);
>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-10-04 18:36 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24 23:46 [PATCH 0/2] Add ADSP and CDSP support on Kaanapali SoC Jingyi Wang
2025-09-24 23:46 ` [PATCH 1/2] misc: fastrpc: Add support for new DSP IOVA formatting Jingyi Wang
2025-09-25 2:25 ` Dmitry Baryshkov
2025-09-30 4:43 ` Kumari Pallavi
2025-09-25 6:24 ` Arnd Bergmann
2025-09-30 4:40 ` Kumari Pallavi
2025-09-26 0:08 ` kernel test robot
2025-10-04 18:25 ` Srinivas Kandagatla
2025-09-24 23:46 ` [PATCH 2/2] misc: fastrpc: Update dma_mask for CDSP support on Kaanapali SoC Jingyi Wang
2025-09-25 2:57 ` Dmitry Baryshkov
2025-10-04 18:36 ` Srinivas Kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox