Linux work is queued in intr context, so block intrs when locking.
(Yes, this getting out of hand.)
This commit is contained in:
parent
6f08ad218d
commit
6dedd04ff8
29
sys/external/bsd/drm2/linux/linux_work.c
vendored
29
sys/external/bsd/drm2/linux/linux_work.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_work.c,v 1.5 2014/07/25 16:15:12 riastradh Exp $ */
|
||||
/* $NetBSD: linux_work.c,v 1.6 2014/07/27 14:02:48 riastradh Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.5 2014/07/25 16:15:12 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.6 2014/07/27 14:02:48 riastradh Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -281,24 +281,49 @@ linux_wq_barrier(struct work_struct *work)
|
||||
*
|
||||
* We use __cpu_simple_lock(9) rather than mutex(9) because Linux code
|
||||
* does not destroy work, so there is nowhere to call mutex_destroy.
|
||||
*
|
||||
* XXX This is getting out of hand... Really, work items shouldn't
|
||||
* have locks in them at all; instead the workqueues should.
|
||||
*/
|
||||
|
||||
static void
|
||||
linux_work_lock_init(struct work_struct *work)
|
||||
{
|
||||
|
||||
__cpu_simple_lock_init(&work->w_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_work_lock(struct work_struct *work)
|
||||
{
|
||||
struct cpu_info *ci;
|
||||
int cnt, s;
|
||||
|
||||
/* XXX Copypasta of MUTEX_SPIN_SPLRAISE. */
|
||||
s = splvm();
|
||||
ci = curcpu();
|
||||
cnt = ci->ci_mtx_count--;
|
||||
__insn_barrier();
|
||||
if (cnt == 0)
|
||||
ci->ci_mtx_oldspl = s;
|
||||
|
||||
__cpu_simple_lock(&work->w_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_work_unlock(struct work_struct *work)
|
||||
{
|
||||
struct cpu_info *ci;
|
||||
int s;
|
||||
|
||||
__cpu_simple_unlock(&work->w_lock);
|
||||
|
||||
/* XXX Copypasta of MUTEX_SPIN_SPLRESTORE. */
|
||||
ci = curcpu();
|
||||
s = ci->ci_mtx_oldspl;
|
||||
__insn_barrier();
|
||||
if (++ci->ci_mtx_count == 0)
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static bool __diagused
|
||||
|
Loading…
Reference in New Issue
Block a user