diff --git a/drivers/gpu/drm/apple/dcp-180hz.c b/drivers/gpu/drm/apple/dcp-180hz.c index 09bbc5bd20ad7..c12aca97a3f12 100644 --- a/drivers/gpu/drm/apple/dcp-180hz.c +++ b/drivers/gpu/drm/apple/dcp-180hz.c @@ -266,26 +266,49 @@ bool dcp_180hz_pending(struct apple_dcp *dcp, const struct dcp_display_mode *mod return raw && raw->extensions == 1 && dcp_180hz_edid((const u8 *)raw, 256, &mode->mode); } +/* + * 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. The budget counts the + * re-probes that ran: a request while one is pending only moves its timer. + * See + * https://github.com/aurora-silicon/linux/issues/2346 + */ +#define DCP_180HZ_PROBE_RETRIES 8 +#define DCP_180HZ_PROBE_DELAY_MS 300 + static void dcp_180hz_retry_work(struct work_struct *work) { struct apple_dcp *dcp = container_of(to_delayed_work(work), struct apple_dcp, rate_retry_wq); unsigned long flags; - bool current_generation; + bool owner; guard(mutex)(&dcp->hpd_mutex); + owner = dcp->connector && + READ_ONCE(dcp->connector->dcp) == to_platform_device(dcp->dev); + /* + * One section for the generation check, the re-probe and its count, so + * a proof that starts over in between is never charged for this timer. + * The budget counts re-probes this queued: none when the hotplug work + * was already pending, and none at all once it is spent. + */ spin_lock_irqsave(&dcp->metadata.lock, flags); - current_generation = dcp->typec_cable_connected && !dcp->quiescing && - dcp->rate_proof.retry_generation == dcp->typec_generation; + if (owner && dcp->typec_cable_connected && !dcp->quiescing && + dcp->rate_proof.retry_generation == dcp->typec_generation && + dcp->rate_proof.retries < DCP_180HZ_PROBE_RETRIES && + schedule_work(&dcp->connector->hotplug_wq)) + dcp->rate_proof.retries++; spin_unlock_irqrestore(&dcp->metadata.lock, flags); - if (current_generation && dcp->connector && - READ_ONCE(dcp->connector->dcp) == to_platform_device(dcp->dev)) - schedule_work(&dcp->connector->hotplug_wq); } + 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 +317,27 @@ 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) { + /* + * Every re-probe of the budget ran and the mode is still not + * offered: said once, until the proof starts over. + */ + gave_up = dcp->rate_proof.retries == DCP_180HZ_PROBE_RETRIES; + if (gave_up) + dcp->rate_proof.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 6abd5cc9fda60..edb036401d129 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -9927,7 +9927,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/drivers/gpu/drm/apple/dcp_backlight.c b/drivers/gpu/drm/apple/dcp_backlight.c index 5746c318e54cd..b10ebd990dc31 100644 --- a/drivers/gpu/drm/apple/dcp_backlight.c +++ b/drivers/gpu/drm/apple/dcp_backlight.c @@ -588,13 +588,30 @@ int dcp_backlight_wake_lit(struct apple_dcp *dcp) return ret; } +/* + * Called with the lock held; warns once when a refused level gets no more + * deferred presents. + */ +static unsigned int dcp_backlight_retry_delay_locked(struct apple_dcp *dcp) +{ + struct dcp_backlight_state *state = &dcp->backlight.state; + + lockdep_assert_held(&dcp->backlight.lock); + if (dcp_bl_retry_exhausted_report(state)) + dev_warn_ratelimited(dcp->dev, + "backlight: %u nits refused %u times, %u presents refused in total; waiting for the next present\n", + dcp_bl_effective(state), DCP_BL_RETRY_MAX + 1, + state->refused); + return dcp_bl_retry_delay(state); +} + unsigned int dcp_backlight_retry_delay(struct apple_dcp *dcp) { unsigned long flags; unsigned int delay; spin_lock_irqsave(&dcp->backlight.lock, flags); - delay = dcp_bl_retry_delay(&dcp->backlight.state); + delay = dcp_backlight_retry_delay_locked(dcp); spin_unlock_irqrestore(&dcp->backlight.lock, flags); return delay; } @@ -662,7 +679,7 @@ void dcp_backlight_desktop_finish(struct apple_dcp *dcp, u32 id, finished = dcp_bl_swap_finish(&dcp->backlight.state, &dcp->desktop->backlight, id, reply, accepted); changed = previous != dcp_bl_actual(&dcp->backlight.state); - delay = dcp_bl_retry_delay(&dcp->backlight.state); + delay = finished ? dcp_backlight_retry_delay_locked(dcp) : 0; pending = dcp->backlight.state.dirty; spin_unlock_irqrestore(&dcp->backlight.lock, flags); if (changed) diff --git a/drivers/gpu/drm/apple/dcp_backlight.h b/drivers/gpu/drm/apple/dcp_backlight.h index bb200ace90258..1daa23ff52eb5 100644 --- a/drivers/gpu/drm/apple/dcp_backlight.h +++ b/drivers/gpu/drm/apple/dcp_backlight.h @@ -25,7 +25,12 @@ struct dcp_backlight_state { /* Firmware observations confirm output; they never become user requests. */ u32 reported; u64 sequence; + /* Deferred presents of the current request after a refusal. */ u8 retries; + /* Presents carrying a level that the firmware refused, in total. */ + u32 refused; + /* The refusal that used up the deferred presents is not reported yet. */ + bool retry_report; bool ready; bool controlled; /* An unchanged registration default cannot take over an unknown level. */ @@ -53,6 +58,23 @@ struct dcp_backlight_present { u32 nits; }; +/* + * The level rides on a present; there is no separate brightness write. It + * is taken once the firmware has accepted the swap and completed it, and + * dcp_bl_complete() is called on exactly those events. A present can still + * be refused: swap_submit answers a non-zero status, or the swap watchdog + * retires a present the firmware never completed. Both are logged where + * they happen. The firmware gives no reason for a refusal and sends nothing + * that says when a present would be taken, so on a static display (no other + * present coming) the refused level is presented again after + * DCP_BL_RETRY_BASE_MS ms, doubling each time, at most DCP_BL_RETRY_MAX + * times per request. After that it stays pending for the next present or + * request, and dcp_backlight_retry_delay() warns once. The cause of refusals + * is not known yet: https://github.com/aurora-silicon/linux/issues/2332 + */ +#define DCP_BL_RETRY_MAX 3U +#define DCP_BL_RETRY_BASE_MS 100U + /* * Public powerlog reports use millinits. A report slightly above the panel * ceiling describes the brightest level the panel can show, so clamp it; one @@ -303,8 +325,11 @@ static inline bool dcp_bl_complete(struct dcp_backlight_state *state, state->level_known = true; } else { state->dirty = true; - if (state->retries < 4) + state->refused++; + if (state->retries <= DCP_BL_RETRY_MAX) { state->retries++; + state->retry_report = state->retries > DCP_BL_RETRY_MAX; + } } return true; } @@ -316,13 +341,32 @@ static inline int dcp_bl_reported_actual(const struct dcp_backlight_state *state return state->actual; } -/* Three deferred retries per user request; a permanent rejection stays dirty. */ +/* A refused level that has used up its deferred presents. */ +static inline bool dcp_bl_retry_exhausted(const struct dcp_backlight_state *state) +{ + return state->ready && state->dirty && !state->in_flight && + state->retries > DCP_BL_RETRY_MAX; +} + +/* + * True once for each exhausted budget, for the refusal that used it up. + * Later refusals of the same request are counted but not reported again. + */ +static inline bool dcp_bl_retry_exhausted_report(struct dcp_backlight_state *state) +{ + if (!state->retry_report || !dcp_bl_retry_exhausted(state)) + return false; + state->retry_report = false; + return true; +} + +/* Delay before the next deferred present of a refused level, 0 for none. */ static inline unsigned int dcp_bl_retry_delay(const struct dcp_backlight_state *state) { if (!state->ready || !state->dirty || state->in_flight || - !state->retries || state->retries > 3) + !state->retries || state->retries > DCP_BL_RETRY_MAX) return 0; - return 100U << (state->retries - 1); + return DCP_BL_RETRY_BASE_MS << (state->retries - 1); } /* A desktop present can complete before its submit reply arrives. */ diff --git a/drivers/gpu/drm/apple/iomfb.c b/drivers/gpu/drm/apple/iomfb.c index cfb3f4f984724..3c852a47743cc 100644 --- a/drivers/gpu/drm/apple/iomfb.c +++ b/drivers/gpu/drm/apple/iomfb.c @@ -484,9 +484,6 @@ static void iomfb_queue_advance(struct apple_dcp *dcp) if (delay) mod_delayed_work(system_dfl_wq, &dcp->iomfb.backlight_retry, msecs_to_jiffies(delay)); - else - dev_warn_ratelimited(dcp->dev, - "backlight retry limit reached\n"); } } transaction->release(transaction); diff --git a/tools/testing/apple/check-backlight-retry.py b/tools/testing/apple/check-backlight-retry.py index 32d1fc40580f2..5a2e3752619a5 100644 --- a/tools/testing/apple/check-backlight-retry.py +++ b/tools/testing/apple/check-backlight-retry.py @@ -39,6 +39,7 @@ def function(file, name): functions = '\n'.join(function(f, n) for f, n in ( ('dcp_backlight.c', 'dcp_backlight_complete'), ('dcp_backlight.c', 'dcp_backlight_pending'), + ('dcp_backlight.c', 'dcp_backlight_retry_delay_locked'), ('dcp_backlight.c', 'dcp_backlight_retry_delay'), ('iomfb.c', 'iomfb_present_failed_h17p'), ('iomfb.c', 'iomfb_present_complete_h17p'), @@ -55,6 +56,10 @@ def function(file, name): #include typedef uint8_t u8;typedef uint32_t u32;typedef uint64_t u64; #define READ_ONCE(x) (x) +#define min(a,b) ((a)<(b)?(a):(b)) +#define max(a,b) ((a)>(b)?(a):(b)) +static inline u64 div_u64(u64 n,u32 d) {return n/d;} +static inline u64 mul_u32_u32(u32 a,u32 b) {return (u64)a*b;} #define WRITE_ONCE(x,v) ((x)=(v)) #define lockdep_assert_held(x) ((void)(x)) #define spin_lock_irqsave(x,f) do { (void)(x);(f)=0; } while(0) @@ -64,6 +69,11 @@ def function(file, name): #define msecs_to_jiffies(x) (x) #define IOMFB_OPAQUE_X_WAITING 0 #define IOMFB_OPAQUE_X_NEEDED 1 +#define DCP_FIRMWARE_V_27_0 27 +#define list_for_each_entry_safe(p,n,h,m) for((void)(n),(p)=NULL;(p)&&(h)->empty;) +#define list_del(x) ((void)(x)) +struct iomfb_scanout_h17p {int link;}; +static void iomfb_scanout_release_h17p(struct iomfb_scanout_h17p *s) {(void)s;} struct work_struct {int id;};struct delayed_work {struct work_struct work;}; struct list_head {int empty;}; struct iomfb_transaction { @@ -72,16 +82,16 @@ def function(file, name): void (*release)(struct iomfb_transaction *); }; struct apple_dcp { - bool crashed;void *dev;struct work_struct bl_update_wq,vblank_wq; + bool crashed,ext26_control_pending;int fw_compat;void *dev;struct work_struct bl_update_wq,vblank_wq; struct {int lock;struct dcp_backlight_state state;} backlight; struct {bool pending;} present_state_h17p; struct {int lock;bool stopped,backlight_queued;struct iomfb_transaction *active; struct delayed_work timeout,backlight_retry;struct work_struct work; - struct list_head pending;int opaque_x_state; + struct list_head pending,dropped;int opaque_x_state,callback_count; } iomfb; }; -static unsigned delay,scheduled,released,discarded;static bool idle=true; -static void *system_wq; +static unsigned delay,scheduled,released,discarded,warned;static bool idle=true; +static void *system_dfl_wq; static bool iomfb_channels_idle(struct apple_dcp *d) {(void)d;return idle;} static int iomfb_enqueue_opaque_x(struct apple_dcp *d) {(void)d;return 0;} static void iomfb_discard_pending(struct apple_dcp *d) {(void)d;discarded++;} @@ -91,7 +101,7 @@ def function(file, name): static void mod_delayed_work(void *q,struct delayed_work *w,unsigned ms) { (void)q;assert(w->work.id==2);delay=ms; } -static void dev_warn_ratelimited(void *d,const char *msg) {(void)d;(void)msg;} +#define dev_warn_ratelimited(d,...) do { (void)(d);warned++; } while(0) static void iomfb_scanout_complete_h17p(struct apple_dcp *d) {(void)d;} static void atomic_cmpxchg(int *p,int old,int value) {if(*p==old)*p=value;} static void release(struct iomfb_transaction *t) {(void)t;released++;} @@ -106,7 +116,7 @@ def function(file, name): d->iomfb.pending.empty=1;assert(!dcp_bl_init(&d->backlight.state,509,true,inherited,false,0)); assert(dcp_bl_seed(&d->backlight.state,36));assert(!dcp_bl_dpms(&d->backlight.state,true)); assert(!dcp_bl_request(&d->backlight.state,140,false,false)); - delay=scheduled=released=discarded=0;idle=true; + delay=scheduled=released=discarded=warned=0;idle=true; } static void reserve(struct apple_dcp *d,struct iomfb_transaction *t) { memset(t,0,sizeof(*t));t->brightness_only=true;t->release=release; @@ -129,11 +139,20 @@ def function(file, name): init(&d); for(unsigned i=0;i<4;i++) { reserve(&d,&t);delay=0;reject(&d);assert(delay==(i<3?(100U< @@ -926,15 +927,18 @@ def brightness_notifications(root): #define KOBJ_CHANGE 1 #define system_dfl_wq NULL #define msecs_to_jiffies(x) (x) +#define lockdep_assert_held(p) assert(*(p)) +static unsigned warned; +#define dev_warn_ratelimited(dev,...) do {(void)(dev);warned++;} while(0) struct work_struct {int unused;}; struct backlight_device {struct {int kobj;} dev;struct {u32 brightness;} props;}; struct apple_dcp { - int fw_compat;bool quiescing,crashed; + int fw_compat;bool quiescing,crashed;void *dev; struct {struct backlight_device *bl_dev;int fade_work;} brightness; struct {bool lock;struct dcp_backlight_state state;struct work_struct notify_work;int fade_work,retry_work;} backlight; struct {struct dcp_backlight_swap backlight;} *desktop; }; -static unsigned events,brightness,actual,kicks,cancelled,delayed_cancelled; +static unsigned events,brightness,actual,kicks,cancelled,delayed_cancelled,scheduled,retry_delay; static void cancel_delayed_work_sync(int *work) {(void)work;delayed_cancelled++;} static void cancel_work_sync(struct work_struct *w) {(void)w;cancelled++;} static void kobject_uevent_env(int *k,int action,char **env) @@ -944,7 +948,7 @@ def brightness_notifications(root): static void dcp_backlight_notify_work(struct work_struct *); static void schedule_work(struct work_struct *w) {dcp_backlight_notify_work(w);} static void dcp_backlight_kick(struct apple_dcp *d) {assert(!d->backlight.lock);kicks++;} -static void mod_delayed_work(void *q,int *w,unsigned delay) {(void)q;(void)w;assert(delay);} +static void mod_delayed_work(void *q,int *w,unsigned delay) {(void)q;(void)w;assert(delay);retry_delay=delay;scheduled++;} '''+functions+r''' int main(void) { @@ -964,6 +968,25 @@ def brightness_notifications(root): assert(!dcp_bl_request(&d.backlight.state,250,false,false)); assert(!dcp_bl_swap_prepare(&d.backlight.state,&desktop.backlight,9,true)); dcp_backlight_desktop_finish(&d,9,true,false);assert(events==1); + /* A refused present is presented again after the base delay, without a warning. */ + assert(scheduled==1 && retry_delay==DCP_BL_RETRY_BASE_MS && !warned && !kicks); + /* Each refusal doubles the delay. The one that ends the budget warns; later ones do not. */ + for(unsigned n=1;n<=DCP_BL_RETRY_MAX+2;n++) { + assert(!dcp_bl_swap_prepare(&d.backlight.state,&desktop.backlight,9+n,true)); + retry_delay=0;dcp_backlight_desktop_finish(&d,9+n,true,false); + assert(retry_delay==(n=DCP_BL_RETRY_MAX)); + } + assert(scheduled==DCP_BL_RETRY_MAX && d.backlight.state.refused==DCP_BL_RETRY_MAX+3); + assert(events==1 && !kicks && d.backlight.state.dirty); + /* A new request has its own budget and its own warning. */ + assert(!dcp_bl_request(&d.backlight.state,300,false,false)); + for(unsigned n=0;n<=DCP_BL_RETRY_MAX;n++) { + assert(warned==1); + assert(!dcp_bl_swap_prepare(&d.backlight.state,&desktop.backlight,20+n,true)); + dcp_backlight_desktop_finish(&d,20+n,true,false); + } + assert(warned==2 && scheduled==2*DCP_BL_RETRY_MAX && events==1); d.quiescing=true;dcp_backlight_notify(&d);assert(events==1); d.quiescing=false;d.fw_compat=1;dcp_backlight_notify(&d);assert(events==1); dcp_backlight_stop(&d);assert(!cancelled && delayed_cancelled==3); diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py b/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py index 30eba776e8eee..503c85aecff32 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/rate.py @@ -1597,6 +1597,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 @@ -1613,48 +1615,78 @@ def retry(root): #define to_delayed_work(p) container_of(p,struct delayed_work,work) #define to_platform_device(p) (p) #define msecs_to_jiffies(x) (x) -struct work_struct { unsigned scheduled; }; +struct work_struct { unsigned scheduled; bool pending; }; struct delayed_work { struct work_struct work; unsigned delay; bool pending; }; struct apple_connector { void *dcp; struct work_struct hotplug_wq; }; 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 void schedule_work(struct work_struct *w) { w->scheduled++; } +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 struct apple_dcp *locked_dcp; +static bool schedule_work(struct work_struct *w) +{ if (locked_dcp) assert(locked_dcp->metadata.lock); if (w->pending) return false; w->pending=true; w->scheduled++; return true; } static void mod_delayed_work(int q,struct delayed_work *w,unsigned delay) { (void)q; submissions++; w->pending=true; w->delay=delay; } static void cancel_delayed_work_sync(struct delayed_work *w) { cancellations++; w->pending=false; } """ controls = r""" +static void hotplug_ran(struct apple_connector *c) { c->hotplug_wq.pending=false; } int main(void) { struct apple_dcp d={.typec_cable_connected=true,.typec_generation=7}; - struct apple_connector c={.dcp=&d}; d.connector=&c; d.dev=&d; + struct apple_connector c={.dcp=&d}; d.connector=&c; d.dev=&d; locked_dcp=&d; dcp_180hz_retry(&d); assert(!submissions); d.rate_retry_initialized=true; + /* Requests before the first timer fires only move it: no probe ran, nothing is spent. */ 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); - dcp_180hz_retry_work(&d.rate_retry_wq.work); assert(c.hotplug_wq.scheduled==1); + assert(submissions==100 && d.rate_proof.retries==0 && d.rate_retry_wq.delay==300 && !warnings); + /* The hotplug work is still pending: the timer queues nothing and is not charged. */ + c.hotplug_wq.pending=true; + dcp_180hz_retry_work(&d.rate_retry_wq.work); + assert(c.hotplug_wq.scheduled==0 && d.rate_proof.retries==0); + hotplug_ran(&c); + /* Each re-probe the timer queues spends one; the request after the eighth says so, once. */ + for(unsigned i=1;i<=8;i++) { + dcp_180hz_retry_work(&d.rate_retry_wq.work); + assert(c.hotplug_wq.scheduled==i && d.rate_proof.retries==i); + hotplug_ran(&c); + dcp_180hz_retry(&d); + } + assert(submissions==107 && d.rate_proof.retries==9 && warnings==1); + for(unsigned i=0;i<10;i++) dcp_180hz_retry(&d); + assert(submissions==107 && warnings==1); + /* A timer still pending once the budget is spent queues nothing more. */ + dcp_180hz_retry_work(&d.rate_retry_wq.work); assert(c.hotplug_wq.scheduled==8 && d.rate_proof.retries==9); + hotplug_ran(&c); + /* A timer of the old generation neither probes nor charges the new proof. */ + d.typec_generation++; dcp_180hz_retry_work(&d.rate_retry_wq.work); + assert(c.hotplug_wq.scheduled==8 && d.rate_proof.retries==9); + d.typec_cable_connected=false; dcp_180hz_retry(&d); assert(submissions==107); + d.typec_cable_connected=true; dcp_180hz_retry(&d); assert(submissions==108 && d.rate_proof.retries==0); 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(c.hotplug_wq.scheduled==8 && d.rate_proof.retries==0); + dcp_180hz_retry(&d); assert(submissions==109 && d.rate_proof.retries==0); + 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); + assert(submissions==109 && c.hotplug_wq.scheduled==8 && d.rate_proof.retries==0); d.quiescing=false; c.dcp=NULL; dcp_180hz_retry_work(&d.rate_retry_wq.work); - assert(c.hotplug_wq.scheduled==1); - c.dcp=&d; dcp_180hz_retry_work(&d.rate_retry_wq.work); assert(c.hotplug_wq.scheduled==2); + assert(c.hotplug_wq.scheduled==8 && d.rate_proof.retries==0); + c.dcp=&d; dcp_180hz_retry_work(&d.rate_retry_wq.work); assert(c.hotplug_wq.scheduled==9 && d.rate_proof.retries==1); 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"); + dcp_180hz_retry(&d); assert(submissions==109); + assert(warnings==1); + puts("PASS: budget counts re-probes the timer queued (none for requests before it fires, none while hotplug is pending, none for an old generation, none once spent), one warning when it runs out, 300ms delay, disconnect/quiesce/ownership gates and cancellation"); } """ return prefix + production + controls