From: xuanqiang.luo@linux.dev
To: intel-wired-lan@lists.osuosl.org, horms@kernel.org
Cc: vadim.fedorenko@linux.dev, anthony.l.nguyen@intel.com,
przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, richardcochran@gmail.com,
piotr.kwapulinski@intel.com, arkadiusz.kubalewski@intel.com,
aleksandr.loktionov@intel.com, netdev@vger.kernel.org,
Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Subject: [Intel-wired-lan] [PATCH iwl-net v2 3/5] i40e: synchronize reset recovery with device removal
Date: Wed, 5 Aug 2026 14:51:30 +0800 [thread overview]
Message-ID: <20260805065132.148625-4-xuanqiang.luo@linux.dev> (raw)
In-Reply-To: <20260805065132.148625-1-xuanqiang.luo@linux.dev>
From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
i40e_remove() currently tears down PTP and device resources before
claiming RESET_RECOVERY_PENDING. A service task can pass its initial state
check before removal starts and continue into reset recovery after the
remove path has begun teardown. This can make i40e_reset_and_rebuild()
access or recreate resources that are being released.
Stop the service timer and disable the service work before claiming reset
ownership. disable_work_sync() drains the current service task and rejects
later queue_work() attempts, including those from interrupts. Claim the
reset bit before starting teardown so an existing reset owner completes
first.
Fixes: 6533e558c650 ("i40e: Fix reset path while removing the driver")
Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
---
drivers/net/ethernet/intel/i40e/i40e_main.c | 28 ++++++++++-----------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 8c28788ac634f..5922f83f324ae 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -16159,6 +16159,20 @@ static void i40e_remove(struct pci_dev *pdev)
i40e_devlink_unregister(pf);
+ /* Interrupts can queue the service task until __I40E_DOWN is set.
+ * Disable it so no service work can outlive the PF.
+ */
+ set_bit(__I40E_SUSPENDED, pf->state);
+ if (pf->service_timer.function)
+ timer_shutdown_sync(&pf->service_timer);
+ if (pf->service_task.func)
+ disable_work_sync(&pf->service_task);
+
+ /* Wait for any reset owner before tearing down device resources. */
+ while (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, pf->state))
+ usleep_range(1000, 2000);
+ set_bit(__I40E_IN_REMOVE, pf->state);
+
i40e_dbg_pf_exit(pf);
i40e_ptp_stop(pf);
@@ -16167,26 +16181,12 @@ static void i40e_remove(struct pci_dev *pdev)
i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), 0);
i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), 0);
- /* Grab __I40E_RESET_RECOVERY_PENDING and set __I40E_IN_REMOVE
- * flags, once they are set, i40e_rebuild should not be called as
- * i40e_prep_for_reset always returns early.
- */
- while (test_and_set_bit(__I40E_RESET_RECOVERY_PENDING, pf->state))
- usleep_range(1000, 2000);
- set_bit(__I40E_IN_REMOVE, pf->state);
-
if (test_bit(I40E_FLAG_SRIOV_ENA, pf->flags)) {
set_bit(__I40E_VF_RESETS_DISABLED, pf->state);
i40e_free_vfs(pf);
clear_bit(I40E_FLAG_SRIOV_ENA, pf->flags);
}
- /* no more scheduling of any task */
- set_bit(__I40E_SUSPENDED, pf->state);
set_bit(__I40E_DOWN, pf->state);
- if (pf->service_timer.function)
- timer_shutdown_sync(&pf->service_timer);
- if (pf->service_task.func)
- cancel_work_sync(&pf->service_task);
if (test_bit(__I40E_RECOVERY_MODE, pf->state)) {
struct i40e_vsi *vsi = pf->vsi[0];
--
2.43.0
next prev parent reply other threads:[~2026-08-05 6:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 6:51 [Intel-wired-lan] [PATCH iwl-net v2 0/5] i40e: fix PTP work and teardown races xuanqiang.luo
2026-08-05 6:51 ` [Intel-wired-lan] [PATCH iwl-net v2 1/5] i40e: serialize Tx timestamp skb ownership xuanqiang.luo
2026-08-05 6:51 ` [Intel-wired-lan] [PATCH iwl-net v2 2/5] i40e: serialize timestamp configuration with PTP teardown xuanqiang.luo
2026-08-05 6:51 ` xuanqiang.luo [this message]
2026-08-05 6:51 ` [Intel-wired-lan] [PATCH iwl-net v2 4/5] i40e: replace reset polling with wait-bit synchronization xuanqiang.luo
2026-08-05 6:51 ` [Intel-wired-lan] [PATCH iwl-net v2 5/5] i40e: fix races in PTP external timestamp work handling xuanqiang.luo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260805065132.148625-4-xuanqiang.luo@linux.dev \
--to=xuanqiang.luo@linux.dev \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=luoxuanqiang@kylinos.cn \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=piotr.kwapulinski@intel.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox