Repository navigation
media: apple: prores: bind T6041's second engine (apr1) on the multi-job ring - #2661
RyanTheTide wants to merge 6 commits into
Conversation
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> (cherry picked from commit f7419f1)
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> (cherry picked from commit 49aceef)
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> (cherry picked from commit 45ba8f9)
On a J616c (M4 Max) the second ProRes engine, apr1, finishes every job and raises IRQ_STATUS, but its AIC line never goes high. 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. Once the watchdog finds a finished job without its interrupt, mark the engine and poll its completions with a 100 us hrtimer while it has jobs in the ring. The poll and the interrupt handler share one service routine, so finished jobs are given back the same way whichever sees them first; the interrupt stays requested, and the watchdog still handles timeouts and resets. Every arm of the timer is an hrtimer_start() under hw_lock: on submission, from the watchdog, and from the service routine while jobs remain. This is linux#2509's completion poll ported to the multi-job ring. Reported-by: AxxzyWasTaken <98161954+AxxzyWasTaken@users.noreply.github.com> Link: #2509 Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
T6041's apr1 wrapper does not end up like apr0's after the power-up rows: 0x338-0x350, 0x430-0x448, 0x948 and 0xa50 stay 0, 0xc00 reads 0xf against 0x7fffffff, and 0x018-0x044 show a shifted 0x001d00xx pattern, whether the rows are written once or twice. Read every wrapper row back after it is written. The first time an instance's wrapper does not take its rows, log 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, apply and check the rows once more before the next job after the engine has completed one, while the ring is empty and the engine idle, and log that count too. This separates a block that ignores the writes, a block with a different layout and a block that was not yet clocked at power-up. 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. This is linux#2509's read-back ported to the multi-job ring. Reported-by: AxxzyWasTaken <98161954+AxxzyWasTaken@users.noreply.github.com> Link: #2509 Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
@AxxzyWasTaken, could you run your J616c row on this head (2a93a0d)? It's #2509 again, but the poll now sits on #2620's multi-job ring, so the numbers you got on 44cc1db don't carry over. What would settle it:
I'll post an M1 Pro decode no-regression row against #2620's hashes here. |
The completion poll started the first time the watchdog found a finished job that no interrupt had given back. On the multi-job ring that also happens on engines whose line works: on an M1 Pro (T6000) the watchdog finds a completion ahead of its interrupt on every module load, so the engine was switched to the 100 us poll for good. Remember whether the line has ever fired. Start the poll only for an engine whose jobs finish while its line has never fired, as apr1 on the M4 Max, and stop it as soon as an interrupt arrives. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
M1 Pro (T6000) no-regression row, fleet77, module swap: #2620's head (64b404a) vs this PR's 2a93a0d, one boot.
One thing it turned up, and the reason for the new commit 69a9475: on this Mac the watchdog finds a finished job before its interrupt on every module load (#2620 logs that too, as its one-time @AxxzyWasTaken: please row 69a9475 rather than 2a93a0d. On your J616c, apr1 should log |
|
M1 Pro (T6000) row on 69a9475, fleet77, module swap against #2620's head 64b404a, one boot:
So on a Mac whose interrupt works, this PR now behaves exactly like #2620. What's left is the J616c row on 69a9475. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial Pre-PR Checklist Review (head 69a947526a34)
Requesting changes for §2 production-readiness blockers and a suspend lifecycle gap.
Blockers
-
§2 Lab-only diagnostic code & boot-time
dev_warnflood underspin_lock_irqsave(drivers/media/platform/apple/prores/apple-prores-drv.c:1255-1316,:1889-1899):- Commit
2a93a0dfaddsapr_apply_check(),wrapper_checked, andwrapper_recheckexplicitly as a diagnostic probe ("This separates a block that ignores the writes, a block with a different layout and a block that was not yet clocked at power-up"). - On every J616c boot,
apr_hw_init()emits ~20+dev_warn()lines (one per mismatched row plus summary) while holdingspin_lock_irqsave(&apr->hw_lock, flags), andapr_device_run()rewrites all 62 wrapper registers on the next idle submission and logs an unconditionaldev_warn()("%u of %zu wrapper rows did not take after a completed job", even when0). - This is a lab-only diagnostic path left in production code (§2) and violates the §5 regression bar (0 new kernel errors/warnings on boot). Remove the diagnostic read-back / second-pass rewrite and
dev_warnflood from the driver.
- Commit
-
§2 Applying
apr0's SCODEC wrapper table toapr1+ magic100 ushrtimer poll (APR_FAST_POLL_US = 100):apr1sits outside SCODEC and visibly rejects or shifts a large subset ofapr_t6041_wrapper_tunables(which came from a J616sapr0trace), whileAPR_FAST_POLL_US = 100polls around an uninvestigated missing AIC interrupt (IRQ 2010).- Writing an incompatible SCODEC wrapper table onto a non-SCODEC wrapper block and masking an unresolved interrupt routing issue behind a magic 100 us timer fails §2 ("no magic delay or depth"). Please either identify
apr1's actual wrapper init / interrupt routing (or drop inapplicable SCODEC wrapper rows cleanly) and justify any unavoidable fallback without diagnostic mismatch writes.
-
Suspend lifecycle gap (
drivers/media/platform/apple/prores/apple-prores-drv.c:2681-2689):apr_suspend()waits for!atomic_read(&apr->outstanding)and callspm_runtime_force_suspend(dev), but never cancels&apr->poll(or&apr->watchdog). If the last job was retired byapr_watchdog()orapr_irq()whileapr->pollwas armed, the hrtimer remains queued across suspend. Cancel&apr->polland&apr->watchdoginapr_suspend()once the ring drains (matchingapr_cleanup()).
Other Checklist Notes (§1, §3, §4, §5, §6, CI)
- §1 / §3 / §4 / §6: Binding (
apple,prores.yaml), optional SCODEC window mapping (i >= 2inapr_probe()with zero-initializedregs[4]), andt6041.dtsinode placement under/(matchingt604x.dtsi) look structurally sound; all 6 commits have human identity +Signed-off-by:with no agent trailers, and the PR body hasAssisted-by:. - CI & §5: Stacked on unmerged
#2620(media/prores-decode-v4-20261121) with 0 CI checks run on this PR. After addressing the blockers above and running CI, a J616c (M4 Max) HW row on the live head (apr0+apr1encode & decode, hashes, suspend/resume, 0 SELinux denials, 0 failed units, 0 new kernel errors) is still required.
Assisted-by: LLM (Gemini 4 Neon)
|
Closing for now: apr1 needs its real interrupt routing and wrapper setup instead of a 100 us poll and the apr0 table; the binding and DT part can come back on its own. |
|
Reopened and kept as a draft; the comment above lists what it still needs before review. cc @niteria |
Replaces #2509, rebuilt on the ProRes decode stack (#2620, the base of this PR). #2509 was written for the single-job driver; the stack's multi-job ring changed the completion path, so its interrupt workaround is re-ported here rather than merged.
Problem
The M4 Max (T6041) has a second ProRes engine, apr1, that could never bind: its node has a core and a wrapper window but no SCODEC (aux) window, and the T6041 variant required all three. The T6041 device tree had no ProRes nodes at all. On a J616c, apr1 also finishes every job and sets IRQ_STATUS without its AIC line going high, so each job waits for the 4 ms watchdog (125 fps against 1100-1600 on apr0).
Change
apple,t6041-proresnode may have two reg entries (core, wrapper) or three (core, wrapper, aux). Other compatibles are unchanged. (clean pick of media: apple: prores: bind T6041's second engine (apr1) without an aux window #2509's f7419f1)reg-nameslists them. This keys on the hardware description, not on a compatible or an instance. (clean pick of 49aceef)apr_service(), shared by the IRQ and a 100 us hrtimer. When the watchdog finds finished jobs on an engine whose interrupt line has never fired, the timer polls that engine while jobs are in the ring, and an interrupt ends the poll. Every arm is anhrtimer_start()underhw_lock. On the ring the watchdog also finds a completion ahead of its interrupt on working lines (seen on the M1 Pro), so "no interrupt yet for this job" alone does not start the poll (69a9475).Testing
drivers/media/platform/apple/prores/: no warnings. checkpatch --strict clean on every commit.pmp-floor-tests --mutant class-twice) is a GCC 16-only false failure in code this PR doesn't touch; tools/asahi: pmp-floor-tests: keep the class-twice mutant building on GCC 16 #2658 fixes it.M1 Pro (J316s) row on 69a9475 done: v4 against 69a9475 gives identical output hashes, fps, MIXED/DRAIN/KILL/TWO/OOB results, 0 bad dmesg lines, and no poll message (#2661 (comment)).
Still to run
How the poll sits on the ring
apr_irq()now only callsapr_service(apr);apr_service()reads IRQ_STATUS, takes every finished job off the ring withapr_take_done(apr, done, &n), and gives them back outsidehw_lock, exactly as the IRQ path did before.irq_missingfor an engine with finished jobs whose line has never fired (irq_seen);apr_irq()setsirq_seenand clearsirq_missing. While it is set,apr_device_run()arms the 100 us timer for that engine, andapr_service()re-arms it whilenjobsis non-zero.apr_service()and the second one finds nothing.Commits: 32a7032, 55e8a22, 2d2dab3 =
git cherry-pick -xof #2509's f7419f1, 49aceef, 45ba8f9; 26222da and 2a93a0d are the two ports; 69a9475 limits the poll to a line that has never fired.Assisted-by: LLM (Claude:Opus 5.5)