Module Name:    src
Committed By:   mlelstv
Date:           Sat Oct 13 14:24:35 UTC 2018

Modified Files:
        src/sys/dev: ld.c

Log Message:
take kernel lock for ioctl calls when backend isn't tagged MPSAFE.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/ld.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/dev/ld.c
diff -u src/sys/dev/ld.c:1.104 src/sys/dev/ld.c:1.105
--- src/sys/dev/ld.c:1.104	Sat Oct 28 03:47:24 2017
+++ src/sys/dev/ld.c	Sat Oct 13 14:24:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld.c,v 1.104 2017/10/28 03:47:24 riastradh Exp $	*/
+/*	$NetBSD: ld.c,v 1.105 2018/10/13 14:24:35 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.104 2017/10/28 03:47:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.105 2018/10/13 14:24:35 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -369,7 +369,11 @@ ldioctl(dev_t dev, u_long cmd, void *add
 		return (error);
 
 	if (sc->sc_ioctl) {
+		if ((sc->sc_flags & LDF_MPSAFE) == 0)
+			KERNEL_LOCK(1, curlwp);
 		error = (*sc->sc_ioctl)(sc, cmd, addr, flag, 0);
+		if ((sc->sc_flags & LDF_MPSAFE) == 0)
+			KERNEL_UNLOCK_ONE(curlwp);
 		if (error != EPASSTHROUGH)
 			return (error);
 	}
@@ -388,7 +392,11 @@ ld_flush(device_t self, bool poll)
 	struct ld_softc *sc = device_private(self);
 
 	if (sc->sc_ioctl) {
+		if ((sc->sc_flags & LDF_MPSAFE) == 0)
+			KERNEL_LOCK(1, curlwp);
 		error = (*sc->sc_ioctl)(sc, DIOCCACHESYNC, NULL, 0, poll);
+		if ((sc->sc_flags & LDF_MPSAFE) == 0)
+			KERNEL_UNLOCK_ONE(curlwp);
 		if (error != 0)
 			device_printf(self, "unable to flush cache\n");
 	}

Reply via email to