PERFORCE change 54261 for review

Scott Long scottl at FreeBSD.org
Sun Jun 6 11:15:13 GMT 2004


http://perforce.freebsd.org/chv.cgi?CH=54261

Change 54261 by scottl at scottl-esp-sparc64 on 2004/06/06 11:14:12

	Remove spl
	Change simple_lock to mtx_lock
	move sc_dev.dv_xname to dv_name
	Pare down ncr53x9x_poll() to something more appropriate.

Affected files ...

.. //depot/projects/scottl-esp/src/sys/dev/esp/ncr53c9x.c#5 edit
.. //depot/projects/scottl-esp/src/sys/dev/esp/ncr53c9xvar.h#5 edit

Differences ...

==== //depot/projects/scottl-esp/src/sys/dev/esp/ncr53c9x.c#5 (text+ko) ====

@@ -82,6 +82,7 @@
 #include <sys/systm.h>
 #include <sys/bus.h>
 #include <sys/kernel.h>
+#include <sys/malloc.h>
 #include <sys/resource.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
@@ -102,8 +103,7 @@
 static void	ncr53c9x_select(struct ncr53c9x_softc *, struct ncr53c9x_ecb *);
 static int	ncr53c9x_reselect(struct ncr53c9x_softc *, int, int, int);
 static void	ncr53c9x_scsi_reset(struct ncr53c9x_softc *);
-static int	ncr53c9x_poll(struct ncr53c9x_softc *,
-			      struct scsipi_xfer *, int);
+static int	ncr53c9x_poll(struct cam_sim *);
 static void	ncr53c9x_sched(struct ncr53c9x_softc *);
 static void	ncr53c9x_done(struct ncr53c9x_softc *, struct ncr53c9x_ecb *);
 static void	ncr53c9x_msgin(struct ncr53c9x_softc *);
@@ -190,14 +190,15 @@
 	struct scsipi_adapter *adapt = &sc->sc_adapter;
 	struct scsipi_channel *chan = &sc->sc_channel;
 
-	simple_lock_init(&sc->sc_lock);
+	mtx_init(&sc->sc_lock, "ncr" "ncr53c9x lock", MTX_DEF);
+	sc->dv_name = device_get_nameunit(sc->sc_dev);
 
 	/*
 	 * Note, the front-end has set us up to print the chip variation.
 	 */
 	if (sc->sc_rev >= NCR_VARIANT_MAX) {
 		printf("\n%s: unknown variant %d, devices not attached\n",
-		    sc->sc_dev.dv_xname, sc->sc_rev);
+		    sc->dv_name, sc->sc_rev);
 		return;
 	}
 
@@ -226,7 +227,7 @@
 		return;
 	}
 
-	callout_init(&sc->sc_watchdog);
+	callout_init(&sc->sc_watchdog, 0);
 
 	/*
 	 * Treat NCR53C90 with the 86C01 DMA chip exactly as ESP100
@@ -284,7 +285,7 @@
 	 */
 	if (scsipi_adapter_addref(adapt) != 0) {
 		printf("%s: unable to enable controller\n",
-		    sc->sc_dev.dv_xname);
+		    sc->dv_name);
 		return;
 	}
 
@@ -381,7 +382,7 @@
 
 	default:
 		printf("%s: unknown revision code, assuming ESP100\n",
-		    sc->sc_dev.dv_xname);
+		    sc->dv_name);
 		NCR_WRITE_REG(sc, NCR_CFG1, sc->sc_cfg1);
 		NCR_WRITE_REG(sc, NCR_CCF, sc->sc_ccf);
 		NCR_WRITE_REG(sc, NCR_SYNCOFF, 0);
@@ -393,10 +394,10 @@
 
 #if 0
 	printf("%s: ncr53c9x_reset: revision %d\n",
-	       sc->sc_dev.dv_xname, sc->sc_rev);
+	       sc->dv_name, sc->sc_rev);
 	printf("%s: ncr53c9x_reset: cfg1 0x%x, cfg2 0x%x, cfg3 0x%x, "
 	    "ccf 0x%x, timeout 0x%x\n",
-	    sc->sc_dev.dv_xname, sc->sc_cfg1, sc->sc_cfg2, sc->sc_cfg3,
+	    sc->dv_name, sc->sc_cfg1, sc->sc_cfg2, sc->sc_cfg3,
 	    sc->sc_ccf, sc->sc_timeout);
 #endif
 }
@@ -411,7 +412,7 @@
 
 	(*sc->sc_glue->gl_dma_stop)(sc);
 
-	printf("%s: resetting SCSI bus\n", sc->sc_dev.dv_xname);
+	printf("%s: resetting SCSI bus\n", sc->dv_name);
 	NCRCMD(sc, NCRCMD_RSTSCSI);
 }
 
@@ -774,12 +775,9 @@
 	struct ncr53c9x_softc *sc;
 	struct ncr53c9x_ecb *ecb;
 {
-	int s;
 
-	s = splbio();
 	ecb->flags = 0;
 	pool_put(&ecb_pool, (void *)ecb);
-	splx(s);
 	return;
 }
 
@@ -789,11 +787,8 @@
 	int flags;
 {
 	struct ncr53c9x_ecb *ecb;
-	int s;
 
-	s = splbio();
 	ecb = (struct ncr53c9x_ecb *)pool_get(&ecb_pool, PR_NOWAIT);
-	splx(s);
 	if (ecb) {
 		memset(ecb, 0, sizeof(*ecb));
 		ecb->flags |= ECB_ALLOC;
@@ -812,21 +807,17 @@
  */
 
 void
-ncr53c9x_scsipi_request(chan, req, arg)
-	struct scsipi_channel *chan;
-	scsipi_adapter_req_t req;
-	void *arg;
+ncr53c9x_action(struct cam_sim *sim, union ccb *ccb)
 {
 	struct scsipi_xfer *xs;
 	struct scsipi_periph *periph;
 	struct ncr53c9x_softc *sc = (void *)chan->chan_adapter->adapt_dev;
 	struct ncr53c9x_ecb *ecb;
-	int s, flags;
+	int flags;
 
-	NCR_TRACE(("[ncr53c9x_scsipi_request] "));
+	NCR_TRACE(("[ncr53c9x_action] "));
 
-	s = splbio();
-	simple_lock(&sc->sc_lock);
+	mtx_lock(&sc->sc_lock);
 
 	switch (req) {
 	case ADAPTER_REQ_RUN_XFER:
@@ -847,8 +838,7 @@
 			scsipi_printaddr(periph);
 			printf("unable to allocate ecb\n");
 			xs->error = XS_RESOURCE_SHORTAGE;
-			simple_unlock(&sc->sc_lock);
-			splx(s);
+			mtx_unlock(&sc->sc_lock);
 			scsipi_done(xs);
 			return;
 		}
@@ -877,12 +867,14 @@
 		if ((flags & XS_CTL_POLL) == 0)
 			break;
 
+#if 0
 		/* Not allowed to use interrupts, use polling instead */
 		if (ncr53c9x_poll(sc, xs, ecb->timeout)) {
 			ncr53c9x_timeout(ecb);
 			if (ncr53c9x_poll(sc, xs, ecb->timeout))
 				ncr53c9x_timeout(ecb);
 		}
+#endif
 		break;
 
 	case ADAPTER_REQ_GROW_RESOURCES:
@@ -902,14 +894,14 @@
 		if ((sc->sc_cfflags & (1<<((xm->xm_target&7)+16))) == 0 &&
 		    (xm->xm_mode & PERIPH_CAP_TQING)) {
 			NCR_MISC(("%s: target %d: tagged queuing\n",
-			    sc->sc_dev.dv_xname, xm->xm_target));
+			    sc->dv_name, xm->xm_target));
 			ti->flags |= T_TAG;
 		} else
 			ti->flags &= ~T_TAG;
 
 		if ((xm->xm_mode & PERIPH_CAP_WIDE16) != 0) {
 			NCR_MISC(("%s: target %d: wide scsi negotiation\n",
-			    sc->sc_dev.dv_xname, xm->xm_target));
+			    sc->dv_name, xm->xm_target));
 			if (sc->sc_rev == NCR_VARIANT_FAS366) {
 				ti->flags |= T_WIDE;
 				ti->width = 1;
@@ -919,7 +911,7 @@
 		if ((xm->xm_mode & PERIPH_CAP_SYNC) != 0 &&
 		    (ti->flags & T_SYNCHOFF) == 0 && sc->sc_minsync != 0) {
 			NCR_MISC(("%s: target %d: sync negotiation\n",
-			    sc->sc_dev.dv_xname, xm->xm_target));
+			    sc->dv_name, xm->xm_target));
 			ti->flags |= T_NEGOTIATE;
 			ti->period = sc->sc_minsync;
 		}
@@ -933,8 +925,7 @@
 		break;
 	}
 
-	simple_unlock(&sc->sc_lock);
-	splx(s);
+	mtx_unlock(&sc->sc_lock);
 }
 
 static void
@@ -967,34 +958,14 @@
 /*
  * Used when interrupt driven I/O isn't allowed, e.g. during boot.
  */
-static int
-ncr53c9x_poll(sc, xs, count)
-	struct ncr53c9x_softc *sc;
-	struct scsipi_xfer *xs;
-	int count;
+static void
+ncr53c9x_poll(struct cam_sim *sim)
 {
 
 	NCR_TRACE(("[ncr53c9x_poll] "));
-	while (count) {
-		if (NCRDMA_ISINTR(sc)) {
-			simple_unlock(&sc->sc_lock);
-			ncr53c9x_intr(sc);
-			simple_lock(&sc->sc_lock);
-		}
-#if alternatively
-		if (NCR_READ_REG(sc, NCR_STAT) & NCRSTAT_INT)
-			ncr53c9x_intr(sc);
-#endif
-		if ((xs->xs_status & XS_STS_DONE) != 0)
-			return (0);
-		if (sc->sc_state == NCR_IDLE) {
-			NCR_TRACE(("[ncr53c9x_poll: rescheduling] "));
-			ncr53c9x_sched(sc);
-		}
-		DELAY(1000);
-		count--;
+	if (NCRDMA_ISINTR(sc)) {
+		ncr53c9x_intr(cam_sim_softc(sim));
 	}
-	return (1);
 }
 
 /*
@@ -1224,9 +1195,9 @@
 
 	ncr53c9x_free_ecb(sc, ecb);
 	ti->cmds++;
-	simple_unlock(&sc->sc_lock);
+	mtx_unlock(&sc->sc_lock);
 	scsipi_done(xs);
-	simple_lock(&sc->sc_lock);
+	mtx_lock(&sc->sc_lock);
 }
 
 static void
@@ -1410,7 +1381,7 @@
 		if (selid & (selid - 1)) {
 			printf("%s: reselect with invalid selid %02x;"
 			    " sending DEVICE RESET\n",
-			    sc->sc_dev.dv_xname, selid);
+			    sc->dv_name, selid);
 			goto reset;
 		}
 
@@ -1446,7 +1417,7 @@
 	if (ecb == NULL) {
 		printf("%s: reselect from target %d lun %d tag %x:%x "
 		    "with no nexus; sending ABORT\n",
-		    sc->sc_dev.dv_xname, target, lun, tagtype, tagid);
+		    sc->dv_name, target, lun, tagtype, tagid);
 		goto abort;
 	}
 
@@ -1505,7 +1476,7 @@
 
 	if (sc->sc_imlen == 0) {
 		printf("%s: msgin: no msg byte available\n",
-		    sc->sc_dev.dv_xname);
+		    sc->dv_name);
 		return;
 	}
 
@@ -1519,7 +1490,7 @@
 	    sc->sc_state != NCR_RESELECTED) {
 		printf("%s: phase change, dropping message, "
 		    "prev %d, state %d\n",
-		    sc->sc_dev.dv_xname, sc->sc_prevphase, sc->sc_state);
+		    sc->dv_name, sc->sc_prevphase, sc->sc_state);
 		sc->sc_flags &= ~NCR_DROP_MSGI;
 		sc->sc_imlen = 0;
 	}
@@ -1612,8 +1583,7 @@
 				 *  - Dequeue ecb from the queued array.
 				 */
 				printf("%s: tagged queuing rejected: "
-				    "target %d\n",
-				    sc->sc_dev.dv_xname, 
+				    "target %d\n", sc->dv_name, 
 				    ecb->xs->xs_periph->periph_target);
 
 				NCR_MSGS(("(rejected sent tag)"));
@@ -1634,8 +1604,7 @@
 
 			case SEND_SDTR:
 				printf("%s: sync transfer rejected: "
-				    "target %d\n",
-				    sc->sc_dev.dv_xname, 
+				    "target %d\n", sc->dv_name, 
 				    ecb->xs->xs_periph->periph_target);
 
 				sc->sc_flags &= ~NCR_SYNCHNEGO;
@@ -1647,8 +1616,7 @@
 
 			case SEND_WDTR:
 				printf("%s: wide transfer rejected: "
-				    "target %d\n",
-				    sc->sc_dev.dv_xname, 
+				    "target %d\n", sc->dv_xname, 
 				    ecb->xs->xs_periph->periph_target);
 				ti->flags &= ~(T_WIDE | T_WDTRSENT);
 				ti->width = 0;
@@ -1759,7 +1727,7 @@
 			case MSG_EXT_WDTR:
 #ifdef NCR53C9X_DEBUG
 				printf("%s: wide mode %d\n",
-				       sc->sc_dev.dv_xname, sc->sc_imess[3]);
+				       sc->dv_name, sc->sc_imess[3]);
 #endif
 				if (sc->sc_imess[3] == 1) {
 					ti->cfg3 |= NCRFASCFG3_EWIDE;
@@ -1800,8 +1768,7 @@
 			printf("%s: TAG reselect without IDENTIFY;"
 			    " MSG %x;"
 			    " sending DEVICE RESET\n",
-			    sc->sc_dev.dv_xname,
-			    sc->sc_imess[0]);
+			     sc->dv_name, sc->sc_imess[0]);
 			goto reset;
 		}
 		(void) ncr53c9x_reselect(sc, sc->sc_msgify,
@@ -1815,8 +1782,7 @@
 			printf("%s: reselect without IDENTIFY;"
 			    " MSG %x;"
 			    " sending DEVICE RESET\n",
-			    sc->sc_dev.dv_xname,
-			    sc->sc_imess[1]);
+			    sc->dv_name, sc->sc_imess[1]);
 			goto reset;
 		}
 		(void) ncr53c9x_reselect(sc, sc->sc_msgify, 0, 0);
@@ -1824,7 +1790,7 @@
 
 	default:
 		printf("%s: unexpected MESSAGE IN; sending DEVICE RESET\n",
-		    sc->sc_dev.dv_xname);
+		    sc->dv_name);
 	reset:
 		ncr53c9x_sched_msgout(SEND_DEV_RESET);
 		break;
@@ -1882,7 +1848,7 @@
 			goto new;
 		} else {
 			printf("%s at line %d: unexpected MESSAGE OUT phase\n",
-			    sc->sc_dev.dv_xname, __LINE__);
+			    sc->dv_name, __LINE__);
 		}
 	}
 
@@ -1919,7 +1885,7 @@
                 case SEND_IDENTIFY:
                         if (sc->sc_state != NCR_CONNECTED) {
                                 printf("%s at line %d: no nexus\n",
-                                    sc->sc_dev.dv_xname, __LINE__);
+                                    sc->dv_name, __LINE__);
                         }
                         ecb = sc->sc_nexus;
                         sc->sc_omess[0] =
@@ -1928,7 +1894,7 @@
 		case SEND_TAG:
 			if (sc->sc_state != NCR_CONNECTED) {
 				printf("%s at line %d: no nexus\n",
-				    sc->sc_dev.dv_xname, __LINE__);
+				    sc->dv_name, __LINE__);
 			}
 			ecb = sc->sc_nexus;
 			sc->sc_omess[0] = ecb->tag[0];
@@ -2037,7 +2003,7 @@
 	if (!NCRDMA_ISINTR(sc))
 		return (0);
 
-	simple_lock(&sc->sc_lock);
+	mtx_lock(&sc->sc_lock);
 again:
 	/* and what do the registers say... */
 	ncr53c9x_readregs(sc);
@@ -2066,7 +2032,7 @@
 			DELAY(1);
 		}
 		if (sc->sc_state != NCR_SBR) {
-			printf("%s: SCSI bus reset\n", sc->sc_dev.dv_xname);
+			printf("%s: SCSI bus reset\n", sc->dv_name);
 			ncr53c9x_init(sc, 0); /* Restart everything */
 			goto out;
 		}
@@ -2077,7 +2043,7 @@
 #endif
 		if (sc->sc_nexus != NULL)
 			panic("%s: nexus in reset state",
-			    sc->sc_dev.dv_xname);
+			    sc->dv_name);
 		goto sched;
 	}
 
@@ -2111,7 +2077,7 @@
 				 */
 #ifdef DEBUG
 				printf("%s: ESP100 work-around activated\n",
-					sc->sc_dev.dv_xname);
+					sc->dv_name);
 #endif
 				sc->sc_flags &= ~NCR_EXPECT_ILLCMD;
 				goto out;
@@ -2119,7 +2085,7 @@
 			/* illegal command, out of sync ? */
 			printf("%s: illegal command: 0x%x "
 			    "(state %d, phase %x, prevphase %x)\n",
-			    sc->sc_dev.dv_xname, sc->sc_lastcmd,
+			    sc->dv_name, sc->sc_lastcmd,
 			    sc->sc_state, sc->sc_phase, sc->sc_prevphase);
 			if (NCR_READ_REG(sc, NCR_FFLAG) & NCRFIFO_FF) {
 				NCRCMD(sc, NCRCMD_FLUSH);
@@ -2142,7 +2108,7 @@
 		int r = NCRDMA_INTR(sc);
 		if (r == -1) {
 			printf("%s: DMA error; resetting\n",
-			    sc->sc_dev.dv_xname);
+			    sc->dv_name);
 			ncr53c9x_init(sc, 1);
 			goto out;
 		}
@@ -2173,7 +2139,7 @@
 					printf("%s: !TC on MSG OUT"
 					    " [intr %x, stat %x, step %d]"
 					    " prevphase %x, resid %lx\n",
-					    sc->sc_dev.dv_xname,
+					    sc->dv_name,
 					    sc->sc_espintr,
 					    sc->sc_espstat,
 					    sc->sc_espstep,
@@ -2189,7 +2155,7 @@
 				printf("%s: !TC on DATA XFER"
 				    " [intr %x, stat %x, step %d]"
 				    " prevphase %x, resid %x\n",
-				    sc->sc_dev.dv_xname,
+				    sc->dv_name,
 				    sc->sc_espintr,
 				    sc->sc_espstat,
 				    sc->sc_espstep,
@@ -2203,7 +2169,7 @@
 	 * Check for less serious errors.
 	 */
 	if ((sc->sc_espstat & NCRSTAT_PE) != 0) {
-		printf("%s: SCSI bus parity error\n", sc->sc_dev.dv_xname);
+		printf("%s: SCSI bus parity error\n", sc->dv_name);
 		if (sc->sc_prevphase == MESSAGE_IN_PHASE)
 			ncr53c9x_sched_msgout(SEND_PARITY_ERROR);
 		else
@@ -2279,7 +2245,7 @@
 				 */
 				printf("%s: unexpected disconnect "
 			"[state %d, intr %x, stat %x, phase(c %x, p %x)]; ",
-					sc->sc_dev.dv_xname, sc->sc_state,
+					sc->dv_name, sc->sc_state,
 					sc->sc_espintr, sc->sc_espstat,
 					sc->sc_phase, sc->sc_prevphase);
 
@@ -2309,7 +2275,7 @@
 
 	case NCR_SBR:
 		printf("%s: waiting for SCSI Bus Reset to happen\n",
-		    sc->sc_dev.dv_xname);
+		    sc->dv_name);
 		goto out;
 
 	case NCR_RESELECTED:
@@ -2318,7 +2284,7 @@
 		 */
 		printf("%s: unhandled reselect continuation, "
 			"state %d, intr %02x\n",
-			sc->sc_dev.dv_xname, sc->sc_state, sc->sc_espintr);
+			sc->dv_name, sc->sc_state, sc->sc_espintr);
 		ncr53c9x_init(sc, 1);
 		goto out;
 		break;
@@ -2332,7 +2298,7 @@
 			 * Pull the brakes, i.e. reset
 			 */
 			printf("%s: target didn't send tag: %d bytes in fifo\n",
-			    sc->sc_dev.dv_xname, i);
+			    sc->dv_name, i);
 			/* Drain and display fifo */
 			while (i-- > 0)
 				printf("[%d] ", NCR_READ_REG(sc, NCR_FIFO));
@@ -2370,7 +2336,7 @@
 				 * Pull the brakes, i.e. reset
 				 */
 				printf("%s: target didn't identify\n",
-				    sc->sc_dev.dv_xname);
+				    sc->dv_name);
 				ncr53c9x_init(sc, 1);
 				goto out;
 			}
@@ -2408,7 +2374,7 @@
 				printf("%s: RESELECT: %d bytes in FIFO! "
 				    "[intr %x, stat %x, step %d, "
 				    "prevphase %x]\n",
-				    sc->sc_dev.dv_xname,
+				    sc->dv_name,
 				    nfifo,
 				    sc->sc_espintr,
 				    sc->sc_espstat,
@@ -2428,7 +2394,7 @@
 				/* IDENTIFY fail?! */
 				printf("%s: identify failed, "
 				    "state %d, intr %02x\n",
-				    sc->sc_dev.dv_xname, sc->sc_state,
+				    sc->dv_name, sc->sc_state,
 				    sc->sc_espintr);
 				ncr53c9x_init(sc, 1);
 				goto out;
@@ -2466,12 +2432,12 @@
 				if ((ti->flags & T_NEGOTIATE) == 0 &&
 				    ecb->tag[0] == 0) {
 					printf("%s: step 1 & !NEG\n",
-					    sc->sc_dev.dv_xname);
+					    sc->dv_name);
 					goto reset;
 				}
 				if (sc->sc_phase != MESSAGE_OUT_PHASE) {
 					printf("%s: !MSGOUT\n",
-					    sc->sc_dev.dv_xname);
+					    sc->dv_name);
 					goto reset;
 				}
 				if (ti->flags & T_WIDE) {
@@ -2516,7 +2482,7 @@
 				printf("(%s:%d:%d): selection failed;"
 				    " %d left in FIFO "
 				    "[intr %x, stat %x, step %d]\n",
-				    sc->sc_dev.dv_xname,
+				    sc->dv_name,
 				    periph->periph_target,
 				    periph->periph_lun,
 				    NCR_READ_REG(sc, NCR_FFLAG)
@@ -2536,7 +2502,7 @@
 					printf("(%s:%d:%d): select; "
 					    "%lu left in DMA buffer "
 					    "[intr %x, stat %x, step %d]\n",
-					    sc->sc_dev.dv_xname,
+					    sc->dv_name,
 					    periph->periph_target,
 					    periph->periph_lun,
 					    (u_long)sc->sc_cmdlen,
@@ -2558,15 +2524,15 @@
 
 			printf("%s: unexpected status after select"
 			    ": [intr %x, stat %x, step %x]\n",
-			    sc->sc_dev.dv_xname,
+			    sc->dv_name,
 			    sc->sc_espintr, sc->sc_espstat, sc->sc_espstep);
 			NCRCMD(sc, NCRCMD_FLUSH);
 			DELAY(1);
 			goto reset;
 		}
 		if (sc->sc_state == NCR_IDLE) {
-			printf("%s: stray interrupt\n", sc->sc_dev.dv_xname);
-			simple_unlock(&sc->sc_lock);
+			printf("%s: stray interrupt\n", sc->dv_name);
+			mtx_unlock(&sc->sc_lock);
 			return (0);
 		}
 		break;
@@ -2581,14 +2547,14 @@
 			if (!(sc->sc_espintr & NCRINTR_DONE)) {
 				printf("%s: ICCS: "
 				    ": [intr %x, stat %x, step %x]\n",
-				    sc->sc_dev.dv_xname,
+				    sc->dv_name,
 				    sc->sc_espintr, sc->sc_espstat,
 				    sc->sc_espstep);
 			}
 			ncr53c9x_rdfifo(sc, NCR_RDFIFO_START);
 			if (sc->sc_imlen < 2)
 				printf("%s: can't get status, only %d bytes\n", 
-				    sc->sc_dev.dv_xname, (int)sc->sc_imlen);
+				    sc->dv_name, (int)sc->sc_imlen);
 			ecb->stat = sc->sc_imess[sc->sc_imlen - 2];
 			msg = sc->sc_imess[sc->sc_imlen - 1];
 			NCR_PHASE(("<stat:(%x,%x)>", ecb->stat, msg));
@@ -2600,7 +2566,7 @@
 				sc->sc_state = NCR_CMDCOMPLETE;
 			} else
 				printf("%s: STATUS_PHASE: msg %d\n",
-				    sc->sc_dev.dv_xname, msg);
+				    sc->dv_name, msg);
 			sc->sc_imlen = 0;
 			NCRCMD(sc, NCRCMD_MSGOK);
 			goto shortcut; /* ie. wait for disconnect */
@@ -2609,7 +2575,7 @@
 
 	default:
 		printf("%s: invalid state: %d [intr %x, phase(c %x, p %x)]\n",
-			sc->sc_dev.dv_xname, sc->sc_state,
+			sc->dv_name, sc->sc_state,
 			sc->sc_espintr, sc->sc_phase, sc->sc_prevphase);
 		goto reset;
 	}
@@ -2643,7 +2609,7 @@
 			if ((sc->sc_flags & NCR_WAITI) == 0) {
 				printf("%s: MSGIN: unexpected FC bit: "
 				    "[intr %x, stat %x, step %x]\n",
-				    sc->sc_dev.dv_xname,
+				    sc->dv_name,
 				    sc->sc_espintr, sc->sc_espstat,
 				    sc->sc_espstep);
 			}
@@ -2655,7 +2621,7 @@
 		} else {
 			printf("%s: MSGIN: weird bits: "
 			    "[intr %x, stat %x, step %x]\n",
-			    sc->sc_dev.dv_xname,
+			    sc->dv_name,
 			    sc->sc_espintr, sc->sc_espstat, sc->sc_espstep);
 		}
 		sc->sc_prevphase = MESSAGE_IN_PHASE;
@@ -2750,12 +2716,12 @@
 
 	default:
 		printf("%s: unexpected bus phase; resetting\n",
-		    sc->sc_dev.dv_xname);
+		    sc->dv_name);
 		goto reset;
 	}
 
 out:
-	simple_unlock(&sc->sc_lock);
+	mtx_unlock(&sc->sc_lock);
 	return (1);
 
 reset:
@@ -2844,13 +2810,12 @@
 	struct ncr53c9x_softc *sc =
 	    (void *)periph->periph_channel->chan_adapter->adapt_dev;
 	struct ncr53c9x_tinfo *ti = &sc->sc_tinfo[periph->periph_target];
-	int s;
 
 	scsipi_printaddr(periph);
 	printf("%s: timed out [ecb %p (flags 0x%x, dleft %x, stat %x)], "
 	    "<state %d, nexus %p, phase(l %x, c %x, p %x), resid %lx, "
 	    "msg(q %x,o %x) %s>",
-	    sc->sc_dev.dv_xname,
+	    sc->dv_name,
 	    ecb, ecb->flags, ecb->dleft, ecb->stat,
 	    sc->sc_state, sc->sc_nexus,
 	    NCR_READ_REG(sc, NCR_STAT),
@@ -2861,8 +2826,7 @@
 	printf("TRACE: %s.", ecb->trace);
 #endif
 
-	s = splbio();
-	simple_lock(&sc->sc_lock);
+	mtx_lock(&sc->sc_lock);
 
 	if (ecb->flags & ECB_ABORT) {
 		/* abort timed out */
@@ -2888,8 +2852,7 @@
 		}
 	}
 
-	simple_unlock(&sc->sc_lock);
-	splx(s);
+	mtx_unlock(&sc->sc_lock);
 }
 
 static void
@@ -2899,12 +2862,11 @@
 	struct ncr53c9x_softc *sc = (struct ncr53c9x_softc *)arg;
 	struct ncr53c9x_tinfo *ti;
 	struct ncr53c9x_linfo *li;
-	int t, s;
+	int t;
 	/* Delete any structures that have not been used in 10min. */
 	time_t old = time.tv_sec - (10 * 60);
 
-	s = splbio();
-	simple_lock(&sc->sc_lock);
+	mtx_lock(&sc->sc_lock);
 	for (t = 0; t < sc->sc_ntarg; t++) {
 		ti = &sc->sc_tinfo[t];
 		li = LIST_FIRST(&ti->luns);
@@ -2923,8 +2885,7 @@
 			li = LIST_NEXT(li, link);
 		}
 	}
-	simple_unlock(&sc->sc_lock);
-	splx(s);
+	mtx_unlock(&sc->sc_lock);
 	callout_reset(&sc->sc_watchdog, 60 * hz, ncr53c9x_watch, sc);
 }
 

==== //depot/projects/scottl-esp/src/sys/dev/esp/ncr53c9xvar.h#5 (text+ko) ====

@@ -270,6 +270,7 @@
 
 struct ncr53c9x_softc {
 	device_t sc_dev;			/* us as a device */
+	char *dv_name;
 
 	struct cam_sim	*sim;			/* our scsi adapter */
 	struct cam_path	*path;			/* our scsi channel */


More information about the p4-projects mailing list