Skip to content

Commit 0c7469e

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: airoha: Fix error path in airoha_probe()
Do not run napi_disable() if airoha_hw_init() fails since Tx/Rx napi has not been started yet. In order to fix the issue, introduce airoha_qdma_stop_napi routine and remove napi_disable in airoha_hw_cleanup(). Fixes: 23020f0 ("net: airoha: Introduce ethernet support for EN7581 SoC") Reviewed-by: Michal Swiatkowski <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Link: https://patch.msgid.link/20241216-airoha_probe-error-path-fix-v2-1-6b10e04e9a5c@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5fde7ed commit 0c7469e

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

drivers/net/ethernet/mediatek/airoha_eth.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,17 +2138,14 @@ static void airoha_hw_cleanup(struct airoha_qdma *qdma)
21382138
if (!qdma->q_rx[i].ndesc)
21392139
continue;
21402140

2141-
napi_disable(&qdma->q_rx[i].napi);
21422141
netif_napi_del(&qdma->q_rx[i].napi);
21432142
airoha_qdma_cleanup_rx_queue(&qdma->q_rx[i]);
21442143
if (qdma->q_rx[i].page_pool)
21452144
page_pool_destroy(qdma->q_rx[i].page_pool);
21462145
}
21472146

2148-
for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++) {
2149-
napi_disable(&qdma->q_tx_irq[i].napi);
2147+
for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
21502148
netif_napi_del(&qdma->q_tx_irq[i].napi);
2151-
}
21522149

21532150
for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
21542151
if (!qdma->q_tx[i].ndesc)
@@ -2173,6 +2170,21 @@ static void airoha_qdma_start_napi(struct airoha_qdma *qdma)
21732170
}
21742171
}
21752172

2173+
static void airoha_qdma_stop_napi(struct airoha_qdma *qdma)
2174+
{
2175+
int i;
2176+
2177+
for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
2178+
napi_disable(&qdma->q_tx_irq[i].napi);
2179+
2180+
for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
2181+
if (!qdma->q_rx[i].ndesc)
2182+
continue;
2183+
2184+
napi_disable(&qdma->q_rx[i].napi);
2185+
}
2186+
}
2187+
21762188
static void airoha_update_hw_stats(struct airoha_gdm_port *port)
21772189
{
21782190
struct airoha_eth *eth = port->qdma->eth;
@@ -2738,7 +2750,7 @@ static int airoha_probe(struct platform_device *pdev)
27382750

27392751
err = airoha_hw_init(pdev, eth);
27402752
if (err)
2741-
goto error;
2753+
goto error_hw_cleanup;
27422754

27432755
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
27442756
airoha_qdma_start_napi(&eth->qdma[i]);
@@ -2753,13 +2765,16 @@ static int airoha_probe(struct platform_device *pdev)
27532765
err = airoha_alloc_gdm_port(eth, np);
27542766
if (err) {
27552767
of_node_put(np);
2756-
goto error;
2768+
goto error_napi_stop;
27572769
}
27582770
}
27592771

27602772
return 0;
27612773

2762-
error:
2774+
error_napi_stop:
2775+
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
2776+
airoha_qdma_stop_napi(&eth->qdma[i]);
2777+
error_hw_cleanup:
27632778
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
27642779
airoha_hw_cleanup(&eth->qdma[i]);
27652780

@@ -2780,8 +2795,10 @@ static void airoha_remove(struct platform_device *pdev)
27802795
struct airoha_eth *eth = platform_get_drvdata(pdev);
27812796
int i;
27822797

2783-
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
2798+
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) {
2799+
airoha_qdma_stop_napi(&eth->qdma[i]);
27842800
airoha_hw_cleanup(&eth->qdma[i]);
2801+
}
27852802

27862803
for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
27872804
struct airoha_gdm_port *port = eth->ports[i];

0 commit comments

Comments
 (0)