Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] net: lantiq: Add locking for TX DMA channel
@ 2020-09-22 21:41 Hauke Mehrtens
  2020-09-24  1:01 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Hauke Mehrtens @ 2020-09-22 21:41 UTC (permalink / raw)
  To: davem; +Cc: kuba, netdev, martin.blumenstingl, Hauke Mehrtens

The TX DMA channel data is accessed by the xrx200_start_xmit() and the
xrx200_tx_housekeeping() function from different threads. Make sure the
accesses are synchronized by acquiring the netif_tx_lock() in the
xrx200_tx_housekeeping() function too. This lock is acquired by the
kernel before calling xrx200_start_xmit().

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 drivers/net/ethernet/lantiq_xrx200.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c
index affec78cc0f5..36847ff93918 100644
--- a/drivers/net/ethernet/lantiq_xrx200.c
+++ b/drivers/net/ethernet/lantiq_xrx200.c
@@ -239,6 +239,7 @@ static int xrx200_tx_housekeeping(struct napi_struct *napi, int budget)
 	int pkts = 0;
 	int bytes = 0;
 
+	netif_tx_lock(net_dev);
 	while (pkts < budget) {
 		struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->tx_free];
 
@@ -262,6 +263,7 @@ static int xrx200_tx_housekeeping(struct napi_struct *napi, int budget)
 	net_dev->stats.tx_bytes += bytes;
 	netdev_completed_queue(ch->priv->net_dev, pkts, bytes);
 
+	netif_tx_unlock(net_dev);
 	if (netif_queue_stopped(net_dev))
 		netif_wake_queue(net_dev);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] net: lantiq: Add locking for TX DMA channel
  2020-09-22 21:41 [PATCH v2] net: lantiq: Add locking for TX DMA channel Hauke Mehrtens
@ 2020-09-24  1:01 ` David Miller
  2020-09-25 12:19   ` Martin Blumenstingl
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: David Miller @ 2020-09-24  1:01 UTC (permalink / raw)
  To: hauke; +Cc: kuba, netdev, martin.blumenstingl

From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Tue, 22 Sep 2020 23:41:12 +0200

> The TX DMA channel data is accessed by the xrx200_start_xmit() and the
> xrx200_tx_housekeeping() function from different threads. Make sure the
> accesses are synchronized by acquiring the netif_tx_lock() in the
> xrx200_tx_housekeeping() function too. This lock is acquired by the
> kernel before calling xrx200_start_xmit().
> 
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

Applied, but...

You posted this really fast after my feedback, so I have to ask if you
actually functionally tested this patch?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] net: lantiq: Add locking for TX DMA channel
  2020-09-24  1:01 ` David Miller
@ 2020-09-25 12:19   ` Martin Blumenstingl
  2020-09-26 19:30   ` Hauke Mehrtens
  2020-11-13 20:54   ` Martin Blumenstingl
  2 siblings, 0 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2020-09-25 12:19 UTC (permalink / raw)
  To: David Miller; +Cc: Hauke Mehrtens, kuba, netdev

On Thu, Sep 24, 2020 at 3:01 AM David Miller <davem@davemloft.net> wrote:
>
> From: Hauke Mehrtens <hauke@hauke-m.de>
> Date: Tue, 22 Sep 2020 23:41:12 +0200
>
> > The TX DMA channel data is accessed by the xrx200_start_xmit() and the
> > xrx200_tx_housekeeping() function from different threads. Make sure the
> > accesses are synchronized by acquiring the netif_tx_lock() in the
> > xrx200_tx_housekeeping() function too. This lock is acquired by the
> > kernel before calling xrx200_start_xmit().
> >
> > Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

> Applied, but...
>
> You posted this really fast after my feedback, so I have to ask if you
> actually functionally tested this patch?
it fixes the following crash for me: [0]


Best regards,
Martin


[0] https://pastebin.com/t1SLz9PH

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] net: lantiq: Add locking for TX DMA channel
  2020-09-24  1:01 ` David Miller
  2020-09-25 12:19   ` Martin Blumenstingl
@ 2020-09-26 19:30   ` Hauke Mehrtens
  2020-11-13 20:54   ` Martin Blumenstingl
  2 siblings, 0 replies; 5+ messages in thread
From: Hauke Mehrtens @ 2020-09-26 19:30 UTC (permalink / raw)
  To: David Miller; +Cc: kuba, netdev, martin.blumenstingl


[-- Attachment #1.1: Type: text/plain, Size: 921 bytes --]

On 9/24/20 3:01 AM, David Miller wrote:
> From: Hauke Mehrtens <hauke@hauke-m.de>
> Date: Tue, 22 Sep 2020 23:41:12 +0200
> 
>> The TX DMA channel data is accessed by the xrx200_start_xmit() and the
>> xrx200_tx_housekeeping() function from different threads. Make sure the
>> accesses are synchronized by acquiring the netif_tx_lock() in the
>> xrx200_tx_housekeeping() function too. This lock is acquired by the
>> kernel before calling xrx200_start_xmit().
>>
>> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> 
> Applied, but...
> 
> You posted this really fast after my feedback, so I have to ask if you
> actually functionally tested this patch?
> 

Hi David,

I created the patch first, then tested it with ipef3 (iperf3 -c
192.168.1.70 -P 10 -t 30 and reverse) multiple times and send both mails.

I did not see any problems, but it could still be that I miss more problems.

Hauke


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] net: lantiq: Add locking for TX DMA channel
  2020-09-24  1:01 ` David Miller
  2020-09-25 12:19   ` Martin Blumenstingl
  2020-09-26 19:30   ` Hauke Mehrtens
@ 2020-11-13 20:54   ` Martin Blumenstingl
  2 siblings, 0 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2020-11-13 20:54 UTC (permalink / raw)
  To: David Miller; +Cc: Hauke Mehrtens, kuba, netdev

On Thu, Sep 24, 2020 at 3:01 AM David Miller <davem@davemloft.net> wrote:
>
> From: Hauke Mehrtens <hauke@hauke-m.de>
> Date: Tue, 22 Sep 2020 23:41:12 +0200
>
> > The TX DMA channel data is accessed by the xrx200_start_xmit() and the
> > xrx200_tx_housekeeping() function from different threads. Make sure the
> > accesses are synchronized by acquiring the netif_tx_lock() in the
> > xrx200_tx_housekeeping() function too. This lock is acquired by the
> > kernel before calling xrx200_start_xmit().
> >
> > Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
>
> Applied [...]
what is the procedure to have this patch included in the 5.4 and 5.9
-stable trees as well?
this commit is already in mainline as f9317ae5523f99999fb54c513ebabbb2bc887ddf

After more testing other users have confirmed that this patch works
In hindsight it should have carried Fixes: fe1a56420cf2ec ("net:
lantiq: Add Lantiq / Intel VRX200 Ethernet driver")


Thank you!
Martin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-13 20:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-22 21:41 [PATCH v2] net: lantiq: Add locking for TX DMA channel Hauke Mehrtens
2020-09-24  1:01 ` David Miller
2020-09-25 12:19   ` Martin Blumenstingl
2020-09-26 19:30   ` Hauke Mehrtens
2020-11-13 20:54   ` Martin Blumenstingl

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).