ice: restore DDP state during PFR recovery
Subsystems (3)
PATCH v2 1/2 ice: restore DDP state during PFR recovery
The firmware package and switch recipes are shared by all PFs of an adapter. However, each PF rebuilds independently after system resume. The resulting package downloads and recipe updates can interleave, causing firmware timeouts and leaving interfaces unusable.
PFR also clears package-derived firmware state on affected devices. The existing PFR path only rebuilds the driver's block tables, so VLAN recipe programming can fail after the reset.
The failure is reported as:
ice 0000:04:00.0: Update pkg failed: err -5
ice 0000:04:00.0: package load failed, -12
ice 0000:04:00.0: Rebuild failed, unload and reload driver
This was observed on an Intel E810-XXV-2 adapter (PCI ID 8086:159b, revision 02) with NVM package 1.0.0.18 and ICE OS Default DDP package 1.3.43.0.
Serialize rebuilds across PFs of the same adapter, while allowing each PFR to complete independently. Reload the DDP package from its cached copy and restore the default DVM recipes before rebuilding the remaining PF state. Abort recovery if either operation fails.
In addition, stop the service task before tearing down resources in ice_remove() so that an in-flight rebuild completes and cannot dereference pf->adapter after ice_adapter_put().
---
v1 -> v2:
- Stop service task early in ice_remove() to prevent use-after-free on pf->adapter if rebuild is in flight.
drivers/net/ethernet/intel/ice/ice_adapter.c | 2 ++ drivers/net/ethernet/intel/ice/ice_adapter.h | 3 ++ drivers/net/ethernet/intel/ice/ice_main.c | 35 ++++++++++++++----- .../net/ethernet/intel/ice/ice_vlan_mode.c | 2 +- .../net/ethernet/intel/ice/ice_vlan_mode.h | 1 + 5 files changed, 34 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_adapter.c +2 -0
@@ -64,6 +64,7 @@ static struct ice_adapter *ice_adapter_new(struct pci_dev *pdev)spin_lock_init (&adapter->txq_ctx_lock);for (int i =0 ; i <ARRAY_SIZE (adapter->cpi_phy_lock); i++)mutex_init (&adapter->cpi_phy_lock[i]); +mutex_init (&adapter->rebuild_lock);refcount_set (&adapter->refcount,1 );mutex_init (&adapter->ports.lock);
@@ -77,6 +78,7 @@ static void ice_adapter_free(struct ice_adapter *adapter)WARN_ON (!list_empty (&adapter->ports.ports));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->ports.lock);kfree (adapter);
drivers/net/ethernet/intel/ice/ice_adapter.h +3 -0
@@ -37,6 +37,7 @@ struct ice_port_list {* @cpi_phy_lock: Per-PHY mutex serializing CPI REQ/ACK transactions. * 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 * @ports: Ports list * @index: 64-bit index cached for collision detection on 32bit systems */
@@ -48,6 +49,8 @@ struct ice_adapter {spinlock_t txq_ctx_lock;/* Serialize CPI REQ/ACK transactions per PHY (E825C only) */ struct mutex cpi_phy_lock[ICE_E825_MAX_PHYS ]; +/* Serialize PFR recovery touching shared FW global state */ +struct mutex rebuild_lock;struct ice_pf *ctrl_pf;struct ice_port_list ports;
drivers/net/ethernet/intel/ice/ice_main.c +27 -8
@@ -659,7 +659,9 @@ static void ice_do_reset(struct ice_pf *pf, enum ice_reset_req reset_type)*/ if (reset_type ==ICE_RESET_PFR ) { pf->pfr_count++; +mutex_lock (&pf->adapter->rebuild_lock);ice_rebuild (pf, reset_type); +mutex_unlock (&pf->adapter->rebuild_lock);clear_bit (ICE_PREPARED_FOR_RESET , pf->state);clear_bit (ICE_PFR_REQ , pf->state);wake_up (&pf->reset_wait_queue);
@@ -704,7 +706,9 @@ static void ice_reset_subtask(struct ice_pf *pf) }else {/* done with reset. start rebuild */ pf->hw.reset_ongoing = false; +mutex_lock (&pf->adapter->rebuild_lock);ice_rebuild (pf, reset_type); +mutex_unlock (&pf->adapter->rebuild_lock);/* clear bit to resume normal operations, but * ICE_NEEDS_RESTART bit is set in case rebuild failed */
@@ -5374,6 +5378,8 @@ static void ice_remove(struct pci_dev *pdev)return ; } +ice_service_task_stop (pf); +if (test_bit (ICE_FLAG_SRIOV_ENA , pf->flags)) {set_bit (ICE_VF_RESETS_DISABLED , pf->state);ice_free_vfs (pf);
@@ -7674,14 +7680,27 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) goto err_init_ctrlq; } -/* if DDP was previously loaded successfully */ -if (!ice_is_safe_mode (pf)) { -/* reload the SW DB of filter tables */ -if (reset_type ==ICE_RESET_PFR ) -ice_fill_blk_tbls (hw); -else -/* Reload DDP Package after CORER/GLOBR reset */ -ice_load_pkg (NULL , pf); +if (!ice_is_safe_mode (pf) && reset_type ==ICE_RESET_PFR ) { +enum ice_ddp_state state; + + state =ice_init_pkg (hw, hw->pkg_copy, hw->pkg_size); +ice_log_pkg_init (hw, state); +if (!ice_is_init_pkg_successful (state)) + goto err_init_ctrlq; + }else if (!ice_is_safe_mode (pf)) { +/* Reload DDP Package after CORER/GLOBR reset */ +ice_load_pkg (NULL , pf); + } + +/* PFR can lose DVM recipes after system suspend. */ +if (!ice_is_safe_mode (pf) && reset_type ==ICE_RESET_PFR && +ice_is_dvm_ena (hw)) { + err =ice_dvm_update_dflt_recipes (hw); +if (err) { +dev_err (dev,"failed to restore default DVM recipes: %d\n" , + err); + goto err_init_ctrlq; + } } err =ice_clear_pf_cfg (hw);
drivers/net/ethernet/intel/ice/ice_vlan_mode.c +1 -1
@@ -240,7 +240,7 @@ static struct ice_update_recipe_lkup_idx_params ice_dvm_dflt_recipes[] = {* ice_dvm_update_dflt_recipes - update default switch recipes in DVM * @hw: hardware structure used to update the recipes */ -static int ice_dvm_update_dflt_recipes (struct ice_hw *hw) +int ice_dvm_update_dflt_recipes (struct ice_hw *hw) {unsigned long i;
drivers/net/ethernet/intel/ice/ice_vlan_mode.h +1 -0
@@ -8,6 +8,7 @@ struct ice_hw;bool ice_is_dvm_ena (struct ice_hw *hw);int ice_set_vlan_mode (struct ice_hw *hw); +int ice_dvm_update_dflt_recipes (struct ice_hw *hw);void ice_post_pkg_dwnld_vlan_mode_cfg (struct ice_hw *hw);#endif /* _ICE_VLAN_MODE_H */
Signature · 1 line
2.43.0
PATCH v2 2/2 ice: clear Flow Director entries before reset cleanup
Flow Director profiles retain handles to generic flow entries. Reset calls ice_clear_hw_tbls() to free those entries, but leaves the Flow Director handles unchanged until replay replaces them.
If rebuild fails before replay completes, later driver removal follows a stale handle and dereferences a freed flow entry in ice_flow_rem_entry(). KASAN reports a wild access to list poison from ice_fdir_erase_flow_from_hw().
The failure is reported as:
KASAN: maybe wild-memory-access in range [0xdead000000000108-...] RIP: ice_flow_rem_entry+0xaf/0x170 [ice] ice_fdir_erase_flow_from_hw+0x1ee/0x420 [ice]
Clear the Flow Director handles while holding hw->fdir_fltr_lock before the hardware tables free their entries. A successful replay installs new handles, while a failed rebuild leaves them invalid for later cleanup.
---
v1 -> v2:
- Acquire hw->fdir_fltr_lock in ice_fdir_clear_flow_handles() to synchronize with concurrent ethtool filter add/del.
drivers/net/ethernet/intel/ice/ice.h | 1 + .../net/ethernet/intel/ice/ice_ethtool_fdir.c | 26 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 3 files changed, 29 insertions(+)
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -1029,6 +1029,7 @@ ice_get_fdir_fltr_ids(struct ice_hw *hw, struct ethtool_rxnfc *cmd, u32 *rule_locs);void ice_fdir_rem_adq_chnl (struct ice_hw *hw,u16 vsi_idx);void ice_fdir_release_flows (struct ice_hw *hw); +void ice_fdir_clear_flow_handles (struct ice_hw *hw);void ice_fdir_replay_flows (struct ice_hw *hw);void ice_fdir_replay_fltrs (struct ice_pf *pf);int ice_fdir_create_dflt_rules (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c +26 -0
@@ -428,6 +428,32 @@ void ice_fdir_release_flows(struct ice_hw *hw)ice_fdir_erase_flow_from_hw (hw,ICE_BLK_FD , flow); } +/** +* ice_fdir_clear_flow_handles - clear handles freed during reset +* @hw: pointer to HW instance +*/ +void ice_fdir_clear_flow_handles (struct ice_hw *hw) +{ +int flow; + +if (!hw->fdir_prof) +return ; + +mutex_lock (&hw->fdir_fltr_lock); +for (flow =0 ; flow <ICE_FLTR_PTYPE_MAX ; flow++) { +struct ice_fd_hw_prof *prof = hw->fdir_prof[flow]; +int tun, i; + +if (!prof) +continue ; + +for (tun =0 ; tun <ICE_FD_HW_SEG_MAX ; tun++) +for (i =0 ; i < prof->cnt; i++) + prof->entry_h[i][tun] =0 ; + } +mutex_unlock (&hw->fdir_fltr_lock); +} +/** * ice_fdir_replay_flows - replay HW Flow Director filter info * @hw: pointer to HW instance
drivers/net/ethernet/intel/ice/ice_main.c +2 -0
@@ -601,6 +601,8 @@ ice_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type)netif_device_detach (vsi->netdev); skip: +if (hw->fdir_prof) +ice_fdir_clear_flow_handles (hw);/* clear SW filtering DB */ ice_clear_hw_tbls (hw);/* disable the VSIs and their queues that are not already DOWN */
Signature · 1 line
2.43.0
RE: [PATCH v2 2/2] ice: clear Flow Director entries before reset cleanup
Quoted 116 lines
-----Original Message-----
From: Aaron Ma <[email protected]>
Sent: Monday, September 7, 2026 1: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]>; [email protected]; linux- [email protected]
Cc: Henry Tieman <[email protected]>; moderated list:INTEL ETHERNET DRIVERS <[email protected]>
Subject: [PATCH v2 2/2] ice: clear Flow Director entries before reset cleanupFlow Director profiles retain handles to generic flow entries. Reset calls
ice_clear_hw_tbls()to free those entries, but leaves the Flow Director handles unchanged until replay replaces them.If rebuild fails before replay completes, later driver removal follows a stale handle and dereferences a freed flow entry in
ice_flow_rem_entry().
KASAN reports a wild access to list poison fromice_fdir_erase_flow_from_hw().The failure is reported as:
KASAN: maybe wild-memory-access in range [0xdead000000000108-...] RIP: ice_flow_rem_entry+0xaf/0x170 [ice] ice_fdir_erase_flow_from_hw+0x1ee/0x420 [ice]Clear the Flow Director handles while holding
hw->fdir_fltr_lockbefore the hardware tables free their entries. A successful replay installs new handles, while a failed rebuild leaves them invalid for later cleanup.Fixes 148beb612031 ("ice: Initialize Flow Director resources")Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Aaron Ma <[email protected]>---
v1 -> v2:
- Acquirehw->fdir_fltr_lockinice_fdir_clear_flow_handles()to synchronize with concurrent ethtool filter add/del.drivers/net/ethernet/intel/ice/ice.h | 1 + .../net/ethernet/intel/ice/ice_ethtool_fdir.c | 26 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 3 files changed, 29 insertions(+)drivers/net/ethernet/intel/ice/ice.h +1
-0@@ -1029,6 +1029,7 @@ ice_get_fdir_fltr_ids(struct ice_hw *hw, struct ethtool_rxnfc *cmd, u32 *rule_locs);void ice_fdir_rem_adq_chnl (struct ice_hw *hw,u16 vsi_idx);void ice_fdir_release_flows (struct ice_hw *hw); +void ice_fdir_clear_flow_handles (struct ice_hw *hw);void ice_fdir_replay_flows (struct ice_hw *hw);void
ice_fdir_replay_fltrs(struct ice_pf *pf); intice_fdir_create_dflt_rules(struct ice_pf *pf); diff --gita/drivers/net/ethernet/intel/ice/ice_ethtool_fdir.cb/drivers/net/ethernet/intel/ice/ice_ethtool_fdir.cindexaceec184e89b2..04510b36aa56b100644drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c +25
-0@@ -428,6 +428,32 @@ void ice_fdir_release_flows(struct ice_hw *hw)ice_fdir_erase_flow_from_hw (hw,ICE_BLK_FD , flow); } +/** +* ice_fdir_clear_flow_handles - clear handles freed during reset +* @hw: pointer to HW instance +*/ +void ice_fdir_clear_flow_handles (struct ice_hw *hw) { +int flow; + +if (!hw->fdir_prof) +return ; + +mutex_lock (&hw->fdir_fltr_lock); +for (flow =0 ; flow <ICE_FLTR_PTYPE_MAX ; flow++) { +struct ice_fd_hw_prof *prof = hw->fdir_prof[flow]; +int tun, i; + +if (!prof) +continue ; + +for (tun =0 ; tun <ICE_FD_HW_SEG_MAX ; tun++) +for (i =0 ; i < prof->cnt; i++) + prof->entry_h[i][tun] =0 ; + } +mutex_unlock (&hw->fdir_fltr_lock); +} +/** * ice_fdir_replay_flows - replay HW Flow Director filter info * @hw: pointer to HW instance drivers/net/ethernet/intel/ice/ice_main.c +2
-0@@ -601,6 +601,8 @@ ice_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) netif_device_detach(vsi->netdev); skip: +if (hw->fdir_prof) +ice_fdir_clear_flow_handles (hw);/* clear SW filtering DB */ ice_clear_hw_tbls (hw);
Quoted 4 lines
/* disable the VSIs and their queues that are not already DOWN
*/
--
2.43.0
Re: [PATCH v2 2/2] ice: clear Flow Director entries before reset cleanup
In reply to Aaron MaQuoted 19 lines · Aaron Ma
Flow Director profiles retain handles to generic flow entries. Reset calls
ice_clear_hw_tbls()to free those entries, but leaves the Flow Director handles unchanged until replay replaces them.If rebuild fails before replay completes, later driver removal follows a stale handle and dereferences a freed flow entry in
ice_flow_rem_entry(). KASAN reports a wild access to list poison fromice_fdir_erase_flow_from_hw().The failure is reported as:
KASAN: maybe wild-memory-access in range [0xdead000000000108-...] RIP: ice_flow_rem_entry+0xaf/0x170 [ice] ice_fdir_erase_flow_from_hw+0x1ee/0x420 [ice]Clear the Flow Director handles while holding
hw->fdir_fltr_lockbefore the hardware tables free their entries. A successful replay installs new handles, while a failed rebuild leaves them invalid for later cleanup.
Quoted 7 lines
Fixes 148beb612031 ("ice: Initialize Flow Director resources")Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Aaron Ma <[email protected]>---
v1 -> v2:
- Acquirehw->fdir_fltr_lockinice_fdir_clear_flow_handles()to synchronize with concurrent ethtool filter add/del.
RE: [PATCH v2 2/2] ice: clear Flow Director entries before reset cleanup
In reply to Aaron MaQuoted 11 lines
-----Original Message-----
From: Aaron Ma <[email protected]>
Sent: 07 September 2026 17:22
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]>; [email protected]; [email protected]
Cc: Henry Tieman <[email protected]>; moderated list:INTEL ETHERNET DRIVERS <[email protected]>
Subject: [PATCH v2 2/2] ice: clear Flow Director entries before reset cleanupFlow Director profiles retain handles to generic flow entries. Reset calls
ice_clear_hw_tbls()to free those entries, but leaves the Flow Director handles unchanged until replay replaces them.If rebuild fails before replay completes, later driver removal follows a stale handle and dereferences a freed flow entry in
ice_flow_rem_entry().
KASAN reports a wild access to list poison from ice_fdir_erase_flow_from_hw().
Quoted 17 lines
The failure is reported as:
KASAN: maybe wild-memory-access in range [0xdead000000000108-...] RIP: ice_flow_rem_entry+0xaf/0x170 [ice] ice_fdir_erase_flow_from_hw+0x1ee/0x420 [ice]Clear the Flow Director handles while holding
hw->fdir_fltr_lockbefore the hardware tables free their entries. A successful replay installs new handles, while a failed rebuild leaves them invalid for later cleanup.Fixes 148beb612031 ("ice: Initialize Flow Director resources")Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Aaron Ma <[email protected]>---
v1 -> v2:
- Acquirehw->fdir_fltr_lockinice_fdir_clear_flow_handles()to synchronize with concurrent ethtool filter add/del.
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice.h | 1 + .../net/ethernet/intel/ice/ice_ethtool_fdir.c | 26 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 3 files changed, 29 insertions(+)
Quoted 212 lines
-----Original Message-----
From: Aaron Ma <[email protected]>
Sent: Monday, September 7, 2026 1: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]>; [email protected]; linux- [email protected]
Cc: Henry Tieman <[email protected]>; moderated list:INTEL ETHERNET DRIVERS <[email protected]>
Subject: [PATCH v2 1/2] ice: restore DDP state during PFR recoveryThe firmware package and switch recipes are shared by all PFs of an adapter. However, each PF rebuilds independently after system resume. The resulting package downloads and recipe updates can interleave, causing firmware timeouts and leaving interfaces unusable.
PFR also clears package-derived firmware state on affected devices. The existing PFR path only rebuilds the driver's block tables, so VLAN recipe programming can fail after the reset.
The failure is reported as:
ice 0000:04:00.0: Update pkg failed: err -5
ice 0000:04:00.0: package load failed, -12
ice 0000:04:00.0: Rebuild failed, unload and reload driverThis was observed on an Intel E810-XXV-2 adapter (PCI ID 8086:159b, revision 02) with NVM package 1.0.0.18 and ICE OS Default DDP package 1.3.43.0.
Serialize rebuilds across PFs of the same adapter, while allowing each PFR to complete independently. Reload the DDP package from its cached copy and restore the default DVM recipes before rebuilding the remaining PF state.
Abort recovery if either operation fails.In addition, stop the service task before tearing down resources in
ice_remove()so that an in-flight rebuild completes and cannot dereferencepf->adapterafterice_adapter_put().Fixes 462acf6aca85 ("ice: Enable DDP package download")Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Aaron Ma <[email protected]>---
v1 -> v2:
- Stop service task early inice_remove()to prevent use-after-free onpf->adapterif rebuild is in flight.drivers/net/ethernet/intel/ice/ice_adapter.c | 2 ++ drivers/net/ethernet/intel/ice/ice_adapter.h | 3 ++ drivers/net/ethernet/intel/ice/ice_main.c | 35 ++++++++++++++----(quoted diff) +0
-1- .../net/ethernet/intel/ice/ice_vlan_mode.c | 2 +- .../net/ethernet/intel/ice/ice_vlan_mode.h | 1 + 5 files changed, 34 insertions(+), 9 deletions(-)drivers/net/ethernet/intel/ice/ice_adapter.c +1
-0@@ -64,6 +64,7 @@ static struct ice_adapter *ice_adapter_new(struct pci_dev *pdev) spin_lock_init(&adapter->txq_ctx_lock);for (int i =0 ; i <ARRAY_SIZE (adapter->cpi_phy_lock); i++)mutex_init (&adapter->cpi_phy_lock[i]); +mutex_init (&adapter->rebuild_lock);refcount_set (&adapter->refcount,1 );drivers/net/ethernet/intel/ice/ice_adapter.c +1
-0mutex_init (&adapter->ports.lock);@@ -77,6 +78,7 @@ static void ice_adapter_free(struct ice_adapter *adapter)WARN_ON (!list_empty (&adapter->ports.ports));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->ports.lock);drivers/net/ethernet/intel/ice/ice_adapter.c +0
-0kfree (adapter);drivers/net/ethernet/intel/ice/ice_adapter.h +0
-0@@ -37,6 +37,7 @@ struct ice_port_list {* @cpi_phy_lock: Per-PHY mutex serializing CPI REQ/ACK transactions. * 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
* @ports: Ports list
* @index: 64-bit index cached for collision detection on 32bit
systems
*/drivers/net/ethernet/intel/ice/ice_adapter.h +2
-0@@ -48,6 +49,8 @@ struct ice_adapter {spinlock_t txq_ctx_lock;/* Serialize CPI REQ/ACK transactions per PHY (E825C only) */ struct mutex cpi_phy_lock[ICE_E825_MAX_PHYS ]; +/* Serialize PFR recovery touching shared FW global state */ +struct mutex rebuild_lock;struct ice_pf *ctrl_pf;struct ice_port_list ports;drivers/net/ethernet/intel/ice/ice_main.c +2
-0@@ -659,7 +659,9 @@ static void ice_do_reset(struct ice_pf *pf, enumice_reset_req reset_type) */ if (reset_type ==ICE_RESET_PFR ) { pf->pfr_count++; +mutex_lock (&pf->adapter->rebuild_lock);ice_rebuild (pf, reset_type); +mutex_unlock (&pf->adapter->rebuild_lock);clear_bit (ICE_PREPARED_FOR_RESET , pf->state);clear_bit (ICE_PFR_REQ , pf->state);drivers/net/ethernet/intel/ice/ice_main.c +2
-0wake_up (&pf->reset_wait_queue);@@ -704,7 +706,9 @@ static void ice_reset_subtask(struct ice_pf *pf) }else {/* done with reset. start rebuild */ pf->hw.reset_ongoing = false; +mutex_lock (&pf->adapter->rebuild_lock);ice_rebuild (pf, reset_type); +mutex_unlock (&pf->adapter->rebuild_lock);/* clear bit to resume normal operations, but * ICE_NEEDS_RESTART bit is set in case rebuild failed
drivers/net/ethernet/intel/ice/ice_main.c +23
-8*/ @@ -5374,6 +5378,8 @@ static void ice_remove(struct pci_dev *pdev)return ; } +ice_service_task_stop (pf); +if (test_bit (ICE_FLAG_SRIOV_ENA , pf->flags)) {set_bit (ICE_VF_RESETS_DISABLED , pf->state);ice_free_vfs (pf);@@ -7674,14 +7680,27 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) goto err_init_ctrlq; } -/* if DDP was previously loaded successfully */ -if (!ice_is_safe_mode (pf)) { -/* reload the SW DB of filter tables */ -if (reset_type ==ICE_RESET_PFR ) -ice_fill_blk_tbls (hw); -else -/* Reload DDP Package after CORER/GLOBR reset */ -ice_load_pkg (NULL , pf); +if (!ice_is_safe_mode (pf) && reset_type ==ICE_RESET_PFR ) { +enum ice_ddp_state state; + + state =ice_init_pkg (hw, hw->pkg_copy, hw->pkg_size); +ice_log_pkg_init (hw, state); +if (!ice_is_init_pkg_successful (state)) + goto err_init_ctrlq; + }else if (!ice_is_safe_mode (pf)) { +/* Reload DDP Package after CORER/GLOBR reset */ +ice_load_pkg (NULL , pf); + } + +/* PFR can lose DVM recipes after system suspend. */ +if (!ice_is_safe_mode (pf) && reset_type ==ICE_RESET_PFR && +ice_is_dvm_ena (hw)) { + err =ice_dvm_update_dflt_recipes (hw); +if (err) { +dev_err (dev,"failed to restore default DVM recipes: %d\n", + err); + goto err_init_ctrlq; + } }drivers/net/ethernet/intel/ice/ice_main.c +0
-0err =ice_clear_pf_cfg (hw);drivers/net/ethernet/intel/ice/ice_vlan_mode.c +1
-1@@ -240,7 +240,7 @@ static struct ice_update_recipe_lkup_idx_paramsice_dvm_dflt_recipes[] = { * ice_dvm_update_dflt_recipes - update default switch recipes in DVM * @hw: hardware structure used to update the recipes */ -static int ice_dvm_update_dflt_recipes (struct ice_hw *hw) +int ice_dvm_update_dflt_recipes (struct ice_hw *hw) {unsigned long i;drivers/net/ethernet/intel/ice/ice_vlan_mode.h +1
-1@@ -8,6 +8,7 @@ struct ice_hw;bool ice_is_dvm_ena (struct ice_hw *hw);int ice_set_vlan_mode (struct ice_hw *hw); +int ice_dvm_update_dflt_recipes (struct ice_hw *hw);void ice_post_pkg_dwnld_vlan_mode_cfg (struct ice_hw *hw);#endif /* _ICE_VLAN_MODE_H */ --
Quoted 1 line
2.43.0
Quoted 28 lines · Aaron Ma
The firmware package and switch recipes are shared by all PFs of an adapter. However, each PF rebuilds independently after system resume. The resulting package downloads and recipe updates can interleave, causing firmware timeouts and leaving interfaces unusable.
PFR also clears package-derived firmware state on affected devices. The existing PFR path only rebuilds the driver's block tables, so VLAN recipe programming can fail after the reset.
The failure is reported as:
ice 0000:04:00.0: Update pkg failed: err -5
ice 0000:04:00.0: package load failed, -12
ice 0000:04:00.0: Rebuild failed, unload and reload driverThis was observed on an Intel E810-XXV-2 adapter (PCI ID 8086:159b, revision 02) with NVM package 1.0.0.18 and ICE OS Default DDP package 1.3.43.0.
Serialize rebuilds across PFs of the same adapter, while allowing each PFR to complete independently. Reload the DDP package from its cached copy and restore the default DVM recipes before rebuilding the remaining PF state. Abort recovery if either operation fails.
In addition, stop the service task before tearing down resources in
ice_remove()so that an in-flight rebuild completes and cannot dereferencepf->adapterafterice_adapter_put().
Quoted 7 lines
Fixes 462acf6aca85 ("ice: Enable DDP package download")Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Aaron Ma <[email protected]>---
v1 -> v2:
- Stop service task early inice_remove()to prevent use-after-free onpf->adapterif rebuild is in flight.
Thanks for the update.
Quoted 34 lines
-----Original Message-----
From: Aaron Ma <[email protected]>
Sent: 07 September 2026 17:22
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]>; [email protected]; [email protected]
Cc: Henry Tieman <[email protected]>; moderated list:INTEL ETHERNET DRIVERS <[email protected]>
Subject: [PATCH v2 1/2] ice: restore DDP state during PFR recoveryThe firmware package and switch recipes are shared by all PFs of an adapter. However, each PF rebuilds independently after system resume. The resulting package downloads and recipe updates can interleave, causing firmware timeouts and leaving interfaces unusable.
PFR also clears package-derived firmware state on affected devices. The existing PFR path only rebuilds the driver's block tables, so VLAN recipe programming can fail after the reset.
The failure is reported as:
ice 0000:04:00.0: Update pkg failed: err -5
ice 0000:04:00.0: package load failed, -12
ice 0000:04:00.0: Rebuild failed, unload and reload driverThis was observed on an Intel E810-XXV-2 adapter (PCI ID 8086:159b, revision 02) with NVM package 1.0.0.18 and ICE OS Default DDP package 1.3.43.0.
Serialize rebuilds across PFs of the same adapter, while allowing each PFR to complete independently. Reload the DDP package from its cached copy and restore the default DVM recipes before rebuilding the remaining PF state. Abort recovery if either operation fails.
In addition, stop the service task before tearing down resources in
ice_remove()so that an in-flight rebuild completes and cannot dereferencepf->adapterafterice_adapter_put().Fixes 462acf6aca85 ("ice: Enable DDP package download")Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Aaron Ma <[email protected]>---
v1 -> v2:
- Stop service task early inice_remove()to prevent use-after-free onpf->adapterif rebuild is in flight.
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_adapter.c | 2 ++ drivers/net/ethernet/intel/ice/ice_adapter.h | 3 ++ drivers/net/ethernet/intel/ice/ice_main.c | 35 ++++++++++++++----- .../net/ethernet/intel/ice/ice_vlan_mode.c | 2 +- .../net/ethernet/intel/ice/ice_vlan_mode.h | 1 + 5 files changed, 34 insertions(+), 9 deletions(-)