Netdev List
 help / color / mirror / Atom feed
From: "Nikhil P. Rao" <nikhil.rao@amd.com>
To: Brett Creeley <brett.creeley@amd.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Richard Cochran <richardcochran@gmail.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Eric Joyner <eric.joyner@amd.com>,
	Abhijit Gangurde <abhijit.gangurde@amd.com>,
	"Allen Hubbe" <allen.hubbe@amd.com>,
	"Nikhil P. Rao" <nikhil.rao@amd.com>, <stable@vger.kernel.org>
Subject: [PATCH net v2 4/5] ionic: fix ethtool coalesce updates racing a reset
Date: Fri, 4 Dec 2026 22:04:23 +0000	[thread overview]
Message-ID: <20261204-b4-pr60-v2-4-9e0b5408a68e@amd.com> (raw)
In-Reply-To: <20261204-b4-pr60-v2-0-9e0b5408a68e@amd.com>

ionic_set_coalesce() runs under rtnl only. It saves the new settings,
tests LIF_F_UP and writes each queue's interrupt control register in
BAR0. A PCI reset or a firmware reset clears LIF_F_UP and frees the
queues without rtnl, and the PCI reset also unmaps BAR0, so an update
that passed the test just before the reset reads freed queues and can
write the unmapped BAR. The restart after either reset also programs
the new queues from the saved settings without rtnl, so it can pick up
a half-written update.

The teardown and the restart of both resets run under queue_lock, so
take it for the whole update. ethtool's ring and channel changes
already take queue_lock under rtnl.

Found by an AI code review of this series and confirmed by reading the
code. Not reproduced, as there is no call between the test and the
register write where a test module could hold the update. Tested on an
AMD Pensando NIC, on a kernel with KASAN and lockdep, with ethtool -C
running during 30 PCI resets.

Fixes: c672412f6172 ("ionic: remove lifs on fw reset")
Fixes: a79b559e99be ("ionic: add FLR recovery support")
Cc: <stable@vger.kernel.org> # 5.10.x: 2624d95972db: ionic: widen queue_lock use around lif init and deinit
Cc: <stable@vger.kernel.org> # 5.10.x
Reviewed-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
index 1360a3dfb7c6..bc0601dbcf63 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
@@ -555,6 +555,8 @@ static int ionic_set_coalesce(struct net_device *netdev,
 	    tx_coal > IONIC_INTR_CTRL_COAL_MAX)
 		return -ERANGE;
 
+	mutex_lock(&lif->queue_lock);
+
 	/* Save the new values */
 	lif->rx_coalesce_usecs = coalesce->rx_coalesce_usecs;
 	lif->rx_coalesce_hw = rx_coal;
@@ -598,6 +600,7 @@ static int ionic_set_coalesce(struct net_device *netdev,
 			}
 		}
 	}
+	mutex_unlock(&lif->queue_lock);
 
 	return 0;
 }

-- 
2.43.0


  parent reply	other threads:[~2026-12-04 22:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 22:04 [PATCH net v2 0/5] ionic: fix register reads racing the BAR unmap on PCI reset Nikhil P. Rao
2026-12-04 22:04 ` [PATCH net v2 1/5] ionic: fix devcmds " Nikhil P. Rao
2026-12-04 22:04 ` [PATCH net v2 2/5] ionic: fix device info register reads " Nikhil P. Rao
2026-12-04 22:04 ` [PATCH net v2 3/5] ionic: fix PHC " Nikhil P. Rao
2026-12-04 22:04 ` Nikhil P. Rao [this message]
2026-12-04 22:04 ` [PATCH net v2 5/5] ionic: fix DIM work racing the queue teardown Nikhil P. Rao

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=20261204-b4-pr60-v2-4-9e0b5408a68e@amd.com \
    --to=nikhil.rao@amd.com \
    --cc=abhijit.gangurde@amd.com \
    --cc=allen.hubbe@amd.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=eric.joyner@amd.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=stable@vger.kernel.org \
    /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