From: Willy Tarreau <w@1wt.eu>
To: Claudiu.Beznea@microchip.com
Cc: Nicolas.Ferre@microchip.com, netdev@vger.kernel.org,
davem@davemloft.net, kuba@kernel.org, daniel@0x0f.com
Subject: Re: [PATCH net-next 3/3] macb: support the two tx descriptors on at91rm9200
Date: Wed, 14 Oct 2020 18:27:32 +0200 [thread overview]
Message-ID: <20201014162732.GA12944@1wt.eu> (raw)
In-Reply-To: <29603cfa-db00-f088-3dbe-0781ee5a99ed@microchip.com>
Hi Claudiu,
first, thanks for your feedback!
On Wed, Oct 14, 2020 at 04:08:00PM +0000, Claudiu.Beznea@microchip.com wrote:
> > @@ -3994,11 +3996,10 @@ static netdev_tx_t at91ether_start_xmit(struct sk_buff *skb,
> > struct net_device *dev)
> > {
> > struct macb *lp = netdev_priv(dev);
> > + unsigned long flags;
> >
> > - if (macb_readl(lp, TSR) & MACB_BIT(RM9200_BNQ)) {
> > - int desc = 0;
> > -
> > - netif_stop_queue(dev);
> > + if (lp->rm9200_tx_len < 2) {
> > + int desc = lp->rm9200_tx_tail;
>
> I think you also want to protect these reads with spin_lock() to avoid
> concurrency with the interrupt handler.
I don't think it's needed because the condition doesn't change below
us as the interrupt handler only decrements. However I could use a
READ_ONCE to make things cleaner. And in practice this test was kept
to keep some sanity checks but it never fails, as if the queue length
reaches 2, the queue is stopped (and I never got the device busy message
either before nor after the patch).
> > /* Store packet information (to free when Tx completed) */
> > lp->rm9200_txq[desc].skb = skb;
> > @@ -4012,6 +4013,15 @@ static netdev_tx_t at91ether_start_xmit(struct sk_buff *skb,
> > return NETDEV_TX_OK;
> > }
> >
> > + spin_lock_irqsave(&lp->lock, flags);
> > +
> > + lp->rm9200_tx_tail = (desc + 1) & 1;
> > + lp->rm9200_tx_len++;
> > + if (lp->rm9200_tx_len > 1)
> > + netif_stop_queue(dev);
This is where we guarantee that we won't call start_xmit() again with
rm9200_tx_len >= 2.
> > @@ -4088,21 +4100,39 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
> > at91ether_rx(dev);
> >
> > /* Transmit complete */
> > - if (intstatus & MACB_BIT(TCOMP)) {
> > + if (intstatus & (MACB_BIT(TCOMP) | MACB_BIT(RM9200_TBRE))) {
> > /* The TCOM bit is set even if the transmission failed */
> > if (intstatus & (MACB_BIT(ISR_TUND) | MACB_BIT(ISR_RLE)))
> > dev->stats.tx_errors++;
> >
> > - desc = 0;
> > - if (lp->rm9200_txq[desc].skb) {
> > + spin_lock(&lp->lock);
>
> Also, this lock could be moved before while, below, as you want to protect
> the rm9200_tx_len and rm9200_tx_tails members of lp as I understand.
Sure, but it actually *is* before the while(). I'm sorry if that was not
visible from the context of the diff. The while is just a few lins below,
thus rm9200_tx_len and rm9200_tx_tail are properly protected. Do not
hesitate to tell me if something is not clear or if I'm wrong!
Thanks!
Willy
next prev parent reply other threads:[~2020-10-14 16:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-11 9:09 [PATCH net-next 0/3] macb: support the 2-deep Tx queue on at91 Willy Tarreau
2020-10-11 9:09 ` [PATCH net-next 1/3] macb: add RM9200's interrupt flag TBRE Willy Tarreau
2020-10-11 9:09 ` [PATCH net-next 2/3] macb: prepare at91 to use a 2-frame TX queue Willy Tarreau
2020-10-11 9:09 ` [PATCH net-next 3/3] macb: support the two tx descriptors on at91rm9200 Willy Tarreau
2020-10-14 16:08 ` Claudiu.Beznea
2020-10-14 16:27 ` Willy Tarreau [this message]
2020-10-21 9:02 ` Claudiu.Beznea
2020-10-14 0:03 ` [PATCH net-next 0/3] macb: support the 2-deep Tx queue on at91 Jakub Kicinski
2020-10-14 3:06 ` Willy Tarreau
2020-10-14 3:13 ` Jakub Kicinski
2020-11-13 10:03 ` Alexandre Belloni
2020-11-13 19:44 ` Willy Tarreau
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=20201014162732.GA12944@1wt.eu \
--to=w@1wt.eu \
--cc=Claudiu.Beznea@microchip.com \
--cc=Nicolas.Ferre@microchip.com \
--cc=daniel@0x0f.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).