From: "Tantilov, Emil S" <emil.s.tantilov@intel.com>
To: <netdev-bot+sashiko@kernel.org>, <anthony.l.nguyen@intel.com>
Cc: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
<edumazet@kernel.org>, <andrew+netdev@lunn.ch>,
<willemb@google.com>, <netdev@vger.kernel.org>,
<tianxun.ng@bytedance.com>, <oss.patchbox@gmail.com>,
<richardcochran@gmail.com>, <milena.olech@intel.com>,
<konstantin.ilichev@intel.com>, <stable@vger.kernel.org>,
<Samuel.salin@intel.com>
Subject: Re: [PATCH net 4/6] idpf: keep the mailbox up while tearing down vports on shutdown
Date: Fri, 4 Dec 2026 09:22:51 -0800 [thread overview]
Message-ID: <17b90ff9-b944-4f80-9d22-8c0b58e9a171@intel.com> (raw)
In-Reply-To: <179573641346.3135.10145335142730257135@kernel.org>
On 11/26/2026 3:40 PM, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 6 potential
> issue(s) to consider.
>
> Critical: 0 · High: 1 · Medium: 3 · Low: 2
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [High] The fix still misses its target when the control plane is slow
> but alive.
> - [Medium] During shutdown, idpf_wait_for_marker_event_set() computes
> wait_all as false, because vc_xn_timeout_ms is 500 or 0, below…
> - [Medium] The 500 ms cap and the sticky zero apply to the whole adapter,
> but idpf_shutdown() shortens the timeout before every other mailbox…
> - [Medium] The shutdown path can now free the mailbox rings while a
> control-plane reply is still pending, and the mailbox queues stay…
> - [Low] The new kernel-doc for idpf_send_mb_msg() in
> drivers/net/ethernet/intel/idpf/idpf_virtchnl.c says -ETIMEDOUT is…
> - [Low] The struct idpf_adapter kernel-doc for @vc_xn_timeout_ms
> (drivers/net/ethernet/intel/idpf/idpf.h) says the field is "set to 0…
>
> --
>
> idpf: keep the mailbox up while tearing down vports on shutdown
>
> This patch sets IDPF_REMOVE_IN_PROG at the start of idpf_shutdown(). The
> vports are then torn down while the virtchnl transaction manager is still
> up, so the device is told to disable and destroy them before reboot. Each
> teardown transaction is capped at 500 ms through a new
> adapter->vc_xn_timeout_ms, later synchronous sends fail at once after a
> capped one times out, and after one SW marker is missed the remaining
> marker waits of that vport are skipped.
>
>> diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h
>> index f214023095ee7..533b069d97f94 100644
>> --- a/drivers/net/ethernet/intel/idpf/idpf.h
>> +++ b/drivers/net/ethernet/intel/idpf/idpf.h
>
> [ ... ]
>
>> @@ -635,6 +635,8 @@ struct idpf_edt_caps_ilog2 {
>> * @asq: Send control queue info
>> * @arq: Receive control queue info
>> * @xnm: Xn transaction manager
>> + * @vc_xn_timeout_ms: Upper bound for each Xn transaction timeout, shortened
>> + * on shutdown and set to 0 once a shortened one timed out
>
> [Severity: Low]
> This isn't a bug, but is this description accurate for async transactions?
>
> The only code that writes 0 is in idpf_send_mb_msg(), and it runs only
> when the synchronous libie_ctlq_xn_send() returns -ETIMEDOUT.
>
> Async transactions with resp_cb set also get the shortened cap through
> min_t(). Examples are the MAC filter, promiscuous and PTP Tx timestamp
> async handlers. For those, libie_ctlq_xn_send() returns 0 right after
> posting. Their timeout is reported later through resp_cb, which never
> touches vc_xn_timeout_ms.
>
> The idpf_send_mb_msg() kernel-doc says "synchronous". Should this one say
> it too?
>
> [ ... ]
>
>> diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c
>> index 129bccaa6baa8..21be83dc82b1b 100644
>> --- a/drivers/net/ethernet/intel/idpf/idpf_main.c
>> +++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
>> @@ -194,8 +194,18 @@ static void idpf_shutdown(struct pci_dev *pdev)
>> {
>> struct idpf_adapter *adapter = pci_get_drvdata(pdev);
>>
>> + /* As in idpf_remove(): keep the event task from being requeued, and
>> + * destroy the vports while the mailbox is still up.
>> + */
>> + set_bit(IDPF_REMOVE_IN_PROG, adapter->flags);
>> cancel_delayed_work_sync(&adapter->serv_task);
>> cancel_delayed_work_sync(&adapter->vc_event_task);
>> +
>> + /* Bound the teardown transactions started from here on, so that an
>> + * unresponsive control plane costs a single timeout. A reset or a
>> + * transaction that is already running keeps its own timeouts.
>> + */
>> + WRITE_ONCE(adapter->vc_xn_timeout_ms, IDPF_VC_XN_SHUTDOWN_TIMEOUT_MSEC);
>
> [Severity: Medium]
> Can a transaction that has nothing to do with the teardown pick up the
> 500 ms cap here and latch vc_xn_timeout_ms to 0?
>
> Only serv_task and vc_event_task are cancelled before this write.
> init_task and stats_task are cancelled later, inside idpf_deinit_task():
>
> idpf_deinit_task() {
> cancel_delayed_work_sync(&adapter->init_task);
> ...
> cancel_delayed_work_sync(&adapter->stats_task);
> ...
> }
>
> idpf_init_task() never checks IDPF_REMOVE_IN_PROG. Any message it sends
> in this window, such as idpf_send_create_vport_msg(), gets the 500 ms cap.
>
> In idpf_statistics_task(), the new test_bit(IDPF_REMOVE_IN_PROG) check
> and the READ_ONCE(adapter->vc_xn_timeout_ms) in idpf_send_mb_msg() are
> separate reads. A worker can pass the bit check before set_bit() and then
> read the timeout after this WRITE_ONCE(). That GET_STATS is then sent with
> the 500 ms cap.
>
> If either of these times out, idpf_send_mb_msg() writes 0. Once
> cancel_delayed_work_sync() returns in idpf_deinit_task(), every vport
> teardown message (DISABLE_VPORT, DISABLE_QUEUES, DEL_QUEUES,
> DESTROY_VPORT) then fails at once and nothing is sent.
>
> The commit message says "A request it already has waiting ... keeps its
> own timeouts". Does that also hold for a stats worker that is past the
> flag check but has not read the timeout yet? What about init_task, which
> has no flag check at all?
>
>> idpf_vc_core_deinit(adapter);
>> idpf_deinit_dflt_mbx(adapter);
Not from init_task. It is queued only by idpf_vc_core_init(), from
vc_event_task, and by itself while it creates the default vports.
idpf_init_hard_reset() does not return until init_task clears
IDPF_HR_RESET_IN_PROG, and idpf_shutdown() waits for vc_event_task
before lowering the cap, so init_task has sent its last message by then.
A stats worker past the flag check can send one more GET_STATS with the
cap, as can any other sender still running; the commit message refers to
requests that are already waiting. That sets the cap to 0 only if the CP
takes longer than 500 ms to answer, the slow CP case below.
>
> [Severity: Medium]
> Can the mailbox rings be freed here while the control plane still owes a
> reply, with the mailbox queues still enabled in hardware?
>
> Before this patch, libie_ctlq_xn_shutdown() ran first on shutdown, so no
> teardown message was ever posted. Now the messages are posted with a
> 500 ms cap, and once one times out the rest fail right away. The code then
> reaches idpf_deinit_dflt_mbx() almost at once:
>
> idpf_deinit_dflt_mbx() {
> ...
> if (adapter->xnm) {
> libie_ctlq_xn_shutdown(adapter->xnm);
> idpf_mb_clean(adapter->asq, true);
> libie_ctlq_xn_deinit(adapter->xnm, &adapter->ctlq_ctx);
> }
> ...
> }
>
> libie_ctlq_xn_deinit()->libie_ctlq_deinit()->libie_ctlq_remove()->
> libie_ctlq_dealloc_ring_res() frees the ARQ and ASQ descriptor rings and
> the ARQ buffers.
>
> Nothing in libie/controlq.c ever clears the len/enable or base address
> registers; libie_ctlq_init_regs() is the only place that writes them.
> idpf_remove() calls trigger_reset(adapter, IDPF_HR_FUNC_RESET) before
> idpf_deinit_dflt_mbx(), but idpf_shutdown() does not.
>
> If the reply to the timed-out request arrives late, could the device write
> a descriptor and payload into the freed ARQ memory, or read a freed ASQ
> send buffer?
This was already the case prior to this patch and this patch narrows it:
requests already in flight are now waited out, and with a CP that
answers within the cap every teardown reply arrives before
idpf_deinit_dflt_mbx(). Only a CP slower than the cap can leave a reply
outstanding, the trade-off described below. Resetting the function on
shutdown would be a separate change.
>
>>
> [ ... ]
>
>> diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
>> index 854eb1f1ada4c..e7a8ccbc35857 100644
>> --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
>> +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
>> @@ -195,20 +195,32 @@ static void idpf_prepare_ptp_mb_msg(struct idpf_adapter *adapter, u32 op,
>> * Cleanup the mailbox queue entries of the previously sent message to
>> * unmap and release the buffer.
>> *
>> + * The transaction timeout is capped at adapter->vc_xn_timeout_ms. Once a
>> + * synchronous transaction with a shortened timeout times out, later ones
>> + * fail at once instead of waiting again.
>> + *
>> * Return: 0 if the request was successful, -%EBUSY if reset is detected
>> - * or Tx control queue is full, other negative error code on failure.
>> + * or Tx control queue is full, -%ETIMEDOUT if a shortened transaction
>> + * already timed out, other negative error code on failure.
>
> [Severity: Low]
> This isn't a bug, but this text ties -ETIMEDOUT only to the early-fail
> case where nothing is sent.
>
> The function also passes back -ETIMEDOUT from libie_ctlq_xn_send() when
> the transaction it just sent gets no reply in time. That can happen with
> any timeout, including the default 60 s.
>
> Should the doc mention both meanings, "message never sent" and "message
> sent, no reply"?
>
>> */
>> int idpf_send_mb_msg(struct idpf_adapter *adapter,
>> struct libie_ctlq_xn_send_params *xn_params,
>> void *send_buf, size_t send_buf_size)
>> {
>> + u32 timeout_ms = READ_ONCE(adapter->vc_xn_timeout_ms);
>> struct libie_ctlq_msg ctlq_msg = {};
>> + int err = 0;
>>
>> - if (idpf_is_reset_detected(adapter)) {
>> + if (idpf_is_reset_detected(adapter))
>> + err = -EBUSY;
>> + else if (!timeout_ms)
>> + err = -ETIMEDOUT;
>> +
>> + if (err) {
>> if (!libie_cp_can_send_onstack(send_buf_size))
>> kfree(send_buf);
>>
>> - return -EBUSY;
>> + return err;
>> }
>
> [ ... ]
>
>> @@ -219,10 +231,15 @@ int idpf_send_mb_msg(struct idpf_adapter *adapter,
>> xn_params->xnm = adapter->xnm;
>> xn_params->ctlq = xn_params->ctlq ? xn_params->ctlq : adapter->asq;
>> xn_params->rel_tx_buf = kfree;
>> + xn_params->timeout_ms = min_t(u64, xn_params->timeout_ms, timeout_ms);
>>
>> idpf_mb_clean(xn_params->ctlq, false);
>>
>> - return libie_ctlq_xn_send(xn_params);
>> + err = libie_ctlq_xn_send(xn_params);
>> + if (err == -ETIMEDOUT && timeout_ms < IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC)
>> + WRITE_ONCE(adapter->vc_xn_timeout_ms, 0);
>
> [Severity: High]
> Can a control plane that is slow but still alive leave the device in the
> same state this commit sets out to fix?
>
> The first synchronous transaction that takes longer than 500 ms during
> shutdown sets vc_xn_timeout_ms to 0 for good. From then on, every
> idpf_send_mb_msg() takes the new early return above. Nothing is posted to
> the ASQ, nothing is logged, and nothing resets the value.
>
> idpf_vport_stop() ignores these return values and frees the rings anyway:
>
> idpf_vport_stop() {
> ...
> idpf_send_disable_vport_msg(adapter, vport_id);
> idpf_send_disable_queues_msg(vport);
> idpf_send_map_unmap_queue_vector_msg(adapter, rsrc, vport_id, false);
> ...
> idpf_vport_queues_rel(vport, rsrc);
> ...
> }
>
> idpf_deinit_task() tears the vports down one after another. A single
> timeout on an early vport, for example on DISABLE_VPORT, also suppresses
> DISABLE_QUEUES, DEL_QUEUES and DESTROY_VPORT for that vport, plus the
> whole teardown of every later vport. The device keeps those queues enabled
> over freed rings.
>
> If DISABLE_QUEUES itself is the one that times out,
> idpf_send_disable_queues_msg() returns before the marker wait:
>
> err = idpf_send_ena_dis_queues_msg(vport->adapter,
> &vport->dflt_qv_rsrc,
> vport->vport_id, false);
> if (err)
> return err;
>
> return idpf_wait_for_marker_event(vport);
>
> The rings are then freed while the CP may still be processing the request
> and writing markers into them.
>
> The commit message measures the slowest transaction (DEALLOC_VECTORS) at
> about 300 ms on an idle system, against the 500 ms cap. It accepts an
> incomplete teardown only for a control plane that dies.
>
> Would a larger cap, a cap that does not stick at 0, or an overall time
> budget for the teardown avoid this?
Yes, if it takes longer than the cap to answer one teardown message: the
rest of the teardown is then skipped. That is no worse than before this
patch, when none of these messages were sent on shutdown. A larger cap,
a cap that does not stick at 0, or a time budget would each let a CP
that does not answer hold up the reboot longer, which is what the cap
bounds. 500 ms is above the slowest transaction measured (~300 ms).
Since the goal here is to both send the messages to the CP and not hog
the shutdown process should the CP becomes unresponsive, or is just not
there at all, this patch seems like a decent compromise on both sides.
DEL_QUEUES is not sent on shutdown, only after a soft reset sets
IDPF_VPORT_DEL_QUEUES.
>
>> +
>> + return err;
>> }
>>
>> /**
>> @@ -372,6 +389,11 @@ static int idpf_wait_for_marker_event_set(const struct idpf_queue_set *qs)
>> struct net_device *netdev;
>> struct idpf_tx_queue *txq;
>> bool markers_rcvd = true;
>> + bool wait_all;
>> +
>> + /* On shutdown, once one marker is missing, don't wait for the rest */
>> + wait_all = READ_ONCE(qs->adapter->vc_xn_timeout_ms) >=
>> + IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC;
>>
>> for (u32 i = 0; i < qs->num; i++) {
>> switch (qs->qs[i].type) {
>> @@ -381,7 +403,8 @@ static int idpf_wait_for_marker_event_set(const struct idpf_queue_set *qs)
>> netdev = txq->netdev;
>>
>> idpf_queue_set(SW_MARKER, txq);
>> - idpf_wait_for_sw_marker_completion(txq);
>> + if (markers_rcvd || wait_all)
>> + idpf_wait_for_sw_marker_completion(txq);
>
> [Severity: Medium]
> What happens to markers that are late rather than lost on the queues that
> are skipped here?
>
> During shutdown, wait_all is false for the whole teardown, because
> vc_xn_timeout_ms is 500 or 0. Once one Tx queue misses its
> IDPF_WAIT_FOR_MARKER_TIMEO window, the remaining Tx queues of the vport
> are never polled. Their SW_MARKER bits stay set and their completion
> queues are not drained.
>
> idpf_vport_stop() then carries on and frees the completion rings, while
> DESTROY_VPORT is sent only later from idpf_vport_rel():
>
> idpf_vport_intr_deinit(vport, rsrc);
> idpf_xdp_rxq_info_deinit_all(rsrc);
> idpf_vport_queues_rel(vport, rsrc);
>
> Before this patch, each queue got its own wait, so markers that arrived up
> to N times the marker timeout late were still consumed before the rings
> were freed.
>
> If a remaining marker arrives late on a completion queue other than the
> one that was polled, can the device write it into a completion ring that
> has already been freed? The commit message describes the shortcut as
> intended, but it does not cover late markers.
Before this patch shutdown sent no DISABLE_QUEUES at all: the
transaction manager was shut down first, idpf_send_disable_queues_msg()
returned before the marker wait, and the rings were freed with the
queues enabled. On every other path vc_xn_timeout_ms stays at the
default, wait_all is true and nothing changes.
The rings are freed after a bounded wait on every path, and a marker
later than that wait lands in a freed ring. On shutdown the wait is
shorter on purpose: a CP that writes no markers costs one marker timeout
per vport instead of one per queue (32s for 64 queues).
>
>> markers_rcvd &= !idpf_queue_has(SW_MARKER, txq);
>> break;
>> default:
>
> [ ... ]
>
next prev parent reply other threads:[~2026-12-04 17:23 UTC|newest]
Thread overview: 13+ 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 ` [PATCH net 2/6] idpf: ignore Tx timestamp replies once removal has started Tony Nguyen
2026-11-25 22:51 ` [PATCH net 3/6] idpf: ignore link events " Tony Nguyen
2026-11-26 23:40 ` netdev-bot+sashiko
2026-11-25 22:51 ` [PATCH net 4/6] idpf: keep the mailbox up while tearing down vports on shutdown Tony Nguyen
2026-11-26 23:40 ` netdev-bot+sashiko
2026-12-04 17:22 ` Tantilov, Emil S [this message]
2026-11-25 22:51 ` [PATCH net 5/6] idpf: fix use-after-free in the PTP auxiliary worker Tony Nguyen
2026-11-26 23:40 ` netdev-bot+sashiko
2026-12-01 23:13 ` 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=17b90ff9-b944-4f80-9d22-8c0b58e9a171@intel.com \
--to=emil.s.tantilov@intel.com \
--cc=Samuel.salin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=konstantin.ilichev@intel.com \
--cc=kuba@kernel.org \
--cc=milena.olech@intel.com \
--cc=netdev-bot+sashiko@kernel.org \
--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