public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Francois Romieu <romieu@fr.zoreil.com>
To: Sonic Zhang <sonic.adi@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org,
	adi-buildroot-devel@lists.sourceforge.net,
	Sonic Zhang <sonic.zhang@analog.com>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	David Laight <David.Laight@aculab.com>
Subject: Re: [PATCH v7] bfin_mac: convert bfin Ethernet driver to NAPI framework
Date: Wed, 23 Jul 2014 00:16:06 +0200	[thread overview]
Message-ID: <20140722221606.GA16444@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <1406014682-19188-1-git-send-email-sonic.adi@gmail.com>

Sonic Zhang <sonic.adi@gmail.com> :
[...]
> diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
> index 7ae74d4..8924802 100644
> --- a/drivers/net/ethernet/adi/bfin_mac.c
> +++ b/drivers/net/ethernet/adi/bfin_mac.c
[...]
> @@ -1302,41 +1303,53 @@ out:
>  	current_rx_ptr = current_rx_ptr->next;
>  }
>  
> +static int bfin_mac_poll(struct napi_struct *napi, int budget)
> +{
> +	int i = 0;
> +	struct bfin_mac_local *lp = container_of(napi,
> +						 struct bfin_mac_local,
> +						 napi);
> +
> +	while (current_rx_ptr->status.status_word != 0 && i < budget) {
> +		bfin_mac_rx(lp, budget);
> +		i++;
> +	}
> +
> +	if (i < budget) {
> +		napi_complete(napi);
> +		if (lp->rx_irq_disabled--)
> +			if (!lp->rx_irq_disabled)
> +				enable_irq(IRQ_MAC_RX);
> +	}
[...]
>  static irqreturn_t bfin_mac_interrupt(int irq, void *dev_id)
>  {
> +	struct bfin_mac_local *lp = netdev_priv(dev_id);
> +	u32 status;
> +
> +	status = bfin_read_DMA1_IRQ_STATUS();
> +
> +	bfin_write_DMA1_IRQ_STATUS(status | DMA_DONE | DMA_ERR);
> +	if ((status & DMA_DONE) && napi_schedule_prep(&lp->napi)) {
> +		if (!lp->rx_irq_disabled++)
> +			disable_irq_nosync(IRQ_MAC_RX);
> +		__napi_schedule(&lp->napi);

If netpoll scavenges between napi_schedule_prep and lp->rx_irq_disabled++
on a different CPU, bfin_mac_interrupt may later __napi_schedule while
already napi_completed in netpoll...bfin_mac_poll(): bfin_mac_poll won't
be run in net_rx_action and IRQ_MAC_RX will stay disabled.

I don't know if something on the blackfin arch prevents the window to
widen and makes it moot.

As the bfin_mac driver requests the single non shared IRQ_MAC_RX irq,
couldn't we instead:

static irqreturn_t bfin_mac_interrupt(int irq, void *dev_id)
[...]
	if (status & DMA_DONE) {
		disable_irq_nosync(IRQ_MAC_RX);
		/* Code won't return here until a scheduled poll enables irq. */
		set_bit(BFIN_IRQ_DISABLED, &lp->flags);
		napi_schedule(&lp->napi);
	}

static int bfin_mac_poll(struct napi_struct *napi, int budget)
[...]
	if (i < budget) {
		napi_complete(napi);
		if (test_and_clear_bit(BFIN_IRQ_DISABLED, &lp->flags))
			enable_irq(IRQ_MAC_RX);
	}

Comments ?

-- 
Ueimor

  parent reply	other threads:[~2014-07-22 22:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-22  7:38 [PATCH v7] bfin_mac: convert bfin Ethernet driver to NAPI framework Sonic Zhang
2014-07-22  7:59 ` Eric Dumazet
2014-07-22  8:01   ` David Miller
2014-07-22  8:53     ` Sonic Zhang
2014-07-22  9:10       ` David Laight
2014-07-22  9:51       ` Eric Dumazet
2014-07-22 10:10         ` Sonic Zhang
2014-07-22 10:12     ` Sonic Zhang
2014-07-22 22:16 ` Francois Romieu [this message]
2014-07-24  8:28   ` Sonic Zhang

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=20140722221606.GA16444@electric-eye.fr.zoreil.com \
    --to=romieu@fr.zoreil.com \
    --cc=David.Laight@aculab.com \
    --cc=adi-buildroot-devel@lists.sourceforge.net \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sonic.adi@gmail.com \
    --cc=sonic.zhang@analog.com \
    /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