From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@kernel.org, andrew+netdev@lunn.ch, willemb@google.com,
netdev@vger.kernel.org
Cc: Tian Xun Ng <tianxun.ng@bytedance.com>,
anthony.l.nguyen@intel.com, oss.patchbox@gmail.com,
emil.s.tantilov@intel.com, richardcochran@gmail.com,
milena.olech@intel.com, konstantin.ilichev@intel.com,
stable@vger.kernel.org, Samuel Salin <Samuel.salin@intel.com>
Subject: [PATCH net 2/6] idpf: ignore Tx timestamp replies once removal has started
Date: Wed, 25 Nov 2026 14:51:39 -0800 [thread overview]
Message-ID: <20261125225145.4126333-3-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20261125225145.4126333-1-anthony.l.nguyen@intel.com>
From: Tian Xun Ng <tianxun.ng@bytedance.com>
On remove, idpf_vc_core_deinit() keeps the virtchnl transaction manager
up until the vports have been torn down, so mbx_task keeps processing
replies while idpf_ptp_release() frees the Tx timestamp trackers. An
async VIRTCHNL2_OP_PTP_GET_VPORT_TX_TSTAMP reply handled in that window
reaches idpf_ptp_get_tx_tstamp_async_handler(), which reads
vport->tx_tstamp_caps and takes its lock after
idpf_ptp_release_vport_tstamp() may already have freed it.
Once IDPF_REMOVE_IN_PROG is set, wait for a mailbox task that may be
running a callback before releasing anything, and make the Tx timestamp
callback return when the bit is set. Matched replies to synchronous
transactions are not affected, so the vport teardown still receives
them; mbx_task is requeued straight away for that.
The last patch of this series sets IDPF_REMOVE_IN_PROG on shutdown too,
which would otherwise expose shutdown to the same window.
Fixes: 1a49cf814fe1 ("idpf: add Tx timestamp flows")
Cc: stable@vger.kernel.org
Signed-off-by: Tian Xun Ng <tianxun.ng@bytedance.com>
Reviewed-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Samuel Salin <Samuel.salin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 12 +++++++++++-
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c | 3 ++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index c89783966bae..348c7875134a 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
@@ -3262,8 +3262,18 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter)
/* Avoid transaction timeouts when called during reset */
remove_in_prog = test_bit(IDPF_REMOVE_IN_PROG, adapter->flags);
- if (!remove_in_prog)
+ if (!remove_in_prog) {
libie_ctlq_xn_shutdown(adapter->xnm);
+ } else {
+ /* The transaction manager stays up for the teardown below, so
+ * async replies can still arrive. Wait for a mailbox task that
+ * may be running an async callback; callbacks that run later
+ * see IDPF_REMOVE_IN_PROG and leave the state released below
+ * alone.
+ */
+ cancel_delayed_work_sync(&adapter->mbx_task);
+ queue_delayed_work(adapter->mbx_wq, &adapter->mbx_task, 0);
+ }
idpf_ptp_release(adapter);
idpf_deinit_task(adapter);
diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
index 14dba40a993f..1422b30d09a3 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
@@ -550,7 +550,8 @@ idpf_ptp_get_tx_tstamp_async_handler(void *ctx, struct kvec *mem, int status)
u16 num_latches;
u32 vport_id;
- if (status)
+ /* The Tx timestamp trackers are released on remove and shutdown */
+ if (status || test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
return;
recv_tx_tstamp_msg = mem->iov_base;
--
2.47.1
next prev parent reply other threads:[~2026-11-25 22:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 22:51 [PATCH net 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) Tony Nguyen
2026-11-25 22:51 ` [PATCH net 1/6] idpf: Fix vport IRQ name leak on request failure Tony Nguyen
2026-11-25 22:51 ` Tony Nguyen [this message]
2026-11-25 22:51 ` [PATCH net 3/6] idpf: ignore link events once removal has started Tony Nguyen
2026-11-25 22:51 ` [PATCH net 4/6] idpf: keep the mailbox up while tearing down vports on shutdown Tony Nguyen
2026-11-25 22:51 ` [PATCH net 5/6] idpf: fix use-after-free in the PTP auxiliary worker Tony Nguyen
2026-11-25 22:51 ` [PATCH net 6/6] idpf: release PTP before freeing vports on the init task error path Tony Nguyen
2026-11-25 22:58 ` [PATCH net 0/6][pull request] Intel Wired LAN Driver Updates 2026-11-25 (idpf) netdev-bot+sinfo
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=20261125225145.4126333-3-anthony.l.nguyen@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=Samuel.salin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=emil.s.tantilov@intel.com \
--cc=konstantin.ilichev@intel.com \
--cc=kuba@kernel.org \
--cc=milena.olech@intel.com \
--cc=netdev@vger.kernel.org \
--cc=oss.patchbox@gmail.com \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tianxun.ng@bytedance.com \
--cc=willemb@google.com \
/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