git: f739d9f46c24 - main - linuxkpi: Do not wait for a disabled tasklet in tasklet_unlock_wait()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 Nov 2026 06:36:27 UTC
The branch main has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=f739d9f46c24da39651ae981a549a55eb2a3d006
commit f739d9f46c24da39651ae981a549a55eb2a3d006
Author: Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2026-10-28 15:02:00 +0000
Commit: Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2026-11-04 06:35:19 +0000
linuxkpi: Do not wait for a disabled tasklet in tasklet_unlock_wait()
tasklet_unlock_wait() waited for the tasklet state to become idle. Linux
only waits for TASKLET_STATE_RUN, i.e. for a tasklet that is currently
executing. A tasklet which is scheduled but disabled does not run until
it is enabled again, so in LinuxKPI it stays in the BUSY (queued) state and
the waiter never returns.
This is what happens when unloading i915: execlists_reset_prepare()
disables the engine tasklet with __tasklet_disable_sync_once() while the
tasklet is queued and kldunload loops forever in pause().
Do not wait if the tasklet is only queued and disabled.
Reviewed by: bz
Sponsored by: Beckhoff Automation GmbH & Co. KG
---
sys/compat/linuxkpi/common/src/linux_tasklet.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/sys/compat/linuxkpi/common/src/linux_tasklet.c b/sys/compat/linuxkpi/common/src/linux_tasklet.c
index e443ab3958b4..d2cf6df35f0f 100644
--- a/sys/compat/linuxkpi/common/src/linux_tasklet.c
+++ b/sys/compat/linuxkpi/common/src/linux_tasklet.c
@@ -271,7 +271,24 @@ tasklet_unlock_wait(struct tasklet_struct *ts)
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "tasklet_kill() can sleep");
- /* wait until tasklet is no longer busy */
- while (TASKLET_ST_GET(ts) != TASKLET_ST_IDLE)
+ /*
+ * Wait until the tasklet is no longer running, like Linux which only
+ * waits for TASKLET_STATE_RUN. A tasklet which is only scheduled and
+ * is disabled will not be run until it is enabled again, so waiting for
+ * it to become idle would block forever (for example i915 disables the
+ * engine tasklets while a reset is pending and waits for them).
+ */
+ while (1) {
+ switch (TASKLET_ST_GET(ts)) {
+ case TASKLET_ST_IDLE:
+ return;
+ case TASKLET_ST_BUSY:
+ if (atomic_read(&ts->count) != 0)
+ return;
+ break;
+ default:
+ break;
+ }
pause("W", 1);
+ }
}