Subject: Re: "transmit timed out" on FCC in MPC8260 => bug corrected

From: "hubert.loewenguth" <[email-masked]>
Date: Fri, 24 Mar 2006 12:44:18 +0100

Hi to the community.

I'm the man who has posted numerous questions about this problem of 
fcc_enet timeout in ppc8260.
I just want to say that the 2.6 kernel doesn't solve the problem if you 
have it on your board (I tried it,  normally I have a 2.4-20 linux too).
I have search for this bug during a long time, and fortunatly, I 'm 
happy to say you that finally, it is corrected since few days.
Special thanks to "Hunter, David" for having take in consideration my 
problem, and proposing me some way of invastigations in this thread:

http://ozlabs.org/pipermail/linuxppc-embedded/2006-January/021842.html

In fact the solution comes from the new "MPC8260 PowerQUICC II Family 
Reference Manual"   fresescale has delivered 01/19/2006.
http://www.freescale.com/files/product/doc/MPC8260UM.pdf

They have added a very interesting paragraph about error handling in 
ethernet mode:

/29.10.1.3 Adjusting Transmitter BD Handling
When a TXE event occurs, the TBPTR may already point beyond BDs still 
marked as ready due to internal
pipelining. If the TBPTR is not adjusted, these BDs would be skipped 
while still being marked as ready.
Software must determine if these BDs should be retransmitted or if they 
should be skipped, depending on
the protocol and application needs. This requires the following steps:
1. From the current TBPTR value, search backwards over all (if any) BDs 
still marked as ready to
find the first BD that has not been closed by the CPM. The search 
process should stop if the BD to
be checked next is not ready or if it is the most recent BD marked as 
ready by the CPU transmit
software. This is to avoid an endless loop in case the CPU software 
fills the BD ring completely.
2. A) For skipping BDs, manually close all BDs from the BD just found up 
to and including the BD
just before TBPTR. Leave the TBPTR value untouched.
B) For retransmitting BDs, change the TBPTR value to point to the BD 
just found.
/
So, here is the correction  I have done to the fcc-enet.c driver, and 
wich I'am very satsify
I have tested it on my platform which was always entering in this 
infernal timeout loop when there was successive plug/unplug during 
important data transfert.
Thanks to some trace, I have seen that, as it is said in the new manual, 
the error comes from the pipelining and a bad restart procedure in the 
driver.
(I think it is the same restart procedure in the 2.6 kernel ??? to 
verify ...)
With this correction, I have no more infernal timeout  loop.
In fact, I replace the restart procedure in the fcc_enet_interrupt 
method by this one, which respect the MPC8260 manual restart procedure:

if (must_restart) {
        volatile cpm8260_t *cp;

        /* Some transmit errors cause the transmitter to shut
         * down.  We now issue a restart transmit.  Since the
         * errors close the BD and update the pointers, the restart
         * _should_ pick up without having to reset any of our
         * pointers either.  Also, To workaround 8260 device erratum
         * CPM37, we must disable and then re-enable the transmitter
         * following a Late Collision, Underrun, or Retry Limit error.
         */
         
         // disable Transmitter
        cep->fccp->fcc_gfmr &= ~FCC_GFMR_ENT;
        udelay(10); /* wait a few microseconds just on principle */
   
        #ifdef THALES_DEBUG_TRACE
        printk("Thales restart debug trace :\n");
        printk("first dirty tx %d, final dirty_tx %d, tbptr 
%d\n",cbt_ptr2index(dev,first_bdp_dirty_tx),cbt_ptr2index(dev,cep->dirty_tx),tbptr_ptr2index(dev,ep->fen_genfcc.fcc_tbptr));
        #endif
                                   
        // RESTART TX command to the cpm
        cp = cpmp;
        cp->cp_cpcr = mk_cr_cmd(cep->fip->fc_cpmpage, 
cep->fip->fc_cpmblock,0x0c, CPM_CR_RESTART_TX) | CPM_CR_FLG;
        while (cp->cp_cpcr & CPM_CR_FLG);
       
        // Adjusting Transmitter BD Handling
        /* HLO : I do not search backwards from the current TBPTR value 
to found skip BDs, but I directly
         * adjust the tbptr value to the dirty_tx current value.
         * In case of problemes occuring, change it and do like 
indicated in 29.10.3 of MPC8260 manual
         */
        ep->fen_genfcc.fcc_tbptr = __pa(cep->dirty_tx);
       
        #ifdef THALES_DEBUG_TRACE
        printk(" Thales workaround tbptr value adjusted : 
%d\n",tbptr_ptr2index(dev,ep->fen_genfcc.fcc_tbptr));
        #endif
       
        // re-enable Transmitter       
        cep->fccp->fcc_gfmr |=  FCC_GFMR_ENT;

        }

I hope this correction will help you and the community.

Best regards

Siju Viswanath K E a écrit :

>Hi Denk,
>	Thanks for the suggestion. I had a look at the source repository
>at projects/linuxppc_2_4_devel.git site. Outdated code doesnt seem to be
>the issue. My repository is patched upto 
>"Patch by Wojciech Kromer, 06 Jan 2004" and later changes are only
>adding extra board support. 
>
>regards,
>Siju Viswanath
>
>On Fri, 2006-03-24 at 13:21, Wolfgang Denk wrote:
>  
>
>>In message <1143177651.22246.3.camel@Blaze> you wrote:
>>    
>>
>>>	I am using denk's linuxppc-2.4.20 . I am getting this problem of
>>>      
>>>
>>Why don't you try using a more current version of the code? 2.4.20 is
>>*very* old, and *lots* of bugs and problems have been fixed since.
>>
>>It really does not make sense to spend effort on such old code.
>>
>>Best regards,
>>
>>Wolfgang Denk
>>    
>>
>
>_______________________________________________
>Linuxppc-embedded mailing list
>[email-masked]
>https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>
>  
>