Skip to content

Commit a040afa

Browse files
jordanrh1kuba-moo
authored andcommitted
gve: fix probe failure if clock read fails
If timestamping is supported, GVE reads the clock during probe, which can fail for various reasons. Previously, this failure would abort the driver probe, rendering the device unusable. This behavior has been observed on production GCP VMs, causing driver initialization to fail completely. This patch allows the driver to degrade gracefully. If gve_init_clock() fails, it logs a warning and continues loading the driver without PTP support. Cc: stable@vger.kernel.org Fixes: a479a27 ("gve: Move gve_init_clock to after AQ CONFIGURE_DEVICE_RESOURCES call") Signed-off-by: Jordan Rhee <jordanrhee@google.com> Reviewed-by: Shachar Raindel <shacharr@google.com> Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com> Link: https://patch.msgid.link/20260127010210.969823-1-hramamurthy@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d32ba90 commit a040afa

5 files changed

Lines changed: 14 additions & 15 deletions

File tree

drivers/net/ethernet/google/gve/gve.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,11 @@ static inline bool gve_supports_xdp_xmit(struct gve_priv *priv)
12061206
}
12071207
}
12081208

1209+
static inline bool gve_is_clock_enabled(struct gve_priv *priv)
1210+
{
1211+
return priv->nic_ts_report;
1212+
}
1213+
12091214
/* gqi napi handler defined in gve_main.c */
12101215
int gve_napi_poll(struct napi_struct *napi, int budget);
12111216

drivers/net/ethernet/google/gve/gve_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ static int gve_get_ts_info(struct net_device *netdev,
938938

939939
ethtool_op_get_ts_info(netdev, info);
940940

941-
if (priv->nic_timestamp_supported) {
941+
if (gve_is_clock_enabled(priv)) {
942942
info->so_timestamping |= SOF_TIMESTAMPING_RX_HARDWARE |
943943
SOF_TIMESTAMPING_RAW_HARDWARE;
944944

drivers/net/ethernet/google/gve/gve_main.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,12 @@ static int gve_setup_device_resources(struct gve_priv *priv)
680680
}
681681
}
682682

683-
err = gve_init_clock(priv);
684-
if (err) {
685-
dev_err(&priv->pdev->dev, "Failed to init clock");
686-
goto abort_with_ptype_lut;
683+
if (priv->nic_timestamp_supported) {
684+
err = gve_init_clock(priv);
685+
if (err) {
686+
dev_warn(&priv->pdev->dev, "Failed to init clock, continuing without PTP support");
687+
err = 0;
688+
}
687689
}
688690

689691
err = gve_init_rss_config(priv, priv->rx_cfg.num_queues);
@@ -2183,7 +2185,7 @@ static int gve_set_ts_config(struct net_device *dev,
21832185
}
21842186

21852187
if (kernel_config->rx_filter != HWTSTAMP_FILTER_NONE) {
2186-
if (!priv->nic_ts_report) {
2188+
if (!gve_is_clock_enabled(priv)) {
21872189
NL_SET_ERR_MSG_MOD(extack,
21882190
"RX timestamping is not supported");
21892191
kernel_config->rx_filter = HWTSTAMP_FILTER_NONE;

drivers/net/ethernet/google/gve/gve_ptp.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ static int gve_ptp_init(struct gve_priv *priv)
7070
struct gve_ptp *ptp;
7171
int err;
7272

73-
if (!priv->nic_timestamp_supported) {
74-
dev_dbg(&priv->pdev->dev, "Device does not support PTP\n");
75-
return -EOPNOTSUPP;
76-
}
77-
7873
priv->ptp = kzalloc(sizeof(*priv->ptp), GFP_KERNEL);
7974
if (!priv->ptp)
8075
return -ENOMEM;
@@ -116,9 +111,6 @@ int gve_init_clock(struct gve_priv *priv)
116111
{
117112
int err;
118113

119-
if (!priv->nic_timestamp_supported)
120-
return 0;
121-
122114
err = gve_ptp_init(priv);
123115
if (err)
124116
return err;

drivers/net/ethernet/google/gve/gve_rx_dqo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ int gve_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *timestamp)
484484
{
485485
const struct gve_xdp_buff *ctx = (void *)_ctx;
486486

487-
if (!ctx->gve->nic_ts_report)
487+
if (!gve_is_clock_enabled(ctx->gve))
488488
return -ENODATA;
489489

490490
if (!(ctx->compl_desc->ts_sub_nsecs_low & GVE_DQO_RX_HWTSTAMP_VALID))

0 commit comments

Comments
 (0)