Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue

Tony Nguyen says:

====================
ice: postpone service task disabling

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()).

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

* '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue:
ice: remove duplicate call to ice_deinit_hw() on error paths
ice: move ice_deinit_dev() to the end of deinit paths
ice: extract ice_init_dev() from ice_init()
ice: move ice_init_pf() out of ice_init_dev()
ice: move udp_tunnel_nic and misc IRQ setup into ice_init_pf()
ice: ice_init_pf: destroy mutexes and xarrays on memory alloc failure
ice: move ice_init_interrupt_scheme() prior ice_init_pf()
ice: move service task start out of ice_init_pf()
ice: enforce RTNL assumption of queue NAPI manipulation
====================

Link: https://patch.msgid.link/20251024204746.3092277-1-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+110 -91
+17 -4
drivers/net/ethernet/intel/ice/devlink/devlink.c
··· 459 459 rtnl_lock(); 460 460 ice_vsi_decfg(ice_get_main_vsi(pf)); 461 461 rtnl_unlock(); 462 + ice_deinit_pf(pf); 462 463 ice_deinit_dev(pf); 463 464 } 464 465 ··· 1232 1231 static int ice_devlink_reinit_up(struct ice_pf *pf) 1233 1232 { 1234 1233 struct ice_vsi *vsi = ice_get_main_vsi(pf); 1234 + struct device *dev = ice_pf_to_dev(pf); 1235 + bool need_dev_deinit = false; 1235 1236 int err; 1236 1237 1237 1238 err = ice_init_hw(&pf->hw); 1238 1239 if (err) { 1239 - dev_err(ice_pf_to_dev(pf), "ice_init_hw failed: %d\n", err); 1240 + dev_err(dev, "ice_init_hw failed: %d\n", err); 1240 1241 return err; 1241 1242 } 1242 1243 ··· 1249 1246 if (err) 1250 1247 goto unroll_hw_init; 1251 1248 1249 + err = ice_init_pf(pf); 1250 + if (err) { 1251 + dev_err(dev, "ice_init_pf failed: %d\n", err); 1252 + goto unroll_dev_init; 1253 + } 1254 + 1252 1255 vsi->flags = ICE_VSI_FLAG_INIT; 1253 1256 1254 1257 rtnl_lock(); 1255 1258 err = ice_vsi_cfg(vsi); 1256 1259 rtnl_unlock(); 1257 1260 if (err) 1258 - goto err_vsi_cfg; 1261 + goto unroll_pf_init; 1259 1262 1260 1263 /* No need to take devl_lock, it's already taken by devlink API */ 1261 1264 err = ice_load(pf); ··· 1274 1265 rtnl_lock(); 1275 1266 ice_vsi_decfg(vsi); 1276 1267 rtnl_unlock(); 1277 - err_vsi_cfg: 1278 - ice_deinit_dev(pf); 1268 + unroll_pf_init: 1269 + ice_deinit_pf(pf); 1270 + unroll_dev_init: 1271 + need_dev_deinit = true; 1279 1272 unroll_hw_init: 1280 1273 ice_deinit_hw(&pf->hw); 1274 + if (need_dev_deinit) 1275 + ice_deinit_dev(pf); 1281 1276 return err; 1282 1277 } 1283 1278
+4
drivers/net/ethernet/intel/ice/ice.h
··· 1029 1029 int ice_open_internal(struct net_device *netdev); 1030 1030 int ice_stop(struct net_device *netdev); 1031 1031 void ice_service_task_schedule(struct ice_pf *pf); 1032 + void ice_start_service_task(struct ice_pf *pf); 1032 1033 int ice_load(struct ice_pf *pf); 1033 1034 void ice_unload(struct ice_pf *pf); 1034 1035 void ice_adv_lnk_speed_maps_init(void); 1036 + void ice_init_dev_hw(struct ice_pf *pf); 1035 1037 int ice_init_dev(struct ice_pf *pf); 1036 1038 void ice_deinit_dev(struct ice_pf *pf); 1039 + int ice_init_pf(struct ice_pf *pf); 1040 + void ice_deinit_pf(struct ice_pf *pf); 1037 1041 int ice_change_mtu(struct net_device *netdev, int new_mtu); 1038 1042 void ice_tx_timeout(struct net_device *netdev, unsigned int txqueue); 1039 1043 int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp);
+3
drivers/net/ethernet/intel/ice/ice_common.c
··· 1161 1161 status = ice_init_hw_tbls(hw); 1162 1162 if (status) 1163 1163 goto err_unroll_fltr_mgmt_struct; 1164 + 1165 + ice_init_dev_hw(hw->back); 1166 + 1164 1167 mutex_init(&hw->tnl_lock); 1165 1168 ice_init_chk_recipe_reuse_support(hw); 1166 1169
+2 -2
drivers/net/ethernet/intel/ice/ice_lib.c
··· 2769 2769 * @vsi: VSI pointer 2770 2770 * 2771 2771 * Associate queue[s] with napi for all vectors. 2772 - * The caller must hold rtnl_lock. 2773 2772 */ 2774 2773 void ice_vsi_set_napi_queues(struct ice_vsi *vsi) 2775 2774 { ··· 2778 2779 if (!netdev) 2779 2780 return; 2780 2781 2782 + ASSERT_RTNL(); 2781 2783 ice_for_each_rxq(vsi, q_idx) 2782 2784 netif_queue_set_napi(netdev, q_idx, NETDEV_QUEUE_TYPE_RX, 2783 2785 &vsi->rx_rings[q_idx]->q_vector->napi); ··· 2799 2799 * @vsi: VSI pointer 2800 2800 * 2801 2801 * Clear the association between all VSI queues queue[s] and napi. 2802 - * The caller must hold rtnl_lock. 2803 2802 */ 2804 2803 void ice_vsi_clear_napi_queues(struct ice_vsi *vsi) 2805 2804 { ··· 2808 2809 if (!netdev) 2809 2810 return; 2810 2811 2812 + ASSERT_RTNL(); 2811 2813 /* Clear the NAPI's interrupt number */ 2812 2814 ice_for_each_q_vector(vsi, v_idx) { 2813 2815 struct ice_q_vector *q_vector = vsi->q_vectors[v_idx];
+84 -85
drivers/net/ethernet/intel/ice/ice_main.c
··· 3949 3949 * ice_deinit_pf - Unrolls initialziations done by ice_init_pf 3950 3950 * @pf: board private structure to initialize 3951 3951 */ 3952 - static void ice_deinit_pf(struct ice_pf *pf) 3952 + void ice_deinit_pf(struct ice_pf *pf) 3953 3953 { 3954 - ice_service_task_stop(pf); 3954 + /* note that we unroll also on ice_init_pf() failure here */ 3955 + 3955 3956 mutex_destroy(&pf->lag_mutex); 3956 3957 mutex_destroy(&pf->adev_mutex); 3957 3958 mutex_destroy(&pf->sw_mutex); ··· 3977 3976 3978 3977 if (pf->ptp.clock) 3979 3978 ptp_clock_unregister(pf->ptp.clock); 3979 + 3980 + if (!xa_empty(&pf->irq_tracker.entries)) 3981 + ice_free_irq_msix_misc(pf); 3980 3982 3981 3983 xa_destroy(&pf->dyn_ports); 3982 3984 xa_destroy(&pf->sf_nums); ··· 4034 4030 pf->max_pf_rxqs = func_caps->common_cap.num_rxq; 4035 4031 } 4036 4032 4033 + void ice_start_service_task(struct ice_pf *pf) 4034 + { 4035 + timer_setup(&pf->serv_tmr, ice_service_timer, 0); 4036 + pf->serv_tmr_period = HZ; 4037 + INIT_WORK(&pf->serv_task, ice_service_task); 4038 + clear_bit(ICE_SERVICE_SCHED, pf->state); 4039 + } 4040 + 4037 4041 /** 4038 4042 * ice_init_pf - Initialize general software structures (struct ice_pf) 4039 4043 * @pf: board private structure to initialize 4044 + * Return: 0 on success, negative errno otherwise. 4040 4045 */ 4041 - static int ice_init_pf(struct ice_pf *pf) 4046 + int ice_init_pf(struct ice_pf *pf) 4042 4047 { 4043 - ice_set_pf_caps(pf); 4048 + struct udp_tunnel_nic_info *udp_tunnel_nic = &pf->hw.udp_tunnel_nic; 4049 + struct device *dev = ice_pf_to_dev(pf); 4050 + struct ice_hw *hw = &pf->hw; 4051 + int err = -ENOMEM; 4044 4052 4045 4053 mutex_init(&pf->sw_mutex); 4046 4054 mutex_init(&pf->tc_mutex); ··· 4065 4049 4066 4050 init_waitqueue_head(&pf->reset_wait_queue); 4067 4051 4068 - /* setup service timer and periodic service task */ 4069 - timer_setup(&pf->serv_tmr, ice_service_timer, 0); 4070 - pf->serv_tmr_period = HZ; 4071 - INIT_WORK(&pf->serv_task, ice_service_task); 4072 - clear_bit(ICE_SERVICE_SCHED, pf->state); 4073 - 4074 4052 mutex_init(&pf->avail_q_mutex); 4075 - pf->avail_txqs = bitmap_zalloc(pf->max_pf_txqs, GFP_KERNEL); 4076 - if (!pf->avail_txqs) 4077 - return -ENOMEM; 4078 - 4079 - pf->avail_rxqs = bitmap_zalloc(pf->max_pf_rxqs, GFP_KERNEL); 4080 - if (!pf->avail_rxqs) { 4081 - bitmap_free(pf->avail_txqs); 4082 - pf->avail_txqs = NULL; 4083 - return -ENOMEM; 4084 - } 4085 - 4086 - pf->txtime_txqs = bitmap_zalloc(pf->max_pf_txqs, GFP_KERNEL); 4087 - if (!pf->txtime_txqs) { 4088 - bitmap_free(pf->avail_txqs); 4089 - pf->avail_txqs = NULL; 4090 - bitmap_free(pf->avail_rxqs); 4091 - pf->avail_rxqs = NULL; 4092 - return -ENOMEM; 4093 - } 4094 4053 4095 4054 mutex_init(&pf->vfs.table_lock); 4096 4055 hash_init(pf->vfs.table); ··· 4078 4087 xa_init(&pf->dyn_ports); 4079 4088 xa_init(&pf->sf_nums); 4080 4089 4090 + pf->avail_txqs = bitmap_zalloc(pf->max_pf_txqs, GFP_KERNEL); 4091 + pf->avail_rxqs = bitmap_zalloc(pf->max_pf_rxqs, GFP_KERNEL); 4092 + pf->txtime_txqs = bitmap_zalloc(pf->max_pf_txqs, GFP_KERNEL); 4093 + if (!pf->avail_txqs || !pf->avail_rxqs || !pf->txtime_txqs) 4094 + goto undo_init; 4095 + 4096 + udp_tunnel_nic->set_port = ice_udp_tunnel_set_port; 4097 + udp_tunnel_nic->unset_port = ice_udp_tunnel_unset_port; 4098 + udp_tunnel_nic->shared = &hw->udp_tunnel_shared; 4099 + udp_tunnel_nic->tables[0].n_entries = hw->tnl.valid_count[TNL_VXLAN]; 4100 + udp_tunnel_nic->tables[0].tunnel_types = UDP_TUNNEL_TYPE_VXLAN; 4101 + udp_tunnel_nic->tables[1].n_entries = hw->tnl.valid_count[TNL_GENEVE]; 4102 + udp_tunnel_nic->tables[1].tunnel_types = UDP_TUNNEL_TYPE_GENEVE; 4103 + 4104 + /* In case of MSIX we are going to setup the misc vector right here 4105 + * to handle admin queue events etc. In case of legacy and MSI 4106 + * the misc functionality and queue processing is combined in 4107 + * the same vector and that gets setup at open. 4108 + */ 4109 + err = ice_req_irq_msix_misc(pf); 4110 + if (err) { 4111 + dev_err(dev, "setup of misc vector failed: %d\n", err); 4112 + goto undo_init; 4113 + } 4114 + 4081 4115 return 0; 4116 + undo_init: 4117 + /* deinit handles half-initialized pf just fine */ 4118 + ice_deinit_pf(pf); 4119 + return err; 4082 4120 } 4083 4121 4084 4122 /** ··· 4742 4722 vsi->netdev = NULL; 4743 4723 } 4744 4724 4745 - int ice_init_dev(struct ice_pf *pf) 4725 + void ice_init_dev_hw(struct ice_pf *pf) 4746 4726 { 4747 - struct device *dev = ice_pf_to_dev(pf); 4748 4727 struct ice_hw *hw = &pf->hw; 4749 4728 int err; 4750 4729 ··· 4763 4744 */ 4764 4745 ice_set_safe_mode_caps(hw); 4765 4746 } 4747 + } 4766 4748 4767 - err = ice_init_pf(pf); 4768 - if (err) { 4769 - dev_err(dev, "ice_init_pf failed: %d\n", err); 4770 - return err; 4771 - } 4749 + int ice_init_dev(struct ice_pf *pf) 4750 + { 4751 + struct device *dev = ice_pf_to_dev(pf); 4752 + int err; 4772 4753 4773 - pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port; 4774 - pf->hw.udp_tunnel_nic.unset_port = ice_udp_tunnel_unset_port; 4775 - pf->hw.udp_tunnel_nic.shared = &pf->hw.udp_tunnel_shared; 4776 - if (pf->hw.tnl.valid_count[TNL_VXLAN]) { 4777 - pf->hw.udp_tunnel_nic.tables[0].n_entries = 4778 - pf->hw.tnl.valid_count[TNL_VXLAN]; 4779 - pf->hw.udp_tunnel_nic.tables[0].tunnel_types = 4780 - UDP_TUNNEL_TYPE_VXLAN; 4781 - } 4782 - if (pf->hw.tnl.valid_count[TNL_GENEVE]) { 4783 - pf->hw.udp_tunnel_nic.tables[1].n_entries = 4784 - pf->hw.tnl.valid_count[TNL_GENEVE]; 4785 - pf->hw.udp_tunnel_nic.tables[1].tunnel_types = 4786 - UDP_TUNNEL_TYPE_GENEVE; 4787 - } 4788 - 4754 + ice_set_pf_caps(pf); 4789 4755 err = ice_init_interrupt_scheme(pf); 4790 4756 if (err) { 4791 4757 dev_err(dev, "ice_init_interrupt_scheme failed: %d\n", err); 4792 - err = -EIO; 4793 - goto unroll_pf_init; 4758 + return -EIO; 4794 4759 } 4795 4760 4796 - /* In case of MSIX we are going to setup the misc vector right here 4797 - * to handle admin queue events etc. In case of legacy and MSI 4798 - * the misc functionality and queue processing is combined in 4799 - * the same vector and that gets setup at open. 4800 - */ 4801 - err = ice_req_irq_msix_misc(pf); 4802 - if (err) { 4803 - dev_err(dev, "setup of misc vector failed: %d\n", err); 4804 - goto unroll_irq_scheme_init; 4805 - } 4761 + ice_start_service_task(pf); 4806 4762 4807 4763 return 0; 4808 - 4809 - unroll_irq_scheme_init: 4810 - ice_clear_interrupt_scheme(pf); 4811 - unroll_pf_init: 4812 - ice_deinit_pf(pf); 4813 - return err; 4814 4764 } 4815 4765 4816 4766 void ice_deinit_dev(struct ice_pf *pf) 4817 4767 { 4818 - ice_free_irq_msix_misc(pf); 4819 - ice_deinit_pf(pf); 4820 - ice_deinit_hw(&pf->hw); 4768 + ice_service_task_stop(pf); 4821 4769 4822 4770 /* Service task is already stopped, so call reset directly. */ 4823 4771 ice_reset(&pf->hw, ICE_RESET_PFR); ··· 5024 5038 5025 5039 static int ice_init(struct ice_pf *pf) 5026 5040 { 5041 + struct device *dev = ice_pf_to_dev(pf); 5027 5042 int err; 5028 5043 5029 - err = ice_init_dev(pf); 5030 - if (err) 5044 + err = ice_init_pf(pf); 5045 + if (err) { 5046 + dev_err(dev, "ice_init_pf failed: %d\n", err); 5031 5047 return err; 5048 + } 5032 5049 5033 5050 if (pf->hw.mac_type == ICE_MAC_E830) { 5034 5051 err = pci_enable_ptm(pf->pdev, NULL); 5035 5052 if (err) 5036 - dev_dbg(ice_pf_to_dev(pf), "PCIe PTM not supported by PCIe bus/controller\n"); 5053 + dev_dbg(dev, "PCIe PTM not supported by PCIe bus/controller\n"); 5037 5054 } 5038 5055 5039 5056 err = ice_alloc_vsis(pf); 5040 5057 if (err) 5041 - goto err_alloc_vsis; 5058 + goto unroll_pf_init; 5042 5059 5043 5060 err = ice_init_pf_sw(pf); 5044 5061 if (err) ··· 5078 5089 ice_deinit_pf_sw(pf); 5079 5090 err_init_pf_sw: 5080 5091 ice_dealloc_vsis(pf); 5081 - err_alloc_vsis: 5082 - ice_deinit_dev(pf); 5092 + unroll_pf_init: 5093 + ice_deinit_pf(pf); 5083 5094 return err; 5084 5095 } 5085 5096 ··· 5090 5101 5091 5102 ice_deinit_pf_sw(pf); 5092 5103 ice_dealloc_vsis(pf); 5093 - ice_deinit_dev(pf); 5104 + ice_deinit_pf(pf); 5094 5105 } 5095 5106 5096 5107 /** ··· 5224 5235 ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) 5225 5236 { 5226 5237 struct device *dev = &pdev->dev; 5238 + bool need_dev_deinit = false; 5227 5239 struct ice_adapter *adapter; 5228 5240 struct ice_pf *pf; 5229 5241 struct ice_hw *hw; ··· 5321 5331 } 5322 5332 pf->adapter = adapter; 5323 5333 5324 - err = ice_init(pf); 5334 + err = ice_init_dev(pf); 5325 5335 if (err) 5326 5336 goto unroll_adapter; 5337 + 5338 + err = ice_init(pf); 5339 + if (err) 5340 + goto unroll_dev_init; 5327 5341 5328 5342 devl_lock(priv_to_devlink(pf)); 5329 5343 err = ice_load(pf); ··· 5346 5352 unroll_init: 5347 5353 devl_unlock(priv_to_devlink(pf)); 5348 5354 ice_deinit(pf); 5355 + unroll_dev_init: 5356 + need_dev_deinit = true; 5349 5357 unroll_adapter: 5350 5358 ice_adapter_put(pdev); 5351 5359 unroll_hw_init: 5352 5360 ice_deinit_hw(hw); 5361 + if (need_dev_deinit) 5362 + ice_deinit_dev(pf); 5353 5363 return err; 5354 5364 } 5355 5365 ··· 5448 5450 5449 5451 ice_hwmon_exit(pf); 5450 5452 5451 - ice_service_task_stop(pf); 5452 - ice_aq_cancel_waiting_tasks(pf); 5453 - set_bit(ICE_DOWN, pf->state); 5454 - 5455 5453 if (!ice_is_safe_mode(pf)) 5456 5454 ice_remove_arfs(pf); 5457 5455 ··· 5465 5471 ice_set_wake(pf); 5466 5472 5467 5473 ice_adapter_put(pdev); 5474 + ice_deinit_hw(&pf->hw); 5475 + 5476 + ice_deinit_dev(pf); 5477 + ice_aq_cancel_waiting_tasks(pf); 5478 + set_bit(ICE_DOWN, pf->state); 5468 5479 } 5469 5480 5470 5481 /**