Skip to content

Commit 2f52b8f

Browse files
committed
airoha: backport minor fixup for Ethernet driver on Offload Scenario
Backport minor fixup merged upstream for Ethernet driver on Offload Scenario. This is to continue the effort of keeping the Airoha Ethernet driver synced with the upstream version. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1 parent cd0f6dd commit 2f52b8f

7 files changed

Lines changed: 143 additions & 23 deletions
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
From cedc1bf327de62ec30af9743bd1f601c2de30553 Mon Sep 17 00:00:00 2001
2+
From: Lorenzo Bianconi <lorenzo@kernel.org>
3+
Date: Sun, 29 Mar 2026 12:32:27 +0200
4+
Subject: [PATCH] net: airoha: Delay offloading until all net_devices are fully
5+
registered
6+
7+
Netfilter flowtable can theoretically try to offload flower rules as soon
8+
as a net_device is registered while all the other ones are not
9+
registered or initialized, triggering a possible NULL pointer dereferencing
10+
of qdma pointer in airoha_ppe_set_cpu_port routine. Moreover, if
11+
register_netdev() fails for a particular net_device, there is a small
12+
race if Netfilter tries to offload flowtable rules before all the
13+
net_devices are properly unregistered in airoha_probe() error patch,
14+
triggering a NULL pointer dereferencing in airoha_ppe_set_cpu_port
15+
routine. In order to avoid any possible race, delay offloading until
16+
all net_devices are registered in the networking subsystem.
17+
18+
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
19+
Link: https://patch.msgid.link/20260329-airoha-regiser-race-fix-v2-1-f4ebb139277b@kernel.org
20+
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
21+
---
22+
drivers/net/ethernet/airoha/airoha_eth.c | 2 ++
23+
drivers/net/ethernet/airoha/airoha_eth.h | 1 +
24+
drivers/net/ethernet/airoha/airoha_ppe.c | 7 +++++++
25+
3 files changed, 10 insertions(+)
26+
27+
--- a/drivers/net/ethernet/airoha/airoha_eth.c
28+
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
29+
@@ -2957,6 +2957,8 @@ static int airoha_register_gdm_devices(s
30+
return err;
31+
}
32+
33+
+ set_bit(DEV_STATE_REGISTERED, &eth->state);
34+
+
35+
return 0;
36+
}
37+
38+
--- a/drivers/net/ethernet/airoha/airoha_eth.h
39+
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
40+
@@ -88,6 +88,7 @@ enum {
41+
42+
enum {
43+
DEV_STATE_INITIALIZED,
44+
+ DEV_STATE_REGISTERED,
45+
};
46+
47+
enum {
48+
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
49+
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
50+
@@ -1387,6 +1387,13 @@ int airoha_ppe_setup_tc_block_cb(struct
51+
struct airoha_eth *eth = ppe->eth;
52+
int err = 0;
53+
54+
+ /* Netfilter flowtable can try to offload flower rules while not all
55+
+ * the net_devices are registered or initialized. Delay offloading
56+
+ * until all net_devices are registered in the system.
57+
+ */
58+
+ if (!test_bit(DEV_STATE_REGISTERED, &eth->state))
59+
+ return -EBUSY;
60+
+
61+
mutex_lock(&flow_offload_mutex);
62+
63+
if (!eth->npu)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From 514aac3599879a7ed48b7dc19e31145beb6958ac Mon Sep 17 00:00:00 2001
2+
From: Lorenzo Bianconi <lorenzo@kernel.org>
3+
Date: Fri, 27 Mar 2026 10:48:21 +0100
4+
Subject: [PATCH] net: airoha: Add missing cleanup bits in
5+
airoha_qdma_cleanup_rx_queue()
6+
7+
In order to properly cleanup hw rx QDMA queues and bring the device to
8+
the initial state, reset rx DMA queue head/tail index. Moreover, reset
9+
queued DMA descriptor fields.
10+
11+
Fixes: 23020f049327 ("net: airoha: Introduce ethernet support for EN7581 SoC")
12+
Tested-by: Madhur Agrawal <Madhur.Agrawal@airoha.com>
13+
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
14+
Link: https://patch.msgid.link/20260327-airoha_qdma_cleanup_rx_queue-fix-v1-1-369d6ab1511a@kernel.org
15+
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
16+
---
17+
drivers/net/ethernet/airoha/airoha_eth.c | 18 +++++++++++++++++-
18+
1 file changed, 17 insertions(+), 1 deletion(-)
19+
20+
--- a/drivers/net/ethernet/airoha/airoha_eth.c
21+
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
22+
@@ -794,18 +794,34 @@ static int airoha_qdma_init_rx_queue(str
23+
24+
static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q)
25+
{
26+
- struct airoha_eth *eth = q->qdma->eth;
27+
+ struct airoha_qdma *qdma = q->qdma;
28+
+ struct airoha_eth *eth = qdma->eth;
29+
+ int qid = q - &qdma->q_rx[0];
30+
31+
while (q->queued) {
32+
struct airoha_queue_entry *e = &q->entry[q->tail];
33+
+ struct airoha_qdma_desc *desc = &q->desc[q->tail];
34+
struct page *page = virt_to_head_page(e->buf);
35+
36+
dma_sync_single_for_cpu(eth->dev, e->dma_addr, e->dma_len,
37+
page_pool_get_dma_dir(q->page_pool));
38+
page_pool_put_full_page(q->page_pool, page, false);
39+
+ /* Reset DMA descriptor */
40+
+ WRITE_ONCE(desc->ctrl, 0);
41+
+ WRITE_ONCE(desc->addr, 0);
42+
+ WRITE_ONCE(desc->data, 0);
43+
+ WRITE_ONCE(desc->msg0, 0);
44+
+ WRITE_ONCE(desc->msg1, 0);
45+
+ WRITE_ONCE(desc->msg2, 0);
46+
+ WRITE_ONCE(desc->msg3, 0);
47+
+
48+
q->tail = (q->tail + 1) % q->ndesc;
49+
q->queued--;
50+
}
51+
+
52+
+ q->head = q->tail;
53+
+ airoha_qdma_rmw(qdma, REG_RX_DMA_IDX(qid), RX_RING_DMA_IDX_MASK,
54+
+ FIELD_PREP(RX_RING_DMA_IDX_MASK, q->tail));
55+
}
56+
57+
static int airoha_qdma_init_rx(struct airoha_qdma *qdma)

target/linux/airoha/patches-6.12/310-02-net-airoha-deassert-XSI-line-on-hw-init.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1313

1414
--- a/drivers/net/ethernet/airoha/airoha_eth.c
1515
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
16-
@@ -1409,6 +1409,10 @@ static int airoha_hw_init(struct platfor
16+
@@ -1425,6 +1425,10 @@ static int airoha_hw_init(struct platfor
1717
if (err)
1818
return err;
1919

target/linux/airoha/patches-6.12/310-06-net-airoha-add-initial-fixup-for-GDM3-4-port-support.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2828

2929
airoha_fe_crsn_qsel_init(eth);
3030

31-
@@ -1641,7 +1643,8 @@ static int airoha_dev_open(struct net_de
31+
@@ -1657,7 +1659,8 @@ static int airoha_dev_open(struct net_de
3232
if (err)
3333
return err;
3434

target/linux/airoha/patches-6.12/310-07-airoha-ethernet-drop-xsi-mac-reset.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1515

1616
--- a/drivers/net/ethernet/airoha/airoha_eth.c
1717
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
18-
@@ -3109,7 +3109,6 @@ static void airoha_remove(struct platfor
18+
@@ -3127,7 +3127,6 @@ static void airoha_remove(struct platfor
1919
}
2020

2121
static const char * const en7581_xsi_rsts_names[] = {
2222
- "xsi-mac",
2323
"hsi0-mac",
2424
"hsi1-mac",
2525
"hsi-mac",
26-
@@ -3141,7 +3140,6 @@ static int airoha_en7581_get_src_port_id
26+
@@ -3159,7 +3158,6 @@ static int airoha_en7581_get_src_port_id
2727
}
2828

2929
static const char * const an7583_xsi_rsts_names[] = {

target/linux/airoha/patches-6.12/310-10-net-airoha-add-phylink-support-for-GDM2-4.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
3535
static void airoha_set_macaddr(struct airoha_gdm_port *port, const u8 *addr)
3636
{
3737
struct airoha_eth *eth = port->qdma->eth;
38-
@@ -1638,6 +1644,17 @@ static int airoha_dev_open(struct net_de
38+
@@ -1654,6 +1660,17 @@ static int airoha_dev_open(struct net_de
3939
struct airoha_qdma *qdma = port->qdma;
4040
u32 pse_port = FE_PSE_PORT_PPE1;
4141

@@ -53,7 +53,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
5353
netif_tx_start_all_queues(dev);
5454
err = airoha_set_vip_for_gdm_port(port, true);
5555
if (err)
56-
@@ -1702,6 +1719,11 @@ static int airoha_dev_stop(struct net_de
56+
@@ -1718,6 +1735,11 @@ static int airoha_dev_stop(struct net_de
5757
}
5858
}
5959

@@ -65,7 +65,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
6565
return 0;
6666
}
6767

68-
@@ -2833,6 +2855,20 @@ static const struct ethtool_ops airoha_e
68+
@@ -2849,6 +2871,20 @@ static const struct ethtool_ops airoha_e
6969
.get_link = ethtool_op_get_link,
7070
};
7171

@@ -86,7 +86,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
8686
static int airoha_metadata_dst_alloc(struct airoha_gdm_port *port)
8787
{
8888
int i;
89-
@@ -2877,6 +2913,99 @@ bool airoha_is_valid_gdm_port(struct air
89+
@@ -2893,6 +2929,99 @@ bool airoha_is_valid_gdm_port(struct air
9090
return false;
9191
}
9292

@@ -186,7 +186,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
186186
static int airoha_alloc_gdm_port(struct airoha_eth *eth,
187187
struct device_node *np)
188188
{
189-
@@ -2948,6 +3077,12 @@ static int airoha_alloc_gdm_port(struct
189+
@@ -2964,6 +3093,12 @@ static int airoha_alloc_gdm_port(struct
190190
port->id = id;
191191
eth->ports[p] = port;
192192

@@ -199,7 +199,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
199199
return airoha_metadata_dst_alloc(port);
200200
}
201201

202-
@@ -3075,6 +3210,10 @@ error_napi_stop:
202+
@@ -3093,6 +3228,10 @@ error_napi_stop:
203203

204204
if (port->dev->reg_state == NETREG_REGISTERED)
205205
unregister_netdev(port->dev);
@@ -210,7 +210,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
210210
airoha_metadata_dst_free(port);
211211
}
212212
airoha_hw_cleanup(eth);
213-
@@ -3101,6 +3240,10 @@ static void airoha_remove(struct platfor
213+
@@ -3119,6 +3258,10 @@ static void airoha_remove(struct platfor
214214

215215
unregister_netdev(port->dev);
216216
airoha_metadata_dst_free(port);
@@ -223,7 +223,7 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
223223

224224
--- a/drivers/net/ethernet/airoha/airoha_eth.h
225225
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
226-
@@ -537,6 +537,10 @@ struct airoha_gdm_port {
226+
@@ -538,6 +538,10 @@ struct airoha_gdm_port {
227227
struct net_device *dev;
228228
int id;
229229

target/linux/airoha/patches-6.12/606-net-airoha-disable-external-phy-code-if-PCS_AIROHA-i.patch

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
2828

2929
static void airoha_set_macaddr(struct airoha_gdm_port *port, const u8 *addr)
3030
{
31-
@@ -1647,6 +1649,7 @@ static int airoha_dev_open(struct net_de
31+
@@ -1663,6 +1665,7 @@ static int airoha_dev_open(struct net_de
3232
struct airoha_qdma *qdma = port->qdma;
3333
u32 pse_port = FE_PSE_PORT_PPE1;
3434

3535
+#if defined(CONFIG_PCS_AIROHA)
3636
if (airhoa_is_phy_external(port)) {
3737
err = phylink_of_phy_connect(port->phylink, dev->dev.of_node, 0);
3838
if (err) {
39-
@@ -1657,6 +1660,7 @@ static int airoha_dev_open(struct net_de
39+
@@ -1673,6 +1676,7 @@ static int airoha_dev_open(struct net_de
4040

4141
phylink_start(port->phylink);
4242
}
4343
+#endif
4444

4545
netif_tx_start_all_queues(dev);
4646
err = airoha_set_vip_for_gdm_port(port, true);
47-
@@ -1722,10 +1726,12 @@ static int airoha_dev_stop(struct net_de
47+
@@ -1738,10 +1742,12 @@ static int airoha_dev_stop(struct net_de
4848
}
4949
}
5050

@@ -57,39 +57,39 @@ Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
5757

5858
return 0;
5959
}
60-
@@ -2858,6 +2864,7 @@ static const struct ethtool_ops airoha_e
60+
@@ -2874,6 +2880,7 @@ static const struct ethtool_ops airoha_e
6161
.get_link = ethtool_op_get_link,
6262
};
6363

6464
+#if defined(CONFIG_PCS_AIROHA)
6565
static struct phylink_pcs *airoha_phylink_mac_select_pcs(struct phylink_config *config,
6666
phy_interface_t interface)
6767
{
68-
@@ -2871,6 +2878,7 @@ static void airoha_mac_config(struct phy
68+
@@ -2887,6 +2894,7 @@ static void airoha_mac_config(struct phy
6969
const struct phylink_link_state *state)
7070
{
7171
}
7272
+#endif
7373

7474
static int airoha_metadata_dst_alloc(struct airoha_gdm_port *port)
7575
{
76-
@@ -2916,6 +2924,7 @@ bool airoha_is_valid_gdm_port(struct air
76+
@@ -2932,6 +2940,7 @@ bool airoha_is_valid_gdm_port(struct air
7777
return false;
7878
}
7979

8080
+#if defined(CONFIG_PCS_AIROHA)
8181
static void airoha_mac_link_up(struct phylink_config *config, struct phy_device *phy,
8282
unsigned int mode, phy_interface_t interface,
8383
int speed, int duplex, bool tx_pause, bool rx_pause)
84-
@@ -3008,6 +3017,7 @@ static int airoha_setup_phylink(struct n
84+
@@ -3024,6 +3033,7 @@ static int airoha_setup_phylink(struct n
8585

8686
return 0;
8787
}
8888
+#endif
8989

9090
static int airoha_alloc_gdm_port(struct airoha_eth *eth,
9191
struct device_node *np)
92-
@@ -3080,11 +3090,13 @@ static int airoha_alloc_gdm_port(struct
92+
@@ -3096,11 +3106,13 @@ static int airoha_alloc_gdm_port(struct
9393
port->id = id;
9494
eth->ports[p] = port;
9595

@@ -103,7 +103,7 @@ Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
103103

104104
return airoha_metadata_dst_alloc(port);
105105
}
106-
@@ -3213,10 +3225,12 @@ error_napi_stop:
106+
@@ -3231,10 +3243,12 @@ error_napi_stop:
107107

108108
if (port->dev->reg_state == NETREG_REGISTERED)
109109
unregister_netdev(port->dev);
@@ -116,7 +116,7 @@ Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
116116
airoha_metadata_dst_free(port);
117117
}
118118
airoha_hw_cleanup(eth);
119-
@@ -3243,10 +3257,12 @@ static void airoha_remove(struct platfor
119+
@@ -3261,10 +3275,12 @@ static void airoha_remove(struct platfor
120120

121121
unregister_netdev(port->dev);
122122
airoha_metadata_dst_free(port);
@@ -131,7 +131,7 @@ Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
131131

132132
--- a/drivers/net/ethernet/airoha/airoha_eth.h
133133
+++ b/drivers/net/ethernet/airoha/airoha_eth.h
134-
@@ -537,9 +537,11 @@ struct airoha_gdm_port {
134+
@@ -538,9 +538,11 @@ struct airoha_gdm_port {
135135
struct net_device *dev;
136136
int id;
137137

0 commit comments

Comments
 (0)