Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jun 2004 03:27:21 GMT
From:      Scott Long <scottl@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 54534 for review
Message-ID:  <200406100327.i5A3RLHP034535@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=54534

Change 54534 by scottl@scottl-esp-sparc64 on 2004/06/10 03:26:41

	Provide maxsync, maxoffset, and maxwidth values for setting the
	USER/GOAL transfer settings.
	Remove dv_name from the ncr53c9x_softc and use device_print() in
	its place.
	Switch from using a private callout for each command to using the
	callout that is provided in the ccb.  This also switches from the
	callout api to the timeout api.
	Fix autosense.  Provide the correct datasize to the REQUEST_SENSE
	cdb.  Return the correct error code from the completion path.
	Remove ncr53c9x_update_xfer_mode().  NetBSD seems to need a callback
	when the transfer settings are changed, but this is not needed in CAM.
	
	Wide and sync transfers work reliably now, though it seems that a
	faster sync rate actually gives slower real performance on my test
	box.  I have no idea why this is.

Affected files ...

.. //depot/projects/scottl-esp/src/sys/dev/esp/esp_sbus.c#16 edit
.. //depot/projects/scottl-esp/src/sys/dev/esp/ncr53c9x.c#17 edit
.. //depot/projects/scottl-esp/src/sys/dev/esp/ncr53c9xvar.h#11 edit

Differences ...

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

@@ -359,6 +359,10 @@
 	 */
 	sc->sc_minsync = 1000 / sc->sc_freq;
 
+	/* limit minsync due to unsolved performance issues */
+	sc->sc_maxsync = sc->sc_minsync;
+	sc->sc_maxoffset = 15;
+
 	/*
 	 * Alas, we must now modify the value a bit, because it's
 	 * only valid when can switch on FASTCLK and FASTSCSI bits  
@@ -366,11 +370,13 @@
 	 */
 	switch (sc->sc_rev) {
 	case NCR_VARIANT_ESP100:
+		sc->sc_maxwidth = 0;
 		sc->sc_maxxfer = 64 * 1024;
 		sc->sc_minsync = 0;	/* No synch on old chip? */
 		break;
 
 	case NCR_VARIANT_ESP100A:
+		sc->sc_maxwidth = 1;
 		sc->sc_maxxfer = 64 * 1024;
 		/* Min clocks/byte is 5 */
 		sc->sc_minsync = ncr53c9x_cpb2stp(sc, 5);
@@ -378,6 +384,7 @@
 
 	case NCR_VARIANT_ESP200:
 	case NCR_VARIANT_FAS366:
+		sc->sc_maxwidth = 1;
 		sc->sc_maxxfer = 16 * 1024 * 1024;
 		/* XXX - do actually set FAST* bits */
 		break;

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

@@ -102,7 +102,7 @@
 #include <dev/esp/ncr53c9xreg.h>
 #include <dev/esp/ncr53c9xvar.h>
 
-int ncr53c9x_debug = NCR_SHOWMISC /* |NCR_SHOWPHASE|NCR_SHOWMISC|NCR_SHOWTRAC|NCR_SHOWCMDS */;
+int ncr53c9x_debug = NCR_SHOWMISC /*|NCR_SHOWPHASE|NCR_SHOWTRAC|NCR_SHOWCMDS*/;
 #ifdef DEBUG
 int ncr53c9x_notag = 0;
 #endif
@@ -125,7 +125,6 @@
 				  struct ncr53c9x_ecb *);
 static void	ncr53c9x_wrfifo(struct ncr53c9x_softc *, u_char *, int);
 static int	ncr53c9x_rdfifo(struct ncr53c9x_softc *, int);
-static void	ncr53c9x_update_xfer_mode(struct ncr53c9x_softc *, int);
 
 static struct ncr53c9x_ecb *ncr53c9x_get_ecb(struct ncr53c9x_softc *);
 static struct ncr53c9x_linfo *ncr53c9x_lunsearch(struct ncr53c9x_tinfo *,
@@ -205,18 +204,17 @@
 	struct cam_path *path;
 
 	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->dv_name, sc->sc_rev);
+		device_printf(sc->sc_dev, "unknown variant %d, devices not "
+		    "attached\n", sc->sc_rev);
 		return (EINVAL);
 	}
 
-	printf(": %s, %dMHz, SCSI ID %d\n",
+	device_printf(sc->sc_dev, "%s, %dMHz, SCSI ID %d\n",
 	    ncr53c9x_variant_names[sc->sc_rev], sc->sc_freq, sc->sc_id);
 
 	sc->sc_ntarg = (sc->sc_rev == NCR_VARIANT_FAS366) ? 16 : 8;
@@ -280,7 +278,7 @@
 		return (ENOMEM);
 
 	sim = cam_sim_alloc(ncr53c9x_action, ncr53c9x_poll, "esp", sc,
-			    device_get_unit(sc->sc_dev), 256, 1, devq);
+			    device_get_unit(sc->sc_dev), 256, 256, devq);
 	if (sim == NULL) {
 		cam_simq_free(devq);
 		return (ENOMEM);
@@ -386,8 +384,8 @@
 		break;
 
 	default:
-		printf("%s: unknown revision code, assuming ESP100\n",
-		    sc->dv_name);
+		device_printf(sc->sc_dev, "unknown revision code, "
+			      "assuming ESP100\n");
 		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);
@@ -398,12 +396,11 @@
 		NCR_WRITE_REG(sc, NCR_AMDCFG4, sc->sc_cfg4);
 
 #if 0
-	printf("%s: ncr53c9x_reset: revision %d\n",
-	       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->dv_name, sc->sc_cfg1, sc->sc_cfg2, sc->sc_cfg3,
-	    sc->sc_ccf, sc->sc_timeout);
+	device_printf(sc->sc_dev, "ncr53c9x_reset: revision %d\n",
+	       sc->sc_rev);
+	device_printf(sc->sc_dev, "ncr53c9x_reset: cfg1 0x%x, cfg2 0x%x, "
+	    "cfg3 0x%x, ccf 0x%x, timeout 0x%x\n",
+	    sc->sc_cfg1, sc->sc_cfg2, sc->sc_cfg3, sc->sc_ccf, sc->sc_timeout);
 #endif
 }
 
@@ -417,8 +414,9 @@
 
 	(*sc->sc_glue->gl_dma_stop)(sc);
 
-	printf("%s: resetting SCSI bus\n", sc->dv_name);
+	NCR_MISC(("%s: resetting SCSI bus\n", device_get_nameunit(sc->sc_dev)));
 	NCRCMD(sc, NCRCMD_RSTSCSI);
+	DELAY(250000);		/* Give the bus a fighting chance to settle */
 }
 
 /*
@@ -508,8 +506,6 @@
 		ti->period = sc->sc_minsync;
 		ti->offset = 0;
 		ti->cfg3   = 0;
-
-		ncr53c9x_update_xfer_mode(sc, r);
 	}
 
 	if (doreset) {
@@ -635,8 +631,8 @@
 {
 	int target = ecb->ccb->ccb_h.target_id;
 	int lun = ecb->ccb->ccb_h.target_lun;
-	struct ncr53c9x_tinfo *ti = &sc->sc_tinfo[target];
-	int tiflags = ti->flags;
+	struct ncr53c9x_tinfo *ti;
+	int tiflags;
 	u_char *cmd;
 	int clen;
 	int selatn3, selatns;
@@ -645,14 +641,16 @@
 	NCR_TRACE(("[ncr53c9x_select(t%d,l%d,cmd:%x,tag:%x,%x)] ",
 	    target, lun, ecb->cmd.cmd.opcode, ecb->tag[0], ecb->tag[1]));
 
+	ti = &sc->sc_tinfo[target];
+	tiflags = ti->flags;
 	sc->sc_state = NCR_SELECTING;
 	/*
 	 * Schedule the timeout now, the first time we will go away
 	 * expecting to come back due to an interrupt, because it is
 	 * always possible that the interrupt may never happen.
 	 */
-	callout_reset(&ecb->ecb_callout, mstohz(ecb->timeout),
-		      ncr53c9x_timeout, ecb);
+	ecb->ccb->ccb_h.timeout_ch =
+	    timeout(ncr53c9x_timeout, sc, mstohz(ecb->timeout));
 
 	/*
 	 * The docs say the target register is never reset, and I
@@ -839,7 +837,8 @@
 		struct ccb_pathinq *cpi = &ccb->cpi;
 
 		cpi->version_num = 1;
-		cpi->hba_inquiry =
+		cpi->hba_inquiry = PI_SDTR_ABLE/*|PI_TAG_ABLE*/;
+		cpi->hba_inquiry |=
 		    (sc->sc_rev == NCR_VARIANT_FAS366) ? PI_WIDE_16 : 0;
 		cpi->target_sprt = 0;
 		cpi->hba_misc = 0;
@@ -865,10 +864,22 @@
 
 		ti = &sc->sc_tinfo[ccb->ccb_h.target_id];
 
-		cts->sync_period = ti->period;
-		cts->sync_offset = ti->offset;
-		cts->bus_width = ti->width;
-		cts->flags |= CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB;
+		if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) {
+			cts->sync_period = ti->period;
+			cts->sync_offset = ti->offset;
+			cts->bus_width = ti->width;
+			if ((ti->flags & T_TAG) != 0)
+				cts->flags |=
+				    (CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB);
+			else
+				cts->flags &=
+				    ~(CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB);
+		} else {
+			cts->sync_period = sc->sc_maxsync;
+			cts->sync_offset = sc->sc_maxoffset;
+			cts->bus_width = sc->sc_maxwidth;
+			cts->flags |= (CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB);
+		}
 		cts->valid = CCB_TRANS_BUS_WIDTH_VALID |
 			     CCB_TRANS_SYNC_RATE_VALID |
 			     CCB_TRANS_SYNC_OFFSET_VALID |
@@ -880,17 +891,20 @@
 		return;
 	}
 	case XPT_ABORT:
+		printf("XPT_ABORT called\n");
 		ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
 		mtx_unlock(&sc->sc_lock);
 		xpt_done(ccb);
 		return;
 	case XPT_TERM_IO:
+		printf("XPT_TERM_IO called\n");
 		ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
 		mtx_unlock(&sc->sc_lock);
 		xpt_done(ccb);
 		return;
+	case XPT_RESET_DEV:
+		printf("XPT_RESET_DEV called\n");
 	case XPT_SCSI_IO:
-	case XPT_RESET_DEV:
 	{
 		struct ccb_scsiio *csio;
 
@@ -953,15 +967,12 @@
 		int target = ccb->ccb_h.target_id;
 
 		ti = &sc->sc_tinfo[target];
-		ti->flags &= ~(T_NEGOTIATE|T_SYNCMODE);
-		ti->period = 0;
-		ti->offset = 0;
 
 		if ((cts->valid & CCB_TRANS_TQ_VALID) != 0) {
 			if ((sc->sc_cfflags & (1<<((target & 7) + 16))) == 0 &&
 			    (cts->flags & CCB_TRANS_TAG_ENB)) {
 				NCR_MISC(("%s: target %d: tagged queuing\n",
-				    sc->dv_name, target));
+				    device_get_nameunit(sc->sc_dev), target));
 				ti->flags |= T_TAG;
 			} else
 				ti->flags &= ~T_TAG;
@@ -970,7 +981,7 @@
 		if ((cts->valid & CCB_TRANS_BUS_WIDTH_VALID) != 0) {
 			if (cts->bus_width != 0) {
 				NCR_MISC(("%s: target %d: wide negotiation\n",
-				    sc->dv_name, target));
+				    device_get_nameunit(sc->sc_dev), target));
 				if (sc->sc_rev == NCR_VARIANT_FAS366) {
 					ti->flags |= T_WIDE;
 					ti->width = 1;
@@ -983,23 +994,17 @@
 
 		if ((cts->valid & CCB_TRANS_SYNC_RATE_VALID) != 0) {
 			NCR_MISC(("%s: target %d: sync period negotiation\n",
-			    sc->dv_name, target));
+			    device_get_nameunit(sc->sc_dev), target));
 			ti->flags |= T_NEGOTIATE;
 			ti->period = cts->sync_period;
 		}
 
 		if ((cts->valid & CCB_TRANS_SYNC_OFFSET_VALID) != 0) {
 			NCR_MISC(("%s: target %d: sync offset negotiation\n",
-			    sc->dv_name, target));
+			    device_get_nameunit(sc->sc_dev), target));
 			ti->flags |= T_NEGOTIATE;
-			ti->period = cts->sync_offset;
+			ti->offset = cts->sync_offset;
 		}
-		/*
-		 * If we're not going to negotiate, send the notification
-		 * now, since it won't happen later.
-		 */
-		if ((ti->flags & T_NEGOTIATE) == 0)
-			ncr53c9x_update_xfer_mode(sc, target);
 
 		mtx_unlock(&sc->sc_lock);
 		ccb->ccb_h.status = CAM_REQ_CMP;
@@ -1008,7 +1013,7 @@
 	}
 
 	default:
-		printf("%s: Unhandled function code %d\n", sc->dv_name,
+		device_printf(sc->sc_dev, "Unhandled function code %d\n",
 		       ccb->ccb_h.func_code);
 		ccb->ccb_h.status = CAM_PROVIDE_FAIL;
 		mtx_unlock(&sc->sc_lock);
@@ -1019,35 +1024,6 @@
 	mtx_unlock(&sc->sc_lock);
 }
 
-static void
-ncr53c9x_update_xfer_mode(sc, target)
-	struct ncr53c9x_softc *sc;
-	int target;
-{
-#if 0
-	struct scsipi_xfer_mode xm;
-	struct ncr53c9x_tinfo *ti = &sc->sc_tinfo[target];
-
-	xm.xm_target = target;
-	xm.xm_mode = 0;
-	xm.xm_period = 0;
-	xm.xm_offset = 0;
-
-	if (ti->flags & T_SYNCMODE) {
-		xm.xm_mode |= PERIPH_CAP_SYNC;
-		xm.xm_period = ti->period;
-		xm.xm_offset = ti->offset;
-	}
-	if (ti->width)
-		xm.xm_mode |= PERIPH_CAP_WIDE16;
-
-	if ((ti->flags & (T_RSELECTOFF|T_TAG)) == T_TAG)
-		xm.xm_mode |= PERIPH_CAP_TQING;
-
-	scsipi_async_event(&sc->sc_channel, ASYNC_EVENT_XFER_MODE, &xm);
-#endif
-}
-
 /*
  * Used when interrupt driven I/O isn't allowed, e.g. during boot.
  */
@@ -1182,7 +1158,7 @@
 	memset(ss, 0, sizeof(*ss));
 	ss->opcode = REQUEST_SENSE;
 	ss->byte2 = ccb->ccb_h.target_lun << SCSI_CMD_LUN_SHIFT;
-	ss->length = sizeof(struct scsi_request_sense);
+	ss->length = sizeof(struct scsi_sense_data);
 	ecb->clen = sizeof(*ss);
 	ecb->daddr = (char *)&ecb->ccb->csio.sense_data;
 	ecb->dleft = sizeof(struct scsi_sense_data);
@@ -1224,7 +1200,7 @@
 	lun = ccb->ccb_h.target_lun;
 	li  = TINFO_LUN(ti, lun);
 
-	callout_stop(&ecb->ecb_callout);
+	untimeout(ncr53c9x_timeout, sc, ccb->ccb_h.timeout_ch);
 
 	/*
 	 * Now, if we've come here with no error code, i.e. we've kept the
@@ -1238,12 +1214,15 @@
 		if ((ecb->flags & ECB_ABORT) != 0) {
 			ccb->ccb_h.status = CAM_CMD_TIMEOUT;
 		} else if ((ecb->flags & ECB_SENSE) != 0) {
-			ccb->ccb_h.status = CAM_AUTOSENSE_FAIL;
 		} else if (ecb->stat == SCSI_STATUS_CHECK_COND) {
-			/* First, save the return values */
-			ccb->csio.resid = ecb->dleft;
-			ncr53c9x_sense(sc, ecb);
-			return;
+			if ((ecb->flags & ECB_SENSE) != 0)
+				ccb->ccb_h.status = CAM_AUTOSENSE_FAIL;
+			else {
+				/* First, save the return values */
+				ccb->csio.resid = ecb->dleft;
+				ncr53c9x_sense(sc, ecb);
+				return;
+			}
 		} else {
 			ccb->csio.resid = ecb->dleft;
 		}
@@ -1476,9 +1455,8 @@
 		 */
 		selid = sc->sc_selid & ~(1 << sc->sc_id);
 		if (selid & (selid - 1)) {
-			printf("%s: reselect with invalid selid %02x;"
-			    " sending DEVICE RESET\n",
-			    sc->dv_name, selid);
+			device_printf(sc->sc_dev, "reselect with invalid "
+			    "selid %02x; sending DEVICE RESET\n", selid);
 			goto reset;
 		}
 
@@ -1512,9 +1490,9 @@
 			ecb = li->queued[tagid];
 	}
 	if (ecb == NULL) {
-		printf("%s: reselect from target %d lun %d tag %x:%x "
-		    "with no nexus; sending ABORT\n",
-		    sc->dv_name, target, lun, tagtype, tagid);
+		device_printf(sc->sc_dev, "reselect from target %d lun %d "
+		    "tag %x:%x with no nexus; sending ABORT\n",
+		    target, lun, tagtype, tagid);
 		goto abort;
 	}
 
@@ -1578,8 +1556,7 @@
 	NCR_TRACE(("[ncr53c9x_msgin(curmsglen:%ld)] ", (long)sc->sc_imlen));
 
 	if (sc->sc_imlen == 0) {
-		printf("%s: msgin: no msg byte available\n",
-		    sc->dv_name);
+		device_printf(sc->sc_dev, "msgin: no msg byte available\n");
 		return;
 	}
 
@@ -1591,9 +1568,8 @@
 	 */
 	if (sc->sc_prevphase != MESSAGE_IN_PHASE &&
 	    sc->sc_state != NCR_RESELECTED) {
-		printf("%s: phase change, dropping message, "
-		    "prev %d, state %d\n",
-		    sc->dv_name, sc->sc_prevphase, sc->sc_state);
+		device_printf(sc->sc_dev, "phase change, dropping message, "
+		    "prev %d, state %d\n", sc->sc_prevphase, sc->sc_state);
 		sc->sc_flags &= ~NCR_DROP_MSGI;
 		sc->sc_imlen = 0;
 	}
@@ -1685,8 +1661,8 @@
 				 *  - Disable tagged queuing for the target
 				 *  - Dequeue ecb from the queued array.
 				 */
-				printf("%s: tagged queuing rejected: "
-				    "target %d\n", sc->dv_name, 
+				device_printf(sc->sc_dev, "tagged queuing "
+				    "rejected: target %d\n",
 				    ecb->ccb->ccb_h.target_id);
 
 				NCR_MSGS(("(rejected sent tag)"));
@@ -1706,20 +1682,18 @@
 				break;
 
 			case SEND_SDTR:
-				printf("%s: sync transfer rejected: "
-				    "target %d\n", sc->dv_name, 
+				device_printf(sc->sc_dev, "sync transfer "
+				    "rejected: target %d\n",
 				    ecb->ccb->ccb_h.target_id);
 
 				sc->sc_flags &= ~NCR_SYNCHNEGO;
 				ti->flags &= ~(T_NEGOTIATE | T_SYNCMODE);
 				ncr53c9x_setsync(sc, ti);
-				ncr53c9x_update_xfer_mode(sc,
-				    ecb->ccb->ccb_h.target_id);
 				break;
 
 			case SEND_WDTR:
-				printf("%s: wide transfer rejected: "
-				    "target %d\n", sc->dv_name, 
+				device_printf(sc->sc_dev, "wide transfer "
+				    "rejected: target %d\n",
 				    ecb->ccb->ccb_h.target_id);
 				ti->flags &= ~(T_WIDE | T_WDTRSENT);
 				ti->width = 0;
@@ -1821,16 +1795,14 @@
 						ti->flags |= T_SYNCMODE;
 					}
 				}
-				ncr53c9x_update_xfer_mode(sc,
-				    ecb->ccb->ccb_h.target_id);
 				sc->sc_flags &= ~NCR_SYNCHNEGO;
 				ncr53c9x_setsync(sc, ti);
 				break;
 
 			case MSG_EXT_WDTR:
 #ifdef NCR53C9X_DEBUG
-				printf("%s: wide mode %d\n",
-				       sc->dv_name, sc->sc_imess[3]);
+				device_printf(sc->sc_dev, "wide mode %d\n",
+				    sc->sc_imess[3]);
 #endif
 				if (sc->sc_imess[3] == 1) {
 					ti->cfg3 |= NCRFASCFG3_EWIDE;
@@ -1868,10 +1840,9 @@
 		 */ 
 		if ((sc->sc_imess[0] != MSG_SIMPLE_Q_TAG) ||
 		    (sc->sc_msgify == 0)) {
-			printf("%s: TAG reselect without IDENTIFY;"
-			    " MSG %x;"
-			    " sending DEVICE RESET\n",
-			     sc->dv_name, sc->sc_imess[0]);
+			device_printf(sc->sc_dev, "TAG reselect without "
+			    "IDENTIFY; MSG %x; sending DEVICE RESET\n",
+			     sc->sc_imess[0]);
 			goto reset;
 		}
 		(void) ncr53c9x_reselect(sc, sc->sc_msgify,
@@ -1882,18 +1853,16 @@
 		if (MSG_ISIDENTIFY(sc->sc_imess[1])) {
 			sc->sc_msgify = sc->sc_imess[1];
 		} else {
-			printf("%s: reselect without IDENTIFY;"
-			    " MSG %x;"
-			    " sending DEVICE RESET\n",
-			    sc->dv_name, sc->sc_imess[1]);
+			device_printf(sc->sc_dev, "reselect without IDENTIFY;"
+			    " MSG %x; sending DEVICE RESET\n", sc->sc_imess[1]);
 			goto reset;
 		}
 		(void) ncr53c9x_reselect(sc, sc->sc_msgify, 0, 0);
 		break;
 
 	default:
-		printf("%s: unexpected MESSAGE IN; sending DEVICE RESET\n",
-		    sc->dv_name);
+		device_printf(sc->sc_dev, "unexpected MESSAGE IN; "
+		    "sending DEVICE RESET\n");
 	reset:
 		ncr53c9x_sched_msgout(SEND_DEV_RESET);
 		break;
@@ -1950,8 +1919,8 @@
 			ncr53c9x_sched_msgout(sc->sc_msgoutq);
 			goto new;
 		} else {
-			printf("%s at line %d: unexpected MESSAGE OUT phase\n",
-			    sc->dv_name, __LINE__);
+			device_printf(sc->sc_dev, "at line %d: unexpected "
+			    "MESSAGE OUT phase\n", __LINE__);
 		}
 	}
 
@@ -1987,8 +1956,8 @@
 			break;
                 case SEND_IDENTIFY:
                         if (sc->sc_state != NCR_CONNECTED) {
-                                printf("%s at line %d: no nexus\n",
-                                    sc->dv_name, __LINE__);
+                                device_printf(sc->sc_dev, "at line %d: no "
+				    "nexus\n", __LINE__);
                         }
                         ecb = sc->sc_nexus;
                         sc->sc_omess[0] =
@@ -1996,8 +1965,8 @@
                         break;
 		case SEND_TAG:
 			if (sc->sc_state != NCR_CONNECTED) {
-				printf("%s at line %d: no nexus\n",
-				    sc->dv_name, __LINE__);
+				device_printf(sc->sc_dev, "at line %d: no "
+				    "nexus\n", __LINE__);
 			}
 			ecb = sc->sc_nexus;
 			sc->sc_omess[0] = ecb->tag[0];
@@ -2010,7 +1979,6 @@
 			ecb = sc->sc_nexus;
 			ti = &sc->sc_tinfo[ecb->ccb->ccb_h.target_id];
 			ti->flags &= ~T_SYNCMODE;
-			ncr53c9x_update_xfer_mode(sc,ecb->ccb->ccb_h.target_id);
 			if ((ti->flags & T_SYNCHOFF) == 0)
 				/* We can re-start sync negotiation */
 				ti->flags |= T_NEGOTIATE;
@@ -2133,7 +2101,7 @@
 			DELAY(1);
 		}
 		if (sc->sc_state != NCR_SBR) {
-			printf("%s: SCSI bus reset\n", sc->dv_name);
+			device_printf(sc->sc_dev, "SCSI bus reset\n");
 			ncr53c9x_init(sc, 0); /* Restart everything */
 			goto out;
 		}
@@ -2144,7 +2112,7 @@
 #endif
 		if (sc->sc_nexus != NULL)
 			panic("%s: nexus in reset state",
-			    sc->dv_name);
+			    device_get_nameunit(sc->sc_dev));
 		goto sched;
 	}
 
@@ -2177,16 +2145,16 @@
 				 * another target.
 				 */
 #ifdef DEBUG
-				printf("%s: ESP100 work-around activated\n",
-					sc->dv_name);
+				device_printf(sc->sc_dev, "ESP100 work-around "
+				    "activated\n");
 #endif
 				sc->sc_flags &= ~NCR_EXPECT_ILLCMD;
 				goto out;
 			}
 			/* illegal command, out of sync ? */
-			printf("%s: illegal command: 0x%x "
+			device_printf(sc->sc_dev, "illegal command: 0x%x "
 			    "(state %d, phase %x, prevphase %x)\n",
-			    sc->dv_name, sc->sc_lastcmd,
+			    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);
@@ -2208,8 +2176,7 @@
 	if (NCRDMA_ISACTIVE(sc)) {
 		int r = NCRDMA_INTR(sc);
 		if (r == -1) {
-			printf("%s: DMA error; resetting\n",
-			    sc->dv_name);
+			device_printf(sc->sc_dev, "DMA error; resetting\n");
 			ncr53c9x_init(sc, 1);
 			goto out;
 		}
@@ -2237,10 +2204,9 @@
 				 * is not MESSAGE IN.
 				 */
 				if (sc->sc_phase != MESSAGE_IN_PHASE)
-					printf("%s: !TC on MSG OUT"
+					device_printf(sc->sc_dev,"!TC on MSGOUT"
 					    " [intr %x, stat %x, step %d]"
 					    " prevphase %x, resid %lx\n",
-					    sc->dv_name,
 					    sc->sc_espintr,
 					    sc->sc_espstat,
 					    sc->sc_espstep,
@@ -2253,10 +2219,9 @@
 				 * if the DMA counter and TC bit
 				 * appear to be out of sync.
 				 */
-				printf("%s: !TC on DATA XFER"
+				device_printf(sc->sc_dev, "!TC on DATA XFER"
 				    " [intr %x, stat %x, step %d]"
 				    " prevphase %x, resid %x\n",
-				    sc->dv_name,
 				    sc->sc_espintr,
 				    sc->sc_espstat,
 				    sc->sc_espstep,
@@ -2270,7 +2235,7 @@
 	 * Check for less serious errors.
 	 */
 	if ((sc->sc_espstat & NCRSTAT_PE) != 0) {
-		printf("%s: SCSI bus parity error\n", sc->dv_name);
+		device_printf(sc->sc_dev, "SCSI bus parity error\n");
 		if (sc->sc_prevphase == MESSAGE_IN_PHASE)
 			ncr53c9x_sched_msgout(SEND_PARITY_ERROR);
 		else
@@ -2343,18 +2308,19 @@
 				 * disconnecting, and this is necessary
 				 * to clean up their state.
 				 */
-				printf("%s: unexpected disconnect "
-			"[state %d, intr %x, stat %x, phase(c %x, p %x)]; ",
-					sc->dv_name, sc->sc_state,
-					sc->sc_espintr, sc->sc_espstat,
-					sc->sc_phase, sc->sc_prevphase);
+				device_printf(sc->sc_dev, "unexpected "
+				    "disconnect [state %d, intr %x, stat %x, "
+				    "phase(c %x, p %x)]; ", sc->sc_state,
+				    sc->sc_espintr, sc->sc_espstat,
+				    sc->sc_phase, sc->sc_prevphase);
 
 				if ((ecb->flags & ECB_SENSE) != 0) {
 					printf("resetting\n");
 					goto reset;
 				}
 				printf("sending REQUEST SENSE\n");
-				callout_stop(&ecb->ecb_callout);
+				untimeout(ncr53c9x_timeout, sc,
+					  ecb->ccb->ccb_h.timeout_ch);
 				ncr53c9x_sense(sc, ecb);
 				goto out;
 			}
@@ -2375,17 +2341,15 @@
 	switch (sc->sc_state) {
 
 	case NCR_SBR:
-		printf("%s: waiting for SCSI Bus Reset to happen\n",
-		    sc->dv_name);
+		device_printf(sc->sc_dev, "waiting for Bus Reset to happen\n");
 		goto out;
 
 	case NCR_RESELECTED:
 		/*
 		 * we must be continuing a message ?
 		 */
-		printf("%s: unhandled reselect continuation, "
-			"state %d, intr %02x\n",
-			sc->dv_name, sc->sc_state, sc->sc_espintr);
+		device_printf(sc->sc_dev, "unhandled reselect continuation, "
+			"state %d, intr %02x\n", sc->sc_state, sc->sc_espintr);
 		ncr53c9x_init(sc, 1);
 		goto out;
 		break;
@@ -2398,8 +2362,8 @@
 			 * Things are seriously fucked up.
 			 * Pull the brakes, i.e. reset
 			 */
-			printf("%s: target didn't send tag: %d bytes in fifo\n",
-			    sc->dv_name, i);
+			device_printf(sc->sc_dev, "target didn't send tag: %d "
+			    "bytes in fifo\n", i);
 			/* Drain and display fifo */
 			while (i-- > 0)
 				printf("[%d] ", NCR_READ_REG(sc, NCR_FIFO));
@@ -2424,7 +2388,8 @@
 			 */
 			if (sc->sc_state == NCR_SELECTING) {
 				NCR_INTS(("backoff selector "));
-				callout_stop(&ecb->ecb_callout);
+				untimeout(ncr53c9x_timeout, sc,
+					  ecb->ccb->ccb_h.timeout_ch);
 				ncr53c9x_dequeue(sc, ecb);
 				TAILQ_INSERT_HEAD(&sc->ready_list, ecb, chain);
 				ecb->flags |= ECB_READY;
@@ -2436,8 +2401,8 @@
 				 * Things are seriously fucked up.
 				 * Pull the brakes, i.e. reset
 				 */
-				printf("%s: target didn't identify\n",
-				    sc->dv_name);
+				device_printf(sc->sc_dev, "target didn't "
+				    "identify\n");
 				ncr53c9x_init(sc, 1);
 				goto out;
 			}
@@ -2472,10 +2437,9 @@
 				nfifo = ncr53c9x_rdfifo(sc, NCR_RDFIFO_START);
 
 			if (nfifo != 2) {
-				printf("%s: RESELECT: %d bytes in FIFO! "
-				    "[intr %x, stat %x, step %d, "
+				device_printf(sc->sc_dev, "RESELECT: %d bytes "
+				    "in FIFO! [intr %x, stat %x, step %d, "
 				    "prevphase %x]\n",
-				    sc->dv_name,
 				    nfifo,
 				    sc->sc_espintr,
 				    sc->sc_espstat,
@@ -2493,9 +2457,8 @@
 			if (sc->sc_state != NCR_CONNECTED &&
 			    sc->sc_state != NCR_IDENTIFIED) {
 				/* IDENTIFY fail?! */
-				printf("%s: identify failed, "
-				    "state %d, intr %02x\n",
-				    sc->dv_name, sc->sc_state,
+				device_printf(sc->sc_dev, "identify failed, "
+				    "state %d, intr %02x\n", sc->sc_state,
 				    sc->sc_espintr);
 				ncr53c9x_init(sc, 1);
 				goto out;
@@ -2531,13 +2494,12 @@
 			case 1:
 				if ((ti->flags & T_NEGOTIATE) == 0 &&
 				    ecb->tag[0] == 0) {
-					printf("%s: step 1 & !NEG\n",
-					    sc->dv_name);
+					device_printf(sc->sc_dev, "step 1 & "
+					    "!NEG\n");
 					goto reset;
 				}
 				if (sc->sc_phase != MESSAGE_OUT_PHASE) {
-					printf("%s: !MSGOUT\n",
-					    sc->dv_name);
+					device_printf(sc->sc_dev, "!MSGOUT\n");
 					goto reset;
 				}
 				if (ti->flags & T_WIDE) {
@@ -2546,8 +2508,6 @@
 				}
 				if (ti->flags & T_NEGOTIATE) {
 					/* Start negotiating */
-					ti->period = sc->sc_minsync;
-					ti->offset = 15;
 					sc->sc_flags |= NCR_SYNCHNEGO;
 					if (ecb->tag[0])
 						ncr53c9x_sched_msgout(
@@ -2582,7 +2542,7 @@
 				printf("(%s:%d:%d): selection failed;"
 				    " %d left in FIFO "
 				    "[intr %x, stat %x, step %d]\n",
-				    sc->dv_name,
+				    device_get_nameunit(sc->sc_dev),
 				    ecb->ccb->ccb_h.target_id,
 				    ecb->ccb->ccb_h.target_lun,
 				    NCR_READ_REG(sc, NCR_FFLAG)
@@ -2602,7 +2562,7 @@
 					printf("(%s:%d:%d): select; "
 					    "%lu left in DMA buffer "
 					    "[intr %x, stat %x, step %d]\n",
-					    sc->dv_name,
+					    device_get_nameunit(sc->sc_dev),
 					    ecb->ccb->ccb_h.target_id,
 					    ecb->ccb->ccb_h.target_lun,
 					    (u_long)sc->sc_cmdlen,
@@ -2622,16 +2582,15 @@
 
 		} else {
 
-			printf("%s: unexpected status after select"
-			    ": [intr %x, stat %x, step %x]\n",
-			    sc->dv_name,
+			device_printf(sc->sc_dev, "unexpected status after "
+			    "select: [intr %x, stat %x, step %x]\n",
 			    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->dv_name);
+			device_printf(sc->sc_dev, "stray interrupt\n");
 			mtx_unlock(&sc->sc_lock);
 			return;
 		}
@@ -2645,16 +2604,15 @@
 			sc->sc_flags &= ~NCR_ICCS;
 
 			if (!(sc->sc_espintr & NCRINTR_DONE)) {
-				printf("%s: ICCS: "
+				device_printf(sc->sc_dev, "ICCS: "
 				    ": [intr %x, stat %x, step %x]\n",
-				    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->dv_name, (int)sc->sc_imlen);
+				device_printf(sc->sc_dev, "can't get status, "
+				    "only %d bytes\n", (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));
@@ -2665,8 +2623,8 @@
 					ecb->ccb->csio.resid = ecb->dleft;
 				sc->sc_state = NCR_CMDCOMPLETE;
 			} else
-				printf("%s: STATUS_PHASE: msg %d\n",
-				    sc->dv_name, msg);
+				device_printf(sc->sc_dev, "STATUS_PHASE: "
+				    "msg %d\n", msg);
 			sc->sc_imlen = 0;
 			NCRCMD(sc, NCRCMD_MSGOK);
 			goto shortcut; /* ie. wait for disconnect */
@@ -2674,9 +2632,9 @@
 		break;
 
 	default:
-		printf("%s: invalid state: %d [intr %x, phase(c %x, p %x)]\n",
-			sc->dv_name, sc->sc_state,
-			sc->sc_espintr, sc->sc_phase, sc->sc_prevphase);
+		device_printf(sc->sc_dev, "invalid state: %d [intr %x, "
+		    "phase(c %x, p %x)]\n", sc->sc_state,
+		    sc->sc_espintr, sc->sc_phase, sc->sc_prevphase);
 		goto reset;
 	}
 
@@ -2707,9 +2665,8 @@
 			NCRCMD(sc, NCRCMD_TRANS);
 		} else if ((sc->sc_espintr & NCRINTR_FC) != 0) {
 			if ((sc->sc_flags & NCR_WAITI) == 0) {
-				printf("%s: MSGIN: unexpected FC bit: "
-				    "[intr %x, stat %x, step %x]\n",
-				    sc->dv_name,
+				device_printf(sc->sc_dev, "MSGIN: unexpected "
+				    "FC bit: [intr %x, stat %x, step %x]\n",
 				    sc->sc_espintr, sc->sc_espstat,
 				    sc->sc_espstep);
 			}
@@ -2719,9 +2676,8 @@
 			    NCR_RDFIFO_CONTINUE : NCR_RDFIFO_START);
 			ncr53c9x_msgin(sc);
 		} else {
-			printf("%s: MSGIN: weird bits: "
+			device_printf(sc->sc_dev, "MSGIN: weird bits: "
 			    "[intr %x, stat %x, step %x]\n",
-			    sc->dv_name,
 			    sc->sc_espintr, sc->sc_espstat, sc->sc_espstep);
 		}
 		sc->sc_prevphase = MESSAGE_IN_PHASE;
@@ -2815,8 +2771,7 @@
 		break;
 
 	default:
-		printf("%s: unexpected bus phase; resetting\n",
-		    sc->dv_name);
+		device_printf(sc->sc_dev, "unexpected bus phase; resetting\n");
 		goto reset;
 	}
 
@@ -2887,8 +2842,8 @@
 		/*
 		 * Reschedule timeout.
 		 */
-		callout_reset(&ecb->ecb_callout, mstohz(ecb->timeout),
-		    ncr53c9x_timeout, ecb);
+		ecb->ccb->ccb_h.timeout_ch =
+		    timeout(ncr53c9x_timeout, sc, mstohz(ecb->timeout));
 	} else {
 		/*
 		 * Just leave the command where it is.
@@ -2910,10 +2865,9 @@
 	struct ncr53c9x_tinfo *ti = &sc->sc_tinfo[ccb->ccb_h.target_id];
 
 	xpt_print_path(ccb->ccb_h.path);
-	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->dv_name,
+	device_printf(sc->sc_dev, "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>",
 	    ecb, ecb->flags, ecb->dleft, ecb->stat,
 	    sc->sc_state, sc->sc_nexus,
 	    NCR_READ_REG(sc, NCR_STAT),
@@ -2946,7 +2900,6 @@
 			printf("sync negotiation disabled\n");
 			sc->sc_cfflags |=
 			    (1 << ((ccb->ccb_h.target_id & 7) + 8));
-			ncr53c9x_update_xfer_mode(sc, ccb->ccb_h.target_id);
 		}
 	}
 

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

@@ -119,7 +119,6 @@
 #define	ECB_RESET		0x80
 #define	ECB_TENTATIVE_DONE	0x100
 	int timeout;
-	struct callout ecb_callout;
 
 	struct {
 		u_char	msg[3];			/* Selection Id msg and tags */
@@ -272,7 +271,6 @@
 
 struct ncr53c9x_softc {
 	device_t sc_dev;			/* us as a device */
-	const char *dv_name;
 
 	struct cam_sim	*sc_sim;		/* our scsi adapter */
 	struct cam_path	*sc_path;		/* our scsi channel */
@@ -342,6 +340,9 @@
 	int sc_features;	/* Chip features */
 	int sc_minsync;		/* Minimum sync period / 4 */
 	int sc_maxxfer;		/* Maximum transfer size */
+	int sc_maxsync;		/* Maximum sync period */
+	int sc_maxoffset;	/* Maximum offset */
+	int sc_maxwidth;	/* Maximum width */
 
 	struct mtx sc_lock;	/* driver mutex */
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406100327.i5A3RLHP034535>