* [PATCH 0/4] misc: fastrpc: add HPASS domain support
@ 2026-11-25 0:06 Anandu Krishnan E
2026-11-25 0:06 ` [PATCH 1/4] dt-bindings: misc: qcom,fastrpc: add hpass label Anandu Krishnan E
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Anandu Krishnan E @ 2026-11-25 0:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linux-arm-msm, dri-devel, devicetree, quic_bkumar, quic_chennak,
dmitry.baryshkov, Anandu Krishnan E
HPASS (High Performance Audio Subsystem) is a distinct audio
hardware block from the LPASS-class ADSP used on earlier targets,
with its own shared resources, audio interface block, and additional
integrated processing hardware such as HVX (Hexagon Vector
eXtensions). It is described in the devicetree with its own "hpass"
label, following the existing fastrpc convention of distinguishing
DSP domains by label (adsp/cdsp/sdsp/gdsp0/gdsp1/...).
Depending on the firmware image it loads, an HPASS domain can run
either an audio image or a compute image. An audio image only needs
the existing secure fastrpc node, while a compute image additionally
offloads user compute workloads and needs a non-secure node for
unsigned PD support.
Which image is loaded is only knowable by querying the DSP's
capability attributes. This series moves that query from userspace's
first FASTRPC_IOCTL_GET_DSP_INFO call to probe time, so the device
nodes registered at probe already reflect the DSP's actual
capabilities instead of being created from the domain id alone. The
query runs on a per-channel workqueue so a slow or silent DSP domain
does not block probe() or delay other channels probing concurrently.
Patch 1 adds the "hpass" devicetree label. Patch 2 adds the
corresponding HPASS_DOMAIN_ID to the driver. Patch 3 moves the
capability query to probe time. Patch 4 uses the queried capability to
register the unsigned PD node for a compute-capable HPASS domain.
Signed-off-by: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
---
Anandu Krishnan E (4):
dt-bindings: misc: qcom,fastrpc: add hpass label
misc: fastrpc: add HPASS domain
misc: fastrpc: query the dsp capabilities during probe time
misc: fastrpc: expose unsigned PD node for compute-capable HPASS
.../devicetree/bindings/misc/qcom,fastrpc.yaml | 1 +
drivers/misc/fastrpc.c | 259 ++++++++++++++++-----
2 files changed, 207 insertions(+), 53 deletions(-)
---
base-commit: 3191063649dbf7c0d0b768e1f3655e4c5fc6edb5
change-id: 20261125-fastrpc-hpass-support-bdb86e8b15d7
Best regards,
--
Anandu Krishnan E <anandu.e@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] dt-bindings: misc: qcom,fastrpc: add hpass label
2026-11-25 0:06 [PATCH 0/4] misc: fastrpc: add HPASS domain support Anandu Krishnan E
@ 2026-11-25 0:06 ` Anandu Krishnan E
2026-11-25 0:06 ` [PATCH 2/4] misc: fastrpc: add HPASS domain Anandu Krishnan E
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Anandu Krishnan E @ 2026-11-25 0:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linux-arm-msm, dri-devel, devicetree, quic_bkumar, quic_chennak,
dmitry.baryshkov, Anandu Krishnan E
Add "hpass" as a valid value for the fastrpc node "label" property so
that a fastrpc instance can be attached to the HPASS (High-Performance
Audio SubSystem) remote processor domain.
Signed-off-by: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
---
Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
index 6b6ad95d5cf4..a7f7504897a5 100644
--- a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
+++ b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml
@@ -41,6 +41,7 @@ properties:
- cdsp3
- gdsp0
- gdsp1
+ - hpass
memory-region:
maxItems: 1
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] misc: fastrpc: add HPASS domain
2026-11-25 0:06 [PATCH 0/4] misc: fastrpc: add HPASS domain support Anandu Krishnan E
2026-11-25 0:06 ` [PATCH 1/4] dt-bindings: misc: qcom,fastrpc: add hpass label Anandu Krishnan E
@ 2026-11-25 0:06 ` Anandu Krishnan E
2026-11-25 0:24 ` sashiko-bot
2026-11-25 0:06 ` [PATCH 3/4] misc: fastrpc: query the dsp capabilities during probe time Anandu Krishnan E
2026-11-25 0:06 ` [PATCH 4/4] misc: fastrpc: expose unsigned PD node for compute-capable HPASS Anandu Krishnan E
3 siblings, 1 reply; 7+ messages in thread
From: Anandu Krishnan E @ 2026-11-25 0:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linux-arm-msm, dri-devel, devicetree, quic_bkumar, quic_chennak,
dmitry.baryshkov, Anandu Krishnan E
HPASS (High Performance Audio Subsystem) is a distinct audio
hardware block from the LPASS-class ADSP used on earlier targets,
with its own shared resources, audio interface block, and additional
integrated processing hardware such as HVX (Hexagon Vector
eXtensions), described in the devicetree with its own "hpass" label.
Add a HPASS_DOMAIN_ID and map the "hpass" DT label to it.
Signed-off-by: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 9e760f68bcaf..c515097c3d3b 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -35,6 +35,7 @@
#define SDSP_DOMAIN_ID (2)
#define CDSP_DOMAIN_ID (3)
#define GDSP_DOMAIN_ID (4)
+#define HPASS_DOMAIN_ID (5)
#define FASTRPC_MAX_SESSIONS 14
/*
* Extra ADSP sessions duplicated from the last CB, as each CB supports
@@ -2497,6 +2498,8 @@ static int fastrpc_get_domain_id(const char *domain)
return SDSP_DOMAIN_ID;
else if (!strncmp(domain, "gdsp", 4))
return GDSP_DOMAIN_ID;
+ else if (!strncmp(domain, "hpass", 5))
+ return HPASS_DOMAIN_ID;
return -EINVAL;
}
@@ -2655,8 +2658,9 @@ static int fastrpc_init_reserved_mem(struct fastrpc_channel_ctx *cctx,
u64 src_perms;
int err;
- /* Only SDSP and ADSP domains use a reserved remote heap region */
- if (domain_id != SDSP_DOMAIN_ID && domain_id != ADSP_DOMAIN_ID)
+ /* Only SDSP, ADSP and HPASS domains use a reserved remote heap region */
+ if (domain_id != SDSP_DOMAIN_ID && domain_id != ADSP_DOMAIN_ID &&
+ domain_id != HPASS_DOMAIN_ID)
return 0;
err = of_reserved_mem_region_to_resource(rdev->of_node, 0, &res);
@@ -2670,11 +2674,11 @@ static int fastrpc_init_reserved_mem(struct fastrpc_channel_ctx *cctx,
}
/*
- * Audio PD (ADSP) is a static PD: cache the region so its lifetime
- * is tied to the rpmsg channel instead of being controlled by
- * userspace.
+ * Audio PD (ADSP/HPASS) is a static PD: cache the region so its
+ * lifetime is tied to the rpmsg channel instead of being controlled
+ * by userspace.
*/
- if (domain_id == ADSP_DOMAIN_ID) {
+ if (domain_id == ADSP_DOMAIN_ID || domain_id == HPASS_DOMAIN_ID) {
cctx->remote_heap_addr = res.start;
cctx->remote_heap_size = resource_size(&res);
@@ -2761,6 +2765,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
case ADSP_DOMAIN_ID:
case MDSP_DOMAIN_ID:
case SDSP_DOMAIN_ID:
+ case HPASS_DOMAIN_ID:
/* Unsigned PD offloading is only supported on CDSP and GDSP */
data->unsigned_support = false;
err = fastrpc_device_register(rdev, data, secure_dsp, domain);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] misc: fastrpc: query the dsp capabilities during probe time
2026-11-25 0:06 [PATCH 0/4] misc: fastrpc: add HPASS domain support Anandu Krishnan E
2026-11-25 0:06 ` [PATCH 1/4] dt-bindings: misc: qcom,fastrpc: add hpass label Anandu Krishnan E
2026-11-25 0:06 ` [PATCH 2/4] misc: fastrpc: add HPASS domain Anandu Krishnan E
@ 2026-11-25 0:06 ` Anandu Krishnan E
2026-11-25 0:28 ` sashiko-bot
2026-11-25 0:06 ` [PATCH 4/4] misc: fastrpc: expose unsigned PD node for compute-capable HPASS Anandu Krishnan E
3 siblings, 1 reply; 7+ messages in thread
From: Anandu Krishnan E @ 2026-11-25 0:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linux-arm-msm, dri-devel, devicetree, quic_bkumar, quic_chennak,
dmitry.baryshkov, Anandu Krishnan E
An HPASS domain can load either an audio firmware image or a compute
firmware image, and only a compute image exposes an unsigned PD node
in addition to the signed one. Which image is loaded is only knowable
by querying the DSP's capability attributes, and the driver needs
that answer before it can decide which /dev/fastrpc-* device nodes to
create. Today the query happens lazily on the first
FASTRPC_IOCTL_GET_DSP_INFO call from userspace, well after the device
nodes have already been created from the domain id alone.
Move the query to probe time, before the device nodes are registered,
so the set of nodes created reflects the DSP's actual capabilities.
A synchronous query in fastrpc_rpmsg_probe() would work but
fastrpc_internal_invoke() can block for up to 10 seconds waiting on
the DSP, and a target can have several DSP domains probing
concurrently, so a single slow or silent domain would delay bring-up
of the rest. Instead, run the query on a per-channel high-priority
ordered workqueue (WQ_HIGHPRI | WQ_MEM_RECLAIM) so that probe()
returns immediately, and register the device nodes from that work
item once the query completes or times out.
fastrpc_rpmsg_remove() cancels the pending work and destroys the
per-channel workqueue before tearing down the rest of the channel
state. The temporary client used to drive the query is linked into
cctx->users for the duration of the invoke so that a concurrent
channel removal aborts it via fastrpc_notify_users() instead of
blocking on the full invoke timeout.
Signed-off-by: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 225 ++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 177 insertions(+), 48 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index c515097c3d3b..59ef755feeaf 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -338,6 +338,10 @@ struct fastrpc_channel_ctx {
atomic_t ctx_seq;
u64 dma_mask;
const struct fastrpc_soc_data *soc_data;
+ /* Per-channel workqueue for the probe-time DSP capability query */
+ struct workqueue_struct *cap_wq;
+ struct work_struct cap_query_work;
+ char domain[8];
};
struct fastrpc_device {
@@ -2704,6 +2708,159 @@ static int fastrpc_init_reserved_mem(struct fastrpc_channel_ctx *cctx,
cctx->vmperms, cctx->vmcount);
}
+static int fastrpc_register_devices(struct fastrpc_channel_ctx *cctx,
+ struct rpmsg_device *rpdev)
+{
+ struct device *rdev = &rpdev->dev;
+ int err, i;
+
+ switch (cctx->domain_id) {
+ case ADSP_DOMAIN_ID:
+ case MDSP_DOMAIN_ID:
+ case SDSP_DOMAIN_ID:
+ case HPASS_DOMAIN_ID:
+ cctx->unsigned_support = false;
+ err = fastrpc_device_register(rdev, cctx, cctx->secure, cctx->domain);
+ if (err)
+ goto err_depopulate;
+ break;
+ case CDSP_DOMAIN_ID:
+ case GDSP_DOMAIN_ID:
+ cctx->unsigned_support = true;
+ err = fastrpc_device_register(rdev, cctx, true, cctx->domain);
+ if (err)
+ goto err_depopulate;
+ err = fastrpc_device_register(rdev, cctx, false, cctx->domain);
+ if (err) {
+ misc_deregister(&cctx->secure_fdevice->miscdev);
+ cctx->secure_fdevice = NULL;
+ goto err_depopulate;
+ }
+ break;
+ default:
+ err = -EINVAL;
+ goto err_depopulate;
+ }
+
+ /* Duplicate the last session so multiple processes can share
+ * the same compute bank.
+ */
+ if (cctx->domain_id == ADSP_DOMAIN_ID && cctx->sesscount > 0) {
+ struct fastrpc_session_ctx *last_sess;
+ struct fastrpc_session_ctx *dup_sess;
+ unsigned long flags;
+
+ spin_lock_irqsave(&cctx->lock, flags);
+ last_sess = &cctx->session[cctx->sesscount - 1];
+ for (i = 0; i < FASTRPC_DUP_SESSIONS; i++) {
+ if (cctx->sesscount >= FASTRPC_MAX_SESSIONS)
+ break;
+ dup_sess = &cctx->session[cctx->sesscount++];
+ memcpy(dup_sess, last_sess, sizeof(*dup_sess));
+ }
+ spin_unlock_irqrestore(&cctx->lock, flags);
+ }
+
+ return 0;
+
+err_depopulate:
+ fastrpc_cb_devices_destroy(rpdev);
+ return err;
+}
+
+static void fastrpc_cap_query_work(struct work_struct *work)
+{
+ struct fastrpc_channel_ctx *cctx =
+ container_of(work, struct fastrpc_channel_ctx, cap_query_work);
+ struct rpmsg_device *rpdev = cctx->rpdev;
+ struct device *rdev = &rpdev->dev;
+ u32 *dsp_attributes;
+ struct fastrpc_user *fl;
+ unsigned long flags;
+ int err;
+
+ fl = kzalloc_obj(*fl);
+ if (!fl)
+ goto register_devices;
+
+ spin_lock_init(&fl->lock);
+ mutex_init(&fl->mutex);
+ INIT_LIST_HEAD(&fl->pending);
+ INIT_LIST_HEAD(&fl->maps);
+ INIT_LIST_HEAD(&fl->mmaps);
+ INIT_LIST_HEAD(&fl->user);
+ fl->cctx = cctx;
+ fl->pd = ROOT_PD;
+ kref_init(&fl->refcount);
+ fastrpc_channel_ctx_get(cctx);
+
+ fl->sctx = fastrpc_session_alloc(fl);
+ if (!fl->sctx) {
+ dev_warn(rdev, "no session for capability query, skipping\n");
+ fastrpc_user_put(fl);
+ goto register_devices;
+ }
+
+ dsp_attributes = kzalloc_objs(*dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES);
+ if (!dsp_attributes)
+ goto err_cleanup_register;
+
+ /* Linked into cctx->users so fastrpc_rpmsg_remove() can abort us
+ * via fastrpc_notify_users() instead of waiting out the timeout.
+ */
+ spin_lock_irqsave(&cctx->lock, flags);
+ if (!cctx->rpdev) {
+ spin_unlock_irqrestore(&cctx->lock, flags);
+ goto err_cleanup_noreg;
+ }
+ list_add_tail(&fl->user, &cctx->users);
+ spin_unlock_irqrestore(&cctx->lock, flags);
+
+ err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES);
+
+ spin_lock_irqsave(&cctx->lock, flags);
+ list_del(&fl->user);
+ spin_unlock_irqrestore(&cctx->lock, flags);
+
+ if (err == -EPIPE) {
+ /* Channel is going away; remove() will tear it down. */
+ goto err_cleanup_noreg;
+ }
+
+ if (!err) {
+ spin_lock_irqsave(&cctx->lock, flags);
+ memcpy(cctx->dsp_attributes, dsp_attributes,
+ FASTRPC_MAX_DSP_ATTRIBUTES_LEN);
+ cctx->valid_attributes = true;
+ spin_unlock_irqrestore(&cctx->lock, flags);
+ dev_dbg(rdev, "DSP capabilities cached at probe time\n");
+ } else if (err == DSP_UNSUPPORTED_API) {
+ dev_info(rdev, "DSP does not support capability query\n");
+ } else {
+ dev_warn(rdev,
+ "probe-time capability query failed (%d), will retry on demand\n",
+ err);
+ }
+
+err_cleanup_register:
+ kfree(dsp_attributes);
+ fastrpc_session_free(cctx, fl->sctx);
+ fl->sctx = NULL;
+ fastrpc_user_put(fl);
+ goto register_devices;
+
+err_cleanup_noreg:
+ kfree(dsp_attributes);
+ fastrpc_session_free(cctx, fl->sctx);
+ fl->sctx = NULL;
+ fastrpc_user_put(fl);
+ return;
+
+register_devices:
+ if (fastrpc_register_devices(cctx, rpdev))
+ dev_err(rdev, "failed to register device nodes\n");
+}
+
static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
{
struct device *rdev = &rpdev->dev;
@@ -2761,34 +2918,6 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
data->poll_mode_supported = soc_data->poll_mode_supported ||
of_machine_get_match(fastrpc_poll_supported_machines);
- switch (domain_id) {
- case ADSP_DOMAIN_ID:
- case MDSP_DOMAIN_ID:
- case SDSP_DOMAIN_ID:
- case HPASS_DOMAIN_ID:
- /* Unsigned PD offloading is only supported on CDSP and GDSP */
- data->unsigned_support = false;
- err = fastrpc_device_register(rdev, data, secure_dsp, domain);
- if (err)
- goto err_unmap_heap;
- break;
- case CDSP_DOMAIN_ID:
- case GDSP_DOMAIN_ID:
- data->unsigned_support = true;
- /* Create both device nodes so that we can allow both Signed and Unsigned PD */
- err = fastrpc_device_register(rdev, data, true, domain);
- if (err)
- goto err_unmap_heap;
-
- err = fastrpc_device_register(rdev, data, false, domain);
- if (err)
- goto err_deregister_fdev;
- break;
- default:
- err = -EINVAL;
- goto err_unmap_heap;
- }
-
kref_init(&data->refcount);
atomic_set(&data->ctx_seq, 0);
@@ -2804,31 +2933,27 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
err = fastrpc_cb_devices_create(rpdev);
if (err)
- goto err_deregister_fdev;
-
- if (data->domain_id == ADSP_DOMAIN_ID && data->sesscount > 0) {
- struct fastrpc_session_ctx *last_sess;
- struct fastrpc_session_ctx *dup_sess;
- unsigned long flags;
+ goto err_unmap_heap;
- spin_lock_irqsave(&data->lock, flags);
- last_sess = &data->session[data->sesscount - 1];
- for (i = 0; i < FASTRPC_DUP_SESSIONS; i++) {
- if (data->sesscount >= FASTRPC_MAX_SESSIONS)
- break;
- dup_sess = &data->session[data->sesscount++];
- memcpy(dup_sess, last_sess, sizeof(*dup_sess));
- }
- spin_unlock_irqrestore(&data->lock, flags);
+ /* Probe returns immediately; the capability query and device node
+ * registration happen asynchronously on this channel's own queue.
+ */
+ data->cap_wq = alloc_ordered_workqueue("fastrpc_cap_wq_%s",
+ WQ_HIGHPRI | WQ_MEM_RECLAIM,
+ domain);
+ if (!data->cap_wq) {
+ err = -ENOMEM;
+ goto err_destroy_cb_devices;
}
+ strscpy(data->domain, domain, sizeof(data->domain));
+ INIT_WORK(&data->cap_query_work, fastrpc_cap_query_work);
+ queue_work(data->cap_wq, &data->cap_query_work);
+
return 0;
-err_deregister_fdev:
- if (data->fdevice)
- misc_deregister(&data->fdevice->miscdev);
- if (data->secure_fdevice)
- misc_deregister(&data->secure_fdevice->miscdev);
+err_destroy_cb_devices:
+ fastrpc_cb_devices_destroy(rpdev);
err_unmap_heap:
fastrpc_remote_heap_release(data, rpdev);
@@ -2864,6 +2989,10 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
fastrpc_notify_users(user);
spin_unlock_irqrestore(&cctx->lock, flags);
+ /* Wait for a pending capability query before tearing down cctx. */
+ cancel_work_sync(&cctx->cap_query_work);
+ destroy_workqueue(cctx->cap_wq);
+
if (cctx->fdevice)
misc_deregister(&cctx->fdevice->miscdev);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] misc: fastrpc: expose unsigned PD node for compute-capable HPASS
2026-11-25 0:06 [PATCH 0/4] misc: fastrpc: add HPASS domain support Anandu Krishnan E
` (2 preceding siblings ...)
2026-11-25 0:06 ` [PATCH 3/4] misc: fastrpc: query the dsp capabilities during probe time Anandu Krishnan E
@ 2026-11-25 0:06 ` Anandu Krishnan E
3 siblings, 0 replies; 7+ messages in thread
From: Anandu Krishnan E @ 2026-11-25 0:06 UTC (permalink / raw)
To: Srinivas Kandagatla, Ekansh Gupta, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann,
Greg Kroah-Hartman
Cc: linux-arm-msm, dri-devel, devicetree, quic_bkumar, quic_chennak,
dmitry.baryshkov, Anandu Krishnan E
HPASS (high-performance audio subsystem) is a distinct hardware block
from the LPASS-class ADSP, described in the devicetree with its own
"hpass" label. Depending on the firmware image it loads, an HPASS
domain can run either an audio image or a compute image. When it runs
a compute image it offloads user compute workloads and therefore
needs a non-secure node for unsigned PD offload, in addition to the
secure node; an audio image needs only the secure node.
The image type is reported by the DSP in its capability attributes,
which are now queried at probe time. Use that cached capability: when
an audio-PD domain reports a compute image, register both the secure
and non-secure nodes and enable unsigned PD support. When the
capability query did not complete, retain the existing domain-id based
gating.
Signed-off-by: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
---
drivers/misc/fastrpc.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 59ef755feeaf..eb107d0f2bc2 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -88,6 +88,14 @@
#define FASTRPC_MAX_DSP_ATTRIBUTES (256)
#define FASTRPC_MAX_DSP_ATTRIBUTES_LEN (sizeof(u32) * FASTRPC_MAX_DSP_ATTRIBUTES)
+/* remote_dsp_attributes[] index reporting the DSP's image configuration */
+#define DSP_IMAGE_CONFIG_ATTR_IDX (14)
+
+/* enum dsp_image_config: values reported at DSP_IMAGE_CONFIG_ATTR_IDX */
+#define FASTRPC_DSP_COMPUTE (1)
+#define FASTRPC_DSP_COMPUTE_LITE (2)
+#define FASTRPC_DSP_AUDIO (3)
+
/* Retrives number of input buffers from the scalars parameter */
#define REMOTE_SCALARS_INBUFS(sc) (((sc) >> 16) & 0x0ff)
@@ -2713,12 +2721,22 @@ static int fastrpc_register_devices(struct fastrpc_channel_ctx *cctx,
{
struct device *rdev = &rpdev->dev;
int err, i;
+ bool compute_lite = false;
+
+ /* An audio-PD domain (e.g. HPASS) running a compute image also
+ * needs an unsigned PD node, same as CDSP/GDSP.
+ */
+ if (cctx->valid_attributes &&
+ cctx->dsp_attributes[DSP_IMAGE_CONFIG_ATTR_IDX] == FASTRPC_DSP_COMPUTE_LITE)
+ compute_lite = true;
switch (cctx->domain_id) {
case ADSP_DOMAIN_ID:
case MDSP_DOMAIN_ID:
case SDSP_DOMAIN_ID:
case HPASS_DOMAIN_ID:
+ if (compute_lite)
+ goto unsigned_capable;
cctx->unsigned_support = false;
err = fastrpc_device_register(rdev, cctx, cctx->secure, cctx->domain);
if (err)
@@ -2726,6 +2744,7 @@ static int fastrpc_register_devices(struct fastrpc_channel_ctx *cctx,
break;
case CDSP_DOMAIN_ID:
case GDSP_DOMAIN_ID:
+unsigned_capable:
cctx->unsigned_support = true;
err = fastrpc_device_register(rdev, cctx, true, cctx->domain);
if (err)
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/4] misc: fastrpc: add HPASS domain
2026-11-25 0:06 ` [PATCH 2/4] misc: fastrpc: add HPASS domain Anandu Krishnan E
@ 2026-11-25 0:24 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-25 0:24 UTC (permalink / raw)
To: Anandu Krishnan E; +Cc: dri-devel, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] misc: fastrpc: use-after-free due to dangling dma_mask in
fastrpc_rpmsg_probe() [1]
--
commit 45628114d33912de02c404c2680ce4e7336df5df
Author: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
misc: fastrpc: add HPASS domain
This commit adds HPASS_DOMAIN_ID for the High Performance Audio Subsystem
(HPASS), maps the "hpass" devicetree label to it, and enables reserved
remote heap memory and device registration for the domain.
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 9e760f68bcaf2..c515097c3d3ba 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
[ ... ]
> @@ -2761,6 +2765,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> case ADSP_DOMAIN_ID:
> case MDSP_DOMAIN_ID:
> case SDSP_DOMAIN_ID:
> + case HPASS_DOMAIN_ID:
> /* Unsigned PD offloading is only supported on CDSP and GDSP */
> data->unsigned_support = false;
> err = fastrpc_device_register(rdev, data, secure_dsp, domain);
[Severity: Critical]
This problem wasn't introduced by this patch, but can fastrpc_rpmsg_probe()
leave a dangling rdev->dma_mask pointer [1]?
drivers/misc/fastrpc.c:fastrpc_rpmsg_probe() {
...
rdev->dma_mask = &data->dma_mask;
dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32));
...
err = fastrpc_cb_devices_create(rpdev);
if (err)
goto err_deregister_fdev;
...
err_free_data:
kfree(data);
return err;
}
fastrpc_rpmsg_probe() points rdev->dma_mask at data->dma_mask inside the
heap-allocated fastrpc_channel_ctx. If fastrpc_cb_devices_create() fails
or the driver is later unbound via fastrpc_rpmsg_remove() ->
fastrpc_channel_ctx_put(), data is freed while rpdev->dev lives on with
rdev->dma_mask still pointing into the freed object, causing a
use-after-free on any subsequent probe or DMA API access on the device.
[1] https://sashiko.dev/#/bug/linux-3d83ea49-16e6-4a33-9f74-77e4b19335b8
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-fastrpc-hpass-support-v1-0-cb1d46b29e3b@oss.qualcomm.com?part=2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/4] misc: fastrpc: query the dsp capabilities during probe time
2026-11-25 0:06 ` [PATCH 3/4] misc: fastrpc: query the dsp capabilities during probe time Anandu Krishnan E
@ 2026-11-25 0:28 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-25 0:28 UTC (permalink / raw)
To: Anandu Krishnan E; +Cc: dri-devel, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] misc: fastrpc: NULL deref and teardown race in
fastrpc_cap_query_work()
- [High] misc: fastrpc: leak of ctx, DMA buf, fl, and cctx in
fastrpc_cap_query_work()
- [Medium] misc: fastrpc: race duplicating ADSP sessions after
misc_register()
- [Medium] misc: fastrpc: misuse of WQ_MEM_RECLAIM on per-channel cap_wq
in probe()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] misc: fastrpc: NULL pointer dereference in
fastrpc_remote_heap_alloc() [1]
--
commit 5d26fca6a35553f861e698fe1de404c633098aee
Author: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
misc: fastrpc: query the dsp capabilities during probe time
This commit moves the DSP capability query to an asynchronous per-channel
workqueue at probe time and registers the FastRPC device nodes once the
query completes.
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index c515097c3d3ba..59ef755feeaf0 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
[ ... ]
> @@ -2704,6 +2708,159 @@ static int fastrpc_init_reserved_mem(struct fastrpc_channel_ctx *cctx,
> cctx->vmperms, cctx->vmcount);
> }
>
> +static int fastrpc_register_devices(struct fastrpc_channel_ctx *cctx,
> + struct rpmsg_device *rpdev)
> +{
> + struct device *rdev = &rpdev->dev;
> + int err, i;
> +
> + switch (cctx->domain_id) {
> + case ADSP_DOMAIN_ID:
> + case MDSP_DOMAIN_ID:
> + case SDSP_DOMAIN_ID:
> + case HPASS_DOMAIN_ID:
> + cctx->unsigned_support = false;
> + err = fastrpc_device_register(rdev, cctx, cctx->secure, cctx->domain);
> + if (err)
> + goto err_depopulate;
> + break;
[ ... ]
> + /* Duplicate the last session so multiple processes can share
> + * the same compute bank.
> + */
> + if (cctx->domain_id == ADSP_DOMAIN_ID && cctx->sesscount > 0) {
> + struct fastrpc_session_ctx *last_sess;
> + struct fastrpc_session_ctx *dup_sess;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&cctx->lock, flags);
> + last_sess = &cctx->session[cctx->sesscount - 1];
> + for (i = 0; i < FASTRPC_DUP_SESSIONS; i++) {
> + if (cctx->sesscount >= FASTRPC_MAX_SESSIONS)
> + break;
> + dup_sess = &cctx->session[cctx->sesscount++];
> + memcpy(dup_sess, last_sess, sizeof(*dup_sess));
> + }
> + spin_unlock_irqrestore(&cctx->lock, flags);
> + }
[Severity: Medium]
Can an open() right after fastrpc_device_register() cause memcpy() to mark
all duplicated ADSP sessions as used?
Before this patch, fastrpc_device_register() ran before
fastrpc_cb_devices_create(), so cctx->sesscount was 0 when the miscdevice
appeared. Now cctx->sesscount is already populated when
fastrpc_device_register() exposes the device node:
CPU0 (kworker) CPU1 (userspace open)
fastrpc_register_devices()
fastrpc_device_register()
misc_register()
fastrpc_device_open()
fastrpc_session_alloc()
session[sesscount - 1].used = true
spin_lock_irqsave(&cctx->lock)
last_sess = &cctx->session[cctx->sesscount - 1]
memcpy(dup_sess, last_sess, ...)
/* copies used = true into all 4 dup_sess slots */
Those duplicated session slots have no owning fastrpc_user and remain
unallocatable for the lifetime of the channel. Duplicating the ADSP
sessions before calling fastrpc_device_register() avoids exposing the
partially initialized session table.
[ ... ]
> +static void fastrpc_cap_query_work(struct work_struct *work)
> +{
> + struct fastrpc_channel_ctx *cctx =
> + container_of(work, struct fastrpc_channel_ctx, cap_query_work);
> + struct rpmsg_device *rpdev = cctx->rpdev;
> + struct device *rdev = &rpdev->dev;
> + u32 *dsp_attributes;
> + struct fastrpc_user *fl;
> + unsigned long flags;
> + int err;
> +
> + fl = kzalloc_obj(*fl);
> + if (!fl)
> + goto register_devices;
> +
> + spin_lock_init(&fl->lock);
> + mutex_init(&fl->mutex);
> + INIT_LIST_HEAD(&fl->pending);
> + INIT_LIST_HEAD(&fl->maps);
> + INIT_LIST_HEAD(&fl->mmaps);
> + INIT_LIST_HEAD(&fl->user);
> + fl->cctx = cctx;
> + fl->pd = ROOT_PD;
> + kref_init(&fl->refcount);
> + fastrpc_channel_ctx_get(cctx);
> +
> + fl->sctx = fastrpc_session_alloc(fl);
> + if (!fl->sctx) {
> + dev_warn(rdev, "no session for capability query, skipping\n");
> + fastrpc_user_put(fl);
> + goto register_devices;
> + }
> +
> + dsp_attributes = kzalloc_objs(*dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES);
> + if (!dsp_attributes)
> + goto err_cleanup_register;
> +
> + /* Linked into cctx->users so fastrpc_rpmsg_remove() can abort us
> + * via fastrpc_notify_users() instead of waiting out the timeout.
> + */
> + spin_lock_irqsave(&cctx->lock, flags);
> + if (!cctx->rpdev) {
> + spin_unlock_irqrestore(&cctx->lock, flags);
> + goto err_cleanup_noreg;
> + }
[Severity: High]
This problem wasn't introduced by this patch, but fastrpc_rpmsg_remove()
clears cctx->rpdev without waiting for in-flight invocations [1],
which can cause a NULL pointer dereference in fastrpc_remote_heap_alloc().
fastrpc_internal_invoke() checks fl->cctx->rpdev locklessly and does not
hold the lock across argument allocation:
CPU0 CPU1
fastrpc_internal_invoke()
if (!fl->cctx->rpdev)
fastrpc_rpmsg_remove()
spin_lock_irqsave(&cctx->lock, ...)
cctx->rpdev = NULL
spin_unlock_irqrestore(&cctx->lock, ...)
fastrpc_get_args()
fastrpc_remote_heap_alloc()
rdev = &fl->cctx->rpdev->dev
__fastrpc_buf_alloc(..., rdev, ...)
<-- NULL pointer dereference
> + list_add_tail(&fl->user, &cctx->users);
> + spin_unlock_irqrestore(&cctx->lock, flags);
> +
> + err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES);
> +
> + spin_lock_irqsave(&cctx->lock, flags);
> + list_del(&fl->user);
> + spin_unlock_irqrestore(&cctx->lock, flags);
> +
> + if (err == -EPIPE) {
> + /* Channel is going away; remove() will tear it down. */
> + goto err_cleanup_noreg;
> + }
[Severity: High]
Can a concurrent fastrpc_rpmsg_remove() trigger a NULL pointer dereference
or register device nodes on a removed channel in fastrpc_cap_query_work()?
fastrpc_rpmsg_remove() sets cctx->rpdev = NULL and calls
fastrpc_notify_users() once before waiting in
cancel_work_sync(&cctx->cap_query_work). At the top of
fastrpc_cap_query_work(), rpdev = cctx->rpdev is read without holding
cctx->lock or checking for NULL:
CPU0 CPU1 (kworker)
fastrpc_rpmsg_remove()
spin_lock_irqsave(&cctx->lock)
cctx->rpdev = NULL
spin_unlock_irqrestore(&cctx->lock)
cancel_work_sync(&cctx->cap_query_work)
fastrpc_cap_query_work()
rpdev = cctx->rpdev /* NULL */
fastrpc_session_alloc() -> NULL
goto register_devices
fastrpc_register_devices(cctx, NULL)
fastrpc_device_register(NULL, ...)
<-- NULL pointer dereference
Even when cctx->rpdev is non-NULL at the locked check before
fastrpc_get_info_from_dsp(), dropping cctx->lock allows
fastrpc_rpmsg_remove() to clear cctx->rpdev and run fastrpc_notify_users()
before fastrpc_context_alloc() adds ctx->node to fl->pending;
fastrpc_invoke_send() then dereferences cctx->rpdev->ept while cctx->rpdev
is NULL.
Also, if fastrpc_rpmsg_remove() clears cctx->rpdev after
fastrpc_get_info_from_dsp() has already returned (for example with 0 or
-ETIMEDOUT), err is not -EPIPE, so fastrpc_cap_query_work() falls through
to register_devices and registers the miscdevices during teardown.
[ ... ]
> +err_cleanup_register:
> + kfree(dsp_attributes);
> + fastrpc_session_free(cctx, fl->sctx);
> + fl->sctx = NULL;
> + fastrpc_user_put(fl);
> + goto register_devices;
> +
> +err_cleanup_noreg:
> + kfree(dsp_attributes);
> + fastrpc_session_free(cctx, fl->sctx);
> + fl->sctx = NULL;
> + fastrpc_user_put(fl);
> + return;
[Severity: High]
Does fastrpc_cap_query_work() leak the invoke context, its DMA buffer, fl,
and cctx when fastrpc_get_info_from_dsp() fails with -ETIMEDOUT or -EPIPE?
fastrpc_context_alloc() takes a reference on fl (released only in
fastrpc_context_free()) and a reference on cctx, and fastrpc_invoke_send()
takes a second reference on ctx for the rpmsg reply callback:
drivers/misc/fastrpc.c:fastrpc_internal_invoke() {
...
bail:
if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
/* We are done with this compute context */
spin_lock(&fl->lock);
list_del(&ctx->node);
spin_unlock(&fl->lock);
fastrpc_context_put(ctx);
}
...
}
On -ETIMEDOUT, fastrpc_internal_invoke() leaves ctx on fl->pending without
dropping its reference. fastrpc_user_put(fl) here only drops fl->refcount
from 2 to 1 because ctx still holds a reference to fl, while fl->pending is
only drained in fastrpc_user_free(), leaving fl and ctx in a reference
cycle. In addition, fastrpc_session_free(cctx, fl->sctx) releases the
session back to the pool for reuse while ctx->buf is still mapped on that
session's IOMMU context bank.
On -EPIPE from fastrpc_notify_users(), fastrpc_internal_invoke() removes
ctx from fl->pending and calls fastrpc_context_put(ctx) once, dropping
ctx->refcount from 2 to 1. Because the channel is being removed and the
rpmsg callback will not run, the second reference taken by
fastrpc_invoke_send() is never dropped, so ctx, ctx->buf, fl, and cctx are
never freed.
[ ... ]
> @@ -2804,31 +2933,27 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
>
> err = fastrpc_cb_devices_create(rpdev);
> if (err)
> - goto err_deregister_fdev;
> -
> - if (data->domain_id == ADSP_DOMAIN_ID && data->sesscount > 0) {
> - struct fastrpc_session_ctx *last_sess;
> - struct fastrpc_session_ctx *dup_sess;
> - unsigned long flags;
> + goto err_unmap_heap;
>
> - spin_lock_irqsave(&data->lock, flags);
> - last_sess = &data->session[data->sesscount - 1];
> - for (i = 0; i < FASTRPC_DUP_SESSIONS; i++) {
> - if (data->sesscount >= FASTRPC_MAX_SESSIONS)
> - break;
> - dup_sess = &data->session[data->sesscount++];
> - memcpy(dup_sess, last_sess, sizeof(*dup_sess));
> - }
> - spin_unlock_irqrestore(&data->lock, flags);
> + /* Probe returns immediately; the capability query and device node
> + * registration happen asynchronously on this channel's own queue.
> + */
> + data->cap_wq = alloc_ordered_workqueue("fastrpc_cap_wq_%s",
> + WQ_HIGHPRI | WQ_MEM_RECLAIM,
> + domain);
[Severity: Medium]
Should this workqueue be allocated without WQ_MEM_RECLAIM, or use a shared
system workqueue instead?
WQ_MEM_RECLAIM spawns a dedicated rescuer kthread per channel that stays
alive until fastrpc_rpmsg_remove(), and requires the work item not to enter
direct memory reclaim. fastrpc_cap_query_work() is not part of a memory
reclaim path and performs GFP_KERNEL allocations in kzalloc_obj(),
dma_alloc_coherent(), and misc_register(). Queuing cap_query_work on
system_highpri_wq (or system_dfl_wq) would run queries for different
domains concurrently without a per-channel workqueue or rescuer kthread.
[1] https://sashiko.dev/#/bug/linux-94614a33-7b4b-4011-a75a-fc1470b783b0
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-fastrpc-hpass-support-v1-0-cb1d46b29e3b@oss.qualcomm.com?part=3
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-25 0:28 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 0:06 [PATCH 0/4] misc: fastrpc: add HPASS domain support Anandu Krishnan E
2026-11-25 0:06 ` [PATCH 1/4] dt-bindings: misc: qcom,fastrpc: add hpass label Anandu Krishnan E
2026-11-25 0:06 ` [PATCH 2/4] misc: fastrpc: add HPASS domain Anandu Krishnan E
2026-11-25 0:24 ` sashiko-bot
2026-11-25 0:06 ` [PATCH 3/4] misc: fastrpc: query the dsp capabilities during probe time Anandu Krishnan E
2026-11-25 0:28 ` sashiko-bot
2026-11-25 0:06 ` [PATCH 4/4] misc: fastrpc: expose unsigned PD node for compute-capable HPASS Anandu Krishnan E
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox