Wed Jan 27 21:43:49 2010 UTC ()
Pull up the following revisions(s) (requested by bouyer in ticket #1257):
	sys/dev/ic/mfi.c:	revision 1.31

bio(4) is MP-safe but mfi(4) is not. So get the kernel_lock at
mfi_ioctl() entry and release it on exit.


(sborrill)
diff -r1.19.8.1 -r1.19.8.2 src/sys/dev/ic/mfi.c

cvs diff -r1.19.8.1 -r1.19.8.2 src/sys/dev/ic/mfi.c (expand / switch to unified diff)

--- src/sys/dev/ic/mfi.c 2009/09/10 07:09:43 1.19.8.1
+++ src/sys/dev/ic/mfi.c 2010/01/27 21:43:48 1.19.8.2
@@ -1,33 +1,33 @@ @@ -1,33 +1,33 @@
1/* $NetBSD: mfi.c,v 1.19.8.1 2009/09/10 07:09:43 snj Exp $ */ 1/* $NetBSD: mfi.c,v 1.19.8.2 2010/01/27 21:43:48 sborrill Exp $ */
2/* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */ 2/* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
3/* 3/*
4 * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us> 4 * Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
5 * 5 *
6 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies. 8 * copyright notice and this permission notice appear in all copies.
9 * 9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19#include <sys/cdefs.h> 19#include <sys/cdefs.h>
20__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.19.8.1 2009/09/10 07:09:43 snj Exp $"); 20__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.19.8.2 2010/01/27 21:43:48 sborrill Exp $");
21 21
22#include "bio.h" 22#include "bio.h"
23 23
24#include <sys/param.h> 24#include <sys/param.h>
25#include <sys/systm.h> 25#include <sys/systm.h>
26#include <sys/buf.h> 26#include <sys/buf.h>
27#include <sys/ioctl.h> 27#include <sys/ioctl.h>
28#include <sys/device.h> 28#include <sys/device.h>
29#include <sys/kernel.h> 29#include <sys/kernel.h>
30#include <sys/malloc.h> 30#include <sys/malloc.h>
31#include <sys/proc.h> 31#include <sys/proc.h>
32 32
33#include <uvm/uvm_param.h> 33#include <uvm/uvm_param.h>
@@ -1311,27 +1311,30 @@ mfi_mgmt_done(struct mfi_ccb *ccb) @@ -1311,27 +1311,30 @@ mfi_mgmt_done(struct mfi_ccb *ccb)
1311 } 1311 }
1312 mfi_put_ccb(ccb); 1312 mfi_put_ccb(ccb);
1313 scsipi_done(xs); 1313 scsipi_done(xs);
1314 } else  1314 } else
1315 wakeup(ccb); 1315 wakeup(ccb);
1316} 1316}
1317 1317
1318#if NBIO > 0 1318#if NBIO > 0
1319int 1319int
1320mfi_ioctl(struct device *dev, u_long cmd, void *addr) 1320mfi_ioctl(struct device *dev, u_long cmd, void *addr)
1321{ 1321{
1322 struct mfi_softc *sc = (struct mfi_softc *)dev; 1322 struct mfi_softc *sc = (struct mfi_softc *)dev;
1323 int error = 0; 1323 int error = 0;
1324 int s = splbio(); 1324 int s;
 1325
 1326 KERNEL_LOCK(1, curlwp);
 1327 s = splbio();
1325 1328
1326 DNPRINTF(MFI_D_IOCTL, "%s: mfi_ioctl ", DEVNAME(sc)); 1329 DNPRINTF(MFI_D_IOCTL, "%s: mfi_ioctl ", DEVNAME(sc));
1327 1330
1328 switch (cmd) { 1331 switch (cmd) {
1329 case BIOCINQ: 1332 case BIOCINQ:
1330 DNPRINTF(MFI_D_IOCTL, "inq\n"); 1333 DNPRINTF(MFI_D_IOCTL, "inq\n");
1331 error = mfi_ioctl_inq(sc, (struct bioc_inq *)addr); 1334 error = mfi_ioctl_inq(sc, (struct bioc_inq *)addr);
1332 break; 1335 break;
1333 1336
1334 case BIOCVOL: 1337 case BIOCVOL:
1335 DNPRINTF(MFI_D_IOCTL, "vol\n"); 1338 DNPRINTF(MFI_D_IOCTL, "vol\n");
1336 error = mfi_ioctl_vol(sc, (struct bioc_vol *)addr); 1339 error = mfi_ioctl_vol(sc, (struct bioc_vol *)addr);
1337 break; 1340 break;
@@ -1351,26 +1354,27 @@ mfi_ioctl(struct device *dev, u_long cmd @@ -1351,26 +1354,27 @@ mfi_ioctl(struct device *dev, u_long cmd
1351 error = mfi_ioctl_blink(sc, (struct bioc_blink *)addr); 1354 error = mfi_ioctl_blink(sc, (struct bioc_blink *)addr);
1352 break; 1355 break;
1353 1356
1354 case BIOCSETSTATE: 1357 case BIOCSETSTATE:
1355 DNPRINTF(MFI_D_IOCTL, "setstate\n"); 1358 DNPRINTF(MFI_D_IOCTL, "setstate\n");
1356 error = mfi_ioctl_setstate(sc, (struct bioc_setstate *)addr); 1359 error = mfi_ioctl_setstate(sc, (struct bioc_setstate *)addr);
1357 break; 1360 break;
1358 1361
1359 default: 1362 default:
1360 DNPRINTF(MFI_D_IOCTL, " invalid ioctl\n"); 1363 DNPRINTF(MFI_D_IOCTL, " invalid ioctl\n");
1361 error = EINVAL; 1364 error = EINVAL;
1362 } 1365 }
1363 splx(s); 1366 splx(s);
 1367 KERNEL_UNLOCK_ONE(curlwp);
1364 1368
1365 DNPRINTF(MFI_D_IOCTL, "%s: mfi_ioctl return %x\n", DEVNAME(sc), error); 1369 DNPRINTF(MFI_D_IOCTL, "%s: mfi_ioctl return %x\n", DEVNAME(sc), error);
1366 return error; 1370 return error;
1367} 1371}
1368 1372
1369static int 1373static int
1370mfi_ioctl_inq(struct mfi_softc *sc, struct bioc_inq *bi) 1374mfi_ioctl_inq(struct mfi_softc *sc, struct bioc_inq *bi)
1371{ 1375{
1372 struct mfi_conf *cfg; 1376 struct mfi_conf *cfg;
1373 int rv = EINVAL; 1377 int rv = EINVAL;
1374 1378
1375 DNPRINTF(MFI_D_IOCTL, "%s: mfi_ioctl_inq\n", DEVNAME(sc)); 1379 DNPRINTF(MFI_D_IOCTL, "%s: mfi_ioctl_inq\n", DEVNAME(sc));
1376 1380