[PATCH net-next] net: ethernet: mtk_wed: get rid of queue lock for rx queue

Subsystems: mediatek ethernet driver, networking drivers, the rest

STALE1337d

5 messages, 4 authors, 2023-01-10 · open the first message on its own page

[PATCH net-next] net: ethernet: mtk_wed: get rid of queue lock for rx queue

From: Lorenzo Bianconi <lorenzo@kernel.org>
Date: 2023-01-07 14:41:44

mtk_wed_wo_queue_rx_clean and mtk_wed_wo_queue_refill routines can't run
concurrently so get rid of spinlock for rx queues.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/mediatek/mtk_wed_wo.c | 4 ----
 1 file changed, 4 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_wed_wo.c b/drivers/net/ethernet/mediatek/mtk_wed_wo.c
index a0a39643caf7..d32b86499896 100644
--- a/drivers/net/ethernet/mediatek/mtk_wed_wo.c
+++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.c
@@ -138,7 +138,6 @@ mtk_wed_wo_queue_refill(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q,
 	enum dma_data_direction dir = rx ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
 	int n_buf = 0;
 
-	spin_lock_bh(&q->lock);
 	while (q->queued < q->n_desc) {
 		struct mtk_wed_wo_queue_entry *entry;
 		dma_addr_t addr;
@@ -172,7 +171,6 @@ mtk_wed_wo_queue_refill(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q,
 		q->queued++;
 		n_buf++;
 	}
-	spin_unlock_bh(&q->lock);
 
 	return n_buf;
 }
@@ -316,7 +314,6 @@ mtk_wed_wo_queue_rx_clean(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q)
 {
 	struct page *page;
 
-	spin_lock_bh(&q->lock);
 	for (;;) {
 		void *buf = mtk_wed_wo_dequeue(wo, q, NULL, true);
 
@@ -325,7 +322,6 @@ mtk_wed_wo_queue_rx_clean(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q)
 
 		skb_free_frag(buf);
 	}
-	spin_unlock_bh(&q->lock);
 
 	if (!q->cache.va)
 		return;
-- 
2.39.0

Re: [PATCH net-next] net: ethernet: mtk_wed: get rid of queue lock for rx queue

From: Alexander H Duyck <hidden>
Date: 2023-01-10 00:51:02

On Sat, 2023-01-07 at 15:41 +0100, Lorenzo Bianconi wrote:
mtk_wed_wo_queue_rx_clean and mtk_wed_wo_queue_refill routines can't run
concurrently so get rid of spinlock for rx queues.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
My understanding is that mtk_wed_wo_queue_refill will only be called
during init and by the tasklet. The mtk_wed_wo_queue_rx_clean function
is only called during deinit and only after the tasklet has been
disabled. That is the reason they cannot run at the same time correct?

It would be nice if you explained why they couldn't run concurrently
rather than just stating it is so in the patch description. It makes it
easier to verify assumptions that way. Otherwise the patch itself looks
good to me.

Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>

Re: [PATCH net-next] net: ethernet: mtk_wed: get rid of queue lock for rx queue

From: Jakub Kicinski <kuba@kernel.org>
Date: 2023-01-10 03:37:27

On Mon, 09 Jan 2023 16:50:55 -0800 Alexander H Duyck wrote:
On Sat, 2023-01-07 at 15:41 +0100, Lorenzo Bianconi wrote:
quoted
mtk_wed_wo_queue_rx_clean and mtk_wed_wo_queue_refill routines can't run
concurrently so get rid of spinlock for rx queues.
You say "for rx queues" but mtk_wed_wo_queue_refill() is also called
for tx queues.
My understanding is that mtk_wed_wo_queue_refill will only be called
during init and by the tasklet. The mtk_wed_wo_queue_rx_clean function
is only called during deinit and only after the tasklet has been
disabled. That is the reason they cannot run at the same time correct?

It would be nice if you explained why they couldn't run concurrently
rather than just stating it is so in the patch description. It makes it
easier to verify assumptions that way. Otherwise the patch itself looks
good to me.
Agreed, please respin with a better commit message.

Re: [PATCH net-next] net: ethernet: mtk_wed: get rid of queue lock for rx queue

From: Lorenzo Bianconi <hidden>
Date: 2023-01-10 09:11:17

On Sat, 2023-01-07 at 15:41 +0100, Lorenzo Bianconi wrote:
quoted
mtk_wed_wo_queue_rx_clean and mtk_wed_wo_queue_refill routines can't run
concurrently so get rid of spinlock for rx queues.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
My understanding is that mtk_wed_wo_queue_refill will only be called
during init and by the tasklet. The mtk_wed_wo_queue_rx_clean function
is only called during deinit and only after the tasklet has been
disabled. That is the reason they cannot run at the same time correct?
correct
It would be nice if you explained why they couldn't run concurrently
rather than just stating it is so in the patch description. It makes it
easier to verify assumptions that way. Otherwise the patch itself looks
good to me.
ack, right. I will update the commit message in v2.

Regards,
Lorenzo
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>

Re: [PATCH net-next] net: ethernet: mtk_wed: get rid of queue lock for rx queue

From: Lorenzo Bianconi <hidden>
Date: 2023-01-10 09:11:49

On Mon, 09 Jan 2023 16:50:55 -0800 Alexander H Duyck wrote:
quoted
On Sat, 2023-01-07 at 15:41 +0100, Lorenzo Bianconi wrote:
quoted
mtk_wed_wo_queue_rx_clean and mtk_wed_wo_queue_refill routines can't run
concurrently so get rid of spinlock for rx queues.
You say "for rx queues" but mtk_wed_wo_queue_refill() is also called
for tx queues.
ack, but for tx queues is run just during initialization.
quoted
My understanding is that mtk_wed_wo_queue_refill will only be called
during init and by the tasklet. The mtk_wed_wo_queue_rx_clean function
is only called during deinit and only after the tasklet has been
disabled. That is the reason they cannot run at the same time correct?

It would be nice if you explained why they couldn't run concurrently
rather than just stating it is so in the patch description. It makes it
easier to verify assumptions that way. Otherwise the patch itself looks
good to me.
Agreed, please respin with a better commit message.
ack, I will post v2 with a better commit message.

Regards,
Lorenzo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help