Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: a479a27f4da4 ("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>

authored by

Jordan Rhee and committed by
Jakub Kicinski
a040afa3 d32ba904

+14 -15
+5
drivers/net/ethernet/google/gve/gve.h
··· 1206 1206 } 1207 1207 } 1208 1208 1209 + static inline bool gve_is_clock_enabled(struct gve_priv *priv) 1210 + { 1211 + return priv->nic_ts_report; 1212 + } 1213 + 1209 1214 /* gqi napi handler defined in gve_main.c */ 1210 1215 int gve_napi_poll(struct napi_struct *napi, int budget); 1211 1216
+1 -1
drivers/net/ethernet/google/gve/gve_ethtool.c
··· 938 938 939 939 ethtool_op_get_ts_info(netdev, info); 940 940 941 - if (priv->nic_timestamp_supported) { 941 + if (gve_is_clock_enabled(priv)) { 942 942 info->so_timestamping |= SOF_TIMESTAMPING_RX_HARDWARE | 943 943 SOF_TIMESTAMPING_RAW_HARDWARE; 944 944
+7 -5
drivers/net/ethernet/google/gve/gve_main.c
··· 680 680 } 681 681 } 682 682 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 + } 687 689 } 688 690 689 691 err = gve_init_rss_config(priv, priv->rx_cfg.num_queues); ··· 2185 2183 } 2186 2184 2187 2185 if (kernel_config->rx_filter != HWTSTAMP_FILTER_NONE) { 2188 - if (!priv->nic_ts_report) { 2186 + if (!gve_is_clock_enabled(priv)) { 2189 2187 NL_SET_ERR_MSG_MOD(extack, 2190 2188 "RX timestamping is not supported"); 2191 2189 kernel_config->rx_filter = HWTSTAMP_FILTER_NONE;
-8
drivers/net/ethernet/google/gve/gve_ptp.c
··· 70 70 struct gve_ptp *ptp; 71 71 int err; 72 72 73 - if (!priv->nic_timestamp_supported) { 74 - dev_dbg(&priv->pdev->dev, "Device does not support PTP\n"); 75 - return -EOPNOTSUPP; 76 - } 77 - 78 73 priv->ptp = kzalloc(sizeof(*priv->ptp), GFP_KERNEL); 79 74 if (!priv->ptp) 80 75 return -ENOMEM; ··· 110 115 int gve_init_clock(struct gve_priv *priv) 111 116 { 112 117 int err; 113 - 114 - if (!priv->nic_timestamp_supported) 115 - return 0; 116 118 117 119 err = gve_ptp_init(priv); 118 120 if (err)
+1 -1
drivers/net/ethernet/google/gve/gve_rx_dqo.c
··· 484 484 { 485 485 const struct gve_xdp_buff *ctx = (void *)_ctx; 486 486 487 - if (!ctx->gve->nic_ts_report) 487 + if (!gve_is_clock_enabled(ctx->gve)) 488 488 return -ENODATA; 489 489 490 490 if (!(ctx->compl_desc->ts_sub_nsecs_low & GVE_DQO_RX_HWTSTAMP_VALID))