From: Harshitha Ramamurthy <hramamurthy@google.com>
To: netdev@vger.kernel.org
Cc: joshwash@google.com, hramamurthy@google.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, jordanrhee@google.com,
willemb@google.com, przemyslaw.kitszel@intel.com,
nktgrg@google.com, maolson@google.com, jacob.e.keller@intel.com,
pkaligineedi@google.com, yangchun@google.com,
patricion@google.com, awogbemila@google.com,
stable@vger.kernel.org, linux-kernel@vger.kernel.org,
Pin-yen Lin <treapking@google.com>
Subject: [PATCH net v4 4/4] gve: Fix link flap after ethtool ops
Date: Thu, 29 Oct 2026 21:16:34 +0000 [thread overview]
Message-ID: <20261029211634.2232784-5-hramamurthy@google.com> (raw)
In-Reply-To: <20261029211634.2232784-1-hramamurthy@google.com>
From: Pin-yen Lin <treapking@google.com>
When modifying device features via ethtool, GVE causes a short link-down
after the ethtool command completes, which can break scripts that use
the network interface right after the ethtool command.
This issue was discovered and actually triggered by the
drivers/net/ping.py selftest. Modifying checksum offload features via
ethtool caused a transient carrier drop ("Lost carrier", DHCP lease lost),
causing the immediate ping invocation to fail.
Fix it by calling gve_turnup_and_check_status() in gve_queues_start()
instead of deferring the link status update to the service task, so the
carrier status is updated synchronously before returning to userspace.
Take netdev_lock() around the link status update in gve_service_task(),
so that it is serialized with the synchronous update. All other callers
of gve_handle_link_status() already hold the instance lock.
This change was tested using the DQO RDA queue format.
Cc: stable@vger.kernel.org
Fixes: 3b7cc73628ff ("gve: Use link status register to report link status")
Signed-off-by: Pin-yen Lin <treapking@google.com>
Reviewed-by: Joshua Washington <joshwash@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
---
Changes in v4:
- Take netdev_lock() around the link status update in
gve_service_task() to serialize it with gve_queues_start() (Sashiko)
Changes in v3:
- Retitled from "gve: Make ethtool config changes synchronous"
- Fix the Fixes tag
- Refined the commit message
drivers/net/ethernet/google/gve/gve_main.c | 70 ++++++++++++----------
1 file changed, 39 insertions(+), 31 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index b5e2f39a903c..bc7d7c41948c 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -17,6 +17,7 @@
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/workqueue.h>
+#include <net/netdev_lock.h>
#include <net/netdev_queues.h>
#include <net/sch_generic.h>
#include <net/xdp_sock_drv.h>
@@ -1431,6 +1432,37 @@ static void gve_queues_stop(struct gve_priv *priv)
gve_rx_stop_rings(priv, priv->rx_cfg.num_queues);
}
+static void gve_handle_link_status(struct gve_priv *priv)
+{
+ bool link_up;
+
+ netdev_assert_locked(priv->dev);
+
+ if (!gve_get_napi_enabled(priv))
+ return;
+
+ link_up = READ_ONCE(priv->link_up);
+ if (link_up == netif_carrier_ok(priv->dev))
+ return;
+
+ if (link_up) {
+ netdev_info(priv->dev, "Device link is up.\n");
+ netif_carrier_on(priv->dev);
+ } else {
+ netdev_info(priv->dev, "Device link is down.\n");
+ netif_carrier_off(priv->dev);
+ }
+}
+
+static void gve_turnup_and_check_status(struct gve_priv *priv)
+{
+ const struct gve_ctrl_ops *ops = priv->ctrl_ops;
+
+ gve_turnup(priv);
+ ops->report_link_status(priv);
+ gve_handle_link_status(priv);
+}
+
/* The passed-in queue memory is stored into priv and the queues are made live.
* No memory is allocated. Passed-in memory is freed on errors.
*/
@@ -1494,8 +1526,7 @@ static int gve_queues_start(struct gve_priv *priv,
round_jiffies(jiffies +
msecs_to_jiffies(priv->stats_report_timer_period)));
- gve_turnup(priv);
- queue_work(priv->gve_wq, &priv->service_task);
+ gve_turnup_and_check_status(priv);
priv->interface_up_cnt++;
return 0;
@@ -1570,26 +1601,6 @@ static int gve_close(struct net_device *dev)
return err;
}
-static void gve_handle_link_status(struct gve_priv *priv)
-{
- bool link_up;
-
- if (!gve_get_napi_enabled(priv))
- return;
-
- link_up = READ_ONCE(priv->link_up);
- if (link_up == netif_carrier_ok(priv->dev))
- return;
-
- if (link_up) {
- netdev_info(priv->dev, "Device link is up.\n");
- netif_carrier_on(priv->dev);
- } else {
- netdev_info(priv->dev, "Device link is down.\n");
- netif_carrier_off(priv->dev);
- }
-}
-
static int gve_configure_rings_xdp(struct gve_priv *priv,
u16 num_xdp_rings)
{
@@ -2064,15 +2075,6 @@ static void gve_turnup(struct gve_priv *priv)
gve_set_napi_enabled(priv);
}
-static void gve_turnup_and_check_status(struct gve_priv *priv)
-{
- const struct gve_ctrl_ops *ops = priv->ctrl_ops;
-
- gve_turnup(priv);
- ops->report_link_status(priv);
- gve_handle_link_status(priv);
-}
-
static struct gve_notify_block *gve_get_tx_notify_block(struct gve_priv *priv,
unsigned int txqueue)
{
@@ -2406,8 +2408,14 @@ static void gve_service_task(struct work_struct *work)
gve_handle_status(priv, status);
gve_handle_reset(priv);
+
+ /* Serialize with the synchronous link status updates, which all run
+ * under the netdev instance lock.
+ */
+ netdev_lock(priv->dev);
ops->report_link_status(priv);
gve_handle_link_status(priv);
+ netdev_unlock(priv->dev);
}
static void gve_set_netdev_xdp_features(struct gve_priv *priv)
--
2.56.0.313.g2479322e68-goog
prev parent reply other threads:[~2026-10-29 21:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 21:16 [PATCH net v4 0/4] gve: Fixes for issues discovered via net selftests and Sashiko Harshitha Ramamurthy
2026-10-29 21:16 ` [PATCH net v4 1/4] gve: Fix race between stats query and queue reconfig Harshitha Ramamurthy
2026-10-29 21:16 ` [PATCH net v4 2/4] gve: Fix backward stats when interface goes down or configuration is adjusted Harshitha Ramamurthy
2026-10-29 21:16 ` [PATCH net v4 3/4] gve: Block invalid ring sizes when device options are 0 Harshitha Ramamurthy
2026-10-29 21:16 ` Harshitha Ramamurthy [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=20261029211634.2232784-5-hramamurthy@google.com \
--to=hramamurthy@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=awogbemila@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jordanrhee@google.com \
--cc=joshwash@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maolson@google.com \
--cc=netdev@vger.kernel.org \
--cc=nktgrg@google.com \
--cc=pabeni@redhat.com \
--cc=patricion@google.com \
--cc=pkaligineedi@google.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=stable@vger.kernel.org \
--cc=treapking@google.com \
--cc=willemb@google.com \
--cc=yangchun@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
all inboxes | Powered by JetHome®