Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: alexander.duyck@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, horms@kernel.org,
	kernel-team@meta.com, kuba@kernel.org, pabeni@redhat.com
Subject: Re: [net PATCH 1/6] fbnic: Wait for in-flight PTP timestamps before treating Tx as idle
Date: Tue, 17 Nov 2026 21:14:18 +0000	[thread overview]
Message-ID: <179495005876.3136.9616798412841778832@kernel.org> (raw)
In-Reply-To: <179460248693.8819.282933709034208845.stgit@ahduyck-xeon-server.home.arpa>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

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).

- [Medium] The new comment above FBNIC_IDLE_POLL_US, and the commit
  message, say a 20us delay keeps the PCIe reads 'a small part of each…

--

fbnic: Wait for in-flight PTP timestamps before treating Tx as idle

This patch moves the Tx idle wait into its own function,
fbnic_wait_tx_idle(). The Tx path now counts as idle only when the
QM idle registers report idle and FBNIC_TCE_PTP_INFLIGHT reads zero.
The patch also raises the poll delay from 2us to 20us and extends
FBNIC_CSR_END_TCE so the ethtool register dump covers the new register.

> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> index 07d4b2e923627..c75c5683b724e 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
> @@ -2398,38 +2398,85 @@ static void fbnic_idle_dump(struct fbnic_dev *fbd,
>  				   fbnic_rd32(fbd, regs[i].reg_base + j));
>  }
>  
> -int fbnic_wait_all_queues_idle(struct fbnic_dev *fbd, bool may_fail)
> +/* The poll timeout only accounts for the delay between polls, not for
> + * the time spent in the poll itself, and each poll is a series of
> + * non-posted PCIe register reads that take on the order of a
> + * microsecond each. Space the polls out so that the reads stay a small
> + * part of each interval and the timeout stays close to wall time.
> + */
> +#define FBNIC_IDLE_POLL_US	20
> +#define FBNIC_IDLE_TIMEOUT_US	500000
> +
> +static bool fbnic_tx_idle(struct fbnic_dev *fbd,
> +			  const struct fbnic_idle_regs *regs,
> +			  unsigned int nregs)
> +{
> +	u32 inflight;
> +
> +	if (!fbnic_all_idle(fbd, regs, nregs))
> +		return false;
> +
> +	/* The QM idle bits do not cover the TMI completion path, so a
> +	 * timestamp request can still be waiting on its completion. The
> +	 * count is bounded by the timestamp requests the Tx path can hold,
> +	 * so all ones is a failed read, as for the idle bits, not a count.
> +	 */
> +	inflight = fbnic_rd32(fbd, FBNIC_TCE_PTP_INFLIGHT);

[Severity: Medium]
Does a 20us delay really keep the reads "a small part of each interval"
in the case this patch adds, where the QM registers are idle but
FBNIC_TCE_PTP_INFLIGHT is still non-zero?

In that state, every poll in fbnic_tx_idle() reads all 28 Tx QM idle
registers (8 TWQ + 8 TQS + 8 TDE + 4 TCQ) as all ones before it reads
FBNIC_TCE_PTP_INFLIGHT.

For each all-ones read, fbnic_rd32() does a second non-posted read:

drivers/net/ethernet/meta/fbnic/fbnic_pci.c:fbnic_rd32() {
    ...
	if (reg != FBNIC_MASTER_SPARE_0 && ~readl(csr + FBNIC_MASTER_SPARE_0))
		return value;
    ...
}

That makes about 57 reads per poll. At the comment's own figure of
about 1us per read, that is roughly 57us of reads against the 20us
delay, so the reads are about three quarters of each interval.

poll_timeout_us_atomic() only charges the delay against the timeout:

	if (__delay_us) {
		udelay(__delay_us);
		if (__timeout_us)
			__left_ns -= __delay_ns;
	}

So the 500000us timeout allows about 25000 polls of about 77us each.
That is roughly 1.9s per Tx wait rather than 500ms.

fbnic_wait_tx_idle() can run two of these waits, one before and one
after fbnic_tx_flush(), so about 3.9s. The Rx wait reads 12 registers,
24 reads per poll, so it adds about another 1.1s.

All of this is udelay() busy-waiting while the RTNL/netdev lock is held
in fbnic_down(), fbnic_set_ringparam() and fbnic_set_channels().

Could the delay be sized for the real per-poll read count? Another
option is to bound the wait by elapsed time, for example by reading
FBNIC_TCE_PTP_INFLIGHT first or using a ktime-based deadline. If the
code stays as it is, could the comment and the part of the commit
message saying "the 500ms timeout stays close to wall time" be updated?

> +
> +	return !inflight || !~inflight;
> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179460241885.8819.7179935130629202331.stgit%40ahduyck-xeon-server.home.arpa

  reply	other threads:[~2026-11-17 21:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 20:41 [net PATCH 0/6] fbnic: Follow-up fixes for the Tx idle check, HW stats and FW mailbox allocations Alexander Duyck
2026-11-13 20:41 ` [net PATCH 1/6] fbnic: Wait for in-flight PTP timestamps before treating Tx as idle Alexander Duyck
2026-11-17 21:14   ` netdev-bot+sashiko [this message]
2026-11-17 21:31     ` Alexander Duyck
2026-11-13 20:41 ` [net PATCH 2/6] fbnic: Do not accumulate HW stats from failed register reads Alexander Duyck
2026-11-17 21:14   ` netdev-bot+sashiko
2026-11-17 22:11     ` Alexander Duyck
2026-11-13 20:41 ` [net PATCH 3/6] fbnic: Cover all of the HW stats with the stats lock Alexander Duyck
2026-11-17 21:14   ` netdev-bot+sashiko
2026-11-17 22:01     ` Alexander Duyck
2026-11-13 20:41 ` [net PATCH 4/6] fbnic: Initialize and reset the HW stats before they can be read Alexander Duyck
2026-11-13 20:42 ` [net PATCH 5/6] fbnic: Stamp heartbeat and ownership requests after allocating them Alexander Duyck
2026-11-13 20:42 ` [net PATCH 6/6] fbnic: Allocate FW completions with kvzalloc Alexander Duyck

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=179495005876.3136.9616798412841778832@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alexander.duyck@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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