Subject: sgiwd93 multiple disk problem

From: Florian Lohoff <[email-masked]>
Date: Tue, 3 Apr 2001 17:47:49 +0200

Hi,
i guess Ryan Murray has stumbled over the multiple disk problem
on one of my machines again - I would like to fix that bug if i am able to.

My first suspicion was garbled DMA transfers which might happen if starting
a new DMA transfer when thge last is still running. So i tried
to add this to 

drivers/scsi/sgiwd93.c:dma_setup

    105 
    106         if (hregs->ctrl & HPC3_SCTRL_ACTIVE)
    107                 BUG();
    108 

This doesnt seem to get triggered. 

Does anyone have another idea what happens ?

Flo
-- 
Florian Lohoff                  [email-masked]             +49-5201-669912
     Why is it called "common sense" when nobody seems to have any?

---

From: Florian Lohoff <[email-masked]>
Date: Tue, 3 Apr 2001 19:04:58 +0200

> on one of my machines again - I would like to fix that bug if i am able to.

While staring at it - Duplicate cache-inv in driver init

--- drivers/scsi/sgiwd93.c	2001/03/26 00:38:20	1.27
+++ drivers/scsi/sgiwd93.c	2001/04/03 17:03:12
@@ -329,7 +333,6 @@
 			hdata1 = (struct WD33C93_hostdata *)sgiwd93_host1->hostdata;
 			hdata1->no_sync = 0;
 			hdata1->dma_bounce_buffer = (uchar *) (KSEG1ADDR(buf));
-			dma_cache_wback_inv((unsigned long) buf, PAGE_SIZE);
 	
 			if (request_irq(SGI_WD93_1_IRQ, sgiwd93_intr, 0, "SGI WD93", (void *) sgiwd93_host1)) {
 				printk(KERN_WARNING "sgiwd93: Could not allocate irq %d (for host1).\n", SGI_WD93_1_IRQ);

Flo

---

From: Florian Lohoff <[email-masked]>
Date: Wed, 4 Apr 2001 13:18:10 +0200

> > on one of my machines again - I would like to fix that bug if i am able to.

Another one - After speaking to a couple of people on IRC i got to
the conclusion that we are possibly dealing with 3 different problems.

I/Ryan have/has seen data corruption. The files md5sum gets broken the fses
Metadata stays intact what an fsck shows.

Spock and Ian see "I/O" errors when copying a sourcetree from
a disk to a different one (even on the same bus) with "cp -dR".
Afterwards the filesystems metadata is corrupt.

Karel sees complete hangs on copy

Flo

---

From: [email-masked] (H.Heinold)
Date: Wed, 4 Apr 2001 14:51:28 +0200

Hi,

I saw cp hanged as I want copy the kernel-tree between two disks
on resume(the indgio2 from flo, which is online).

-- 

Henning

---

From: Florian Lohoff <[email-masked]>
Date: Tue, 10 Apr 2001 00:55:28 +0200

Ok - more info

1. The bug only happens when accessing 2 disks/devices on the SAME controller
2. The bug is in stopping the HPC DMA to early.
3. Stopping the DMA to early happens only on reads.

If applying this patch on the driver 

Index: drivers/scsi/sgiwd93.c
===================================================================
RCS file: /cvs/linux/drivers/scsi/sgiwd93.c,v
retrieving revision 1.27
diff -u -r1.27 sgiwd93.c
--- drivers/scsi/sgiwd93.c	2001/03/26 00:38:20	1.27
+++ drivers/scsi/sgiwd93.c	2001/04/09 22:12:10
@@ -183,6 +187,10 @@
 	printk("dma_stop: status<%d> ", status);
 #endif
 
+	if (hregs->ctrl & HPC3_SCTRL_ACTIVE)
+		printk("DMA still active dir %d bresid %d\n",
+			hdata->dma_dir,
+			SCpnt->SCp.buffers_residual);
 	/* First stop the HPC and flush it's FIFO. */
 	if(hdata->dma_dir) {
 		hregs->ctrl |= HPC3_SCTRL_FLUSH;

I get this output on the console which means files/data
got corrupted.

---------------schnipp---------------------
DMA still active dir 1 bresid 6
DMA still active dir 1 bresid 1
DMA still active dir 1 bresid 3
DMA still active dir 1 bresid 1
DMA still active dir 1 bresid 0
DMA still active dir 1 bresid 0
DMA still active dir 1 bresid 0
DMA still active dir 1 bresid 2
DMA still active dir 1 bresid 0
DMA still active dir 1 bresid 2
---------------schnapp---------------------

This might also be the cause why metadata has never been corrupted.
Metadata are mostly not read in large chunks which get unchecked
dumped to disk again.

One suspicion i had was around the modification of the wd33 registers in
the sgi driver (Its the only driver to do so) which based on the thesis
that on the wd33 driver we act on the current scatter_gather item
and subtract the total length - But this is simply wrong.

Flo