Subject: pdcide(4) and pci latency
To: None <port-alpha@netbsd.org>
From: Tobias Nygren <tnn@netilium.org>
List: port-alpha
Date: 01/13/2005 01:15:29
Hi all,

I have a PC164SX running NetBSD 2.0. The machine has two pdcide(4) Ultra/133
controllers and one ti(4) Gigabit ethernet adapter. All busmaster capable.
When I use the promise card simultaneously with another card (copying files,
nfs, etc) I get many DMA soft errors, and transfer rates drop below 1MB/s.

pcictl dump showed that the latency timer for the card is set to 0.
After applying the patch below i can copy data at 30MB/s using NFS.
I'm using wd flags 0x0a00 (Ultra/33) so that's about as good as it will get.
Any idea why the latency timer is set to zero? Should I PR this?
Apparently the same goes for ti0, but that card seems to handle it better.

Another interesting thing is that the errors showed up even with latency 32,
a value that seems to be the default for many systems. Had to bump
it above 128 for things to settle down.

-Tobias

Index: pdcide.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pdcide.c,v
retrieving revision 1.11
diff -u -r1.11 pdcide.c
--- pdcide.c	3 Jan 2004 22:56:53 -0000	1.11
+++ pdcide.c	12 Jan 2005 23:56:16 -0000
@@ -133,6 +133,18 @@
 	struct pci_attach_args *pa = aux;
 	struct pciide_softc *sc = (struct pciide_softc *)self;
 
+#ifdef alpha
+	uint32_t reg;
+
+	printf ("\n%s: Overriding default PCI latency", self->dv_xname);
+
+	reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG);
+	reg &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT);
+	reg |= 248 << PCI_LATTIMER_SHIFT;
+
+	pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG, reg);
+#endif
+
 	pciide_common_attach(sc, pa,
 	    pciide_lookup_product(pa->pa_id, pciide_promise_products));