Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev take kernel lock for ioctl calls when backend isn't ...



details:   https://anonhg.NetBSD.org/src/rev/b354c6f3e2eb
branches:  trunk
changeset: 836358:b354c6f3e2eb
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Oct 13 14:24:35 2018 +0000

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

diffstat:

 sys/dev/ld.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r 8de01a9d3699 -r b354c6f3e2eb sys/dev/ld.c
--- a/sys/dev/ld.c      Sat Oct 13 13:32:50 2018 +0000
+++ b/sys/dev/ld.c      Sat Oct 13 14:24:35 2018 +0000
@@ -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 @@
                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 @@
        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");
        }



Home | Main Index | Thread Index | Old Index