From b9e0d23a53290c7a8d254c5b7c5a2e3ca8370d1d Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:42:09 +1100 Subject: [PATCH 1/2] drm/apple: dcp-180hz: say when the exception mode probe runs out While a 1920x1080 at 180 Hz exception mode is pending on an H17P Type-C connection but not yet proven, get_modes calls dcp_180hz_retry(), which probes the connector again up to 8 times, 300 ms apart. After the 8th probe it stopped without a word, and the mode was simply not offered. Each input of the proof already has an event that probes again (the link rate and lane facts and the firmware announcement through dcp_180hz_notify(), the AV service through its publication, a new catalog through dcp_180hz_catalog_changed()), so the re-probe is a poll. It is kept until every order of arrival is shown to be covered by one of those events, tracked in https://github.com/aurora-silicon/linux/issues/2346. Name its bound and delay, and warn once when it runs out, with whether the current connection's link rate and lane facts are proven, so a missing 180 Hz mode can be told from a missing event. The count goes to DCP_180HZ_PROBE_RETRIES + 1 to mark the warning as given; a new connection or proof resets it as before. The host selftest checks the bound, the single warning and the reset. Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/dcp-180hz.c | 31 ++++++++++++++++--- .../selftests/drivers/gpu/apple-dcp/rate.py | 16 +++++++--- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-180hz.c b/drivers/gpu/drm/apple/dcp-180hz.c index 09bbc5bd20ad7..ab34c25453a77 100644 --- a/drivers/gpu/drm/apple/dcp-180hz.c +++ b/drivers/gpu/drm/apple/dcp-180hz.c @@ -282,10 +282,22 @@ static void dcp_180hz_retry_work(struct work_struct *work) schedule_work(&dcp->connector->hotplug_wq); } +/* + * Probes again while an exception mode waits for the rest of its proof. + * Each input already has an event that probes again (the link facts and + * the announcement through dcp_180hz_notify(), the AV service through its + * publication, a new catalog through dcp_180hz_catalog_changed()); this + * bounded re-probe is kept until every one of them is shown to cover all + * orders of arrival, and says so when it runs out; see + * https://github.com/aurora-silicon/linux/issues/2346 + */ +#define DCP_180HZ_PROBE_RETRIES 8 +#define DCP_180HZ_PROBE_DELAY_MS 300 + void dcp_180hz_retry(struct apple_dcp *dcp) { + bool retry = false, gave_up = false, rate = false, lanes = false; unsigned long flags; - bool retry = false; if (!dcp->rate_retry_initialized || READ_ONCE(dcp->quiescing)) return; @@ -294,13 +306,22 @@ void dcp_180hz_retry(struct apple_dcp *dcp) dcp->rate_proof.retry_generation = READ_ONCE(dcp->typec_generation); dcp->rate_proof.retries = 0; } - if (READ_ONCE(dcp->typec_cable_connected) && dcp->rate_proof.retries < 8) { - dcp->rate_proof.retries++; - retry = true; + if (READ_ONCE(dcp->typec_cable_connected) && + dcp->rate_proof.retries <= DCP_180HZ_PROBE_RETRIES) { + /* Past the last re-probe: said once, until the proof starts over. */ + gave_up = dcp->rate_proof.retries++ == DCP_180HZ_PROBE_RETRIES; + retry = !gave_up; + rate = dcp_180hz_fact_current(dcp, &dcp->rate_proof.rate); + lanes = dcp_180hz_fact_current(dcp, &dcp->rate_proof.lanes); } spin_unlock_irqrestore(&dcp->metadata.lock, flags); if (retry) - mod_delayed_work(system_freezable_wq, &dcp->rate_retry_wq, msecs_to_jiffies(300)); + mod_delayed_work(system_freezable_wq, &dcp->rate_retry_wq, + msecs_to_jiffies(DCP_180HZ_PROBE_DELAY_MS)); + else if (gave_up) + dev_warn(dcp->dev, "180 Hz exception mode still not offered after %u probes (link rate %s, lane count %s)\n", + DCP_180HZ_PROBE_RETRIES, rate ? "proven" : "missing", + lanes ? "proven" : "missing"); } static void dcp_180hz_cancel(void *data) diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py b/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py index 1df2c17f68a9a..2180a868c9aa7 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py @@ -1484,6 +1484,8 @@ def retry(root): source = (root / 'drivers/gpu/drm/apple/dcp-180hz.c').read_text() production = '\n'.join(block(source, marker) for marker in ( 'static void dcp_180hz_retry_work(', 'void dcp_180hz_retry(', 'static void dcp_180hz_cancel(')) + production = '\n'.join(line for line in source.splitlines() + if line.startswith('#define DCP_180HZ_PROBE_')) + '\n' + production prefix = r""" #include #include @@ -1506,14 +1508,17 @@ def retry(root): struct apple_dcp { bool hpd_mutex, typec_cable_connected, quiescing, rate_retry_initialized; struct { bool lock; } metadata; - struct { u64 retry_generation; unsigned retries; } rate_proof; + struct { u64 retry_generation; unsigned retries; struct { bool valid; } rate, lanes; } rate_proof; u64 typec_generation; struct apple_connector *connector; void *dev; struct delayed_work rate_retry_wq; }; static int system_freezable_wq; -static unsigned submissions, cancellations; +static unsigned submissions, cancellations, warnings; +static void dev_warn(void *dev, const char *fmt, ...) { (void)dev; (void)fmt; warnings++; } +static bool dcp_180hz_fact_current(struct apple_dcp *d, const void *f) +{ (void)d; return ((const bool *)f)[0]; } static void schedule_work(struct work_struct *w) { w->scheduled++; } static void mod_delayed_work(int q,struct delayed_work *w,unsigned delay) { (void)q; submissions++; w->pending=true; w->delay=delay; } @@ -1528,12 +1533,14 @@ def retry(root): dcp_180hz_retry(&d); assert(!submissions); d.rate_retry_initialized=true; for(unsigned i=0;i<100;i++) dcp_180hz_retry(&d); - assert(submissions==8 && d.rate_proof.retries==8 && d.rate_retry_wq.delay==300); + assert(submissions==8 && d.rate_proof.retries==9 && d.rate_retry_wq.delay==300); + assert(warnings==1); dcp_180hz_retry_work(&d.rate_retry_wq.work); assert(c.hotplug_wq.scheduled==1); d.typec_generation++; dcp_180hz_retry_work(&d.rate_retry_wq.work); assert(c.hotplug_wq.scheduled==1); d.typec_cable_connected=false; dcp_180hz_retry(&d); assert(submissions==8); d.typec_cable_connected=true; dcp_180hz_retry(&d); assert(submissions==9 && d.rate_proof.retries==1); + assert(warnings==1); d.quiescing=true; dcp_180hz_retry(&d); dcp_180hz_retry_work(&d.rate_retry_wq.work); assert(submissions==9 && c.hotplug_wq.scheduled==1); d.quiescing=false; c.dcp=NULL; dcp_180hz_retry_work(&d.rate_retry_wq.work); @@ -1541,7 +1548,8 @@ def retry(root): c.dcp=&d; dcp_180hz_retry_work(&d.rate_retry_wq.work); assert(c.hotplug_wq.scheduled==2); dcp_180hz_cancel(&d); assert(!d.rate_retry_initialized && !d.rate_retry_wq.pending && cancellations==1); dcp_180hz_retry(&d); assert(submissions==9); - puts("PASS: actual eight-retry bound, 300ms delay, stale-generation/disconnect/quiesce/ownership gates and cancellation"); + assert(warnings==1); + puts("PASS: actual eight-retry bound, one warning when it runs out, 300ms delay, stale-generation/disconnect/quiesce/ownership gates and cancellation"); } """ return prefix + production + controls From bdbdd613cfe5ca96d2a7c63f6993416d22894f37 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:42:22 +1100 Subject: [PATCH 2/2] drm/apple: dcp: say what the refused-idle retry of T8140 s2r rests on dcp_s2r_quiesce() retries a refused RTKit idle once, after polling the mailbox and a fixed 30 ms sleep, on the assumption that the firmware still had messages queued. Nothing shows that assumption: the one recorded refusal on a J700 (-62 after 1137 ms) was refused again and went down the undo path. Say so at the retry and point at https://github.com/aurora-silicon/linux/issues/2347, which tracks counting both outcomes and then either removing the retry or waiting on the condition the sleep stands for. No functional change. Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/dcp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 7cde46e009096..152d416a641b2 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -8225,7 +8225,12 @@ static int dcp_s2r_quiesce(struct apple_dcp *dcp, u32 *status) idle_sent = true; ret = apple_rtkit_idle_with(dcp->rtk, dcp_secure_port_idle, dcp); if (ret) { - /* Answer what it still has queued, its log counters among them, and ask again. */ + /* + * Answer what it still has queued, its log counters among them, and ask again. + * That queued messages are the cause is not shown: the one recorded refusal + * (-62 after 1137 ms on J700) was refused again. Kept until counted; see + * https://github.com/aurora-silicon/linux/issues/2347 + */ dev_warn(dcp->dev, "firmware refused idle after %lld ms: %d, control %#x status %#x: retrying once\n", ktime_ms_delta(ktime_get(), start), ret, readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL),