Subject: Re: NVIDIA nForce2/3/4 SMBus controller
To: None <njoly@pasteur.fr>
From: KIYOHARA Takashi <kiyohara@kk.iij4u.or.jp>
List: current-users
Date: 07/21/2007 02:02:26
----Next_Part(Sat_Jul_21_02_02_26_2007_819)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi! Nicolas,


From: Nicolas Joly <njoly@pasteur.fr>
Date: Wed, 18 Jul 2007 14:32:40 +0200

> I made some tests with a delay(10) loop on my machine (Tyan S4895
> motherboard). And the protocol register seems cleared in an interval
> of 0 to 600 microseconds.
> 
> Just to be sure, i checked SMBus/ACPI specifications about this.
>      SMB_STS:   Status code for transaction.
>      SMB_PRTCL: 0x00 to indicate command completion.
> The FreeBSD way looks correct to me (SMB_PRTCL, then SMB_STS).

Can you try this patch.

Thanks,
--
kiyohara


----Next_Part(Sat_Jul_21_02_02_26_2007_819)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="nfsmb.diff"

Index: nfsmb.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/nfsmb.c,v
retrieving revision 1.1
diff -u -r1.1 nfsmb.c
--- nfsmb.c	11 Jul 2007 07:53:29 -0000	1.1
+++ nfsmb.c	20 Jul 2007 12:23:53 -0000
@@ -291,21 +291,19 @@
 static int
 nfsmb_check_done(struct nfsmb_softc *sc)
 {
+	int us;
 	uint8_t stat;
 
-	stat = bus_space_read_1(sc->sc_iot, sc->sc_ioh, NFORCE_SMB_STATUS);
-
-	if (~stat & NFORCE_SMB_STATUS_DONE) {
-		delay(500);
-		stat =
-		    bus_space_read_1(sc->sc_iot, sc->sc_ioh, NFORCE_SMB_STATUS);
-	}
-	if (~stat & NFORCE_SMB_STATUS_DONE) {
-		tsleep(sc, PCATCH, "nfsmb", hz / 100);
-		stat =
-		    bus_space_read_1(sc->sc_iot, sc->sc_ioh, NFORCE_SMB_STATUS);
-	}
+	us = 10 * 1000;	/* XXXX: wait maximum 10 msec */
+	do {
+		delay(10);
+		us -= 10;
+		if (us <= 0)
+			return -1;
+	} while (bus_space_read_1(sc->sc_iot, sc->sc_ioh,
+	    NFORCE_SMB_PROTOCOL) != 0);
 
+	stat = bus_space_read_1(sc->sc_iot, sc->sc_ioh, NFORCE_SMB_STATUS);
 	if ((stat & NFORCE_SMB_STATUS_DONE) &&
 	    !(stat & NFORCE_SMB_STATUS_STATUS))
 		return 0;

----Next_Part(Sat_Jul_21_02_02_26_2007_819)----