Subject: kern/12991: DVD ioctls don't work
To: None <gnats-bugs@gnats.netbsd.org>
From: Dave Huang <khym@azeotrope.org>
List: netbsd-bugs
Date: 05/20/2001 16:00:19
>Number:         12991
>Category:       kern
>Synopsis:       DVD ioctls don't work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 20 13:59:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Dave Huang
>Release:        NetBSD-1.5V as of May 19, 2001
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 25 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Environment:
	
System: NetBSD dahan.metonymy.com 1.5V NetBSD 1.5V (SPIFF) #357: Sun May 20 15:39:15 CDT 2001 khym@dahan.metonymy.com:/usr/src.local/sys/arch/i386/compile/SPIFF i386
Architecture: i386
Machine: i386

siop0 at pci0 dev 9 function 0: Symbios Logic 53c810a (fast scsi)
siop0: interrupting at irq 15
scsibus0 at siop0: 8 targets, 8 luns per target
siop1 at pci0 dev 11 function 0: Symbios Logic 53c875 (ultra-wide scsi)
siop1: using on-board RAM
siop1: interrupting at irq 10
scsibus1 at siop1: 16 targets, 8 luns per target
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <Quantum, VP32210, L915> SCSI2 0/direct fixed
cd0 at scsibus0 target 2 lun 0: <PIONEER, DVD-ROM DVD-305, 1.00> SCSI2 5/cdrom removable
st0 at scsibus0 target 6 lun 0: <ARCHIVE, Python 28849-XXX, 4.CM> SCSI2 1/sequential removable
ch0 at scsibus0 target 6 lun 1: <ARCHIVE, Python 28849-XXX, 4.CM> SCSI2 8/changer removable
scsibus1: waiting 2 seconds for devices to settle...
sd1 at scsibus1 target 1 lun 0: <QUANTUM, VIKING 4.5 SCA, 880R> SCSI2 0/direct fixed
sd2 at scsibus1 target 3 lun 0: <QUANTUM, VIKING 4.5 SCA, 8600> SCSI2 0/direct fixed

>Description:
	I just got a DVD-ROM, so I figure I'd see how DVD support was
doing... I had an old copy of the css-auth utilities lying around, so
I compiled 'em and gave it a try, only to get my SCSI bus reset by tstdvd:

siop0: unexpected phase mismatch 1
siop0: unhandled scsi interrupt, sist=0xc0 sstat1=0x19 DSA=0xcb1c DSP=0x3b0
siop0: phase mismatch without command
siop0: unhandled scsi interrupt, sist=0x80 sstat1=0x19 DSA=0xffffffff DSP=0x2a8
siop0: scsi bus reset
sd0: Async, 8-bit transfers, tagged queueing
sd0: Sync (100.0ns offset 8), 8-bit (10.000MB/s) transfers, tagged queueing

>How-To-Repeat:
	Run the css-auth utils on a machine that uses the siop SCSI
driver, I guess... or maybe it's the Pioneer DVD-ROM. Or maybe both :)
>Fix:
Well, according to the SCSI MMC-3 draft at
<ftp://ftp.t10.org/t10/drafts/mmc3/mmc3r09.pdf>, the DVD SCSI commands
take a 12 byte CDB, not 16... so it's not too good to send a 16 byte
CDB. With these patches, the css-auth stuff seems to work now, and I
got this big .vob file that I don't know what to do with :)

--- /usr/src/sys/dev/scsipi/cd.c	Sun May 20 01:26:39 2001
+++ cd.c	Sun May 20 15:38:52 2001
@@ -1611,7 +1611,7 @@
 		cmd.opcode = GPCMD_REPORT_KEY;
 		cmd.bytes[8] = 8;
 		cmd.bytes[9] = 0 | (0 << 6);
-		error = scsipi_command(cd->sc_periph, &cmd, 16, buf, 8,
+		error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 8,
 		    CDRETRIES, 30000, NULL,
 		    XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 		if (error)
@@ -1623,7 +1623,7 @@
 		cmd.opcode = GPCMD_REPORT_KEY;
 		cmd.bytes[8] = 16;
 		cmd.bytes[9] = 1 | (a->lsc.agid << 6);
-		error = scsipi_command(cd->sc_periph, &cmd, 16, buf, 16,
+		error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 16,
 		    CDRETRIES, 30000, NULL,
 		    XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 		if (error)
@@ -1635,7 +1635,7 @@
 		cmd.opcode = GPCMD_REPORT_KEY;
 		cmd.bytes[8] = 12;
 		cmd.bytes[9] = 2 | (a->lsk.agid << 6);
-		error = scsipi_command(cd->sc_periph, &cmd, 16, buf, 12,
+		error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 12,
 		    CDRETRIES, 30000, NULL,
 		    XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 		if (error)
@@ -1648,7 +1648,7 @@
 		_lto4b(a->lstk.lba, &cmd.bytes[1]);
 		cmd.bytes[8] = 12;
 		cmd.bytes[9] = 4 | (a->lstk.agid << 6);
-		error = scsipi_command(cd->sc_periph, &cmd, 16, buf, 12,
+		error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 12,
 		    CDRETRIES, 30000, NULL,
 		    XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 		if (error)
@@ -1663,7 +1663,7 @@
 		cmd.opcode = GPCMD_REPORT_KEY;
 		cmd.bytes[8] = 8;
 		cmd.bytes[9] = 5 | (a->lsasf.agid << 6);
-		error = scsipi_command(cd->sc_periph, &cmd, 16, buf, 8,
+		error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 8,
 		    CDRETRIES, 30000, NULL,
 		    XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 		if (error)
@@ -1677,7 +1677,7 @@
 		cmd.bytes[9] = 1 | (a->hsc.agid << 6);
 		buf[1] = 14;
 		dvd_copy_challenge(&buf[4], a->hsc.chal);
-		error = scsipi_command(cd->sc_periph, &cmd, 16, buf, 16,
+		error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 16,
 		    CDRETRIES, 30000, NULL,
 		    XS_CTL_DATA_OUT|XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 		if (error)
@@ -1691,7 +1691,7 @@
 		cmd.bytes[9] = 3 | (a->hsk.agid << 6);
 		buf[1] = 10;
 		dvd_copy_key(&buf[4], a->hsk.key);
-		error = scsipi_command(cd->sc_periph, &cmd, 16, buf, 12,
+		error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 12,
 		    CDRETRIES, 30000, NULL,
 		    XS_CTL_DATA_OUT|XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 		if (error) {
@@ -1704,7 +1704,7 @@
 	case DVD_INVALIDATE_AGID:
 		cmd.opcode = GPCMD_REPORT_KEY;
 		cmd.bytes[9] = 0x3f | (a->lsa.agid << 6);
-		error = scsipi_command(cd->sc_periph, &cmd, 16, buf, 16,
+		error = scsipi_command(cd->sc_periph, &cmd, 12, buf, 16,
 		    CDRETRIES, 30000, NULL, 0);
 		if (error)
 			return (error);
@@ -1733,7 +1733,7 @@
 	_lto2b(sizeof(buf), &cmd.bytes[7]);
 
 	cmd.bytes[5] = s->physical.layer_num;
-	error = scsipi_command(cd->sc_periph, &cmd, 16, buf, sizeof(buf),
+	error = scsipi_command(cd->sc_periph, &cmd, 12, buf, sizeof(buf),
 	    CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 	if (error)
 		return (error);
@@ -1773,7 +1773,7 @@
 	_lto2b(sizeof(buf), &cmd.bytes[7]);
 
 	cmd.bytes[5] = s->copyright.layer_num;
-	error = scsipi_command(cd->sc_periph, &cmd, 16, buf, sizeof(buf),
+	error = scsipi_command(cd->sc_periph, &cmd, 12, buf, sizeof(buf),
 	    CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 	if (error)
 		return (error);
@@ -1798,7 +1798,7 @@
 	_lto2b(sizeof(buf), &cmd.bytes[7]);
 
 	cmd.bytes[9] = s->disckey.agid << 6;
-	error = scsipi_command(cd->sc_periph, &cmd, 16, buf, sizeof(buf),
+	error = scsipi_command(cd->sc_periph, &cmd, 12, buf, sizeof(buf),
 	    CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 	if (error)
 		return (error);
@@ -1821,7 +1821,7 @@
 	cmd.bytes[6] = s->type;
 	_lto2b(sizeof(buf), &cmd.bytes[7]);
 
-	error = scsipi_command(cd->sc_periph, &cmd, 16, buf, sizeof(buf),
+	error = scsipi_command(cd->sc_periph, &cmd, 12, buf, sizeof(buf),
 	    CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 	if (error)
 		return (error);
@@ -1847,7 +1847,7 @@
 	cmd.bytes[6] = s->type;
 	_lto2b(sizeof(buf), &cmd.bytes[7]);
 
-	error = scsipi_command(cd->sc_periph, &cmd, 16, buf, sizeof(buf),
+	error = scsipi_command(cd->sc_periph, &cmd, 12, buf, sizeof(buf),
 	    CDRETRIES, 30000, NULL, XS_CTL_DATA_IN|XS_CTL_DATA_ONSTACK);
 	if (error)
 		return (error);

>Release-Note:
>Audit-Trail:
>Unformatted: