From root@xena.gsicomp.on.ca  Sun Feb 25 21:36:57 2001
Return-Path: <root@xena.gsicomp.on.ca>
Received: from xena.gsicomp.on.ca (cr677933-a.ktchnr1.on.wave.home.com [24.43.230.149])
	by hub.freebsd.org (Postfix) with ESMTP id DD03437B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 25 Feb 2001 21:36:56 -0800 (PST)
	(envelope-from root@xena.gsicomp.on.ca)
Received: (from root@localhost)
	by xena.gsicomp.on.ca (8.11.1/8.9.3) id f1Q5ZBZ10641;
	Mon, 26 Feb 2001 00:35:11 -0500 (EST)
	(envelope-from root)
Message-Id: <200102260535.f1Q5ZBZ10641@xena.gsicomp.on.ca>
Date: Mon, 26 Feb 2001 00:35:11 -0500 (EST)
From: matt@gsicomp.on.ca
Reply-To: matt@gsicomp.on.ca
To: FreeBSD-gnats-submit@freebsd.org
Subject: ATA subsystem in 4.x fails to recognize some ATA CD-ROMs
X-Send-Pr-Version: 3.2

>Number:         25370
>Category:       kern
>Synopsis:       ATA subsystem in 4.x fails to recognize some ATA CD-ROMs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 25 21:40:02 PST 2001
>Closed-Date:    Mon Apr 16 14:22:47 PDT 2001
>Last-Modified:  Mon Apr 16 14:23:57 PDT 2001
>Originator:     Matt Emmerton
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
GSI Computer Services
>Environment:

4.2-STABLE FreeBSD 4.2-STABLE #1: Sat Feb 10 23:23:51 EST 2001

>Description:

	During a boot, ATA devices are probed.  During the CD probe,
	drives are asked to provide their "capabilities page" which 
	provides details of the drive.

	In 3.x, if a drive failed to respond to this request, some
	some defaults were filled in and the device was configured
	and enabled.

	In 4.x, if a drive fails to respond, it is treated as a hard
	error and the drive is not configured and enabled.
	
	Many older first generation CD-ROM devices (in particular, any
	MKE/Panasonic 1/2/4x "Creative" drive) do not properly respond
	to this request, and hence are not usable under 4.x

	The following patch forces the ATA driver to ignore "ABORTED
	COMMAND" results when executing a "MODE_SENSE_BIG" command, 
	which used during a drive probe to extract the capabilities
	page.  This allows older drives to be detected and used under
	4.x.

>How-To-Repeat:

	Build any 4.x kernel on a machine with one of these drives.
	Boot and you'll get this:

Feb 25 23:08:44 styx /kernel: (null): MODE_SENSE_BIG DONEDRQ
Feb 25 23:08:44 styx /kernel: (null): read data overrun 65526/1
Feb 25 23:08:44 styx /kernel: (null): MODE_SENSE_BIG - ABORTED COMMAND asc=4e ascq=00 error=00
Feb 25 23:08:45 styx /kernel: ata0-slave: <MATSHITA CR-581/1.00> CDROM device - NO DRIVER!

>Fix:

	This patch has been tested on 4-STABLE (as of a few hours ago)
	and a prior revision was tested on 4.2-RELEASE with positive
	results.

451a452,462
 	    case ATAPI_SK_ABORTED_COMMAND:
 		/* This allows first-generation ATAPI devices (such
 		 * as MKE/Panasonic "Creative" CD-ROMs) that don't
 		 * respond properly to MODE_SENSE_BIG to still be 
 		 * detected and recognized by the ata subsystem, 
 		 * as they were in 3.x)
 		 */
 		if (atp->cmd == ATAPI_MODE_SENSE_BIG)
 			break;
 		/* FALLTHROUGH */

>Release-Note:
>Audit-Trail:

From: "Matthew Emmerton" <matt@gsicomp.on.ca>
To: <freebsd-gnats-submit@FreeBSD.org>
Cc:  
Subject: Re: kern/25370: ATA subsystem in 4.x fails to recognize some ATA CD-ROMs
Date: Mon, 26 Feb 2001 20:08:53 -0500

 Here's the patch in a more usuable format.
 
 I realize that this code may cause problems for ATA floppy devices, although
 I believe an "aborted command" response from a ATA floppy may be indicative
 of a "device powering up" situation which is similar to the case of the
 CD-ROM.
 
 --- sys/dev/ata/atapi-all.c.orig Sun Feb 25 16:35:20 2001
 +++ sys/dev/ata/atapi-all.c Sun Feb 25 23:50:08 2001
 @@ -449,6 +449,17 @@
    request->error = EIO;
    break;
 
 +     case ATAPI_SK_ABORTED_COMMAND:
 +  /* This allows first-generation ATAPI devices (such
 +   * as MKE/Panasonic "Creative" CD-ROMs) that don't
 +   * respond properly to MODE_SENSE_BIG to still be
 +   * detected and recognized by the ata subsystem,
 +   * as they were in 3.x)
 +   */
 +  if (atp->cmd == ATAPI_MODE_SENSE_BIG)
 +   break;
 +  /* FALLTHROUGH */
 +
       default:
    printf("%s: %s - %s asc=%02x ascq=%02x ",
           atp->devname, atapi_cmd2str(atp->cmd),
 

From: "Matthew Emmerton" <matt@gsicomp.on.ca>
To: <freebsd-gnats-submit@FreeBSD.org>, <matt@gsicomp.on.ca>,
	<sos@FreeBSD.org>
Cc:  
Subject: Re: kern/25370: ATA subsystem in 4.x fails to recognize some ATA CD-ROMs
Date: Mon, 19 Mar 2001 14:54:22 -0500

 I tested my previous patch using some afd devices, and that caused
 undesireable effects.
 
 After considerable time learning the ata code, I've created an updated patch
 which should fix the problem.
 
 <PATCH>
 --- sys/dev/ata/atapi-all.c.orig        Mon Mar 19 14:48:51 2001
 +++ sys/dev/ata/atapi-all.c     Mon Mar 19 14:49:00 2001
 @@ -391,7 +391,7 @@
                 atapi_read(request, length);
             else
                 atapi_write(request, length);
 -           /* FALLTHROUGH */
 +           return ATA_OP_CONTINUES;
 
         case ATAPI_P_ABORT:
         case ATAPI_P_DONE:
 </PATCH>
 
 
 boot output:
 (null): MODE_SENSE_BIG command timeout - resetting
 ata0: resetting devices .. done
 (null): MODE_SENSE_BIG DONEDRQ
 (null): read data overrun 65526/1
 (null): MODE_SENSE_BIG command timeout - resetting
 ata0: resetting devices .. done
 (null): read data overrun 29/0
 acd0: CDROM <MATSHITA CR-581> at ata0-slave using BIOSPIO
 
 boot -v output:
 acd0: <MATSHITA CR-581/1.00> CDROM drive at ata0 as slave
 acd0: read 689KB/s (689KB/s), 128KB buffer, BIOSPIO
 acd0: Reads: CD-DA
 acd0: Audio: play, 256 volume levels
 acd0: Mechanism: ejectable tray
 acd0: Medium: no/blank disc inside, unlocked
 
 
 Clearly, the proper capabilities page is being read, so the command is
 succeeding.  Mounting disks and performing read actions do not appear to
 cause problems.
 
 According to the ATAPI spec that I had access to (Rev 2.6 Proposed,
 1/22/96), DRQ is set when the device is ready to accept a packet command,
 and is cleared once the device receives the command.  In this sense,
 ATAPI_P_DONEDRQ is exactly the same as ATAPI_P_READ and ATAPI_P_WRITE, which
 are used for successive read/writes of additional data for the same command.
 Hence, ATAPI_P_DONEDRQ should return ATA_OP_CONTINUES rather than
 fallthrough.
 
 By falling through, the command is returned prematurely with request->error
 set (as a result of the command timeout caused by the sluggishness of the
 ancient devices in question).  The if/then statement immediately after
 utimeout() picks it up, queues a REQUEST_SENSE command, which then causes
 the driver to bail with "ABORTED COMMAND" (see original comments in PR), as
 the initial MODE_SENSE_BIG command has yet to complete.
 
 

From: Soren Schmidt <sos@freebsd.dk>
To: matt@gsicomp.on.ca (Matthew Emmerton)
Cc: freebsd-gnats-submit@FreeBSD.org, sos@FreeBSD.org
Subject: Re: kern/25370: ATA subsystem in 4.x fails to recognize some ATA CD-ROMs
Date: Mon, 19 Mar 2001 21:56:20 +0100 (CET)

 It seems Matthew Emmerton wrote:
 > After considerable time learning the ata code, I've created an updated patch
 > which should fix the problem.
 > 
 > <PATCH>
 > --- sys/dev/ata/atapi-all.c.orig        Mon Mar 19 14:48:51 2001
 > +++ sys/dev/ata/atapi-all.c     Mon Mar 19 14:49:00 2001
 > @@ -391,7 +391,7 @@
 >                 atapi_read(request, length);
 >             else
 >                 atapi_write(request, length);
 > -           /* FALLTHROUGH */
 > +           return ATA_OP_CONTINUES;
 > 
 >         case ATAPI_P_ABORT:
 >         case ATAPI_P_DONE:
 > </PATCH>
 > boot output:
 > (null): MODE_SENSE_BIG command timeout - resetting
 > ata0: resetting devices .. done
 > (null): MODE_SENSE_BIG DONEDRQ
 > (null): read data overrun 65526/1
 > (null): MODE_SENSE_BIG command timeout - resetting
 > ata0: resetting devices .. done
 > (null): read data overrun 29/0
 > acd0: CDROM <MATSHITA CR-581> at ata0-slave using BIOSPIO
 
 Hmm, well it still sortof fails, and it breaks devices that actually
 use ATAPI_P_DONEDRQ (which by the way is another abuse of the spec),
 since it is meant for devices that return the DONE part of the
 protocol together with the last part of the data. Now if you 
 return ATA_OP_CONTINUES the driver will wait for a new interrupt 
 which wont occur..
 
 -Sren
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: kris 
Responsible-Changed-When: Fri Mar 23 21:39:25 PST 2001 
Responsible-Changed-Why:  
sos is Mr ATA 

http://www.freebsd.org/cgi/query-pr.cgi?pr=25370 
State-Changed-From-To: open->analyzed 
State-Changed-By: sos 
State-Changed-When: Mon Apr 2 12:55:47 PDT 2001 
State-Changed-Why:  

Try this patch, it should restore the sam behavior as 3.x had 
(allthough it wrong and needs a try fix) 

--- atapi-cd.c  2001/03/27 10:22:50     1.87 
+++ atapi-cd.c  2001/04/02 20:00:01 
@@ -128,10 +128,12 @@ 
(caddr_t)&cdp->cap, sizeof(cdp->cap)))) 
break; 
} 
+#if 0 
if (error) { 
free(cdp, M_ACD); 
return -1; 
} 
+#endif 
cdp->cap.max_read_speed = ntohs(cdp->cap.max_read_speed); 
cdp->cap.cur_read_speed = ntohs(cdp->cap.cur_read_speed); 
cdp->cap.max_write_speed = ntohs(cdp->cap.max_write_speed); 


http://www.freebsd.org/cgi/query-pr.cgi?pr=25370 
State-Changed-From-To: analyzed->closed 
State-Changed-By: sos 
State-Changed-When: Mon Apr 16 14:22:47 PDT 2001 
State-Changed-Why:  

This is fixed in current. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=25370 
>Unformatted:
