NetBSD Problem Report #15841

Return-Path: tad@entrisphere.com
Received: (qmail 23983 invoked from network); 9 Mar 2002 00:32:23 -0000
Message-Id: <200203090032.g290WDh06103@mail.entrisphere.com>
Date: Fri, 8 Mar 2002 16:32:13 -0800 (PST)
From: tad@entrisphere.com
Reply-To: tad@entrisphere.com
To: gnats-bugs@gnats.netbsd.org
Subject: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
X-Send-Pr-Version: 3.95

>Number:         15841
>Category:       kern
>Synopsis:       WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 09 00:33:00 +0000 2002
>Closed-Date:    Mon Apr 08 20:07:28 +0000 2002
>Last-Modified:  Mon Apr 08 20:07:28 +0000 2002
>Originator:     Tad Hunt
>Release:        NetBSD-1.5 (upgraded to current WDC and ATA drivers) i386 and others
>Organization:
	Entrisphere, Inc.
	http://www.entrisphere.com
>Environment:

System: NetBSD ntejava.int.entrisphere.com 1.5 NetBSD 1.5 (ENTRISPHERE) #7: Fri Dec 7 13:32:13 PST 2001 tad@ntejava.int.entrisphere.com:/n/ahab/NetBSD-1.5/src/sys/arch/i386/compile/ENTRISPHERE i386

>Description:

I have been using IBM microdrives in both PCMCIA (on our mpc8260
port) and CardBus slots (on our i386 development machines) without
any trouble for months and months.  They work wonderfully.

Now, we've begun switching to compact flash flash ATA disks (instead
of compact flash spinning ATA disks), because we don't want any
moving parts.

I've tried a couple of different PC Card and Compact flash flash
[sic] disks (listed below).

The trouble I'm having is that I'm receiving a disk interrupt that
the wdc driver is not expecting (WDCF_IRQ_WAIT is not set), which
results in the interrupt never being cleared, thus getting stuck
in an infinite interrupt loop.

I have verified this infinite interrupt loop is without any doubt
the problem that is occurring on the mpc8260 board.  And I am
assuming this is why the NetBSD-i386 host hangs as well (though I
haven't instrumented it to check, the behavior is identical).

The hang is very timing related.  It tends to occur much more
frequently during heavy interrupt activity.  It doesn't seem to be
strongly correlated to disk activity alone.

On our mpc8260 device, we have the PCMCIA controller, and two 8
port UARTs interrupting on the same IRQ.  It seems to take UART
activity coupled with disk activity to cause the interrupt problem.
The disk alone seems to run fine.

As soon as I start heavy uart activity, I tend to see several log
messages per second (see the log() call in the fix below).
Acknowledging the interrupt from the ATA drive is enough to make
the interrupt go away, and elicits no complaints from the ATA or
WDC drivers.

The NetBSD-i386 box tends to hang shortly after starting a "dd
if=/dev/r${disk}${rawpart} of=/dev/null bs=512".  However, I don't
know much about how it is configured or what else may be sharing
the disk interrupt.

Obviously, the above hack is quite a hack, but I have spent several
days tracking this problem down and am at a loss for how to proceed.

I tried updating the WDC and ATA drivers to NetBSD-current (as of
last night), but the problem did not go away.

Has anyone seen anything like this before, or have some suggestions on
what I could do to narrow the problem down?

-Tad

------------------------------------------------------------------------------


1) SMART Modular Technologies ATA PC Card (model SM9FLAPC512M1)

   NetBSD identifies this as follows:

	wdc0 at pcmcia0 function 0 port 0x15000000-0x1500000f
	wd0 at wdc0 channel 0 drive 0: <SMART ATA FLASH>
	wd0: drive supports 1-sector PIO transfers, LBA addressing
	wd0: 489 MB, 994 cyl, 16 head, 63 sec, 512 bytes/sect x 1001952 sectors
	wd0: drive supports PIO mode 4

2) AVL Compact Flash Card 128MB (no model number)

   NetBSD identifies this as follows:

	wdc0 at pcmcia0 function 0 port 0x15000000-0x1500000f
	wd0 at wdc0 channel 0 drive 0: <Ritek Corporation>
	wd0: drive supports 1-sector PIO transfers, LBA addressing
	wd0: 122 MB, 978 cyl, 8 head, 32 sec, 512 bytes/sect x 250368 sectors


>How-To-Repeat:

1) start a dd if=/dev/r${disk}${rawpart} of=/dev/null bs=512

2) let this run long enough to stabilize:
	If I don't move onto step 3, this tends to run without
	the log messages appearing.

3) cause non-disk interrupts to occur on the same IRQ.
	On the mpc8260 board, I start a file transfer on one of
	the uart channels.

	This causes unexpected ATA interrupts quite frequently
	(averages about once per second)

>Fix:

The below hack is enough to acknowledge the disk interrupt, so we
can continue happily along.  It doesn't appear to cause any data
lossage, nor does the wdc driver get confused.

This fix is by no means a general solution, because it forces the
device-independent interrupt handling code to be forced to know
about ATA controllers.

------------------------------------------------------------------------------
	intrhandler()
	{
		handled = 0;
		for(ih = handlers_for_this_irq; ih != nil; ih = ih->next) {
			handled += ih->handle(ih->arg);
			if(handled)
				break;
		}
		if(!handled && irq == WDC_DISK_IRQ) {
			ih = find_ata_disk_ih();
			wdcfix(ih->arg);
		}
	}

------------------------------------------------------------------------------

	void
	wdcfix(void *arg)
	{
		struct channel_softc *chp;

		chp = arg;

		if(chp->ch_flags & WDCF_IRQ_WAIT)
			return;

		wdcwait(chp, 0, 0, 0);
		log(LOG_ERR, "%s: read status %02x\n",
			chp->wdc->sc_dev.dv_xname, chp->ch_status);
	}
------------------------------------------------------------------------------

>Release-Note:
>Audit-Trail:

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: tad@entrisphere.com
Cc: gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Sat, 9 Mar 2002 21:36:30 +0100

 On Fri, Mar 08, 2002 at 04:32:13PM -0800, tad@entrisphere.com wrote:
 > I have been using IBM microdrives in both PCMCIA (on our mpc8260
 > port) and CardBus slots (on our i386 development machines) without
 > any trouble for months and months.  They work wonderfully.
 > 
 > Now, we've begun switching to compact flash flash ATA disks (instead
 > of compact flash spinning ATA disks), because we don't want any
 > moving parts.
 > 
 > I've tried a couple of different PC Card and Compact flash flash
 > [sic] disks (listed below).
 > 
 > The trouble I'm having is that I'm receiving a disk interrupt that
 > the wdc driver is not expecting (WDCF_IRQ_WAIT is not set), which
 > results in the interrupt never being cleared, thus getting stuck
 > in an infinite interrupt loop.
 > 
 > I have verified this infinite interrupt loop is without any doubt
 > the problem that is occurring on the mpc8260 board.  And I am
 > assuming this is why the NetBSD-i386 host hangs as well (though I
 > haven't instrumented it to check, the behavior is identical).
 > 
 > The hang is very timing related.  It tends to occur much more
 > frequently during heavy interrupt activity.  It doesn't seem to be
 > strongly correlated to disk activity alone.
 > 
 > On our mpc8260 device, we have the PCMCIA controller, and two 8
 > port UARTs interrupting on the same IRQ.  It seems to take UART
 > activity coupled with disk activity to cause the interrupt problem.
 > The disk alone seems to run fine.
 > 
 > As soon as I start heavy uart activity, I tend to see several log
 > messages per second (see the log() call in the fix below).
 > Acknowledging the interrupt from the ATA drive is enough to make
 > the interrupt go away, and elicits no complaints from the ATA or
 > WDC drivers.
 > 
 > The NetBSD-i386 box tends to hang shortly after starting a "dd
 > if=/dev/r${disk}${rawpart} of=/dev/null bs=512".  However, I don't
 > know much about how it is configured or what else may be sharing
 > the disk interrupt.
 > 
 > Obviously, the above hack is quite a hack, but I have spent several
 > days tracking this problem down and am at a loss for how to proceed.
 > 
 > I tried updating the WDC and ATA drivers to NetBSD-current (as of
 > last night), but the problem did not go away.
 > 
 > Has anyone seen anything like this before, or have some suggestions on
 > what I could do to narrow the problem down?

 Well, the problem is that the ATA interface was never designed for shared
 interrupts: reading the status register will clear the pending interrupt,
 which opens the door to race condition. The ATA device is supposed to
 update the status register before posting the interrupt.
 For pciide devices this is solved by using status registers in the pciide
 device itself (which is vendor-specific, unfortunably). But for pcmcia/cardbus
 devices I can't see how we can solve this, unless there are vendor-specific
 registers where we could check for pending interrupt, designed to work in
 shared interrupt context.

 > ------------------------------------------------------------------------------
 > 	intrhandler()
 > 	{
 > 		handled = 0;
 > 		for(ih = handlers_for_this_irq; ih != nil; ih = ih->next) {
 > 			handled += ih->handle(ih->arg);
 > 			if(handled)
 > 				break;
 > 		}
 > 		if(!handled && irq == WDC_DISK_IRQ) {
 > 			ih = find_ata_disk_ih();
 > 			wdcfix(ih->arg);
 > 		}
 > 	}
 > 
 > ------------------------------------------------------------------------------
 > 
 > 	void
 > 	wdcfix(void *arg)
 > 	{
 > 		struct channel_softc *chp;
 > 
 > 		chp = arg;
 > 
 > 		if(chp->ch_flags & WDCF_IRQ_WAIT)
 > 			return;
 > 
 > 		wdcwait(chp, 0, 0, 0);
 > 		log(LOG_ERR, "%s: read status %02x\n",
 > 			chp->wdc->sc_dev.dv_xname, chp->ch_status);
 > 	}

 This is not rigth. I think this can be implemeted all in wdc_intr()

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
 --

From: David Laight <david@l8s.co.uk>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: tad@entrisphere.com, gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Mon, 11 Mar 2002 22:49:02 +0000

 > Well, the problem is that the ATA interface was never designed for shared
 > interrupts: reading the status register will clear the pending interrupt,
 > which opens the door to race condition. The ATA device is supposed to
 > update the status register before posting the interrupt.
 > For pciide devices this is solved by using status registers in the pciide
 > device itself (which is vendor-specific, unfortunably). But for pcmcia/cardbus
 > devices I can't see how we can solve this, unless there are vendor-specific
 > registers where we could check for pending interrupt, designed to work in
 > shared interrupt context.

 What is wrong with the 'alternate' status register?
 (returns the same as the status register but without
 clearing the IRQ).

 OTOH is is perfectly possible to write an ATA driver
 that will never unintentionally clear an IRQ.

 Also, the interrupt loop would be caused by FAILING to
 remove an IRQ, not by removing one when it shouldn't be.

 Maybe one if the ISRs is reporting that it 'used' the
 interrupt when that wasn't the case.


 	David

 -- 
 David Laight: david@l8s.co.uk

From: Manuel Bouyer <bouyer@antioche.lip6.fr>
To: David Laight <david@l8s.co.uk>
Cc: tad@entrisphere.com, gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Tue, 12 Mar 2002 08:58:34 +0100

 On Mon, Mar 11, 2002 at 10:49:02PM +0000, David Laight wrote:
 > What is wrong with the 'alternate' status register?
 > (returns the same as the status register but without
 > clearing the IRQ).

 Not all controllers provide it :(

 > OTOH is is perfectly possible to write an ATA driver
 > that will never unintentionally clear an IRQ.
 > 
 > Also, the interrupt loop would be caused by FAILING to
 > remove an IRQ, not by removing one when it shouldn't be.

 Yes, but you can also remove one when you shouldn't, and this can lead to a
 lost interrupt.

 --
 Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
 --

From: David Laight <david@l8s.co.uk>
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
Cc: tad@entrisphere.com, gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Tue, 12 Mar 2002 10:04:12 +0000

 On Tue, Mar 12, 2002 at 08:58:34AM +0100, Manuel Bouyer wrote:
 > On Mon, Mar 11, 2002 at 10:49:02PM +0000, David Laight wrote:
 > > What is wrong with the 'alternate' status register?
 > > (returns the same as the status register but without
 > > clearing the IRQ).
 > 
 > Not all controllers provide it :(

 Is this one of the things that separate an ATA disk from a wd one?
 > 
 > > OTOH is is perfectly possible to write an ATA driver
 > > that will never unintentionally clear an IRQ.
 > > 
 > > Also, the interrupt loop would be caused by FAILING to
 > > remove an IRQ, not by removing one when it shouldn't be.
 > 
 > Yes, but you can also remove one when you shouldn't, and this can lead to a
 > lost interrupt.

 But that isn't what the problem was!


 	David

 -- 
 David Laight: david@l8s.co.uk

From: David Laight <david@l8s.co.uk>
To: netbsd-bugs@netbsd.org, gnats-bugs@gnats.netbsd.org
Cc:  
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Tue, 12 Mar 2002 10:34:07 +0000

 On Mon, Mar 11, 2002 at 02:54:16PM -0800, Tad Hunt wrote:
 > 
 > The problem here is that according to the ATA spec, you're supposed to wait
 > a certain length of time before reading the register.  On the order of 400 ns
 > or so...

 This is a tricky one!

 For most command BUSY is set first, then later DRQ set and BUSY cleared.
 So you can tell what has happened.

 However if you issue a command that doesn't involve a data transfer,
 it is somewhat harder to determine whether BUSY hasn't been set yet,
 or has been set and then cleared.

 I don't have the ATA spec handy - and can't remember if there
 is anything that would tell you that a sector erase, for example,
 had completed.

 (For CF, I think performance would be inproved if the filesystem
 code generated erase requests when sectors were no longer required,
 this would give the device free sectors to play with.)

 	David

 -- 
 David Laight: david@l8s.co.uk

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: David Laight <david@l8s.co.uk>
Cc: tad@entrisphere.com, gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Tue, 12 Mar 2002 22:14:26 +0100

 On Tue, Mar 12, 2002 at 10:04:12AM +0000, David Laight wrote:
 > On Tue, Mar 12, 2002 at 08:58:34AM +0100, Manuel Bouyer wrote:
 > > On Mon, Mar 11, 2002 at 10:49:02PM +0000, David Laight wrote:
 > > > What is wrong with the 'alternate' status register?
 > > > (returns the same as the status register but without
 > > > clearing the IRQ).
 > > 
 > > Not all controllers provide it :(
 > 
 > Is this one of the things that separate an ATA disk from a wd one?

 Not only, some ATA controllers don't provide it (I think one of them is on
 atari, or amiga, I don't remember).

 > > 
 > > > OTOH is is perfectly possible to write an ATA driver
 > > > that will never unintentionally clear an IRQ.
 > > > 
 > > > Also, the interrupt loop would be caused by FAILING to
 > > > remove an IRQ, not by removing one when it shouldn't be.
 > > 
 > > Yes, but you can also remove one when you shouldn't, and this can lead to a
 > > lost interrupt.
 > 
 > But that isn't what the problem was!

 Yes, but if you change the code this way to solve the problem, you'll create
 another one.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
 --

From: Manuel Bouyer <bouyer@antioche.lip6.fr>
To: David Laight <david@l8s.co.uk>
Cc: tad@entrisphere.com, gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Tue, 12 Mar 2002 22:26:36 +0100

 On Tue, Mar 12, 2002 at 08:58:34AM +0100, Manuel Bouyer wrote:
 > On Mon, Mar 11, 2002 at 10:49:02PM +0000, David Laight wrote:
 > > What is wrong with the 'alternate' status register?
 > > (returns the same as the status register but without
 > > clearing the IRQ).
 > 
 > Not all controllers provide it :(

 Oh, and after more though (which I probably discovered while writing the
 code): there is still a race condition with the alternate status register,
 which is that when you find the device not busy, you can't say if it's because
 the command completed or if it's because it has not yet been started.
 The only way to clear the race would be to wait a bit (the exact delay is
 specified in the ATA specs) but it's not a solution for an interrupt routine.

 The only way to properly share interrupt is to have a bit saying "yes,
 interrupt occured" for each device.

 --
 Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
 --

From: David Laight <david@l8s.co.uk>
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
Cc: tad@entrisphere.com, gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Tue, 12 Mar 2002 23:41:00 +0000

 On Tue, Mar 12, 2002 at 10:26:36PM +0100, Manuel Bouyer wrote:
 > 
 > Oh, and after more though (which I probably discovered while writing the
 > code): there is still a race condition with the alternate status register,
 > which is that when you find the device not busy, you can't say if it's because
 > the command completed or if it's because it has not yet been started.
 > The only way to clear the race would be to wait a bit (the exact delay is
 > specified in the ATA specs) but it's not a solution for an interrupt routine.
 > 
 > The only way to properly share interrupt is to have a bit saying "yes,
 > interrupt occured" for each device.

 I think it is possible to detect a value it the status register
 that can only have happened if the command has completed.
 (This may require sending an illegal commands to get an error
 status set first).

 I would have to read the ATA spec very closely....

 Note that command that require a data transfer can be identified.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: David Laight <david@l8s.co.uk>
Cc: tad@entrisphere.com, gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Wed, 13 Mar 2002 22:36:31 +0100

 On Tue, Mar 12, 2002 at 11:41:00PM +0000, David Laight wrote:
 > I think it is possible to detect a value it the status register
 > that can only have happened if the command has completed.
 > (This may require sending an illegal commands to get an error
 > status set first).

 Well, we're talking about a test needed for all interrupts here

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
 --

From: David Laight <david@l8s.co.uk>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: tad@entrisphere.com, gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Wed, 13 Mar 2002 23:42:26 +0000

 On Wed, Mar 13, 2002 at 10:36:31PM +0100, Manuel Bouyer wrote:
 > On Tue, Mar 12, 2002 at 11:41:00PM +0000, David Laight wrote:
 > > I think it is possible to detect a value it the status register
 > > that can only have happened if the command has completed.
 > > (This may require sending an illegal commands to get an error
 > > status set first).
 > 
 > Well, we're talking about a test needed for all interrupts here

 Not really, you just need to write the device driver such that
 its ISR can be entered at any time, and it decides what to do
 given the contents of the STATUS register and the last command
 issued.

 I've just been reading T13/1153D revsion 18 (again)....

 I would ensure that the ISR:
 1) always reads STATUS to ensure the hardware IRQ is removed
 2) if BUSY set, return
 3) if DRQ set request data xfer (unless dma active) and return
 4) if no command active, return
 5) if ERR set, report error and/or retry
 6) if < 400ns since command issued, wait on short timer
 7) report command complete

 IRQ is 'taken' if you return at 3, 5 or 7.

 For most systems the system interrupt entry sequence is
 probably longer than 400ns!  (you only need to wait 400ns
 to ensure the contents of STATUS is valid, reading it
 earlier isn't a problem).

 The 400ns is probably only relevant when issuing write or
 packet commands - where there is no interrupt before the
 first data transfer, and you are polling for DRQ.

 Might be a problem doing commands with no data in a poll
 mode driver.  But these aren't usually performance critical.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: David Laight <david@l8s.co.uk>
Cc: tad@entrisphere.com, gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/15841: WDC/ATA PCMCIA and CardBus flash disk unhandled interrupt locks kernel
Date: Thu, 14 Mar 2002 21:16:50 +0100

 On Wed, Mar 13, 2002 at 11:42:26PM +0000, David Laight wrote:
 > On Wed, Mar 13, 2002 at 10:36:31PM +0100, Manuel Bouyer wrote:
 > > On Tue, Mar 12, 2002 at 11:41:00PM +0000, David Laight wrote:
 > > > I think it is possible to detect a value it the status register
 > > > that can only have happened if the command has completed.
 > > > (This may require sending an illegal commands to get an error
 > > > status set first).
 > > 
 > > Well, we're talking about a test needed for all interrupts here
 > 
 > Not really, you just need to write the device driver such that
 > its ISR can be entered at any time, and it decides what to do
 > given the contents of the STATUS register and the last command
 > issued.

 I meant "all interrupt on the same line". Remember this started with a problem
 about shared interrupts.

 > 
 > I've just been reading T13/1153D revsion 18 (again)....
 > 
 > I would ensure that the ISR:
 > 1) always reads STATUS to ensure the hardware IRQ is removed
 > 2) if BUSY set, return
 > 3) if DRQ set request data xfer (unless dma active) and return
 > 4) if no command active, return
 > 5) if ERR set, report error and/or retry
 > 6) if < 400ns since command issued, wait on short timer

 And how do you know how many time ago the interrupt has been issued, especially
 with such a higth resolution, without performances penalty ?

 Also I've seen weird things with some controllers when reading status before
 it's time. From data corruption to machine wedge.

 When I got my first PCI-native PCIIDE controlers I tried to find a generic
 way of sharing interrupts. After a lot of experiments, I conclued that
 interrupt sharing support was not possible without support at the controller
 level (i.e. a controller register that can tell us if interrupt occured).
 Maybe this is controller dependant.

 > 7) report command complete
 > 
 > IRQ is 'taken' if you return at 3, 5 or 7.
 > 
 > For most systems the system interrupt entry sequence is
 > probably longer than 400ns!  (you only need to wait 400ns
 > to ensure the contents of STATUS is valid, reading it
 > earlier isn't a problem).

 Not if you already have a pending interrupt on this line. You'll enter
 the interrupt routine at the first splx(). Again think shared interrupts.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
 --

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Tad Hunt <tad@entrisphere.com>
Cc: tech-kern@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: kern/15841 More info about WDC/ATA PCMCIA and CardBus problems using flash (i.e., not with microdrive)
Date: Thu, 28 Mar 2002 23:52:27 +0100

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

 On Wed, Mar 27, 2002 at 02:19:20PM -0800, Tad Hunt wrote:
 > 
 > I just had one of our hardware engineers change the PCMCIA interface
 > on our MPC8260 board so I can demultiplex the pcmcia interrupts
 > from the other interrupts on the same irq line (aren't PALs great!).
 > Anyway, the problem described in PR kern/15841 still exists when
 > using the flash ATA PC Card.
 > 
 > As before the jammed interrupt problem never occurs with the IBM
 > Microdrive (side note: believe it or not, the microdrive is faster
 > for both reading and writing than the flash disk!).
 > 
 > In summary, the problem is that the flash disk is asserting the
 > interrupt request, but the WDCF_IRQ_WAIT bit is not set in the
 > "channel_softc", so the interrupt is never serviced.
 > 
 > I see the same problem on the "stock" NetBSD-1.5 i386 port (a Dell
 > with a cardbus card in a PCI slot) as I do on our MPC8260 port,
 > which leads me to believe that it is a general problem.
 > 
 > I see the same behavior with both of the following flash disk parts
 > (the only ones I have been able to test with so far):
 > 
 > 1) SMART Modular Technologies ATA PC Card (model SM9FLAPC512M1)
 > 
 >    NetBSD identifies this as follows:
 > 
 > 	wdc0 at pcmcia0 function 0 port 0x15000000-0x1500000f
 > 	wd0 at wdc0 channel 0 drive 0: <SMART ATA FLASH>
 > 	wd0: drive supports 1-sector PIO transfers, LBA addressing
 > 	wd0: 489 MB, 994 cyl, 16 head, 63 sec, 512 bytes/sect x 1001952 sectors
 > 	wd0: drive supports PIO mode 4
 > 
 > 2) AVL Compact Flash Card 128MB (unknown model number)
 > 
 >    NetBSD identifies this as follows:
 > 
 > 	wdc0 at pcmcia0 function 0 port 0x15000000-0x1500000f
 > 	wd0 at wdc0 channel 0 drive 0: <Ritek Corporation>
 > 	wd0: drive supports 1-sector PIO transfers, LBA addressing
 > 	wd0: 122 MB, 978 cyl, 8 head, 32 sec, 512 bytes/sect x 250368 sectors

 Hi,
 I just commited the attached patch to current. Does it solve your problem ?

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
 --

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

 Index: wdc.c
 ===================================================================
 RCS file: /cvsroot/syssrc/sys/dev/ic/wdc.c,v
 retrieving revision 1.112
 diff -u -r1.112 wdc.c
 --- wdc.c	2002/03/08 20:48:38	1.112
 +++ wdc.c	2002/03/28 22:46:40
 @@ -714,6 +714,8 @@
  	}
  	if ((chp->ch_flags & WDCF_IRQ_WAIT) == 0) {
  		WDCDEBUG_PRINT(("wdcintr: inactive controller\n"), DEBUG_INTR);
 +		/* try to clear the pending interrupt anyway */
 +		(void)bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_status);
  		return (0);
  	}


 --ZPt4rx8FFjLCG7dd--
State-Changed-From-To: open->closed 
State-Changed-By: bouyer 
State-Changed-When: Mon Apr 8 13:06:41 PDT 2002 
State-Changed-Why:  
The patch commited to current solves the problem. 
Thanks ! 
>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.