From gmenhennitt@optusnet.com.au  Tue Mar 29 09:21:50 2005
Return-Path: <gmenhennitt@optusnet.com.au>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3744616A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 29 Mar 2005 09:21:50 +0000 (GMT)
Received: from mail09.syd.optusnet.com.au (mail09.syd.optusnet.com.au [211.29.132.190])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 39DDB43D41
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 29 Mar 2005 09:21:49 +0000 (GMT)
	(envelope-from gmenhennitt@optusnet.com.au)
Received: from [203.2.73.8] (c220-237-137-84.mckinn1.vic.optusnet.com.au [220.237.137.84])
	by mail09.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id j2T9LkZG006155
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 29 Mar 2005 19:21:46 +1000
Message-Id: <42491DAB.4040009@optusnet.com.au>
Date: Tue, 29 Mar 2005 19:19:39 +1000
From: Graham Menhennitt <gmenhennitt@optusnet.com.au>
To: FreeBSD-gnats-submit@freebsd.org
Subject: <synopsis of the problem (one line)>

>Number:         79332
>Category:       kern
>Synopsis:       [ata] [patch] "ffs_mountroot: can't find rootvp" after change 1.51 to ata-lowlevel.c
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 29 09:30:02 GMT 2005
>Closed-Date:    Mon Sep 25 10:45:56 GMT 2006
>Last-Modified:  Mon Sep 25 10:45:56 GMT 2006
>Originator:     Graham Menhennitt
>Release:        FreeBSD 5.4-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD fang.mencon.com.au 5.4-PRERELEASE FreeBSD 5.4-PRERELEASE #22: Mon Mar 28 16:13:27 EST 2005 root@fang.mencon.com.au:/usr/obj/usr/src/sys/fang i386
FreeBSD 5.4-PRERELEASE i386 kernel
single disk drive ad0: 76319MB <ST380011A/3.06> [155061/16/63] at 
ata0-master UDMA100

>Description:
The disk drive is not detected by the kernel at boot time. The boot 
fails with "ffs_mountroot: can't find rootvp". The disk was previously 
detected correctly with a kernel built in January. There have been no 
hardware changes or kernel config changes since then.
>How-To-Repeat:
Boot a kernel built from recent source using the above disk drive. 
If the "-v" flag is specified in the boot, during the disk probe, the line
          ata0-master: stat=0x90 err=0x90 lsb=0x90 msb=0x90
appears 8 times. This seems to not be enough probes. In the January 
kernel, that line appears 14 times before it changes to
          ata0-master: stat=0x50 err=0x01 lsb=0x00 msb=0x00
This is 100% reproducable on this machine and disk.
>Fix:
It appears to have been broken by change 1.51 to ata-lowlevel.c 
which was MFC'd as change 1.44.2.4. Applying the following patch to the 
current version of this file (1.44.2.5) reverses some of that change and 
fixes the problem.

--- ata-lowlevel.c    Mon Mar 28 15:59:57 2005
+++ ata-lowlevel.c_orig    Wed Mar 23 19:17:46 2005
@@ -605,19 +605,26 @@
       }
   }
   if (mask == 0x01)    /* wait for master only */
-        if (!(stat0 & ATA_S_BUSY) || (stat0 == 0xff && timeout > 5))
+        if (!(stat0 & ATA_S_BUSY) || (stat0 == 0xff && timeout > 5) ||
+        (stat0 == err && lsb == err && msb == err && timeout > 5))
       break;
   if (mask == 0x02)    /* wait for slave only */
-        if (!(stat1 & ATA_S_BUSY) || (stat1 == 0xff && timeout > 5))
+        if (!(stat1 & ATA_S_BUSY) || (stat1 == 0xff && timeout > 5) ||
+        (stat1 == err && lsb == err && msb == err && timeout > 5))
       break;
   if (mask == 0x03) {    /* wait for both master & slave */
       if (!(stat0 & ATA_S_BUSY) && !(stat1 & ATA_S_BUSY))
       break;
-        if (stat0 == 0xff && timeout > 5)
+        if ((stat0 == 0xff && timeout > 5) ||
+        (stat0 == err && lsb == err && msb == err && timeout > 5))
       mask &= ~0x01;
-        if (stat1 == 0xff && timeout > 5)
+        if ((stat1 == 0xff && timeout > 5) ||
+        (stat1 == err && lsb == err && msb == err && timeout > 5))
       mask &= ~0x02;
   }
+    if (mask == 0 && !(stat0 & ATA_S_BUSY) && !(stat1 & ATA_S_BUSY))
+        break;
+
   ata_udelay(100000);
   }   
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Mar 29 10:05:26 GMT 2005 
Responsible-Changed-Why:  
Attempt to rescue this horribly mangled PR from the 'pending' category. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=79332 

From: Graham Menhennitt <gmenhennitt@optusnet.com.au>
To: freebsd-gnats-submit@FreeBSD.org, gmenhennitt@optusnet.com.au
Cc:  
Subject: Re: kern/79332: [patch] "ffs_mountroot: can't find rootvp" after
 change 1.51 to ata-lowlevel.c
Date: Mon, 04 Apr 2005 21:17:31 +1000

 An alternate fix seems to be changing the
     ata_udelay(100000);
 to
     ata_udelay(400000);
 at line 628 in ata-lowlevel.c version 1.44.2.4. Changing to 300000 is 
 not sufficient.
 
 Graham Menhennitt

From: Graham Menhennitt <gmenhennitt@optusnet.com.au>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/79332: [patch] "ffs_mountroot: can't find rootvp" after
 change 1.51 to ata-lowlevel.c
Date: Wed, 07 Sep 2005 21:18:52 +1000

 This appears to be fixed in 6.0 beta 3.
State-Changed-From-To: open->patched 
State-Changed-By: linimon 
State-Changed-When: Wed Sep 7 13:39:19 GMT 2005 
State-Changed-Why:  
Set to 'patched' as a possible MT5 reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=79332 
State-Changed-From-To: patched->closed 
State-Changed-By: delphij 
State-Changed-When: Mon Sep 25 10:45:06 UTC 2006 
State-Changed-Why:  
mdodd@ has MFC'ed the change as part of 1.44.2.4 to RELENG_5. 

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