Skip to content

Commit e32b79e

Browse files
committed
ice: fix Tx scheduler error handling in XDP callback
JIRA: https://issues.redhat.com/browse/RHEL-83543 Upstream commit(s): commit 0153f36 Author: Michal Kubiak <[email protected]> Date: Tue May 13 12:55:27 2025 +0200 ice: fix Tx scheduler error handling in XDP callback When the XDP program is loaded, the XDP callback adds new Tx queues. This means that the callback must update the Tx scheduler with the new queue number. In the event of a Tx scheduler failure, the XDP callback should also fail and roll back any changes previously made for XDP preparation. The previous implementation had a bug that not all changes made by the XDP callback were rolled back. This caused the crash with the following call trace: [ +9.549584] ice 0000:ca:00.0: Failed VSI LAN queue config for XDP, error: -5 [ +0.382335] Oops: general protection fault, probably for non-canonical address 0x50a2250a90495525: 0000 [#1] SMP NOPTI [ +0.010710] CPU: 103 UID: 0 PID: 0 Comm: swapper/103 Not tainted 6.14.0-net-next-mar-31+ #14 PREEMPT(voluntary) [ +0.010175] Hardware name: Intel Corporation M50CYP2SBSTD/M50CYP2SBSTD, BIOS SE5C620.86B.01.01.0005.2202160810 02/16/2022 [ +0.010946] RIP: 0010:__ice_update_sample+0x39/0xe0 [ice] [...] [ +0.002715] Call Trace: [ +0.002452] <IRQ> [ +0.002021] ? __die_body.cold+0x19/0x29 [ +0.003922] ? die_addr+0x3c/0x60 [ +0.003319] ? exc_general_protection+0x17c/0x400 [ +0.004707] ? asm_exc_general_protection+0x26/0x30 [ +0.004879] ? __ice_update_sample+0x39/0xe0 [ice] [ +0.004835] ice_napi_poll+0x665/0x680 [ice] [ +0.004320] __napi_poll+0x28/0x190 [ +0.003500] net_rx_action+0x198/0x360 [ +0.003752] ? update_rq_clock+0x39/0x220 [ +0.004013] handle_softirqs+0xf1/0x340 [ +0.003840] ? sched_clock_cpu+0xf/0x1f0 [ +0.003925] __irq_exit_rcu+0xc2/0xe0 [ +0.003665] common_interrupt+0x85/0xa0 [ +0.003839] </IRQ> [ +0.002098] <TASK> [ +0.002106] asm_common_interrupt+0x26/0x40 [ +0.004184] RIP: 0010:cpuidle_enter_state+0xd3/0x690 Fix this by performing the missing unmapping of XDP queues from q_vectors and setting the XDP rings pointer back to NULL after all those queues are released. Also, add an immediate exit from the XDP callback in case of ring preparation failure. Fixes: efc2214 ("ice: Add support for XDP") Reviewed-by: Dawid Osuchowski <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Signed-off-by: Michal Kubiak <[email protected]> Reviewed-by: Aleksandr Loktionov <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Jesse Brandeburg <[email protected]> Tested-by: Saritha Sanigani <[email protected]> (A Contingent Worker at Intel) Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: Petr Oros <[email protected]>
1 parent c52eed4 commit e32b79e

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,6 +2798,27 @@ void ice_map_xdp_rings(struct ice_vsi *vsi)
27982798
}
27992799
}
28002800

2801+
/**
2802+
* ice_unmap_xdp_rings - Unmap XDP rings from interrupt vectors
2803+
* @vsi: the VSI with XDP rings being unmapped
2804+
*/
2805+
static void ice_unmap_xdp_rings(struct ice_vsi *vsi)
2806+
{
2807+
int v_idx;
2808+
2809+
ice_for_each_q_vector(vsi, v_idx) {
2810+
struct ice_q_vector *q_vector = vsi->q_vectors[v_idx];
2811+
struct ice_tx_ring *ring;
2812+
2813+
ice_for_each_tx_ring(ring, q_vector->tx)
2814+
if (!ring->tx_buf || !ice_ring_is_xdp(ring))
2815+
break;
2816+
2817+
/* restore the value of last node prior to XDP setup */
2818+
q_vector->tx.tx_ring = ring;
2819+
}
2820+
}
2821+
28012822
/**
28022823
* ice_prepare_xdp_rings - Allocate, configure and setup Tx rings for XDP
28032824
* @vsi: VSI to bring up Tx rings used by XDP
@@ -2861,7 +2882,7 @@ int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog,
28612882
if (status) {
28622883
dev_err(dev, "Failed VSI LAN queue config for XDP, error: %d\n",
28632884
status);
2864-
goto clear_xdp_rings;
2885+
goto unmap_xdp_rings;
28652886
}
28662887

28672888
/* assign the prog only when it's not already present on VSI;
@@ -2877,6 +2898,8 @@ int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog,
28772898
ice_vsi_assign_bpf_prog(vsi, prog);
28782899

28792900
return 0;
2901+
unmap_xdp_rings:
2902+
ice_unmap_xdp_rings(vsi);
28802903
clear_xdp_rings:
28812904
ice_for_each_xdp_txq(vsi, i)
28822905
if (vsi->xdp_rings[i]) {
@@ -2893,6 +2916,8 @@ int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog,
28932916
mutex_unlock(&pf->avail_q_mutex);
28942917

28952918
devm_kfree(dev, vsi->xdp_rings);
2919+
vsi->xdp_rings = NULL;
2920+
28962921
return -ENOMEM;
28972922
}
28982923

@@ -2908,25 +2933,15 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi, enum ice_xdp_cfg cfg_type)
29082933
{
29092934
u16 max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 };
29102935
struct ice_pf *pf = vsi->back;
2911-
int i, v_idx;
2936+
int i;
29122937

29132938
/* q_vectors are freed in reset path so there's no point in detaching
29142939
* rings
29152940
*/
29162941
if (cfg_type == ICE_XDP_CFG_PART)
29172942
goto free_qmap;
29182943

2919-
ice_for_each_q_vector(vsi, v_idx) {
2920-
struct ice_q_vector *q_vector = vsi->q_vectors[v_idx];
2921-
struct ice_tx_ring *ring;
2922-
2923-
ice_for_each_tx_ring(ring, q_vector->tx)
2924-
if (!ring->tx_buf || !ice_ring_is_xdp(ring))
2925-
break;
2926-
2927-
/* restore the value of last node prior to XDP setup */
2928-
q_vector->tx.tx_ring = ring;
2929-
}
2944+
ice_unmap_xdp_rings(vsi);
29302945

29312946
free_qmap:
29322947
mutex_lock(&pf->avail_q_mutex);
@@ -3071,11 +3086,14 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
30713086
xdp_ring_err = ice_vsi_determine_xdp_res(vsi);
30723087
if (xdp_ring_err) {
30733088
NL_SET_ERR_MSG_MOD(extack, "Not enough Tx resources for XDP");
3089+
goto resume_if;
30743090
} else {
30753091
xdp_ring_err = ice_prepare_xdp_rings(vsi, prog,
30763092
ICE_XDP_CFG_FULL);
3077-
if (xdp_ring_err)
3093+
if (xdp_ring_err) {
30783094
NL_SET_ERR_MSG_MOD(extack, "Setting up XDP Tx resources failed");
3095+
goto resume_if;
3096+
}
30793097
}
30803098
xdp_features_set_redirect_target(vsi->netdev, true);
30813099
/* reallocate Rx queues that are used for zero-copy */
@@ -3093,6 +3111,7 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
30933111
NL_SET_ERR_MSG_MOD(extack, "Freeing XDP Rx resources failed");
30943112
}
30953113

3114+
resume_if:
30963115
if (if_running)
30973116
ret = ice_up(vsi);
30983117

0 commit comments

Comments
 (0)