From: "Måns Rullgård" <mans@mansr.com>
To: Francois Romieu <romieu@fr.zoreil.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, slash.tmp@free.fr
Subject: Re: [PATCH v5] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
Date: Wed, 11 Nov 2015 00:40:09 +0000 [thread overview]
Message-ID: <yw1xio59pdw6.fsf@unicorn.mansr.com> (raw)
In-Reply-To: <20151110233448.GA8646@electric-eye.fr.zoreil.com> (Francois Romieu's message of "Wed, 11 Nov 2015 00:34:48 +0100")
Francois Romieu <romieu@fr.zoreil.com> writes:
> Mans Rullgard <mans@mansr.com> :
>> diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c
>> new file mode 100644
>> index 0000000..11cd389
>> --- /dev/null
>> +++ b/drivers/net/ethernet/aurora/nb8800.c
> [...]
>> +static int nb8800_xmit(struct sk_buff *skb, struct net_device *dev)
>> +{
> [...]
>> +
>> + netdev_sent_queue(dev, skb->len);
>> +
>> + smp_mb__before_spinlock();
>> + spin_lock_irqsave(&priv->tx_lock, flags);
>
> At some point you may consider performing both Tx and Rx from napi context
> and thus replacing priv->tx_lock with netif_tx_lock.
That lock is to synchronise the DMA start between nb8800_xmit() and the
interrupt handler. When the DMA complete interrupt arrives, the next
chain should be kicked off as quickly as possible, and I don't see why
that would benefit from being done in napi context.
>> +
>> + if (!skb->xmit_more) {
>> + priv->tx_chain->ready = true;
>> + priv->tx_chain = NULL;
>> + nb8800_tx_dma_start(dev);
>> + }
>> +
>> + spin_unlock_irqrestore(&priv->tx_lock, flags);
>> +
>> + priv->tx_next = next;
>
> Are there strong reasons why nb8800_tx_done could not kick between
> spin_unlock_irqrestore and the non-local update of priv->tx_next ?
Good catch. priv->tx_next wasn't accessed elsewhere in an earlier
version, and I forgot to fix that. nb8800_tx_done() makes sure the DMA
has actually finished, so priv->tx_next should be updated before
starting the DMA rather than after. The check against tx_next in
nb8800_tx_done() is only to put some limit on the loop and to avoid
confusion when nb8800_dma_stop() does it's dance. There should be no
need for more synchronisation here than what the already present memory
barriers provide.
> [...]
>> +static irqreturn_t nb8800_irq(int irq, void *dev_id)
>> +{
>> + struct net_device *dev = dev_id;
>> + struct nb8800_priv *priv = netdev_priv(dev);
>> + u32 val;
>> +
>> + /* tx interrupt */
>> + val = nb8800_readl(priv, NB8800_TXC_SR);
>> + if (val) {
> [...]
>> + }
>> +
>> + /* rx interrupt */
>> + val = nb8800_readl(priv, NB8800_RXC_SR);
>> + if (val) {
> [...]
>> + }
>> +
>> + return IRQ_HANDLED;
>
> Returning IRQ_HANDLED is fine if one of those hold:
> 1. you're sure that at least one of the "if" branch is used
> 2. you'll be able to quickly figure out what's happening whenever 1. stops
> being true.
You're right, better to check that the device really did have something
to say.
--
Måns Rullgård
mans@mansr.com
next prev parent reply other threads:[~2015-11-11 0:40 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 16:14 Mans Rullgard
2015-11-10 17:55 ` Eric Dumazet
2015-11-10 18:05 ` Måns Rullgård
2015-11-10 20:04 ` David Miller
2015-11-10 20:53 ` Måns Rullgård
2015-11-10 21:06 ` David Miller
2015-11-10 21:21 ` Måns Rullgård
2015-11-10 21:51 ` Eric Dumazet
2015-11-11 13:41 ` Mason
2015-11-11 13:54 ` Måns Rullgård
2015-11-11 14:10 ` Eric Dumazet
2015-11-11 14:06 ` Eric Dumazet
2015-11-10 17:58 ` Eric Dumazet
2015-11-10 18:07 ` Måns Rullgård
2015-11-10 19:13 ` Mason
2015-11-10 19:25 ` Måns Rullgård
2015-11-12 13:33 ` Mason
2015-11-12 14:04 ` Måns Rullgård
2015-11-12 16:19 ` Mason
2015-11-12 16:57 ` Måns Rullgård
2015-11-12 17:20 ` Måns Rullgård
2015-11-10 22:09 ` Andy Shevchenko
2015-11-10 22:34 ` Måns Rullgård
2015-11-10 22:40 ` Andy Shevchenko
2015-11-10 23:07 ` Måns Rullgård
2015-11-11 0:36 ` Andy Shevchenko
2015-11-11 0:44 ` Måns Rullgård
2015-11-10 23:34 ` Francois Romieu
2015-11-11 0:40 ` Måns Rullgård [this message]
2015-11-11 2:11 ` David Miller
2015-11-11 12:22 ` Måns Rullgård
2015-11-11 13:04 ` Måns Rullgård
2015-11-11 13:29 ` Eric Dumazet
2015-11-11 13:48 ` Måns Rullgård
2015-11-11 14:09 ` Eric Dumazet
2015-11-11 14:15 ` Måns Rullgård
2015-11-11 14:35 ` Måns Rullgård
2015-11-11 14:44 ` Eric Dumazet
2015-11-11 14:42 ` Eric Dumazet
2015-11-11 16:24 ` David Miller
2015-11-11 18:25 ` Måns Rullgård
2015-11-11 19:02 ` David Miller
2015-11-11 19:09 ` Måns Rullgård
2015-11-11 19:13 ` David Miller
2015-11-11 19:17 ` Måns Rullgård
2015-11-11 19:19 ` David Miller
2015-11-11 19:25 ` Måns Rullgård
2015-11-11 19:26 ` David Miller
2015-11-11 19:35 ` Måns Rullgård
2015-11-11 19:48 ` David Miller
2015-11-11 20:47 ` Måns Rullgård
2015-11-11 16:20 ` David Miller
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=yw1xio59pdw6.fsf@unicorn.mansr.com \
--to=mans@mansr.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=romieu@fr.zoreil.com \
--cc=slash.tmp@free.fr \
/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
all inboxes | Powered by JetHome®