]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gve: Move ptp_schedule_worker to gve_init_clock
authorTim Hostetler <thostet@google.com>
Fri, 14 Nov 2025 21:11:43 +0000 (13:11 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 18 Nov 2025 14:52:42 +0000 (15:52 +0100)
Previously, gve had been only initializing ptp aux work when
hardware timestamping was initialized through ndo_hwtsatmp_set. As this
patch series introduces XDP hardware timestamp metadata which will
require the ptp aux work, the work can't be gated on the
kernel_hwtstamp_config being set and must be initialized elsewhere.

For simplicity, ptp_schedule_worker is invoked right after the ptp_clock
is registered with the kernel (which happens during gve_probe or
following reset). The worker is scheduled in GVE_NIC_TS_SYNC_INTERVAL_MS
as the synchronous call to gve_clock_nic_ts_read makes the worker
redundant if scheduled immediately.

If gve cannot read the device clock immediately, it errors out of
gve_init_clock.

Signed-off-by: Tim Hostetler <thostet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com>
Signed-off-by: Joshua Washington <joshwash@google.com>
Link: https://patch.msgid.link/20251114211146.292068-2-joshwash@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/google/gve/gve_main.c
drivers/net/ethernet/google/gve/gve_ptp.c

index 6fb8fbb38a7d393604af829e7c3136c68b55c925..2b41a42fb51695fffbb61d6d2f5971759a2c152f 100644 (file)
@@ -2188,10 +2188,6 @@ static int gve_set_ts_config(struct net_device *dev,
                }
 
                kernel_config->rx_filter = HWTSTAMP_FILTER_ALL;
-               gve_clock_nic_ts_read(priv);
-               ptp_schedule_worker(priv->ptp->clock, 0);
-       } else {
-               ptp_cancel_worker_sync(priv->ptp->clock);
        }
 
        priv->ts_config.rx_filter = kernel_config->rx_filter;
index a384a9ed4914ef02d420617d6eb3fc3ad7b62ec7..073677d82ee8e50fafbdc19bf9024c78e2c49e52 100644 (file)
@@ -133,9 +133,21 @@ int gve_init_clock(struct gve_priv *priv)
                err = -ENOMEM;
                goto release_ptp;
        }
+       err = gve_clock_nic_ts_read(priv);
+       if (err) {
+               dev_err(&priv->pdev->dev, "failed to read NIC clock %d\n", err);
+               goto release_nic_ts_report;
+       }
+       ptp_schedule_worker(priv->ptp->clock,
+                           msecs_to_jiffies(GVE_NIC_TS_SYNC_INTERVAL_MS));
 
        return 0;
 
+release_nic_ts_report:
+       dma_free_coherent(&priv->pdev->dev,
+                         sizeof(struct gve_nic_ts_report),
+                         priv->nic_ts_report, priv->nic_ts_report_bus);
+       priv->nic_ts_report = NULL;
 release_ptp:
        gve_ptp_release(priv);
        return err;