Skip to content

Commit 080b0c8

Browse files
anambiarinanguy11
authored andcommitted
ice: Fix ASSERT_RTNL() warning during certain scenarios
Commit 91fdbce ("ice: Add support in the driver for associating queue with napi") invoked the netif_queue_set_napi() call. This kernel function requires to be called with rtnl_lock taken, otherwise ASSERT_RTNL() warning will be triggered. ice_vsi_rebuild() initiating this call is under rtnl_lock when the rebuild is in response to configuration changes from external interfaces (such as tc, ethtool etc. which holds the lock). But, the VSI rebuild generated from service tasks and resets (PFR/CORER/GLOBR) is not under rtnl lock protection. Handle these cases as well to hold lock before the kernel call (by setting the 'locked' boolean to false). netif_queue_set_napi() is also used to clear previously set napi in the q_vector unroll flow. Handle this for locked/lockless execution paths. Fixes: 91fdbce ("ice: Add support in the driver for associating queue with napi") Signed-off-by: Amritha Nambiar <[email protected]> Reviewed-by: Sridhar Samudrala <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent ee89921 commit 080b0c8

File tree

4 files changed

+83
-26
lines changed

4 files changed

+83
-26
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,13 @@ static void ice_free_q_vector(struct ice_vsi *vsi, int v_idx)
190190
q_vector = vsi->q_vectors[v_idx];
191191

192192
ice_for_each_tx_ring(tx_ring, q_vector->tx) {
193-
if (vsi->netdev)
194-
netif_queue_set_napi(vsi->netdev, tx_ring->q_index,
195-
NETDEV_QUEUE_TYPE_TX, NULL);
193+
ice_queue_set_napi(vsi, tx_ring->q_index, NETDEV_QUEUE_TYPE_TX,
194+
NULL);
196195
tx_ring->q_vector = NULL;
197196
}
198197
ice_for_each_rx_ring(rx_ring, q_vector->rx) {
199-
if (vsi->netdev)
200-
netif_queue_set_napi(vsi->netdev, rx_ring->q_index,
201-
NETDEV_QUEUE_TYPE_RX, NULL);
198+
ice_queue_set_napi(vsi, rx_ring->q_index, NETDEV_QUEUE_TYPE_RX,
199+
NULL);
202200
rx_ring->q_vector = NULL;
203201
}
204202

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

Lines changed: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,7 @@ ice_vsi_cfg_def(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params)
24262426
ice_vsi_map_rings_to_vectors(vsi);
24272427

24282428
/* Associate q_vector rings to napi */
2429-
ice_vsi_set_napi_queues(vsi, true);
2429+
ice_vsi_set_napi_queues(vsi);
24302430

24312431
vsi->stat_offsets_loaded = false;
24322432

@@ -2904,19 +2904,19 @@ void ice_vsi_dis_irq(struct ice_vsi *vsi)
29042904
}
29052905

29062906
/**
2907-
* ice_queue_set_napi - Set the napi instance for the queue
2907+
* __ice_queue_set_napi - Set the napi instance for the queue
29082908
* @dev: device to which NAPI and queue belong
29092909
* @queue_index: Index of queue
29102910
* @type: queue type as RX or TX
29112911
* @napi: NAPI context
29122912
* @locked: is the rtnl_lock already held
29132913
*
2914-
* Set the napi instance for the queue
2914+
* Set the napi instance for the queue. Caller indicates the lock status.
29152915
*/
29162916
static void
2917-
ice_queue_set_napi(struct net_device *dev, unsigned int queue_index,
2918-
enum netdev_queue_type type, struct napi_struct *napi,
2919-
bool locked)
2917+
__ice_queue_set_napi(struct net_device *dev, unsigned int queue_index,
2918+
enum netdev_queue_type type, struct napi_struct *napi,
2919+
bool locked)
29202920
{
29212921
if (!locked)
29222922
rtnl_lock();
@@ -2926,46 +2926,98 @@ ice_queue_set_napi(struct net_device *dev, unsigned int queue_index,
29262926
}
29272927

29282928
/**
2929-
* ice_q_vector_set_napi_queues - Map queue[s] associated with the napi
2929+
* ice_queue_set_napi - Set the napi instance for the queue
2930+
* @vsi: VSI being configured
2931+
* @queue_index: Index of queue
2932+
* @type: queue type as RX or TX
2933+
* @napi: NAPI context
2934+
*
2935+
* Set the napi instance for the queue. The rtnl lock state is derived from the
2936+
* execution path.
2937+
*/
2938+
void
2939+
ice_queue_set_napi(struct ice_vsi *vsi, unsigned int queue_index,
2940+
enum netdev_queue_type type, struct napi_struct *napi)
2941+
{
2942+
struct ice_pf *pf = vsi->back;
2943+
2944+
if (!vsi->netdev)
2945+
return;
2946+
2947+
if (current_work() == &pf->serv_task ||
2948+
test_bit(ICE_PREPARED_FOR_RESET, pf->state) ||
2949+
test_bit(ICE_DOWN, pf->state) ||
2950+
test_bit(ICE_SUSPENDED, pf->state))
2951+
__ice_queue_set_napi(vsi->netdev, queue_index, type, napi,
2952+
false);
2953+
else
2954+
__ice_queue_set_napi(vsi->netdev, queue_index, type, napi,
2955+
true);
2956+
}
2957+
2958+
/**
2959+
* __ice_q_vector_set_napi_queues - Map queue[s] associated with the napi
29302960
* @q_vector: q_vector pointer
29312961
* @locked: is the rtnl_lock already held
29322962
*
2963+
* Associate the q_vector napi with all the queue[s] on the vector.
2964+
* Caller indicates the lock status.
2965+
*/
2966+
void __ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked)
2967+
{
2968+
struct ice_rx_ring *rx_ring;
2969+
struct ice_tx_ring *tx_ring;
2970+
2971+
ice_for_each_rx_ring(rx_ring, q_vector->rx)
2972+
__ice_queue_set_napi(q_vector->vsi->netdev, rx_ring->q_index,
2973+
NETDEV_QUEUE_TYPE_RX, &q_vector->napi,
2974+
locked);
2975+
2976+
ice_for_each_tx_ring(tx_ring, q_vector->tx)
2977+
__ice_queue_set_napi(q_vector->vsi->netdev, tx_ring->q_index,
2978+
NETDEV_QUEUE_TYPE_TX, &q_vector->napi,
2979+
locked);
2980+
/* Also set the interrupt number for the NAPI */
2981+
netif_napi_set_irq(&q_vector->napi, q_vector->irq.virq);
2982+
}
2983+
2984+
/**
2985+
* ice_q_vector_set_napi_queues - Map queue[s] associated with the napi
2986+
* @q_vector: q_vector pointer
2987+
*
29332988
* Associate the q_vector napi with all the queue[s] on the vector
29342989
*/
2935-
void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked)
2990+
void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector)
29362991
{
29372992
struct ice_rx_ring *rx_ring;
29382993
struct ice_tx_ring *tx_ring;
29392994

29402995
ice_for_each_rx_ring(rx_ring, q_vector->rx)
2941-
ice_queue_set_napi(q_vector->vsi->netdev, rx_ring->q_index,
2942-
NETDEV_QUEUE_TYPE_RX, &q_vector->napi,
2943-
locked);
2996+
ice_queue_set_napi(q_vector->vsi, rx_ring->q_index,
2997+
NETDEV_QUEUE_TYPE_RX, &q_vector->napi);
29442998

29452999
ice_for_each_tx_ring(tx_ring, q_vector->tx)
2946-
ice_queue_set_napi(q_vector->vsi->netdev, tx_ring->q_index,
2947-
NETDEV_QUEUE_TYPE_TX, &q_vector->napi,
2948-
locked);
3000+
ice_queue_set_napi(q_vector->vsi, tx_ring->q_index,
3001+
NETDEV_QUEUE_TYPE_TX, &q_vector->napi);
29493002
/* Also set the interrupt number for the NAPI */
29503003
netif_napi_set_irq(&q_vector->napi, q_vector->irq.virq);
29513004
}
29523005

29533006
/**
29543007
* ice_vsi_set_napi_queues
29553008
* @vsi: VSI pointer
2956-
* @locked: is the rtnl_lock already held
29573009
*
29583010
* Associate queue[s] with napi for all vectors
29593011
*/
2960-
void ice_vsi_set_napi_queues(struct ice_vsi *vsi, bool locked)
3012+
void ice_vsi_set_napi_queues(struct ice_vsi *vsi)
29613013
{
29623014
int i;
29633015

29643016
if (!vsi->netdev)
29653017
return;
29663018

29673019
ice_for_each_q_vector(vsi, i)
2968-
ice_q_vector_set_napi_queues(vsi->q_vectors[i], locked);
3020+
ice_q_vector_set_napi_queues(vsi->q_vectors[i]);
29693021
}
29703022

29713023
/**

drivers/net/ethernet/intel/ice/ice_lib.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc);
9191
struct ice_vsi *
9292
ice_vsi_setup(struct ice_pf *pf, struct ice_vsi_cfg_params *params);
9393

94-
void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked);
94+
void
95+
ice_queue_set_napi(struct ice_vsi *vsi, unsigned int queue_index,
96+
enum netdev_queue_type type, struct napi_struct *napi);
97+
98+
void __ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked);
99+
100+
void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector);
95101

96-
void ice_vsi_set_napi_queues(struct ice_vsi *vsi, bool locked);
102+
void ice_vsi_set_napi_queues(struct ice_vsi *vsi);
97103

98104
int ice_vsi_release(struct ice_vsi *vsi);
99105

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3495,7 +3495,7 @@ static void ice_napi_add(struct ice_vsi *vsi)
34953495
ice_for_each_q_vector(vsi, v_idx) {
34963496
netif_napi_add(vsi->netdev, &vsi->q_vectors[v_idx]->napi,
34973497
ice_napi_poll);
3498-
ice_q_vector_set_napi_queues(vsi->q_vectors[v_idx], false);
3498+
__ice_q_vector_set_napi_queues(vsi->q_vectors[v_idx], false);
34993499
}
35003500
}
35013501

@@ -5447,6 +5447,7 @@ static int ice_reinit_interrupt_scheme(struct ice_pf *pf)
54475447
if (ret)
54485448
goto err_reinit;
54495449
ice_vsi_map_rings_to_vectors(pf->vsi[v]);
5450+
ice_vsi_set_napi_queues(pf->vsi[v]);
54505451
}
54515452

54525453
ret = ice_req_irq_msix_misc(pf);

0 commit comments

Comments
 (0)