ice: fix reset and suspend paths
Subsystems (3)
cover ice: fix reset and suspend paths
These fixes address failures seen while validating reset recovery and suspend/resume on a system with two E830 PFs and two E810 PFs, with KASAN enabled. With several PFs probing, downloading DDP packages and rebuilding after resets at the same time, the logs filled up with:
ice 0000:38:00.0: Control Send Queue Writeback timeout.
ice 0000:38:00.0: Failed to get VLAN mode, status -5
ice 0000:38:00.0: Pkg download failed: err -5 off 267124737 inf 96
ice 0000:38:00.0: package load failed, -12
ice 0000:38:00.0: probe with driver ice failed with error -5
ice 0000:c8:00.1: clear PF configuration failed -5
ice 0000:c8:00.0: Rebuild failed, unload and reload driverPatch 2 has no Fixes tag on purpose; it is a prerequisite for patch 3, so stable backports of patch 3 must include patch 2.
Aaron Ma (5):
ice: check the full PF reset polling limit
ice: retain the adapter throughout hardware initialization and
teardown
ice: scope global configuration lock to the adapter
ice: clear DVM boost table before scanning package hints
ice: quiesce PTP periodic work before system suspend
drivers/net/ethernet/intel/ice/ice_adapter.c | 2 + drivers/net/ethernet/intel/ice/ice_adapter.h | 6 ++ drivers/net/ethernet/intel/ice/ice_common.c | 65 +++++++++++++------- drivers/net/ethernet/intel/ice/ice_common.h | 3 +- drivers/net/ethernet/intel/ice/ice_ddp.c | 8 +-- drivers/net/ethernet/intel/ice/ice_main.c | 37 ++++++----- 6 files changed, 80 insertions(+), 41 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/5 ice: check the full PF reset polling limit
The PF reset polling loop includes the Global Configuration Lock timeout in addition to the normal PF reset wait. Its timeout check still compares the iteration count against only the normal PF reset wait.
Consequently, exhausting the extended loop reports success while PFSWR is still set. A reset completing exactly at the old limit can instead report a false failure. Subsequent initialization must not proceed on the assumption that an unfinished reset succeeded.
Compare the count against the same bound used by the polling loop.
--- drivers/net/ethernet/intel/ice/ice_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_common.c +1 -1
@@ -1291,7 +1291,7 @@ static int ice_pf_reset(struct ice_hw *hw)mdelay (1 ); } -if (cnt ==ICE_PF_RESET_WAIT_COUNT ) { +if (cnt ==ICE_GLOBAL_CFG_LOCK_TIMEOUT +ICE_PF_RESET_WAIT_COUNT ) {ice_debug (hw,ICE_DBG_INIT ,"PF reset polling failed to complete.\n" );return -EIO ; }
Signature · 1 line
2.53.0
Re: [PATCH 1/5] ice: check the full PF reset polling limit
Quoted 22 lines · Aaron Ma
The PF reset polling loop includes the Global Configuration Lock timeout in addition to the normal PF reset wait. Its timeout check still compares the iteration count against only the normal PF reset wait.
Consequently, exhausting the extended loop reports success while PFSWR is still set. A reset completing exactly at the old limit can instead report a false failure. Subsequent initialization must not proceed on the assumption that an unfinished reset succeeded.
Compare the count against the same bound used by the polling loop.
Fixes c9a12d6d2091 ("ice: Increase timeout after PFR")Signed-off-by Aaron Ma <[email protected]>--- drivers/net/ethernet/intel/ice/ice_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_common.c +0
-0
drivers/net/ethernet/intel/ice/ice_common.c static int ice_pf_reset(struct ice_hw *hw) · line 1297
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_common.c +1
-1@@ -1291,7 +1291,7 @@ static int ice_pf_reset(struct ice_hw *hw)mdelay (1 ); } -if (cnt ==ICE_PF_RESET_WAIT_COUNT ) { +if (cnt ==ICE_GLOBAL_CFG_LOCK_TIMEOUT +ICE_PF_RESET_WAIT_COUNT ) {ice_debug (hw,ICE_DBG_INIT ,"PF reset polling failed to complete.\n" );return -EIO ; }
RE: [PATCH 1/5] ice: check the full PF reset polling limit
In reply to Aaron MaQuoted 16 lines
-----Original Message-----
From: Aaron Ma <[email protected]>
Sent: Monday, October 19, 2026 12:52 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Lobakin, Aleksander <[email protected]>; Richard Cochran <[email protected]>; [email protected]; [email protected]
Cc: Dan Nowlin <[email protected]>; Brett Creeley <[email protected]>; Keller, Jacob E <[email protected]>; moderated list:INTEL ETHERNET DRIVERS <[email protected]>
Subject: [PATCH 1/5] ice: check the full PF reset polling limit
...
Re: [PATCH 1/5] ice: check the full PF reset polling limit
In reply to Aaron MaQuoted 22 lines · Aaron Ma
The PF reset polling loop includes the Global Configuration Lock timeout in addition to the normal PF reset wait. Its timeout check still compares the iteration count against only the normal PF reset wait.
Consequently, exhausting the extended loop reports success while PFSWR is still set. A reset completing exactly at the old limit can instead report a false failure. Subsequent initialization must not proceed on the assumption that an unfinished reset succeeded.
Compare the count against the same bound used by the polling loop.
Fixes c9a12d6d2091 ("ice: Increase timeout after PFR")Signed-off-by Aaron Ma <[email protected]>--- drivers/net/ethernet/intel/ice/ice_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_common.c +0
-0
drivers/net/ethernet/intel/ice/ice_common.c static int ice_pf_reset(struct ice_hw *hw) · line 1297
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_common.c +1
-1@@ -1291,7 +1291,7 @@ static int ice_pf_reset(struct ice_hw *hw)mdelay (1 ); } -if (cnt ==ICE_PF_RESET_WAIT_COUNT ) { +if (cnt ==ICE_GLOBAL_CFG_LOCK_TIMEOUT +ICE_PF_RESET_WAIT_COUNT ) {ice_debug (hw,ICE_DBG_INIT ,"PF reset polling failed to complete.\n" );return -EIO ; }
This conflicts with
https://lore.kernel.org/intel-wired-lan/[email protected]/
which is part of the series
https://lore.kernel.org/intel-wired-lan/[email protected]/
I think Petr's fix is more complete, checking for the actual reset status is more reliable than *either* the old or this check.
I'm rejecting just this one patch from the series and won't apply it. If you need to rebase please exlude that fix in v2 or later and we'll carry the better fix from Petr as it goes through the net tree.
Thanks,
Jake
PATCH 2/5 ice: retain the adapter throughout hardware initialization and teardown
In reply to Aaron MaAdapter-scoped synchronization must be available to Admin Queue users from initial queue creation through the last teardown command. Probe currently obtains its adapter reference only after hardware and package initialization, and error cleanup and removal drop it before hardware teardown.
Acquire the reference before either normal hardware initialization or firmware recovery-mode initialization. Release it after hardware and device cleanup, balancing recovery-mode probe failures and removal too.
This establishes the lifetime prerequisite for moving package ownership exclusion from a module-global mutex to the shared adapter.
--- drivers/net/ethernet/intel/ice/ice_main.c | 31 +++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +17 -14
@@ -5242,27 +5242,29 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) hw->debug_mask = debug;#endif -if (ice_is_recovery_mode (hw)) -return ice_probe_recovery_mode (pf); + adapter =ice_adapter_get (pdev); +if (IS_ERR (adapter)) +return PTR_ERR (adapter); + pf->adapter = adapter; + +if (ice_is_recovery_mode (hw)) { + err =ice_probe_recovery_mode (pf); +if (err) +ice_adapter_put (pdev); +return err; + } err =ice_init_hw (hw);if (err) {dev_err (dev,"ice_init_hw failed: %d\n" , err); -return err; + goto unroll_adapter; }ice_init_dev_hw (pf); - adapter =ice_adapter_get (pdev); -if (IS_ERR (adapter)) { - err =PTR_ERR (adapter); - goto unroll_hw_init; - } - pf->adapter = adapter; - err =ice_init_dev (pf);if (err) - goto unroll_adapter; + goto unroll_hw_init; err =ice_init (pf);if (err)
@@ -5287,12 +5289,12 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)ice_deinit (pf); unroll_dev_init: 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); +unroll_adapter: +ice_adapter_put (pdev);return err; }
@@ -5377,6 +5379,7 @@ static void ice_remove(struct pci_dev *pdev) scoped_guard(devl, priv_to_devlink(pf)) {ice_deinit_devlink (pf); } +ice_adapter_put (pdev);return ; }
@@ -5403,11 +5406,11 @@ static void ice_remove(struct pci_dev *pdev)ice_setup_mc_magic_wake (pf);ice_set_wake (pf); -ice_adapter_put (pdev);ice_deinit_hw (&pf->hw);ice_deinit_dev (pf);ice_aq_cancel_waiting_tasks (pf); +ice_adapter_put (pdev);set_bit (ICE_DOWN , pf->state); }
Signature · 1 line
2.53.0
RE: [PATCH 2/5] ice: retain the adapter throughout hardware initialization and teardown
Quoted 7 lines
-----Original Message-----
From: Aaron Ma <[email protected]>
Sent: Monday, October 19, 2026 12:52 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni
Quoted 8 lines
<[email protected]>; Lobakin, Aleksander <[email protected]>; Richard Cochran <[email protected]>; [email protected]; [email protected]
Cc: Dan Nowlin <[email protected]>; Brett Creeley <[email protected]>; Keller, Jacob E <[email protected]>; moderated list:INTEL ETHERNET DRIVERS <[email protected]>
Subject: [PATCH 2/5] ice: retain the adapter throughout hardware initialization and teardown
Przemek Kitszel
maintainerRe: [PATCH 2/5] ice: retain the adapter throughout hardware initialization and teardown
In reply to Aaron MaQuoted 6 lines · Aaron Ma
Adapter-scoped synchronization must be available to Admin Queue users from initial queue creation through the last teardown command. Probe currently obtains its adapter reference only after hardware and package initialization, and error cleanup and removal drop it before hardware teardown.
Quoted 8 lines
Acquire the reference before either normal hardware initialization or firmware recovery-mode initialization. Release it after hardware and device cleanup, balancing recovery-mode probe failures and removal too.
This establishes the lifetime prerequisite for moving package ownership exclusion from a module-global mutex to the shared adapter.
Signed-off-by Aaron Ma <[email protected]>
it was me to move hw init before adapter init, to make hw details readily accessible to the adapter
but I agree that SW lock protection covering HW reinit will be great, and my needs could be achieved by other means, even if less elegant
so, I'm happy with your patch
OTOH I have a big series that git-conflicts, would be easiest if your series will be merged first (so I will adjust), but I don't want to be delayed (will be CCing you on it going forward)
the real thing is of course the 3rd patch not this one
Quoted 85 lines
--- drivers/net/ethernet/intel/ice/ice_main.c | 31 +++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +17
-14@@ -5242,27 +5242,29 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) hw->debug_mask = debug;#endif -if (ice_is_recovery_mode (hw)) -return ice_probe_recovery_mode (pf); + adapter =ice_adapter_get (pdev); +if (IS_ERR (adapter)) +return PTR_ERR (adapter); + pf->adapter = adapter; + +if (ice_is_recovery_mode (hw)) { + err =ice_probe_recovery_mode (pf); +if (err) +ice_adapter_put (pdev); +return err; + } err =ice_init_hw (hw);if (err) {dev_err (dev,"ice_init_hw failed: %d\n" , err); -return err; + goto unroll_adapter; }ice_init_dev_hw (pf); - adapter =ice_adapter_get (pdev); -if (IS_ERR (adapter)) { - err =PTR_ERR (adapter); - goto unroll_hw_init; - } - pf->adapter = adapter; - err =ice_init_dev (pf);if (err) - goto unroll_adapter; + goto unroll_hw_init; err =ice_init (pf);if (err)@@ -5287,12 +5289,12 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)ice_deinit (pf); unroll_dev_init: 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); +unroll_adapter: +ice_adapter_put (pdev);return err; }@@ -5377,6 +5379,7 @@ static void ice_remove(struct pci_dev *pdev) scoped_guard(devl, priv_to_devlink(pf)) {ice_deinit_devlink (pf); } +ice_adapter_put (pdev);return ; }@@ -5403,11 +5406,11 @@ static void ice_remove(struct pci_dev *pdev)ice_setup_mc_magic_wake (pf);ice_set_wake (pf); -ice_adapter_put (pdev);ice_deinit_hw (&pf->hw);ice_deinit_dev (pf);ice_aq_cancel_waiting_tasks (pf); +ice_adapter_put (pdev);set_bit (ICE_DOWN , pf->state); }
Re: [PATCH 2/5] ice: retain the adapter throughout hardware initialization and teardown
Quoted 22 lines · Przemek Kitszel
Quoted 6 lines · Aaron Ma
Adapter-scoped synchronization must be available to Admin Queue users from initial queue creation through the last teardown command. Probe currently obtains its adapter reference only after hardware and package initialization, and error cleanup and removal drop it before hardware teardown.
Quoted 8 lines
Acquire the reference before either normal hardware initialization or firmware recovery-mode initialization. Release it after hardware and device cleanup, balancing recovery-mode probe failures and removal too.
This establishes the lifetime prerequisite for moving package ownership exclusion from a module-global mutex to the shared adapter.
Signed-off-by Aaron Ma <[email protected]>it was me to move hw init before adapter init, to make hw details readily accessible to the adapter
but I agree that SW lock protection covering HW reinit will be great, and my needs could be achieved by other means, even if less elegant
Quoted 7 lines
so, I'm happy with your patch
OTOH I have a big series that git-conflicts, would be easiest if your series will be merged first (so I will adjust), but I don't want to be delayed (will be CCing you on it going forward)the real thing is of course the 3rd patch not this one
I got a Sashiko report about adapter not being present during hw deinit, which was problematic for PTP. I think the lifetime rules make more sense if the adapter outlives the PFs.
Sounds good.
Thanks,
Jake
Przemek Kitszel
maintainerRe: [PATCH 2/5] ice: retain the adapter throughout hardware initialization and teardown
In reply to Przemek KitszelQuoted 19 lines · Przemek Kitszel
Quoted 6 lines · Aaron Ma
Adapter-scoped synchronization must be available to Admin Queue users from initial queue creation through the last teardown command. Probe currently obtains its adapter reference only after hardware and package initialization, and error cleanup and removal drop it before hardware teardown.
Quoted 8 lines
Acquire the reference before either normal hardware initialization or firmware recovery-mode initialization. Release it after hardware and device cleanup, balancing recovery-mode probe failures and removal too.
This establishes the lifetime prerequisite for moving package ownership exclusion from a module-global mutex to the shared adapter.
Signed-off-by Aaron Ma <[email protected]>it was me to move hw init before adapter init, to make hw details readily accessible to the adapter
Quoted 7 lines
but I agree that SW lock protection covering HW reinit will be great, and my needs could be achieved by other means, even if less elegant
so, I'm happy with your patch
OTOH I have a big series that git-conflicts, would be easiest if your series will be merged first (so I will adjust), but I don't want to be delayed (will be CCing you on it going forward)
this was merged (just this and 1st patch of the lined series):
https://lore.kernel.org/netdev/[email protected]/
to make your and my needs met, I think the right solution would be to move ice_hw init/deinit into ice_adapter constructor/destructor then holding ice_adapter devl lock will be both easy and natural
the "init_param" param of ice_adapter_init() was initially meant for number of PFs (taken from ice_hw), but I will pass in v8 of my series ptr to ice_hw
(talking aloud to make it easier for you to base over it and/or comment early)
Quoted 2 lines
the real thing is of course the 3rd patch not this one
Re: [PATCH 2/5] ice: retain the adapter throughout hardware initialization and teardown
Quoted 36 lines · Przemek Kitszel
Quoted 19 lines · Przemek Kitszel
Quoted 6 lines · Aaron Ma
Adapter-scoped synchronization must be available to Admin Queue users from initial queue creation through the last teardown command. Probe currently obtains its adapter reference only after hardware and package initialization, and error cleanup and removal drop it before hardware teardown.
Quoted 8 lines
Acquire the reference before either normal hardware initialization or firmware recovery-mode initialization. Release it after hardware and device cleanup, balancing recovery-mode probe failures and removal too.
This establishes the lifetime prerequisite for moving package ownership exclusion from a module-global mutex to the shared adapter.
Signed-off-by Aaron Ma <[email protected]>it was me to move hw init before adapter init, to make hw details readily accessible to the adapter
Quoted 7 lines
but I agree that SW lock protection covering HW reinit will be great, and my needs could be achieved by other means, even if less elegant
so, I'm happy with your patch
OTOH I have a big series that git-conflicts, would be easiest if your series will be merged first (so I will adjust), but I don't want to be delayed (will be CCing you on it going forward)this was merged (just this and 1st patch of the lined series):
https://lore.kernel.org/netdev/20261117094913.100756-3-
[email protected]/to make your and my needs met, I think the right solution would be to move
ice_hwinit/deinit intoice_adapterconstructor/destructor then holdingice_adapterdevl lock will be both easy and natural
Quoted 6 lines
the "
init_param" param ofice_adapter_init()was initially meant for number of PFs (taken fromice_hw), but I will pass in v8 of my series ptr toice_hw
(talking aloud to make it easier for you to base over it and/or comment early)
I need the ptr to ice_hw or something equivalent as well in order to get the device type for the timecounter series :)
Thanks,
Jake
Quoted 3 lines
Quoted 2 lines
the real thing is of course the 3rd patch not this one
PATCH 3/5 ice: scope global configuration lock to the adapter
In reply to Aaron Maice_global_cfg_lock_sw is a module-global mutex, so a package download on one E810 adapter blocks Admin Queue commands on unrelated adapters in the same system. In addition, the mutex is acquired only after firmware grants the Global Configuration Lock and dropped before firmware releases it, while the opcode exemption list in ice_aq_send_cmd() does not check whether the caller is the lock owner. Non-owning PFs on the same adapter can therefore submit exempted Admin Queue commands or sideband requests while another PF holds firmware ownership.
Move the software mutex to struct ice_adapter and record the owning task across the entire Global Configuration Lock acquisition and release sequence, including the core reset path in ice_cfg_tx_topo(). In ice_aq_send_cmd(), require non-owning tasks to wait on the adapter mutex while allowing the owning task to issue the permitted configuration commands. Route the Admin Queue fallback in ice_sbq_send_cmd() through ice_aq_send_cmd() as well.
This patch depends on the previous patch in this series.
--- drivers/net/ethernet/intel/ice/ice_adapter.c | 2 + drivers/net/ethernet/intel/ice/ice_adapter.h | 6 ++ drivers/net/ethernet/intel/ice/ice_common.c | 63 +++++++++++++------- drivers/net/ethernet/intel/ice/ice_common.h | 3 +- drivers/net/ethernet/intel/ice/ice_ddp.c | 7 +-- 5 files changed, 55 insertions(+), 26 deletions(-)
drivers/net/ethernet/intel/ice/ice_adapter.c +2 -0
@@ -65,6 +65,7 @@ static struct ice_adapter *ice_adapter_new(struct pci_dev *pdev)for (int i =0 ; i <ARRAY_SIZE (adapter->cpi_phy_lock); i++)mutex_init (&adapter->cpi_phy_lock[i]);mutex_init (&adapter->rebuild_lock); +mutex_init (&adapter->global_cfg_lock);refcount_set (&adapter->refcount,1 );mutex_init (&adapter->ports.lock);
@@ -79,6 +80,7 @@ static void ice_adapter_free(struct ice_adapter *adapter)for (int i =0 ; i <ARRAY_SIZE (adapter->cpi_phy_lock); i++)mutex_destroy (&adapter->cpi_phy_lock[i]);mutex_destroy (&adapter->rebuild_lock); +mutex_destroy (&adapter->global_cfg_lock);mutex_destroy (&adapter->ports.lock);kfree (adapter);
drivers/net/ethernet/intel/ice/ice_adapter.h +6 -0
@@ -13,6 +13,7 @@struct pci_dev ;struct ice_pf ; +struct task_struct ;/** * struct ice_port_list - data used to store the list of adapter ports
@@ -38,6 +39,8 @@ struct ice_port_list {* Index 0 = PHY0, index 1 = PHY1. Used on E825C devices. * @ctrl_pf: Control PF of the adapter * @rebuild_lock: serialize PFR recovery across PFs of the same adapter +* @global_cfg_lock: serialize AQ access during global configuration +* @global_cfg_owner: task holding the global configuration lock * @ports: Ports list * @index: 64-bit index cached for collision detection on 32bit systems */
@@ -51,6 +54,9 @@ struct ice_adapter {struct mutex cpi_phy_lock[ICE_E825_MAX_PHYS ];/* Serialize PFR recovery touching shared FW global state */ struct mutex rebuild_lock; +/* Keep other PFs off the AQ until firmware releases ownership */ +struct mutex global_cfg_lock; +struct task_struct *global_cfg_owner;struct ice_pf *ctrl_pf;struct ice_port_list ports;
drivers/net/ethernet/intel/ice/ice_common.c +43 -20
127 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_common.h +1 -2
@@ -98,6 +98,7 @@ int ice_acquire_res(struct ice_hw *hw, enum ice_aq_res_ids res, enum ice_aq_res_access_type access, u32 timeout);void ice_release_res (struct ice_hw *hw,enum ice_aq_res_ids res); +void ice_global_cfg_unlock (struct ice_hw *hw);int ice_alloc_hw_res (struct ice_hw *hw,u16 type,u16 num,bool btm,u16 *res);int
@@ -142,8 +143,6 @@ void ice_fill_dflt_direct_cmd_desc(struct libie_aq_desc *desc, u16 opcode);void ice_pack_txq_ctx (const struct ice_tlan_ctx *ctx,ice_txq_ctx_buf_t *buf); -extern struct mutex ice_global_cfg_lock_sw; -int ice_aq_send_cmd (struct ice_hw *hw,struct libie_aq_desc *desc,void *buf,u16 buf_size,struct ice_sq_cd *cd);
drivers/net/ethernet/intel/ice/ice_ddp.c +3 -4
@@ -1141,9 +1141,7 @@ static int ice_acquire_global_cfg_lock(struct ice_hw *hw, status =ice_acquire_res (hw,ICE_GLOBAL_CFG_LOCK_RES_ID , access,ICE_GLOBAL_CFG_LOCK_TIMEOUT ); -if (!status) -mutex_lock (&ice_global_cfg_lock_sw); -else if (status == -EALREADY ) +if (status == -EALREADY )ice_debug (hw,ICE_DBG_PKG ,"Global config lock: No work to do\n" );
@@ -1158,7 +1156,6 @@ static int ice_acquire_global_cfg_lock(struct ice_hw *hw,*/ static void ice_release_global_cfg_lock (struct ice_hw *hw) { -mutex_unlock (&ice_global_cfg_lock_sw);ice_release_res (hw,ICE_GLOBAL_CFG_LOCK_RES_ID ); }
@@ -2536,6 +2533,8 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)ice_check_reset (hw); reinit_hw: +ice_global_cfg_unlock (hw); +/* Since we triggered a CORER, re-initialize hardware */ ice_deinit_hw (hw);if (ice_init_hw (hw)) {
Signature · 1 line
2.53.0
RE: [PATCH 3/5] ice: scope global configuration lock to the adapter
Quoted 57 lines
-----Original Message-----
From: Aaron Ma <[email protected]>
Sent: Monday, October 19, 2026 12:52 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Lobakin, Aleksander <[email protected]>; Richard Cochran <[email protected]>; [email protected]; [email protected]
Cc: Dan Nowlin <[email protected]>; Brett Creeley <[email protected]>; Keller, Jacob E <[email protected]>; moderated list:INTEL ETHERNET DRIVERS <[email protected]>
Subject: [PATCH 3/5] ice: scope global configuration lock to the adapter
ice_global_cfg_lock_swis a module-global mutex, so a package download on one E810 adapter blocks Admin Queue commands on unrelated adapters in the same system. In addition, the mutex is acquired only after firmware grants the Global Configuration Lock and dropped before firmware releases it, while the opcode exemption list inice_aq_send_cmd()does not check whether the caller is the lock owner. Non-owning PFs on the same adapter can therefore submit exempted Admin Queue commands or sideband requests while another PF holds firmware ownership.Move the software mutex to struct
ice_adapterand record the owning task across the entire Global Configuration Lock acquisition and release sequence, including the core reset path inice_cfg_tx_topo(). Inice_aq_send_cmd(), require non-owning tasks to wait on the adapter mutex while allowing the owning task to issue the permitted configuration commands. Route the Admin Queue fallback inice_sbq_send_cmd()throughice_aq_send_cmd()as well.This patch depends on the previous patch in this series.
Fixes c76488109616 ("ice: Implement Dynamic Device Personalization(DDP) download")
Signed-off-by Aaron Ma <[email protected]>--- drivers/net/ethernet/intel/ice/ice_adapter.c | 2 + drivers/net/ethernet/intel/ice/ice_adapter.h | 6 ++ drivers/net/ethernet/intel/ice/ice_common.c | 63 +++++++++++++------- drivers/net/ethernet/intel/ice/ice_common.h | 3 +- drivers/net/ethernet/intel/ice/ice_ddp.c | 7 +-- 5 files changed, 55 insertions(+), 26 deletions(-)drivers/net/ethernet/intel/ice/ice_adapter.c +0
-0@@ -65,6 +65,7 @@ static struct ice_adapter *ice_adapter_new(struct pci_dev *pdev)for (int i =0 ; i <ARRAY_SIZE (adapter->cpi_phy_lock); i++)mutex_init (&adapter->cpi_phy_lock[i]);mutex_init (&adapter->rebuild_lock);
...
drivers/net/ethernet/intel/ice/ice_adapter.c ice_aq_send_cmd(struct ice_hw *hw, struct · line 1899
Quoted 12 lines
/**
*ice_should_retry_sq_send_cmd
* @opcode: AQ opcodedrivers/net/ethernet/intel/ice/ice_adapter.c +2
-2@@ -1895,17 +1894,24 @@ ice_aq_send_cmd(struct ice_hw *hw, struct libie_aq_desc *desc, void *buf, u16 buf_size, struct ice_sq_cd *cd) {struct libie_aqc_req_res *cmd =libie_aq_raw (desc); -bool lock_acquired = false; -int status; +struct ice_pf *pf = hw->back; +struct ice_adapter *adapter = pf->adapter;
pf->adapter can be NULL during ice_init_hw(), is it ok?
Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_adapter.c +6
-0+ +if (READ_ONCE (adapter->global_cfg_owner) != current) { +guard (mutex)(&adapter->global_cfg_lock); +return ice_sq_send_cmd_retry (hw, &hw->adminq, desc, buf, + buf_size, cd); + }/* When a package download is in process (i.e. when the firmware's
drivers/net/ethernet/intel/ice/ice_adapter.c +0
-0* Global Configuration Lock resource is held), only the Download * Package, Get Version, Get Package Info List, Upload Section, * Update Package, Set Port Parameters, Get/Set VLAN Mode Parameters,
...
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_adapter.c +0
-1/* Since we triggered a CORER, re-initialize hardware */ ice_deinit_hw (hw);if (ice_init_hw (hw)) { --2.53.0
Re: [PATCH 3/5] ice: scope global configuration lock to the adapter
Quoted 61 lines · Aleksandr
Quoted 58 lines
-----Original Message-----
From: Aaron Ma <[email protected]>
Sent: Monday, October 19, 2026 12:52 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Lobakin, Aleksander <[email protected]>; Richard Cochran <[email protected]>; [email protected]; [email protected]
Cc: Dan Nowlin <[email protected]>; Brett Creeley <[email protected]>; Keller, Jacob E <[email protected]>; moderated list:INTEL ETHERNET DRIVERS <[email protected]>
Subject: [PATCH 3/5] ice: scope global configuration lock to the adapter
ice_global_cfg_lock_swis a module-global mutex, so a package download on one E810 adapter blocks Admin Queue commands on unrelated adapters in the same system. In addition, the mutex is acquired only after firmware grants the Global Configuration Lock and dropped before firmware releases it, while the opcode exemption list inice_aq_send_cmd()does not check whether the caller is the lock owner. Non-owning PFs on the same adapter can therefore submit exempted Admin Queue commands or sideband requests while another PF holds firmware ownership.Move the software mutex to struct
ice_adapterand record the owning task across the entire Global Configuration Lock acquisition and release sequence, including the core reset path inice_cfg_tx_topo(). Inice_aq_send_cmd(), require non-owning tasks to wait on the adapter mutex while allowing the owning task to issue the permitted configuration commands. Route the Admin Queue fallback inice_sbq_send_cmd()throughice_aq_send_cmd()as well.This patch depends on the previous patch in this series.
Fixes c76488109616 ("ice: Implement Dynamic Device Personalization(DDP) download")
Signed-off-by Aaron Ma <[email protected]>--- drivers/net/ethernet/intel/ice/ice_adapter.c | 2 + drivers/net/ethernet/intel/ice/ice_adapter.h | 6 ++ drivers/net/ethernet/intel/ice/ice_common.c | 63 +++++++++++++------- drivers/net/ethernet/intel/ice/ice_common.h | 3 +- drivers/net/ethernet/intel/ice/ice_ddp.c | 7 +-- 5 files changed, 55 insertions(+), 26 deletions(-)drivers/net/ethernet/intel/ice/ice_adapter.c +0
-0@@ -65,6 +65,7 @@ static struct ice_adapter *ice_adapter_new(struct pci_dev *pdev)for (int i =0 ; i <ARRAY_SIZE (adapter->cpi_phy_lock); i++)mutex_init (&adapter->cpi_phy_lock[i]);mutex_init (&adapter->rebuild_lock);...
Quoted 15 lines
drivers/net/ethernet/intel/ice/ice_adapter.c ice_aq_send_cmd(struct ice_hw *hw, struct · line 1899
Quoted 12 lines
/**
*ice_should_retry_sq_send_cmd
* @opcode: AQ opcodedrivers/net/ethernet/intel/ice/ice_adapter.c +2
-2@@ -1895,17 +1894,24 @@ ice_aq_send_cmd(struct ice_hw *hw, struct libie_aq_desc *desc, void *buf, u16 buf_size, struct ice_sq_cd *cd) {struct libie_aqc_req_res *cmd =libie_aq_raw (desc); -bool lock_acquired = false; -int status; +struct ice_pf *pf = hw->back; +struct ice_adapter *adapter = pf->adapter;
pf->adaptercan be NULL duringice_init_hw(), is it ok?
Patch 2/5 moves ice_adapter_get() and the pf->adapter assignment before ice_init_hw() in ice_probe(), and retains the reference until after hardware teardown. The reference is also retained across Tx-topology reinitialization and devlink reload, so pf->adapter is valid during ice_init_hw() with that patch applied.
Thanks for review,
Aaron
Quoted 23 lines
Quoted 14 lines
drivers/net/ethernet/intel/ice/ice_adapter.c +6
-0+ +if (READ_ONCE (adapter->global_cfg_owner) != current) { +guard (mutex)(&adapter->global_cfg_lock); +return ice_sq_send_cmd_retry (hw, &hw->adminq, desc, buf, + buf_size, cd); + }/* When a package download is in process (i.e. when the firmware's
* Global Configuration Lock resource is held), only the Download
* Package, Get Version, Get Package Info List, Upload Section,
* Update Package, Set Port Parameters, Get/Set VLAN Mode
Parameters,...
Quoted 5 lines
/* Since we triggered a CORER, re-initialize hardware */ ice_deinit_hw(hw); if (ice_init_hw(hw)) {--
2.53.0
Przemek Kitszel
maintainerRe: [PATCH 3/5] ice: scope global configuration lock to the adapter
In reply to Aaron MaQuoted 8 lines · Aaron Ma
ice_global_cfg_lock_swis a module-global mutex, so a package download on one E810 adapter blocks Admin Queue commands on unrelated adapters in the same system. In addition, the mutex is acquired only after firmware grants the Global Configuration Lock and dropped before firmware releases it, while the opcode exemption list inice_aq_send_cmd()does not check whether the caller is the lock owner. Non-owning PFs on the same adapter can therefore submit exempted Admin Queue commands or sideband requests while another PF holds firmware ownership.
This is not a bug to allow exempted commands, does not matter from which PF.
Quoted 4 lines
Move the software mutex to struct
ice_adapterand record the owning task across the entire Global Configuration Lock acquisition and release sequence, including the core reset path inice_cfg_tx_topo(). In
this is fine,
would be better to not track mutex holder
Quoted 7 lines
ice_aq_send_cmd(), require non-owning tasks to wait on the adapter mutex while allowing the owning task to issue the permitted configuration commands.Route the Admin Queue fallback in
ice_sbq_send_cmd()throughice_aq_send_cmd()as well.
perhaps this should be separate commit?
Quoted 8 lines
This patch depends on the previous patch in this series.
Fixes c76488109616 ("ice: Implement Dynamic Device Personalization (DDP) download")Signed-off-by Aaron Ma <[email protected]>
drivers/net/ethernet/intel/ice/ice_common.c ice_aq_send_cmd(struct ice_hw *hw, struct libie_aq_desc *desc, void *buf, · line 1898
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_common.c +2
-2@@ -1895,17 +1894,24 @@ ice_aq_send_cmd(struct ice_hw *hw, struct libie_aq_desc *desc, void *buf, u16 buf_size, struct ice_sq_cd *cd) { struct libie_aqc_req_res *cmd = libie_aq_raw(desc); -bool lock_acquired = false; -int status; +struct ice_pf *pf = hw->back; +struct ice_adapter *adapter = pf->adapter;
RCT violation
drivers/net/ethernet/intel/ice/ice_common.c ice_aq_send_cmd(struct ice_hw *hw, struct libie_aq_desc *desc, void *buf, · line 1901
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_common.c +3
-0+ +if (READ_ONCE (adapter->global_cfg_owner) != current) { +guard (mutex)(&adapter->global_cfg_lock);
no guard()()
especially here scoped_guard() fits nicely
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_common.c +3
-0+return ice_sq_send_cmd_retry (hw, &hw->adminq, desc, buf, + buf_size, cd); + }
Re: [PATCH 3/5] ice: scope global configuration lock to the adapter
Quoted 10 lines · Przemek Kitszel
Quoted 8 lines · Aaron Ma
ice_global_cfg_lock_swis a module-global mutex, so a package download on one E810 adapter blocks Admin Queue commands on unrelated adapters in the same system. In addition, the mutex is acquired only after firmware grants the Global Configuration Lock and dropped before firmware releases it, while the opcode exemption list inice_aq_send_cmd()does not check whether the caller is the lock owner. Non-owning PFs on the same adapter can therefore submit exempted Admin Queue commands or sideband requests while another PF holds firmware ownership.
Quoted 3 lines
This is not a bug to allow exempted commands, does not matter from which PF.
Its not strictly a "bug" but I do think it makes sense to only allow a single PF to send the set of configuration commands.
Quoted 8 lines
Quoted 4 lines
Move the software mutex to struct
ice_adapterand record the owning task across the entire Global Configuration Lock acquisition and release sequence, including the core reset path inice_cfg_tx_topo(). Inthis is fine,
would be better to not track mutex holder
Yea. I'm struggling to understand what the reason we need to track the owning task vs just having the lock.
Quoted 10 lines
Quoted 7 lines
ice_aq_send_cmd(), require non-owning tasks to wait on the adapter mutex while allowing the owning task to issue the permitted configuration commands.Route the Admin Queue fallback in
ice_sbq_send_cmd()throughice_aq_send_cmd()as well.perhaps this should be separate commit?
That might make it easier to review.. OTOH we also have been limited in how many patches we can get merged, so I could see the pressure for reducing the number where it reasonably makes sense...
Quoted 20 lines
Quoted 9 lines
This patch depends on the previous patch in this series.
Fixes c76488109616 ("ice: Implement Dynamic Device Personalization(DDP) download")
Signed-off-by Aaron Ma <[email protected]>drivers/net/ethernet/intel/ice/ice_common.c ice_aq_send_cmd(struct ice_hw *hw, struct · line 1899
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_common.c +2
-2@@ -1895,17 +1894,24 @@ ice_aq_send_cmd(struct ice_hw *hw, struct libie_aq_desc *desc, void *buf, u16 buf_size, struct ice_sq_cd *cd) { struct libie_aqc_req_res *cmd = libie_aq_raw(desc); - bool lock_acquired = false; - int status; + struct ice_pf *pf = hw->back; + struct ice_adapter *adapter = pf->adapter;RCT violation
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_common.c ice_aq_send_cmd(struct ice_hw *hw, struct libie_aq_desc *desc, void *buf, · line 1901
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_common.c +3
-0+ + if (READ_ONCE(adapter->global_cfg_owner) != current) { + guard(mutex)(&adapter->global_cfg_lock);no guard()()
especially herescoped_guard()fits nicely
Yes. guard() is not well liked by the maintainers, and I believe recently they have strengthened their preference against its use, but its at least documented as discouraged:
https://lore.kernel.org/netdev/[email protected]/
I thought recently there were some high profile issues caused by __free and/or guard() that strengthened this to a hard no but I can't find the emails.
Please stick to scoped_guard or regular bare lock/unlock where scoped_guard does not provide much benefit.
PATCH 4/5 ice: clear DVM boost table before scanning package hints
In reply to Aaron Maice_init_pkg_hints() clears hw->tnl before enumerating package labels, but leaves hw->dvm_upd untouched. Every subsequent call to ice_init_pkg() during reset recovery appends duplicate DVM and SVM boost entries to hw->dvm_upd.tbl[] until hw->dvm_upd.count saturates at ICE_DVM_MAX_ENTRIES (48).
During package download, ice_set_dvm_boost_entries() then issues a redundant Update Package Admin Queue command for every accumulated duplicate while holding the firmware Global Configuration Lock.
Zero hw->dvm_upd alongside hw->tnl before enumerating package hints.
--- drivers/net/ethernet/intel/ice/ice_ddp.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/ice/ice_ddp.c +1 -0
@@ -2101,6 +2101,7 @@ static void ice_init_pkg_hints(struct ice_hw *hw, struct ice_seg *ice_seg)int i;memset (&hw->tnl,0 ,sizeof (hw->tnl)); +memset (&hw->dvm_upd,0 ,sizeof (hw->dvm_upd));memset (&state,0 ,sizeof (state));if (!ice_seg)
Signature · 1 line
2.53.0
PATCH 5/5 ice: quiesce PTP periodic work before system suspend
In reply to Aaron Maice_suspend() stops the main service task but leaves PTP work active. The PTP kworker is not freezable, so it can continue issuing MMIO accesses after the PCI function has entered D3hot. Both the periodic work updating the cached PHC time and the E822 offset calibration work, which reschedules itself while calibration is pending, are affected.
Synchronously cancel both works when PTP is ready, after disabling the VSIs and before shutting down the control queues.
--- drivers/net/ethernet/intel/ice/ice_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/ice/ice_main.c +6 -0
@@ -5450,6 +5450,12 @@ static void ice_prepare_for_shutdown(struct ice_pf *pf)/* disable the VSIs and their queues that are not already DOWN */ ice_pf_dis_all_vsi (pf, false); +if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags) && + pf->ptp.state ==ICE_PTP_READY ) { +kthread_cancel_delayed_work_sync (&pf->ptp.work); +kthread_cancel_delayed_work_sync (&pf->ptp.port.ov_work); + } +ice_for_each_vsi (pf, v)if (pf->vsi[v]) pf->vsi[v]->vsi_num =0 ;
Signature · 1 line
2.53.0
RE: [PATCH 5/5] ice: quiesce PTP periodic work before system suspend
Quoted 53 lines
-----Original Message-----
From: Aaron Ma <[email protected]>
Sent: Monday, October 19, 2026 12:52 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Lobakin, Aleksander <[email protected]>; Richard Cochran <[email protected]>; [email protected]; [email protected]
Cc: Dan Nowlin <[email protected]>; Brett Creeley <[email protected]>; Keller, Jacob E <[email protected]>; moderated list:INTEL ETHERNET DRIVERS <[email protected]>
Subject: [PATCH 5/5] ice: quiesce PTP periodic work before system suspend
ice_suspend()stops the main service task but leaves PTP work active. The PTP kworker is not freezable, so it can continue issuing MMIO accesses after the PCI function has entered D3hot. Both the periodic work updating the cached PHC time and the E822 offset calibration work, which reschedules itself while calibration is pending, are affected.Synchronously cancel both works when PTP is ready, after disabling the VSIs and before shutting down the control queues.
Fixes 77a781155a65 ("ice: enable receive hardware timestamping")Fixes a69f1cb62aec ("ice: exit bypass mode once hardware finishestimestamp calibration")
Signed-off-by Aaron Ma <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/ethernet/intel/ice/ice_main.c +6
-0@@ -5450,6 +5450,12 @@ static void ice_prepare_for_shutdown(struct ice_pf *pf)/* disable the VSIs and their queues that are not already DOWN */ ice_pf_dis_all_vsi (pf ,false ); +if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags) && + pf->ptp.state ==ICE_PTP_READY ) { +kthread_cancel_delayed_work_sync (&pf->ptp.work); +kthread_cancel_delayed_work_sync (&pf->ptp.port.ov_work); + } +ice_for_each_vsi (pf, v)if (pf->vsi[v])
Quoted 3 lines
pf->vsi[v]->vsi_num = 0;
--
2.53.0
Re: [PATCH 5/5] ice: quiesce PTP periodic work before system suspend
In reply to Aaron MaQuoted 23 lines · Aaron Ma
ice_suspend()stops the main service task but leaves PTP work active. The PTP kworker is not freezable, so it can continue issuing MMIO accesses after the PCI function has entered D3hot. Both the periodic work updating the cached PHC time and the E822 offset calibration work, which reschedules itself while calibration is pending, are affected.Synchronously cancel both works when PTP is ready, after disabling the VSIs and before shutting down the control queues.
Fixes 77a781155a65 ("ice: enable receive hardware timestamping")Fixes a69f1cb62aec ("ice: exit bypass mode once hardware finishes timestamp calibration")Signed-off-by Aaron Ma <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/ethernet/intel/ice/ice_main.c +0
-0@@ -5450,6 +5450,12 @@ static void ice_prepare_for_shutdown(struct ice_pf *pf)/* disable the VSIs and their queues that are not already DOWN */ ice_pf_dis_all_vsi (pf, false);
drivers/net/ethernet/intel/ice/ice_main.c static void ice_prepare_for_shutdown(struct ice_pf *pf) · line 5461
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c +6
-0+if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags) && + pf->ptp.state ==ICE_PTP_READY ) { +kthread_cancel_delayed_work_sync (&pf->ptp.work); +kthread_cancel_delayed_work_sync (&pf->ptp.port.ov_work); + } +ice_for_each_vsi (pf, v)if (pf->vsi[v]) pf->vsi[v]->vsi_num =0 ;
I don't think kthread has the same API as workers to fully disable re-queueing, but at least the periodic work is only requeueud within its own run or by rebuild flows. ov_work I am not fully sure about, I guess it depends on if this can race with another thread that would re-schedule. I believe the PTP teardown also cancel the tasks but may happen later than needed? But maybe we lack a PTP flow for prepare_for_shutdown. Hmm.
This is at least better than what we do now so: