From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: John Crispin <blogic@openwrt.org>,
"David S. Miller" <davem@davemloft.net>
Cc: "Felix Fietkau" <nbd@openwrt.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"Sean Wang (王志亘)" <sean.wang@mediatek.com>,
netdev@vger.kernel.org, linux-mediatek@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 6/8] net: mediatek: fix TX locking
Date: Thu, 7 Apr 2016 22:46:47 +0300 [thread overview]
Message-ID: <5706B927.8090309@cogentembedded.com> (raw)
In-Reply-To: <1460057210-55786-7-git-send-email-blogic@openwrt.org>
Hello.
On 04/07/2016 10:26 PM, John Crispin wrote:
> Inside the TX path there is a lock inside the tx_map function. This is
> however too late. The patch moves the lock to the start of the xmit
> function right before the free count check of the DMA ring happens.
> If we do not do this, the code becomes racy leading to TX stalls and
> dropped packets. This happens as there are 2 netdevs running on the
> same physical DMA ring.
>
> Signed-off-by: John Crispin <blogic@openwrt.org>
> ---
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 60b66ab..8434355 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
[...]
> @@ -712,14 +702,22 @@ static int mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
> struct mtk_eth *eth = mac->hw;
> struct mtk_tx_ring *ring = ð->tx_ring;
> struct net_device_stats *stats = &dev->stats;
> + unsigned long flags;
> bool gso = false;
> int tx_num;
>
> + /* normally we can rely on the stack not calling this more than once,
> + * however we have 2 queues running ont he same ring so we need to lock
s/ont he/ on the/, perhaps a good chance to fix the comment?
> + * the ring access
> + */
> + spin_lock_irqsave(ð->page_lock, flags);
> +
> tx_num = mtk_cal_txd_req(skb);
> if (unlikely(atomic_read(&ring->free_count) <= tx_num)) {
> mtk_stop_queue(eth);
> netif_err(eth, tx_queued, dev,
> "Tx Ring full when queue awake!\n");
> + spin_unlock_irqrestore(ð->page_lock, flags);
> return NETDEV_TX_BUSY;
> }
>
[...]
MBR, Sergei
next prev parent reply other threads:[~2016-04-07 19:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 19:26 [PATCH V2 0/8] net: mediatek: make the driver pass stress tests John Crispin
2016-04-07 19:26 ` [PATCH V2 1/8] net: mediatek: watchdog_timeo was not set John Crispin
[not found] ` <1460057210-55786-1-git-send-email-blogic-p3rKhJxN3npAfugRpC6u6w@public.gmane.org>
2016-04-07 19:26 ` [PATCH V2 2/8] net: mediatek: mtk_cal_txd_req() returns bad value John Crispin
2016-04-07 19:26 ` [PATCH V2 3/8] net: mediatek: remove superfluous reset call John Crispin
2016-04-07 19:26 ` [PATCH V2 4/8] net: mediatek: fix stop and wakeup of queue John Crispin
2016-04-07 19:26 ` [PATCH V2 5/8] net: mediatek: fix mtk_pending_work John Crispin
2016-04-07 22:00 ` kbuild test robot
2016-04-07 19:26 ` [PATCH V2 6/8] net: mediatek: fix TX locking John Crispin
2016-04-07 19:46 ` Sergei Shtylyov [this message]
2016-04-07 19:26 ` [PATCH V2 7/8] net: mediatek: move the pending_work struct to the device generic struct John Crispin
2016-04-07 19:26 ` [PATCH V2 8/8] net: mediatek: do not set the QID field in the TX DMA descriptors John Crispin
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=5706B927.8090309@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=blogic@openwrt.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=nbd@openwrt.org \
--cc=netdev@vger.kernel.org \
--cc=sean.wang@mediatek.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;
as well as URLs for NNTP newsgroup(s).