[PATCH, take 2] libertas: fixes for slow hardware

Holger Schurig hs4233 at mail.mn-solutions.de
Wed Oct 10 03:24:11 EDT 2007


> > @@ -148,11 +148,11 @@ static int
> > if_cs_poll_while_fw_download( {
> >  	int i;
> >
> > -	for (i = 0; i < 500; i++) {
> > +	for (i = 0; i < 1000; i++) {
> >  		u8 val = if_cs_read8(card, addr);
> >  		if (val == reg)
> >  			return i;
> > -		udelay(100);
> > +		udelay(500);
> >  	}
> >  	return -ETIME;
> >  }
>
> 10x the maximum delay?  Is this really necessary?
>
> How did you determine this was needed?

For my hardware, it was not necessary. My CF card worked with the 
old settings.

The documentation, in 2.2.1.2 "CF Interface" says at point 3. a)

   "The host polls this for 50 ms before declaring a failure on
   the particular block of firmware being downloaded".

Some lines below, in the section about the real firmware (the 
former citation was from the section about the helper firmware), 
it just says in "8.", after polling card status register:

   "The is no definite time period that the host polls this bit
   before declaring a failure on this particular block of
   firmware".

and in "9.", after card configuration and scratch port register:

   "The host polls this 50ms before declaring a failure ..."

So, two times it's 50ms, once it's unspecified.





For me 50ms worked in all cases (my hardware actually reacts in 
way less than 50 millisends). 

However, Vitaly sent this patch, he had hardware where the 
firmware download was failing with the original approach and 
where it was necessary to make those values larger. I'm actually 
don't know in which of the three cases it failed for him. But 
this code piece isn't so time critical:

* the routine will only called during firmware download, not for 
normal operation. Especially not when sending commands, 
receiving responses or sending/receiving packets

* for my hardware, I never reach the upper ceilings, the routine 
routines always way faster.

This are my findings how often it spun loops in 
if_cs_poll_while_fw_download():

* While programming the helper firmware: 10 * 1 loop
* While programming the real firmware, 1 * 0 loop, 363 * 1 loop
* While waiting for the expected value in the scratch pad 
register: 88 loops

With the original code:

* While programming the helper firmware: 8 * 3 loops, 2 * 1 loop
* While programming the real firmware: 1 * 0 loop, 363 * 1 loop
* While waiting for the expected value in the scratch pad 
register: 434 loops



> If it really is necessary, you need to change the "The host
> polls the Card Status register for 50 ms..." comment in
> if_cs_prog_helper as well.

As this is an excerpt from the docs, I don't want to change this 
arbitrary.

My problem is that I don't have the hardware that failed with the 
original code. If I would have this hardware, I would have 
changed if_cs_poll_while_fw_download() so that I could specify 
the amount of time it should wait. Or so that I can change the 
number of loops it should wait.



More information about the libertas-dev mailing list