🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Jakub Kicinski Wed, 18 Nov 2026 02:39
[PATCH net-next 1/6] eth: bnxt_en: order event data before setting the sp_event bit
#18267
Author: Jakub Kicinski
Date: Wed, 18 Nov 2026 02:39
37 lines
9041 bytes
Callers of bnxt_queue_sp_work() may store data for bnxt_sp_task()
right before raising the event, e.g. the IRQ affinity notifier
publishes the new TPH Steering Tag. set_bit() is not ordered, so on
weakly ordered architectures the event bit may become visible first.
If bnxt_sp_task() is already running it can consume the event and
read the stale data. The queue_work() which follows only re-runs
the task with the event bit already cleared, so the update is lost.

Add smp_mb__before_atomic() before setting the bit, it pairs with
the fully ordered test_and_clear_bit() in bnxt_sp_task().

Reported by an LLM reviewer while working on subsequent patches.
Very unlikely to matter in practice.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 6846a27bfef4..5ad2a3033505 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -394,6 +394,10 @@ static void __bnxt_queue_sp_work(struct bnxt *bp)
 
 static void bnxt_queue_sp_work(struct bnxt *bp, unsigned int event)
 {
+	/* Make the data the event carries visible before the event bit,
+	 * pairs with test_and_clear_bit() in bnxt_sp_task().
+	 */
+	smp_mb__before_atomic();
 	set_bit(event, &bp->sp_event);
 	__bnxt_queue_sp_work(bp);
 }
-- 
2.56.1
Re: [PATCH net-next 1/6] eth: bnxt_en: order event data before setting the sp_event bit
#18501
Author: Björn Töpel
Date: Wed, 18 Nov 2026 12:27
43 lines
9389 bytes
Jakub Kicinski <kuba@kernel.org> writes:

> Callers of bnxt_queue_sp_work() may store data for bnxt_sp_task()
> right before raising the event, e.g. the IRQ affinity notifier
> publishes the new TPH Steering Tag. set_bit() is not ordered, so on
> weakly ordered architectures the event bit may become visible first.
> If bnxt_sp_task() is already running it can consume the event and
> read the stale data. The queue_work() which follows only re-runs
> the task with the event bit already cleared, so the update is lost.
>
> Add smp_mb__before_atomic() before setting the bit, it pairs with
> the fully ordered test_and_clear_bit() in bnxt_sp_task().
>
> Reported by an LLM reviewer while working on subsequent patches.
> Very unlikely to matter in practice.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 6846a27bfef4..5ad2a3033505 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -394,6 +394,10 @@ static void __bnxt_queue_sp_work(struct bnxt *bp)
>  
>  static void bnxt_queue_sp_work(struct bnxt *bp, unsigned int event)
>  {
> +	/* Make the data the event carries visible before the event bit,
> +	 * pairs with test_and_clear_bit() in bnxt_sp_task().
> +	 */
> +	smp_mb__before_atomic();
>  	set_bit(event, &bp->sp_event);
>  	__bnxt_queue_sp_work(bp);

There are direct callers of __bnxt_queue_sp_work(), that'll miss the
fence. Fixup those callers?


Björn
Re: [PATCH net-next 1/6] eth: bnxt_en: order event data before setting the sp_event bit
#18929
Author: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 03:21
119 lines
12237 bytes
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 patch fixes only some of the producers that publish data
  and then raise an sp_event bit.

--

eth: bnxt_en: order event data before setting the sp_event bit

This commit adds smp_mb__before_atomic() in bnxt_queue_sp_work() before
the set_bit() on bp->sp_event. Data that callers store for bnxt_sp_task()
then becomes visible before the event bit. The barrier pairs with the
fully ordered test_and_clear_bit() in bnxt_sp_task().

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 6846a27bfef4c..5ad2a3033505d 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -394,6 +394,10 @@ static void __bnxt_queue_sp_work(struct bnxt *bp)
>  
>  static void bnxt_queue_sp_work(struct bnxt *bp, unsigned int event)
>  {
> +	/* Make the data the event carries visible before the event bit,
> +	 * pairs with test_and_clear_bit() in bnxt_sp_task().
> +	 */
> +	smp_mb__before_atomic();
>  	set_bit(event, &bp->sp_event);
>  	__bnxt_queue_sp_work(bp);
>  }

[Severity: Medium]
Should the same ordering also cover the producers that set sp_event bits
directly and then call __bnxt_queue_sp_work()?

The new comment reads like an ordering contract for sp_event in general.
Several paths in bnxt.c do not go through bnxt_queue_sp_work(), so they
never reach the new barrier. Each of them stores the event data, does a
plain set_bit() on bp->sp_event, and then calls __bnxt_queue_sp_work(),
which has no barrier.

In bnxt_async_event_process(), the echo request case does this:

	if (fw_health) {
		fw_health->echo_req_data1 = data1;
		fw_health->echo_req_data2 = data2;
		set_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event);
		break;
	}
	...
	__bnxt_queue_sp_work(bp);

Could bnxt_fw_echo_reply() then copy stale echo_req_data1/2 into
HWRM_FUNC_ECHO_RESPONSE?

In the RESET_NOTIFY case, the code writes fw_reset_timestamp,
fw_reset_min_dsecs, fw_reset_max_dsecs and the BNXT_STATE_FW_FATAL_COND or
BNXT_STATE_FW_NON_FATAL_COND bit in bp->state, and then does:

	set_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event);

The state bits are also set with a relaxed set_bit(), on a different
word, so nothing orders them against the sp_event bit. bnxt_sp_task()
then checks them:

	if (test_and_clear_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event)) {
		if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) ||
		    test_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state))
			bnxt_devlink_health_fw_report(bp);
		else
			bnxt_fw_reset(bp);
	}

Can this take bnxt_fw_reset() instead of bnxt_devlink_health_fw_report(),
or start the reset with stale wait limits?

bnxt_event_error_report() does the same with bp->thermal_threshold_type:

	bp->thermal_threshold_type = type;
	set_bit(BNXT_THERMAL_THRESHOLD_SP_EVENT, &bp->sp_event);

and bnxt_hwmon_notify_event() switches on that value.

bnxt_sched_reset_rxr() follows the same pattern:

	rxr->bnapi->in_reset = true;
	if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
		set_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event);
	else
		set_bit(BNXT_RST_RING_SP_EVENT, &bp->sp_event);
	__bnxt_queue_sp_work(bp);

If bnxt_rx_ring_reset() sees a stale in_reset == false, it skips the ring:

	if (!rxr->bnapi->in_reset)
		continue;

in_reset then stays true, so bnxt_sched_reset_rxr() never schedules that
ring reset again. Would that ring stay stuck until a full reset?

These paths are still unchanged at the end of the series, as of the
"restart Rx queues when their IRQ moves to another NUMA node" patch.

Moving the barrier into __bnxt_queue_sp_work() would not cover these
paths, because the open-coded set_bit() calls run before it. Could
smp_mb__before_atomic() go before each open-coded set_bit() instead, or
could these producers use an ordered helper?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118023905.3050661-1-kuba%40kernel.org
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads