From root@daniel.sobral  Sat Oct  5 20:15:58 1996
Received: from daniel.sobral (dl0123-bsb.GNS.com.br [200.239.56.123])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id UAA02694
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 5 Oct 1996 20:15:33 -0700 (PDT)
Received: (from root@localhost) by daniel.sobral (8.7.5/8.7.3) id AAA00626; Sun, 6 Oct 1996 00:17:10 -0300 (EST)
Message-Id: <199610060317.AAA00626@daniel.sobral>
Date: Sun, 6 Oct 1996 00:17:10 -0300 (EST)
From: dcs@gns.com.br
Reply-To: dcs@gns.com.br
To: FreeBSD-gnats-submit@freebsd.org
Subject: ATAPI driver does not work with HITACHI CDR-7730
X-Send-Pr-Version: 3.2

>Number:         1730
>Category:       i386
>Synopsis:       SFF8020 violation and silly bug in atapi.c hinder it's working with HITACHI CDR-7730
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    sos
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct  5 20:20:02 PDT 1996
>Closed-Date:    Fri May 23 09:10:08 PDT 1997
>Last-Modified:  Fri May 23 09:11:55 PDT 1997
>Originator:     Daniel C. Sobral
>Release:        FreeBSD 2.2-961004-SNAP i386
>Organization:
>Environment:

	
960801-SNAPSHOT with current (961004) kernel and HITACHI CDR-7730
CD-ROM drive (slave in secondary IDE).

>Description:

	
The drive gets recognized but wcd_describe is rarely called, and
even when that happens you can't mount the drive.

This happens because a DELAY is missing in one loop, and ARS_BSY
flag is being ignored in another (atapi_request_immediate and
atapi_wait_cmd functions).

>How-To-Repeat:

	
Install an HITACHI CDR-7730 CD-ROM drive as slave in the secondary IDE
(well, I haven't tried other setups... :), configure ATAPI options in the
kernel, reboot.

dmesg | grep wcd0			#Shows nothing most of the time
mount -t cd9660 -r /dev/wcd0c /mnt	#Won't work

>Fix:
	
	
Apply this patch (unified diff):


--- atapi.c	1996/10/05 21:06:44	1.1
+++ atapi.c	1996/10/06 02:25:16	1.1.1.2
@@ -585,7 +585,7 @@
 		ireason = inb (ata->port + AR_IREASON);
 		ac->result.status = inb (ata->port + AR_STATUS);
 		phase = (ireason & (ARI_CMD | ARI_IN)) |
-			(ac->result.status & ARS_DRQ);
+			(ac->result.status & (ARS_DRQ|ARS_BSY));
 		if (phase == PHASE_CMDOUT)
 			break;
 		DELAY (10);
@@ -898,8 +898,11 @@
 		while (atapi_io (ata, ac))
 			/* Wait for DRQ deassert. */
 			for (cnt=2000; cnt>0; --cnt)
+				{
 				if (! (inb (ata->port + AR_STATUS) & ARS_DRQ))
 					break;
+				DELAY(10);
+				}
 	}
 	return (ac->result);
 }
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: sos 
Responsible-Changed-When: Sat Feb 22 03:17:43 PST 1997 
Responsible-Changed-Why:  
SOS is the Atapi man... 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Fri May 23 09:10:08 PDT 1997 
State-Changed-Why:  


Patch integrated in -current (2.2.x candidate). 
Tested on all the drives I have access to in (I hope) all combinations. 
>Unformatted:
