Skip to content

Commit 444299d

Browse files
nbd168Ansuel
authored andcommitted
kernel: backport mediatek WED DMA mask fixes
Fixes issues on devices with 4 GB RAM. Signed-off-by: Felix Fietkau <[email protected]> (cherry picked from commit 3632c0d) [ fix conflict errors ] Signed-off-by: Christian Marangi <[email protected]>
1 parent 6c5c859 commit 444299d

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
From: Lorenzo Bianconi <[email protected]>
2+
Date: Wed, 8 Oct 2025 12:41:48 +0200
3+
Subject: [PATCH] wifi: mt76: wed: use proper wed reference in mt76 wed driver
4+
callabacks
5+
6+
MT7996 driver can use both wed and wed_hif2 devices to offload traffic
7+
from/to the wireless NIC. In the current codebase we assume to always
8+
use the primary wed device in wed callbacks resulting in the following
9+
crash if the hw runs wed_hif2 (e.g. 6GHz link).
10+
11+
[ 297.455876] Unable to handle kernel read from unreadable memory at virtual address 000000000000080a
12+
[ 297.464928] Mem abort info:
13+
[ 297.467722] ESR = 0x0000000096000005
14+
[ 297.471461] EC = 0x25: DABT (current EL), IL = 32 bits
15+
[ 297.476766] SET = 0, FnV = 0
16+
[ 297.479809] EA = 0, S1PTW = 0
17+
[ 297.482940] FSC = 0x05: level 1 translation fault
18+
[ 297.487809] Data abort info:
19+
[ 297.490679] ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
20+
[ 297.496156] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
21+
[ 297.501196] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
22+
[ 297.506500] user pgtable: 4k pages, 39-bit VAs, pgdp=0000000107480000
23+
[ 297.512927] [000000000000080a] pgd=08000001097fb003, p4d=08000001097fb003, pud=08000001097fb003, pmd=0000000000000000
24+
[ 297.523532] Internal error: Oops: 0000000096000005 [#1] SMP
25+
[ 297.715393] CPU: 2 UID: 0 PID: 45 Comm: kworker/u16:2 Tainted: G O 6.12.50 #0
26+
[ 297.723908] Tainted: [O]=OOT_MODULE
27+
[ 297.727384] Hardware name: Banana Pi BPI-R4 (2x SFP+) (DT)
28+
[ 297.732857] Workqueue: nf_ft_offload_del nf_flow_rule_route_ipv6 [nf_flow_table]
29+
[ 297.740254] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
30+
[ 297.747205] pc : mt76_wed_offload_disable+0x64/0xa0 [mt76]
31+
[ 297.752688] lr : mtk_wed_flow_remove+0x58/0x80
32+
[ 297.757126] sp : ffffffc080fe3ae0
33+
[ 297.760430] x29: ffffffc080fe3ae0 x28: ffffffc080fe3be0 x27: 00000000deadbef7
34+
[ 297.767557] x26: ffffff80c5ebca00 x25: 0000000000000001 x24: ffffff80c85f4c00
35+
[ 297.774683] x23: ffffff80c1875b78 x22: ffffffc080d42cd0 x21: ffffffc080660018
36+
[ 297.781809] x20: ffffff80c6a076d0 x19: ffffff80c6a043c8 x18: 0000000000000000
37+
[ 297.788935] x17: 0000000000000000 x16: 0000000000000001 x15: 0000000000000000
38+
[ 297.796060] x14: 0000000000000019 x13: ffffff80c0ad8ec0 x12: 00000000fa83b2da
39+
[ 297.803185] x11: ffffff80c02700c0 x10: ffffff80c0ad8ec0 x9 : ffffff81fef96200
40+
[ 297.810311] x8 : ffffff80c02700c0 x7 : ffffff80c02700d0 x6 : 0000000000000002
41+
[ 297.817435] x5 : 0000000000000400 x4 : 0000000000000000 x3 : 0000000000000000
42+
[ 297.824561] x2 : 0000000000000001 x1 : 0000000000000800 x0 : ffffff80c6a063c8
43+
[ 297.831686] Call trace:
44+
[ 297.834123] mt76_wed_offload_disable+0x64/0xa0 [mt76]
45+
[ 297.839254] mtk_wed_flow_remove+0x58/0x80
46+
[ 297.843342] mtk_flow_offload_cmd+0x434/0x574
47+
[ 297.847689] mtk_wed_setup_tc_block_cb+0x30/0x40
48+
[ 297.852295] nf_flow_offload_ipv6_hook+0x7f4/0x964 [nf_flow_table]
49+
[ 297.858466] nf_flow_rule_route_ipv6+0x438/0x4a4 [nf_flow_table]
50+
[ 297.864463] process_one_work+0x174/0x300
51+
[ 297.868465] worker_thread+0x278/0x430
52+
[ 297.872204] kthread+0xd8/0xdc
53+
[ 297.875251] ret_from_fork+0x10/0x20
54+
[ 297.878820] Code: 928b5ae0 8b000273 91400a60 f943fa61 (79401421)
55+
[ 297.884901] ---[ end trace 0000000000000000 ]---
56+
57+
Fix the issue detecting the proper wed reference to use running wed
58+
callabacks.
59+
60+
-- Partial backport for data structure change only (rest is in the mt76 package)
61+
62+
Fixes: 83eafc9251d6 ("wifi: mt76: mt7996: add wed tx support")
63+
Tested-by: Daniel Pawlik <[email protected]>
64+
Tested-by: Matteo Croce <[email protected]>
65+
Signed-off-by: Lorenzo Bianconi <[email protected]>
66+
Link: https://patch.msgid.link/[email protected]
67+
Signed-off-by: Felix Fietkau <[email protected]>
68+
---
69+
70+
--- a/include/linux/soc/mediatek/mtk_wed.h
71+
+++ b/include/linux/soc/mediatek/mtk_wed.h
72+
@@ -154,6 +154,7 @@ struct mtk_wed_device {
73+
bool wcid_512;
74+
bool hw_rro;
75+
bool msi;
76+
+ bool hif2;
77+
78+
u16 token_start;
79+
unsigned int nbuf;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From: Rex Lu <[email protected]>
2+
Date: Thu, 9 Oct 2025 08:29:34 +0200
3+
Subject: [PATCH] net: mtk: wed: add dma mask limitation and GFP_DMA32 for
4+
device with more than 4GB DRAM
5+
6+
Limit tx/rx buffer address to 32-bit address space for board with more
7+
than 4GB DRAM.
8+
9+
Fixes: 804775dfc2885 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)")
10+
Fixes: 6757d345dd7db ("net: ethernet: mtk_wed: introduce hw_rro support for MT7988")
11+
Tested-by: Daniel Pawlik <[email protected]>
12+
Tested-by: Matteo Croce <[email protected]>
13+
Signed-off-by: Rex Lu <[email protected]>
14+
Co-developed-by: Lorenzo Bianconi <[email protected]>
15+
Signed-off-by: Lorenzo Bianconi <[email protected]>
16+
Reviewed-by: Simon Horman <[email protected]>
17+
Signed-off-by: David S. Miller <[email protected]>
18+
---
19+
20+
--- a/drivers/net/ethernet/mediatek/mtk_wed.c
21+
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c
22+
@@ -677,7 +677,7 @@ mtk_wed_tx_buffer_alloc(struct mtk_wed_d
23+
void *buf;
24+
int s;
25+
26+
- page = __dev_alloc_page(GFP_KERNEL);
27+
+ page = __dev_alloc_page(GFP_KERNEL | GFP_DMA32);
28+
if (!page)
29+
return -ENOMEM;
30+
31+
@@ -800,7 +800,7 @@ mtk_wed_hwrro_buffer_alloc(struct mtk_we
32+
struct page *page;
33+
int s;
34+
35+
- page = __dev_alloc_page(GFP_KERNEL);
36+
+ page = __dev_alloc_page(GFP_KERNEL | GFP_DMA32);
37+
if (!page)
38+
return -ENOMEM;
39+
40+
@@ -2438,6 +2438,10 @@ mtk_wed_attach(struct mtk_wed_device *de
41+
dev->version = hw->version;
42+
dev->hw->pcie_base = mtk_wed_get_pcie_base(dev);
43+
44+
+ ret = dma_set_mask_and_coherent(hw->dev, DMA_BIT_MASK(32));
45+
+ if (ret)
46+
+ goto out;
47+
+
48+
if (hw->eth->dma_dev == hw->eth->dev &&
49+
of_dma_is_coherent(hw->eth->dev->of_node))
50+
mtk_eth_set_dma_device(hw->eth, hw->dev);

0 commit comments

Comments
 (0)