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

Joe Hershberger joe.hershberger at ni.com
Mon Oct 15 20:58:51 UTC 2018


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.

> +               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