Module Name: src Committed By: christos Date: Fri Jul 14 17:50:11 UTC 2017
Modified Files: src/sys/dev/scsipi: scsipi_base.c Log Message: Async event can be called before the adapter is running (pmax tc asc) To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/dev/scsipi/scsipi_base.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/scsipi/scsipi_base.c diff -u src/sys/dev/scsipi/scsipi_base.c:1.177 src/sys/dev/scsipi/scsipi_base.c:1.178 --- src/sys/dev/scsipi/scsipi_base.c:1.177 Mon Jun 19 16:52:20 2017 +++ src/sys/dev/scsipi/scsipi_base.c Fri Jul 14 13:50:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: scsipi_base.c,v 1.177 2017/06/19 20:52:20 mlelstv Exp $ */ +/* $NetBSD: scsipi_base.c,v 1.178 2017/07/14 17:50:11 christos Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.177 2017/06/19 20:52:20 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.178 2017/07/14 17:50:11 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_scsi.h" @@ -2238,8 +2238,10 @@ void scsipi_async_event(struct scsipi_channel *chan, scsipi_async_event_t event, void *arg) { + bool lock = chan_running(chan) > 0; - mutex_enter(chan_mtx(chan)); + if (lock) + mutex_enter(chan_mtx(chan)); switch (event) { case ASYNC_EVENT_MAX_OPENINGS: scsipi_async_event_max_openings(chan, @@ -2256,7 +2258,8 @@ scsipi_async_event(struct scsipi_channel scsipi_async_event_channel_reset(chan); break; } - mutex_exit(chan_mtx(chan)); + if (lock) + mutex_exit(chan_mtx(chan)); } /*