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>
Subject: [PATCH net 4/4] ionic: fix ethtool coalesce updates racing a PCI reset
Date: Wed, 2 Dec 2026 00:38:25 +0000	[thread overview]
Message-ID: <20261202-b4-pr60-v1-4-b1f6706e065b@amd.com> (raw)
In-Reply-To: <20261202-b4-pr60-v1-0-b1f6706e065b@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 clears LIF_F_UP, frees the queues and unmaps BAR0
without rtnl, so an update that passed the test just before the reset
reads freed queues and writes the unmapped BAR. The restart after the
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 both 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 under KASAN and lockdep with ethtool -C running during
30 PCI resets.

Fixes: a79b559e99be ("ionic: add FLR recovery support")
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-02  0:39 UTC|newest]

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

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=20261202-b4-pr60-v1-4-b1f6706e065b@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 \
    /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