From nobody@FreeBSD.org  Mon Aug  9 19:34:29 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CC41116A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  9 Aug 2004 19:34:29 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A84D043D3F
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  9 Aug 2004 19:34:29 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i79JYTYE022793
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 9 Aug 2004 19:34:29 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i79JYTL3022792;
	Mon, 9 Aug 2004 19:34:29 GMT
	(envelope-from nobody)
Message-Id: <200408091934.i79JYTL3022792@www.freebsd.org>
Date: Mon, 9 Aug 2004 19:34:29 GMT
From: Claudio Destro <o1b6@tiscali.it>
To: freebsd-gnats-submit@FreeBSD.org
Subject: 5.2-CURRENT does not recognize <CD-ROM CDU55E/1.0u> CDROM drive at ata1
X-Send-Pr-Version: www-2.3

>Number:         70227
>Category:       kern
>Synopsis:       5.2-CURRENT does not recognize <CD-ROM CDU55E/1.0u> CDROM drive at ata1
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 09 19:40:37 GMT 2004
>Closed-Date:    Mon Aug 16 11:57:14 GMT 2004
>Last-Modified:  Mon Aug 16 11:57:14 GMT 2004
>Originator:     Claudio Destro
>Release:        5.2-CURRENT
>Organization:
>Environment:
FreeBSD vulcan 5.2-CURRENT FreeBSD 5.2-CURRENT #2: Mon Aug  9 20:24:16 CEST 2004     root@vulcan:/mnt/ST52520A/usr-obj/usr/src/sys/VULCAN  i386
>Description:
the 5.2-CURRENT code in src/sys/dev/ata/ata-lowlevel.c does not recognize my 2x Sony CD-ROM on ata1.

The following dump is from dmesg bootverbose=yes before my patch:
..
atapci0: <Intel PIIX4 UDMA33 controller> port 0xb800-0xb80f,0x376,0x170-0x177,0x3f6,0x1f0-0x1f7 at device 4.1 on pci0
atapci0: Reserved 0x10 bytes for rid 0x20 type 4 at 0xb800
atapci0: Reserved 0x8 bytes for rid 0x10 type 4 at 0x1f0
atapci0: Reserved 0x1 bytes for rid 0x14 type 4 at 0x3f6
ata0: reset tp1 mask=03 ostat0=50 ostat1=00
ata0-master: stat=0x50 err=0x01 lsb=0x00 msb=0x00
ata0-slave:  stat=0x00 err=0x01 lsb=0x00 msb=0x00
ata0: reset tp2 stat0=50 stat1=00 devices=0x1<ATA_MASTER>
ata0: at 0x1f0 irq 14 on atapci0
ata0: [MPSAFE]
atapci0: Reserved 0x8 bytes for rid 0x18 type 4 at 0x170
atapci0: Reserved 0x1 bytes for rid 0x1c type 4 at 0x376
ata1: reset tp1 mask=03 ostat0=50 ostat1=50
ata1-master: stat=0x50 err=0x00 lsb=0x14 msb=0xeb
ata1-slave:  stat=0x50 err=0x50 lsb=0x50 msb=0x50
ata1-slave:  stat=0x50 err=0x50 lsb=0x50 msb=0x50
ata1-slave:  stat=0x50 err=0x50 lsb=0x50 msb=0x50
..
ata1-slave:  stat=0x50 err=0x50 lsb=0x50 msb=0x50
ata1-slave:  stat=0x50 err=0x50 lsb=0x50 msb=0x50
ata1-slave:  stat=0x50 err=0x50 lsb=0x50 msb=0x50
ata1: reset tp2 stat0=50 stat1=d0 devices=0x0
ata1: at 0x170 irq 15 on atapci0
ata1: [MPSAFE]
..

As you can see ata0 is correctly and quickly recognized, while ata1 is not. I think there is another problem with "stat=0x50 err=0x50 lsb=0x50 msb=0x50" because I have no more CD-ROMs attached, but I don't know how to fix it.
>How-To-Repeat:
      
>Fix:
This patch solves the immediate problem, and in fact it works for me (now I can see my CD-ROM), but I am new to FreeBSD and also I don't know whether this is a correct solution or not: here I simply assume that when err == 0 then it simply means no errors.

--- ata-lowlevel.c.orig	Sun Aug  8 22:36:18 2004
+++ ata-lowlevel.c	Mon Aug  9 20:00:03 2004
@@ -601,7 +601,7 @@
 			   "stat=0x%02x err=0x%02x lsb=0x%02x msb=0x%02x\n",
 			   stat0, err, lsb, msb);
 	    if (!(stat0 & ATA_S_BUSY)) {
-		if ((err & 0x7f) == ATA_E_ILI) {
+		if ((err & 0x7f) == 0 || (err & 0x7f) == ATA_E_ILI) {
 		    if (lsb == ATAPI_MAGIC_LSB && msb == ATAPI_MAGIC_MSB) {
 			ch->devices |= ATA_ATAPI_MASTER;
 		    }
@@ -626,7 +626,7 @@
 			   " stat=0x%02x err=0x%02x lsb=0x%02x msb=0x%02x\n",
 			   stat1, err, lsb, msb);
 	    if (!(stat1 & ATA_S_BUSY)) {
-		if ((err & 0x7f) == ATA_E_ILI) {
+		if ((err & 0x7f) == 0 || (err & 0x7f) == ATA_E_ILI) {
 		    if (lsb == ATAPI_MAGIC_LSB && msb == ATAPI_MAGIC_MSB) {
 			ch->devices |= ATA_ATAPI_SLAVE;
 		    }

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: simon 
Responsible-Changed-When: Mon Aug 9 19:52:12 GMT 2004 
Responsible-Changed-Why:  
Over to ata(4) maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=70227 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Mon Aug 16 11:40:25 GMT 2004 
State-Changed-Why:  
That change wont fly, that bit is needed as part of the spec to 
signal a valid device is there. 

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