ice: postpone service task disabling
Subsystems (3)
Tony Nguyen
maintainerPrzemek Kitszel says:
Move service task shutdown to the very end of driver teardown procedure. This is needed (or at least beneficial) for all unwinding functions that talk to FW/HW via Admin Queue (so, most of top-level functions, like ice_deinit_hw()).
Most of the patches move stuff around (I believe it makes it much easier to review/proof when kept separate) in preparation to defer stopping the service task to the very end of ice_remove() (and other unwinding flows). Then last patch fixes duplicate call to ice_init_hw() (actual, but unlikely to encounter, so -next, given the size of the changes).
First patch is not much related, only by that it was developed together
---
IWL: https://lore.kernel.org/intel-wired-lan/[email protected]/
The following are changes since commit f0a24b2547cfdd5ec85a131e386a2ce4ff9179cb:
Merge branch 'net-dsa-lantiq_gswip-use-regmap-for-register-access'
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue 100GbE
Przemek Kitszel (9):
ice: enforce RTNL assumption of queue NAPI manipulation
ice: move service task start out of ice_init_pf()
ice: move ice_init_interrupt_scheme() prior ice_init_pf()
ice: ice_init_pf: destroy mutexes and xarrays on memory alloc failure
ice: move udp_tunnel_nic and misc IRQ setup into ice_init_pf()
ice: move ice_init_pf() out of ice_init_dev()
ice: extract ice_init_dev() from ice_init()
ice: move ice_deinit_dev() to the end of deinit paths
ice: remove duplicate call to ice_deinit_hw() on error paths
.../net/ethernet/intel/ice/devlink/devlink.c | 21 ++- drivers/net/ethernet/intel/ice/ice.h | 4 + drivers/net/ethernet/intel/ice/ice_common.c | 3 + drivers/net/ethernet/intel/ice/ice_lib.c | 4 +- drivers/net/ethernet/intel/ice/ice_main.c | 169 +++++++++--------- 5 files changed, 110 insertions(+), 91 deletions(-)
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 1/9 ice: enforce RTNL assumption of queue NAPI manipulation
From: Przemek Kitszel <[email protected]>
Instead of making assumptions in comments move them into code. Be also more precise, RTNL must be locked only when there is NAPI, and we have VSIs w/o NAPI that call ice_vsi_clear_napi_queues() during rmmod.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +2 -2
@@ -2769,7 +2769,6 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked)* @vsi: VSI pointer * * Associate queue[s] with napi for all vectors. -* The caller must hold rtnl_lock. */ void ice_vsi_set_napi_queues (struct ice_vsi *vsi) {
@@ -2779,6 +2778,7 @@ void ice_vsi_set_napi_queues(struct ice_vsi *vsi)if (!netdev)return ; +ASSERT_RTNL ();ice_for_each_rxq (vsi, q_idx)netif_queue_set_napi (netdev, q_idx,NETDEV_QUEUE_TYPE_RX , &vsi->rx_rings[q_idx]->q_vector->napi);
@@ -2799,7 +2799,6 @@ void ice_vsi_set_napi_queues(struct ice_vsi *vsi)* @vsi: VSI pointer * * Clear the association between all VSI queues queue[s] and napi. -* The caller must hold rtnl_lock. */ void ice_vsi_clear_napi_queues (struct ice_vsi *vsi) {
@@ -2809,6 +2808,7 @@ void ice_vsi_clear_napi_queues(struct ice_vsi *vsi)if (!netdev)return ; +ASSERT_RTNL ();/* Clear the NAPI's interrupt number */ ice_for_each_q_vector (vsi, v_idx) {struct ice_q_vector *q_vector = vsi->q_vectors[v_idx];
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 2/9 ice: move service task start out of ice_init_pf()
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
Move service task start out of ice_init_pf(). Do analogous with deinit. Service task is needed up to the very end of driver removal, later commit of the series will move it later on execution timeline.
--- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -1029,6 +1029,7 @@ int ice_open(struct net_device *netdev);int ice_open_internal (struct net_device *netdev);int ice_stop (struct net_device *netdev);void ice_service_task_schedule (struct ice_pf *pf); +void ice_start_service_task (struct ice_pf *pf);int ice_load (struct ice_pf *pf);void ice_unload (struct ice_pf *pf);void ice_adv_lnk_speed_maps_init (void );
drivers/net/ethernet/intel/ice/ice_main.c +11 -7
@@ -3951,7 +3951,6 @@ u16 ice_get_avail_rxq_count(struct ice_pf *pf)*/ static void ice_deinit_pf (struct ice_pf *pf) { -ice_service_task_stop (pf);mutex_destroy (&pf->lag_mutex);mutex_destroy (&pf->adev_mutex);mutex_destroy (&pf->sw_mutex);
@@ -4030,6 +4029,14 @@ static void ice_set_pf_caps(struct ice_pf *pf) pf->max_pf_rxqs = func_caps->common_cap.num_rxq; } +void ice_start_service_task (struct ice_pf *pf) +{ +timer_setup (&pf->serv_tmr, ice_service_timer,0 ); + pf->serv_tmr_period =HZ ; +INIT_WORK (&pf->serv_task, ice_service_task); +clear_bit (ICE_SERVICE_SCHED , pf->state); +} +/** * ice_init_pf - Initialize general software structures (struct ice_pf) * @pf: board private structure to initialize
@@ -4049,12 +4056,6 @@ static int ice_init_pf(struct ice_pf *pf)init_waitqueue_head (&pf->reset_wait_queue); -/* setup service timer and periodic service task */ -timer_setup (&pf->serv_tmr, ice_service_timer,0 ); - pf->serv_tmr_period =HZ ; -INIT_WORK (&pf->serv_task, ice_service_task); -clear_bit (ICE_SERVICE_SCHED , pf->state); -mutex_init (&pf->avail_q_mutex); pf->avail_txqs =bitmap_zalloc (pf->max_pf_txqs,GFP_KERNEL );if (!pf->avail_txqs)
@@ -4745,6 +4746,7 @@ int ice_init_dev(struct ice_pf *pf)ice_set_safe_mode_caps (hw); } +ice_start_service_task (pf); err =ice_init_pf (pf);if (err) {dev_err (dev,"ice_init_pf failed: %d\n" , err);
@@ -4791,6 +4793,7 @@ int ice_init_dev(struct ice_pf *pf)ice_clear_interrupt_scheme (pf); unroll_pf_init:ice_deinit_pf (pf); +ice_service_task_stop (pf);return err; }
@@ -4799,6 +4802,7 @@ void ice_deinit_dev(struct ice_pf *pf)ice_free_irq_msix_misc (pf);ice_deinit_pf (pf);ice_deinit_hw (&pf->hw); +ice_service_task_stop (pf);/* Service task is already stopped, so call reset directly. */ ice_reset (&pf->hw,ICE_RESET_PFR );
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 3/9 ice: move ice_init_interrupt_scheme() prior ice_init_pf()
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
Move ice_init_interrupt_scheme() prior ice_init_pf().
To enable the move ice_set_pf_caps() was moved out from ice_init_pf() to the caller (ice_init_dev()), and placed prior to the irq scheme init.
The move makes deinit order of ice_deinit_dev() and failure-path of ice_init_pf() match (at least in terms of not calling ice_clear_interrupt_scheme() and ice_deinit_pf() in opposite ways).
The new order aligns with findings made by Jakub Buchocki in the commit 24b454bc354a ("ice: Fix ice module unload").
--- drivers/net/ethernet/intel/ice/ice_main.c | 25 ++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +11 -14
@@ -4043,8 +4043,6 @@ void ice_start_service_task(struct ice_pf *pf)*/ static int ice_init_pf (struct ice_pf *pf) { -ice_set_pf_caps (pf); -mutex_init (&pf->sw_mutex);mutex_init (&pf->tc_mutex);mutex_init (&pf->adev_mutex);
@@ -4746,11 +4744,18 @@ int ice_init_dev(struct ice_pf *pf)ice_set_safe_mode_caps (hw); } +ice_set_pf_caps (pf); + err =ice_init_interrupt_scheme (pf); +if (err) { +dev_err (dev,"ice_init_interrupt_scheme failed: %d\n" , err); +return -EIO ; + } +ice_start_service_task (pf); err =ice_init_pf (pf);if (err) {dev_err (dev,"ice_init_pf failed: %d\n" , err); -return err; + goto unroll_irq_scheme_init; } pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port;
@@ -4768,14 +4773,6 @@ int ice_init_dev(struct ice_pf *pf) pf->hw.udp_tunnel_nic.tables[1 ].tunnel_types =UDP_TUNNEL_TYPE_GENEVE ; } - - err =ice_init_interrupt_scheme (pf); -if (err) { -dev_err (dev,"ice_init_interrupt_scheme failed: %d\n" , err); - err = -EIO ; - goto unroll_pf_init; - } -/* In case of MSIX we are going to setup the misc vector right here * to handle admin queue events etc. In case of legacy and MSI * the misc functionality and queue processing is combined in
@@ -4784,16 +4781,16 @@ int ice_init_dev(struct ice_pf *pf) err =ice_req_irq_msix_misc (pf);if (err) {dev_err (dev,"setup of misc vector failed: %d\n" , err); - goto unroll_irq_scheme_init; + goto unroll_pf_init; }return 0 ; -unroll_irq_scheme_init: -ice_clear_interrupt_scheme (pf); unroll_pf_init:ice_deinit_pf (pf); +unroll_irq_scheme_init:ice_service_task_stop (pf); +ice_clear_interrupt_scheme (pf);return err; }
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 4/9 ice: ice_init_pf: destroy mutexes and xarrays on memory alloc failure
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
Unroll actions of ice_init_pf() when it fails. ice_deinit_pf() happens to be perfect to call here.
--- drivers/net/ethernet/intel/ice/ice_main.c | 31 +++++++++-------------- 1 file changed, 12 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +12 -19
@@ -3951,6 +3951,8 @@ u16 ice_get_avail_rxq_count(struct ice_pf *pf)*/ static void ice_deinit_pf (struct ice_pf *pf) { +/* note that we unroll also on ice_init_pf() failure here */ +mutex_destroy (&pf->lag_mutex);mutex_destroy (&pf->adev_mutex);mutex_destroy (&pf->sw_mutex);
@@ -4055,25 +4057,6 @@ static int ice_init_pf(struct ice_pf *pf)init_waitqueue_head (&pf->reset_wait_queue);mutex_init (&pf->avail_q_mutex); - pf->avail_txqs =bitmap_zalloc (pf->max_pf_txqs,GFP_KERNEL ); -if (!pf->avail_txqs) -return -ENOMEM ; - - pf->avail_rxqs =bitmap_zalloc (pf->max_pf_rxqs,GFP_KERNEL ); -if (!pf->avail_rxqs) { -bitmap_free (pf->avail_txqs); - pf->avail_txqs =NULL ; -return -ENOMEM ; - } - - pf->txtime_txqs =bitmap_zalloc (pf->max_pf_txqs,GFP_KERNEL ); -if (!pf->txtime_txqs) { -bitmap_free (pf->avail_txqs); - pf->avail_txqs =NULL ; -bitmap_free (pf->avail_rxqs); - pf->avail_rxqs =NULL ; -return -ENOMEM ; - }mutex_init (&pf->vfs.table_lock);hash_init (pf->vfs.table);
@@ -4086,7 +4069,17 @@ static int ice_init_pf(struct ice_pf *pf)xa_init (&pf->dyn_ports);xa_init (&pf->sf_nums); + pf->avail_txqs =bitmap_zalloc (pf->max_pf_txqs,GFP_KERNEL ); + pf->avail_rxqs =bitmap_zalloc (pf->max_pf_rxqs,GFP_KERNEL ); + pf->txtime_txqs =bitmap_zalloc (pf->max_pf_txqs,GFP_KERNEL ); +if (!pf->avail_txqs || !pf->avail_rxqs || !pf->txtime_txqs) + goto undo_init; +return 0 ; +undo_init: +/* deinit handles half-initialized pf just fine */ +ice_deinit_pf (pf); +return -ENOMEM ; }/**
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 5/9 ice: move udp_tunnel_nic and misc IRQ setup into ice_init_pf()
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
Move udp_tunnel_nic setup and ice_req_irq_msix_misc() call into ice_init_pf(), remove some redundancy in the former while moving.
Move ice_free_irq_msix_misc() call into ice_deinit_pf(), to mimic the above in terms of needed cleanup. Guard it via emptiness check, to keep the allowance of half-initialized pf being cleaned up.
--- drivers/net/ethernet/intel/ice/ice_main.c | 58 +++++++++++------------ 1 file changed, 28 insertions(+), 30 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +28 -30
@@ -3978,6 +3978,9 @@ static void ice_deinit_pf(struct ice_pf *pf)if (pf->ptp.clock)ptp_clock_unregister (pf->ptp.clock); +if (!xa_empty (&pf->irq_tracker.entries)) +ice_free_irq_msix_misc (pf); +xa_destroy (&pf->dyn_ports);xa_destroy (&pf->sf_nums); }
@@ -4045,6 +4048,11 @@ void ice_start_service_task(struct ice_pf *pf)*/ static int ice_init_pf (struct ice_pf *pf) { +struct udp_tunnel_nic_info *udp_tunnel_nic = &pf->hw.udp_tunnel_nic; +struct device *dev =ice_pf_to_dev (pf); +struct ice_hw *hw = &pf->hw; +int err = -ENOMEM ; +mutex_init (&pf->sw_mutex);mutex_init (&pf->tc_mutex);mutex_init (&pf->adev_mutex);
@@ -4075,11 +4083,30 @@ static int ice_init_pf(struct ice_pf *pf)if (!pf->avail_txqs || !pf->avail_rxqs || !pf->txtime_txqs) goto undo_init; + udp_tunnel_nic->set_port = ice_udp_tunnel_set_port; + udp_tunnel_nic->unset_port = ice_udp_tunnel_unset_port; + udp_tunnel_nic->shared = &hw->udp_tunnel_shared; + udp_tunnel_nic->tables[0 ].n_entries = hw->tnl.valid_count[TNL_VXLAN ]; + udp_tunnel_nic->tables[0 ].tunnel_types =UDP_TUNNEL_TYPE_VXLAN ; + udp_tunnel_nic->tables[1 ].n_entries = hw->tnl.valid_count[TNL_GENEVE ]; + udp_tunnel_nic->tables[1 ].tunnel_types =UDP_TUNNEL_TYPE_GENEVE ; + +/* In case of MSIX we are going to setup the misc vector right here +* to handle admin queue events etc. In case of legacy and MSI +* the misc functionality and queue processing is combined in +* the same vector and that gets setup at open. +*/ + err =ice_req_irq_msix_misc (pf); +if (err) { +dev_err (dev,"setup of misc vector failed: %d\n" , err); + goto undo_init; + } +return 0 ; undo_init:/* deinit handles half-initialized pf just fine */ ice_deinit_pf (pf); -return -ENOMEM ; +return err; }/**
@@ -4751,36 +4778,8 @@ int ice_init_dev(struct ice_pf *pf) goto unroll_irq_scheme_init; } - pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port; - pf->hw.udp_tunnel_nic.unset_port = ice_udp_tunnel_unset_port; - pf->hw.udp_tunnel_nic.shared = &pf->hw.udp_tunnel_shared; -if (pf->hw.tnl.valid_count[TNL_VXLAN ]) { - pf->hw.udp_tunnel_nic.tables[0 ].n_entries = - pf->hw.tnl.valid_count[TNL_VXLAN ]; - pf->hw.udp_tunnel_nic.tables[0 ].tunnel_types = -UDP_TUNNEL_TYPE_VXLAN ; - } -if (pf->hw.tnl.valid_count[TNL_GENEVE ]) { - pf->hw.udp_tunnel_nic.tables[1 ].n_entries = - pf->hw.tnl.valid_count[TNL_GENEVE ]; - pf->hw.udp_tunnel_nic.tables[1 ].tunnel_types = -UDP_TUNNEL_TYPE_GENEVE ; - } -/* In case of MSIX we are going to setup the misc vector right here -* to handle admin queue events etc. In case of legacy and MSI -* the misc functionality and queue processing is combined in -* the same vector and that gets setup at open. -*/ - err =ice_req_irq_msix_misc (pf); -if (err) { -dev_err (dev,"setup of misc vector failed: %d\n" , err); - goto unroll_pf_init; - } -return 0 ; -unroll_pf_init: -ice_deinit_pf (pf); unroll_irq_scheme_init:ice_service_task_stop (pf);ice_clear_interrupt_scheme (pf);
@@ -4789,7 +4788,6 @@ int ice_init_dev(struct ice_pf *pf)void ice_deinit_dev (struct ice_pf *pf) { -ice_free_irq_msix_misc (pf);ice_deinit_pf (pf);ice_deinit_hw (&pf->hw);ice_service_task_stop (pf);
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 6/9 ice: move ice_init_pf() out of ice_init_dev()
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
Move ice_init_pf() out of ice_init_dev().
Do the same for deinit counterpart.
--- .../net/ethernet/intel/ice/devlink/devlink.c | 16 ++++++++-- drivers/net/ethernet/intel/ice/ice.h | 2 ++ drivers/net/ethernet/intel/ice/ice_main.c | 32 +++++++++---------- 3 files changed, 31 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/ice/devlink/devlink.c +13 -3
@@ -459,6 +459,7 @@ static void ice_devlink_reinit_down(struct ice_pf *pf)rtnl_lock ();ice_vsi_decfg (ice_get_main_vsi (pf));rtnl_unlock (); +ice_deinit_pf (pf);ice_deinit_dev (pf); }
@@ -1231,11 +1232,12 @@ static void ice_set_min_max_msix(struct ice_pf *pf)static int ice_devlink_reinit_up (struct ice_pf *pf) {struct ice_vsi *vsi =ice_get_main_vsi (pf); +struct device *dev =ice_pf_to_dev (pf);int err; err =ice_init_hw (&pf->hw);if (err) { -dev_err (ice_pf_to_dev (pf),"ice_init_hw failed: %d\n" , err); +dev_err (dev,"ice_init_hw failed: %d\n" , err);return err; }
@@ -1246,13 +1248,19 @@ static int ice_devlink_reinit_up(struct ice_pf *pf)if (err) goto unroll_hw_init; + err =ice_init_pf (pf); +if (err) { +dev_err (dev,"ice_init_pf failed: %d\n" , err); + goto unroll_dev_init; + } + vsi->flags =ICE_VSI_FLAG_INIT ;rtnl_lock (); err =ice_vsi_cfg (vsi);rtnl_unlock ();if (err) - goto err_vsi_cfg; + goto unroll_pf_init;/* No need to take devl_lock, it's already taken by devlink API */ err =ice_load (pf);
@@ -1265,7 +1273,9 @@ static int ice_devlink_reinit_up(struct ice_pf *pf)rtnl_lock ();ice_vsi_decfg (vsi);rtnl_unlock (); -err_vsi_cfg: +unroll_pf_init: +ice_deinit_pf (pf); +unroll_dev_init:ice_deinit_dev (pf); unroll_hw_init:ice_deinit_hw (&pf->hw);
drivers/net/ethernet/intel/ice/ice.h +2 -0
@@ -1035,6 +1035,8 @@ void ice_unload(struct ice_pf *pf);void ice_adv_lnk_speed_maps_init (void );int ice_init_dev (struct ice_pf *pf);void ice_deinit_dev (struct ice_pf *pf); +int ice_init_pf (struct ice_pf *pf); +void ice_deinit_pf (struct ice_pf *pf);int ice_change_mtu (struct net_device *netdev,int new_mtu);void ice_tx_timeout (struct net_device *netdev,unsigned int txqueue);int ice_xdp (struct net_device *dev,struct netdev_bpf *xdp);
drivers/net/ethernet/intel/ice/ice_main.c +16 -16
@@ -3949,7 +3949,7 @@ u16 ice_get_avail_rxq_count(struct ice_pf *pf)* ice_deinit_pf - Unrolls initialziations done by ice_init_pf * @pf: board private structure to initialize */ -static void ice_deinit_pf (struct ice_pf *pf) +void ice_deinit_pf (struct ice_pf *pf) {/* note that we unroll also on ice_init_pf() failure here */
@@ -4045,8 +4045,9 @@ void ice_start_service_task(struct ice_pf *pf)/** * ice_init_pf - Initialize general software structures (struct ice_pf) * @pf: board private structure to initialize +* Return: 0 on success, negative errno otherwise. */ -static int ice_init_pf (struct ice_pf *pf) +int ice_init_pf (struct ice_pf *pf) {struct udp_tunnel_nic_info *udp_tunnel_nic = &pf->hw.udp_tunnel_nic;struct device *dev =ice_pf_to_dev (pf);
@@ -4772,23 +4773,12 @@ int ice_init_dev(struct ice_pf *pf) }ice_start_service_task (pf); - err =ice_init_pf (pf); -if (err) { -dev_err (dev,"ice_init_pf failed: %d\n" , err); - goto unroll_irq_scheme_init; - }return 0 ; - -unroll_irq_scheme_init: -ice_service_task_stop (pf); -ice_clear_interrupt_scheme (pf); -return err; }void ice_deinit_dev (struct ice_pf *pf) { -ice_deinit_pf (pf);ice_deinit_hw (&pf->hw);ice_service_task_stop (pf);
@@ -5030,21 +5020,28 @@ static void ice_deinit_devlink(struct ice_pf *pf)static int ice_init (struct ice_pf *pf) { +struct device *dev =ice_pf_to_dev (pf);int err; err =ice_init_dev (pf);if (err)return err; + err =ice_init_pf (pf); +if (err) { +dev_err (dev,"ice_init_pf failed: %d\n" , err); + goto unroll_dev_init; + } +if (pf->hw.mac_type ==ICE_MAC_E830 ) { err =pci_enable_ptm (pf->pdev,NULL );if (err) -dev_dbg (ice_pf_to_dev (pf),"PCIe PTM not supported by PCIe bus/controller\n" ); +dev_dbg (dev,"PCIe PTM not supported by PCIe bus/controller\n" ); } err =ice_alloc_vsis (pf);if (err) - goto err_alloc_vsis; + goto unroll_pf_init; err =ice_init_pf_sw (pf);if (err)
@@ -5081,7 +5078,9 @@ static int ice_init(struct ice_pf *pf)ice_deinit_pf_sw (pf); err_init_pf_sw:ice_dealloc_vsis (pf); -err_alloc_vsis: +unroll_pf_init: +ice_deinit_pf (pf); +unroll_dev_init:ice_deinit_dev (pf);return err; }
@@ -5093,6 +5092,7 @@ static void ice_deinit(struct ice_pf *pf)ice_deinit_pf_sw (pf);ice_dealloc_vsis (pf); +ice_deinit_pf (pf);ice_deinit_dev (pf); }
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 7/9 ice: extract ice_init_dev() from ice_init()
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
Extract ice_init_dev() from ice_init(), to allow service task and IRQ scheme teardown to be put after clearing SW constructs in the subsequent commit.
--- drivers/net/ethernet/intel/ice/ice_main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +9 -9
@@ -5023,14 +5023,10 @@ static int ice_init(struct ice_pf *pf)struct device *dev =ice_pf_to_dev (pf);int err; - err =ice_init_dev (pf); -if (err) -return err; - err =ice_init_pf (pf);if (err) {dev_err (dev,"ice_init_pf failed: %d\n" , err); - goto unroll_dev_init; +return err; }if (pf->hw.mac_type ==ICE_MAC_E830 ) {
@@ -5080,8 +5076,6 @@ static int ice_init(struct ice_pf *pf)ice_dealloc_vsis (pf); unroll_pf_init:ice_deinit_pf (pf); -unroll_dev_init: -ice_deinit_dev (pf);return err; }
@@ -5093,7 +5087,6 @@ static void ice_deinit(struct ice_pf *pf)ice_deinit_pf_sw (pf);ice_dealloc_vsis (pf);ice_deinit_pf (pf); -ice_deinit_dev (pf); }/**
@@ -5323,10 +5316,14 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) } pf->adapter = adapter; - err =ice_init (pf); + err =ice_init_dev (pf);if (err) goto unroll_adapter; + err =ice_init (pf); +if (err) + goto unroll_dev_init; +devl_lock (priv_to_devlink (pf)); err =ice_load (pf);if (err)
@@ -5344,6 +5341,8 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) unroll_init:devl_unlock (priv_to_devlink (pf));ice_deinit (pf); +unroll_dev_init: +ice_deinit_dev (pf); unroll_adapter:ice_adapter_put (pdev); unroll_hw_init:
@@ -5457,6 +5456,7 @@ static void ice_remove(struct pci_dev *pdev)devl_unlock (priv_to_devlink (pf));ice_deinit (pf); +ice_deinit_dev (pf);ice_vsi_release_all (pf);ice_setup_mc_magic_wake (pf);
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 8/9 ice: move ice_deinit_dev() to the end of deinit paths
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
ice_deinit_dev() takes care of turning off adminq processing, which is much needed during driver teardown (remove, reset, error path). Move it to the very end where applicable.
For example, ice_deinit_hw() called after adminq deinit slows rmmod on my two-card setup by about 60 seconds.
ice_init_dev() and ice_deinit_dev() scopes were reduced by previous commits of the series, with a final touch of extracting ice_init_dev_hw() out now (there is no deinit counterpart).
Note that removed ice_service_task_stop() call from ice_remove() is placed in the ice_deinit_dev() (and stopping twice makes no sense).
--- .../net/ethernet/intel/ice/devlink/devlink.c | 5 +++- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_common.c | 3 +++ drivers/net/ethernet/intel/ice/ice_main.c | 23 ++++++++++++------- 4 files changed, 23 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/devlink/devlink.c +4 -1
@@ -1233,6 +1233,7 @@ static int ice_devlink_reinit_up(struct ice_pf *pf) {struct ice_vsi *vsi =ice_get_main_vsi (pf);struct device *dev =ice_pf_to_dev (pf); +bool need_dev_deinit = false;int err; err =ice_init_hw (&pf->hw);
@@ -1276,9 +1277,11 @@ static int ice_devlink_reinit_up(struct ice_pf *pf) unroll_pf_init:ice_deinit_pf (pf); unroll_dev_init: -ice_deinit_dev (pf); + need_dev_deinit = true; unroll_hw_init:ice_deinit_hw (&pf->hw); +if (need_dev_deinit) +ice_deinit_dev (pf);return err; }
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -1033,6 +1033,7 @@ void ice_start_service_task(struct ice_pf *pf);int ice_load (struct ice_pf *pf);void ice_unload (struct ice_pf *pf);void ice_adv_lnk_speed_maps_init (void ); +void ice_init_dev_hw (struct ice_pf *pf);int ice_init_dev (struct ice_pf *pf);void ice_deinit_dev (struct ice_pf *pf);int ice_init_pf (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_common.c +3 -0
@@ -1161,6 +1161,9 @@ int ice_init_hw(struct ice_hw *hw) status =ice_init_hw_tbls (hw);if (status) goto err_unroll_fltr_mgmt_struct; + +ice_init_dev_hw (hw->back); +mutex_init (&hw->tnl_lock);ice_init_chk_recipe_reuse_support (hw);
drivers/net/ethernet/intel/ice/ice_main.c +15 -8
@@ -4742,9 +4742,8 @@ static void ice_decfg_netdev(struct ice_vsi *vsi) vsi->netdev =NULL ; } -int ice_init_dev (struct ice_pf *pf) +void ice_init_dev_hw (struct ice_pf *pf) { -struct device *dev =ice_pf_to_dev (pf);struct ice_hw *hw = &pf->hw;int err;
@@ -4764,6 +4763,12 @@ int ice_init_dev(struct ice_pf *pf)*/ ice_set_safe_mode_caps (hw); } +} + +int ice_init_dev (struct ice_pf *pf) +{ +struct device *dev =ice_pf_to_dev (pf); +int err;ice_set_pf_caps (pf); err =ice_init_interrupt_scheme (pf);
@@ -5220,6 +5225,7 @@ static int ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) { struct device *dev = &pdev->dev; +bool need_dev_deinit = false;struct ice_adapter *adapter;struct ice_pf *pf;struct ice_hw *hw;
@@ -5342,11 +5348,13 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)devl_unlock (priv_to_devlink (pf));ice_deinit (pf); unroll_dev_init: -ice_deinit_dev (pf); + need_dev_deinit = true; unroll_adapter:ice_adapter_put (pdev); unroll_hw_init:ice_deinit_hw (hw); +if (need_dev_deinit) +ice_deinit_dev (pf);return err; }
@@ -5441,10 +5449,6 @@ static void ice_remove(struct pci_dev *pdev)ice_hwmon_exit (pf); -ice_service_task_stop (pf); -ice_aq_cancel_waiting_tasks (pf); -set_bit (ICE_DOWN , pf->state); -if (!ice_is_safe_mode (pf))ice_remove_arfs (pf);
@@ -5456,13 +5460,16 @@ static void ice_remove(struct pci_dev *pdev)devl_unlock (priv_to_devlink (pf));ice_deinit (pf); -ice_deinit_dev (pf);ice_vsi_release_all (pf);ice_setup_mc_magic_wake (pf);ice_set_wake (pf);ice_adapter_put (pdev); + +ice_deinit_dev (pf); +ice_aq_cancel_waiting_tasks (pf); +set_bit (ICE_DOWN , pf->state); }/**
Signature · 1 line
2.47.1
Tony Nguyen
maintainerPATCH 9/9 ice: remove duplicate call to ice_deinit_hw() on error paths
In reply to Tony NguyenFrom: Przemek Kitszel <[email protected]>
Current unwinding code on error paths of ice_devlink_reinit_up() and ice_probe() have manual call to ice_deinit_hw() (which is good, as there is also manual call to ice_hw_init() there), which is then duplicated (and was prior current series) in ice_deinit_dev().
Fix the above by removing ice_deinit_hw() from ice_deinit_dev(). Add a (now missing) call in ice_remove().
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -4784,7 +4784,6 @@ int ice_init_dev(struct ice_pf *pf)void ice_deinit_dev (struct ice_pf *pf) { -ice_deinit_hw (&pf->hw);ice_service_task_stop (pf);/* Service task is already stopped, so call reset directly. */
@@ -5466,6 +5465,7 @@ static void ice_remove(struct pci_dev *pdev)ice_set_wake (pf);ice_adapter_put (pdev); +ice_deinit_hw (&pf->hw);ice_deinit_dev (pf);ice_aq_cancel_waiting_tasks (pf);
Signature · 1 line
2.47.1
This series was applied to netdev/net-next.git (main) by Tony Nguyen <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Tony Nguyen <[email protected]>:
Quoted 8 lines · On Fri, 24 Oct 2025 13:47:35 -0700 you wrote:
Przemek Kitszel says:
Move service task shutdown to the very end of driver teardown procedure. This is needed (or at least beneficial) for all unwinding functions that talk to FW/HW via Admin Queue (so, most of top-level functions, like
ice_deinit_hw()).[...]
Here is the summary with links:
- [net-next,1/9] ice: enforce RTNL assumption of queue NAPI manipulation
https://git.kernel.org/netdev/net-next/c/c35c178fcdff - [net-next,2/9] ice: move service task start out of ice_init_pf() https://git.kernel.org/netdev/net-next/c/806c4f32a806 - [net-next,3/9] ice: move ice_init_interrupt_scheme() prior ice_init_pf() https://git.kernel.org/netdev/net-next/c/2fe18288fce6 - [net-next,4/9] ice: ice_init_pf: destroy mutexes and xarrays on memory alloc failure https://git.kernel.org/netdev/net-next/c/71430451f81b - [net-next,5/9] ice: move udp_tunnel_nic and misc IRQ setup into ice_init_pf() https://git.kernel.org/netdev/net-next/c/e3bf1cdde747 - [net-next,6/9] ice: move ice_init_pf() out of ice_init_dev() https://git.kernel.org/netdev/net-next/c/ef825bdb4605 - [net-next,7/9] ice: extract ice_init_dev() from ice_init() https://git.kernel.org/netdev/net-next/c/c2fb9398f73d - [net-next,8/9] ice: move ice_deinit_dev() to the end of deinit paths https://git.kernel.org/netdev/net-next/c/8a37f9e2ff40 - [net-next,9/9] ice: remove duplicate call to ice_deinit_hw() on error paths https://git.kernel.org/netdev/net-next/c/1390b8b3d2be
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html