NetBSD Problem Report #8326

Received: (qmail 27276 invoked from network); 5 Sep 1999 16:05:08 -0000
Message-Id: <19990905160506.6009CBA8E@boojum.piermont.com>
Date: Sun,  5 Sep 1999 12:05:06 -0400 (EDT)
From: perry@piermont.com
Reply-To: perry@piermont.com
To: gnats-bugs@gnats.netbsd.org
Subject: cdplay always errors on the first request made
X-Send-Pr-Version: 3.95

>Number:         8326
>Category:       bin
>Synopsis:       cdplay always errors on the first request made
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    ad
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 05 09:20:01 +0000 1999
>Closed-Date:    Mon Aug 20 11:40:28 +0000 2001
>Last-Modified:  Mon Aug 20 11:40:28 +0000 2001
>Originator:     Perry E. Metzger
>Release:        NetBSD-current, August 29, 1999
>Organization:
Perry Metzger		perry@piermont.com
--
"Ask not what your country can force other people to do for you..."
>Environment:

System: NetBSD boojum.piermont.com 1.4K NetBSD 1.4K (BOOJUM) #0: Sun Aug 29 11:29:41 EDT 1999 perry@boojum.piermont.com:/usr/src/sys/arch/i386/compile/BOOJUM i386


>Description:
	Whenever I put a new CD into my ATAPI cdrom drive, the first
	command I give to cdplay (whether info or play) always results
	in "cdplay: I/O error". Subsequent requests work fine. This is
	not nice behavior.
	Note that at the same time, I typically get the console
	message:
	cd0(pciide0:1:0): unit attention, data = 00 00 00 00 28 00 00 00 00 00
	Just to repeat: this only happens on first access. All
	subsequent accesses work without any trouble.

	Drive data:
	cd0 at atapibus0 drive 0: <TOSHIBA CD-ROM XM-6502B, , 1013> type 5 cdrom removable
	cd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 2

>How-To-Repeat:
	On my machine, this *always* happens. I have no idea if it
	impacts anyone elses's hardware at all.
>Fix:
	No idea.

>Release-Note:
>Audit-Trail:

From: Jaromir Dolecek <dolecek@ics.muni.cz>
To: perry@piermont.com
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/8326: cdplay always errors on the first request made
Date: Mon, 6 Sep 1999 09:06:48 +0200 (MEST)

 Just a wild guess - do you wait long enough for the drive to recognize
 the CD ?

 perry@piermont.com wrote:
 > >Description:
 > 	Whenever I put a new CD into my ATAPI cdrom drive, the first
 > 	command I give to cdplay (whether info or play) always results
 > 	in "cdplay: I/O error". Subsequent requests work fine. This is
 > 	not nice behavior.
 > 	Note that at the same time, I typically get the console
 > 	message:
 > 	cd0(pciide0:1:0): unit attention, data = 00 00 00 00 28 00 00 00 00 00
 > 	Just to repeat: this only happens on first access. All
 > 	subsequent accesses work without any trouble.
 > 
 > 	Drive data:
 > 	cd0 at atapibus0 drive 0: <TOSHIBA CD-ROM XM-6502B, , 1013> type 5 cdrom removable
 > 	cd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 2

 Jaromir

 -- 
 Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
 "The only way how to get rid temptation is to yield to it." -- Oscar Wilde

From: "Perry E. Metzger" <perry@piermont.com>
To: Jaromir Dolecek <dolecek@ics.muni.cz>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/8326: cdplay always errors on the first request made
Date: 06 Sep 1999 04:32:23 -0400

 Jaromir Dolecek <dolecek@ics.muni.cz> writes:
 > Just a wild guess - do you wait long enough for the drive to recognize
 > the CD ?

 Whether I wait five seconds or five minutes, the first request always
 results in an error and all subsequent ones work.

 Perry

From: Sergey Svishchev <svs@ropnet.ru>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: Re: bin/8326
Date: Wed, 11 Jul 2001 15:23:30 +0400

 --NzB8fVQJ5HfG6fxh
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 I observed behavior similar to one described in this PR: when a new CD is
 loaded manually -- i.e., not with CDIOCCLOSE ioctl -- first command fails
 because a Unit Attention is sent by the drive.  The patch to cd.c fixes this.

 The patch to scsipi_base.c is necessary since ASC 0x3A can have ASCQ 0x01
 (MEDIUM NOT PRESENT - TRAY CLOSED) and 0x02 (MEDIUM NOT PRESENT - TRAY OPEN),
 too.  This change is not related to PR.

 -- 
 Sergey Svishchev

 --NzB8fVQJ5HfG6fxh
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="my-kern-8326.pch"

 Index: cd.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/dev/scsipi/cd.c,v
 retrieving revision 1.151
 diff -u -r1.151 cd.c
 --- cd.c	2001/06/26 15:32:03	1.151
 +++ cd.c	2001/07/10 18:49:28
 @@ -766,29 +773,40 @@
  	 * the generic code handle it.
  	 */
  	if ((sense->error_code & SSD_ERRCODE) != 0x70 &&
 -	    (sense->error_code & SSD_ERRCODE) != 0x71) {	/* DEFFERRED */
 +	    (sense->error_code & SSD_ERRCODE) != 0x71) {	/* DEFERRED */
  		return (retval);
  	}

 +	switch (sense->flags & SSD_KEY) {
  	/*
  	 * If we got a "Unit not ready" (SKEY_NOT_READY) and "Logical Unit
  	 * Is In The Process of Becoming Ready" (Sense code 0x04,0x01), then
  	 * wait a bit for the drive to spin up
  	 */
 -
 -	if ((sense->flags & SSD_KEY) == SKEY_NOT_READY &&
 -	    sense->add_sense_code == 0x4 &&
 -	    sense->add_sense_code_qual == 0x01)	{
 -		/*
 -		 * Sleep for 5 seconds to wait for the drive to spin up
 -		 */
 -
 -		SC_DEBUG(periph, SCSIPI_DB1, ("Waiting 5 sec for CD "
 -						"spinup\n"));
 -		scsipi_periph_freeze(periph, 1);
 -		callout_reset(&periph->periph_callout,
 -		    5 * hz, scsipi_periph_timed_thaw, periph);
 -		retval = ERESTART;
 +		case SKEY_NOT_READY:
 +			if (sense->add_sense_code == 0x4 &&
 +		    sense->add_sense_code_qual == 0x01)	{
 +				/*
 +				 * Sleep for 5 seconds to wait for the drive to spin up
 +				 */
 +
 +				SC_DEBUG(periph, SCSIPI_DB1, ("Waiting 5 sec for CD "
 +								"spinup\n"));
 +				scsipi_periph_freeze(periph, 1);
 +				callout_reset(&periph->periph_callout,
 +						5 * hz, scsipi_periph_timed_thaw, periph);
 +				retval = ERESTART;
 +			}
 +			break;
 +		case SKEY_UNIT_ATTENTION:
 +			if (sense->add_sense_code == 0x28 &&
 +			    sense->add_sense_code_qual == 0x00) {
 +				/* medium changed */
 +				retval = ERESTART;
 +			}
 +			break;
 +		default:
 +			break;
  	}
  	return (retval);
  }
 Index: scsipi_base.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/dev/scsipi/scsipi_base.c,v
 retrieving revision 1.48
 diff -u -r1.48 scsipi_base.c
 --- scsipi_base.c	2001/06/27 23:14:26	1.48
 +++ scsipi_base.c	2001/07/10 18:49:43
 @@ -797,8 +797,7 @@
  				periph->periph_flags &= ~PERIPH_MEDIA_LOADED;
  			if ((xs->xs_control & XS_CTL_IGNORE_NOT_READY) != 0)
  				return (0);
 -			if (sense->add_sense_code == 0x3A &&
 -			    sense->add_sense_code_qual == 0x00) {
 +			if (sense->add_sense_code == 0x3A) {
  				error = ENODEV; /* Medium not present */
  				if (xs->xs_control & XS_CTL_SILENT_NODEV)
  					return (error);

 --NzB8fVQJ5HfG6fxh--
Responsible-Changed-From-To: bin-bug-people->ad 
Responsible-Changed-By: ad 
Responsible-Changed-When: Mon Aug 20 10:50:11 BST 2001 
Responsible-Changed-Why:  
I'm working on this. 
State-Changed-From-To: open->closed 
State-Changed-By: ad 
State-Changed-When: Mon Aug 20 12:40:09 BST 2001 
State-Changed-Why:  
Sure this is fixed now. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.