Subject: Re: NVIDIA nForce2/3/4 SMBus controller
To: KIYOHARA Takashi <kiyohara@kk.iij4u.or.jp>
From: Nicolas Joly <njoly@pasteur.fr>
List: current-users
Date: 07/18/2007 14:32:40
On Wed, Jul 18, 2007 at 02:07:21AM +0900, KIYOHARA Takashi wrote:
> Hi! Nicolas,
> 
> I apologize for a slow reply.

No worries.

> > +	for (i = 10000; i > 0; i--) {
> > +		stat = bus_space_read_1(sc->sc_iot, sc->sc_ioh, NFORCE_SMB_PROTOCOL);
> > +		if (stat == 0)
> > +			break;
> >  		delay(500);
> 
> >  	}
> 
> First of all, it doesn't keep spending long time CPU like that us. (max
> 5 seconds)  We should use not delay(9) but tsleep(9).  See man delay(9).

Yes, i blindy copied the FreeBSD values, just to see if it improved
the situation ...

According to the man page, tsleep(9) is now marked as obsolete ?

> Next, I corrected it to tsleep(9).  However, protocol became 0 and
> status became busy in my amd64.  I think that it should check that
> we are not busy.  However, I was not able to test because there was
> no time.

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).

Thanks.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.