Subject: PCI latency problem on 164SX
To: None <port-alpha@netbsd.org>
From: Andreas Johansson <ajo@wopr.campus.luth.se>
List: port-alpha
Date: 08/25/1998 20:37:50
Hi!

I wrote a mail concerning my pci latency problem (the SRM doesn't set the
pci latency timers in the pci devices to any reasonable values), but I
have receieved no replies. Is there really noone interrested in fixing
this problem or am I the only one that has it?

Anyway, to show one way to solve my problem (which is probably not the
best way to do it), here is a patch for sys/dev/pci/pci.c:

---------------------- snip -------------------------
--- pci.c.orig	Sat Aug 15 13:13:33 1998
+++ pci.c	Tue Aug 25 20:20:25 1998
@@ -161,6 +161,8 @@
 			nfunctions = 1;
 
 		for (function = 0; function < nfunctions; function++) {
+			struct device *d;
+			
 			tag = pci_make_tag(pc, bus, device, function);
 			id = pci_conf_read(pc, tag, PCI_ID_REG);
 			csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
@@ -215,7 +217,23 @@
 			}
 			pa.pa_intrline = PCI_INTERRUPT_LINE(intr);
 
-			config_found_sm(self, &pa, pciprint, pcisubmatch);
+			if ((d = config_found_sm(self, &pa, pciprint,
+						 pcisubmatch))) {
+#ifdef PCI_FORCE_LATENCY
+				u_int32_t v;
+
+				v = pci_conf_read(pa.pa_pc, pa.pa_tag,
+						  PCI_BHLC_REG);
+				printf ("%s: Changing pci latency from %d to %d\n",
+					d->dv_xname, (v & PCI_LATTIMER_MASK) >>
+					PCI_LATTIMER_SHIFT, PCI_FORCE_LATENCY);
+				v &= ~(PCI_LATTIMER_MASK <<
+				       PCI_LATTIMER_SHIFT);
+				v |= PCI_FORCE_LATENCY << PCI_LATTIMER_SHIFT;
+				pci_conf_write(pa.pa_pc, pa.pa_tag,
+					       PCI_BHLC_REG, v);
+#endif
+			}
 		}
 	}
 }
------------------------------ snip ------------------------------

Then the latency can be forced to any desired value in the config.
I use 32.

I think this should be fixed some way, and the proper place for this
fix is probably in the SRM. However, since the SRM doesn't seem to
initialize any pci latency (all pci devices are set to 0 latency) it
is necessary to initialize them in the kernel. The system behaves very
strange if the default latency (0) is used.

/Andreas