* [PATCH net-next] net: airoha: Fix error patch in airoha_probe()
@ 2024-12-15 17:36 Lorenzo Bianconi
2024-12-16 7:15 ` Michal Swiatkowski
0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Bianconi @ 2024-12-15 17:36 UTC (permalink / raw)
To: Felix Fietkau, Sean Wang, Mark Lee, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: linux-arm-kernel, linux-mediatek, netdev, Lorenzo Bianconi
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_disable_napi routine and remove napi_disable in
airoha_hw_cleanup().
Fixes: 23020f049327 ("net: airoha: Introduce ethernet support for EN7581 SoC")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/ethernet/mediatek/airoha_eth.c | 33 ++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/airoha_eth.c b/drivers/net/ethernet/mediatek/airoha_eth.c
index 6c683a12d5aa52dd9d966df123509075a989c0b3..5bbf5fee2802135ff6083233d0bda78f2ba5606a 100644
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
@@ -2138,17 +2138,14 @@ static void airoha_hw_cleanup(struct airoha_qdma *qdma)
if (!qdma->q_rx[i].ndesc)
continue;
- napi_disable(&qdma->q_rx[i].napi);
netif_napi_del(&qdma->q_rx[i].napi);
airoha_qdma_cleanup_rx_queue(&qdma->q_rx[i]);
if (qdma->q_rx[i].page_pool)
page_pool_destroy(qdma->q_rx[i].page_pool);
}
- for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++) {
- napi_disable(&qdma->q_tx_irq[i].napi);
+ for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
netif_napi_del(&qdma->q_tx_irq[i].napi);
- }
for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
if (!qdma->q_tx[i].ndesc)
@@ -2173,6 +2170,21 @@ static void airoha_qdma_start_napi(struct airoha_qdma *qdma)
}
}
+static void airoha_qdma_disable_napi(struct airoha_qdma *qdma)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
+ napi_disable(&qdma->q_tx_irq[i].napi);
+
+ for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
+ if (!qdma->q_rx[i].ndesc)
+ continue;
+
+ napi_disable(&qdma->q_rx[i].napi);
+ }
+}
+
static void airoha_update_hw_stats(struct airoha_gdm_port *port)
{
struct airoha_eth *eth = port->qdma->eth;
@@ -2738,7 +2750,7 @@ static int airoha_probe(struct platform_device *pdev)
err = airoha_hw_init(pdev, eth);
if (err)
- goto error;
+ goto error_hw_cleanup;
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
airoha_qdma_start_napi(ð->qdma[i]);
@@ -2753,13 +2765,16 @@ static int airoha_probe(struct platform_device *pdev)
err = airoha_alloc_gdm_port(eth, np);
if (err) {
of_node_put(np);
- goto error;
+ goto error_napi_disable;
}
}
return 0;
-error:
+error_napi_disable:
+ for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
+ airoha_qdma_disable_napi(ð->qdma[i]);
+error_hw_cleanup:
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
airoha_hw_cleanup(ð->qdma[i]);
@@ -2780,8 +2795,10 @@ static void airoha_remove(struct platform_device *pdev)
struct airoha_eth *eth = platform_get_drvdata(pdev);
int i;
- for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
+ for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) {
+ airoha_qdma_disable_napi(ð->qdma[i]);
airoha_hw_cleanup(ð->qdma[i]);
+ }
for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
struct airoha_gdm_port *port = eth->ports[i];
---
base-commit: 2c2b61d2138f472e50b5531ec0cb4a1485837e21
change-id: 20241215-airoha_probe-error-path-fix-5bc6bed0e20e
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: airoha: Fix error patch in airoha_probe()
2024-12-15 17:36 [PATCH net-next] net: airoha: Fix error patch in airoha_probe() Lorenzo Bianconi
@ 2024-12-16 7:15 ` Michal Swiatkowski
2024-12-16 8:54 ` Lorenzo Bianconi
0 siblings, 1 reply; 3+ messages in thread
From: Michal Swiatkowski @ 2024-12-16 7:15 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Felix Fietkau, Sean Wang, Mark Lee, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger,
AngeloGioacchino Del Regno, linux-arm-kernel, linux-mediatek,
netdev
On Sun, Dec 15, 2024 at 06:36:35PM +0100, Lorenzo Bianconi wrote:
> 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_disable_napi routine and remove napi_disable in
> airoha_hw_cleanup().
>
> Fixes: 23020f049327 ("net: airoha: Introduce ethernet support for EN7581 SoC")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/ethernet/mediatek/airoha_eth.c | 33 ++++++++++++++++++++++--------
> 1 file changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/airoha_eth.c b/drivers/net/ethernet/mediatek/airoha_eth.c
> index 6c683a12d5aa52dd9d966df123509075a989c0b3..5bbf5fee2802135ff6083233d0bda78f2ba5606a 100644
> --- a/drivers/net/ethernet/mediatek/airoha_eth.c
> +++ b/drivers/net/ethernet/mediatek/airoha_eth.c
> @@ -2138,17 +2138,14 @@ static void airoha_hw_cleanup(struct airoha_qdma *qdma)
> if (!qdma->q_rx[i].ndesc)
> continue;
>
> - napi_disable(&qdma->q_rx[i].napi);
> netif_napi_del(&qdma->q_rx[i].napi);
> airoha_qdma_cleanup_rx_queue(&qdma->q_rx[i]);
> if (qdma->q_rx[i].page_pool)
> page_pool_destroy(qdma->q_rx[i].page_pool);
> }
>
> - for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++) {
> - napi_disable(&qdma->q_tx_irq[i].napi);
> + for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
> netif_napi_del(&qdma->q_tx_irq[i].napi);
> - }
>
> for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
> if (!qdma->q_tx[i].ndesc)
> @@ -2173,6 +2170,21 @@ static void airoha_qdma_start_napi(struct airoha_qdma *qdma)
> }
> }
>
> +static void airoha_qdma_disable_napi(struct airoha_qdma *qdma)
Nit: similar function for enabling napi is named airoha_qdma_start_napi()
maybe stop here or enable there to be consistent.
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Thanks
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
> + napi_disable(&qdma->q_tx_irq[i].napi);
> +
> + for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
> + if (!qdma->q_rx[i].ndesc)
> + continue;
> +
> + napi_disable(&qdma->q_rx[i].napi);
> + }
> +}
> +
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: airoha: Fix error patch in airoha_probe()
2024-12-16 7:15 ` Michal Swiatkowski
@ 2024-12-16 8:54 ` Lorenzo Bianconi
0 siblings, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2024-12-16 8:54 UTC (permalink / raw)
To: Michal Swiatkowski
Cc: Felix Fietkau, Sean Wang, Mark Lee, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger,
AngeloGioacchino Del Regno, linux-arm-kernel, linux-mediatek,
netdev
[-- Attachment #1: Type: text/plain, Size: 2416 bytes --]
> On Sun, Dec 15, 2024 at 06:36:35PM +0100, Lorenzo Bianconi wrote:
> > 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_disable_napi routine and remove napi_disable in
> > airoha_hw_cleanup().
> >
> > Fixes: 23020f049327 ("net: airoha: Introduce ethernet support for EN7581 SoC")
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > drivers/net/ethernet/mediatek/airoha_eth.c | 33 ++++++++++++++++++++++--------
> > 1 file changed, 25 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/mediatek/airoha_eth.c b/drivers/net/ethernet/mediatek/airoha_eth.c
> > index 6c683a12d5aa52dd9d966df123509075a989c0b3..5bbf5fee2802135ff6083233d0bda78f2ba5606a 100644
> > --- a/drivers/net/ethernet/mediatek/airoha_eth.c
> > +++ b/drivers/net/ethernet/mediatek/airoha_eth.c
> > @@ -2138,17 +2138,14 @@ static void airoha_hw_cleanup(struct airoha_qdma *qdma)
> > if (!qdma->q_rx[i].ndesc)
> > continue;
> >
> > - napi_disable(&qdma->q_rx[i].napi);
> > netif_napi_del(&qdma->q_rx[i].napi);
> > airoha_qdma_cleanup_rx_queue(&qdma->q_rx[i]);
> > if (qdma->q_rx[i].page_pool)
> > page_pool_destroy(qdma->q_rx[i].page_pool);
> > }
> >
> > - for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++) {
> > - napi_disable(&qdma->q_tx_irq[i].napi);
> > + for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
> > netif_napi_del(&qdma->q_tx_irq[i].napi);
> > - }
> >
> > for (i = 0; i < ARRAY_SIZE(qdma->q_tx); i++) {
> > if (!qdma->q_tx[i].ndesc)
> > @@ -2173,6 +2170,21 @@ static void airoha_qdma_start_napi(struct airoha_qdma *qdma)
> > }
> > }
> >
> > +static void airoha_qdma_disable_napi(struct airoha_qdma *qdma)
> Nit: similar function for enabling napi is named airoha_qdma_start_napi()
> maybe stop here or enable there to be consistent.
>
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
>
> Thanks
ack, I will fix it in v2.
Regards,
Lorenzo
>
> > +{
> > + int i;
> > +
> > + for (i = 0; i < ARRAY_SIZE(qdma->q_tx_irq); i++)
> > + napi_disable(&qdma->q_tx_irq[i].napi);
> > +
> > + for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
> > + if (!qdma->q_rx[i].ndesc)
> > + continue;
> > +
> > + napi_disable(&qdma->q_rx[i].napi);
> > + }
> > +}
> > +
>
> [...]
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-16 8:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-15 17:36 [PATCH net-next] net: airoha: Fix error patch in airoha_probe() Lorenzo Bianconi
2024-12-16 7:15 ` Michal Swiatkowski
2024-12-16 8:54 ` Lorenzo Bianconi
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).