Repository navigation
media: apple: scaler: stop the engine before handing back a failed job's buffers - #3204
Conversation
…b's buffers A job that fails with an error, for example a decompress error from lossless input the engine cannot decode, left the engine's interrupt line asserted. Writing ASC_IRQ_STATUS does not deassert it; only an engine reset does, and that reset waited for the next job. The handler then saw interrupts with no status and returned IRQ_NONE until the interrupt core disabled the line, so no later job could complete without reloading the driver and resetting the engine first. A job that timed out had its buffers handed back at once, while the engine might still be reading or writing them, and again the reset waited for the next job. Handle both before any buffer goes back: - The interrupt is threaded and one-shot, so the line stays masked while a failed job is handled. - A failed or timed-out job masks the engine interrupt and resets the engine, falling back to the PMGR reset as at power-up. The buffers go back once the engine is idle and no completion or error source is left set. asc_hw_init() now fails if a source stays set after the reset. - If no reset stops the engine, it is powered off before the buffers go back. - The watchdog disables the interrupt line while it resets the engine, so an interrupt handler already running finishes first. Add a host test that runs the production interrupt handler and watchdog against a modelled engine whose error holds the line until a reset: a decompress error with the engine idle and running, timeouts with the engine idle, running and stuck, a late error and a spurious interrupt. At the previous revision five of the eight cases fail. Signed-off-by: Dj <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
J773g (M4 Mac mini, T8132 scaler, MSR hardware-version 20) at How it was run: both modules were loaded in the same boot of one kernel, main
So after a timed-out job, main's module leaves the engine stuck for every later job until the module is reloaded. The candidate resets or powers off the engine, and the next jobs complete.
Kernel log over the module A/B:
Not yet: the P010 → XRGB32 timeout on the J773g with both modules. It looks like a separate issue, either the format on this scaler or the test's P010 case. Both modules were unloaded afterwards and the kernel's own module reloaded. Then the Mac went back to the stock kernel, and the binary and modules were removed from the Mac. |
|
Verdict at Blockers: none Checked:
Evidence
|
There was a problem hiding this comment.
Verdict: MERGE at 01086502 (once cancelled CI checks are rerun green)
Blockers: none (code, host tests, and J773g hardware row are ready; rerun the 15 cancelled CI checks before merge).
Checked:
drivers/media/platform/apple/scaler/apple-scaler-drv.c: verifieddevm_request_threaded_irq(..., NULL, asc_irq, IRQF_ONESHOT, ...)keeps the line masked untilasc_irq()finishes,spin_lock_irqsave(&asc->hw_lock, flags)matchesasc_device_run()/asc_watchdog(),asc_hw_init()rejects residualASC_IRQ_DONE | ASC_IRQ_ERRORSafter reset, andasc_abort()masks interrupts, tries engine + PMGR reset, and falls back topm_runtime_put_sync_suspend()(passingpowered_off = trueto avoid double runtime PM put) before handing buffers back.- Verified
asc_watchdog()wrapsasc_abort()withdisable_irq(asc->irq)/enable_irq(asc->irq)so no concurrent threaded IRQ races the reset. tools/asahi/apple-scaler-recovery-tests.py: verified 8/8 cases and negative control against prior revision.- Verified J773g (M4 mini) hardware row (CRCs match base, all-zero lossless errors recover cleanly, timed-out job no longer wedges engine, 0 DART faults).
Evidence
- Diff reviewed at
01086502(all 3 files, 581 lines). - CI at review time: 4 passed, 0 failed, 15 cancelled.
|
Merge-train status at |
|
Merge-train, point 4: the scaler driver runs on every family that has the block, and the J773g row covers one. Please add a row at this head on a second family (J616s or M1 Pro: scale jobs, plus the failed-job recovery path if it can be triggered, 0 IOMMU faults), then it merges. |
|
Row (J616s, M4 Pro) at exact head 0108650 in combined candidate cedaeff9ee2fe5396733351bb571d0a6049bd7fc on main aa76613: 8 apple-scaler v4l2 m2m conversions (NV12/NM12/P010/BA24/BX24, 160x120..3840x2160, 16 frames each) -> PASS (7/8 complete with output sha identical to production; NV12->BX24 640x480 job-times-out on production too and the engine takes the next job normally after it; 0 IOMMU/DART faults). Evidence: traces/kernel/20261129-closeout-j616s-combo/. Saved boot restored. |
|
code-owner ping @DjDeveloperr: closeout merge at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
The merge of aurora-silicon#3204 combined the recovery harness with preexisting rotation and V4L2 control fields in the scaler driver. Declare both types in the host harness so the extracted structures compile. The registered pre-fix control still fails its recovery assertions after compiling. Signed-off-by: Ryan Murray <[email protected]>
What: A failed scaler job (for example, lossless input the engine can't decode) left the engine's interrupt line asserted until the interrupt core disabled it, so no later job could complete until the driver was reloaded. A timed-out job handed its buffers back while the engine might still be using them. Both now stop the engine first: mask the interrupt, reset the engine, and hand the buffers back only once it is idle with no status left.
Tested: the module builds W=1-clean (clang, arm64). The new host test
apple-scaler-recovery-tests.pypasses its 8 cases; at the previous revision 5 of them fail, and that run is the registered negative control. J773g (M4 mini) at145ffb7639b5: conversion CRCs match base, three all-zero lossless inputs each come back as an error with the next valid conversion completing, and a timed-out job no longer wedges the engine. 0 DART faults, no interrupt disabled (row). J700 (Neo) at145ffb7639b5, with #3217, in the combined candidate 7.3.0-neo-combined1126, which carries it unchanged: conversions match base. Three all-zero lossless inputs each come back as an error, and the next valid conversion completes. 0 DART faults, no interrupt disabled, nothing times out.Risk: two-way · M1 and M4 families and the Neo, which have the direct-MMIO scaler. The interrupt is now threaded.
Not yet: nothing. The P010 to XRGB32 timeout seen on the M4 mini is fixed separately in #3217.
Details
NULLprimary handler,IRQF_ONESHOT), so the line stays masked while a failed job is handled.asc_abort()runs for an error interrupt and for a watchdog timeout:ASC_IRQ_ENABLEand resets the engine: the engine reset first, then the PMGR reset of its power domain, asasc_device_run()already did at power-up. Both now shareasc_reset_engine().pm_runtime_put_sync_suspend()) before the buffers go back.asc_hw_init()now fails if a completion or error source is still set after the reset and clear, since that source would hold the line.buf_prepare(). What changes is that a decompress error can no longer wedge the engine.Evidence
python3 tools/asahi/apple-scaler-recovery-tests.py: all 8 cases ok (done, decompress-error, decompress-error-running, timeout-idle, timeout, timeout-stuck, late-error, spurious).python3 tools/asahi/apple-scaler-recovery-tests.py --ref 40e5e29cc915a421fb2676f895ff7dcc3f47a224: decompress-error, decompress-error-running, timeout-idle, timeout and timeout-stuck fail. At that revision the buffers go back with the line still asserted or the engine still running.tools/asahi/run-host-tests.py --only scaler: 2/2.make M=drivers/media/platform/apple/scaler LLVM=1 W=1 modulesagainst a configured 7.3 tree, no warnings.