Skip to content

Commit cd607f2

Browse files
nbd168Kalle Valo
authored andcommitted
wifi: mt76: fix crash with WED rx support enabled
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: [email protected] Fixes: 2f5c3c7 ("wifi: mt76: switch to page_pool allocator") Signed-off-by: Felix Fietkau <[email protected]> Acked-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ce038ed commit cd607f2

File tree

1 file changed

+6
-4
lines changed
  • drivers/net/wireless/mediatek/mt76

1 file changed

+6
-4
lines changed

drivers/net/wireless/mediatek/mt76/dma.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ mt76_dma_rx_reset(struct mt76_dev *dev, enum mt76_rxq_id qid)
783783

784784
static void
785785
mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data,
786-
int len, bool more, u32 info)
786+
int len, bool more, u32 info, bool allow_direct)
787787
{
788788
struct sk_buff *skb = q->rx_head;
789789
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,
795795

796796
skb_add_rx_frag(skb, nr_frags, page, offset, len, q->buf_size);
797797
} else {
798-
mt76_put_page_pool_buf(data, true);
798+
mt76_put_page_pool_buf(data, allow_direct);
799799
}
800800

801801
if (more)
@@ -815,6 +815,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
815815
struct sk_buff *skb;
816816
unsigned char *data;
817817
bool check_ddone = false;
818+
bool allow_direct = !mt76_queue_is_wed_rx(q);
818819
bool more;
819820

820821
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)
855856
}
856857

857858
if (q->rx_head) {
858-
mt76_add_fragment(dev, q, data, len, more, info);
859+
mt76_add_fragment(dev, q, data, len, more, info,
860+
allow_direct);
859861
continue;
860862
}
861863

@@ -884,7 +886,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)
884886
continue;
885887

886888
free_frag:
887-
mt76_put_page_pool_buf(data, true);
889+
mt76_put_page_pool_buf(data, allow_direct);
888890
}
889891

890892
mt76_dma_rx_fill(dev, q, true);

0 commit comments

Comments
 (0)