Subject: kern/2529: Iomega jaz drive prints errors every time the sdN is opened.
To: None <gnats-bugs@NetBSD.ORG>
From: Christos Zoulas <christos@deshaw.com>
List: netbsd-bugs
Date: 06/08/1996 16:17:20
>Number:         2529
>Category:       kern
>Synopsis:       Iomega jaz drive prints errors every time the sdN is opened.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun  8 16:50:01 1996
>Last-Modified:
>Originator:     Christos Zoulas
>Organization:
	void
>Release:        Sat Jun  8 16:13:51 EDT 1996
>Environment:
System: NetBSD ramoth.nyc.deshaw.com 1.1B NetBSD 1.1B (ZEOS_AIC) #24: Sat May 18 11:35:52 EDT 1996 christos@ramoth.nyc.deshaw.com:/tmp_mnt/src/NetBSD/cvsroot/src/sys/arch/i386/compile/ZEOS_AIC i386


>Description:
	Removable drives such as the Iomega jaz, don't understand mode sense
	and print errors every time the device is opened.
>How-To-Repeat:
	plug one in and access it.
>Fix:
	I added another quirk for avoid mode-sensing the drive. If all
	removable drives are like this maybe a better solution is to
	be silent on mode sense failure if the drive is removable?

cvs server: Diffing .
Index: scsiconf.c
===================================================================
RCS file: /a/cvsroot/src/sys/scsi/scsiconf.c,v
retrieving revision 1.57
diff -c -r1.57 scsiconf.c
*** scsiconf.c	1996/05/02 01:09:01	1.57
--- scsiconf.c	1996/06/08 20:10:00
***************
*** 346,352 ****
  	 "SEAGATE ", "ST296N          ", ""},     SDEV_NOLUNS},
  	{{T_DIRECT, T_FIXED,
  	 "TOSHIBA ", "MK538FB         ", "6027"}, SDEV_NOLUNS},
! 
  
  	/* XXX: QIC-36 tape behind Emulex adapter.  Very broken. */
  	{{T_SEQUENTIAL, T_REMOV,
--- 346,353 ----
  	 "SEAGATE ", "ST296N          ", ""},     SDEV_NOLUNS},
  	{{T_DIRECT, T_FIXED,
  	 "TOSHIBA ", "MK538FB         ", "6027"}, SDEV_NOLUNS},
! 	{{T_DIRECT, T_REMOV,
! 	 "iomega", "jaz 1GB", 		 ""},	  SDEV_NOMODESENSE},
  
  	/* XXX: QIC-36 tape behind Emulex adapter.  Very broken. */
  	{{T_SEQUENTIAL, T_REMOV,
Index: scsiconf.h
===================================================================
RCS file: /a/cvsroot/src/sys/scsi/scsiconf.h,v
retrieving revision 1.29
diff -c -r1.29 scsiconf.h
*** scsiconf.h	1996/03/19 03:07:50	1.29
--- scsiconf.h	1996/06/08 20:10:00
***************
*** 151,156 ****
--- 151,157 ----
  #define	SDEV_NOSYNCWIDE		0x02	/* does not grok SDTR or WDTR */
  #define	SDEV_NOLUNS		0x04	/* does not grok LUNs */
  #define	SDEV_FORCELUNS		0x08	/* prehistoric drive/ctlr groks LUNs */
+ #define	SDEV_NOMODESENSE	0x10	/* removable media/optical drives */
  	struct	scsi_device *device;	/* device entry points etc. */
  	void	*device_softc;		/* needed for call to foo_start */
  	struct	scsi_adapter *adapter;	/* adapter entry points etc. */
Index: sd.c
===================================================================
RCS file: /a/cvsroot/src/sys/scsi/sd.c,v
retrieving revision 1.100
diff -c -r1.100 sd.c
*** sd.c	1996/05/14 10:38:47	1.100
--- sd.c	1996/06/08 20:10:00
***************
*** 839,844 ****
--- 839,847 ----
  	} scsi_sense;
  	u_long sectors;
  
+ 	if ((sd->sc_link->quirks & SDEV_NOMODESENSE) != 0)
+ 		goto fake_it;
+ 
  	/*
  	 * do a "mode sense page 4"
  	 */
***************
*** 846,873 ****
  	scsi_cmd.opcode = MODE_SENSE;
  	scsi_cmd.page = 4;
  	scsi_cmd.length = 0x20;
  	/*
  	 * If the command worked, use the results to fill out
  	 * the parameter structure
  	 */
  	if (scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd,
  	    sizeof(scsi_cmd), (u_char *)&scsi_sense, sizeof(scsi_sense),
! 	    SDRETRIES, 6000, NULL, flags | SCSI_DATA_IN) != 0) {
! 		printf("%s: could not mode sense (4)", sd->sc_dev.dv_xname);
! 	fake_it:
! 		printf("; using fictitious geometry\n");
! 		/*
! 		 * use adaptec standard fictitious geometry
! 		 * this depends on which controller (e.g. 1542C is
! 		 * different. but we have to put SOMETHING here..)
! 		 */
! 		sectors = scsi_size(sd->sc_link, flags);
! 		dp->heads = 64;
! 		dp->sectors = 32;
! 		dp->cyls = sectors / (64 * 32);
! 		dp->blksize = 512;
! 		dp->disksize = sectors;
! 	} else {
  		SC_DEBUG(sd->sc_link, SDEV_DB3,
  		    ("%d cyls, %d heads, %d precomp, %d red_write, %d land_zone\n",
  		    _3btol(scsi_sense.pages.rigid_geometry.ncyl),
--- 849,862 ----
  	scsi_cmd.opcode = MODE_SENSE;
  	scsi_cmd.page = 4;
  	scsi_cmd.length = 0x20;
+ 
  	/*
  	 * If the command worked, use the results to fill out
  	 * the parameter structure
  	 */
  	if (scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *)&scsi_cmd,
  	    sizeof(scsi_cmd), (u_char *)&scsi_sense, sizeof(scsi_sense),
! 	    SDRETRIES, 6000, NULL, flags | SCSI_DATA_IN) == 0) {
  		SC_DEBUG(sd->sc_link, SDEV_DB3,
  		    ("%d cyls, %d heads, %d precomp, %d red_write, %d land_zone\n",
  		    _3btol(scsi_sense.pages.rigid_geometry.ncyl),
***************
*** 899,906 ****
--- 888,912 ----
  		dp->disksize = sectors;
  		sectors /= (dp->heads * dp->cyls);
  		dp->sectors = sectors;	/* XXX dubious on SCSI */
+ 		return 0;
  	}
+ 	else
+ 		printf("%s: could not mode sense (4)", sd->sc_dev.dv_xname);
  
+ fake_it:
+ 	/*
+ 	 * use adaptec standard fictitious geometry
+ 	 * this depends on which controller (e.g. 1542C is
+ 	 * different. but we have to put SOMETHING here..)
+ 	 */
+ 	if ((sd->sc_link->quirks & SDEV_NOMODESENSE) == 0)
+ 		printf("; using fictitious geometry\n");
+ 	sectors = scsi_size(sd->sc_link, flags);
+ 	dp->heads = 64;
+ 	dp->sectors = 32;
+ 	dp->cyls = sectors / (64 * 32);
+ 	dp->blksize = 512;
+ 	dp->disksize = sectors;
  	return 0;
  }
  
>Audit-Trail:
>Unformatted: