Module Name: src Committed By: riastradh Date: Sun Jul 27 14:02:48 UTC 2014
Modified Files: src/sys/external/bsd/drm2/linux: linux_work.c Log Message: Linux work is queued in intr context, so block intrs when locking. (Yes, this getting out of hand.) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/linux/linux_work.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/linux/linux_work.c diff -u src/sys/external/bsd/drm2/linux/linux_work.c:1.5 src/sys/external/bsd/drm2/linux/linux_work.c:1.6 --- src/sys/external/bsd/drm2/linux/linux_work.c:1.5 Fri Jul 25 16:15:12 2014 +++ src/sys/external/bsd/drm2/linux/linux_work.c Sun Jul 27 14:02:48 2014 @@ -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 *wor * * 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