Subject: Re: ex0: device timeout
To: None <pooka@iki.fi>
From: Masanori Kanaoka <kanaoka@ann.hi-ho.ne.jp>
List: tech-net
Date: 08/06/2001 18:37:45
Hi,

       From: Antti Kantee <pooka@iki.fi>
    Subject: Re: ex0: device timeout
      Date : Fri, 03 Aug 2001 15:27:42 +0300

$ > How about reverting sys/dev/ic/elinkxl.c from 1.34.2.4 to 1.34.2.3 ?
$ > How about reverting delay value from 100000 to 400 
$ > in ex_reset()@sys/dev/ic/elinkxl.c ?

$ No, that did help. On the contrary, it caused problems. 

I read sys/dev/pci/if_ex_pci.c and sys/dev/cardbus/if_ex_cardbus.c
I found intr_ack code difference between cardbus and pci.

CardBus
	- map by Cardbus_mapreg_map
	- access by bus_space_write_4
PCI
	- does not map
	- access by pci_conf_write

I make a next patch that map by pci_mapreg_map, 
and access by bus_space_write_4. 

How about next patch?
Sorry! I don't test this patch, because I don't have 3c556,3c556B.

Regards!
---
 Masanori Kanaoka	kanaoka@ann.hi-ho.ne.jp

Index: if_ex_pci.c
===================================================================
RCS file: /ftp/cvs/syssrc/sys/dev/pci/if_ex_pci.c,v
retrieving revision 1.12.4.2
diff -u -r1.12.4.2 if_ex_pci.c
--- if_ex_pci.c	2001/03/20 17:25:33	1.12.4.2
+++ if_ex_pci.c	2001/08/06 09:00:54
@@ -94,6 +94,11 @@
 	struct ex_softc sc_ex;
 	pci_chipset_tag_t sc_chiptag;
 	pcitag_t sc_pcitag;
+
+	/* PCI function status space. 556,556B requests it. */
+	bus_space_tag_t sc_funct;
+	bus_space_handle_t sc_funch;
+
 };
 
 /*
@@ -105,6 +110,7 @@
 #define PCI_POWERCTL		0xe0
 #define PCI_FUNCMEM		0x18
 
+#define PCI_INTR		4
 #define PCI_INTRACK		0x00008000
 
 int ex_pci_match __P((struct device *, struct cfdata *, void *));
@@ -258,6 +264,17 @@
 	    pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG) |
 	    PCI_COMMAND_MASTER_ENABLE);
 
+	if (sc->ex_conf & EX_CONF_PCI_FUNCREG) {
+		/* Map PCI function status window. */
+		if (pci_mapreg_map(pa, PCI_FUNCMEM, PCI_MAPREG_TYPE_MEM, 0,
+		    &psc->sc_funct, &psc->sc_funch, NULL, NULL)) {
+			printf("%s: unable to map function status window\n",
+			    sc->sc_dev.dv_xname);
+			return;
+		}
+		sc->intr_ack = ex_pci_intr_ack;
+	}
+		
 	/* Get it out of power save mode if needed (BIOS bugs) */
 	if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
 		reg = pci_conf_read(pc, pa->pa_tag, pmreg + 4) & 0x3;
@@ -284,12 +301,6 @@
 		return;
 	}
 
-	if (sc->ex_conf & EX_CONF_PCI_FUNCREG) {
-		sc->intr_ack = ex_pci_intr_ack;
-		psc->sc_chiptag = pa->pa_pc;
-		psc->sc_pcitag = pa->pa_tag;
-	}
-
 	intrstr = pci_intr_string(pc, ih);
 	sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, ex_intr, sc);
 	if (sc->sc_ih == NULL) {
@@ -303,6 +314,10 @@
 	printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
 
 	ex_config(sc);
+
+	if (sc->ex_conf & EX_CONF_PCI_FUNCREG)
+		bus_space_write_4(psc->sc_funct, psc->sc_funch, PCI_INTR, 
+		    PCI_INTRACK);
 }
 
 void            
@@ -311,6 +326,6 @@
 {
 	struct ex_pci_softc *psc = (struct ex_pci_softc *)sc;
         
-	pci_conf_write(psc->sc_chiptag, psc->sc_pcitag, PCI_FUNCMEM + 4,
+	bus_space_write_4(psc->sc_funct, psc->sc_funch, PCI_INTR,
 	    PCI_INTRACK);
 }