Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: airoha: deinit PPE on offload setup failures
@ 2026-11-30  7:44 Zhiqi Zhang
  2026-11-30  8:20 ` Lorenzo Bianconi
  0 siblings, 1 reply; 2+ messages in thread
From: Zhiqi Zhang @ 2026-11-30  7:44 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev,
	Zhiqi Zhang

airoha_ppe_offload_setup() calls the NPU PPE init callback before
waiting for the firmware-side configuration and before initializing flow
stats.

When either later step fails, the error path only drops the NPU
reference. That leaves the PPE side initialized even though setup did
not complete, while the normal teardown path calls ppe_deinit().

Run the PPE deinit callback before dropping the NPU reference on those
failures, matching the successful setup teardown sequence.

Fixes: 105ce7ad57e4 ("net: airoha: npu: Add a NPU callback to initialize flow stats")
Fixes: f3206328bb52 ("net: airoha: Wait for NPU PPE configuration to complete in airoha_ppe_offload_setup()")
Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>
---
AI assistance disclosure: I found the bug. Codex modified the code.
I reviewed the change.

Build-tested with ARCH=arm64 allmodconfig object builds.
I did not test on hardware.

 drivers/net/ethernet/airoha/airoha_ppe.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c
index f5369c4576..35754f8d2d 100644
--- a/drivers/net/ethernet/airoha/airoha_ppe.c
+++ b/drivers/net/ethernet/airoha/airoha_ppe.c
@@ -1450,14 +1450,14 @@ static int airoha_ppe_offload_setup(struct airoha_eth *eth)
 	/* Wait for NPU PPE configuration to complete */
 	err = airoha_ppe_wait_for_npu_init(eth);
 	if (err)
-		goto error_npu_put;
+		goto error_ppe_deinit;
 
 	ppe_num_stats_entries = airoha_ppe_get_total_num_stats_entries(ppe);
 	if (ppe_num_stats_entries > 0) {
 		err = npu->ops.ppe_init_stats(npu, ppe->foe_stats_dma,
 					      ppe_num_stats_entries);
 		if (err)
-			goto error_npu_put;
+			goto error_ppe_deinit;
 	}
 
 	airoha_ppe_hw_init(ppe);
@@ -1468,6 +1468,8 @@ static int airoha_ppe_offload_setup(struct airoha_eth *eth)
 
 	return 0;
 
+error_ppe_deinit:
+	npu->ops.ppe_deinit(npu);
 error_npu_put:
 	airoha_npu_put(npu);
 

base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
prerequisite-patch-id: e29c14650c775fee7e7fa5755614582933aa0b48
-- 
2.54.0 (Apple Git-157)



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: airoha: deinit PPE on offload setup failures
  2026-11-30  7:44 [PATCH net] net: airoha: deinit PPE on offload setup failures Zhiqi Zhang
@ 2026-11-30  8:20 ` Lorenzo Bianconi
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Bianconi @ 2026-11-30  8:20 UTC (permalink / raw)
  To: Zhiqi Zhang
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, linux-arm-kernel, linux-mediatek, netdev

[-- Attachment #1: Type: text/plain, Size: 2342 bytes --]

> airoha_ppe_offload_setup() calls the NPU PPE init callback before
> waiting for the firmware-side configuration and before initializing flow
> stats.
> 
> When either later step fails, the error path only drops the NPU
> reference. That leaves the PPE side initialized even though setup did
> not complete, while the normal teardown path calls ppe_deinit().
> 
> Run the PPE deinit callback before dropping the NPU reference on those
> failures, matching the successful setup teardown sequence.
> 
> Fixes: 105ce7ad57e4 ("net: airoha: npu: Add a NPU callback to initialize flow stats")
> Fixes: f3206328bb52 ("net: airoha: Wait for NPU PPE configuration to complete in airoha_ppe_offload_setup()")
> Signed-off-by: Zhiqi Zhang <zhiqizhangg@gmail.com>

Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
> AI assistance disclosure: I found the bug. Codex modified the code.
> I reviewed the change.
> 
> Build-tested with ARCH=arm64 allmodconfig object builds.
> I did not test on hardware.
> 
>  drivers/net/ethernet/airoha/airoha_ppe.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c
> index f5369c4576..35754f8d2d 100644
> --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> @@ -1450,14 +1450,14 @@ static int airoha_ppe_offload_setup(struct airoha_eth *eth)
>  	/* Wait for NPU PPE configuration to complete */
>  	err = airoha_ppe_wait_for_npu_init(eth);
>  	if (err)
> -		goto error_npu_put;
> +		goto error_ppe_deinit;
>  
>  	ppe_num_stats_entries = airoha_ppe_get_total_num_stats_entries(ppe);
>  	if (ppe_num_stats_entries > 0) {
>  		err = npu->ops.ppe_init_stats(npu, ppe->foe_stats_dma,
>  					      ppe_num_stats_entries);
>  		if (err)
> -			goto error_npu_put;
> +			goto error_ppe_deinit;
>  	}
>  
>  	airoha_ppe_hw_init(ppe);
> @@ -1468,6 +1468,8 @@ static int airoha_ppe_offload_setup(struct airoha_eth *eth)
>  
>  	return 0;
>  
> +error_ppe_deinit:
> +	npu->ops.ppe_deinit(npu);
>  error_npu_put:
>  	airoha_npu_put(npu);
>  
> 
> base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
> prerequisite-patch-id: e29c14650c775fee7e7fa5755614582933aa0b48
> -- 
> 2.54.0 (Apple Git-157)
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  7:44 [PATCH net] net: airoha: deinit PPE on offload setup failures Zhiqi Zhang
2026-11-30  8:20 ` Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox