NetBSD Problem Report #23208

Received: (qmail 7771 invoked by uid 605); 20 Oct 2003 16:57:20 -0000
Message-Id: <200310201657.h9KGvFWr000555@induction.immanent.net>
Date: Mon, 20 Oct 2003 11:57:16 -0500 (CDT)
From: Frederick Bruckman <fredb@immanent.net>
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: fredb@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: atabus changes in 1.6ZD break IDE on Quadra 630
X-Send-Pr-Version: 3.95

>Number:         23208
>Category:       port-mac68k
>Synopsis:       atabus changes in 1.6ZD break IDE on Quadra 630
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bouyer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 20 16:58:00 +0000 2003
>Closed-Date:    Wed Oct 29 21:45:16 +0000 2003
>Last-Modified:  Wed Oct 29 21:45:16 +0000 2003
>Originator:     Frederick Bruckman
>Release:        NetBSD 1.6ZD
>Organization:
>Environment:


System: NetBSD induction.immanent.net 1.6U NetBSD 1.6U (INDUCTION) #0: Mon Jun 16 09:34:19 CDT 2003 fredb@tautology.immanent.net:/t/netbsd-current/obj.mac68k/s/netbsd/src-current/sys/arch/mac68k/compile/INDUCTION mac68k
Architecture: m68k
Machine: mac68k

The problem kernel was built from sources yesterday, October 19,
and reports as NetBSD 1.6ZD.

>Description:

	Quadra 630/IDE drive used to work as of 1.6U. Now, the controller
	and drive are still detected, but it panics after "root on ffs" w/

	Stopped in pid 3.1 (atabus0)
	panic: queue_freese

	No, it's not a typo -- it really says "freese", with an "s".
	"bt" in the debugger only shows that panic() is called from
	atabus_thread(). "sync" seems to actually take a core dump
	before going into a UVM fault, but later, savecore says:

	Oct 20 11:42:51 induction savecore: can't find device 2365/480

	This is probably not related to the problem at hand.

>How-To-Repeat:

	Try to boot a recent kernel on a Mac with IDE root.
>Fix:

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: port-mac68k-maintainer->bouyer 
Responsible-Changed-By: bouyer 
Responsible-Changed-When: Wed Oct 22 20:58:25 UTC 2003 
Responsible-Changed-Why:  
Looks liek it's my fault :) 

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: fredb@NetBSD.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: port-mac68k/23208: atabus changes in 1.6ZD break IDE on Quadra 630
Date: Wed, 22 Oct 2003 23:01:08 +0200

 On Mon, Oct 20, 2003 at 11:57:16AM -0500, Frederick Bruckman wrote:
 > >Description:
 > 	
 > 	Quadra 630/IDE drive used to work as of 1.6U. Now, the controller
 > 	and drive are still detected, but it panics after "root on ffs" w/
 > 
 > 	Stopped in pid 3.1 (atabus0)
 > 	panic: queue_freese
 > 
 > 	No, it's not a typo -- it really says "freese", with an "s".

 Ops, I'll fix this with some other commits

 > 	"bt" in the debugger only shows that panic() is called from
 > 	atabus_thread(). "sync" seems to actually take a core dump

 Can you add printfs to see
 - what is the value of queue_freese when it panics
 - and then track the queue_freese++/queue_freese-- (it's in sys/dev/ic/wdc.c,
   sys/dev/ata/ata_wdc.c and sys/dev/scsipi/atapi_wdc.c)

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 24 ans d'experience feront toujours la difference
 --

From: Frederick Bruckman <fredb@immanent.net>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: port-mac68k/23208: atabus changes in 1.6ZD break IDE on Quadra
 630
Date: Wed, 22 Oct 2003 18:21:38 -0500 (CDT)

 On Wed, 22 Oct 2003, Manuel Bouyer wrote:

 > On Mon, Oct 20, 2003 at 11:57:16AM -0500, Frederick Bruckman wrote:
 > > >Description:
 > >
 > > 	Quadra 630/IDE drive used to work as of 1.6U. Now, the controller
 > > 	and drive are still detected, but it panics after "root on ffs" w/
 > >
 > > 	Stopped in pid 3.1 (atabus0)
 > > 	panic: queue_freese
 > >
 > > 	No, it's not a typo -- it really says "freese", with an "s".
 >
 > Ops, I'll fix this with some other commits

 :-)

 > > 	"bt" in the debugger only shows that panic() is called from
 > > 	atabus_thread(). "sync" seems to actually take a core dump
 >
 > Can you add printfs to see
 > - what is the value of queue_freese when it panics
 > - and then track the queue_freese++/queue_freese-- (it's in sys/dev/ic/wdc.c,
 >   sys/dev/ata/ata_wdc.c and sys/dev/scsipi/atapi_wdc.c)

 OK. I added one for the decrement, too..., but it never decrements.
 This is typed by hand:


 [...]
 esp0 at obio0 (quick): address 0x87a000: NCR53C96, 16MHz, SCSI ID 7
 scsibus0 at esp0: 8 targets, 8 luns per target
 wdc0 at obio0 (Quadra/Performa series IDE interface)
 atabus0 at wdc0 channel 0
 [...]
 scsibus0: waiting 2 seconds for devices to settle...
 wd0 at atabus0 drive 0cd0 at scsibus0 target 5 lun 0: <MATSHITA, CD-ROM CD-8004A, 2.0a> cdrom removable
 : <ST340016A>
 wd0: 38166 MB, 77545 cyl, 16 head, 63 sec, 512 bytes/sect x 78165360 sectors
 cd0: sync (500.00ns offset 8), 8-bit (2,000MB/s) transfers
 wd0: drive supports PIO mode 4, DMA mode 3, Ultar-DMA mode 5 (Ultra/100)
 boot device: wd0
 root on wd0a dumps on wd0b
 wdcwait: queue_freese is 1mountroot: trying msdos...
 wdcwait: queue_freese is 2mountroot: trying cd9660...
 wdcwait: queue_freese is 3mountroot: trying nfs...
 mountroot: trying ffs...
 wdcwait: queue_freese is 4time read from PRAM: 0xbbbc74cb
 Date and time: October 22, 2003  17:54:19
 PRAM: 0x3f96c44b, macos_boottime: 0x3f96c43c
 root file system tyope: ffs
 panic: atabus_thread: queue_freese is 4
 Stopped in pid 3.1 (atabus0) at netbsd:cpu_Debugger+0x6:	unlk	a6
 db>


 ST340016A is the model of the IDE drive. On 1.6U, the messages don't
 run together, but then wd0 is attached much earlier, right after wdc0.


 Frederick

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Frederick Bruckman <fredb@immanent.net>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: port-mac68k/23208: atabus changes in 1.6ZD break IDE on Quadra 630
Date: Thu, 23 Oct 2003 21:39:14 +0200

 --AqsLC8rIMeq19msA
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 On Wed, Oct 22, 2003 at 06:21:38PM -0500, Frederick Bruckman wrote:
 > OK. I added one for the decrement, too..., but it never decrements.
 > This is typed by hand:
 > 
 > 
 > [...]
 > esp0 at obio0 (quick): address 0x87a000: NCR53C96, 16MHz, SCSI ID 7
 > scsibus0 at esp0: 8 targets, 8 luns per target
 > wdc0 at obio0 (Quadra/Performa series IDE interface)
 > atabus0 at wdc0 channel 0
 > [...]
 > scsibus0: waiting 2 seconds for devices to settle...
 > wd0 at atabus0 drive 0cd0 at scsibus0 target 5 lun 0: <MATSHITA, CD-ROM CD-8004A, 2.0a> cdrom removable
 > : <ST340016A>
 > wd0: 38166 MB, 77545 cyl, 16 head, 63 sec, 512 bytes/sect x 78165360 sectors
 > cd0: sync (500.00ns offset 8), 8-bit (2,000MB/s) transfers
 > wd0: drive supports PIO mode 4, DMA mode 3, Ultar-DMA mode 5 (Ultra/100)
 > boot device: wd0
 > root on wd0a dumps on wd0b
 > wdcwait: queue_freese is 1mountroot: trying msdos...
 > wdcwait: queue_freese is 2mountroot: trying cd9660...
 > wdcwait: queue_freese is 3mountroot: trying nfs...

 OK, I suspect something is calling wdcwait() with the wrong parameters.
 Can you try the attached patch and report the backtrace after the panic ?

 > 
 > ST340016A is the model of the IDE drive. On 1.6U, the messages don't
 > run together, but then wd0 is attached much earlier, right after wdc0.

 Yes, with the last changes the probe/attach is done in a kernel thread context,
 with interrupts enabled.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 24 ans d'experience feront toujours la difference
 --

 --AqsLC8rIMeq19msA
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=diff2

 Index: wdc.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/wdc.c,v
 retrieving revision 1.144
 diff -u -r1.144 wdc.c
 --- wdc.c	2003/10/22 23:59:00	1.144
 +++ wdc.c	2003/10/23 19:36:08
 @@ -1311,6 +1311,8 @@
  				 * we're probably in interrupt context,
  				 * ask the thread to come back here
  				 */
 +				if (chp->ch_queue->queue_freese > 0)
 +					panic("wdcwait: queue_freese");
  				chp->ch_queue->queue_freese++;
  				wakeup(&chp->thread);
  				return(WDCWAIT_THR);

 --AqsLC8rIMeq19msA--

From: Frederick Bruckman <fredb@immanent.net>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: port-mac68k/23208: atabus changes in 1.6ZD break IDE on Quadra
 630
Date: Thu, 23 Oct 2003 18:27:22 -0500 (CDT)

 On Thu, 23 Oct 2003, Manuel Bouyer wrote:

 > OK, I suspect something is calling wdcwait() with the wrong parameters.
 > Can you try the attached patch and report the backtrace after the panic ?

 root on wd0a: dumps on wd0b
 mountroot: trying msdos...
 panic: wdcwait: queue_freese
 Stopped in pid 0.1 (swapper) at netbsd:cpu_Debugger+0x6:	unlk	a6
 db> bt
 cpu_Debugger()
 panic()
 wdcwait()
 __wdccommand_intr()
 __wdccommand_start()
 wdcstart()
 wdc_exec_xfer()
 wdc_exec_command()
 ata_get_params()
 wd_get_params()
 wdopen()
 spec_open()
 VOP_OPEN()
 msdosfs_mountfs()
 msdosfs_mountroot()
 vfs_mountroot()
 main()
 ?() at fee

 (Numbers omitted.) I have a kernel with debugging symbols on the build
 host, and tried to take a core dump, but it wouldn't do it:

 db> sync
 syncing disks... done
 NetBSD/mac68k does not trust itself to update the RTC on shutdown.

 dumping to dev 22,1 offset 147469
 dump panic: wddump: polled command has been queued
 Stopped in pid 0.1 (swapper) at netbsd:cpu_Debugger()


 Frederick

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Frederick Bruckman <fredb@immanent.net>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: port-mac68k/23208: atabus changes in 1.6ZD break IDE on Quadra 630
Date: Fri, 24 Oct 2003 22:19:04 +0200

 --CE+1k2dSO48ffgeK
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 Hi,

 On Thu, Oct 23, 2003 at 06:27:22PM -0500, Frederick Bruckman wrote:
 > On Thu, 23 Oct 2003, Manuel Bouyer wrote:
 > 
 > > OK, I suspect something is calling wdcwait() with the wrong parameters.
 > > Can you try the attached patch and report the backtrace after the panic ?
 > 
 > root on wd0a: dumps on wd0b
 > mountroot: trying msdos...
 > panic: wdcwait: queue_freese
 > Stopped in pid 0.1 (swapper) at netbsd:cpu_Debugger+0x6:	unlk	a6
 > db> bt
 > cpu_Debugger()
 > panic()
 > wdcwait()
 > __wdccommand_intr()
 > __wdccommand_start()
 > wdcstart()
 > wdc_exec_xfer()
 > wdc_exec_command()
 > ata_get_params()
 > wd_get_params()
 > wdopen()
 > spec_open()
 > VOP_OPEN()
 > msdosfs_mountfs()
 > msdosfs_mountroot()
 > vfs_mountroot()
 > main()
 > ?() at fee

 OK, thanks. 
 I suspect your controller is WDC_CAPABILITY_NOIRQ.
 Can you try the attached patch ? This should solve this case.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 24 ans d'experience feront toujours la difference
 --

 --CE+1k2dSO48ffgeK
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=diff

 Index: wdc.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/wdc.c,v
 retrieving revision 1.144
 diff -u -r1.144 wdc.c
 --- wdc.c	2003/10/22 23:59:00	1.144
 +++ wdc.c	2003/10/24 20:14:58
 @@ -1294,9 +1294,11 @@
  	else {
  		error = __wdcwait(chp, mask, bits, WDCDELAY_POLL);
  		if (error != 0) {
 -			if (chp->ch_flags & WDCF_TH_RUN) {
 +			if ((chp->ch_flags & WDCF_TH_RUN) ||
 +			    (flags & AT_WAIT)) {
  				/*
 -				 * we're running in the channel thread context
 +				 * we're running in the channel thread
 +				 * or some userland thread context
  				 */
  				for (i = 0; i < timeout_hz; i++) {
  					if (__wdcwait(chp, mask, bits,
 @@ -1311,6 +1313,10 @@
  				 * we're probably in interrupt context,
  				 * ask the thread to come back here
  				 */
 +#ifdef DIAGNOSTIC
 +				if (chp->ch_queue->queue_freese > 0)
 +					panic("wdcwait: queue_freese");
 +#endif
  				chp->ch_queue->queue_freese++;
  				wakeup(&chp->thread);
  				return(WDCWAIT_THR);

 --CE+1k2dSO48ffgeK--

From: Frederick Bruckman <fredb@immanent.net>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: port-mac68k/23208: atabus changes in 1.6ZD break IDE on Quadra
 630
Date: Fri, 24 Oct 2003 20:25:10 -0500 (CDT)

 On Fri, 24 Oct 2003, Manuel Bouyer wrote:

 > On Thu, Oct 23, 2003 at 06:27:22PM -0500, Frederick Bruckman wrote:
 > > On Thu, 23 Oct 2003, Manuel Bouyer wrote:
 > >
 > > > OK, I suspect something is calling wdcwait() with the wrong parameters.
 > > > Can you try the attached patch and report the backtrace after the panic ?
 > >
 > > root on wd0a: dumps on wd0b
 > > mountroot: trying msdos...
 > > panic: wdcwait: queue_freese
 > > Stopped in pid 0.1 (swapper) at netbsd:cpu_Debugger+0x6:	unlk	a6
 > > db> bt
 > > cpu_Debugger()
 > > panic()
 > > wdcwait()
 > > __wdccommand_intr()
 > > __wdccommand_start()
 > > wdcstart()
 > > wdc_exec_xfer()
 > > wdc_exec_command()
 > > ata_get_params()
 > > wd_get_params()
 > > wdopen()
 > > spec_open()
 > > VOP_OPEN()
 > > msdosfs_mountfs()
 > > msdosfs_mountroot()
 > > vfs_mountroot()
 > > main()
 > > ?() at fee
 >
 > OK, thanks.
 > I suspect your controller is WDC_CAPABILITY_NOIRQ.

 Yes, I think I remember something about that.

 > Can you try the attached patch ? This should solve this case.

 Sadly no, it's exactly the same as before (with DIAGNOSTIC -- haven't
 tried without).


 Frederick

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Frederick Bruckman <fredb@immanent.net>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: port-mac68k/23208: atabus changes in 1.6ZD break IDE on Quadra 630
Date: Mon, 27 Oct 2003 22:19:50 +0100

 --tThc/1wpZn/ma/RB
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 On Fri, Oct 24, 2003 at 08:25:10PM -0500, Frederick Bruckman wrote:
 > > Can you try the attached patch ? This should solve this case.
 > 
 > Sadly no, it's exactly the same as before (with DIAGNOSTIC -- haven't
 > tried without).

 Sorry, I forgot to change one line.
 In __wdccommand_intr(), line 1798, please change
 	wflags = 0;
 to
 	wflags = AT_WAIT | AT_POLL;

 Or use the attached patch :)

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 24 ans d'experience feront toujours la difference
 --

 --tThc/1wpZn/ma/RB
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=diff

 Index: wdc.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/wdc.c,v
 retrieving revision 1.144
 diff -u -r1.144 wdc.c
 --- wdc.c	2003/10/22 23:59:00	1.144
 +++ wdc.c	2003/10/27 21:19:05
 @@ -268,11 +268,15 @@
  	chp->ch_flags |= WDCF_TH_RUN;
  	splx(s);
  	atabusconfig(atabus_sc);
 -	while (!(chp->ch_flags & WDCF_SHUTDOWN)) {
 +	for(;;) {
  		s = splbio();
 -		chp->ch_flags &= ~WDCF_TH_RUN;
 -		tsleep(&chp->thread, PRIBIO, "atath", 0);
 -		chp->ch_flags |= WDCF_TH_RUN;
 +		if ((chp->ch_flags & (WDCF_TH_RESET | WDCF_SHUTDOWN)) == 0 &&
 +		    ((chp->ch_flags & WDCF_ACTIVE) == 0 ||
 +		     chp->ch_queue->queue_freese == 0)) {
 +			chp->ch_flags &= ~WDCF_TH_RUN;
 +			tsleep(&chp->thread, PRIBIO, "atath", 0);
 +			chp->ch_flags |= WDCF_TH_RUN;
 +		}
  		splx(s);
  		if (chp->ch_flags & WDCF_SHUTDOWN)
  			break;
 @@ -284,6 +288,7 @@
  				chp->ch_drive[drive].state = 0;
  			}
  			chp->ch_flags &= ~WDCF_TH_RESET;
 +			chp->ch_queue->queue_freese--;
  			wdcstart(chp);
  		} else if ((chp->ch_flags & WDCF_ACTIVE) != 0 &&
  		    chp->ch_queue->queue_freese == 1) {
 @@ -983,8 +988,8 @@
  	if ((chp->ch_flags & WDCF_ACTIVE) != 0 ) {
  		return; /* channel aleady active */
  	}
 -	if ((chp->ch_flags & WDCF_TH_RESET) != 0) {
 -		return; /* a channel reset is pending */
 +	if (__predict_false(chp->ch_queue->queue_freese > 0)) {
 +		return; /* queue froozen */
  	}
  #ifdef DIAGNOSTIC
  	if ((chp->ch_flags & WDCF_IRQ_WAIT) != 0)
 @@ -1076,13 +1081,13 @@
  	WDCDEBUG_PRINT(("ata_reset_channel %s:%d for drive %d\n",
  	    chp->wdc->sc_dev.dv_xname, chp->channel, drvp->drive),
  	    DEBUG_FUNCS);
 -	if ((chp->ch_flags & WDCF_TH_RUN) == 0 &&
 -	    (flags & AT_POLL) == 0) {
 +	if ((flags & AT_POLL) == 0) {
  		chp->ch_flags |= WDCF_TH_RESET;
 +		chp->ch_queue->queue_freese++;
  		wakeup(&chp->thread);
  		return;
  	}
 -	(void) wdcreset(chp, (flags & AT_POLL) ? RESET_POLL : RESET_SLEEP);
 +	(void) wdcreset(chp, RESET_POLL);
  	for (drive = 0; drive < 2; drive++) {
  		chp->ch_drive[drive].state = 0;
  	}
 @@ -1294,9 +1299,11 @@
  	else {
  		error = __wdcwait(chp, mask, bits, WDCDELAY_POLL);
  		if (error != 0) {
 -			if (chp->ch_flags & WDCF_TH_RUN) {
 +			if ((chp->ch_flags & WDCF_TH_RUN) ||
 +			    (flags & AT_WAIT)) {
  				/*
 -				 * we're running in the channel thread context
 +				 * we're running in the channel thread
 +				 * or some userland thread context
  				 */
  				for (i = 0; i < timeout_hz; i++) {
  					if (__wdcwait(chp, mask, bits,
 @@ -1311,6 +1318,10 @@
  				 * we're probably in interrupt context,
  				 * ask the thread to come back here
  				 */
 +#ifdef DIAGNOSTIC
 +				if (chp->ch_queue->queue_freese > 0)
 +					panic("wdcwait: queue_freese");
 +#endif
  				chp->ch_queue->queue_freese++;
  				wakeup(&chp->thread);
  				return(WDCWAIT_THR);
 @@ -1784,7 +1795,7 @@

  	if ((wdc_c->flags & (AT_WAIT | AT_POLL)) == (AT_WAIT | AT_POLL)) {
  		/* both wait and poll, we can tsleep here */
 -		wflags = 0;
 +		wflags = AT_WAIT | AT_POLL;
  	} else {
  		wflags = AT_POLL;
  	}

 --tThc/1wpZn/ma/RB--

From: Frederick Bruckman <fredb@immanent.net>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: port-mac68k/23208: atabus changes in 1.6ZD break IDE on Quadra
 630
Date: Mon, 27 Oct 2003 17:20:28 -0600 (CST)

 On Mon, 27 Oct 2003, Manuel Bouyer wrote:

 > On Fri, Oct 24, 2003 at 08:25:10PM -0500, Frederick Bruckman wrote:
 > > > Can you try the attached patch ? This should solve this case.
 > >
 > > Sadly no, it's exactly the same as before (with DIAGNOSTIC -- haven't
 > > tried without).
 >
 > Sorry, I forgot to change one line.
 > In __wdccommand_intr(), line 1798, please change
 > 	wflags = 0;
 > to
 > 	wflags = AT_WAIT | AT_POLL;
 >
 > Or use the attached patch :)

 Yes, the patch works fine.

 Thanks!

 Frederick
State-Changed-From-To: open->closed 
State-Changed-By: bouyer 
State-Changed-When: Wed Oct 29 21:43:43 UTC 2003 
State-Changed-Why:  
Fixed in wdc.c 1.147. 
Thanks for the report ! 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.