Skip to content

media: apple: prores: bind T6041's second engine (apr1) without an aux window - #2509

Closed
RyanTheTide wants to merge 5 commits into
integration/aurorafrom
media/prores-apr1-optional-aux-20261120
Closed

RyanTheTide wants to merge 5 commits into
integration/aurorafrom
media/prores-apr1-optional-aux-20261120

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The M4 Max (T6041) has a second ProRes engine, apr1. Its Apple device tree node has only an engine window (0x585000000) and a wrapper window (0x584000000), interrupt 2010, its own DART at 0x585020000 (one stream, sid 0) and its own PRORES power domain. It has no SCODEC system (aux) window. The T6041 variant required core, wrapper and aux, so apr1 could never bind. The T6041 device tree also had no ProRes nodes at all; only the T6040 did.

Change

  • Binding: a apple,t6041-prores node may have two reg entries (core, wrapper) or three (core, wrapper, aux). Other compatibles are unchanged.
  • Driver: core and wrapper stay required. The SCODEC windows after them (aux, and ctrl on T6050) are mapped only when the node's reg-names lists them. Without the window its system or control rows are not applied; apr_hw_init() already skips a missing window. This is a hardware-description check, not a compatible or instance check.
  • apr1's interrupt: on a J616c apr1 sets IRQ_STATUS but its AIC line (2010) never goes high, and 20 wrapper offsets end up different from apr0's (0xc00 reads 0xf instead of 0x7fffffff). After a job finishes without its interrupt, the driver polls completion with a 100 us hrtimer, so the engine is not held to the 4 ms watchdog. That took apr1 from 125 fps to 543 fps (HQ) and 347 fps (4444). A second pass of the wrapper rows did not change apr1's wrapper and has been replaced by a readback: the first time a wrapper does not take its rows, the driver logs each one (value before, written, read back) and checks once more after a completed job. The interrupt cause is still open.
  • DT: t6041.dtsi now describes apr0 (same addresses as T6040, with aux, SCODEC and SCODEC_STREAMING domains) and apr1 (core and wrapper only, own DART, PRORES domain), all disabled. The J616c enables both engines.

Testing

  • make W=1 arm64 LLVM build of drivers/media/platform/apple/prores/: no warnings.
  • dt_binding_check DT_SCHEMA_FILES=apple,prores.yaml: clean.
  • CHECK_DTBS=y for t6041-j616c, t6041-j614c, t6041-j575c, t6040-j616s, t6040-j614s, t6040-j773s: no warnings, before or after. The new J616c dtb checked against the old schema reports apr1's two reg entries as too short, so the check does cover the new node.
  • The three T6040 dtbs are byte-identical before and after.
  • KUnit (arm64, LLVM, prores kunitconfig): 17 of 17 pass.
  • checkpatch --strict: 0 errors, 0 warnings, 0 checks on each patch.
  • 39687ee: W=1 LLVM arm64 build of the driver silent; checkpatch --strict on the patch clean.

Still to run

  • J616c row of 44cc1db: done. apr0 1618/1101 fps, 1.00 IRQ/job; apr1 543/347 fps (was 125), 0 IRQs, output byte-identical, 0 errors.
  • J616c row of 39687ee: the wrapper readback lines for apr1 (and none for apr0), asked in the PR thread. Not run on our J616s: it is in use as another machine's tether host tonight.
  • What macOS leaves in apr1's wrapper (0x584000000 + 0x000-0xc00) after an apr1 encode, read on the tester's own J616c.
  • T6041 apr0 and apr1 encode rows on an M4 Max J616c.
  • M4 Pro single-engine regression row (apr0 with aux) on a T6040.
Values taken from the J616c device tree
apr0 apr1
core 0x301000000, 0x4000 0x585000000, 0x4000
wrapper 0x300000000, 0x1000000 0x584000000, 0x1000000
aux 0x3010c0000, 0x4000 none
interrupt 1960 2010
DART 0x301020000, irq 1959, stream 1 0x585020000, irq 2007, stream 0 (sid-count 1)
DART VM range 0x100_0000_0000 + 0x300_0000_0000 same
power / reset SCODEC_STREAMING / SCODEC PRORES / PRORES

PRORES is PMGR group 1 (the main bank at 0x502280000), offset 0x3a8, parent FAB6_SOC, matching the ARST(0xf7) reset function on apr1. apr1's clock gates are PRORES-V, PRORES-SOC-VNOM and PRORES-SOC-VMAX, and its DART's gate is PRORES-DART, all children of PRORES. FAB1_SOC (0x2d0), SCODEC (0x328) and SCODEC_STREAMING (0x330) are in PMGR group 0 (0x502800000) at the T6040's offsets. The ADT reg addresses are relative to arm-io and the interrupts are used as AIC numbers directly, as for apr0 on the T6040.

Notes for review
  • apr1 uses the same built-in core and wrapper rows (or the APRI file's) as apr0; only the system block rows are skipped. Whether apr1 needs rows of its own is what the J616c encode run will show.
  • The SCODEC and PRORES power domains on T6041 are new nodes in t6041.dtsi. There is no t6041-pmgr.dtsi; T6040 keeps its own copies in t6040-pmgr.dtsi and t6040-peripherals.dtsi, which are not touched.
  • Only the J616c enables the engines. The J614c and J575c get the nodes disabled until someone runs them.

Assisted-by: LLM (Claude:Opus 5.5)

The M4 Max has a second ProRes engine, apr1, outside the SCODEC block.
Its Apple device tree node lists only the engine and wrapper windows and
no SCODEC system window, so a T6041 node may now have two reg entries
(core, wrapper) as well as three (core, wrapper, aux). The other
compatibles are unchanged.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The T6041 variant asked for core, wrapper and aux and failed the probe
without all three. apr1 on the M4 Max sits outside the SCODEC block and
has no aux window, so it could not bind.

Keep core and wrapper required, and map the later SCODEC windows (aux,
and ctrl on T6050) only when the node's reg-names lists them. Without
the window the system or control rows are not applied, which the
power-up path already allows. This follows the hardware description in
the device tree, not the compatible or the instance.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Describe the two ProRes engines of the M4 Max from the J616c device
tree. apr0 sits in the SCODEC block at the same addresses as on the
T6040, with its SCODEC system window, DART and the SCODEC and
SCODEC_STREAMING power domains. apr1 has only its engine and wrapper
windows, interrupt 2010, its own single-stream DART at 0x585020000
(interrupt 2007) and the PRORES power domain (PMGR main bank, 0x3a8,
under FAB6_SOC), which also resets it.

All of it stays disabled in the SoC file. The J616c enables both
engines.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor

Row from a J616c (M4 Max, binned T6041, macOS 26.6.2 firmware), as asked.

Setup: daily 7.3.0 kernel, with apple-prores from this head (45ba8f9) built against it out of tree (LLVM, W=1 clean). The DT has apr0 and apr1 (plus their DARTs and power domains) as in this PR's t6041.dtsi: the same reg/reg-names, IRQs 1960/2010, DART sids 1/0 and power domains. The boot loader is aura main 7dae354b. The input is testsrc2 1920x1080, 8 distinct frames per buffer set, encoded with tools/asahi/prores-enc from this PR, 25 loops (200 jobs per row).

Probe: both engines probe (ProRes encoder, id 0x40008 for 301000000 and 585000000) and get their own node: video11 is apr0, video12 is apr1.

engine profile fps bytes (8 frames) md5 of the 8 frames IRQs over 200 jobs
apr0 3 HQ, NV16 1626 3088581 903a7d9057aa 200
apr0 4 4444, NV24 1104 4718141 58a0c7f858da 200
apr1 3 HQ, NV16 125 3088581 903a7d9057aa 0
apr1 4 4444, NV24 125 4718141 58a0c7f858da 0

Profile 0 (Proxy) matched too: 789818 bytes, ebc7d8f2fd02 on both engines. There were 0 DART faults, 0 job errors and 0 timeouts on either engine.

apr1 never raises its interrupt. Its line in /proc/interrupts (IRQ 2010) stays at 0 over 400 jobs, and the driver logs completion found without an interrupt (once, because it's dev_warn_once). Every apr1 job finishes through the 4 ms watchdog poll. At HZ=250 that's about 8 ms per job, so 125 fps whatever the profile, while apr0 takes 200 IRQs for 200 jobs. The engine itself completes correctly: the IRQ status is set when the poll reads it, and the output is byte-identical to apr0's.

The ADT gives apr1 interrupts = <2010> with the same interrupt-parent as apr0 (1960), and the DT uses 2010. So the number matches the ADT, but nothing arrives. Two guesses:

  • apr1's wrapper needs its own interrupt-enable or routing row, since the 62 wrapper rows were captured from apr0;
  • the line is gated by something the PRORES domain doesn't cover; its ADT clock-gates are PRORES-V plus the PRORES-SOC-VNOM/VMAX votes, mirroring apr0's SCODEC-V/SCODEC-SOC-*.

I can run a test build on this Mac if you want something specific checked, e.g. wrapper registers dumped on both engines after the rows are applied.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks for the row. Here is a read-only capture for apr0 vs apr1 that you can run on the current boot (trial DTB, out-of-tree apple-prores from 45ba8f9 loaded):

https://gist.github.com/RyanTheTide/371045b52cbfe10aa9cbe7f85bf2b0c2

git clone https://gist.github.com/371045b52cbfe10aa9cbe7f85bf2b0c2.git apr-irqpeek
cd apr-irqpeek
sudo bash apr-irqpeek.sh            # needs gcc, make and /lib/modules/$(uname -r)/build
sudo tar czf ~/apr-irqpeek.tgz -C /var/lib/aurora-test/apr-irqpeek "$(ls /var/lib/aurora-test/apr-irqpeek | tail -1)"

It finds every apple,prores node and its /dev/videoN by itself (ENGINES="/dev/video11 /dev/video12" overrides that). For each engine it runs one warm-up 1080p HQ job, then a before dump, then one job while sampling, then an after dump. The whole thing takes under a minute. Please attach the tgz, or paste run.log (it holds everything).

What it reads (nothing is written to any register):

  • Engine core: ID, MODE, IRQ_ENABLE, IRQ_STATUS, ST0/ST1, RING_SIZE/LO/HI/HEAD/TAIL.
  • Every wrapper offset the driver writes (the 62 T6041 wrapper rows), and the 4 aux offsets on apr0. This shows whether apr1 holds the rows, and whether IRQ_ENABLE reads back 0x3.
  • The DART: ERROR, ERROR_MASK, ERROR_ADDR_LO/HI, ERROR_STREAMS, PARAMS4.
  • The AIC lines of the engine and the DART (1960/1959 and 2010/2007): IRQ_CFG, MASK_SET (masked), HW_STATE (line asserted) and SW_SET. The AIC event register is never read, because reading it acknowledges an interrupt.
  • Kernel side: /sys/kernel/irq/<virq>/*, the /proc/interrupts row (the AIC hwirq column is 0x10000 + N, so 67546 for 2010), /sys/kernel/debug/irq/irqs/<virq> if GENERIC_IRQ_DEBUGFS is on, and the new prores/DART dmesg lines.
  • sample: during the job it polls the engine's IRQ_STATUS and the AIC HW_STATE bit together, about every 15 us for 1.5 s. On apr1 the status should stay set for up to one 4 ms poll, so we see directly whether the engine raises status while the AIC line stays low (wrapper/routing side) or the line goes high but nothing is delivered (AIC/mask/target side).

Why it is safe on a daily kernel: it is a small debugfs module (apr_irqpeek.ko). It reads MMIO only while the engine is already runtime-active (pm_runtime_get_if_active(); it never powers anything up). A suspended engine is reported as suspended and skipped. It uses plain ioremap() with no region claim, and it is rmmoded at the end. Loading it taints the kernel (E) until the next reboot.

Self-test (J616s, T6040, apr0 only, 7.3.0): rc 0, module unloaded, DART ERROR 0, no new dmesg lines, apr0 IRQ_ENABLE 0x3 and MODE 0xd, IRQ 1960 counted +1 per job. One run's sampler caught IRQ_STATUS 0x1 at the same moment as AIC hw_state 1 (unmasked); that is what a working line looks like. On a working engine that window is microseconds, so the sampler can miss it, but on apr1 it lasts milliseconds.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor

Capture from the J616c (M4 Max, binned T6041), run as given (KO/ENC prebuilt from the gist's sources). The boot was a 7.3.0 test kernel with the trial DTB (apr0 + apr1 as in this PR), and apple-prores built from 45ba8f9. rc 0, module unloaded, no new prores/DART dmesg lines, both DART ERROR 0.

apr1's engine raises its status, but the AIC line never goes high.

  • Sampler over one apr1 job: IRQ_STATUS 0x1 in 63 samples (~2 ms, until the 4 ms poll took it), AIC hw_state 0 in all 63, masked 0, IRQ_ENABLE 0x3, MODE 0xd. AIC hw_state=1 in 0 of 41347 samples.
  • apr0 for comparison: IRQ_STATUS 0x1 in 1 sample, at the same moment as AIC hw_state 1 (unmasked), which is the working-line picture from your self-test.
  • Both lines are mapped as expected: 1960 is virq 154 (sys_hwirq 67496), 2010 is virq 155 (sys_hwirq 67546), both AIC2 level with the codec's handler; IRQ_CFG 0 on both.

So the loss is between the engine and the AIC (the wrapper/routing side), not in the AIC mask or target.

apr0 vs apr1 'before' snapshots differ in these registers:

reg apr0 apr1
wrapper 0x018 / 0x01c / 0x034 / 0x038 0x001d0003 0x00000003
wrapper 0x03c 0x00000016 0x0000001d
wrapper 0x040 0x00000016 0x001d0003
wrapper 0x044 0x00000016 0x001d000c
wrapper 0x32c 0x8000003c 0x0000003c
wrapper 0x338 / 0x434 / 0x438 / 0x43c 0x000005a0 0
wrapper 0x344 / 0x448 0x01000005 0
wrapper 0x34c 0x00050020 0
wrapper 0x350 0x000a0030 0
wrapper 0x430 0x0000003c 0
wrapper 0x948 0x01400100 0
wrapper 0xa50 0x01000100 0
wrapper 0xc00 0x7fffffff 0x0000000f
aux 0x008 / 0x00c 0x1 / 0x7f7f0001 (no aux)
DART PARAMS4 0x00100010 0x00100001

Many of the T6041 wrapper rows read back 0 on apr1, and 0xc00 reads 0xf there against 0x7fffffff on apr0. Either the rows don't take on apr1's wrapper, or its wrapper is laid out differently (0x040/0x044 on apr1 hold the 0x001d00xx pattern that apr0 has at 0x018-0x038). If 0xc00 is the wrapper's interrupt forward mask, it would explain the line. I can run a test build that writes it on apr1 if you want that tried.

run.log
== apr-irqpeek 2026-11-20T13:21:57+00:00 7.3.0-j616c-ia33 Apple MacBook Pro (16-inch, M4 Max)
engines: /dev/video11 /dev/video12
  /dev/video11 -> /sys/devices/platform/301000000.video-codec name='apple-prores'
  /dev/video12 -> /sys/devices/platform/585000000.video-codec name='apple-prores'
AIC hwirqs of interest (engine + DART): 1959 1960 2007 2010 
---- irq state: start
aic 1959: virq 75 sys_hwirq 67495 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 75: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67495 Level apple-dart fault handler
aic 1960: virq 154 sys_hwirq 67496 chip=AIC2 type=level actions='301000000.video-codec' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 154: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67496 Level 301000000.video-codec
aic 2007: virq 102 sys_hwirq 67543 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 102: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67543 Level apple-dart fault handler
aic 2010: virq 155 sys_hwirq 67546 chip=AIC2 type=level actions='585000000.video-codec' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 155: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67546 Level 585000000.video-codec
== idle dump (engines usually suspended: AIC only)
apr_irqpeek dump t=51832331952 ns aic 0x0000000502400000 irq_cfg@0x10000 max_irq 4096
/video-codec@301000000 core 0x0000000301000000 wrapper 0x0000000300000000 aux 0x00000003010c0000 dart 0x0000000301020000
  aic engine  hwirq 1960: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 1959: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status suspended
  engine not active (0): MMIO skipped (run a job, read within 0.5 s)
/video-codec@585000000 core 0x0000000585000000 wrapper 0x0000000584000000 aux 0x0000000000000000 dart 0x0000000585020000
  aic engine  hwirq 2010: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 2007: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status suspended
  engine not active (0): MMIO skipped (run a job, read within 0.5 s)
======== /dev/video11
frames 1 errors 0 time 0.001 s fps 833.4 avg_bytes 947796
frames 1 errors 0 time 0.001 s fps 1079.9 avg_bytes 947796
-- before:
apr_irqpeek dump t=51842023953 ns aic 0x0000000502400000 irq_cfg@0x10000 max_irq 4096
/video-codec@301000000 core 0x0000000301000000 wrapper 0x0000000300000000 aux 0x00000003010c0000 dart 0x0000000301020000
  aic engine  hwirq 1960: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 1959: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status active
  core    0x0000 ID         = 0x00040008
  core    0x0008 MODE       = 0x0000000d
  core    0x000c IRQ_ENABLE = 0x00000003
  core    0x0010 IRQ_STATUS = 0x00000000
  core    0x0014 ST0        = 0x4004300e
  core    0x0018 ST1        = 0x00000000
  core    0x0100 RING_SIZE  = 0x00020000
  core    0x0104 RING_LO    = 0xfffe0000
  core    0x0108 RING_HI    = 0x000003ff
  core    0x010c RING_HEAD  = 0x00000180
  core    0x0110 RING_TAIL  = 0x00000180
  wrapper 0x0000            = 0x0000001d
  wrapper 0x0004            = 0x001d0003
  wrapper 0x0008            = 0x001d000c
  wrapper 0x000c            = 0x001d0003
  wrapper 0x0010            = 0x00000020
  wrapper 0x0014            = 0x00000020
  wrapper 0x0018            = 0x001d0003
  wrapper 0x001c            = 0x001d0003
  wrapper 0x0020            = 0x00000016
  wrapper 0x0024            = 0x0000001d
  wrapper 0x0028            = 0x001d0003
  wrapper 0x002c            = 0x001d0003
  wrapper 0x0030            = 0x00000020
  wrapper 0x0034            = 0x001d0003
  wrapper 0x0038            = 0x001d0003
  wrapper 0x003c            = 0x00000016
  wrapper 0x0040            = 0x00000016
  wrapper 0x0044            = 0x00000016
  wrapper 0x0100            = 0x000000ff
  wrapper 0x0108            = 0x00101330
  wrapper 0x0304            = 0x02020000
  wrapper 0x0308            = 0x00001681
  wrapper 0x030c            = 0x00001680
  wrapper 0x0310            = 0x000001e0
  wrapper 0x0314            = 0x800001e0
  wrapper 0x0318            = 0x000005a0
  wrapper 0x031c            = 0x800005a0
  wrapper 0x0320            = 0x000005a0
  wrapper 0x0324            = 0x800005a0
  wrapper 0x0328            = 0x0000003c
  wrapper 0x032c            = 0x8000003c
  wrapper 0x0330            = 0x000005a0
  wrapper 0x0334            = 0x000005a0
  wrapper 0x0338            = 0x000005a0
  wrapper 0x0344            = 0x01000005
  wrapper 0x034c            = 0x00050020
  wrapper 0x0350            = 0x000a0030
  wrapper 0x0408            = 0x00190031
  wrapper 0x040c            = 0x00001681
  wrapper 0x0410            = 0x00001680
  wrapper 0x0414            = 0x000001e0
  wrapper 0x0418            = 0x000001e0
  wrapper 0x041c            = 0x000005a0
  wrapper 0x0420            = 0x000005a0
  wrapper 0x0424            = 0x000005a0
  wrapper 0x0428            = 0x000005a0
  wrapper 0x042c            = 0x0000003c
  wrapper 0x0430            = 0x0000003c
  wrapper 0x0434            = 0x000005a0
  wrapper 0x0438            = 0x000005a0
  wrapper 0x043c            = 0x000005a0
  wrapper 0x0448            = 0x01000005
  wrapper 0x0748            = 0x00200000
  wrapper 0x0848            = 0x00100030
  wrapper 0x0948            = 0x01400100
  wrapper 0x0a50            = 0x01000100
  wrapper 0x0c00            = 0x7fffffff
  wrapper 0x4008            = 0x00000000
  wrapper 0x400c            = 0x00000001
  wrapper 0x4014            = 0x00000000
  wrapper 0x4018            = 0x00000000
  wrapper 0x401c            = 0x00000001
  aux     0x0008            = 0x00000001
  aux     0x000c            = 0x7f7f0001
  aux     0x07c4            = 0x00000000
  aux     0x07c8            = 0x00000000
  dart    0x000c PARAMS4       = 0x00100010
  dart    0x0100 ERROR         = 0x00000000
  dart    0x0104 ERROR_MASK    = 0x00000000
  dart    0x0170 ERROR_ADDR_LO = 0x00000000
  dart    0x0174 ERROR_ADDR_HI = 0x00000000
  dart    0x01c0 ERROR_STREAMS = 0x00000000
/video-codec@585000000 core 0x0000000585000000 wrapper 0x0000000584000000 aux 0x0000000000000000 dart 0x0000000585020000
  aic engine  hwirq 2010: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 2007: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status suspended
  engine not active (0): MMIO skipped (run a job, read within 0.5 s)
-- after:
apr_irqpeek dump t=52408248265 ns aic 0x0000000502400000 irq_cfg@0x10000 max_irq 4096
/video-codec@301000000 core 0x0000000301000000 wrapper 0x0000000300000000 aux 0x00000003010c0000 dart 0x0000000301020000
  aic engine  hwirq 1960: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 1959: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status active
  core    0x0000 ID         = 0x00040008
  core    0x0008 MODE       = 0x0000000d
  core    0x000c IRQ_ENABLE = 0x00000003
  core    0x0010 IRQ_STATUS = 0x00000000
  core    0x0014 ST0        = 0x4004300e
  core    0x0018 ST1        = 0x00000000
  core    0x0100 RING_SIZE  = 0x00020000
  core    0x0104 RING_LO    = 0xfffe0000
  core    0x0108 RING_HI    = 0x000003ff
  core    0x010c RING_HEAD  = 0x00000300
  core    0x0110 RING_TAIL  = 0x00000300
  wrapper 0x0000            = 0x0000001d
  wrapper 0x0004            = 0x001d0003
  wrapper 0x0008            = 0x001d000c
  wrapper 0x000c            = 0x001d0003
  wrapper 0x0010            = 0x00000020
  wrapper 0x0014            = 0x00000020
  wrapper 0x0018            = 0x001d0003
  wrapper 0x001c            = 0x001d0003
  wrapper 0x0020            = 0x00000016
  wrapper 0x0024            = 0x0000001d
  wrapper 0x0028            = 0x001d0003
  wrapper 0x002c            = 0x001d0003
  wrapper 0x0030            = 0x00000020
  wrapper 0x0034            = 0x001d0003
  wrapper 0x0038            = 0x001d0003
  wrapper 0x003c            = 0x00000016
  wrapper 0x0040            = 0x00000016
  wrapper 0x0044            = 0x00000016
  wrapper 0x0100            = 0x000000ff
  wrapper 0x0108            = 0x00101330
  wrapper 0x0304            = 0x02020000
  wrapper 0x0308            = 0x00001681
  wrapper 0x030c            = 0x00001680
  wrapper 0x0310            = 0x000001e0
  wrapper 0x0314            = 0x800001e0
  wrapper 0x0318            = 0x000005a0
  wrapper 0x031c            = 0x800005a0
  wrapper 0x0320            = 0x000005a0
  wrapper 0x0324            = 0x800005a0
  wrapper 0x0328            = 0x0000003c
  wrapper 0x032c            = 0x8000003c
  wrapper 0x0330            = 0x000005a0
  wrapper 0x0334            = 0x000005a0
  wrapper 0x0338            = 0x000005a0
  wrapper 0x0344            = 0x01000005
  wrapper 0x034c            = 0x00050020
  wrapper 0x0350            = 0x000a0030
  wrapper 0x0408            = 0x00190031
  wrapper 0x040c            = 0x00001681
  wrapper 0x0410            = 0x00001680
  wrapper 0x0414            = 0x000001e0
  wrapper 0x0418            = 0x000001e0
  wrapper 0x041c            = 0x000005a0
  wrapper 0x0420            = 0x000005a0
  wrapper 0x0424            = 0x000005a0
  wrapper 0x0428            = 0x000005a0
  wrapper 0x042c            = 0x0000003c
  wrapper 0x0430            = 0x0000003c
  wrapper 0x0434            = 0x000005a0
  wrapper 0x0438            = 0x000005a0
  wrapper 0x043c            = 0x000005a0
  wrapper 0x0448            = 0x01000005
  wrapper 0x0748            = 0x00200000
  wrapper 0x0848            = 0x00100030
  wrapper 0x0948            = 0x01400100
  wrapper 0x0a50            = 0x01000100
  wrapper 0x0c00            = 0x7fffffff
  wrapper 0x4008            = 0x00000000
  wrapper 0x400c            = 0x00000001
  wrapper 0x4014            = 0x00000000
  wrapper 0x4018            = 0x00000000
  wrapper 0x401c            = 0x00000001
  aux     0x0008            = 0x00000001
  aux     0x000c            = 0x7f7f0001
  aux     0x07c4            = 0x00000000
  aux     0x07c8            = 0x00000000
  dart    0x000c PARAMS4       = 0x00100010
  dart    0x0100 ERROR         = 0x00000000
  dart    0x0104 ERROR_MASK    = 0x00000000
  dart    0x0170 ERROR_ADDR_LO = 0x00000000
  dart    0x0174 ERROR_ADDR_HI = 0x00000000
  dart    0x01c0 ERROR_STREAMS = 0x00000000
/video-codec@585000000 core 0x0000000585000000 wrapper 0x0000000584000000 aux 0x0000000000000000 dart 0x0000000585020000
  aic engine  hwirq 2010: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 2007: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status suspended
  engine not active (0): MMIO skipped (run a job, read within 0.5 s)
-- sample:
apr_irqpeek sample 1500 ms
/video-codec@301000000 hwirq 1960: samples 41217 active 41217 tail_changes 1 last_tail 0x300
  IRQ_STATUS!=0 in 1 samples (with AIC hw_state=1: 1, with hw_state=0: 0); AIC hw_state=1 in 1 samples
  first status 0x1 at +53511 us: tail 0x300 IRQ_ENABLE 0x3 aic hw_state 1 masked 0
  first AIC hw_state=1 at +53511 us
/video-codec@585000000 hwirq 2010: samples 41217 active 0 tail_changes 0 last_tail 0x0
  IRQ_STATUS!=0 in 0 samples (with AIC hw_state=1: 0, with hw_state=0: 0); AIC hw_state=1 in 0 samples
-- irq before/after:
---- irq state: /dev/video11 before
aic 1959: virq 75 sys_hwirq 67495 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 75: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67495 Level apple-dart fault handler
aic 1960: virq 154 sys_hwirq 67496 chip=AIC2 type=level actions='301000000.video-codec' wakeup=disabled
  per_cpu_count=1,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 154: 1 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67496 Level 301000000.video-codec
aic 2007: virq 102 sys_hwirq 67543 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 102: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67543 Level apple-dart fault handler
aic 2010: virq 155 sys_hwirq 67546 chip=AIC2 type=level actions='585000000.video-codec' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 155: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67546 Level 585000000.video-codec
---- irq state: /dev/video11 after
aic 1959: virq 75 sys_hwirq 67495 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 75: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67495 Level apple-dart fault handler
aic 1960: virq 154 sys_hwirq 67496 chip=AIC2 type=level actions='301000000.video-codec' wakeup=disabled
  per_cpu_count=2,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 154: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67496 Level 301000000.video-codec
aic 2007: virq 102 sys_hwirq 67543 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 102: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67543 Level apple-dart fault handler
aic 2010: virq 155 sys_hwirq 67546 chip=AIC2 type=level actions='585000000.video-codec' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 155: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67546 Level 585000000.video-codec
======== /dev/video12
frames 1 errors 0 time 0.004 s fps 226.8 avg_bytes 947796
frames 1 errors 0 time 0.005 s fps 187.6 avg_bytes 947796
-- before:
apr_irqpeek dump t=53866200505 ns aic 0x0000000502400000 irq_cfg@0x10000 max_irq 4096
/video-codec@301000000 core 0x0000000301000000 wrapper 0x0000000300000000 aux 0x00000003010c0000 dart 0x0000000301020000
  aic engine  hwirq 1960: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 1959: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status suspended
  engine not active (0): MMIO skipped (run a job, read within 0.5 s)
/video-codec@585000000 core 0x0000000585000000 wrapper 0x0000000584000000 aux 0x0000000000000000 dart 0x0000000585020000
  aic engine  hwirq 2010: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 2007: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status active
  core    0x0000 ID         = 0x00040008
  core    0x0008 MODE       = 0x0000000d
  core    0x000c IRQ_ENABLE = 0x00000003
  core    0x0010 IRQ_STATUS = 0x00000000
  core    0x0014 ST0        = 0x4004300e
  core    0x0018 ST1        = 0x00000000
  core    0x0100 RING_SIZE  = 0x00020000
  core    0x0104 RING_LO    = 0xfffe0000
  core    0x0108 RING_HI    = 0x000003ff
  core    0x010c RING_HEAD  = 0x00000180
  core    0x0110 RING_TAIL  = 0x00000180
  wrapper 0x0000            = 0x0000001d
  wrapper 0x0004            = 0x001d0003
  wrapper 0x0008            = 0x001d000c
  wrapper 0x000c            = 0x001d0003
  wrapper 0x0010            = 0x00000020
  wrapper 0x0014            = 0x00000020
  wrapper 0x0018            = 0x00000003
  wrapper 0x001c            = 0x00000003
  wrapper 0x0020            = 0x00000016
  wrapper 0x0024            = 0x0000001d
  wrapper 0x0028            = 0x001d0003
  wrapper 0x002c            = 0x001d0003
  wrapper 0x0030            = 0x00000020
  wrapper 0x0034            = 0x00000003
  wrapper 0x0038            = 0x00000003
  wrapper 0x003c            = 0x0000001d
  wrapper 0x0040            = 0x001d0003
  wrapper 0x0044            = 0x001d000c
  wrapper 0x0100            = 0x000000ff
  wrapper 0x0108            = 0x00101330
  wrapper 0x0304            = 0x02020000
  wrapper 0x0308            = 0x00001681
  wrapper 0x030c            = 0x00001680
  wrapper 0x0310            = 0x000001e0
  wrapper 0x0314            = 0x800001e0
  wrapper 0x0318            = 0x000005a0
  wrapper 0x031c            = 0x800005a0
  wrapper 0x0320            = 0x000005a0
  wrapper 0x0324            = 0x800005a0
  wrapper 0x0328            = 0x0000003c
  wrapper 0x032c            = 0x0000003c
  wrapper 0x0330            = 0x000005a0
  wrapper 0x0334            = 0x000005a0
  wrapper 0x0338            = 0x00000000
  wrapper 0x0344            = 0x00000000
  wrapper 0x034c            = 0x00000000
  wrapper 0x0350            = 0x00000000
  wrapper 0x0408            = 0x00190031
  wrapper 0x040c            = 0x00001681
  wrapper 0x0410            = 0x00001680
  wrapper 0x0414            = 0x000001e0
  wrapper 0x0418            = 0x000001e0
  wrapper 0x041c            = 0x000005a0
  wrapper 0x0420            = 0x000005a0
  wrapper 0x0424            = 0x000005a0
  wrapper 0x0428            = 0x000005a0
  wrapper 0x042c            = 0x0000003c
  wrapper 0x0430            = 0x00000000
  wrapper 0x0434            = 0x00000000
  wrapper 0x0438            = 0x00000000
  wrapper 0x043c            = 0x00000000
  wrapper 0x0448            = 0x00000000
  wrapper 0x0748            = 0x00200000
  wrapper 0x0848            = 0x00100030
  wrapper 0x0948            = 0x00000000
  wrapper 0x0a50            = 0x00000000
  wrapper 0x0c00            = 0x0000000f
  wrapper 0x4008            = 0x00000000
  wrapper 0x400c            = 0x00000001
  wrapper 0x4014            = 0x00000000
  wrapper 0x4018            = 0x00000000
  wrapper 0x401c            = 0x00000001
  dart    0x000c PARAMS4       = 0x00100001
  dart    0x0100 ERROR         = 0x00000000
  dart    0x0104 ERROR_MASK    = 0x00000000
  dart    0x0170 ERROR_ADDR_LO = 0x00000000
  dart    0x0174 ERROR_ADDR_HI = 0x00000000
  dart    0x01c0 ERROR_STREAMS = 0x00000000
-- after:
apr_irqpeek dump t=54456983049 ns aic 0x0000000502400000 irq_cfg@0x10000 max_irq 4096
/video-codec@301000000 core 0x0000000301000000 wrapper 0x0000000300000000 aux 0x00000003010c0000 dart 0x0000000301020000
  aic engine  hwirq 1960: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 1959: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status suspended
  engine not active (0): MMIO skipped (run a job, read within 0.5 s)
/video-codec@585000000 core 0x0000000585000000 wrapper 0x0000000584000000 aux 0x0000000000000000 dart 0x0000000585020000
  aic engine  hwirq 2010: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  aic dart    hwirq 2007: IRQ_CFG 0x00000000 masked 0 hw_state 0 sw_set 0
  driver apple-prores runtime_status active
  core    0x0000 ID         = 0x00040008
  core    0x0008 MODE       = 0x0000000d
  core    0x000c IRQ_ENABLE = 0x00000003
  core    0x0010 IRQ_STATUS = 0x00000000
  core    0x0014 ST0        = 0x4004300e
  core    0x0018 ST1        = 0x00000000
  core    0x0100 RING_SIZE  = 0x00020000
  core    0x0104 RING_LO    = 0xfffe0000
  core    0x0108 RING_HI    = 0x000003ff
  core    0x010c RING_HEAD  = 0x00000300
  core    0x0110 RING_TAIL  = 0x00000300
  wrapper 0x0000            = 0x0000001d
  wrapper 0x0004            = 0x001d0003
  wrapper 0x0008            = 0x001d000c
  wrapper 0x000c            = 0x001d0003
  wrapper 0x0010            = 0x00000020
  wrapper 0x0014            = 0x00000020
  wrapper 0x0018            = 0x00000003
  wrapper 0x001c            = 0x00000003
  wrapper 0x0020            = 0x00000016
  wrapper 0x0024            = 0x0000001d
  wrapper 0x0028            = 0x001d0003
  wrapper 0x002c            = 0x001d0003
  wrapper 0x0030            = 0x00000020
  wrapper 0x0034            = 0x00000003
  wrapper 0x0038            = 0x00000003
  wrapper 0x003c            = 0x0000001d
  wrapper 0x0040            = 0x001d0003
  wrapper 0x0044            = 0x001d000c
  wrapper 0x0100            = 0x000000ff
  wrapper 0x0108            = 0x00101330
  wrapper 0x0304            = 0x02020000
  wrapper 0x0308            = 0x00001681
  wrapper 0x030c            = 0x00001680
  wrapper 0x0310            = 0x000001e0
  wrapper 0x0314            = 0x800001e0
  wrapper 0x0318            = 0x000005a0
  wrapper 0x031c            = 0x800005a0
  wrapper 0x0320            = 0x000005a0
  wrapper 0x0324            = 0x800005a0
  wrapper 0x0328            = 0x0000003c
  wrapper 0x032c            = 0x0000003c
  wrapper 0x0330            = 0x000005a0
  wrapper 0x0334            = 0x000005a0
  wrapper 0x0338            = 0x00000000
  wrapper 0x0344            = 0x00000000
  wrapper 0x034c            = 0x00000000
  wrapper 0x0350            = 0x00000000
  wrapper 0x0408            = 0x00190031
  wrapper 0x040c            = 0x00001681
  wrapper 0x0410            = 0x00001680
  wrapper 0x0414            = 0x000001e0
  wrapper 0x0418            = 0x000001e0
  wrapper 0x041c            = 0x000005a0
  wrapper 0x0420            = 0x000005a0
  wrapper 0x0424            = 0x000005a0
  wrapper 0x0428            = 0x000005a0
  wrapper 0x042c            = 0x0000003c
  wrapper 0x0430            = 0x00000000
  wrapper 0x0434            = 0x00000000
  wrapper 0x0438            = 0x00000000
  wrapper 0x043c            = 0x00000000
  wrapper 0x0448            = 0x00000000
  wrapper 0x0748            = 0x00200000
  wrapper 0x0848            = 0x00100030
  wrapper 0x0948            = 0x00000000
  wrapper 0x0a50            = 0x00000000
  wrapper 0x0c00            = 0x0000000f
  wrapper 0x4008            = 0x00000000
  wrapper 0x400c            = 0x00000001
  wrapper 0x4014            = 0x00000000
  wrapper 0x4018            = 0x00000000
  wrapper 0x401c            = 0x00000001
  dart    0x000c PARAMS4       = 0x00100001
  dart    0x0100 ERROR         = 0x00000000
  dart    0x0104 ERROR_MASK    = 0x00000000
  dart    0x0170 ERROR_ADDR_LO = 0x00000000
  dart    0x0174 ERROR_ADDR_HI = 0x00000000
  dart    0x01c0 ERROR_STREAMS = 0x00000000
-- sample:
apr_irqpeek sample 1500 ms
/video-codec@301000000 hwirq 1960: samples 41347 active 0 tail_changes 0 last_tail 0x0
  IRQ_STATUS!=0 in 0 samples (with AIC hw_state=1: 0, with hw_state=0: 0); AIC hw_state=1 in 0 samples
/video-codec@585000000 hwirq 2010: samples 41347 active 41347 tail_changes 1 last_tail 0x300
  IRQ_STATUS!=0 in 63 samples (with AIC hw_state=1: 0, with hw_state=0: 63); AIC hw_state=1 in 0 samples
  first status 0x1 at +55414 us: tail 0x300 IRQ_ENABLE 0x3 aic hw_state 0 masked 0
-- irq before/after:
---- irq state: /dev/video12 before
aic 1959: virq 75 sys_hwirq 67495 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 75: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67495 Level apple-dart fault handler
aic 1960: virq 154 sys_hwirq 67496 chip=AIC2 type=level actions='301000000.video-codec' wakeup=disabled
  per_cpu_count=2,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 154: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67496 Level 301000000.video-codec
aic 2007: virq 102 sys_hwirq 67543 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 102: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67543 Level apple-dart fault handler
aic 2010: virq 155 sys_hwirq 67546 chip=AIC2 type=level actions='585000000.video-codec' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 155: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67546 Level 585000000.video-codec
---- irq state: /dev/video12 after
aic 1959: virq 75 sys_hwirq 67495 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 75: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67495 Level apple-dart fault handler
aic 1960: virq 154 sys_hwirq 67496 chip=AIC2 type=level actions='301000000.video-codec' wakeup=disabled
  per_cpu_count=2,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 154: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67496 Level 301000000.video-codec
aic 2007: virq 102 sys_hwirq 67543 chip=AIC2 type=level actions='apple-dart fault handler' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 102: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67543 Level apple-dart fault handler
aic 2010: virq 155 sys_hwirq 67546 chip=AIC2 type=level actions='585000000.video-codec' wakeup=disabled
  per_cpu_count=0,0,0,0,0,0,0,0,0,0,0,0,0,0
  proc: 155: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 AIC2 67546 Level 585000000.video-codec
== new dmesg lines (prores/dart):
> [   53.662669] apple-prores 585000000.video-codec: completion found without an interrupt
== done: /var/lib/aurora-test/apr-irqpeek/20261120-132157  (tar it: tar czf apr-irqpeek.tgz -C /var/lib/aurora-test/apr-irqpeek 20261120-132157)

On a J616c (M4 Max) the second ProRes engine, apr1, finishes every job
and raises IRQ_STATUS 0x1 with IRQ_ENABLE 0x3, but its AIC line (2010)
never goes high: a read-only capture saw hw_state 0 in all 63 samples
while the status was set, where apr0 shows status and hw_state
together. Each apr1 job then waits for the watchdog's 4 ms poll, about
8 ms at HZ=250, so apr1 runs at 125 fps whatever the profile, against
1100-1600 fps on apr0.

The same capture shows that apr1's wrapper does not end up like apr0's
after the power-up rows: 0x338-0x350, 0x430-0x448, 0x948 and 0xa50 read
back 0, and 0xc00 reads 0xf instead of 0x7fffffff. Two changes:

- On an instance without an aux window (a wrapper outside the SCODEC
  block), apply the wrapper rows a second time, so a row that only
  takes once a later row (such as 0xc00) is set is written again. The
  values are unchanged, and apr0 and every other instance with an aux
  window get one pass as before.

- Once a job has finished without its interrupt, poll that engine's
  completion with a 100 us hrtimer from submission instead of leaving
  it to the jiffy-granular watchdog. The interrupt stays requested and
  wins when it arrives; the watchdog still handles timeouts.

Reported-by: AxxzyWasTaken <98161954+AxxzyWasTaken@users.noreply.github.com>
Link: #2509
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks for the capture. It settles where the loss is: apr1 sets IRQ_STATUS and the AIC line stays low. New head: 44cc1db (one commit on top of 45ba8f9, make W=1 clean, checkpatch --strict clean).

What it changes

  • On an instance without an aux window (apr1), the wrapper rows are applied a second time. Your readback shows the rows before 0xc00 (0x338-0x350, 0x430-0x448, 0x948, 0xa50) at 0 and 0xc00 at 0xf. If 0xc00 gates them, the second pass writes them again once it is set. apr0 and every instance with an aux window still get one pass.
  • If a job finishes without its interrupt, the engine is polled with a 100 us hrtimer from then on, instead of waiting for the 4 ms watchdog (8 ms at HZ=250). The interrupt stays requested and takes over when it fires. The watchdog still handles timeouts. So apr1 should get close to apr0's rate even if the line stays dead.

Test (same boot setup as before: trial DTB, apple-prores built out of tree from 44cc1db and loaded):

git clone https://gist.github.com/371045b52cbfe10aa9cbe7f85bf2b0c2.git apr1-row && cd apr1-row
sudo bash apr1-row.sh          # one encode per engine: 1080p HQ and 4444, 200 jobs each
sudo bash apr-irqpeek.sh       # optional: shows whether the apr1 wrapper rows now read back like apr0

apr1-row.sh prints, for each engine and profile, the fps, jobs, IRQs counted on the engine's line, IRQs per job, and any new prores/DART dmesg lines (log under /var/lib/aurora-test/apr1-row/). It only reads /proc/interrupts and dmesg. We ran it on a J616s (apr0, 400 jobs, 1.00 IRQ/job, 0 errors).

How to read it

  • apr1 at 1.00 IRQ/job with no completion found without an interrupt line: the second wrapper pass fixed the routing.
  • apr1 at 0 IRQs/job, the warning ending in polling every 100 us, and fps well above 125: the line is still dead, but the poll removes the throughput cap. The apr-irqpeek dump then tells us whether the wrapper rows took.
  • apr0 should be unchanged: 1.00 IRQ/job and the same fps as your last row.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor

Row for 44cc1db on the J616c. Setup as before: trial DTB with apr0 + apr1, module from this head built against my 7.3 kernel (W=1 clean), 1080p input, 8 frames per buffer set, 25 loops = 200 jobs per row.

engine profile fps IRQs / 200 jobs md5 (8 frames)
apr0 3 HQ, NV16 1618 200 903a7d9057aa
apr0 4 4444, NV24 1101 200 58a0c7f858da
apr1 3 HQ, NV16 543 (was 125) 0 903a7d9057aa
apr1 4 4444, NV24 347 (was 125) 0 58a0c7f858da

Output is still byte-identical between the engines. There were 0 DART faults, 0 errors and 0 timeouts. The driver logs completion found without an interrupt, polling every 100 us once.

The 100 us poll works: apr1 is 2.8-4.3x faster than at 45ba8f9. It is still 1.5-3x slower than apr0, which gets its interrupt.

The second pass of wrapper rows doesn't take. Your capture, run again after the change, shows apr1's wrapper exactly as before:

  • the same 20 offsets differ from apr0's;
  • 0x338-0x350, 0x430-0x448, 0x948 and 0xa50 read 0;
  • 0xc00 reads 0xf against 0x7fffffff;
  • 0x018-0x044 hold the shifted 0x001d00xx pattern.

AIC 2010 hw_state is 0 in every sample, unmasked; IRQ_ENABLE is 0x3.

So those rows aren't taking at all on apr1's wrapper, written once or twice. Either apr1's wrapper isn't the same block as apr0's, or it isn't clocked or powered when the rows are written. Its 0x040/0x044 values look like a different layout's defaults. A capture of what macOS leaves in apr1's wrapper would settle which. I can't get that from Linux; a macOS-side read of 0x584000000 + 0x000-0xc00 after an apr1 encode would.

…pass

The second pass of the wrapper rows on an instance without an aux window
(T6041's apr1) changed nothing on the J616c: apr1's wrapper still holds
the same 20 offsets apart from apr0's after the rows are written once or
twice (0x338-0x350, 0x430-0x448, 0x948 and 0xa50 at 0, 0xc00 at 0xf
against 0x7fffffff, and a shifted 0x001d00xx pattern at 0x018-0x044),
and its interrupt still never reaches the AIC. The 100 us completion
poll is what lifted apr1 from 125 fps to 543 (HQ) and 347 (4444) fps.

Drop the second pass and measure instead. Every row of the wrapper is
read back after it is written, and the first time an instance's
wrapper does not take its rows, the driver logs each such row with its
value before the write, the value written and the value read back,
followed by a count. If any row did not take, the rows are applied and
checked once more before the next job, after the engine has completed
one, and that count is logged too. This separates a block that ignores
the writes (the value before equals the value after), a block with a
different layout (the value changes, but not to the written one) and a
block that was not yet clocked at power-up (the rows take on the second
check). Bit 31 is left out of the comparison: the 0x000-0x044 rows are
written with it set and read it back as 0 on apr0 too.

The completion poll stays.

Reported-by: AxxzyWasTaken <98161954+AxxzyWasTaken@users.noreply.github.com>
Link: #2509
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

RyanTheTide commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the row. The poll works, the second pass doesn't, so the second pass is gone. New head: 39687ee (one commit on top of 44cc1db; W=1 and checkpatch clean). The 100 us poll stays either way.

What I checked first. apr1's windows in the DT match its ADT node: engine 0x585000000 and wrapper 0x584000000/16 MiB, with the same arm-io offset as apr0. Its clock gates (PRORES-V, PRORES-SOC-VNOM/VMAX) and its DART's gate (PRORES-DART) are all no-power-state children of PRORES (0x3a8), the domain the DT already uses. So no power domain is missing. apr1 also completes jobs with its DART working, and the rows are written in device_run right after the runtime resume, so "the domain was off when the rows were written" is unlikely. A separate clock is still possible. Both engines' bw_req_interrupt point at SCODEC (0x59), not PRORES. That may be nothing, but it is the one place apr1 refers back to the SCODEC side.

What 39687ee does. Instead of writing the rows again blindly, it reads every wrapper row back after writing it. The first time an engine's wrapper doesn't take its rows, it logs one line per row:
wrapper 0x0338: was 0x........, wrote 0x000005a0, reads 0x........
then N of 62 wrapper rows did not take at power-up. Before the engine's next job, after one job has completed, it writes and checks the rows once more and logs N of 62 wrapper rows did not take after a completed job. How to read it:

  • was equals reads: apr1's wrapper ignores the writes (locked, or the registers aren't there).
  • reads changed, but not to the value written: the registers exist with a different layout (the 0x040/0x044 values point that way).
  • The second count is 0: the block wasn't clocked at power-up, and the rows only need to go in later.

Bit 31 is left out of the comparison, because apr0 also reads it back as 0 at 0x000-0x044. apr0 should print nothing.

Test (same setup: trial DTB, apple-prores built out of tree from 39687ee and loaded):

cd apr1-row && git pull
sudo bash apr1-row.sh
sudo dmesg | grep -E 'wrapper|without an interrupt'

Please paste the dmesg lines and the fps/IRQ table. The fps should match your last row.

macOS read. Yes, that would settle it. If your J616c can do it, please read apr1's wrapper (0x584000000 + 0x000-0xc00, plus 0x4008-0x401c) under macOS right after an apr1 ProRes encode, and apr0's at 0x300000000 for comparison. This is a register read on your own machine, not a disassembly. Any read-only route you already have works: a pmap/iomem dump from a debug kext, or m1n1 with macOS running as a guest. Even the 20 offsets that differ would tell us whether macOS gets apr1's wrapper to apr0's values, or leaves it at what Linux reads now. If it leaves it, the interrupt route is elsewhere, and a hypervisor MMIO trace of macOS bringing up apr1 is the next step.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Replaced by #2661, stacked on the ProRes decode stack (#2620). The binding, SCODEC-window and DT commits are cherry-picked unchanged; the completion poll and the wrapper readback are re-ported to the stack's multi-job ring, since the single-job completion path they were written for is gone there.

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.

2 participants