Repository navigation
drm/apple: process the start's hotplug reports instead of sleeping 100 ms - #2337
Conversation
…0 ms apple_drm_init_dcp() sleeps 100 ms once every display processor is ready, "to settle before a modeset". It came with commit 8d9bd61 ("drm: apple: Adjust startup sequence and timing for dptx"), which also slept 500 ms in dcp_start() so that a DPTX link could deliver its timing modes. A week later commit 1a9051d ("drm: apple: dptx: Wait for link config on connect") replaced that start-time sleep with a wait for the link configuration, which the connect at start still does. What can still be pending when the last processor reports ready is the hotplug work its firmware queued during the start: the connection state and modes the first modeset reads. Flush each connector's pending hotplug work instead. A report queued during the start is processed before the device registers, as the sleep intended, and nothing is waited for when there is none. A report that comes later reaches DRM as a hotplug event, as one after the 100 ms does today. The DRM device registers about 115 ms after the last "DCP booted" on the J616s, M1 Pro and M2, and the boot waits for that device in the initramfs, so all of the sleep was on the boot path. Signed-off-by: Ryan Murray <[email protected]>
|
Blockers: 1.
The rest checks out. Every connector the helper visits (:1496-1509) has The rows in the body cover this change only together with #1771 and #1812, and all of them had no external display. The one case where removing the sleep could change behaviour is a DP/HDMI link whose hotplug work is queued just after the last processor reports ready, and none of the rows exercised it. HW row: this head alone (no #1771/#1812) on the J616s with a USB-C/DP display attached at power-on, and on the M1 Pro with HDMI attached at power-on, 3 cold boots each. Pass: the external output lit at gdm with its native mode, the panel lit, no "not ready"/hotplug retry lines, 0 AVC, 0 failed units, no new kernel errors. Add the Neo (J700) boot the body lists as still to run. Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-check at 5b9abde (unchanged since the last review):
Assisted-by: LLM (Claude:Opus 5.5) |
RyanTheTide
left a comment
There was a problem hiding this comment.
Review at 5b9abde. Flushing each initialized connector's hotplug work before device registration removes the fixed sleep. The native T8132 connector is correctly skipped before the private connector cast. CI still needs the lifecycle fixture to model the new call and assert its ordering between pipeline bring-up and registration. The attach-at-boot checks should cover both HDMI and Type-C. The headless J413 timing row uses the three-patch stack and does not separate this change's contribution.
|
I reproduced the readiness host-test failure at The test-only patch adds the two stubs, removes the obsolete The attached-display cold boots on J616s and M1 Pro, and the Neo row, are still open. Test-only patchdiff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py
index e41e10447eb22..7839c318774df 100644
--- a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py
+++ b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py
@@ -1544,7 +1544,6 @@ typedef uint64_t u64;
#define DRM_MODE_CONNECTOR_HDMIA 11
#define DRM_MODE_CONNECTOR_eDP 14
#define DRM_MODE_CONNECTOR_USB 20
-#define msleep(x) ((void)(x))
#define component_compare_of 0
#define apple_dcp_id_tbl 0
static int dcp_comp_ops;
@@ -1595,7 +1594,17 @@ static struct device master = { .data = &priv };
static struct component_match matches;
static bool machine_supported, absent_external;
static unsigned int references, released, node_puts, probes[2], bind_attempts, disables;
+static unsigned int start_report_flushes;
static int preflight_error, external_probe_error, bind_result;
+static void apple_drm_flush_start_reports(struct drm_device *drm)
+{
+ assert(drm == &priv.drm);
+ start_report_flushes++;
+}
+/* The J700 readiness scenarios do not have a J713 panel. */
+#ifndef iomfb_is_m4
+static bool iomfb_is_m4(struct apple_dcp *dcp) { (void)dcp; return false; }
+#endif
static void try_bind(void);
static bool of_machine_is_compatible(const char *s)
{ assert(!strcmp(s,"apple,j700")); return machine_supported; }
@@ -1711,6 +1720,7 @@ static void initial(bool supported_firmware)
}
absent_external = false;
references = released = node_puts = bind_attempts = disables = 0;
+ start_report_flushes = 0;
preflight_error = external_probe_error = bind_result = 0;
}
static int match_providers(void)
@@ -1745,16 +1755,19 @@ int main(void)
assert(!dcp_h17p_external_ready(&nodes[1]) && references == 0);
try_bind();
assert(bind_attempts == 1 && bind_result == 0 && probes[0] == 1 && !probes[1]);
+ assert(start_report_flushes == 1);
/* Delayed external provider remains in the match; the master must wait. */
initial(true);
assert(match_providers() == 2 && matches.includes[1]);
try_bind();
assert(bind_attempts == 0 && !probes[0] && !probes[1]);
+ assert(start_report_flushes == 0);
/* Last provider is prepared, but driver core bound is still false here. */
assert(publish_provider(&devices[1], &dcps[1]) == 0);
assert(dcps[1].external_prepared && !devices[1].bound);
assert(bind_attempts == 1 && bind_result == 0 && probes[0] == 1 && probes[1] == 1);
+ assert(start_report_flushes == 1);
devices[1].bound = true;
/* Permanent preflight failure cannot silently drop a requested provider. */
@@ -1799,6 +1812,7 @@ int main(void)
dcps[1].external_prepared = true;
if (failure) start_error[0] = -EIO; else ready_error[0] = -ETIMEDOUT;
assert(apple_drm_init_dcp(&master) == -ENODEV);
+ assert(start_report_flushes == 0);
/* A processor that did not start is not waited for. */
assert(starts[0] == 1 && waits[0] == (int)!failure && waits[1] == 1);
}
@@ -1807,10 +1821,12 @@ int main(void)
dcps[1].external_prepared = true;
ready_error[1] = -ETIMEDOUT;
assert(apple_drm_init_dcp(&master) == 0);
+ assert(start_report_flushes == 1);
initial(true);
dcps[1].external_prepared = true;
start_error[1] = -EIO;
assert(apple_drm_init_dcp(&master) == 0 && waits[1] == 0);
+ assert(start_report_flushes == 1);
puts("PASS: automatic hardware/firmware matching, delayed/preflight-failed providers, synchronous publication, readiness rejection, boot framebuffer kept without the panel processor");
return 0;
} |
Stub the startup report flush in the readiness fixture and count its calls. Successful initialization flushes once, while failed or deferred initialization does not flush. Supply the panel predicate for this fixture and remove the obsolete sleep stub. The Apple DCP host suite passes all 88 cases. Signed-off-by: Ryan Murray <[email protected]>
|
The test-only change at The complete local Apple DCP host suite passed 88/88, including readiness, 35/35 lifecycle cases and the optional USB Kconfig checks. The earlier missing-flush and early-flush controls each failed readiness as expected. The attached-display cold boots on J616s and J316s, and the Neo boot row, remain open. |
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at c66f5a48379d5d014543a88fc635afc96e79e81a:
- §1 No model gating: Pass in code (applies across all Macs;
t8132_ext_connector()skip matchesapple_drm_quiesce_connectors()because T8132 external connectors are notapple_connectorinstances withhotplug_wq). Multi-Mac proof on J700 is still open (see §5). - §2 Production-ready, no hacks: Pass. Replaces
msleep(100)(apple_drv.c:1751onintegration/aurora, not superseded) withapple_drm_flush_start_reports(), flushing each connector'shotplug_wqsafely outsideconnector_list_lock(drm_connector_list_iteronly locks while advancing).lifecycle.pyatc66f5a48379dcleanly stubs and asserts flush counts on success/failure paths, and bothkunitandhost-testsCI checks are green. - §3 Safety: Pass.
- §4 Clean-room and attribution: Pass. Both commits (
5b9abded85e3,c66f5a48379d) carry human author/committer (Ryan Murray <[email protected]>) and humanSigned-off-by:only, zero AI trailers in commits; PR body includesAssisted-by:. - §6 Naming: Pass.
- §5 Evidence (BLOCKER): Code and host/KUnit CI are clean, but hardware evidence is still incomplete for removing a startup settle sleep on the display registration path:
- All existing rows (J616s, J413, J316s) tested
#2337only bundled with#1771and#1812, with no external display attached, and with the internal panel off (lab night settings, so visible GDM panel handover is unverified). - No attached-at-boot external display row exists yet — specifically cold boots on J616s with USB-C/DP attached at power-on and J316s (M1 Pro) with HDMI attached at power-on on this head alone (without
#1771/#1812), confirming external native mode + visible internal panel handover at GDM, no hotplug retry/not-ready errors, 0 AVC, 0 failed units, and 0 new kernel errors. - The J700 (Neo) boot row listed in
Still to runremains open.
- All existing rows (J616s, J413, J316s) tested
Please post those hardware rows (default command line, isolated to this head) so this can be approved.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at c66f5a48379d: the code is ready; it needs only a row at this head.
Blockers: none in the code. Missing row: the change is about the hotplug reports during start, and every row so far ran with no external display attached. Needed: one cold boot at this head with an external display attached at power-on (J616s over USB-C/DP or J316s over HDMI), with the external display in its native mode, the internal panel handed over at GDM, and no hotplug retry or not-ready errors. The J700 row and other Macs come after the merge.
Checked: no Apple material, no gates, and it removes a fixed msleep(100). apple_drm_flush_start_reports() flushes each connector's hotplug_wq outside connector_list_lock, and T8132 external connectors are skipped as in apple_drm_quiesce_connectors(). The J616s, J413 and J316s boots, which carried this commit unchanged alongside #1771/#1812, show no regression. kunit and host-tests are green, and lifecycle.py checks the flush counts. This replaces my earlier review.
Evidence
Read 5b9abded and c66f5a48 (apple_drv.c, lifecycle.py).
Superseded by the review at c66f5a4
|
|
Problem.
apple_drm_init_dcp()sleeps 100 ms after every display processor reports ready ("HACK: Wait for dcp* to settle before a modeset"). The boot waits in the initramfs for the appledrm device, so the whole sleep lands on the boot path, on every Mac. In our boot logs the DRM device registers 100-130 ms after the last "DCP booted" on all four lab machines.Change. Flush each connector's pending hotplug work instead of sleeping. The sleep came with 8d9bd61, in the same commit that slept 500 ms in
dcp_start()so that a DPTX link could deliver its timing modes. A week later 1a9051d replaced that start-time sleep with a wait for the link configuration, which the startup connect still does. What can still be pending when the last processor is ready is the hotplug work the firmware queued during the start: the connection state and the modes that the first modeset reads. That work is now processed before the device registers, and nothing is waited for when there is none. A report that comes later reaches DRM as a hotplug event, which is also what happens today with any report that arrives after the 100 ms.Testing. Builds on integration/aurora 0abc2f3 with the fleet config.
apple_drv.o,dcp.oanddpavservep.obuild with W=1 and no new warnings.Testing (J616s, hardware, together with #1771, #1812 and #2337). J616s (T6040), HDMI empty, no external display, production kernel 7.3.0-aurora-fleet75. Only the appledrm module changes: A is the production source rebuilt the same way, B is the same plus #1771, #1812 and #2337. Each arm boots a one-shot test initramfs entry; 5 boots each, alternating, kernel monotonic, median (min-max):
[drm] Initialized apple(s)All ten boots: SELinux enforcing, no failed units, no AVC denials, no kernel errors.
Testing (M2, hardware, together with #1771, #1812 and #2337). M2 (T8112, J413), no external display, production kernel 7.3.0-aurora-fleet74, same module-only A/B (A production source rebuilt, B plus the three changes), one-shot test initramfs entries, 3 boots each, alternating, median (min-max):
[drm] Initialized apple2.089 (2.082-2.095) -> 0.960 (0.943-0.980) s; last "DCP booted" to registration 0.126 -> 0.032 s; switch root 2.394 -> 1.734 s; gdm started 6.393 (6.369-6.415) -> 5.662 (5.661-5.736) s. All six boots: SELinux enforcing, no failed units, no AVC denials, no kernel errors.Testing (M1 Pro, hardware, together with #1771, #1812 and #2337). M1 Pro (T6000, J316s), no external display, production kernel 7.3.0-aurora-fleet74. Only the appledrm module changes: A is the production source rebuilt the same way, B is the same plus #1771, #1812 and #2337. Each arm boots a one-shot test initramfs entry; 3 boots each, alternating, kernel monotonic:
[drm] Initialized apple(s)gdm started at 5.42-5.53 s in all three B boots. All six boots: SELinux enforcing, no failed units, no AVC denials, no kernel errors. The rows measure the three changes together; the split per change is what the logs above predict (the 1 s EDID-service wait on each dcpext, the 100 ms sleep).
Still to run. The Neo row (3 + 3), and a boot with an external display attached at startup (the Neo's USB-C dock, or a USB-C display on the J616s) to check that it comes up as before. The panel was off during the rows above (lab night settings), so the check that gdm lights the panel at the handover is still owed by eye.
Evidence: the gap the sleep makes, per machine (current kernels, before this change)
Last "DCP booted" (or the HDMI processor's power-off right after it) to the DRM registration:
Registered planes/[drm] Initialized appleThe panel's modes are already there before its processor reports ready (for example J616s
dcp_hotplug() connected:1 ... nr_modes:6at 2.501 s, "DCP booted" at 2.503 s), so for the internal panel the sleep waited for nothing.Why the flush cannot deadlock
dcp_hotplug()takesmode_config.mutex,hpd_mutexand the connector's backlight work, none of which the bind path holds at this point. It ran concurrently with the old sleep, beforedrm_mode_config_reset()and registration, so the work does the same things in the same state; the only difference is that the bind now waits for it to finish. T8132 external outputs have no DCP hotplug work and are skipped, as inapple_drm_quiesce_connectors().