Commit a040afa3 authored by Jordan Rhee's avatar Jordan Rhee Committed by Jakub Kicinski
Browse files

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: a479a27f ("gve: Move gve_init_clock to after AQ CONFIGURE_DEVICE_RESOURCES call")
Signed-off-by: default avatarJordan Rhee <jordanrhee@google.com>
Reviewed-by: default avatarShachar Raindel <shacharr@google.com>
Signed-off-by: default avatarHarshitha Ramamurthy <hramamurthy@google.com>
Link: https://patch.msgid.link/20260127010210.969823-1-hramamurthy@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d32ba904
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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);

+1 −1
Original line number Diff line number Diff line
@@ -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;

+7 −5
Original line number Diff line number Diff line
@@ -680,10 +680,12 @@ static int gve_setup_device_resources(struct gve_priv *priv)
		}
	}

	if (priv->nic_timestamp_supported) {
		err = gve_init_clock(priv);
		if (err) {
		dev_err(&priv->pdev->dev, "Failed to init clock");
		goto abort_with_ptype_lut;
			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;
+0 −8
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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))