From jau@jau.tmt.tele.fi Mon Mar 22 06:05:56 1999
Return-Path: <jau@jau.tmt.tele.fi>
Received: from jau.tmt.tele.fi (jau.tmt.tele.fi [194.252.70.165])
	by hub.freebsd.org (Postfix) with ESMTP id 6427E14CD0
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 22 Mar 1999 06:02:51 -0800 (PST)
	(envelope-from jau@jau.tmt.tele.fi)
Received: (from jau@localhost)
	by jau.tmt.tele.fi (8.9.1/8.9.1/JAU-2.2) id QAA01971;
	Mon, 22 Mar 1999 16:02:20 +0200 (EET)
Message-Id: <199903221402.QAA01971@jau.tmt.tele.fi>
Date: Mon, 22 Mar 1999 16:02:20 +0200 (EET)
From: "Jukka A. Ukkonen" <jau@jau.tmt.tele.fi>
Reply-To: jau@jau.tmt.tele.fi
To: FreeBSD-gnats-submit@freebsd.org
Subject: WCD driver does not recognize a recovered atapi/ide error
X-Send-Pr-Version: 3.2

>Number:         10728
>Category:       kern
>Synopsis:       WCD driver does not recognize a recovered atapi/ide error
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 22 06:10:00 PST 1999
>Closed-Date:    Mon Feb 28 11:33:37 PST 2000
>Last-Modified:  Mon Feb 28 11:34:10 PST 2000
>Originator:     Jukka A. Ukkonen
>Release:        FreeBSD 2.2.8-RELEASE i386
>Organization:
Sonera Ltd. / Internet Services
>Environment:

	FreeBSD 2.2.8-RELEASE based AMD/i486 with an ATAPI/IDE CD drive.

>Description:

	Occasionally the CD drives report a recovered error when the
	requested data is delayed. The driver code failed to recognize
	this situation and returned EIO in vain. By checking `dmesg'
	output the driver generated quite often log entries like these...

		wcd0: i/o error, status=51<ready,opdone,check>, error=30
		wcd0: i/o error, status=51<ready,opdone,check>, error=30
		wcd0: i/o error, status=51<ready,opdone,check>, error=30

	This tended to make e.g. workman sometimes fail to probe the CD
	status, and which time workman assumes there is no longer a CD
	in the drive. When the next status probe succeeded, workman then
	automatically started playing a disc with `automatically play this
	disc' set even though the disc had been previously manually stopped.

>How-To-Repeat:

	Simply start workman on a atapi/ide cd-drive like Mitsumi-FX400
	which occasionally report delayed completion of requested operations,
	insert a CD with `automatically play this disc' set, manually stop
	the disc, and let the disc stay in the drive.
	Sometimes it takes hours for this to happen, sometimes it happens
	in a matter of minutes. Anyhow when the problem occurs, there will
	be a new log entry for a recovered error, and workman will start
	playing the disc all by itself.

>Fix:

	This is a tentative patch, but at least workman no longer re-starts
	playing a stopped disc all by itself.
	I simply made the assumption that a delayed but recovered response
	from the drive is quite as much all right as any normal successful
	response.


--- /sys/i386/isa/wcd.c.old	Sun Mar 14 22:24:49 1999
+++ /sys/i386/isa/wcd.c	Sun Mar 14 22:55:12 1999
@@ -620,7 +620,8 @@
 	result = atapi_request_wait (t->ata, t->unit, cmd,
 		a1, a2, a3, a4, a5, a6, a7, a8, a9, 0, 0, 0, 0, 0, 0,
 		addr, count);
-	if (result.code) {
+	if (result.code
+	    && ((result.error & AER_SKEY) != AER_SK_RECOVERED_ERROR)) {
 		wcd_error (t, result);
 		return (EIO);
 	}
@@ -962,7 +963,8 @@
 			ATAPI_TEST_UNIT_READY, 0, 0, 0, 0, 0, 0, 0, 0,
 			0, 0, 0, 0, 0, 0, 0, 0, 0);
 	}
-	if (result.code) {
+	if (result.code
+	    && ((result.error & AER_SKEY) != AER_SK_RECOVERED_ERROR)) {
 		wcd_error (t, result);
 		return (EIO);
 	}
@@ -1084,7 +1086,8 @@
 		return (0);
 	}
 
-	if (result.code) {
+	if (result.code
+	    && ((result.error & AER_SKEY) != AER_SK_RECOVERED_ERROR)) {
 		wcd_error (t, result);
 		return (EIO);
 	}

>Release-Note:
>Audit-Trail:

From: Sheldon Hearn <sheldonh@iafrica.com>
To: "Jukka A. Ukkonen" <jau@jau.tmt.tele.fi>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/10728: WCD driver does not recognize a recovered atapi/ide error
Date: Tue, 23 Mar 1999 21:43:08 +0200

 Hi Jukka,
 
 The problem you reported is unlikely to receive attention in the 2.2
 branch for which active development is over.
 
 Do you get the same results using 3.1-STABLE or 4.0-CURRENT?
 
 Ciao,
 Sheldon.
 

From: "Jukka A. Ukkonen" <jau@jau.tmt.tele.fi>
To: sheldonh@iafrica.com (Sheldon Hearn)
Cc:  
Subject: Re: kern/10728: WCD driver does not recognize a recovered atapi/ide error
Date: Wed, 24 Mar 1999 12:07:46 +0200 (EET)

 Quoting Sheldon Hearn:
 > 
 > The problem you reported is unlikely to receive attention in the 2.2
 > branch for which active development is over.
 > 
 > Do you get the same results using 3.1-STABLE or 4.0-CURRENT?
 > 
 > Ciao,
 > Sheldon.
 
 	Actually I have not tested the wcd.c code for those versions,
 	because I have not had a chance to upgrade to 3.1 yet. I have
 	not even received my CD yet.
 
 	Anyhow I just had a quick look at the 3.1 code on nic.funet.fi
 	(a.k.a www.fi.freebsd.org), and it seems the wcd.c code has been
 	moved completely over to atapi-cd.c, but the strategy there still
 	seems to be exactly what caused fuzz in 2.2.8. The tests for the
 	result code in 3.1 atapi-cd.c are done like this
 
             if (result.code) {
                 atapi_error(cdp->ata, cdp->unit, result);
                 return EIO;
             }
 
 	This is exactly the same as in the old wcd.c in 2.2.8 (except the
 	name of the error function is not wcd_error) for which I changed
 	the if-condition to read
 
             if (result.code
                 && ((result.error & AER_SKEY) != AER_SK_RECOVERED_ERROR))
 
 	In general the logic in the new atapi-cd.c seems basically unchanged
 	from what it was in wcd.c in 2.2.8. So, I have every reason to
 	believe the same changes should still be applicable.
 
 
 	Cheers,
 		// jau
 .---  ..-  -.-  -.-  .-    .-  .-.-.-    ..-  -.-  -.-  ---  -.  .  -.
   /    Jukka A. Ukkonen,           Internet Services R&D / Sonera Ltd.
  /__   M.Sc. (sw-eng & cs)                     (Phone) +358-2040-63673
    /   Internet: Jukka.Ukkonen@sonera.fi         (Fax) +358-2040-64724
   /    Internet: jau@iki.fi                   (Mobile) +358-400-606671
  v     Internet: ukkonen@nic.funet.fi       (Home&Fax) +358-9-6215280
 
 
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Sun Mar 28 09:32:21 PST 1999 
Responsible-Changed-Why:  
Soren will be interested in the Audit Trail. 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Mon Feb 28 11:33:37 PST 2000 
State-Changed-Why:  
Fixed in 4.0. 
>Unformatted:
