Subject: Re: wdc0:0:0 lost interrupt
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Andrew Cagney <cagney@mac.com>
List: port-macppc
Date: 07/27/2001 15:49:04
This is a multi-part message in MIME format.
--------------070003040904030009040506
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

> 
> No, in your dmesg, piomode==-1 for wdc2, which has no drives attached.
> This shouldn't matter much for wdc0 or wdc1
> Still reading an array with negative offset isn't good. I'll correct this.


At least it eliminated an obvious bug, still back to the merge ...

With the difference at exhibit.d, I'm getting the following dmesg output:

wdc0 at obio0 offset 0x1f000 irq 19: DMA transfer
wd0 at wdc0 channel 0 drive 0: <IBM-DJSA-220>
wd0: drive supports 16-sector PIO transfers, LBA addressing
wd0: 19077 MB, 16383 cyl, 16 head, 63 sec, 512 bytes/sect x 39070080 sectors
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 4 (Ultra/66)
piomode 4, dmamode 2
drvp->PIO_mode = piomode; [0->4 = 4]
if (drvp->drive_flags & DRIVE_DMA) [0->51 & 10]
drvp->DMA_mode = dmamode; [0->2 = 2]
chp->cmd_iot=8001f004, chp->cmd_ioh=ecdf1000, CONFIG_REG=20, conf=11823
chp->cmd_iot=8001f004, chp->cmd_ioh=ecdf1000, CONFIG_REG=20, conf=11800
wd0(wdc0:0:0): using PIO mode 4, DMA mode 2 (using DMA data transfers)
wdc1 at obio0 offset 0x20000 irq 20: DMA transfer
atapibus0 at wdc1 channel 0: 2 targets
cd0 at atapibus0 drive 0: <MATSHITADVD-ROM SR-8187, , HA18> type 5 cdrom removable
cd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 2 (Ultra/33)
piomode 4, dmamode 2
drvp->PIO_mode = piomode; [0->4 = 4]
if (drvp->drive_flags & DRIVE_DMA) [0->52 & 10]
drvp->DMA_mode = dmamode; [0->2 = 2]
chp->cmd_iot=80020004, chp->cmd_ioh=ecdf3000, CONFIG_REG=20, conf=11823
chp->cmd_iot=80020004, chp->cmd_ioh=ecdf3000, CONFIG_REG=20, conf=11800
cd0(wdc1:0:0): using PIO mode 4, DMA mode 2 (using DMA data transfers)
wdc2 at obio0 offset 0x21000 irq 21: DMA transfer
piomode -1, dmamode -1


ignoring most of it, the interesting bit is:

chp->cmd_iot=8001f004, chp->cmd_ioh=ecdf1000, CONFIG_REG=20, conf=11823
chp->cmd_iot=8001f004, chp->cmd_ioh=ecdf1000, CONFIG_REG=20, conf=11800

The first line is what the broken 1.15 would have set the config 
register to.  The second line is what my local working version actually 
sets it to (all values in %x).

	Andrew

--------------070003040904030009040506
Content-Type: text/plain;
 name="exhibit.d"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="exhibit.d"

--- wdc_obio.c	Fri Jul 27 00:56:34 2001
+++ wdc_obio.c,1.15	Thu Jul 26 15:12:17 2001
@@ -263,18 +263,11 @@
 				dmamode = drvp->DMA_mode;
 		}
 	}
-printf ("piomode %d, dmamode %d\n", piomode, dmamode);
-       if (dmamode == -1)
-               /* No active DMA mode is found...  Do nothing. */
-               return;
 	if (piomode == -1)
 		return; /* No drive */
 	for (drive = 0; drive < 2; drive++) {
 		drvp = &chp->ch_drive[drive];
 		if (drvp->drive_flags & DRIVE) {
-printf ("drvp->PIO_mode = piomode; [%d->%x = %x]\n", drive, drvp->PIO_mode, piomode);
-printf ("if (drvp->drive_flags & DRIVE_DMA) [%d->%x & %x]\n", drive, drvp->drive_flags, DRIVE_DMA);
-printf ("drvp->DMA_mode = dmamode; [%d->%d = %d]\n", drive, drvp->DMA_mode, dmamode);
 			drvp->PIO_mode = piomode;
 			if (drvp->drive_flags & DRIVE_DMA)
 				drvp->DMA_mode = dmamode;
@@ -304,21 +297,6 @@
 		conf |=
 		    (half_tick << 21) | (inact_tick << 16) | (act_tick << 11);
 	}
-printf ("chp->cmd_iot=%x, chp->cmd_ioh=%x, CONFIG_REG=%x, conf=%x\n",
-	chp->cmd_iot, chp->cmd_ioh, CONFIG_REG, conf);
- 	min_cycle = dma_timing[dmamode].cycle;
-	min_active = dma_timing[dmamode].active;
-
-	cycle_tick = TIME_TO_TICK(min_cycle);
-	act_tick = TIME_TO_TICK(min_active);
-	inact_tick = cycle_tick - act_tick - 1;
-	if (inact_tick < 1)
-		inact_tick = 1;
-
-	half_tick = 0;	/* XXX */
-	conf = (half_tick << 21) | (inact_tick << 16) | (act_tick << 11);
-printf ("chp->cmd_iot=%x, chp->cmd_ioh=%x, CONFIG_REG=%x, conf=%x\n",
-	chp->cmd_iot, chp->cmd_ioh, CONFIG_REG, conf);
 	bus_space_write_4(chp->cmd_iot, chp->cmd_ioh, CONFIG_REG, conf);
 #if 0
 	printf("conf = 0x%x, cyc = %d (%d ns), act = %d (%d ns), inact = %d\n",

--------------070003040904030009040506--