[U-Boot] [PATCH v3 07/13] net: ftgmac100: handle timeouts when transmitting

Cédric Le Goater clg at kaod.org
Tue Oct 16 05:47:41 UTC 2018


On 10/15/18 10:58 PM, Joe Hershberger wrote:
> On Wed, Oct 10, 2018 at 6:48 AM Cédric Le Goater <clg at kaod.org> wrote:
>>
>> Signed-off-by: Cédric Le Goater <clg at kaod.org>
>> ---
>>  drivers/net/ftgmac100.c | 18 ++++++++++++++++++
>>  1 file changed, 18 insertions(+)
>>
>> diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
>> index b46187b567c6..edf34c601c68 100644
>> --- a/drivers/net/ftgmac100.c
>> +++ b/drivers/net/ftgmac100.c
>> @@ -28,6 +28,9 @@
>>  /* PKTBUFSTX/PKTBUFSRX must both be power of 2 */
>>  #define PKTBUFSTX      4       /* must be power of 2 */
>>
>> +/* Timeout for transmit */
>> +#define FTGMAC100_TX_TIMEOUT_MS                1000
>> +
>>  /* Timeout for a mdio read/write operation */
>>  #define FTGMAC100_MDIO_TIMEOUT_USEC    10000
>>
>> @@ -412,6 +415,7 @@ static int ftgmac100_send(struct udevice *dev, void *packet, int length)
>>                 roundup(sizeof(*curr_des), ARCH_DMA_MINALIGN);
>>         ulong data_start;
>>         ulong data_end;
>> +       ulong start;
>>
>>         invalidate_dcache_range(des_start, des_end);
>>
>> @@ -444,6 +448,20 @@ static int ftgmac100_send(struct udevice *dev, void *packet, int length)
>>         /* Start transmit */
>>         writel(1, &ftgmac100->txpd);
>>
>> +       /* Wait until packet is transmitted */
>> +       start = get_timer(0);
>> +       while (get_timer(start) < FTGMAC100_TX_TIMEOUT_MS) {
> 
> In general we prefer to use wait_bit.h for such things. Probably just
> define a BUILD_WAIT_FOR_BIT() in your .c to handle your memory access.

OK. I will take a look for v4. 

Thanks for the review.

C.


> 
>> +               invalidate_dcache_range(des_start, des_end);
>> +               if (!(curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN))
>> +                       break;
>> +               udelay(10);
>> +       }
>> +
>> +       if (get_timer(start) >= FTGMAC100_TX_TIMEOUT_MS) {
>> +               dev_err(dev, "transmit timeout\n");
>> +               return -ETIMEDOUT;
>> +       }
>> +
>>         debug("%s(): packet sent\n", __func__);
>>
>>         /* Move to next descriptor */
>> --
>> 2.17.1
>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot at lists.denx.de
>> https://lists.denx.de/listinfo/u-boot



More information about the U-Boot mailing list