linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH wireless] wifi: mt76: fix crash with WED rx support enabled
@ 2023-12-08  7:50 Felix Fietkau
  2023-12-08  9:50 ` Lorenzo Bianconi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Felix Fietkau @ 2023-12-08  7:50 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo

If WED rx is enabled, rx buffers are added to a buffer pool that can be
filled from multiple page pools. Because buffers freed from rx poll are
not guaranteed to belong to the processed queue's page pool, lockless
caching must not be used in this case.

Cc: stable@vger.kernel.org
Fixes: 2f5c3c77fc9b ("wifi: mt76: switch to page_pool allocator")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/dma.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index 511fe7e6e744..68ad915203aa 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -783,7 +783,7 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid)
 
 static void
 mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
-		  int len, bool more, u32 info)
+		  int len, bool more, u32 info, bool allow_direct)
 {
 	struct sk_buff *skb = q->rx_head;
 	struct skb_shared_info *shinfo = skb_shinfo(skb);
@@ -795,7 +795,7 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
 
 		skb_add_rx_frag(skb, nr_frags, page, offset, len, q->buf_size);
 	} else {
-		mt76_put_page_pool_buf(data, true);
+		mt76_put_page_pool_buf(data, allow_direct);
 	}
 
 	if (more)
@@ -815,6 +815,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
 	struct sk_buff *skb;
 	unsigned char *data;
 	bool check_ddone = false;
+	bool allow_direct = !mt76_queue_is_wed_rx(q);
 	bool more;
 
 	if (IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED) &&
@@ -855,7 +856,8 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
 		}
 
 		if (q->rx_head) {
-			mt76_add_fragment(dev, q, data, len, more, info);
+			mt76_add_fragment(dev, q, data, len, more, info,
+					  allow_direct);
 			continue;
 		}
 
@@ -884,7 +886,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
 		continue;
 
 free_frag:
-		mt76_put_page_pool_buf(data, true);
+		mt76_put_page_pool_buf(data, allow_direct);
 	}
 
 	mt76_dma_rx_fill(dev, q, true);
-- 
2.41.0


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

* Re: [PATCH wireless] wifi: mt76: fix crash with WED rx support enabled
  2023-12-08  7:50 [PATCH wireless] wifi: mt76: fix crash with WED rx support enabled Felix Fietkau
@ 2023-12-08  9:50 ` Lorenzo Bianconi
  2023-12-11 13:13 ` Kalle Valo
  2023-12-12 14:25 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2023-12-08  9:50 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, kvalo

[-- Attachment #1: Type: text/plain, Size: 2431 bytes --]

> If WED rx is enabled, rx buffers are added to a buffer pool that can be
> filled from multiple page pools. Because buffers freed from rx poll are
> not guaranteed to belong to the processed queue's page pool, lockless
> caching must not be used in this case.

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> 
> Cc: stable@vger.kernel.org
> Fixes: 2f5c3c77fc9b ("wifi: mt76: switch to page_pool allocator")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> ---
>  drivers/net/wireless/mediatek/mt76/dma.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
> index 511fe7e6e744..68ad915203aa 100644
> --- a/drivers/net/wireless/mediatek/mt76/dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/dma.c
> @@ -783,7 +783,7 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid)
>  
>  static void
>  mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
> -		  int len, bool more, u32 info)
> +		  int len, bool more, u32 info, bool allow_direct)
>  {
>  	struct sk_buff *skb = q->rx_head;
>  	struct skb_shared_info *shinfo = skb_shinfo(skb);
> @@ -795,7 +795,7 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
>  
>  		skb_add_rx_frag(skb, nr_frags, page, offset, len, q->buf_size);
>  	} else {
> -		mt76_put_page_pool_buf(data, true);
> +		mt76_put_page_pool_buf(data, allow_direct);
>  	}
>  
>  	if (more)
> @@ -815,6 +815,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
>  	struct sk_buff *skb;
>  	unsigned char *data;
>  	bool check_ddone = false;
> +	bool allow_direct = !mt76_queue_is_wed_rx(q);
>  	bool more;
>  
>  	if (IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED) &&
> @@ -855,7 +856,8 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
>  		}
>  
>  		if (q->rx_head) {
> -			mt76_add_fragment(dev, q, data, len, more, info);
> +			mt76_add_fragment(dev, q, data, len, more, info,
> +					  allow_direct);
>  			continue;
>  		}
>  
> @@ -884,7 +886,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
>  		continue;
>  
>  free_frag:
> -		mt76_put_page_pool_buf(data, true);
> +		mt76_put_page_pool_buf(data, allow_direct);
>  	}
>  
>  	mt76_dma_rx_fill(dev, q, true);
> -- 
> 2.41.0
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH wireless] wifi: mt76: fix crash with WED rx support enabled
  2023-12-08  7:50 [PATCH wireless] wifi: mt76: fix crash with WED rx support enabled Felix Fietkau
  2023-12-08  9:50 ` Lorenzo Bianconi
@ 2023-12-11 13:13 ` Kalle Valo
  2023-12-12 14:25 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2023-12-11 13:13 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless

Felix Fietkau <nbd@nbd.name> writes:

> If WED rx is enabled, rx buffers are added to a buffer pool that can be
> filled from multiple page pools. Because buffers freed from rx poll are
> not guaranteed to belong to the processed queue's page pool, lockless
> caching must not be used in this case.
>
> Cc: stable@vger.kernel.org
> Fixes: 2f5c3c77fc9b ("wifi: mt76: switch to page_pool allocator")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

I assigned this to me on patchwork and will apply to wireless later.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

* Re: [PATCH wireless] wifi: mt76: fix crash with WED rx support enabled
  2023-12-08  7:50 [PATCH wireless] wifi: mt76: fix crash with WED rx support enabled Felix Fietkau
  2023-12-08  9:50 ` Lorenzo Bianconi
  2023-12-11 13:13 ` Kalle Valo
@ 2023-12-12 14:25 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2023-12-12 14:25 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless

Felix Fietkau <nbd@nbd.name> wrote:

> If WED rx is enabled, rx buffers are added to a buffer pool that can be
> filled from multiple page pools. Because buffers freed from rx poll are
> not guaranteed to belong to the processed queue's page pool, lockless
> caching must not be used in this case.
> 
> Cc: stable@vger.kernel.org
> Fixes: 2f5c3c77fc9b ("wifi: mt76: switch to page_pool allocator")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

Patch applied to wireless.git, thanks.

cd607f2cbbbe wifi: mt76: fix crash with WED rx support enabled

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20231208075004.69843-1-nbd@nbd.name/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2023-12-12 14:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-08  7:50 [PATCH wireless] wifi: mt76: fix crash with WED rx support enabled Felix Fietkau
2023-12-08  9:50 ` Lorenzo Bianconi
2023-12-11 13:13 ` Kalle Valo
2023-12-12 14:25 ` Kalle Valo

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