mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Oleksij Rempel <linux@rempel-privat.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v1 1/3] net: ath79: add ag71xx Ethernet driver
Date: Tue, 12 Sep 2017 08:32:08 +0200	[thread overview]
Message-ID: <20170912063208.t34njjp6ebmsvnux@pengutronix.de> (raw)
In-Reply-To: <20170818140301.18749-1-linux@rempel-privat.de>

On Fri, Aug 18, 2017 at 04:02:59PM +0200, Oleksij Rempel wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
>  arch/mips/mach-ath79/include/mach/ar71xx_regs.h |  12 +
>  drivers/net/Kconfig                             |   7 +
>  drivers/net/Makefile                            |   1 +
>  drivers/net/ag71xx.c                            | 530 ++++++++++++++++++++++++
>  4 files changed, 550 insertions(+)
>  create mode 100644 drivers/net/ag71xx.c
> 
> +static int ag71xx_ether_send(struct eth_device *edev, void *packet, int length)
> +{
> +	struct ag71xx *priv = edev->priv;
> +	struct device_d *dev = priv->dev;
> +	ag7240_desc_t *f = &priv->fifo_tx[priv->next_tx];
> +	int i;
> +
> +	/* flush */
> +	dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
> +
> +	f->pkt_start_addr = virt_to_phys(packet);
> +	f->res1 = 0;
> +	f->pkt_size = length;
> +	f->is_empty = 0;
> +	ag71xx_wr(priv, AG71XX_REG_TX_DESC, virt_to_phys(f));
> +	ag71xx_wr(priv, AG71XX_REG_TX_CTRL, TX_CTRL_TXE);
> +
> +	/* flush again?! */
> +	dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
> +
> +	for (i = 0; i < MAX_WAIT; i++) {
> +		udelay(100);
> +		if (f->is_empty) {
> +			break;
> +		}
> +	}
> +

Use a is_timeout() loop. With this you won't have a minimum delay of
100us and also not a granularity of 100us.

> +	if (i == MAX_WAIT) {
> +		dev_err(dev, "Tx Timed out\n");
> +	}
> +

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2017-09-12  6:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18 14:02 Oleksij Rempel
2017-08-18 14:03 ` [PATCH v1 2/3] net: ag71xx: bit 19 should be set to 1 for GE0 Oleksij Rempel
2017-08-18 14:03 ` [PATCH v1 3/3] add ar9331.dtsi and enable mac0 Oleksij Rempel
2017-09-12  6:32 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170912063208.t34njjp6ebmsvnux@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=linux@rempel-privat.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox