Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Jan 1998 15:44:19 +0100 (CET)
From:      Luigi Rizzo <luigi@iet.unipi.it>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   kern/5510: Incomplete ATAPI diagnostic at boot
Message-ID:  <199801161444.PAA01301@prova.iet.unipi.it>

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

>Number:         5510
>Category:       kern
>Synopsis:       Incomplete ATAPI diagnostic at boot
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 16 06:50:01 PST 1998
>Last-Modified:
>Originator:     Luigi Rizzo
>Organization:
DEIT
>Release:        all
>Environment:

	wcd (atapi) driver, all versions of FreeBSD, ATAPI cdrom

>Description:

	Some ATAPI CD ROM drives return an error to the
	ATAPI_MODE_SENSE command more than once at boot time. This
	behaviour is not deterministic and might be due to timing
	issues (how fast is the boot phase, how long the drive takes
	to identify the media, etc.).

	The following patch retries the ATAPI_MODE_SENSE command
	several times to leave the drive time to settle and return
	without errors.

>How-To-Repeat:

    boot a 2.2.x kernel on a system with ATAPI cdrom, and try
    how it works during cold vs. warm boot, or with tray
    open/closed, data or audio cd, etc.

    At times, the drive returns two errors and you will not see
    reports like
    wcd0: 344Kb/sec, 256Kb cache, audio play, 256 volume levels, ...

>Fix:

	Apply the following patch. Tested on 2.2.1, should apply
	cleanly to all versions and has no side effects I believe
	(I set the number of retries to 10, although I have never seen
	more than 3 or perhaps 4 necessary on my machines).
	

--- wcd.c.orig	Sun Sep  8 12:28:23 1996
+++ wcd.c	Thu Jan 15 17:38:29 1998
@@ -272,6 +272,7 @@
 	struct wcd *t;
 	struct atapires result;
 	int lun;
+	int loops = 0 ;
 
 	if (wcdnlun >= NUNIT) {
 		printf ("wcd: too many units\n");
@@ -302,18 +303,14 @@
 	}
 
 	/* Get drive capabilities. */
+	for (loops = 0 ; loops < 10 ; loops++) {
+	     /* some drives are slow to respond at boot time... */
 	result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE,
 		0, CAP_PAGE, 0, 0, 0, 0, sizeof (t->cap) >> 8, sizeof (t->cap),
 		0, 0, 0, 0, 0, 0, 0, (char*) &t->cap, sizeof (t->cap));
-
-	/* Do it twice to avoid the stale media changed state. */
-	if (result.code == RES_ERR &&
-	    (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)
-		result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE,
-			0, CAP_PAGE, 0, 0, 0, 0, sizeof (t->cap) >> 8,
-			sizeof (t->cap), 0, 0, 0, 0, 0, 0, 0,
-			(char*) &t->cap, sizeof (t->cap));
-
+	    if (result.code == 0 || result.code == RES_UNDERRUN)
+		    break;
+	}
 	/* Some drives have shorter capabilities page. */
 	if (result.code == RES_UNDERRUN)
 		result.code = 0;


>Audit-Trail:
>Unformatted:



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