Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Dec 1997 00:25:23 +0100 (MET)
From:      wilko@yedi.iaf.nl
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   kern/5181: patch to allow slow scsi cdroms more time to startup
Message-ID:  <199711302325.AAA28132@yedi.iaf.nl>
Resent-Message-ID: <199711302340.PAA14373@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         5181
>Category:       kern
>Synopsis:       patch to allow slow scsi cdroms more time to startup
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 30 15:40:01 PST 1997
>Last-Modified:
>Originator:     Wilko Bulte
>Organization:
Private FreeBSD site - Arnhem, The Netherlands
>Release:        FreeBSD 2.2.1-RELEASE i386
>Environment:

	FreeBSD 2.2.1-R but also applicable to FreeBSD-2.2.5R
	Toshiba XM5701 12x SCSI cdrom connected to a NCR810

>Description:

	Some SCSI cdroms are slow to react to a start_unit command after the
	media has been changed. While getting up to speed, they report 
	'not ready'. This makes the cd_open() fail immediately with ENXIO,
	resulting in misleading 'device not configured' errors when 'mount'
	is run.

>How-To-Repeat:

	Change media and immediately perform mount of the cdrom.

>Fix:
	
	Below is a diff -c based on the 2.2.1R sources for /sys/scsi/cd.c
	that fixes the issue:

	
*** cd.c.orig	Wed Nov 26 20:18:54 1997
--- cd.c	Mon Dec  1 00:12:05 1997
***************
*** 246,251 ****
--- 246,252 ----
  	errval  errcode = 0;
  	u_int32_t unit, part;
  	struct scsi_data *cd;
+ 	int n = 0;
  
  	unit = CDUNIT(dev);
  	part = PARTITION(dev);
***************
*** 285,295 ****
--- 286,312 ----
  	scsi_start_unit(sc_link, CD_START);
  	SC_DEBUG(sc_link, SDEV_DB3, ("'start' attempted "));
  	sc_link->flags |= SDEV_OPEN;	/* unit attn errors are now errors */
+ 
+ 	/* Some drives e.g. Toshiba's tend to take a long time to become ready
+ 	 * after a disc swap and report 'Not Ready' while doing so. 
+ 	 * They should have reported 'Unit In The Process Of Getting Ready' 
+ 	 * but alas they don't. Attempts to e.g. mount during this period 
+ 	 * will result in device not configured due to ENXIO. The code below
+ 	 * gives them some time to come up.
+ 	 */
+ 	while ((scsi_test_unit_ready(sc_link, SCSI_SILENT) != 0) && 
+ 		(n != 12)) {
+ 		tsleep(cd, PRIBIO | PCATCH, "cdrdy", hz);
+ 		n++;
+ 	}
+ 	
+ 	/* It really should be ready by now. If not, it's time to give up */
  	if (scsi_test_unit_ready(sc_link, SCSI_SILENT) != 0) {
  		SC_DEBUG(sc_link, SDEV_DB3, ("not ready\n"));
  		errcode = ENXIO;
  		goto bad;
  	}
+ 
  	SC_DEBUG(sc_link, SDEV_DB3, ("Device present\n"));
  	scsi_prevent(sc_link, PR_PREVENT, SCSI_SILENT);
  	/*

>Audit-Trail:
>Unformatted:



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