Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Nov 1997 00:32:19 +0100 (MET)
From:      Wilko Bulte <wilko@yedi.iaf.nl>
To:        julian@whistle.com (Julian Elischer)
Cc:        freebsd-scsi@FreeBSD.ORG
Subject:   Re: hack for slow starting CD drives
Message-ID:  <199711262332.AAA00406@yedi.iaf.nl>
In-Reply-To: <Pine.BSF.3.95.971126134434.3379E-100000@current1.whistle.com> from "Julian Elischer" at Nov 26, 97 01:45:39 pm

next in thread | previous in thread | raw e-mail | index | archive | help
As Julian Elischer wrote...

> The OPEN call is done from user context rather than interrupt context,
> so you can do a tsleep() in there.

Right. Its too long ago that I played with driver source.. :/

The patch below seems to be working OK without bombing the drive with
TUR commands. Would it be unreasonable to put something like this into
the -current source?

Wilko

*** cd.c.orig	Wed Nov 26 20:18:54 1997
--- cd.c	Thu Nov 27 00:28:03 1997
***************
*** 246,251 ****
--- 246,252 ----
  	errval  errcode = 0;
  	u_int32_t unit, part;
  	struct scsi_data *cd;
+ 	int start_unit_retry_counter = 0;
  
  	unit = CDUNIT(dev);
  	part = PARTITION(dev);
***************
*** 285,295 ****
--- 286,316 ----
  	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 */
+ 
+ 	/* This is a hack, but e.g. Toshiba CD drives tend to take ages to get
+ 	 * up to speed 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 resulted in device not
+ 	 * configured / ENXIO. [wilko]
+ 	 */
+ 	while ((scsi_test_unit_ready(sc_link, SCSI_SILENT) != 0) && 
+ 		(start_unit_retry_counter != 10)) {
+ 
+ 		tsleep((void *)&start_unit_retry_counter,PRIBIO,"cdspup",2*hz);
+ 		start_unit_retry_counter++;
+ 	}
+ 	
+ 	/* 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);
  	/*
_     ______________________________________________________________________
 |   / o / /  _  Bulte email: wilko @ yedi.iaf.nl http://www.tcja.nl/~wilko
 |/|/ / / /( (_) Arnhem, The Netherlands - Do, or do not. There is no 'try'
----------------  Support your local daemons: run [Free,Net]BSD Unix  ------



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