Sat Dec 24 06:04:50 2016 UTC ()
avoid accessing condition variables which belong to a scsibus before actually
attaching the scsibus
now my SS20 boots again


(macallan)
diff -r1.145 -r1.146 src/sys/dev/ic/ncr53c9x.c

cvs diff -r1.145 -r1.146 src/sys/dev/ic/ncr53c9x.c (expand / switch to unified diff)

--- src/sys/dev/ic/ncr53c9x.c 2012/06/18 21:23:56 1.145
+++ src/sys/dev/ic/ncr53c9x.c 2016/12/24 06:04:50 1.146
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ncr53c9x.c,v 1.145 2012/06/18 21:23:56 martin Exp $ */ 1/* $NetBSD: ncr53c9x.c,v 1.146 2016/12/24 06:04:50 macallan Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum. 8 * by Charles M. Hannum.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -60,27 +60,27 @@ @@ -60,27 +60,27 @@
60 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 60 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
61 * POSSIBILITY OF SUCH DAMAGE. 61 * POSSIBILITY OF SUCH DAMAGE.
62 */ 62 */
63 63
64/* 64/*
65 * Based on aic6360 by Jarle Greipsland 65 * Based on aic6360 by Jarle Greipsland
66 * 66 *
67 * Acknowledgements: Many of the algorithms used in this driver are 67 * Acknowledgements: Many of the algorithms used in this driver are
68 * inspired by the work of Julian Elischer (julian@tfs.com) and 68 * inspired by the work of Julian Elischer (julian@tfs.com) and
69 * Charles Hannum (mycroft@duality.gnu.ai.mit.edu). Thanks a million! 69 * Charles Hannum (mycroft@duality.gnu.ai.mit.edu). Thanks a million!
70 */ 70 */
71 71
72#include <sys/cdefs.h> 72#include <sys/cdefs.h>
73__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.145 2012/06/18 21:23:56 martin Exp $"); 73__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.146 2016/12/24 06:04:50 macallan Exp $");
74 74
75#include <sys/param.h> 75#include <sys/param.h>
76#include <sys/systm.h> 76#include <sys/systm.h>
77#include <sys/callout.h> 77#include <sys/callout.h>
78#include <sys/kernel.h> 78#include <sys/kernel.h>
79#include <sys/errno.h> 79#include <sys/errno.h>
80#include <sys/ioctl.h> 80#include <sys/ioctl.h>
81#include <sys/device.h> 81#include <sys/device.h>
82#include <sys/buf.h> 82#include <sys/buf.h>
83#include <sys/malloc.h> 83#include <sys/malloc.h>
84#include <sys/proc.h> 84#include <sys/proc.h>
85#include <sys/queue.h> 85#include <sys/queue.h>
86#include <sys/pool.h> 86#include <sys/pool.h>
@@ -286,27 +286,27 @@ ncr53c9x_attach(struct ncr53c9x_softc *s @@ -286,27 +286,27 @@ ncr53c9x_attach(struct ncr53c9x_softc *s
286 286
287 /* 287 /*
288 * Add reference to adapter so that we drop the reference after 288 * Add reference to adapter so that we drop the reference after
289 * config_found() to make sure the adatper is disabled. 289 * config_found() to make sure the adatper is disabled.
290 */ 290 */
291 if (scsipi_adapter_addref(adapt) != 0) { 291 if (scsipi_adapter_addref(adapt) != 0) {
292 aprint_error_dev(sc->sc_dev, "unable to enable controller\n"); 292 aprint_error_dev(sc->sc_dev, "unable to enable controller\n");
293 return; 293 return;
294 } 294 }
295 295
296 /* Reset state & bus */ 296 /* Reset state & bus */
297 sc->sc_cfflags = device_cfdata(sc->sc_dev)->cf_flags; 297 sc->sc_cfflags = device_cfdata(sc->sc_dev)->cf_flags;
298 sc->sc_state = 0; 298 sc->sc_state = 0;
299 ncr53c9x_init(sc, 1); 299 ncr53c9x_init(sc, 0); /* no bus reset yet, leave that to scsibus* */
300 300
301 /* 301 /*
302 * Now try to attach all the sub-devices 302 * Now try to attach all the sub-devices
303 */ 303 */
304 sc->sc_child = config_found(sc->sc_dev, &sc->sc_channel, scsiprint); 304 sc->sc_child = config_found(sc->sc_dev, &sc->sc_channel, scsiprint);
305 305
306 scsipi_adapter_delref(adapt); 306 scsipi_adapter_delref(adapt);
307 callout_reset(&sc->sc_watchdog, 60 * hz, ncr53c9x_watch, sc); 307 callout_reset(&sc->sc_watchdog, 60 * hz, ncr53c9x_watch, sc);
308} 308}
309 309
310int 310int
311ncr53c9x_detach(struct ncr53c9x_softc *sc, int flags) 311ncr53c9x_detach(struct ncr53c9x_softc *sc, int flags)
312{ 312{
@@ -545,34 +545,34 @@ ncr53c9x_init(struct ncr53c9x_softc *sc, @@ -545,34 +545,34 @@ ncr53c9x_init(struct ncr53c9x_softc *sc,
545 if (ncr53c9x_notag) 545 if (ncr53c9x_notag)
546 ti->flags &= ~T_TAG; 546 ti->flags &= ~T_TAG;
547#endif 547#endif
548 ti->period = sc->sc_minsync; 548 ti->period = sc->sc_minsync;
549 ti->offset = 0; 549 ti->offset = 0;
550 ti->cfg3 = 0; 550 ti->cfg3 = 0;
551 551
552 ncr53c9x_update_xfer_mode(sc, r); 552 ncr53c9x_update_xfer_mode(sc, r);
553 } 553 }
554 554
555 if (doreset) { 555 if (doreset) {
556 sc->sc_state = NCR_SBR; 556 sc->sc_state = NCR_SBR;
557 NCRCMD(sc, NCRCMD_RSTSCSI); 557 NCRCMD(sc, NCRCMD_RSTSCSI);
 558
 559 /* Notify upper layer */
 560 scsipi_async_event(&sc->sc_channel, ASYNC_EVENT_RESET, NULL);
558 } else { 561 } else {
559 sc->sc_state = NCR_IDLE; 562 sc->sc_state = NCR_IDLE;
560 ncr53c9x_sched(sc); 563 ncr53c9x_sched(sc);
561 } 564 }
562 565
563 /* Notify upper layer */ 
564 scsipi_async_event(&sc->sc_channel, ASYNC_EVENT_RESET, NULL); 
565 
566 /* XXXSMP scsipi */ 566 /* XXXSMP scsipi */
567 KERNEL_UNLOCK_ONE(curlwp); 567 KERNEL_UNLOCK_ONE(curlwp);
568} 568}
569 569
570/* 570/*
571 * Read the NCR registers, and save their contents for later use. 571 * Read the NCR registers, and save their contents for later use.
572 * NCR_STAT, NCR_STEP & NCR_INTR are mostly zeroed out when reading 572 * NCR_STAT, NCR_STEP & NCR_INTR are mostly zeroed out when reading
573 * NCR_INTR - so make sure it is the last read. 573 * NCR_INTR - so make sure it is the last read.
574 * 574 *
575 * I think that (from reading the docs) most bits in these registers 575 * I think that (from reading the docs) most bits in these registers
576 * only make sense when he DMA CSR has an interrupt showing. Call only 576 * only make sense when he DMA CSR has an interrupt showing. Call only
577 * if an interrupt is pending. 577 * if an interrupt is pending.
578 */ 578 */