linux: wakeup the target thread in kthread_park(). open-code sleepq_timeout() but without setting LW_STIMO. fixes hang in amdgpu GPU reset sequence, mirrors the linux semantics. diff --git a/sys/external/bsd/drm2/linux/linux_kthread.c b/sys/external/bsd/drm2/linux/linux_kthread.c index bb5c7d576afe..e1681c00320b 100644 --- a/sys/external/bsd/drm2/linux/linux_kthread.c +++ b/sys/external/bsd/drm2/linux/linux_kthread.c @@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD$"); #include #include #include +#include #include @@ -188,8 +189,20 @@ kthread_park(struct task_struct *T) mutex_enter(&T->kt_lock); KASSERT(!T->kt_shouldstop); T->kt_shouldpark = true; - while (!T->kt_parked) - cv_wait(&T->kt_cv, &T->kt_lock); + lwp_t *l = T->kt_lwp; + if (l != curlwp) { + /* Open-coded sleepq_timeout() with no LW_STIMO. */ + lwp_lock(l); + if (l->l_wchan == NULL) { + /* Somebody beat us to it. */ + lwp_unlock(l); + } else { + lwp_unsleep(l, true); + + while (!T->kt_parked) + cv_wait(&T->kt_cv, &T->kt_lock); + } + } mutex_exit(&T->kt_lock); }