--- sys/dev/sbus/esp_sbus.c.orig Fri Jul 4 06:02:13 2003 +++ sys/dev/sbus/esp_sbus.c Wed Apr 21 16:38:19 2004 @@ -733,7 +733,7 @@ } db_printf("\n"); - for (t=0; tsc_ntarg; t++) { LIST_FOREACH(li, &sc->sc_tinfo[t].luns, link) { db_printf("t%d lun %d untagged %p busy %d used %x\n", t, (int)li->lun, li->untagged, li->busy, --- sys/dev/ic/ncr53c9xvar.h.orig Wed Oct 22 03:58:49 2003 +++ sys/dev/ic/ncr53c9xvar.h Fri Apr 23 17:34:33 2004 @@ -68,7 +68,6 @@ #define NCR53C9X_DEBUG 1 /* Wide or differential can have 16 targets */ -#define NCR_NTARG 8 #define NCR_NLUN 8 #define NCR_ABORT_TIMEOUT 2000 /* time to wait for abort */ @@ -292,7 +291,8 @@ TAILQ_HEAD(ecb_list, ncr53c9x_ecb) ready_list; struct ncr53c9x_ecb *sc_nexus; /* Current command */ - struct ncr53c9x_tinfo sc_tinfo[NCR_NTARG]; + int sc_ntarg; + struct ncr53c9x_tinfo *sc_tinfo; /* Data about the current nexus (updated for every cmd switch) */ caddr_t sc_dp; /* Current data pointer */ --- sys/dev/ic/ncr53c9x.c.orig Fri Jan 16 02:51:42 2004 +++ sys/dev/ic/ncr53c9x.c Wed Apr 21 17:01:44 2004 @@ -189,8 +189,21 @@ struct scsi_adapter *adapter; struct scsi_device *dev; { - timeout_set(&sc->sc_watchdog, ncr53c9x_watch, sc); /* + * 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); + return; + } + + printf(": %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; + + /* * Allocate SCSI message buffers. * Front-ends can override allocation to avoid alignment * handling in the DMA engines. Note that that ncr53c9x_msgout() @@ -202,23 +215,18 @@ if (sc->sc_imess == NULL) sc->sc_imess = malloc(NCR_MAX_MSG_LEN+1, M_DEVBUF, M_NOWAIT); - if (sc->sc_omess == NULL || sc->sc_imess == NULL) { + sc->sc_tinfo = malloc(sc->sc_ntarg * sizeof(sc->sc_tinfo[0]), + M_DEVBUF, M_NOWAIT); + + if (sc->sc_omess == NULL || sc->sc_imess == NULL || + sc->sc_tinfo == NULL) { printf("out of memory\n"); return; } + bzero(sc->sc_tinfo, sc->sc_ntarg * sizeof(sc->sc_tinfo[0])); - /* - * 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); - return; - } + timeout_set(&sc->sc_watchdog, ncr53c9x_watch, sc); - printf(": %s, %dMHz, SCSI ID %d\n", - ncr53c9x_variant_names[sc->sc_rev], sc->sc_freq, sc->sc_id); - sc->sc_ccf = FREQTOCCF(sc->sc_freq); /* The value *must not* be == 1. Make it 2 */ @@ -251,6 +259,7 @@ */ sc->sc_link.adapter_softc = sc; sc->sc_link.adapter_target = sc->sc_id; + sc->sc_link.adapter_buswidth = sc->sc_ntarg; sc->sc_link.adapter = adapter; sc->sc_link.device = dev; sc->sc_link.openings = 2; @@ -380,8 +389,8 @@ TAILQ_INIT(&sc->ready_list); sc->sc_nexus = NULL; - bzero(sc->sc_tinfo, sizeof(sc->sc_tinfo)); - for (r = 0; r < NCR_NTARG; r++) { + bzero(sc->sc_tinfo, sc->sc_ntarg * sizeof(sc->sc_tinfo[0])); + for (r = 0; r < sc->sc_ntarg; r++) { LIST_INIT(&sc->sc_tinfo[r].luns); } } else { @@ -392,7 +401,7 @@ ecb->xs->error = XS_TIMEOUT; ncr53c9x_done(sc, ecb); } - for (r = 0; r < 8; r++) { + for (r = 0; r < sc->sc_ntarg; r++) { LIST_FOREACH(li, &sc->sc_tinfo[r].luns, link) { if ((ecb = li->untagged)) { li->untagged = NULL; @@ -422,13 +431,13 @@ ncr53c9x_reset(sc); sc->sc_phase = sc->sc_prevphase = INVALID_PHASE; - for (r = 0; r < 8; r++) { + for (r = 0; r < sc->sc_ntarg; r++) { struct ncr53c9x_tinfo *ti = &sc->sc_tinfo[r]; /* XXX - config flags per target: low bits: no reselect; high bits: no synch */ - ti->flags = ((sc->sc_minsync && !(sc->sc_cfflags & (1<<(r+8)))) + ti->flags = ((sc->sc_minsync && !(sc->sc_cfflags & (1<<((r&7)+8)))) ? 0 : T_SYNCHOFF) | - ((sc->sc_cfflags & (1<sc_cfflags & (1<<(r&7))) ? T_RSELECTOFF : 0) | T_NEED_TO_RESET; #ifdef DEBUG if (ncr53c9x_notag) @@ -2771,7 +2780,7 @@ (sc->sc_phase & (MSGI|CDI)) == 0) { sc_print_addr(sc_link); printf("sync negotiation disabled\n"); - sc->sc_cfflags |= (1<<(sc_link->target+8)); + sc->sc_cfflags |= (1<<((sc_link->target & 7)+8)); } } @@ -2790,7 +2799,7 @@ time_t old = time.tv_sec - (10*60); s = splbio(); - for (t=0; tsc_ntarg; t++) { ti = &sc->sc_tinfo[t]; li = ti->luns.lh_first; while (li) {