drm: Take advantage of kthread interlock to reduce diff.

This commit is contained in:
riastradh 2021-12-19 12:42:32 +00:00
parent 1f420662fc
commit 30d3e3c2b7
2 changed files with 8 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sched_main.c,v 1.8 2021/12/19 12:42:25 riastradh Exp $ */
/* $NetBSD: sched_main.c,v 1.9 2021/12/19 12:42:32 riastradh Exp $ */
/*
* Copyright 2015 Advanced Micro Devices, Inc.
@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sched_main.c,v 1.8 2021/12/19 12:42:25 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: sched_main.c,v 1.9 2021/12/19 12:42:32 riastradh Exp $");
#include <linux/kthread.h>
#include <linux/wait.h>
@ -728,11 +728,8 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
*/
static bool drm_sched_blocked(struct drm_gpu_scheduler *sched)
{
assert_spin_locked(&sched->job_list_lock);
if (kthread_should_park()) {
spin_unlock(&sched->job_list_lock);
kthread_parkme();
spin_lock(&sched->job_list_lock);
return true;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_kthread.c,v 1.6 2021/12/19 12:42:25 riastradh Exp $ */
/* $NetBSD: linux_kthread.c,v 1.7 2021/12/19 12:42:32 riastradh Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.6 2021/12/19 12:42:25 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_kthread.c,v 1.7 2021/12/19 12:42:32 riastradh Exp $");
#include <sys/types.h>
@ -275,6 +275,9 @@ kthread_parkme(void)
{
struct task_struct *T = linux_kthread();
assert_spin_locked(T->kt_interlock);
spin_unlock(T->kt_interlock);
mutex_enter(&T->kt_lock);
while (T->kt_shouldpark) {
T->kt_parked = true;
@ -283,4 +286,5 @@ kthread_parkme(void)
T->kt_parked = false;
}
mutex_exit(&T->kt_lock);
spin_lock(T->kt_interlock);
}