From 4a65f0d14441c8ad5e3025df8379b5b3a6173ec8 Mon Sep 17 00:00:00 2001 From: Naeem Malik Date: Mon, 30 Nov 2026 03:53:02 +0530 Subject: [PATCH] drm/asahi: g15: keep a queued poll when rearm adds its backup rearm() ended with mod_delayed_work_on(.., 1). When the mailbox IRQ had already queued the poll work to run now (kick() goes through poll_now() with delay 0), a submit that rearmed right after pushed that poll out a jiffy, and the poll that would have restarted the resnap timer did not run either. A completion could then be noticed up to a resnap interval (100 us) late. Queue the one-jiffy backup only if no poll is pending, as G17's backup poll does. The resnap timer's poll_now() still brings a later pending poll forward, such as the idle PB reclaim expiry that rearm used to replace, so nothing waits longer than the timer. The resnap timer restart stays: a poll that is already queued rearms after it, so the timer is started again with the new flight in view. Rebased from c474b886b5fc (written on 7.2) onto aurora-silicon/linux main: g15_repoll_us.value() is no longer dereferenced there, so that context line differs. The change itself is unchanged. Signed-off-by: Naeem Malik --- drivers/gpu/drm/asahi/g15/poll.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/asahi/g15/poll.rs b/drivers/gpu/drm/asahi/g15/poll.rs index 67ec21405c6af..fc4fd77364af2 100644 --- a/drivers/gpu/drm/asahi/g15/poll.rs +++ b/drivers/gpu/drm/asahi/g15/poll.rs @@ -25,7 +25,7 @@ use kernel::{ }, msecs_to_jiffies, Delta, Jiffies, Monotonic, }, - workqueue::RawWorkItem, + workqueue::{self, RawWorkItem}, }; use super::channel::Channel; @@ -87,7 +87,8 @@ impl Shared { Ok(true) => self.rearm(firmware.engine.chan_wait), // Idle: nothing polls until new work arrives, so a PB reclaim that comes // due with more idle time gets one more pass then. A job's arrival brings - // the poll work forward (`rearm`), which replaces this expiry. + // the poll work forward (the `resnap` timer's `poll_now`), which replaces + // this expiry. Ok(false) => { if let Some(ns) = firmware.reclaim_delay_ns() { let ms = ns.div_ceil(1_000_000).min(u32::MAX as u64) as u32; @@ -152,7 +153,8 @@ impl Shared { } /// Re-checks a published command soon: hrtimer, with a one-jiffy backup; sooner while a - /// ready prefix waits for a channel record's consumption. + /// ready prefix waits for a channel record's consumption. The backup leaves a poll that is + /// already queued alone, so one a `kick` queued to run now is not pushed out a jiffy. pub(crate) fn rearm(self: &Arc, chan_wait: bool) { let mut us = params::resnap_us(); if chan_wait && module_parameters::g15_repoll_us.value() != 0 { @@ -165,7 +167,10 @@ impl Shared { drop(handle.take()); *handle = Some(self.clone().start(Delta::from_micros(us as i64))); } - self.mod_poll(1); + // Already queued if this fails. One queued to run now needs no backup, and a later one + // (the idle PB reclaim) is brought forward by the timer above. + let _ = + workqueue::system_highpri().enqueue_delayed::, POLL_WORK>(self.clone(), 1); } /// Starts what the engine needs besides the firmware state: the `aurora-g15/stats` and