Skip to content

Do DAPF properly - #22

Merged
niklassheth merged 6 commits into
mainfrom
PR_dapf_adt_power_restore
Nov 15, 2026
Merged

niklassheth merged 6 commits into
mainfrom
PR_dapf_adt_power_restore

Conversation

@ADevWithAnIdea

Copy link
Copy Markdown
Member

No description provided.

dapf_entries hardcodes the DAPF reg index of a fixed set of DARTs. On
T8132, dart-pmp, dart-dcp and dart-dcpext0 have no DAPF, and their reg
at that index is a PS_PROT page shared by many DARTs, which raises an
SError when written. Newer SoCs also have DAPFs on DARTs the table does
not name: dart-ave0/1 and dart-ane0 on T6040/T6041, dart-pmp0/1 on
T6050 and dart-ane1 on T8152.

Walk every DART under /arm-io and take the DAPF from its "instance"
property, which types each reg range by fourcc in one of two layouts:
{type, unit, name[8]} per range, or {type, name[8]} per DART range with
the DAPF in the range after them. The entry count tells them apart.
Fall back to the table for a DART with no instance list.

Assisted-By: LLM
Signed-off-by: Youwes09 <yuvi.shen@outlook.com>
Signed-off-by: Cody Ho <codyho@stanford.edu>
On T8132, T8142 and T8152, dart-ave has a DAPF but lists no filter
data, so there is nothing to write, yet it was reported as an error.
Look the data up before powering the device and skip the DAPF if there
is none.

Assisted-By: LLM
Signed-off-by: Youwes09 <yuvi.shen@outlook.com>
Signed-off-by: Cody Ho <codyho@stanford.edu>
The DAPF is clock gated with the device behind its DART. On T8132,
T8140, T8142 and T8152, the DART lists no gates of its own; they are on
the device named without "dart-" (isp, ane, ave, pmp), so those DAPFs
were written unpowered. An empty clock-gates, as on T8132's mtp and
aop, counts as none.

Power the device only if it is off, and power it down again only then:
the old code gated a device it found running. If the state cannot be
read, power the device and leave it on rather than write to it
unpowered.

Assisted-By: LLM
Signed-off-by: Youwes09 <yuvi.shen@outlook.com>
Signed-off-by: Cody Ho <codyho@stanford.edu>
@ADevWithAnIdea
ADevWithAnIdea force-pushed the PR_dapf_adt_power_restore branch from 23cb6e2 to b3ebc7f Compare November 15, 2026 10:14
ADevWithAnIdea and others added 3 commits November 15, 2026 02:19
Snapshot the real clock gates and their parents before temporarily
powering a device. Virtual gates have no register of their own, so save
their real ancestors as well and deduplicate shared gates.

Restore requested power modes and automatic-gating settings in reverse
dependency order. Preserve gates that were already active, roll back
partial enables, and keep parents powered if restoring a child fails.

Co-authored-by: Youwes09 <yuvi.shen@outlook.com>
Signed-off-by: Cody Ho <codyho@stanford.edu>
Assisted-By: LLM
Save the device power tree before enabling an inactive DAPF owner and
restore it after programming the filters, including on an enable failure.

Disabling only the ADT clock-gates is insufficient for virtual gates:
on the Neo, ANE-SYS-V enables ANE_SYS recursively, but the nonrecursive
disable is a no-op. This left ANE powered after successful initialization.
The snapshot restores the real domain without disabling active parents.

Keep the existing behavior for an unknown initial state: power the device
before writing registers and leave it powered when no snapshot exists.

Signed-off-by: Cody Ho <codyho@stanford.edu>
Assisted-By: LLM
Use dapf_init_all() on T8132 now that ADT instance discovery selects the
correct registers and initialization powers the owning device safely.
Remove the chip-wide bypass and the hardcoded MTP and AOP initializers
in a single change.

Keep the MTP firmware segment reservations: those DART mappings are still
required before the coprocessor starts DMA, independently of DAPF setup.

Signed-off-by: Cody Ho <codyho@stanford.edu>
Assisted-By: LLM

@niklassheth niklassheth left a comment

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.

Tested, works on M4 Air and mini

@niklassheth
niklassheth merged commit 5d8f811 into main Nov 15, 2026
1 of 5 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.

3 participants