NetBSD Problem Report #25659
Received: (qmail 28516 invoked by uid 605); 21 May 2004 19:52:49 -0000
Message-Id: <20040521194745.7E3E677F9@berkshire.research.att.com>
Date: Fri, 21 May 2004 15:47:45 -0400 (EDT)
From: smb@research.att.com
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: smb@research.att.com
To: gnats-bugs@gnats.NetBSD.org
Subject: pcmcia IDE drive not recognized because of power-on delay
X-Send-Pr-Version: 3.95
>Number: 25659
>Category: kern
>Synopsis: pcmcia IDE drive not recognized because of drive's power-on delay
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bouyer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri May 21 19:53:00 +0000 2004
>Closed-Date: Wed Jul 05 17:18:01 +0000 2006
>Last-Modified: Wed Jul 05 17:18:01 +0000 2006
>Originator: Steven M. Bellovin
>Release: NetBSD 2.0_BETA
>Organization:
AT&T Labs Research
>Environment:
System: NetBSD berkshire.research.att.com 2.0_BETA NetBSD 2.0_BETA (BERKSHIRE) #8: Thu May 20 15:11:07 EDT 2004 smb@berkshire.research.att.com:/usr/src/sys/arch/i386/compile/BERKSHIRE i386
Architecture: i386
Machine: i386
>Description:
When I connected an IDE drive to a PCMCIA controller, the
controller was recognized, but not the drive. Debugging output
showed that both channels were showing BSY for a few seconds;
apparently, the specs say that that can go on for 31 seconds.
>How-To-Repeat:
Connect a drive to a controller, plug in, and wait. If you
wish, set wdcdebug_mask to 0x10 to see the status codes.
>Fix:
Enclosed below is a patch to /sys/dev/ic/wdc.c. It will repeat
the drive poll a few times -- how many is settable at run-time
via ddb -- with a one-second delay between tries.
Index: wdc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/wdc.c,v
retrieving revision 1.172
diff -r1.172 wdc.c
476a477,478
> int wdc_delay_cnt = 5;
>
484a487
> int bcnt;
493,494c496,501
< if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
< wdc->select(chp,0);
---
> /* This loop is a hack; it should be a poll based on
> timer interrupts. --smb */
> bcnt = 0;
> do {
> if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
> wdc->select(chp,0);
496,503c503,507
< bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
< WDSD_IBM);
< delay(10); /* 400ns delay */
< st0 = bus_space_read_1(chp->cmd_iot,
< chp->cmd_iohs[wd_status], 0);
<
< if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
< wdc->select(chp,1);
---
> bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
> WDSD_IBM);
> delay(10); /* 400ns delay */
> st0 = bus_space_read_1(chp->cmd_iot,
> chp->cmd_iohs[wd_status], 0);
505,509c509,524
< bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
< WDSD_IBM | 0x10);
< delay(10); /* 400ns delay */
< st1 = bus_space_read_1(chp->cmd_iot,
< chp->cmd_iohs[wd_status], 0);
---
> if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
> wdc->select(chp,1);
>
> bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
> WDSD_IBM | 0x10);
> delay(10); /* 400ns delay */
> st1 = bus_space_read_1(chp->cmd_iot,
> chp->cmd_iohs[wd_status], 0);
>
> if ((st0 & WDCS_BSY) == 0 && (st1 & WDCS_BSY) == 0)
> break;
> delay(1000000);
> WDCDEBUG_PRINT(("%s:%d: 'busy' set (0x%x,0x%x)\n",
> wdc != NULL ? wdc->sc_dev.dv_xname : "wdcprobe",
> chp->ch_channel, st0, st1), DEBUG_PROBE);
> } while (bcnt++ < wdc_delay_cnt);
>Release-Note:
>Audit-Trail:
From: buhrow@lothlorien.nfbcal.org (Brian Buhrow)
To: gnats-bugs@netbsd.org
Cc: buhrow@lothlorien.nfbcal.org
Subject: Re: kern/25659: drive not recognized because of delays
Date: Thu, 21 Apr 2005 15:08:21 -0700
Hello. I'm finding that this problem plagues IDE drives attached to
standard IDE controllers as well as the problem Steven outlines above.
Below is a patch to wdc.c which addresses the issues I'm seeing with a
number of drives attached to Intel IDE controllers driven by the piixide(4)
driver.
In general, I think wdc.c is a bit too trigger happy, and given the
increasing speeds of processors, slowing it down a bit will lead to fewer
failures to recognize attached drives.
The following patch is tested and works on production machines. I
hope this issue can be addressed before NetBSD-3 comes out.
In the mean time, I hope someone finds this useful
-Brian
P.S. This is patched against the netBSD-2-0 branch of the wdc.c file.
Index: wdc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/wdc.c,v
retrieving revision 1.172.2.7
diff -u -r1.172.2.7 wdc.c
--- wdc.c 17 Sep 2004 04:04:57 -0000 1.172.2.7
+++ wdc.c 21 Apr 2005 20:56:30 -0000
@@ -206,13 +206,13 @@
}
/* for ATA/OLD drives, wait for DRDY, 3s timeout */
- for (i = 0; i < mstohz(3000); i++) {
+ for (i = 0; i < mstohz(9000); i++) {
if (chp->ch_drive[0].drive_flags & (DRIVE_ATA|DRIVE_OLD)) {
if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
wdc->select(chp,0);
bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh],
0, WDSD_IBM);
- delay(10); /* 400ns delay */
+ delay(40); /* 400ns delay */
st0 = bus_space_read_1(chp->cmd_iot,
chp->cmd_iohs[wd_status], 0);
}
@@ -222,7 +222,7 @@
wdc->select(chp,1);
bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh],
0, WDSD_IBM | 0x10);
- delay(10); /* 400ns delay */
+ delay(40); /* 400ns delay */
st1 = bus_space_read_1(chp->cmd_iot,
chp->cmd_iohs[wd_status], 0);
}
@@ -246,7 +246,7 @@
chp->ch_channel, st0, st1), DEBUG_PROBE);
/* Wait a bit, some devices are weird just after a reset. */
- delay(5000);
+ delay(9000);
for (i = 0; i < 2; i++) {
/* XXX This should be done by other code. */
@@ -503,7 +503,7 @@
bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
WDSD_IBM);
- delay(10); /* 400ns delay */
+ delay(40); /* 400ns delay */
st0 = bus_space_read_1(chp->cmd_iot,
chp->cmd_iohs[wd_status], 0);
@@ -512,10 +512,11 @@
bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
WDSD_IBM | 0x10);
- delay(10); /* 400ns delay */
+ delay(40); /* 400ns delay */
st1 = bus_space_read_1(chp->cmd_iot,
chp->cmd_iohs[wd_status], 0);
+ delay(1000000);
WDCDEBUG_PRINT(("%s:%d: before reset, st0=0x%x, st1=0x%x\n",
wdc != NULL ? wdc->sc_dev.dv_xname : "wdcprobe",
chp->ch_channel, st0, st1), DEBUG_PROBE);
@@ -700,17 +701,17 @@
if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
wdc->select(chp,0);
bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0, WDSD_IBM);
- delay(10); /* 400ns delay */
+ delay(40); /* 400ns delay */
/* assert SRST, wait for reset to complete */
bus_space_write_1(chp->ctl_iot, chp->ctl_ioh, wd_aux_ctlr,
WDCTL_RST | WDCTL_IDS | WDCTL_4BIT);
- DELAY(1000);
+ DELAY(4000);
bus_space_write_1(chp->ctl_iot, chp->ctl_ioh, wd_aux_ctlr,
WDCTL_IDS | WDCTL_4BIT);
- DELAY(2000);
+ DELAY(8000);
(void) bus_space_read_1(chp->cmd_iot, chp->cmd_iohs[wd_error], 0);
bus_space_write_1(chp->ctl_iot, chp->ctl_ioh, wd_aux_ctlr, WDCTL_4BIT);
- delay(10); /* 400ns delay */
+ delay(40); /* 400ns delay */
/* ACK interrupt in case there is one pending left (Promise ATA100) */
if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_IRQACK))
wdc->irqack(chp);
@@ -738,7 +739,7 @@
wdc->select(chp,drive);
bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
WDSD_IBM | (drive << 4));
- delay(10); /* 400ns delay */
+ delay(80); /* 400ns delay */
/* Save registers contents */
sc = bus_space_read_1(chp->cmd_iot,
chp->cmd_iohs[wd_seccnt], 0);
@@ -1030,14 +1031,14 @@
s = splbio();
/* master */
bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0, WDSD_IBM);
- delay(10); /* 400ns delay */
+ delay(40); /* 400ns delay */
bus_space_write_1(chp->ctl_iot, chp->ctl_ioh, wd_aux_ctlr,
WDCTL_RST | WDCTL_IDS | WDCTL_4BIT);
delay(2000);
(void) bus_space_read_1(chp->cmd_iot, chp->cmd_iohs[wd_error], 0);
bus_space_write_1(chp->ctl_iot, chp->ctl_ioh, wd_aux_ctlr,
WDCTL_4BIT | WDCTL_IDS);
- delay(10); /* 400ns delay */
+ delay(40); /* 400ns delay */
if (poll != RESET_SLEEP) {
if (wdc->cap & WDC_CAPABILITY_IRQACK)
wdc->irqack(chp);
@@ -1710,7 +1711,7 @@
* Polled command. Wait for drive ready or drq. Done in intr().
* Wait for at last 400ns for status bit to be valid.
*/
- delay(10); /* 400ns delay */
+ delay(40); /* 400ns delay */
__wdccommand_intr(chp, xfer, 0);
}
@@ -1862,7 +1863,7 @@
/* enable interrupts */
bus_space_write_1(chp->ctl_iot, chp->ctl_ioh, wd_aux_ctlr,
WDCTL_4BIT);
- delay(10); /* some drives need a little delay here */
+ delay(40); /* some drives need a little delay here */
}
wdc_free_xfer(chp, xfer);
if (wdc_c->flags & AT_WAIT)
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/25659: drive not recognized because of delays
Date: Fri, 22 Apr 2005 08:47:21 +0200
On Thu, Apr 21, 2005 at 10:09:01PM +0000, Brian Buhrow wrote:
> In general, I think wdc.c is a bit too trigger happy, and given the
> increasing speeds of processors, slowing it down a bit will lead to fewer
> failures to recognize attached drives.
Uhm, none of the changes you proposed would change any processor speed
dependend things.
I think the timeout values come from the ATA standard, and I wouldn't mind to
change the outer loop controlls to i.e. give bogus drives twice the time as
the standard permits (while not affecting good drives) - but you are touching
a lot of the inner small delays, is that realy needed?
Martin
From: John Refling <refling@stanfordalumni.org>
To: netbsd <gnats-bugs@NetBSD.org>
Cc:
Subject: Re: kern/25659
Date: Fri, 10 Jun 2005 01:11:30 -0700
I have a pcmcia ide controller and drive
package called "Data Disaster Recovery System
for Notebooks" by ei, an Agate' company. This
had the same symptom of never seeing the disk,
until I applied the first patch above, and all
worked well!
This is in NetBSD/i386 ver 2.02.
Thanks.
____________________________________________________________________
=
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: refling@stanfordalumni.org, smb@research.att.com,
gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
netbsd-bugs@NetBSD.org
Subject: Re: kern/25659
Date: Sat, 11 Jun 2005 12:02:43 +0200
--VrqPEDrXMn8OVzN4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Fri, Jun 10, 2005 at 08:12:02AM +0000, John Refling wrote:
> I have a pcmcia ide controller and drive
> package called "Data Disaster Recovery System
> for Notebooks" by ei, an Agate' company. This
> had the same symptom of never seeing the disk,
> until I applied the first patch above, and all
> worked well!
>
> This is in NetBSD/i386 ver 2.02.
Hi,
can you try the attached patches instead (one for 2.0, one for 3.0/current) ?
This should do the same thing as the patch in the PR, without busy-waiting.
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
--VrqPEDrXMn8OVzN4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff20
Index: wdc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/wdc.c,v
retrieving revision 1.172.2.7
diff -u -r1.172.2.7 wdc.c
--- wdc.c 17 Sep 2004 04:04:57 -0000 1.172.2.7
+++ wdc.c 10 Jun 2005 19:47:55 -0000
@@ -125,6 +125,13 @@
/* timeout for the control commands */
#define WDC_CTRL_DELAY 10000 /* 10s, for the recall command */
+/*
+ * timeout when waiting for BSY to deassert when probing.
+ * set to 5s. From the standards this could be up to 31, but we can't
+ * wait that much at boot time, and 5s seems to be enouth.
+ */
+#define WDC_PROBE_WAIT 5
+
struct pool wdc_xfer_pool;
#if NWD > 0
@@ -489,6 +496,8 @@
u_int8_t ret_value = 0x03;
u_int8_t drive;
int s;
+ int wdc_probe_count =
+ poll ? (WDC_PROBE_WAIT / WDCDELAY) : (WDC_PROBE_WAIT * hz);
/*
* Sanity check to see if the wdc channel responds at all.
@@ -497,24 +506,28 @@
s = splbio();
if (wdc == NULL ||
(wdc->cap & WDC_CAPABILITY_NO_EXTRA_RESETS) == 0) {
+ while (wdc_probe_count-- > 0) {
- if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
- wdc->select(chp,0);
+ if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
+ wdc->select(chp,0);
- bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
- WDSD_IBM);
- delay(10); /* 400ns delay */
- st0 = bus_space_read_1(chp->cmd_iot,
- chp->cmd_iohs[wd_status], 0);
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh],
+ 0, WDSD_IBM);
+ delay(10); /* 400ns delay */
+ st0 = bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_status], 0);
- if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
- wdc->select(chp,1);
+ if (wdc != NULL && (wdc->cap & WDC_CAPABILITY_SELECT))
+ wdc->select(chp,1);
- bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh], 0,
- WDSD_IBM | 0x10);
- delay(10); /* 400ns delay */
- st1 = bus_space_read_1(chp->cmd_iot,
- chp->cmd_iohs[wd_status], 0);
+ bus_space_write_1(chp->cmd_iot, chp->cmd_iohs[wd_sdh],
+ 0, WDSD_IBM | 0x10);
+ delay(10); /* 400ns delay */
+ st1 = bus_space_read_1(chp->cmd_iot,
+ chp->cmd_iohs[wd_status], 0);
+ if ((st0 & WDCS_BSY) == 0)
+ break;
+ }
WDCDEBUG_PRINT(("%s:%d: before reset, st0=0x%x, st1=0x%x\n",
wdc != NULL ? wdc->sc_dev.dv_xname : "wdcprobe",
--VrqPEDrXMn8OVzN4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diffcurrent
Index: wdc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/wdc.c,v
retrieving revision 1.222
diff -u -r1.222 wdc.c
--- wdc.c 29 May 2005 22:10:28 -0000 1.222
+++ wdc.c 10 Jun 2005 19:52:25 -0000
@@ -119,6 +119,14 @@
/* timeout for the control commands */
#define WDC_CTRL_DELAY 10000 /* 10s, for the recall command */
+/*
+ * timeout when waiting for BSY to deassert when probing.
+ * set to 5s. From the standards this could be up to 31, but we can't
+ * wait that much at boot time, and 5s seems to be enouth.
+ */
+#define WDC_PROBE_WAIT 5
+
+
#if NWD > 0
extern const struct ata_bustype wdc_ata_bustype; /* in ata_wdc.c */
#else
@@ -403,6 +395,8 @@
u_int8_t ret_value = 0x03;
u_int8_t drive;
int s;
+ int wdc_probe_count =
+ poll ? (WDC_PROBE_WAIT / WDCDELAY) : (WDC_PROBE_WAIT * hz);
/*
* Sanity check to see if the wdc channel responds at all.
@@ -410,24 +404,27 @@
s = splbio();
if ((wdc->cap & WDC_CAPABILITY_NO_EXTRA_RESETS) == 0) {
+ while (wdc_probe_count-- > 0) {
+ if (wdc->select)
+ wdc->select(chp,0);
- if (wdc->select)
- wdc->select(chp,0);
-
- bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
- WDSD_IBM);
- delay(10); /* 400ns delay */
- st0 = bus_space_read_1(wdr->cmd_iot,
- wdr->cmd_iohs[wd_status], 0);
+ bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
+ 0, WDSD_IBM);
+ delay(10); /* 400ns delay */
+ st0 = bus_space_read_1(wdr->cmd_iot,
+ wdr->cmd_iohs[wd_status], 0);
- if (wdc->select)
- wdc->select(chp,1);
+ if (wdc->select)
+ wdc->select(chp,1);
- bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
- WDSD_IBM | 0x10);
- delay(10); /* 400ns delay */
- st1 = bus_space_read_1(wdr->cmd_iot,
- wdr->cmd_iohs[wd_status], 0);
+ bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
+ 0, WDSD_IBM | 0x10);
+ delay(10); /* 400ns delay */
+ st1 = bus_space_read_1(wdr->cmd_iot,
+ wdr->cmd_iohs[wd_status], 0);
+ if ((st0 & WDCS_BSY) == 0)
+ break;
+ }
ATADEBUG_PRINT(("%s:%d: before reset, st0=0x%x, st1=0x%x\n",
atac->atac_dev.dv_xname,
--VrqPEDrXMn8OVzN4--
Responsible-Changed-From-To: kern-bug-people->bouyer
Responsible-Changed-By: bouyer@netbsd.org
Responsible-Changed-When: Sat, 11 Jun 2005 10:04:10 +0000
Responsible-Changed-Why:
I'll handle it
State-Changed-From-To: open->feedback
State-Changed-By: bouyer@netbsd.org
State-Changed-When: Sat, 11 Jun 2005 10:04:10 +0000
State-Changed-Why:
I proposed a patch based on the one in the PR.
From: "Steven M. Bellovin" <smb@cs.columbia.edu>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: refling@stanfordalumni.org, gnats-bugs@NetBSD.org,
kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
netbsd-bugs@NetBSD.org
Subject: Re: kern/25659
Date: Sat, 11 Jun 2005 09:36:23 -0400
In message <20050611100243.GA2301@antioche.eu.org>, Manuel Bouyer writes:
>
>--VrqPEDrXMn8OVzN4
>Content-Type: text/plain; charset=us-ascii
>Content-Disposition: inline
>
>On Fri, Jun 10, 2005 at 08:12:02AM +0000, John Refling wrote:
>> I have a pcmcia ide controller and drive
>> package called "Data Disaster Recovery System
>> for Notebooks" by ei, an Agate' company. This
>> had the same symptom of never seeing the disk,
>> until I applied the first patch above, and all
>> worked well!
>>
>> This is in NetBSD/i386 ver 2.02.
>
>Hi,
>can you try the attached patches instead (one for 2.0, one for 3.0/current) ?
>This should do the same thing as the patch in the PR, without busy-waiting.
I no longer have access to the equipment where I first encountered the
bug. I do have an old pcmcia hard drive that I can use to verify that
the patch doesn't break things that used to work.
--Steven M. Bellovin, http://www.cs.columbia.edu/~smb
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: "Steven M. Bellovin" <smb@cs.columbia.edu>
Cc: gnats-bugs@NetBSD.org, gnats-admin@NetBSD.org,
netbsd-bugs@NetBSD.org
Subject: Re: kern/25659
Date: Sat, 11 Jun 2005 15:57:35 +0200
On Sat, Jun 11, 2005 at 09:36:23AM -0400, Steven M. Bellovin wrote:
> In message <20050611100243.GA2301@antioche.eu.org>, Manuel Bouyer writes:
> >
> >--VrqPEDrXMn8OVzN4
> >Content-Type: text/plain; charset=us-ascii
> >Content-Disposition: inline
> >
> >On Fri, Jun 10, 2005 at 08:12:02AM +0000, John Refling wrote:
> >> I have a pcmcia ide controller and drive
> >> package called "Data Disaster Recovery System
> >> for Notebooks" by ei, an Agate' company. This
> >> had the same symptom of never seeing the disk,
> >> until I applied the first patch above, and all
> >> worked well!
> >>
> >> This is in NetBSD/i386 ver 2.02.
> >
> >Hi,
> >can you try the attached patches instead (one for 2.0, one for 3.0/current) ?
> >This should do the same thing as the patch in the PR, without busy-waiting.
>
>
> I no longer have access to the equipment where I first encountered the
> bug. I do have an old pcmcia hard drive that I can use to verify that
> the patch doesn't break things that used to work.
If that's easy for you please do. I don't have any IDE PCMCIA stuff.
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
From: John Refling <refling@stanfordalumni.org>
To: Manuel Bouyer <bouyer@antioche.eu.org>,
<refling@stanfordalumni.org>, <smb@research.att.com>,
<gnats-bugs@NetBSD.org>
Cc: <kern-bug-people@NetBSD.org>, <gnats-admin@NetBSD.org>,
<netbsd-bugs@NetBSD.org>
Subject: Re: kern/25659
Date: Fri, 17 Jun 2005 01:00:03 -0700
Alright, I have experimented with some of the patches
in the log for this PR, and have found the following:
The first submission which was to patch ver 1.172 did
not patch cleanly (I'm running 2.0, version 1.172.2.7)
but with a tiny bit of work (the "int bcnt"; was inserted
a few lines off), compiled, and solved the problem attaching
the disk drive to wd1.
The second submission which was to patch 1.172.2.7
also did not apply cleanly, (the "delay(1000000);" and
the following line were swapped), which when changed,
compiled, and also solved the disk problem.
The third submission which was to patch 1.172.2.7, which
gave compiler warnings about uninitialized variables (st0,
st1 on line 495), and after making it compile (st1 =3D 0,
etc.), it did NOT solve the problem.
The forth submission was for 3.0 which I don't have
checked out, so can't test it, yet.
I looked at the 2nd patch, and it seemed to be just
many delays(), so I was curious to see if there was one
delay that made all the difference, and in my case, there
was!
The only statement that mattered was the "delay(1000000);"
I'm testing this with three old disk drives:
IBM DADA-24860 4860 MB (1998) needs delay(200000) or greater
Toshiba MK-2428 500 MB (1994?) needs delay(450000) or greater
Apple DVAA-2810 733 MB (1995) needs delay(380000) or greater
The above shows the range of delays needed from my
tests. I suppose a very old drive might need a larger
delay. I can test that sometime, when I find one.
Is this really an issue with the wdc.c controller, or
is it possibly slow pcmcia hardware/driver between the
wdc controller and the system?
Also, what's going to happen when an old cd-rom is
attached? Aren't they slower than disk drives?
Finally, at least on my system, this is not a spin-up
issue --- the drives are always spinning! It might be
a delay after reset, or something. One of the drives
consistently powers off, then on about 6 times during
the probing. It also powers off then on at any access.
So these drives apparently have strange reactions to
things!
------ Original Message ------
Received: 03:03 AM PDT, 06/11/2005
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: refling@stanfordalumni.org, smb@research.att.com, gnats-bugs@NetBSD.o=
rgCc:
kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.or=
g
Subject: Re: kern/25659
On Fri, Jun 10, 2005 at 08:12:02AM +0000, John Refling wrote:
> I have a pcmcia ide controller and drive
> package called "Data Disaster Recovery System
> for Notebooks" by ei, an Agate' company. This
> had the same symptom of never seeing the disk,
> until I applied the first patch above, and all
> worked well!
> =
> This is in NetBSD/i386 ver 2.02.
Hi,
can you try the attached patches instead (one for 2.0, one for 3.0/curren=
t) ?
This should do the same thing as the patch in the PR, without busy-waitin=
g.
-- =
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
____________________________________________________________________
=
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: John Refling <refling@stanfordalumni.org>
Cc: smb@research.att.com, gnats-bugs@NetBSD.org,
kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
netbsd-bugs@NetBSD.org
Subject: Re: kern/25659
Date: Fri, 17 Jun 2005 23:24:47 +0200
--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Fri, Jun 17, 2005 at 01:00:03AM -0700, John Refling wrote:
>
> Alright, I have experimented with some of the patches
> in the log for this PR, and have found the following:
>
> The first submission which was to patch ver 1.172 did
> not patch cleanly (I'm running 2.0, version 1.172.2.7)
> but with a tiny bit of work (the "int bcnt"; was inserted
> a few lines off), compiled, and solved the problem attaching
> the disk drive to wd1.
>
> The second submission which was to patch 1.172.2.7
> also did not apply cleanly, (the "delay(1000000);" and
> the following line were swapped), which when changed,
> compiled, and also solved the disk problem.
>
> The third submission which was to patch 1.172.2.7, which
> gave compiler warnings about uninitialized variables (st0,
> st1 on line 495), and after making it compile (st1 = 0,
> etc.), it did NOT solve the problem.
>
> The forth submission was for 3.0 which I don't have
> checked out, so can't test it, yet.
>
> I looked at the 2nd patch, and it seemed to be just
> many delays(), so I was curious to see if there was one
> delay that made all the difference, and in my case, there
> was!
>
> The only statement that mattered was the "delay(1000000);"
>
> I'm testing this with three old disk drives:
>
> IBM DADA-24860 4860 MB (1998) needs delay(200000) or greater
> Toshiba MK-2428 500 MB (1994?) needs delay(450000) or greater
> Apple DVAA-2810 733 MB (1995) needs delay(380000) or greater
Ha this is interesting !
>
> The above shows the range of delays needed from my
> tests. I suppose a very old drive might need a larger
> delay. I can test that sometime, when I find one.
>
> Is this really an issue with the wdc.c controller, or
> is it possibly slow pcmcia hardware/driver between the
> wdc controller and the system?
I suspect hardware here. The PCMCIA socket is powered up just before
calling wdcattach(). The power up function waits for the PCMCIA chip to
assert that it is ready, but the pcmcia chip probably doesn't wait
for the drive to be ready.
If so, it should be enouth to add the delay in the wdc_pcmcia.c code.
From your tests, half a second should be enouth. Can you test the attached
patches (one for 2.0, one for current) ?
>
> Also, what's going to happen when an old cd-rom is
> attached? Aren't they slower than disk drives?
I don't think so. It's probably not a spin-up problem, it's the electronic
that is not ready when we start probing. Once the electronic is ready,
the probe code can wait for the device to spin up if needed.
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff20
Index: wdc_pcmcia.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pcmcia/wdc_pcmcia.c,v
retrieving revision 1.67
diff -u -r1.67 wdc_pcmcia.c
--- wdc_pcmcia.c 3 Jan 2004 22:56:53 -0000 1.67
+++ wdc_pcmcia.c 17 Jun 2005 21:18:19 -0000
@@ -41,8 +41,10 @@
#include <sys/param.h>
#include <sys/device.h>
+#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/systm.h>
+#include <sys/proc.h>
#include <machine/bus.h>
#include <machine/intr.h>
@@ -379,6 +381,13 @@
sc->sc_wdcdev.sc_atapi_adapter._generic.adapt_enable =
wdc_pcmcia_enable;
+ /*
+ * Some devices needs some more delay after power up to stabilize
+ * and probe properly, so give them half a second.
+ * See PR 25659 for details.
+ */
+ tsleep(wdc_pcmcia_attach, PWAIT, "wdcattach", hz / 2);
+
sc->sc_flags |= WDC_PCMCIA_ATTACH;
wdcattach(&sc->wdc_channel);
--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diffcurrent
Index: wdc_pcmcia.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pcmcia/wdc_pcmcia.c,v
retrieving revision 1.99
diff -u -r1.99 wdc_pcmcia.c
--- wdc_pcmcia.c 11 Mar 2005 16:17:57 -0000 1.99
+++ wdc_pcmcia.c 17 Jun 2005 21:18:04 -0000
@@ -41,8 +41,10 @@
#include <sys/param.h>
#include <sys/device.h>
+#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/systm.h>
+#include <sys/proc.h>
#include <machine/bus.h>
#include <machine/intr.h>
@@ -300,6 +302,13 @@
wdc_pcmcia_enable;
sc->sc_wdcdev.sc_atac.atac_atapi_adapter._generic.adapt_refcnt = 1;
+ /*
+ * Some devices needs some more delay after power up to stabilize
+ * and probe properly, so give them half a second.
+ * See PR 25659 for details.
+ */
+ tsleep(wdc_pcmcia_attach, PWAIT, "wdcattach", hz / 2);
+
wdcattach(&sc->ata_channel);
ata_delref(&sc->ata_channel);
sc->sc_state = WDC_PCMCIA_ATTACHED;
--6TrnltStXW4iwmi0--
State-Changed-From-To: feedback->closed
State-Changed-By: bouyer@netbsd.org
State-Changed-When: Wed, 05 Jul 2006 17:18:01 +0000
State-Changed-Why:
The proposed patch has been commited.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.