NetBSD Problem Report #27421

From martin@duskware.de  Sun Oct 24 14:10:13 2004
Return-Path: <martin@duskware.de>
Received: from mail.duskware.de (mail.duskware.de [213.146.108.170])
	by narn.netbsd.org (Postfix) with ESMTP id 3E221251EC1
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 24 Oct 2004 14:10:13 +0000 (UTC)
Message-Id: <200410241410.i9OEABAP000534@night-owl.duskware.de>
Date: Sun, 24 Oct 2004 16:10:11 +0200 (CEST)
From: Martin Husemann <martin@duskware.de>
Reply-To: martin@duskware.de
To: gnats-bugs@gnats.NetBSD.org
Subject: Ultra 5 panics on boot with DIAGNOSTIC kernel
X-Send-Pr-Version: 3.95

>Number:         27421
>Category:       kern
>Synopsis:       Ultra 5 panics on boot with DIAGNOSTIC kernel
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bouyer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 24 14:11:00 +0000 2004
>Closed-Date:    Sat Oct 30 23:11:18 +0000 2004
>Last-Modified:  Sat Oct 30 23:11:18 +0000 2004
>Originator:     Martin Husemann
>Release:        NetBSD 2.99.10
>Organization:
>Environment:
System: NetBSD 2.99.10 (SETTINGSUN) #0: Sun Oct 24 15:40:26 CEST 2004      martin@night-porter.duskware.de:/usr/src/sys/arch/sparc64/compile/SETTINGSUN
Architecture: sparc64
Machine: sparc64
>Description:

raidattach: Asked for 8 units                
Kernelized RAIDframe activated
panic: wdc_exec_command: polled command not done
kdb breakpoint at 11b2b20                       
Stopped in pid 3.1 (atabus0) at netbsd:cpu_Debugger+0x4:        nop
db> bt                                                             
wdc_exec_command(3, d007870, fffffffffffffffa, 1, d007b60, 1000000) at netbsd:wdc_exec_command+0x1f8
ata_get_params(283c250, 18, d007b60, 6, fffffffffffffffd, 1877e98) at netbsd:ata_get_params+0xb4
wdc_drvprobe(283c208, 0, 359, 11d7a90, 1f, 1819400) at netbsd:wdc_drvprobe+0x2b0
atabusconfig(26f9100, 0, 1808198, 1874828, 1, 1877e98) at netbsd:atabusconfig+0x14
atabus_thread(26f9100, 0, 359, 11d7a90, 0, 10c86a0) at netbsd:atabus_thread+0x48
proc_trampoline(0, 0, 0, 0, 0, 0) at netbsd:proc_trampoline+0x4

(gdb) list *(wdc_exec_command+0x1f8)
0x1069720 is in wdc_exec_command (../../../../dev/ic/wdc.c:1285).
1280            s = splbio();
1281            ata_exec_xfer(chp, xfer);
1282    #ifdef DIAGNOSTIC
1283            if ((ata_c->flags & AT_POLL) != 0 &&
1284                (ata_c->flags & AT_DONE) == 0)
1285                    panic("wdc_exec_command: polled command not done");
1286    #endif
1287            if (ata_c->flags & AT_DONE) {
1288                    ret = ATACMD_COMPLETE;
1289            } else {

>How-To-Repeat:

Boot a DIAGNOSTIC kernel on a U5 with two disks.
Relevant dmesg part of the working kernel:

cmdide0 at pci1 dev 3 function 0
cmdide0: CMD Technology PCI0646 (rev. 0x03)
cmdide0: bus-master DMA support present    
cmdide0: primary channel configured to native-PCI mode
cmdide0: using ivec 1820 for native-PCI interrupt     
atabus0 at cmdide0 channel 0                     
cmdide0: secondary channel configured to native-PCI mode
atabus1 at cmdide0 channel 1                            
...
Kernelized RAIDframe activated                            
wd0 at atabus0 drive 0: <Maxtor 32049H2>
wd0: drive supports 16-sector PIO transfers, LBA addressing
wd0: 19541 MB, 39704 cyl, 16 head, 63 sec, 512 bytes/sect x 40021632 sectors
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100)    
wd0(cmdide0:0:0): using PIO mode 4, DMA mode 2 (using DMA data transfers)
wd1 at atabus1 drive 0: <WDC WD205AA>                                    
wd1: drive supports 16-sector PIO transfers, LBA addressing
wd1: 19569 MB, 39761 cyl, 16 head, 63 sec, 512 bytes/sect x 40079088 sectors
wd1: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 4 (Ultra/66)     
wd1(cmdide0:1:0): using PIO mode 4, DMA mode 2 (using DMA data transfers)
raid0: RAID Level 1                                                      
raid0: Components: /dev/wd0d /dev/wd1d
raid0: Total Sectors: 38657664 (18875 MB)


This probably is related to the shared ata channel used for this controller,
and the two disks attached (but I'm not sure).

>Fix:
n/a
>Release-Note:
>Audit-Trail:

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/27421: Ultra 5 panics on boot with DIAGNOSTIC kernel
Date: Mon, 25 Oct 2004 23:15:41 +0200

 --x+6KMIRAuhnl3hBn
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 On Sun, Oct 24, 2004 at 04:10:11PM +0200, Martin Husemann wrote:
 > 
 > [...]
 > 
 > This probably is related to the shared ata channel used for this controller,
 > and the two disks attached (but I'm not sure).

 It is. More specifically, it's because we're issuing POLL | WAIT commands
 in the disk probe. I can't see reasons to not use interrupts at this point.
 The attached patch should fix it.

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

 --x+6KMIRAuhnl3hBn
 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.213
 diff -u -r1.213 wdc.c
 --- wdc.c	21 Aug 2004 01:51:46 -0000	1.213
 +++ wdc.c	25 Oct 2004 21:11:56 -0000
 @@ -293,8 +293,7 @@
  			return;

  		/* issue an identify, to try to detect ghosts */
 -		error = ata_get_params(&chp->ch_drive[i],
 -		    AT_WAIT | AT_POLL, &params);
 +		error = ata_get_params(&chp->ch_drive[i], AT_WAIT, &params);
  		if (error != CMD_OK) {
  			tsleep(&params, PRIBIO, "atacnf", mstohz(1000));

 @@ -303,7 +302,7 @@
  				return;

  			error = ata_get_params(&chp->ch_drive[i],
 -			    AT_WAIT | AT_POLL, &params);
 +			    AT_WAIT, &params);
  		}
  		if (error == CMD_OK) {
  			/* If IDENTIFY succeeded, this is not an OLD ctrl */

 --x+6KMIRAuhnl3hBn--
State-Changed-From-To: open->feedback 
State-Changed-By: bouyer 
State-Changed-When: Mon Oct 25 21:16:12 UTC 2004 
State-Changed-Why:  
I just sent a patch 


Responsible-Changed-From-To: kern-bug-people->bouyer 
Responsible-Changed-By: bouyer 
Responsible-Changed-When: Mon Oct 25 21:16:12 UTC 2004 
Responsible-Changed-Why:  
I just sent a patch 

From: Martin Husemann <martin@duskware.de>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/27421: Ultra 5 panics on boot with DIAGNOSTIC kernel
Date: Tue, 26 Oct 2004 07:50:48 +0200

 On Mon, Oct 25, 2004 at 11:15:41PM +0200, Manuel Bouyer wrote:
 > The attached patch should fix it.

 It does, thanks!

 Martin
State-Changed-From-To: feedback->closed 
State-Changed-By: bouyer 
State-Changed-When: Tue Oct 26 21:22:28 UTC 2004 
State-Changed-Why:  
The patch has been commited. 
Thanks ! 
State-Changed-From-To: closed->feedback 
State-Changed-By: bouyer 
State-Changed-When: Sat Oct 30 20:26:27 UTC 2004 
State-Changed-Why:  
Sorry, I had to revert the previous patch, but I have a new one to test. 

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/27421: Ultra 5 panics on boot with DIAGNOSTIC kernel
Date: Sat, 30 Oct 2004 22:28:36 +0200

 --+QahgC5+KEYLbs62
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 Hi,
 unfortunably I had to revert this patch. Can you try the attached one instead
 (with wdc.c 1.216).
 Sorry for this ...

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

 --+QahgC5+KEYLbs62
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=diff

 Index: ata/ata.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ata/ata.c,v
 retrieving revision 1.61
 diff -u -r1.61 ata.c
 --- ata/ata.c	28 Oct 2004 20:11:41 -0000	1.61
 +++ ata/ata.c	30 Oct 2004 19:23:05 -0000
 @@ -702,6 +702,20 @@
  	TAILQ_INSERT_TAIL(&chp->ch_queue->queue_xfer, xfer, c_xferchain);
  	ATADEBUG_PRINT(("atastart from ata_exec_xfer, flags 0x%x\n",
  	    chp->ch_flags), DEBUG_XFERS);
 +	/*
 +	 * if polling and can sleep, wait for the xfer to be at head of queue
 +	 */
 +	if ((xfer->c_flags & (C_POLL | C_WAIT)) ==  (C_POLL | C_WAIT)) {
 +		while (TAILQ_FIRST(&chp->ch_queue->queue_xfer) != xfer) {
 +			xfer->c_flags |= C_WAITACT;
 +			tsleep(xfer, PRIBIO, "ataact", 0);
 +			xfer->c_flags &= ~C_WAITACT;
 +			if (xfer->c_flags & C_FREE) {
 +				ata_free_xfer(chp, xfer);
 +				return;
 +			}
 +		}
 +	}
  	atastart(chp);
  }

 @@ -744,6 +758,17 @@
  	if (__predict_false(chp->ch_queue->queue_freeze > 0)) {
  		return; /* queue froozen */
  	}
 +	/*
 +	 * if someone is waiting for the command to be active, wake it up
 +	 * and let it process the command
 +	 */
 +	if (xfer->c_flags & C_WAITACT) {
 +		ATADEBUG_PRINT(("atastart: xfer %p channel %d drive %d "
 +		    "wait active\n", xfer, chp->ch_channel, xfer->c_drive),
 +		    DEBUG_XFERS);
 +		wakeup(xfer);
 +		return;
 +	}
  #ifdef DIAGNOSTIC
  	if ((chp->ch_flags & ATACH_IRQ_WAIT) != 0)
  		panic("atastart: channel waiting for irq");
 @@ -763,6 +788,7 @@

  	if (atac->atac_cap & ATAC_CAP_NOIRQ)
  		KASSERT(xfer->c_flags & C_POLL);
 +
  	xfer->c_start(chp, xfer);
  }

 @@ -788,6 +814,13 @@
  	struct atac_softc *atac = chp->ch_atac;
  	int s;

 +	if (xfer->c_flags & C_WAITACT) {
 +		/* Someone is waiting for this xfer, so we can't free now */
 +		xfer->c_flags |= C_FREE;
 +		wakeup(xfer);
 +		return;
 +	}
 +
  	if (atac->atac_free_hw)
  		(*atac->atac_free_hw)(chp);
  	s = splbio();
 Index: ata/atavar.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ata/atavar.h,v
 retrieving revision 1.64
 diff -u -r1.64 atavar.h
 --- ata/atavar.h	20 Aug 2004 23:26:54 -0000	1.64
 +++ ata/atavar.h	30 Oct 2004 19:23:05 -0000
 @@ -70,11 +70,14 @@
  	void	(*c_kill_xfer)(struct ata_channel *, struct ata_xfer *, int);
  };

 -/* vlags in c_flags */
 +/* flags in c_flags */
  #define	C_ATAPI		0x0001		/* xfer is ATAPI request */
  #define	C_TIMEOU	0x0002		/* xfer processing timed out */
  #define	C_POLL		0x0004		/* command is polled */
  #define	C_DMA		0x0008		/* command uses DMA */
 +#define C_WAIT		0x0010		/* can use tsleep */
 +#define C_WAITACT	0x0020		/* wakeup when active */
 +#define C_FREE		0x0040		/* call ata_free_xfer() asap */

  /* reasons for c_kill_xfer() */
  #define KILL_GONE 1 /* device is gone */
 Index: ic/wdc.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/wdc.c,v
 retrieving revision 1.216
 diff -u -r1.216 wdc.c
 --- ic/wdc.c	30 Oct 2004 17:17:21 -0000	1.216
 +++ ic/wdc.c	30 Oct 2004 19:23:05 -0000
 @@ -1274,6 +1279,8 @@
  		ata_c->flags |= AT_POLL;
  	if (ata_c->flags & AT_POLL)
  		xfer->c_flags |= C_POLL;
 +	if (ata_c->flags & AT_WAIT)
 +		xfer->c_flags |= C_WAIT;
  	xfer->c_drive = drvp->drive;
  	xfer->c_databuf = ata_c->data;
  	xfer->c_bcount = ata_c->bcount;
 @@ -1657,7 +1664,7 @@
  __wdcerror(struct ata_channel *chp, char *msg) 
  {
  	struct atac_softc *atac = chp->ch_atac;
 -	struct ata_xfer *xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer);
 +	struct ata_xfer *xfer = chp->ch_queue->active_xfer;

  	if (xfer == NULL)
  		printf("%s:%d: %s\n", atac->atac_dev.dv_xname, chp->ch_channel,

 --+QahgC5+KEYLbs62--

From: Martin Husemann <martin@duskware.de>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/27421: Ultra 5 panics on boot with DIAGNOSTIC kernel
Date: Sat, 30 Oct 2004 23:22:45 +0200

 On Sat, Oct 30, 2004 at 10:28:36PM +0200, Manuel Bouyer wrote:
 > Can you try the attached one instead
 > (with wdc.c 1.216).

 Sorry, does not work.

 Martin

 Kernelized RAIDframe activated
 panic: wdc_exec_command: polled command not done
 kdb breakpoint at 11b2d20                       
 Stopped in pid 3.1 (atabus0) at netbsd:cpu_Debugger+0x4:        nop
 db> bt                                                             
 wdc_exec_command(3, d007870, fffffffffffffffa, 1, d007b60, 1000000) at netbsd:wd
 c_exec_command+0x220                                                           
 ata_get_params(283c250, 18, d007b60, 6, fffffffffffffffd, 1877dd0) at netbsd:ata
 _get_params+0xb4                                                               
 wdc_drvprobe(283c208, 0, 359, 11d7d68, 1f, 1819400) at netbsd:wdc_drvprobe+0x2b0

 atabusconfig(26f9100, 0, 1808198, 1874760, 1, 1877dd0) at netbsd:atabusconfig+0x
 14                                                                             
 atabus_thread(26f9100, 0, 359, 11d7d68, 0, 10c8724) at netbsd:atabus_thread+0x48

 proc_trampoline(0, 0, 0, 0, 0, 0) at netbsd:proc_trampoline+0x4

 (gdb) list *(wdc_exec_command+0x220)
 0x1069768 is in wdc_exec_command (../../../../dev/ic/wdc.c:1292).
 1287            s = splbio();
 1288            ata_exec_xfer(chp, xfer);
 1289    #ifdef DIAGNOSTIC
 1290            if ((ata_c->flags & AT_POLL) != 0 &&
 1291                (ata_c->flags & AT_DONE) == 0)
 1292                    panic("wdc_exec_command: polled command not done");
 1293    #endif
 1294            if (ata_c->flags & AT_DONE) {
 1295                    ret = ATACMD_COMPLETE;
 1296            } else {


From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/27421: Ultra 5 panics on boot with DIAGNOSTIC kernel
Date: Sun, 31 Oct 2004 00:33:36 +0200

 On Sat, Oct 30, 2004 at 11:22:45PM +0200, Martin Husemann wrote:
 > On Sat, Oct 30, 2004 at 10:28:36PM +0200, Manuel Bouyer wrote:
 > > Can you try the attached one instead
 > > (with wdc.c 1.216).
 > 
 > Sorry, does not work.
 > 
 > Martin
 > 
 > Kernelized RAIDframe activated
 > panic: wdc_exec_command: polled command not done

 Ok, I think I found why. Please try with this additionnal patch

 --- ata.c.orig	2004-10-31 00:29:42.000000000 +0200
 +++ ata.c	2004-10-31 00:29:47.000000000 +0200
 @@ -707,7 +707,8 @@
  	 */
  	if ((xfer->c_flags & (C_POLL | C_WAIT)) ==  (C_POLL | C_WAIT)) {
  		printf("xfer poll|wait\n");
 -		while (TAILQ_FIRST(&chp->ch_queue->queue_xfer) != xfer) {
 +		while (chp->ch_queue->active_xfer != NULL || 
 +		    TAILQ_FIRST(&chp->ch_queue->queue_xfer) != xfer) {
  			xfer->c_flags |= C_WAITACT;
  			printf("xfer poll|wait tsleep()\n");
  			tsleep(xfer, PRIBIO, "ataact", 0);

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

From: Martin Husemann <martin@duskware.de>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/27421: Ultra 5 panics on boot with DIAGNOSTIC kernel
Date: Sun, 31 Oct 2004 00:56:53 +0200

 On Sun, Oct 31, 2004 at 12:33:36AM +0200, Manuel Bouyer wrote:
 > Ok, I think I found why. Please try with this additionnal patch

 This works.

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: kern/27421: Ultra 5 panics on boot with DIAGNOSTIC kernel
Date: Sun, 31 Oct 2004 00:58:42 +0200

 On Sun, Oct 31, 2004 at 12:56:53AM +0200, Martin Husemann wrote:
 > On Sun, Oct 31, 2004 at 12:33:36AM +0200, Manuel Bouyer wrote:
 > > Ok, I think I found why. Please try with this additionnal patch
 > 
 > This works.

 OK, thanks a lot. I'll commit it in the next few minutes.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --
State-Changed-From-To: feedback->closed 
State-Changed-By: bouyer 
State-Changed-When: Sat Oct 30 23:10:54 UTC 2004 
State-Changed-Why:  
New patch works and has been commited. 
>Unformatted:
 >Quarter:        
 >Keywords:       
 >Date-Required:  

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.