]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gve: fix probe failure if clock read fails
authorJordan Rhee <jordanrhee@google.com>
Tue, 27 Jan 2026 01:02:10 +0000 (01:02 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 28 Jan 2026 02:33:27 +0000 (18:33 -0800)
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>
drivers/net/ethernet/google/gve/gve.h
drivers/net/ethernet/google/gve/gve_ethtool.c
drivers/net/ethernet/google/gve/gve_main.c
drivers/net/ethernet/google/gve/gve_ptp.c
drivers/net/ethernet/google/gve/gve_rx_dqo.c

index 970d5ca8cddeec4907e525d26aee0b40582f8e80..cbdf3a842cfe00c326d3d82a02494e0f93acf16c 100644 (file)
@@ -1206,6 +1206,11 @@ static inline bool gve_supports_xdp_xmit(struct gve_priv *priv)
        }
 }
 
+static inline bool gve_is_clock_enabled(struct gve_priv *priv)
+{
+       return priv->nic_ts_report;
+}
+
 /* gqi napi handler defined in gve_main.c */
 int gve_napi_poll(struct napi_struct *napi, int budget);
 
index 52500ae8348e620f9f6090c9427627a9c85a6125..311b106160b20aa0e3eba81aada79c35cb6369df 100644 (file)
@@ -938,7 +938,7 @@ static int gve_get_ts_info(struct net_device *netdev,
 
        ethtool_op_get_ts_info(netdev, info);
 
-       if (priv->nic_timestamp_supported) {
+       if (gve_is_clock_enabled(priv)) {
                info->so_timestamping |= SOF_TIMESTAMPING_RX_HARDWARE |
                                         SOF_TIMESTAMPING_RAW_HARDWARE;
 
index 7eb64e1e4d858bb9cff0431703d8b4fd97104db5..52c5e4942cd48940d6e29c04a5327bc739dd4daa 100644 (file)
@@ -680,10 +680,12 @@ static int gve_setup_device_resources(struct gve_priv *priv)
                }
        }
 
-       err = gve_init_clock(priv);
-       if (err) {
-               dev_err(&priv->pdev->dev, "Failed to init clock");
-               goto abort_with_ptype_lut;
+       if (priv->nic_timestamp_supported) {
+               err = gve_init_clock(priv);
+               if (err) {
+                       dev_warn(&priv->pdev->dev, "Failed to init clock, continuing without PTP support");
+                       err = 0;
+               }
        }
 
        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,
        }
 
        if (kernel_config->rx_filter != HWTSTAMP_FILTER_NONE) {
-               if (!priv->nic_ts_report) {
+               if (!gve_is_clock_enabled(priv)) {
                        NL_SET_ERR_MSG_MOD(extack,
                                           "RX timestamping is not supported");
                        kernel_config->rx_filter = HWTSTAMP_FILTER_NONE;
index 073677d82ee8e50fafbdc19bf9024c78e2c49e52..de42fc2c19a1a654df7dda293865ef6e83379939 100644 (file)
@@ -70,11 +70,6 @@ static int gve_ptp_init(struct gve_priv *priv)
        struct gve_ptp *ptp;
        int err;
 
-       if (!priv->nic_timestamp_supported) {
-               dev_dbg(&priv->pdev->dev, "Device does not support PTP\n");
-               return -EOPNOTSUPP;
-       }
-
        priv->ptp = kzalloc(sizeof(*priv->ptp), GFP_KERNEL);
        if (!priv->ptp)
                return -ENOMEM;
@@ -116,9 +111,6 @@ int gve_init_clock(struct gve_priv *priv)
 {
        int err;
 
-       if (!priv->nic_timestamp_supported)
-               return 0;
-
        err = gve_ptp_init(priv);
        if (err)
                return err;
index f1bd8f5d573239088ef57ab1b223d8b31899e864..63a96106a69371ab83185177cbfa4e601c29e052 100644 (file)
@@ -484,7 +484,7 @@ int gve_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *timestamp)
 {
        const struct gve_xdp_buff *ctx = (void *)_ctx;
 
-       if (!ctx->gve->nic_ts_report)
+       if (!gve_is_clock_enabled(ctx->gve))
                return -ENODATA;
 
        if (!(ctx->compl_desc->ts_sub_nsecs_low & GVE_DQO_RX_HWTSTAMP_VALID))