Skip to content

Domain discovery - #422

Merged
Ekansh Gupta (ekanshibu) merged 8 commits into
qualcomm:developmentfrom
quic-anane:domain-discovery-for-nord
Nov 29, 2026
Merged

Ekansh Gupta (ekanshibu) merged 8 commits into
qualcomm:developmentfrom
quic-anane:domain-discovery-for-nord

Conversation

@quic-anane

@quic-anane Anandu Krishnan E (quic-anane) commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

This series adds dynamic FastRPC domain discovery: instead of a fixed, compile-time table of DSP domains, the host now discovers live /dev/fastrpc-* nodes at runtime and builds domain info (type, instance, name) from them, so new or variable DSP instance counts work without
hardcoding. The new remote_system_request() API exposes this to clients that need current domain/capability info instead of static config. On top of that, HPASS is classified as a capability of the adsp family (HVX 64B/128B support + ARCH_VER ≥ v81) rather than a separate
device-node family, and audiopd is generalized to connect to any adsp instance whose image config has spare audio capacity.

fastrpc: fix buffer overread and leak/misroute gaps unrelated to dynamic domains
fastrpc: add remote_system_request() and dynamic domain discovery
fastrpc: add DSP_IMAGE_CONFIG attribute and per-instance HPASS/NSP shell fallback
fastrpc: add domain status notification support
fastrpc: add systemd units for the secondary HPASS/NSP instances, restore legacy flat unit names
fastrpc: fix effective-domain validation and extend ARCH_VER path caching to dynamic domains
fastrpc: split domain discovery into generic watcher + devnode backend
fastrpc: start the audiopd daemon on every adsp instance

CRs-Fixed: 4761369

Comment thread src/fastrpc_apps_user.c Fixed
Comment thread src/fastrpc_domains.c Fixed
Comment thread src/fastrpc_domains.c Fixed
Comment thread src/fastrpc_domains.c Fixed
Comment thread src/fastrpc_domains.c Fixed
Comment thread src/fastrpc_domains.c Fixed
Comment thread src/fastrpc_domains.c Fixed
@ekanshibu

Copy link
Copy Markdown
Contributor

Add Signed-off-by

Comment thread inc/fastrpc_internal.h Resolved
Comment thread inc/fastrpc_internal.h Resolved
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_apps_user.c Dismissed
Comment thread src/fastrpc_domain_watcher.c Dismissed
Comment thread src/fastrpc_domain_watcher.c Dismissed
Comment thread src/fastrpc_domain_watcher.c Fixed
Comment thread src/fastrpc_domain_watcher.c Fixed
Comment thread src/fastrpc_domain_watcher.c Dismissed
Comment thread src/fastrpc_domain_watcher.c Dismissed
Comment thread inc/fastrpc_internal.h Resolved
Comment thread src/fastrpc_ioctl.c Resolved
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_domain_watcher.c Resolved
Comment thread src/fastrpc_domain_discovery_devnode.c Resolved
Comment thread inc/fastrpc_domain_watcher.h Resolved
Comment thread src/fastrpc_domain_discovery_devnode.c Resolved
Comment thread src/fastrpc_cap.c Resolved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message says 83bed01 adds the FASTRPC_REGISTER/DEREGISTER_DOMAIN_STATUS_NOTIFICATIONS ids, but they arrive in 274eaff. Please drop that paragraph or move the changes into this commit.

Comment thread src/fastrpc_apps_user.c Resolved
Comment thread inc/fastrpc_internal.h Resolved
Comment thread inc/remote.h Resolved
Comment thread src/fastrpc_apps_user.c Resolved
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_apps_user.c Resolved
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_domain_discovery_devnode.c Resolved
@quic-vkatoch

Copy link
Copy Markdown
Contributor

Please also update the PR description.

@quic-anane
Anandu Krishnan E (quic-anane) force-pushed the domain-discovery-for-nord branch 2 times, most recently from 367b11a to e5db38e Compare November 23, 2026 06:47
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_apps_user.c Resolved
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_domain_discovery_devnode.c Resolved
Comment thread src/fastrpc_domain_watcher.c Resolved
Comment thread src/fastrpc_domain_watcher.c Resolved
Comment thread src/fastrpc_domain_watcher.c Resolved
Comment thread src/fastrpc_domains.c Resolved
Comment thread src/fastrpc_domain_watcher.c Dismissed
Comment thread src/fastrpc_domain_watcher.c Dismissed
…mic domains

Found while stress-testing the dynamic domain discovery feature, but
present in pre-existing code:

- get_domain_from_name() used strlen()/strncmp() on domain_name
  directly instead of the documented domain_name_len, causing a heap
  buffer overread for a caller following that contract exactly (a
  buffer sized to domain_name_len, no trailing NUL). Same issue for
  GET_URI's module_uri.
- The same legacy-name fallback used strncmp() (prefix match) instead
  of an exact match, letting a garbage-suffixed name resolve as a
  legacy domain.
- fopen_from_dirlist()'s fallback path allocation leaked on every
  dirList entry except the last.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Anandu Krishnan E <[email protected]>
@quic-anane Anandu Krishnan E (quic-anane) changed the title Domain discovery for nord Domain discovery Nov 25, 2026
@quic-anane
Anandu Krishnan E (quic-anane) force-pushed the domain-discovery-for-nord branch 2 times, most recently from 2a7303f to 01e7b6e Compare November 25, 2026 13:40
Comment thread Docs/manpages/dsprpcd.8 Resolved
Comment thread Docs/manpages/dsprpcd.8 Resolved
Comment thread inc/fastrpc_internal.h Resolved
@quic-anane
Anandu Krishnan E (quic-anane) force-pushed the domain-discovery-for-nord branch 2 times, most recently from ef96d4c to b6d52f7 Compare November 25, 2026 15:57
@datadog-qualcomm

This comment has been minimized.

Anandu Krishnan E and others added 3 commits November 27, 2026 12:43
Add support for targets with a variable number of DSP instances beyond
the fixed legacy set (adsp/cdsp/cdsp1/sdsp/gdsp0/gdsp1), via two new id
kinds that coexist with the legacy scheme in one int namespace:
- Logical domain id: type*1000+instance (e.g. nsp1000, hpass5001).
- Effective domain id: logical_id*100+session.

A Level-1 hash table of discovered physical domains is populated by
scanning /dev for "fastrpc-*" nodes; each node name is parsed as
"<family><digits>" via a small family->type table, so another instance
of an existing family needs no code change.

Add the public remote_system_request() API with FASTRPC_GET_DOMAINS to
query available domains.

Every public API that takes a domain id normalizes it (legacy or
dynamic) before using it for a session lookup, so existing callers
keep working unchanged.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Anandu Krishnan E <[email protected]>
…ell fallback

Add DSP_IMAGE_CONFIG remote DSP attribute and the dsp_image_config enum
describing the available DSP image configurations (full compute,
compute-lite, audio), cached per physical domain in the Level-1 table.

open_shell() resolves a shell for secondary NSP/HPASS instances that
the primary shell-path lookup doesn't cover: NSP instances sharing
cdsp's compute image retry against the primary cdsp/ directory;
HPASS/LPASS instances try their own discovered directory, then a
capability-specific directory (adsp_computelite/ or adsp_audio/) based
on DSP_IMAGE_CONFIG.

fopen_from_dirlist() takes its domain as an explicit parameter instead
of reading get_current_domain() internally, and routes dynamic domain
names through the Level-1 table since SUBSYSTEM_NAME[] only covers
legacy ids.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Anandu Krishnan E <[email protected]>
Allow clients to register/deregister callbacks that fire when a
domain's up/down status changes, via
FASTRPC_REGISTER_DOMAIN_STATUS_NOTIFICATIONS and
FASTRPC_DEREGISTER_DOMAIN_STATUS_NOTIFICATIONS requests to
remote_system_request(). Registration fires a catch-up callback for
already-discovered matching domains, and accepts either a real
non-negative domain_id or a -1 wildcard-by-type sentinel.

Notifier callbacks run without holding internal locks: domain_info and
the callback list are snapshotted under their respective locks, then
the callbacks fire outside both.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Anandu Krishnan E <[email protected]>
@anankulk

Copy link
Copy Markdown
Contributor

Pre-merge CI results — patch a410b493e093

Pre-merge CI Results

Run: 46106174119
Overall: ✅ All boards passed

Board Step Result Duration
qcs615-ride Build ✅ success 6m20s
monaco-evk Build ✅ success 6m31s
shikra-evk Build ✅ success 6m38s
hamoa-iot-evk Build ✅ success 6m39s
sm8750-mtp Build ✅ success 6m44s
qcs9100-ride-r3 Build ✅ success 6m00s
kaanapali-mtp Build ✅ success 6m26s
qcs6490-rb3gen2 Build ✅ success 6m29s
glymur-crd Build ✅ success 6m15s
qcs8300-ride Build ✅ success 6m23s
lemans-evk Build ✅ success 6m14s
purwa-iot-evk Build ✅ success 6m20s
qcs615-adp-air Build ✅ success 6m14s
sm8750-mtp Test ✅ success 25m27s
qcs8300-ride Test ✅ success 12m25s
purwa-iot-evk Test ✅ success 15m51s
lemans-evk Test ✅ success 8m48s
kaanapali-mtp Test ✅ success 10m23s
qcs615-ride Test ✅ success 17m49s
glymur-crd Test ✅ success 10m16s
monaco-evk Test ✅ success 11m33s
qcs6490-rb3gen2 Test ✅ success 11m16s
qcs9100-ride-r3 Test ✅ success 12m48s
qcs615-adp-air Test ✅ success 27m58s
shikra-evk Test ✅ success 11m15s
hamoa-iot-evk Test ✅ success 48m32s

Posted manually — results from run 46106174119

Anandu Krishnan E and others added 4 commits November 29, 2026 14:12
…tore legacy flat unit names

Replace the adsp/cdsp/gdsp per-instance units with one systemd template
unit per family ([email protected], [email protected],
[email protected]), instantiated at runtime via the systemd "%i"
specifier for both ConditionPathExists and the daemon's "rootpd <name>"
argument, so adsp1/adsp2/cdsp2/cdsp3/gdsp2+ need no new file or rule.

Keep the original, non-templated unit files and exact-match udev rules
for the instances that existed before dynamic domain discovery (adsp,
cdsp, cdsp1, gdsp0, gdsp1), so anything that enables/starts them by
their exact legacy unit name keeps working; only instances with no
legacy name use the template.

sdsp keeps its original single, non-templated unit since it has only
one instance today.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Anandu Krishnan E <[email protected]>
…hing to dynamic domains

build_dsp_search_path_cache_for_domain() validated the raw effective
domain id against the bare-id checks (IS_VALID_DOMAIN_ID/
IS_DYNAMIC_DOMAIN_ID) instead of their effective-id counterparts,
rejecting every dynamic-domain call outright and risking an
out-of-bounds DSP_SEARCH_PATHS_CACHE[] access for legacy domains with
session >= 1.

Switch both checks to the _EFFECTIVE_/_EFFEC_ variants used elsewhere
in this file, and extend the ARCH_VER path cache to dynamic domains via
a new dsp_search_path field in the Level-1 domain table, mirroring the
existing fastrpc_get_cached_image_config() pattern. The cache is
consulted before the ARCH_VER query, so repeat sessions of the same
physical domain skip the ioctl entirely.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Anandu Krishnan E <[email protected]>
Split fastrpc_domains.c into three pieces along the lines that were
already implicit in it: the generic Level-1 table/notification
registry (fastrpc_domains.c), a generic domain-availability watcher
thread (fastrpc_domain_watcher.c), and the /dev-node-probing discovery
backend (fastrpc_domain_discovery_devnode.c). The watcher thread's
mechanics (inotify setup, polling fallback, exit signaling, the
ueventd/SELinux label-race retry) don't depend on how domains are
found, so it now takes the watched directory and rescan/event
callbacks via a small config struct instead of hardcoding /dev and
fastrpc_discover_domains(). This lets a different discovery backend
(e.g. one based on a sysfs tree) be plugged in later without touching
the registry or the watcher thread.

No functional change.

Signed-off-by: Anandu Krishnan E <[email protected]>
resolve_domain_cli_alias() and fastrpc_domain_is_audio() generalize
from a single hardcoded adsp domain to any adsp-family instance
(adsp, adsp1, ...), parsed via fastrpc_parse_dev_family(). An
instance connects to audio PD unless its cached image config is
full FASTRPC_DSP_COMPUTE.

dsprpcd treats AEE_EUNSUPPORTED as a fatal exit (no restart loop)
for instances where audiopd has nothing to attach to.

Signed-off-by: Anandu Krishnan E <[email protected]>
@anankulk

Copy link
Copy Markdown
Contributor
🤖 FastRPC AI Code Review — ⚠️ 6 finding(s): 4 HIGH, 2 MEDIUM · patch 6704cf9c10f0
Severity Location Rule Issue Suggested Fix
🟡 MEDIUM src/apps_std_imp.c:1080 mm-002 malloc(absName) not freed on all paths when out_path is NULL Add FREEIF(absName); before the return nErr; at line 1080, or ensure absName is freed/transferred on every path
🔴 HIGH src/apps_std_imp.c:1029 var-002 Pointer absName not initialized to NULL Change line 1029 to char *absName = NULL, *dirName = NULL, *pos = NULL;
🔴 HIGH src/fastrpc_internal.h:134 mm-009 Array index domain used without bounds check in apps_std_domain_name() Add VERIFYC(domain >= 0 && domain < NUM_DOMAINS, AEE_EBADPARM); before return SUBSYSTEM_NAME[domain]; at line 147
🔴 HIGH inc/fastrpc_domain_watcher.h:44 var-002 Function pointer handle_event_fn not validated before call Callers of handle_event_fn must check if (cfg->handle_event_fn) cfg->handle_event_fn(name, appeared); before invoking
🟡 MEDIUM src/adsp_default_listener.c:63 mm-002 malloc(uri) without free on all error paths Ensure free(uri); is called in all error paths after malloc at line 86
🔴 HIGH src/adsp_default_listener.c:86 mm-003 Missing NULL check after malloc Change line 86-88 to wrap malloc in VERIFYC: VERIFYC(NULL != (uri = (char *)malloc(len)), AEE_ENOMEMORY);

⚠️ Diff truncated (>60 KB) — review may be partial.

To suppress a false positive: add an entry to .qvigor/review_feedback.json on the development branch with "decision": "denied".

@ekanshibu
Ekansh Gupta (ekanshibu) merged commit 0b2374d into qualcomm:development Nov 29, 2026
33 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants