[PATCH] efi: loader: coalesce overdue periodic timers
Ahmad Fatoum
a.fatoum at barebox.org
Thu Jul 9 01:11:05 PDT 2026
EFI timer events are polled by the loader instead of being driven from
an interrupt. If a periodic timer is serviced late, advancing the next
deadline by only one period leaves old deadlines pending.
Advance periodic timers past the current time when they fire. This keeps
each poll to one notification and avoids consumers draining stale timer
ticks in a tight loop.
This fixes an issue of the Fedora-Workstation-Live-44-1.7.aarch64.iso
GRUB going through its countdown way too fast on a Google Corsola.
Assisted-by: Codex:gpt-5.5
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
efi/loader/boot.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/efi/loader/boot.c b/efi/loader/boot.c
index d34de119f4e7..503b44073886 100644
--- a/efi/loader/boot.c
+++ b/efi/loader/boot.c
@@ -735,6 +735,27 @@ static efi_status_t EFIAPI efi_create_event_ext(
notify_context, NULL, event), *event);
}
+/**
+ * efi_timer_rearm_periodic() - re-arm a periodic timer after it fired
+ * @evt: timer event
+ * @now: current time in ns
+ *
+ * Timers are polled. If a periodic timer is serviced late, signal it once
+ * and skip missed intervals so clients do not drain a backlog of stale ticks.
+ */
+static void efi_timer_rearm_periodic(struct efi_event *evt, u64 now)
+{
+ u64 periods;
+
+ if (!evt->trigger_time) {
+ evt->trigger_next = now;
+ return;
+ }
+
+ periods = div64_u64(now - evt->trigger_next, evt->trigger_time) + 1;
+ evt->trigger_next += periods * evt->trigger_time;
+}
+
/**
* efi_timer_check() - check if a timer event has occurred
*
@@ -760,7 +781,7 @@ void efi_timer_check(void)
evt->trigger_type = EFI_TIMER_CANCEL;
break;
case EFI_TIMER_PERIODIC:
- evt->trigger_next += evt->trigger_time;
+ efi_timer_rearm_periodic(evt, now);
break;
default:
continue;
--
2.47.3
More information about the barebox
mailing list