Subject: Re: kern/31990: esiop leaves b_resid non-zero
To: None <bouyer@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: netbsd-bugs
Date: 11/09/2005 19:01:02
The following reply was made to PR kern/31990; it has been noted by GNATS.

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org
Subject: Re: kern/31990: esiop leaves b_resid non-zero
Date: Wed, 9 Nov 2005 19:59:56 +0100

 --RnlQjJ0d97Da+TV1
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 OK, I think I understand the problem, but I can't reproduce it. It's
 probably dependant on the hard drive.
 
 I think that what happens here is that the drive disconnects after the
 last transfert, before the status phase and without a save data pointer
 message (I'm not sure why a drive would do this for a read, though).
 When the drive reconnects to send the status, the offset stored in
 SCRATCHA1 is reset to 0, so the driver thinks that no transfers occured.
 
 The attached patch should fix this, can you try it ?
 
 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --
 
 --RnlQjJ0d97Da+TV1
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="diff.current"
 
 Index: ic/esiop.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/esiop.c,v
 retrieving revision 1.33
 diff -u -r1.33 esiop.c
 --- ic/esiop.c	23 Mar 2005 21:23:15 -0000	1.33
 +++ ic/esiop.c	9 Nov 2005 17:52:37 -0000
 @@ -1125,6 +1125,16 @@
  		esiop_lun->active = NULL;
  	offset = bus_space_read_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh,
  	    SIOP_SCRATCHA + 1);
 +	/*
 +	 * if we got a disconnect between the last data phase
 +	 * and the status phase, offset will be 0. In this
 +	 * case, cmd_tables->offset will have the proper value 
 +	 * if it got updated by the controller
 +	 */
 +	if (offset == 0 &&
 +	    esiop_cmd->cmd_tables->offset != htole32(SIOP_NOOFFSET))
 +		offset = le32toh(esiop_cmd->cmd_tables->offset);
 +
  	esiop_scsicmd_end(esiop_cmd, offset);
  	if (freetarget && esiop_target->target_c.status == TARST_PROBING)
  		esiop_del_dev(sc, target, lun);
 @@ -1953,15 +1963,20 @@
  		xfer->siop_tables.t_status.count= htole32(1);
  		xfer->siop_tables.t_status.addr = htole32(dsa +
  			offsetof(struct siop_common_xfer, status));
 +		xfer->siop_tables.t_offset.count= htole32(1);
 +		xfer->siop_tables.t_offset.addr = htole32(dsa +
 +			offsetof(struct siop_common_xfer, offset));
  
  		s = splbio();
  		TAILQ_INSERT_TAIL(&sc->free_list, &newcbd->cmds[i], next);
  		splx(s);
  #ifdef SIOP_DEBUG
 -		printf("tables[%d]: in=0x%x out=0x%x status=0x%x\n", i,
 +		printf("tables[%d]: in=0x%x out=0x%x status=0x%x "
 +		    "offset=0x%x\n", i,
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgin.addr),
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgout.addr),
 -		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr));
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr,
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_offset.addr));
  #endif
  	}
  	s = splbio();
 Index: ic/siop.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siop.c,v
 retrieving revision 1.78
 diff -u -r1.78 siop.c
 --- ic/siop.c	27 Feb 2005 00:27:02 -0000	1.78
 +++ ic/siop.c	9 Nov 2005 17:52:37 -0000
 @@ -103,6 +103,7 @@
  static int siop_stat_intr = 0;
  static int siop_stat_intr_shortxfer = 0;
  static int siop_stat_intr_sdp = 0;
 +static int siop_stat_intr_saveoffset = 0;
  static int siop_stat_intr_done = 0;
  static int siop_stat_intr_xferdisc = 0;
  static int siop_stat_intr_lunresel = 0;
 @@ -915,6 +916,16 @@
  			    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  			CALL_SCRIPT(Ent_script_sched);
  			return 1;
 +		case A_int_saveoffset:
 +			INCSTAT(siop_stat_intr_saveoffset);
 +			offset = bus_space_read_1(sc->sc_c.sc_rt,
 +			    sc->sc_c.sc_rh, SIOP_SCRATCHA + 1);
 +#ifdef SIOP_DEBUG_DR
 +			printf("saveoffset offset %d\n", offset);
 +#endif
 +			siop_cmd->cmd_tables->status = htole32(offset);
 +			CALL_SCRIPT(Ent_script_sched);
 +			return 1;
  		case A_int_resfail:
  			printf("reselect failed\n");
  			CALL_SCRIPT(Ent_script_sched);
 @@ -939,6 +950,16 @@
  			/* update resid.  */
  			offset = bus_space_read_1(sc->sc_c.sc_rt,
  			    sc->sc_c.sc_rh, SIOP_SCRATCHA + 1);
 +			/*
 +			 * if we got a disconnect between the last data phase
 +			 * and the status phase, offset will be 0. In this
 +			 * case, cmd_tables->offset will have the proper value
 +			 * if it got updated by the controller
 +			 */
 +			if (offset == 0 && 
 +			    siop_cmd->cmd_tables->offset !=
 +			    htole32(SIOP_NOOFFSET))
 +				offset = le32toh(siop_cmd->cmd_tables->offset);
  			siop_update_resid(&siop_cmd->cmd_c, offset);
  			siop_cmd->cmd_c.status = CMDST_DONE;
  			goto end;
 @@ -1686,6 +1707,9 @@
  		xfer->siop_tables.t_status.count= htole32(1);
  		xfer->siop_tables.t_status.addr = htole32(dsa +
  				offsetof(struct siop_common_xfer, status));
 +		xfer->siop_tables.t_offset.count= htole32(1);
 +		xfer->siop_tables.t_offset.addr = htole32(dsa +
 +				offsetof(struct siop_common_xfer, offset));
  		/* The select/reselect script */
  		scr = &xfer->resel[0];
  		for (j = 0; j < sizeof(load_dsa) / sizeof(load_dsa[0]); j++)
 @@ -1717,10 +1741,12 @@
  		TAILQ_INSERT_TAIL(&sc->free_list, &newcbd->cmds[i], next);
  		splx(s);
  #ifdef SIOP_DEBUG
 -		printf("tables[%d]: in=0x%x out=0x%x status=0x%x\n", i,
 +		printf("tables[%d]: in=0x%x out=0x%x status=0x%x "
 +		    "offset=0x%x\n", i,
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgin.addr),
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgout.addr),
 -		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr));
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr),
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_offset.addr));
  #endif
  	}
  	s = splbio();
 @@ -2002,6 +2028,7 @@
  	printf("siop_stat_intr_shortxfer %d\n", siop_stat_intr_shortxfer);
  	printf("siop_stat_intr_xferdisc %d\n", siop_stat_intr_xferdisc);
  	printf("siop_stat_intr_sdp %d\n", siop_stat_intr_sdp);
 +	printf("siop_stat_intr_saveoffset %d\n", siop_stat_intr_saveoffset);
  	printf("siop_stat_intr_done %d\n", siop_stat_intr_done);
  	printf("siop_stat_intr_lunresel %d\n", siop_stat_intr_lunresel);
  	printf("siop_stat_intr_qfull %d\n", siop_stat_intr_qfull);
 Index: ic/siop_common.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siop_common.c,v
 retrieving revision 1.37
 diff -u -r1.37 siop_common.c
 --- ic/siop_common.c	27 Feb 2005 00:27:02 -0000	1.37
 +++ ic/siop_common.c	9 Nov 2005 17:52:37 -0000
 @@ -315,6 +315,8 @@
  	}
  	siop_cmd->siop_tables->status =
  	    htole32(SCSI_SIOP_NOSTATUS); /* set invalid status */
 +	siop_cmd->siop_tables->offset =
 +	    htole32(SIOP_NOOFFSET); /* set invalid offset */
  
  	siop_cmd->siop_tables->cmd.count =
  	    htole32(siop_cmd->dmamap_cmd->dm_segs[0].ds_len);
 Index: ic/siopvar_common.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siopvar_common.h,v
 retrieving revision 1.32
 diff -u -r1.32 siopvar_common.h
 --- ic/siopvar_common.h	27 Feb 2005 00:27:02 -0000	1.32
 +++ ic/siopvar_common.h	9 Nov 2005 17:52:37 -0000
 @@ -56,7 +56,7 @@
  	u_int8_t msg_out[16];	/* 0 */
  	u_int8_t msg_in[16];	/* 16 */
  	u_int32_t status;	/* 32 */
 -	u_int32_t pad1;		/* 36 */
 +	u_int32_t offset;	/* 36 */
  	u_int32_t id;		/* 40 */
  	u_int32_t pad2;		/* 44 */
  	scr_table_t t_msgin;	/* 48 */
 @@ -65,13 +65,17 @@
  	scr_table_t t_msgout;	/* 72 */
  	scr_table_t cmd;	/* 80 */
  	scr_table_t t_status;	/* 88 */
 -	scr_table_t data[SIOP_NSG]; /* 96 */
 +	scr_table_t t_offset;	/* 96 */
 +	scr_table_t data[SIOP_NSG]; /* 104 */
  } __packed;
  
  /* status can hold the SCSI_* status values, and 2 additional values: */
  #define SCSI_SIOP_NOCHECK	0xfe	/* don't check the scsi status */
  #define SCSI_SIOP_NOSTATUS	0xff	/* device didn't report status */
  
 +/* offset is initialised to SIOP_NOOFFSET, used to check if it was updated */
 +#define SIOP_NOOFFSET 0xff
 +
  /*
   * This describes a command handled by the SCSI controller
   */
 Index: microcode/siop/esiop.out
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/esiop.out,v
 retrieving revision 1.13
 diff -u -r1.13 esiop.out
 --- microcode/siop/esiop.out	17 May 2004 18:38:22 -0000	1.13
 +++ microcode/siop/esiop.out	9 Nov 2005 17:52:37 -0000
 @@ -1,7 +1,7 @@
 -/*	$NetBSD: esiop.out,v 1.13 2004/05/17 18:38:22 bouyer Exp $	*/
 +/*	$NetBSD: ncr53cxxx.c,v 1.14 2005/02/11 06:21:22 simonb Exp $	*/
  /*
   *	DO NOT EDIT - this file is automatically generated.
 - *	created from esiop.ss on Mon May 17 20:37:26 2004
 + *	created from esiop.ss on Wed Nov  9 17:21:34 2005
   */
  const u_int32_t esiop_script[] = {
  	0xe15c0004, 0x00000000,			/* 000 -   0 */
 @@ -51,7 +51,7 @@
  	0x6a360000, 0x00000000,			/* 160 - 352 */
  	0x6a630000, 0x00000000,			/* 168 - 360 */
  	0x7a600400, 0x00000000,			/* 170 - 368 */
 -	0x88880000, 0x00000500,			/* 178 - 376 */
 +	0x88880000, 0x00000518,			/* 178 - 376 */
  	0x78370000, 0x00000000,			/* 180 - 384 */
  	0x60000400, 0x00000000,			/* 188 - 392 */
  	0x79360000, 0x00000000,			/* 190 - 400 */
 @@ -71,12 +71,12 @@
  	0x60000040, 0x00000000,			/* 200 - 512 */
  	0x868b0000, 0x000002c8,			/* 208 - 520 */
  	0x878b0000, 0x000002e8,			/* 210 - 528 */
 -	0x808b0000, 0x000003b8,			/* 218 - 536 */
 -	0x818b0000, 0x00000350,			/* 220 - 544 */
 -	0x828b0000, 0x00000320,			/* 228 - 552 */
 -	0x838b0000, 0x00000328,			/* 230 - 560 */
 +	0x808b0000, 0x000003d0,			/* 218 - 536 */
 +	0x818b0000, 0x00000368,			/* 220 - 544 */
 +	0x828b0000, 0x00000338,			/* 228 - 552 */
 +	0x838b0000, 0x00000340,			/* 230 - 560 */
  	0x98080000, 0x0000ffff,			/* 238 - 568 */
 -	0x88880000, 0x00000480,			/* 240 - 576 */
 +	0x88880000, 0x00000498,			/* 240 - 576 */
  	0xf2340004, 0x00000000,			/* 248 - 584 */
  	0x72690000, 0x00000000,			/* 250 - 592 */
  	0x98040000, 0x0000ff00,			/* 258 - 600 */
 @@ -150,7 +150,7 @@
  	0x745c0200, 0x00000000,			/* 478 - 1144 */
  	0x80840000, 0xfffffeb8,			/* 480 - 1152 */
  	0x7c5cfc00, 0x00000000,			/* 488 - 1160 */
 -	0x88880000, 0x000001e8,			/* 490 - 1168 */
 +	0x88880000, 0x00000200,			/* 490 - 1168 */
  	0xe15c0004, 0x00000000,			/* 498 - 1176 */
  	0x7a5c0200, 0x00000000,			/* 4a0 - 1184 */
  	0xe25c0004, 0x00000000,			/* 4a8 - 1192 */
 @@ -168,70 +168,73 @@
  	0x1f000030, 0x00000030,			/* 508 - 1288 */
  	0x808c0000, 0xfffffd28,			/* 510 - 1296 */
  	0x808c0002, 0xffffffd0,			/* 518 - 1304 */
 -	0x808c0001, 0x000001c8,			/* 520 - 1312 */
 +	0x808c0001, 0x000001e0,			/* 520 - 1312 */
  	0x98040004, 0x0000ff01,			/* 528 - 1320 */
 -	0x88880000, 0x00000190,			/* 530 - 1328 */
 +	0x88880000, 0x000001a8,			/* 530 - 1328 */
  	0x74601000, 0x00000000,			/* 538 - 1336 */
 -	0x808c0000, 0xfffffdf8,			/* 540 - 1344 */
 -	0x98080000, 0x0000ff04,			/* 548 - 1352 */
 -	0x1a000050, 0x00000050,			/* 550 - 1360 */
 -	0x80880000, 0xfffffca8,			/* 558 - 1368 */
 -	0x1b000058, 0x00000058,			/* 560 - 1376 */
 -	0x6a690000, 0x00000000,			/* 568 - 1384 */
 +	0x98040000, 0x0000ff04,			/* 540 - 1344 */
 +	0x72350000, 0x00000000,			/* 548 - 1352 */
 +	0x808c0000, 0xfffffde8,			/* 550 - 1360 */
 +	0xf2350001, 0x00000060,			/* 558 - 1368 */
 +	0x80880000, 0xfffffdd8,			/* 560 - 1376 */
 +	0x1a000050, 0x00000050,			/* 568 - 1384 */
  	0x80880000, 0xfffffc90,			/* 570 - 1392 */
 -	0x88880000, 0x000000b8,			/* 578 - 1400 */
 -	0x7a600800, 0x00000000,			/* 580 - 1408 */
 -	0x19000060, 0x00000060,			/* 588 - 1416 */
 -	0x7e350100, 0x00000000,			/* 590 - 1424 */
 -	0x7e100800, 0x00000000,			/* 598 - 1432 */
 -	0x7f110000, 0x00000000,			/* 5a0 - 1440 */
 -	0x7f120000, 0x00000000,			/* 5a8 - 1448 */
 -	0x7f130000, 0x00000000,			/* 5b0 - 1456 */
 -	0x818b0000, 0xffffffc8,			/* 5b8 - 1464 */
 -	0x88880000, 0x000000b8,			/* 5c0 - 1472 */
 -	0x7c60f700, 0x00000000,			/* 5c8 - 1480 */
 -	0x80880000, 0xfffffc30,			/* 5d0 - 1488 */
 -	0x88880000, 0x00000058,			/* 5d8 - 1496 */
 -	0x7a600800, 0x00000000,			/* 5e0 - 1504 */
 -	0x18000060, 0x00000060,			/* 5e8 - 1512 */
 -	0x7e350100, 0x00000000,			/* 5f0 - 1520 */
 -	0x7e100800, 0x00000000,			/* 5f8 - 1528 */
 -	0x7f110000, 0x00000000,			/* 600 - 1536 */
 -	0x7f120000, 0x00000000,			/* 608 - 1544 */
 -	0x7f130000, 0x00000000,			/* 610 - 1552 */
 -	0x808b0000, 0xffffffc8,			/* 618 - 1560 */
 -	0x88880000, 0x00000058,			/* 620 - 1568 */
 -	0x7c60f700, 0x00000000,			/* 628 - 1576 */
 -	0x80880000, 0xfffffbd0,			/* 630 - 1584 */
 -	0x72100000, 0x00000000,			/* 638 - 1592 */
 -	0x6a5c0000, 0x00000000,			/* 640 - 1600 */
 -	0x72110000, 0x00000000,			/* 648 - 1608 */
 -	0x6a5d0000, 0x00000000,			/* 650 - 1616 */
 -	0x72120000, 0x00000000,			/* 658 - 1624 */
 -	0x6a5e0000, 0x00000000,			/* 660 - 1632 */
 -	0x72130000, 0x00000000,			/* 668 - 1640 */
 -	0x6a5f0000, 0x00000000,			/* 670 - 1648 */
 -	0x90080000, 0x00000000,			/* 678 - 1656 */
 -	0x725c0000, 0x00000000,			/* 680 - 1664 */
 -	0x6a100000, 0x00000000,			/* 688 - 1672 */
 -	0x725d0000, 0x00000000,			/* 690 - 1680 */
 -	0x6a110000, 0x00000000,			/* 698 - 1688 */
 -	0x725e0000, 0x00000000,			/* 6a0 - 1696 */
 -	0x6a120000, 0x00000000,			/* 6a8 - 1704 */
 -	0x725f0000, 0x00000000,			/* 6b0 - 1712 */
 -	0x6a130000, 0x00000000,			/* 6b8 - 1720 */
 -	0x90080000, 0x00000000,			/* 6c0 - 1728 */
 -	0x7c027f00, 0x00000000,			/* 6c8 - 1736 */
 -	0x60000008, 0x00000000,			/* 6d0 - 1744 */
 -	0x60000040, 0x00000000,			/* 6d8 - 1752 */
 -	0x48000000, 0x00000000,			/* 6e0 - 1760 */
 -	0x90080000, 0x00000000,			/* 6e8 - 1768 */
 +	0x1b000058, 0x00000058,			/* 578 - 1400 */
 +	0x6a690000, 0x00000000,			/* 580 - 1408 */
 +	0x80880000, 0xfffffc78,			/* 588 - 1416 */
 +	0x88880000, 0x000000b8,			/* 590 - 1424 */
 +	0x7a600800, 0x00000000,			/* 598 - 1432 */
 +	0x19000068, 0x00000068,			/* 5a0 - 1440 */
 +	0x7e350100, 0x00000000,			/* 5a8 - 1448 */
 +	0x7e100800, 0x00000000,			/* 5b0 - 1456 */
 +	0x7f110000, 0x00000000,			/* 5b8 - 1464 */
 +	0x7f120000, 0x00000000,			/* 5c0 - 1472 */
 +	0x7f130000, 0x00000000,			/* 5c8 - 1480 */
 +	0x818b0000, 0xffffffc8,			/* 5d0 - 1488 */
 +	0x88880000, 0x000000b8,			/* 5d8 - 1496 */
 +	0x7c60f700, 0x00000000,			/* 5e0 - 1504 */
 +	0x80880000, 0xfffffc18,			/* 5e8 - 1512 */
 +	0x88880000, 0x00000058,			/* 5f0 - 1520 */
 +	0x7a600800, 0x00000000,			/* 5f8 - 1528 */
 +	0x18000068, 0x00000068,			/* 600 - 1536 */
 +	0x7e350100, 0x00000000,			/* 608 - 1544 */
 +	0x7e100800, 0x00000000,			/* 610 - 1552 */
 +	0x7f110000, 0x00000000,			/* 618 - 1560 */
 +	0x7f120000, 0x00000000,			/* 620 - 1568 */
 +	0x7f130000, 0x00000000,			/* 628 - 1576 */
 +	0x808b0000, 0xffffffc8,			/* 630 - 1584 */
 +	0x88880000, 0x00000058,			/* 638 - 1592 */
 +	0x7c60f700, 0x00000000,			/* 640 - 1600 */
 +	0x80880000, 0xfffffbb8,			/* 648 - 1608 */
 +	0x72100000, 0x00000000,			/* 650 - 1616 */
 +	0x6a5c0000, 0x00000000,			/* 658 - 1624 */
 +	0x72110000, 0x00000000,			/* 660 - 1632 */
 +	0x6a5d0000, 0x00000000,			/* 668 - 1640 */
 +	0x72120000, 0x00000000,			/* 670 - 1648 */
 +	0x6a5e0000, 0x00000000,			/* 678 - 1656 */
 +	0x72130000, 0x00000000,			/* 680 - 1664 */
 +	0x6a5f0000, 0x00000000,			/* 688 - 1672 */
 +	0x90080000, 0x00000000,			/* 690 - 1680 */
 +	0x725c0000, 0x00000000,			/* 698 - 1688 */
 +	0x6a100000, 0x00000000,			/* 6a0 - 1696 */
 +	0x725d0000, 0x00000000,			/* 6a8 - 1704 */
 +	0x6a110000, 0x00000000,			/* 6b0 - 1712 */
 +	0x725e0000, 0x00000000,			/* 6b8 - 1720 */
 +	0x6a120000, 0x00000000,			/* 6c0 - 1728 */
 +	0x725f0000, 0x00000000,			/* 6c8 - 1736 */
 +	0x6a130000, 0x00000000,			/* 6d0 - 1744 */
 +	0x90080000, 0x00000000,			/* 6d8 - 1752 */
 +	0x7c027f00, 0x00000000,			/* 6e0 - 1760 */
 +	0x60000008, 0x00000000,			/* 6e8 - 1768 */
  	0x60000040, 0x00000000,			/* 6f0 - 1776 */
 -	0x1f000038, 0x00000038,			/* 6f8 - 1784 */
 -	0x98080000, 0x0000ff02,			/* 700 - 1792 */
 +	0x48000000, 0x00000000,			/* 6f8 - 1784 */
 +	0x90080000, 0x00000000,			/* 700 - 1792 */
  	0x60000040, 0x00000000,			/* 708 - 1800 */
 -	0x1f000040, 0x00000040,			/* 710 - 1808 */
 -	0x98080000, 0x0000ff03,			/* 718 - 1816 */
 +	0x1f000038, 0x00000038,			/* 710 - 1808 */
 +	0x98080000, 0x0000ff02,			/* 718 - 1816 */
 +	0x60000040, 0x00000000,			/* 720 - 1824 */
 +	0x1f000040, 0x00000040,			/* 728 - 1832 */
 +	0x98080000, 0x0000ff03,			/* 730 - 1840 */
  };
  
  const u_int32_t esiop_led_on[] = {
 @@ -249,7 +252,8 @@
  #define	A_t_msg_out	0x00000048
  #define	A_t_cmd	0x00000050
  #define	A_t_status	0x00000058
 -#define	A_t_data	0x00000060
 +#define	A_t_offset	0x00000060
 +#define	A_t_data	0x00000068
  #define	A_target_id	0x00000000
  #define	A_target_luntbl	0x00000008
  #define	A_target_luntbl_tag	0x0000000c
 @@ -286,10 +290,10 @@
  #define	Ent_led_on1	0x000004b0
  #define	Ent_led_on2	0x00000050
  #define	Ent_led_off	0x00000040
 -#define	Ent_status	0x00000560
 +#define	Ent_status	0x00000578
  #define	Ent_msgin	0x00000500
  #define	Ent_msgin_ack	0x00000200
 -#define	Ent_get_extmsgdata	0x00000708
 +#define	Ent_get_extmsgdata	0x00000720
  #define	Ent_send_msgout	0x000004c8
  #define	Ent_script_sched	0x00000340
  #define	Ent_load_targtable	0x000000a0
 Index: microcode/siop/esiop.ss
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/esiop.ss,v
 retrieving revision 1.19
 diff -u -r1.19 esiop.ss
 --- microcode/siop/esiop.ss	27 Feb 2005 00:27:29 -0000	1.19
 +++ microcode/siop/esiop.ss	9 Nov 2005 17:52:37 -0000
 @@ -40,7 +40,8 @@
  ABSOLUTE t_msg_out = 72;
  ABSOLUTE t_cmd = 80;
  ABSOLUTE t_status = 88;
 -ABSOLUTE t_data = 96;
 +ABSOLUTE t_offset = 96;
 +ABSOLUTE t_data = 104;
  
  ; offsets in the per-target lun table
  ABSOLUTE target_id = 0x0;
 @@ -344,9 +345,12 @@
  	CALL REL(disconnect)		; disconnect message
  ; if we didn't get sdp, no need to interrupt
  	MOVE SCRATCHC0 & f_c_sdp TO SFBR;
 +	INT int_disc, IF not 0x00;
 +; update offset if we did some data transfer
 +	MOVE SCRATCHA1 TO SFBR;
  	JUMP REL(script_sched), if 0x00;
 -; Ok, we need to save data pointers
 -	INT int_disc;
 +	STORE NOFLUSH SCRATCHA1, 1, FROM t_offset;
 +	JUMP REL(script_sched);
  
  cmdout:
          MOVE FROM t_cmd, WHEN CMD;
 Index: microcode/siop/siop.out
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/siop.out,v
 retrieving revision 1.15
 diff -u -r1.15 siop.out
 --- microcode/siop/siop.out	17 May 2004 18:38:02 -0000	1.15
 +++ microcode/siop/siop.out	9 Nov 2005 17:52:37 -0000
 @@ -1,19 +1,19 @@
 -/*	$NetBSD: siop.out,v 1.15 2004/05/17 18:38:02 bouyer Exp $	*/
 +/*	$NetBSD: ncr53cxxx.c,v 1.14 2005/02/11 06:21:22 simonb Exp $	*/
  /*
   *	DO NOT EDIT - this file is automatically generated.
 - *	created from siop.ss on Mon May 17 20:37:26 2004
 + *	created from siop.ss on Wed Nov  9 17:21:34 2005
   */
  const u_int32_t siop_script[] = {
  	0x78340000, 0x00000000,			/* 000 -   0 */
  	0x78350000, 0x00000000,			/* 008 -   8 */
  	0x72370000, 0x00000000,			/* 010 -  16 */
  	0x80840020, 0x00000318,			/* 018 -  24 */
 -	0x868b0000, 0x00000370,			/* 020 -  32 */
 +	0x868b0000, 0x00000380,			/* 020 -  32 */
  	0x878b0000, 0x000002f8,			/* 028 -  40 */
 -	0x808b0000, 0x000003f8,			/* 030 -  48 */
 -	0x818b0000, 0x00000390,			/* 038 -  56 */
 -	0x828b0000, 0x00000368,			/* 040 -  64 */
 -	0x838b0000, 0x00000370,			/* 048 -  72 */
 +	0x808b0000, 0x00000408,			/* 030 -  48 */
 +	0x818b0000, 0x000003a0,			/* 038 -  56 */
 +	0x828b0000, 0x00000378,			/* 040 -  64 */
 +	0x838b0000, 0x00000380,			/* 048 -  72 */
  	0x98080000, 0x0000ffff,			/* 050 -  80 */
  	0x741a4000, 0x00000000,			/* 058 -  88 */
  	0x980c0000, 0x0000ff83,			/* 060 -  96 */
 @@ -107,81 +107,83 @@
  	0x7a340100, 0x00000000,			/* 320 - 800 */
  	0x60000008, 0x00000000,			/* 328 - 808 */
  	0x1f000030, 0x00000030,			/* 330 - 816 */
 -	0x808c0000, 0x00000208,			/* 338 - 824 */
 +	0x808c0000, 0x00000218,			/* 338 - 824 */
  	0x808c0002, 0xffffffd0,			/* 340 - 832 */
 -	0x808c0001, 0x00000208,			/* 348 - 840 */
 +	0x808c0001, 0x00000218,			/* 348 - 840 */
  	0x98040004, 0x0000ff01,			/* 350 - 848 */
 -	0x88880000, 0x000001c0,			/* 358 - 856 */
 +	0x88880000, 0x000001d0,			/* 358 - 856 */
  	0x74340100, 0x00000000,			/* 360 - 864 */
 -	0x808c0000, 0xfffffd00,			/* 368 - 872 */
 -	0x98080000, 0x0000ff04,			/* 370 - 880 */
 -	0x60000040, 0x00000000,			/* 378 - 888 */
 -	0x80880000, 0xfffffc98,			/* 380 - 896 */
 -	0x58000008, 0x00000000,			/* 388 - 904 */
 -	0x60000040, 0x00000000,			/* 390 - 912 */
 -	0x1e000048, 0x00000048,			/* 398 - 920 */
 -	0x60000008, 0x00000000,			/* 3a0 - 928 */
 -	0x80880000, 0xfffffc70,			/* 3a8 - 936 */
 -	0x1a000050, 0x00000050,			/* 3b0 - 944 */
 +	0x98040000, 0x0000ff04,			/* 368 - 872 */
 +	0x72350000, 0x00000000,			/* 370 - 880 */
 +	0x808c0000, 0xfffffcf0,			/* 378 - 888 */
 +	0x98080000, 0x0000ff05,			/* 380 - 896 */
 +	0x60000040, 0x00000000,			/* 388 - 904 */
 +	0x80880000, 0xfffffc88,			/* 390 - 912 */
 +	0x58000008, 0x00000000,			/* 398 - 920 */
 +	0x60000040, 0x00000000,			/* 3a0 - 928 */
 +	0x1e000048, 0x00000048,			/* 3a8 - 936 */
 +	0x60000008, 0x00000000,			/* 3b0 - 944 */
  	0x80880000, 0xfffffc60,			/* 3b8 - 952 */
 -	0x1b000058, 0x00000058,			/* 3c0 - 960 */
 +	0x1a000050, 0x00000050,			/* 3c0 - 960 */
  	0x80880000, 0xfffffc50,			/* 3c8 - 968 */
 -	0x88880000, 0x000000b8,			/* 3d0 - 976 */
 -	0x7a340200, 0x00000000,			/* 3d8 - 984 */
 -	0x19000060, 0x00000060,			/* 3e0 - 992 */
 -	0x7e350100, 0x00000000,			/* 3e8 - 1000 */
 -	0x7e100800, 0x00000000,			/* 3f0 - 1008 */
 -	0x7f110000, 0x00000000,			/* 3f8 - 1016 */
 -	0x7f120000, 0x00000000,			/* 400 - 1024 */
 -	0x7f130000, 0x00000000,			/* 408 - 1032 */
 -	0x818b0000, 0xffffffc8,			/* 410 - 1040 */
 -	0x88880000, 0x000000b8,			/* 418 - 1048 */
 -	0x7c34fd00, 0x00000000,			/* 420 - 1056 */
 -	0x80880000, 0xfffffbf0,			/* 428 - 1064 */
 -	0x88880000, 0x00000058,			/* 430 - 1072 */
 -	0x7a340200, 0x00000000,			/* 438 - 1080 */
 -	0x18000060, 0x00000060,			/* 440 - 1088 */
 -	0x7e350100, 0x00000000,			/* 448 - 1096 */
 -	0x7e100800, 0x00000000,			/* 450 - 1104 */
 -	0x7f110000, 0x00000000,			/* 458 - 1112 */
 -	0x7f120000, 0x00000000,			/* 460 - 1120 */
 -	0x7f130000, 0x00000000,			/* 468 - 1128 */
 -	0x808b0000, 0xffffffc8,			/* 470 - 1136 */
 -	0x88880000, 0x00000058,			/* 478 - 1144 */
 -	0x7c34fd00, 0x00000000,			/* 480 - 1152 */
 -	0x80880000, 0xfffffb90,			/* 488 - 1160 */
 -	0x72100000, 0x00000000,			/* 490 - 1168 */
 -	0x6a5c0000, 0x00000000,			/* 498 - 1176 */
 -	0x72110000, 0x00000000,			/* 4a0 - 1184 */
 -	0x6a5d0000, 0x00000000,			/* 4a8 - 1192 */
 -	0x72120000, 0x00000000,			/* 4b0 - 1200 */
 -	0x6a5e0000, 0x00000000,			/* 4b8 - 1208 */
 -	0x72130000, 0x00000000,			/* 4c0 - 1216 */
 -	0x6a5f0000, 0x00000000,			/* 4c8 - 1224 */
 -	0x90080000, 0x00000000,			/* 4d0 - 1232 */
 -	0x725c0000, 0x00000000,			/* 4d8 - 1240 */
 -	0x6a100000, 0x00000000,			/* 4e0 - 1248 */
 -	0x725d0000, 0x00000000,			/* 4e8 - 1256 */
 -	0x6a110000, 0x00000000,			/* 4f0 - 1264 */
 -	0x725e0000, 0x00000000,			/* 4f8 - 1272 */
 -	0x6a120000, 0x00000000,			/* 500 - 1280 */
 -	0x725f0000, 0x00000000,			/* 508 - 1288 */
 -	0x6a130000, 0x00000000,			/* 510 - 1296 */
 -	0x90080000, 0x00000000,			/* 518 - 1304 */
 -	0x7c027f00, 0x00000000,			/* 520 - 1312 */
 -	0x60000008, 0x00000000,			/* 528 - 1320 */
 -	0x60000040, 0x00000000,			/* 530 - 1328 */
 -	0x48000000, 0x00000000,			/* 538 - 1336 */
 -	0x90080000, 0x00000000,			/* 540 - 1344 */
 -	0x88880000, 0xffffffd0,			/* 548 - 1352 */
 -	0x98080000, 0x0000ff00,			/* 550 - 1360 */
 -	0x60000040, 0x00000000,			/* 558 - 1368 */
 -	0x1f000038, 0x00000038,			/* 560 - 1376 */
 -	0x98080000, 0x0000ff02,			/* 568 - 1384 */
 -	0x60000040, 0x00000000,			/* 570 - 1392 */
 -	0x1f000040, 0x00000040,			/* 578 - 1400 */
 -	0x98080000, 0x0000ff03,			/* 580 - 1408 */
 -	0x80000000, 0x00000000,			/* 588 - 1416 */
 +	0x1b000058, 0x00000058,			/* 3d0 - 976 */
 +	0x80880000, 0xfffffc40,			/* 3d8 - 984 */
 +	0x88880000, 0x000000b8,			/* 3e0 - 992 */
 +	0x7a340200, 0x00000000,			/* 3e8 - 1000 */
 +	0x19000068, 0x00000068,			/* 3f0 - 1008 */
 +	0x7e350100, 0x00000000,			/* 3f8 - 1016 */
 +	0x7e100800, 0x00000000,			/* 400 - 1024 */
 +	0x7f110000, 0x00000000,			/* 408 - 1032 */
 +	0x7f120000, 0x00000000,			/* 410 - 1040 */
 +	0x7f130000, 0x00000000,			/* 418 - 1048 */
 +	0x818b0000, 0xffffffc8,			/* 420 - 1056 */
 +	0x88880000, 0x000000b8,			/* 428 - 1064 */
 +	0x7c34fd00, 0x00000000,			/* 430 - 1072 */
 +	0x80880000, 0xfffffbe0,			/* 438 - 1080 */
 +	0x88880000, 0x00000058,			/* 440 - 1088 */
 +	0x7a340200, 0x00000000,			/* 448 - 1096 */
 +	0x18000068, 0x00000068,			/* 450 - 1104 */
 +	0x7e350100, 0x00000000,			/* 458 - 1112 */
 +	0x7e100800, 0x00000000,			/* 460 - 1120 */
 +	0x7f110000, 0x00000000,			/* 468 - 1128 */
 +	0x7f120000, 0x00000000,			/* 470 - 1136 */
 +	0x7f130000, 0x00000000,			/* 478 - 1144 */
 +	0x808b0000, 0xffffffc8,			/* 480 - 1152 */
 +	0x88880000, 0x00000058,			/* 488 - 1160 */
 +	0x7c34fd00, 0x00000000,			/* 490 - 1168 */
 +	0x80880000, 0xfffffb80,			/* 498 - 1176 */
 +	0x72100000, 0x00000000,			/* 4a0 - 1184 */
 +	0x6a5c0000, 0x00000000,			/* 4a8 - 1192 */
 +	0x72110000, 0x00000000,			/* 4b0 - 1200 */
 +	0x6a5d0000, 0x00000000,			/* 4b8 - 1208 */
 +	0x72120000, 0x00000000,			/* 4c0 - 1216 */
 +	0x6a5e0000, 0x00000000,			/* 4c8 - 1224 */
 +	0x72130000, 0x00000000,			/* 4d0 - 1232 */
 +	0x6a5f0000, 0x00000000,			/* 4d8 - 1240 */
 +	0x90080000, 0x00000000,			/* 4e0 - 1248 */
 +	0x725c0000, 0x00000000,			/* 4e8 - 1256 */
 +	0x6a100000, 0x00000000,			/* 4f0 - 1264 */
 +	0x725d0000, 0x00000000,			/* 4f8 - 1272 */
 +	0x6a110000, 0x00000000,			/* 500 - 1280 */
 +	0x725e0000, 0x00000000,			/* 508 - 1288 */
 +	0x6a120000, 0x00000000,			/* 510 - 1296 */
 +	0x725f0000, 0x00000000,			/* 518 - 1304 */
 +	0x6a130000, 0x00000000,			/* 520 - 1312 */
 +	0x90080000, 0x00000000,			/* 528 - 1320 */
 +	0x7c027f00, 0x00000000,			/* 530 - 1328 */
 +	0x60000008, 0x00000000,			/* 538 - 1336 */
 +	0x60000040, 0x00000000,			/* 540 - 1344 */
 +	0x48000000, 0x00000000,			/* 548 - 1352 */
 +	0x90080000, 0x00000000,			/* 550 - 1360 */
 +	0x88880000, 0xffffffd0,			/* 558 - 1368 */
 +	0x98080000, 0x0000ff00,			/* 560 - 1376 */
 +	0x60000040, 0x00000000,			/* 568 - 1384 */
 +	0x1f000038, 0x00000038,			/* 570 - 1392 */
 +	0x98080000, 0x0000ff02,			/* 578 - 1400 */
 +	0x60000040, 0x00000000,			/* 580 - 1408 */
 +	0x1f000040, 0x00000040,			/* 588 - 1416 */
 +	0x98080000, 0x0000ff03,			/* 590 - 1424 */
 +	0x80000000, 0x00000000,			/* 598 - 1432 */
  };
  
  const u_int32_t lun_switch[] = {
 @@ -244,12 +246,14 @@
  #define	A_t_msg_out	0x00000048
  #define	A_t_cmd	0x00000050
  #define	A_t_status	0x00000058
 -#define	A_t_data	0x00000060
 +#define	A_t_offset	0x00000060
 +#define	A_t_data	0x00000068
  #define	A_int_done	0x0000ff00
  #define	A_int_msgin	0x0000ff01
  #define	A_int_extmsgin	0x0000ff02
  #define	A_int_extmsgdata	0x0000ff03
  #define	A_int_disc	0x0000ff04
 +#define	A_int_saveoffset	0x0000ff05
  #define	A_int_reseltarg	0x0000ff80
  #define	A_int_resellun	0x0000ff81
  #define	A_int_reseltag	0x0000ff82
 @@ -259,24 +263,24 @@
  #define	A_flag_data	0x00000002
  #define	A_flag_data_mask	0x000000fd
  #define	Ent_waitphase	0x00000020
 -#define	Ent_send_msgout	0x00000388
 -#define	Ent_msgout	0x00000398
 +#define	Ent_send_msgout	0x00000398
 +#define	Ent_msgout	0x000003a8
  #define	Ent_msgin	0x00000328
  #define	Ent_handle_msgin	0x00000338
 -#define	Ent_msgin_ack	0x00000378
 -#define	Ent_dataout	0x00000430
 -#define	Ent_datain	0x000003d0
 -#define	Ent_cmdout	0x000003b0
 -#define	Ent_status	0x000003c0
 -#define	Ent_disconnect	0x00000520
 +#define	Ent_msgin_ack	0x00000388
 +#define	Ent_dataout	0x00000440
 +#define	Ent_datain	0x000003e0
 +#define	Ent_cmdout	0x000003c0
 +#define	Ent_status	0x000003d0
 +#define	Ent_disconnect	0x00000530
  #define	Ent_reselect	0x000001e0
  #define	Ent_reselected	0x00000000
 -#define	Ent_selected	0x00000378
 +#define	Ent_selected	0x00000388
  #define	Ent_script_sched	0x00000070
  #define	Ent_script_sched_slot0	0x000000a0
 -#define	Ent_get_extmsgdata	0x00000570
 +#define	Ent_get_extmsgdata	0x00000580
  #define	Ent_resel_targ0	0x00000238
 -#define	Ent_msgin_space	0x00000588
 +#define	Ent_msgin_space	0x00000598
  #define	Ent_lunsw_return	0x000002b8
  #define	Ent_led_on1	0x00000068
  #define	Ent_led_on2	0x00000220
 Index: microcode/siop/siop.ss
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/siop.ss,v
 retrieving revision 1.19
 diff -u -r1.19 siop.ss
 --- microcode/siop/siop.ss	27 Feb 2005 00:27:29 -0000	1.19
 +++ microcode/siop/siop.ss	9 Nov 2005 17:52:37 -0000
 @@ -38,7 +38,8 @@
  ABSOLUTE t_msg_out = 72;
  ABSOLUTE t_cmd = 80;
  ABSOLUTE t_status = 88;
 -ABSOLUTE t_data = 96;
 +ABSOLUTE t_offset = 96;
 +ABSOLUTE t_data = 104;
  
  ;; interrupt codes
  ; interrupts that need a valid DSA
 @@ -47,6 +48,7 @@
  ABSOLUTE int_extmsgin	= 0xff02;
  ABSOLUTE int_extmsgdata	= 0xff03;
  ABSOLUTE int_disc	= 0xff04;
 +ABSOLUTE int_saveoffset	= 0xff05;
  ; interrupts that don't have a valid DSA
  ABSOLUTE int_reseltarg	= 0xff80;
  ABSOLUTE int_resellun	= 0xff81;
 @@ -262,9 +264,12 @@
  	CALL REL(disconnect)                  ; disconnect message;
  ; if we didn't get sdp, no need to interrupt
  	MOVE SCRATCHA0 & flag_sdp TO SFBR;
 +	INT int_disc, IF not 0x00;
 +; update offset if we did some data transfer
 +	MOVE SCRATCHA1 TO SFBR;
  	JUMP REL(script_sched), if 0x00;
 -; Ok, we need to save data pointers
 -	INT int_disc;
 +	INT int_saveoffset;
 +
  msgin_ack:
  selected:
  	CLEAR ACK;
 
 --RnlQjJ0d97Da+TV1--