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/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), 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