public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] gve: add support for PTP gettimex64
@ 2026-03-23 23:48 Harshitha Ramamurthy
  2026-03-23 23:48 ` [PATCH net-next 1/3] gve: skip error logging for retryable AdminQ commands Harshitha Ramamurthy
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Harshitha Ramamurthy @ 2026-03-23 23:48 UTC (permalink / raw)
  To: netdev
  Cc: joshwash, hramamurthy, andrew+netdev, davem, edumazet, kuba,
	pabeni, richardcochran, willemb, nktgrg, jfraker, ziweixiao,
	maolson, thostet, jordanrhee, jefrogers, alok.a.tiwari,
	linux-kernel

From: Jordan Rhee <jordanrhee@google.com>

This patch series adds support to obtain near-simultaneous NIC and
system timestamps with gettimex64. This enables daemons like
chrony and phc2sys to synchronize the system clock to the NIC clock.

GVE does not have direct register access to the NIC hardware clock, so
it must issue an AdminQ command to read the NIC clock. Due to relatively
high latency of AQ commands (~100us), it is necessary for the hypervisor
to sample the system time sandwich inside the AQ command.

The first two patches pave the way for the PTP implementation by
quieting excessive logging and refactoring an existing routine for
thread safety.

When tested inside a GCE C3 VM, this enabled chrony to synchronize the
NIC clock and system clock with sub-microsecond precision.

chronyc tracking
Reference ID    : 50484330 (PHC0)
Stratum         : 1
Ref time (UTC)  : Sat Feb 14 01:53:42 2026
System time     : 0.000000001 seconds fast of NTP time
Last offset     : -0.000000000 seconds
RMS offset      : 0.000000001 seconds
Frequency       : 0.686 ppm fast
Residual freq   : -0.000 ppm
Skew            : 0.001 ppm
Root delay      : 0.000000001 seconds
Root dispersion : 0.000000812 seconds
Update interval : 0.5 seconds
Leap status     : Normal

Ankit Garg (1):
  gve: make nic clock reads thread safe

Jordan Rhee (2):
  gve: skip error logging for retryable AdminQ commands
  gve: implement PTP gettimex64

 drivers/net/ethernet/google/gve/gve.h        |   6 +-
 drivers/net/ethernet/google/gve/gve_adminq.c |  26 ++-
 drivers/net/ethernet/google/gve/gve_adminq.h |   4 +-
 drivers/net/ethernet/google/gve/gve_ptp.c    | 209 +++++++++++++++++--
 4 files changed, 220 insertions(+), 25 deletions(-)


base-commit: 5446b8691eb8278f10deca92048fad84ffd1e4d5
-- 
2.53.0.851.ga537e3e6e9-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/3] gve: skip error logging for retryable AdminQ commands
  2026-03-23 23:48 [PATCH net-next 0/3] gve: add support for PTP gettimex64 Harshitha Ramamurthy
@ 2026-03-23 23:48 ` Harshitha Ramamurthy
  2026-03-23 23:48 ` [PATCH net-next 2/3] gve: make nic clock reads thread safe Harshitha Ramamurthy
  2026-03-23 23:48 ` [PATCH net-next 3/3] gve: implement PTP gettimex64 Harshitha Ramamurthy
  2 siblings, 0 replies; 6+ messages in thread
From: Harshitha Ramamurthy @ 2026-03-23 23:48 UTC (permalink / raw)
  To: netdev
  Cc: joshwash, hramamurthy, andrew+netdev, davem, edumazet, kuba,
	pabeni, richardcochran, willemb, nktgrg, jfraker, ziweixiao,
	maolson, thostet, jordanrhee, jefrogers, alok.a.tiwari,
	linux-kernel

From: Jordan Rhee <jordanrhee@google.com>

AdminQ commands may return -EAGAIN under certain transient conditions.
These commands are intended to be retried by the driver, so logging
a formal error to the system log is misleading and creates
unnecessary noise.

Modify the logging logic to skip the error message when the result
is -EAGAIN.

Reviewed-by: Joshua Washington <joshwash@google.com>
Signed-off-by: Jordan Rhee <jordanrhee@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
---
 drivers/net/ethernet/google/gve/gve_adminq.c | 26 +++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c
index 08587bf40ed4..c7834614c5f0 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.c
+++ b/drivers/net/ethernet/google/gve/gve_adminq.c
@@ -416,11 +416,6 @@ static bool gve_adminq_wait_for_cmd(struct gve_priv *priv, u32 prod_cnt)
 
 static int gve_adminq_parse_err(struct gve_priv *priv, u32 status)
 {
-	if (status != GVE_ADMINQ_COMMAND_PASSED &&
-	    status != GVE_ADMINQ_COMMAND_UNSET) {
-		dev_err(&priv->pdev->dev, "AQ command failed with status %d\n", status);
-		priv->adminq_cmd_fail++;
-	}
 	switch (status) {
 	case GVE_ADMINQ_COMMAND_PASSED:
 		return 0;
@@ -455,6 +450,16 @@ static int gve_adminq_parse_err(struct gve_priv *priv, u32 status)
 	}
 }
 
+static bool gve_adminq_is_retryable(enum gve_adminq_opcodes opcode)
+{
+	switch (opcode) {
+	case GVE_ADMINQ_REPORT_NIC_TIMESTAMP:
+		return true;
+	default:
+		return false;
+	}
+}
+
 /* Flushes all AQ commands currently queued and waits for them to complete.
  * If there are failures, it will return the first error.
  */
@@ -482,9 +487,18 @@ static int gve_adminq_kick_and_wait(struct gve_priv *priv)
 		cmd = &priv->adminq[i & priv->adminq_mask];
 		status = be32_to_cpu(READ_ONCE(cmd->status));
 		err = gve_adminq_parse_err(priv, status);
-		if (err)
+		if (err) {
+			enum gve_adminq_opcodes opcode =
+				be32_to_cpu(READ_ONCE(cmd->opcode));
+			priv->adminq_cmd_fail++;
+			if (!gve_adminq_is_retryable(opcode) || err != -EAGAIN)
+				dev_err_ratelimited(&priv->pdev->dev,
+						    "AQ command %d failed with status %d\n",
+						    opcode, status);
+
 			// Return the first error if we failed.
 			return err;
+		}
 	}
 
 	return 0;
-- 
2.53.0.851.ga537e3e6e9-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/3] gve: make nic clock reads thread safe
  2026-03-23 23:48 [PATCH net-next 0/3] gve: add support for PTP gettimex64 Harshitha Ramamurthy
  2026-03-23 23:48 ` [PATCH net-next 1/3] gve: skip error logging for retryable AdminQ commands Harshitha Ramamurthy
@ 2026-03-23 23:48 ` Harshitha Ramamurthy
  2026-03-23 23:48 ` [PATCH net-next 3/3] gve: implement PTP gettimex64 Harshitha Ramamurthy
  2 siblings, 0 replies; 6+ messages in thread
From: Harshitha Ramamurthy @ 2026-03-23 23:48 UTC (permalink / raw)
  To: netdev
  Cc: joshwash, hramamurthy, andrew+netdev, davem, edumazet, kuba,
	pabeni, richardcochran, willemb, nktgrg, jfraker, ziweixiao,
	maolson, thostet, jordanrhee, jefrogers, alok.a.tiwari,
	linux-kernel

From: Ankit Garg <nktgrg@google.com>

Add a mutex to protect the shared DMA buffer that receives NIC
timestamp reports. The NIC timestamp will be read from two different
threads: the periodic worker and upcoming `gettimex64`.

Reviewed-by: Joshua Washington <joshwash@google.com>
Signed-off-by: Ankit Garg <nktgrg@google.com>
Signed-off-by: Jordan Rhee <jordanrhee@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
---
 drivers/net/ethernet/google/gve/gve.h     |  6 +----
 drivers/net/ethernet/google/gve/gve_ptp.c | 32 +++++++++++++++--------
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h
index 1d66d3834f7e..7b8f78bd1968 100644
--- a/drivers/net/ethernet/google/gve/gve.h
+++ b/drivers/net/ethernet/google/gve/gve.h
@@ -923,6 +923,7 @@ struct gve_priv {
 	bool nic_timestamp_supported;
 	struct gve_ptp *ptp;
 	struct kernel_hwtstamp_config ts_config;
+	struct mutex nic_ts_read_lock; /* Protects nic_ts_report */
 	struct gve_nic_ts_report *nic_ts_report;
 	dma_addr_t nic_ts_report_bus;
 	u64 last_sync_nic_counter; /* Clock counter from last NIC TS report */
@@ -1321,14 +1322,9 @@ int gve_flow_rules_reset(struct gve_priv *priv);
 int gve_init_rss_config(struct gve_priv *priv, u16 num_queues);
 /* PTP and timestamping */
 #if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
-int gve_clock_nic_ts_read(struct gve_priv *priv);
 int gve_init_clock(struct gve_priv *priv);
 void gve_teardown_clock(struct gve_priv *priv);
 #else /* CONFIG_PTP_1588_CLOCK */
-static inline int gve_clock_nic_ts_read(struct gve_priv *priv)
-{
-	return -EOPNOTSUPP;
-}
 
 static inline int gve_init_clock(struct gve_priv *priv)
 {
diff --git a/drivers/net/ethernet/google/gve/gve_ptp.c b/drivers/net/ethernet/google/gve/gve_ptp.c
index 06b1cf4a5efc..140b8fbce4f4 100644
--- a/drivers/net/ethernet/google/gve/gve_ptp.c
+++ b/drivers/net/ethernet/google/gve/gve_ptp.c
@@ -11,19 +11,20 @@
 #define GVE_NIC_TS_SYNC_INTERVAL_MS 250
 
 /* Read the nic timestamp from hardware via the admin queue. */
-int gve_clock_nic_ts_read(struct gve_priv *priv)
+static int gve_clock_nic_ts_read(struct gve_priv *priv, u64 *nic_raw)
 {
-	u64 nic_raw;
 	int err;
 
+	mutex_lock(&priv->nic_ts_read_lock);
 	err = gve_adminq_report_nic_ts(priv, priv->nic_ts_report_bus);
 	if (err)
-		return err;
+		goto out;
 
-	nic_raw = be64_to_cpu(priv->nic_ts_report->nic_timestamp);
-	WRITE_ONCE(priv->last_sync_nic_counter, nic_raw);
+	*nic_raw = be64_to_cpu(priv->nic_ts_report->nic_timestamp);
 
-	return 0;
+out:
+	mutex_unlock(&priv->nic_ts_read_lock);
+	return err;
 }
 
 static int gve_ptp_gettimex64(struct ptp_clock_info *info,
@@ -43,15 +44,19 @@ static long gve_ptp_do_aux_work(struct ptp_clock_info *info)
 {
 	const struct gve_ptp *ptp = container_of(info, struct gve_ptp, info);
 	struct gve_priv *priv = ptp->priv;
+	u64 nic_raw;
 	int err;
 
 	if (gve_get_reset_in_progress(priv) || !gve_get_admin_queue_ok(priv))
 		goto out;
 
-	err = gve_clock_nic_ts_read(priv);
-	if (err && net_ratelimit())
-		dev_err(&priv->pdev->dev,
-			"%s read err %d\n", __func__, err);
+	err = gve_clock_nic_ts_read(priv, &nic_raw);
+	if (err) {
+		dev_err_ratelimited(&priv->pdev->dev, "%s read err %d\n",
+				    __func__, err);
+		goto out;
+	}
+	WRITE_ONCE(priv->last_sync_nic_counter, nic_raw);
 
 out:
 	return msecs_to_jiffies(GVE_NIC_TS_SYNC_INTERVAL_MS);
@@ -109,6 +114,7 @@ static void gve_ptp_release(struct gve_priv *priv)
 
 int gve_init_clock(struct gve_priv *priv)
 {
+	u64 nic_raw;
 	int err;
 
 	err = gve_ptp_init(priv);
@@ -125,17 +131,20 @@ int gve_init_clock(struct gve_priv *priv)
 		err = -ENOMEM;
 		goto release_ptp;
 	}
-	err = gve_clock_nic_ts_read(priv);
+	mutex_init(&priv->nic_ts_read_lock);
+	err = gve_clock_nic_ts_read(priv, &nic_raw);
 	if (err) {
 		dev_err(&priv->pdev->dev, "failed to read NIC clock %d\n", err);
 		goto release_nic_ts_report;
 	}
+	WRITE_ONCE(priv->last_sync_nic_counter, nic_raw);
 	ptp_schedule_worker(priv->ptp->clock,
 			    msecs_to_jiffies(GVE_NIC_TS_SYNC_INTERVAL_MS));
 
 	return 0;
 
 release_nic_ts_report:
+	mutex_destroy(&priv->nic_ts_read_lock);
 	dma_free_coherent(&priv->pdev->dev,
 			  sizeof(struct gve_nic_ts_report),
 			  priv->nic_ts_report, priv->nic_ts_report_bus);
@@ -150,6 +159,7 @@ void gve_teardown_clock(struct gve_priv *priv)
 	gve_ptp_release(priv);
 
 	if (priv->nic_ts_report) {
+		mutex_destroy(&priv->nic_ts_read_lock);
 		dma_free_coherent(&priv->pdev->dev,
 				  sizeof(struct gve_nic_ts_report),
 				  priv->nic_ts_report, priv->nic_ts_report_bus);
-- 
2.53.0.851.ga537e3e6e9-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/3] gve: implement PTP gettimex64
  2026-03-23 23:48 [PATCH net-next 0/3] gve: add support for PTP gettimex64 Harshitha Ramamurthy
  2026-03-23 23:48 ` [PATCH net-next 1/3] gve: skip error logging for retryable AdminQ commands Harshitha Ramamurthy
  2026-03-23 23:48 ` [PATCH net-next 2/3] gve: make nic clock reads thread safe Harshitha Ramamurthy
@ 2026-03-23 23:48 ` Harshitha Ramamurthy
  2026-03-25 14:08   ` kernel test robot
  2026-03-26  7:47   ` kernel test robot
  2 siblings, 2 replies; 6+ messages in thread
From: Harshitha Ramamurthy @ 2026-03-23 23:48 UTC (permalink / raw)
  To: netdev
  Cc: joshwash, hramamurthy, andrew+netdev, davem, edumazet, kuba,
	pabeni, richardcochran, willemb, nktgrg, jfraker, ziweixiao,
	maolson, thostet, jordanrhee, jefrogers, alok.a.tiwari,
	linux-kernel, Kevin Yang, Naman Gulati

From: Jordan Rhee <jordanrhee@google.com>

Enable chrony and phc2sys to synchronize system clock to NIC clock.

The system cycle counters are sampled by the device to minimize the
uncertainty window. If the system times are sampled in the host, the
delta between pre and post readings is 100us or more due to AQ command
latency. The system times returned by the device have a delta of ~1us,
which enables significantly more accurate clock synchronization.

Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Kevin Yang <yyd@google.com>
Reviewed-by: Naman Gulati <namangulati@google.com>
Signed-off-by: Jordan Rhee <jordanrhee@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
---
 drivers/net/ethernet/google/gve/gve_adminq.h |   4 +-
 drivers/net/ethernet/google/gve/gve_ptp.c    | 189 ++++++++++++++++++-
 2 files changed, 184 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/google/gve/gve_adminq.h b/drivers/net/ethernet/google/gve/gve_adminq.h
index 22a74b6aa17e..e6dcf6da9091 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.h
+++ b/drivers/net/ethernet/google/gve/gve_adminq.h
@@ -411,8 +411,8 @@ static_assert(sizeof(struct gve_adminq_report_nic_ts) == 16);
 
 struct gve_nic_ts_report {
 	__be64 nic_timestamp; /* NIC clock in nanoseconds */
-	__be64 reserved1;
-	__be64 reserved2;
+	__be64 pre_cycles; /* System cycle counter before NIC clock read */
+	__be64 post_cycles; /* System cycle counter after NIC clock read */
 	__be64 reserved3;
 	__be64 reserved4;
 };
diff --git a/drivers/net/ethernet/google/gve/gve_ptp.c b/drivers/net/ethernet/google/gve/gve_ptp.c
index 140b8fbce4f4..889f0120e1dd 100644
--- a/drivers/net/ethernet/google/gve/gve_ptp.c
+++ b/drivers/net/ethernet/google/gve/gve_ptp.c
@@ -10,28 +10,203 @@
 /* Interval to schedule a nic timestamp calibration, 250ms. */
 #define GVE_NIC_TS_SYNC_INTERVAL_MS 250
 
+/*
+ * Stores cycle counter samples in get_cycles() units from a
+ * sandwiched NIC clock read
+ */
+struct gve_sysclock_sample {
+	/* Cycle counter from NIC before clock read */
+	u64 nic_pre_cycles;
+	/* Cycle counter from NIC after clock read */
+	u64 nic_post_cycles;
+	/* Cycle counter from host before issuing AQ command */
+	cycles_t host_pre_cycles;
+	/* Cycle counter from host after AQ command returns */
+	cycles_t host_post_cycles;
+};
+
+/*
+ * Read NIC clock by issuing the AQ command. The command is subject to
+ * rate limiting and may need to be retried. Requires nic_ts_read_lock
+ * to be held.
+ */
+static int gve_adminq_read_timestamp(struct gve_priv *priv,
+				     cycles_t *pre_cycles,
+				     cycles_t *post_cycles)
+{
+	unsigned long delay_us = 1000;
+	int retry_count = 0;
+	int err;
+
+	lockdep_assert_held(&priv->nic_ts_read_lock);
+
+	do {
+		*pre_cycles = get_cycles();
+		err = gve_adminq_report_nic_ts(priv, priv->nic_ts_report_bus);
+
+		/* Ensure cycle counter is sampled after AdminQ cmd returns */
+		rmb();
+		*post_cycles = get_cycles();
+		if (likely(err != -EAGAIN))
+			return err;
+
+		fsleep(delay_us);
+
+		/* Exponential backoff */
+		delay_us *= 2;
+		retry_count++;
+	} while (retry_count < 5);
+
+	return -ETIMEDOUT;
+}
+
 /* Read the nic timestamp from hardware via the admin queue. */
-static int gve_clock_nic_ts_read(struct gve_priv *priv, u64 *nic_raw)
+static int gve_clock_nic_ts_read(struct gve_priv *priv, u64 *nic_raw,
+				 struct gve_sysclock_sample *sysclock)
 {
+	cycles_t host_pre_cycles, host_post_cycles;
+	struct gve_nic_ts_report *ts_report;
 	int err;
 
 	mutex_lock(&priv->nic_ts_read_lock);
-	err = gve_adminq_report_nic_ts(priv, priv->nic_ts_report_bus);
-	if (err)
+	err = gve_adminq_read_timestamp(priv, &host_pre_cycles,
+					&host_post_cycles);
+	if (err) {
+		dev_err_ratelimited(&priv->pdev->dev,
+				    "AdminQ timestamp read failed: %d\n", err);
 		goto out;
+	}
 
-	*nic_raw = be64_to_cpu(priv->nic_ts_report->nic_timestamp);
+	ts_report = priv->nic_ts_report;
+	*nic_raw = be64_to_cpu(ts_report->nic_timestamp);
+
+	if (sysclock) {
+		sysclock->nic_pre_cycles = be64_to_cpu(ts_report->pre_cycles);
+		sysclock->nic_post_cycles = be64_to_cpu(ts_report->post_cycles);
+		sysclock->host_pre_cycles = host_pre_cycles;
+		sysclock->host_post_cycles = host_post_cycles;
+	}
 
 out:
 	mutex_unlock(&priv->nic_ts_read_lock);
 	return err;
 }
 
+struct gve_cycles_to_clock_callback_ctx {
+	u64 cycles;
+};
+
+static int gve_cycles_to_clock_fn(ktime_t *device_time,
+				  struct system_counterval_t *system_counterval,
+				  void *ctx)
+{
+	struct gve_cycles_to_clock_callback_ctx *context = ctx;
+
+	*device_time = 0;
+
+	system_counterval->cycles = context->cycles;
+	system_counterval->use_nsecs = false;
+
+	if (IS_ENABLED(CONFIG_X86))
+		system_counterval->cs_id = CSID_X86_TSC;
+	else if (IS_ENABLED(CONFIG_ARM64))
+		system_counterval->cs_id = CSID_ARM_ARCH_COUNTER;
+	else
+		return -EOPNOTSUPP;
+
+	return 0;
+}
+
+/*
+ * Convert a raw cycle count (e.g. from get_cycles()) to the system clock
+ * type specified by clockid. The system_time_snapshot must be taken before
+ * the cycle counter is sampled.
+ */
+static int gve_cycles_to_timespec64(struct gve_priv *priv, clockid_t clockid,
+				    struct system_time_snapshot *snap,
+				    u64 cycles, struct timespec64 *ts)
+{
+	struct gve_cycles_to_clock_callback_ctx ctx = {0};
+	struct system_device_crosststamp xtstamp;
+	int err;
+
+	ctx.cycles = cycles;
+	err = get_device_system_crosststamp(gve_cycles_to_clock_fn, &ctx, snap,
+					    &xtstamp);
+	if (err) {
+		dev_err_ratelimited(&priv->pdev->dev,
+				    "get_device_system_crosststamp() failed to convert %lld cycles to system time: %d\n",
+				    cycles,
+				    err);
+		return err;
+	}
+
+	switch (clockid) {
+	case CLOCK_REALTIME:
+		*ts = ktime_to_timespec64(xtstamp.sys_realtime);
+		break;
+	case CLOCK_MONOTONIC_RAW:
+		*ts = ktime_to_timespec64(xtstamp.sys_monoraw);
+		break;
+	default:
+		dev_err_ratelimited(&priv->pdev->dev,
+				    "Cycle count conversion to clockid %d not supported\n",
+				    clockid);
+		return -EOPNOTSUPP;
+	}
+
+	return 0;
+}
+
 static int gve_ptp_gettimex64(struct ptp_clock_info *info,
 			      struct timespec64 *ts,
 			      struct ptp_system_timestamp *sts)
 {
-	return -EOPNOTSUPP;
+	struct gve_ptp *ptp = container_of(info, struct gve_ptp, info);
+	struct gve_sysclock_sample sysclock = {0};
+	struct gve_priv *priv = ptp->priv;
+	struct system_time_snapshot snap;
+	u64 nic_ts;
+	int err;
+
+	/* Take system clock snapshot before sampling cycle counters */
+	if (sts)
+		ktime_get_snapshot(&snap);
+
+	err = gve_clock_nic_ts_read(priv, &nic_ts, &sysclock);
+	if (err)
+		return err;
+
+	if (sts) {
+		/* Reject samples with out of order system clock values */
+		if (!(sysclock.host_pre_cycles <= sysclock.nic_pre_cycles &&
+		      sysclock.nic_pre_cycles  <= sysclock.nic_post_cycles &&
+		      sysclock.nic_post_cycles <= sysclock.host_post_cycles)) {
+			dev_err_ratelimited(&priv->pdev->dev,
+					    "AdminQ system clock cycle counts out of order. Expecting %llu <= %llu <= %llu <= %llu\n",
+					    sysclock.host_pre_cycles,
+					    sysclock.nic_pre_cycles,
+					    sysclock.nic_post_cycles,
+					    sysclock.host_post_cycles);
+			return -EBADMSG;
+		}
+
+		err = gve_cycles_to_timespec64(priv, sts->clockid, &snap,
+					       sysclock.nic_pre_cycles,
+					       &sts->pre_ts);
+		if (err)
+			return err;
+
+		err = gve_cycles_to_timespec64(priv, sts->clockid, &snap,
+					       sysclock.nic_post_cycles,
+					       &sts->post_ts);
+		if (err)
+			return err;
+	}
+
+	*ts = ns_to_timespec64(nic_ts);
+
+	return 0;
 }
 
 static int gve_ptp_settime64(struct ptp_clock_info *info,
@@ -50,7 +225,7 @@ static long gve_ptp_do_aux_work(struct ptp_clock_info *info)
 	if (gve_get_reset_in_progress(priv) || !gve_get_admin_queue_ok(priv))
 		goto out;
 
-	err = gve_clock_nic_ts_read(priv, &nic_raw);
+	err = gve_clock_nic_ts_read(priv, &nic_raw, NULL);
 	if (err) {
 		dev_err_ratelimited(&priv->pdev->dev, "%s read err %d\n",
 				    __func__, err);
@@ -132,7 +307,7 @@ int gve_init_clock(struct gve_priv *priv)
 		goto release_ptp;
 	}
 	mutex_init(&priv->nic_ts_read_lock);
-	err = gve_clock_nic_ts_read(priv, &nic_raw);
+	err = gve_clock_nic_ts_read(priv, &nic_raw, NULL);
 	if (err) {
 		dev_err(&priv->pdev->dev, "failed to read NIC clock %d\n", err);
 		goto release_nic_ts_report;
-- 
2.53.0.851.ga537e3e6e9-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 3/3] gve: implement PTP gettimex64
  2026-03-23 23:48 ` [PATCH net-next 3/3] gve: implement PTP gettimex64 Harshitha Ramamurthy
@ 2026-03-25 14:08   ` kernel test robot
  2026-03-26  7:47   ` kernel test robot
  1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-03-25 14:08 UTC (permalink / raw)
  To: Harshitha Ramamurthy, netdev
  Cc: oe-kbuild-all, joshwash, hramamurthy, andrew+netdev, davem,
	edumazet, kuba, pabeni, richardcochran, willemb, nktgrg, jfraker,
	ziweixiao, maolson, thostet, jordanrhee, jefrogers, alok.a.tiwari,
	linux-kernel, Kevin Yang, Naman Gulati

Hi Harshitha,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 5446b8691eb8278f10deca92048fad84ffd1e4d5]

url:    https://github.com/intel-lab-lkp/linux/commits/Harshitha-Ramamurthy/gve-skip-error-logging-for-retryable-AdminQ-commands/20260324-133808
base:   5446b8691eb8278f10deca92048fad84ffd1e4d5
patch link:    https://lore.kernel.org/r/20260323234829.3185051-4-hramamurthy%40google.com
patch subject: [PATCH net-next 3/3] gve: implement PTP gettimex64
config: arm-allyesconfig (https://download.01.org/0day-ci/archive/20260325/202603252126.CrpQ8IIi-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260325/202603252126.CrpQ8IIi-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603252126.CrpQ8IIi-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from include/linux/device.h:15,
                    from include/linux/dma-mapping.h:5,
                    from drivers/net/ethernet/google/gve/gve.h:10,
                    from drivers/net/ethernet/google/gve/gve_ptp.c:7:
   drivers/net/ethernet/google/gve/gve_ptp.c: In function 'gve_ptp_gettimex64':
>> drivers/net/ethernet/google/gve/gve_ptp.c:186:45: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'cycles_t' {aka 'long unsigned int'} [-Wformat=]
     186 |                                             "AdminQ system clock cycle counts out of order. Expecting %llu <= %llu <= %llu <= %llu\n",
         |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:154:56: note: in expansion of macro 'dev_fmt'
     154 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   include/linux/dev_printk.h:215:17: note: in expansion of macro 'dev_err'
     215 |                 dev_level(dev, fmt, ##__VA_ARGS__);                     \
         |                 ^~~~~~~~~
   include/linux/dev_printk.h:225:9: note: in expansion of macro 'dev_level_ratelimited'
     225 |         dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/google/gve/gve_ptp.c:185:25: note: in expansion of macro 'dev_err_ratelimited'
     185 |                         dev_err_ratelimited(&priv->pdev->dev,
         |                         ^~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/google/gve/gve_ptp.c:186:106: note: format string is defined here
     186 |                                             "AdminQ system clock cycle counts out of order. Expecting %llu <= %llu <= %llu <= %llu\n",
         |                                                                                                       ~~~^
         |                                                                                                          |
         |                                                                                                          long long unsigned int
         |                                                                                                       %lu
   drivers/net/ethernet/google/gve/gve_ptp.c:186:45: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 6 has type 'cycles_t' {aka 'long unsigned int'} [-Wformat=]
     186 |                                             "AdminQ system clock cycle counts out of order. Expecting %llu <= %llu <= %llu <= %llu\n",
         |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:154:56: note: in expansion of macro 'dev_fmt'
     154 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   include/linux/dev_printk.h:215:17: note: in expansion of macro 'dev_err'
     215 |                 dev_level(dev, fmt, ##__VA_ARGS__);                     \
         |                 ^~~~~~~~~
   include/linux/dev_printk.h:225:9: note: in expansion of macro 'dev_level_ratelimited'
     225 |         dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/google/gve/gve_ptp.c:185:25: note: in expansion of macro 'dev_err_ratelimited'
     185 |                         dev_err_ratelimited(&priv->pdev->dev,
         |                         ^~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/google/gve/gve_ptp.c:186:130: note: format string is defined here
     186 |                                             "AdminQ system clock cycle counts out of order. Expecting %llu <= %llu <= %llu <= %llu\n",
         |                                                                                                                               ~~~^
         |                                                                                                                                  |
         |                                                                                                                                  long long unsigned int
         |                                                                                                                               %lu


vim +186 drivers/net/ethernet/google/gve/gve_ptp.c

   160	
   161	static int gve_ptp_gettimex64(struct ptp_clock_info *info,
   162				      struct timespec64 *ts,
   163				      struct ptp_system_timestamp *sts)
   164	{
   165		struct gve_ptp *ptp = container_of(info, struct gve_ptp, info);
   166		struct gve_sysclock_sample sysclock = {0};
   167		struct gve_priv *priv = ptp->priv;
   168		struct system_time_snapshot snap;
   169		u64 nic_ts;
   170		int err;
   171	
   172		/* Take system clock snapshot before sampling cycle counters */
   173		if (sts)
   174			ktime_get_snapshot(&snap);
   175	
   176		err = gve_clock_nic_ts_read(priv, &nic_ts, &sysclock);
   177		if (err)
   178			return err;
   179	
   180		if (sts) {
   181			/* Reject samples with out of order system clock values */
   182			if (!(sysclock.host_pre_cycles <= sysclock.nic_pre_cycles &&
   183			      sysclock.nic_pre_cycles  <= sysclock.nic_post_cycles &&
   184			      sysclock.nic_post_cycles <= sysclock.host_post_cycles)) {
   185				dev_err_ratelimited(&priv->pdev->dev,
 > 186						    "AdminQ system clock cycle counts out of order. Expecting %llu <= %llu <= %llu <= %llu\n",
   187						    sysclock.host_pre_cycles,
   188						    sysclock.nic_pre_cycles,
   189						    sysclock.nic_post_cycles,
   190						    sysclock.host_post_cycles);
   191				return -EBADMSG;
   192			}
   193	
   194			err = gve_cycles_to_timespec64(priv, sts->clockid, &snap,
   195						       sysclock.nic_pre_cycles,
   196						       &sts->pre_ts);
   197			if (err)
   198				return err;
   199	
   200			err = gve_cycles_to_timespec64(priv, sts->clockid, &snap,
   201						       sysclock.nic_post_cycles,
   202						       &sts->post_ts);
   203			if (err)
   204				return err;
   205		}
   206	
   207		*ts = ns_to_timespec64(nic_ts);
   208	
   209		return 0;
   210	}
   211	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 3/3] gve: implement PTP gettimex64
  2026-03-23 23:48 ` [PATCH net-next 3/3] gve: implement PTP gettimex64 Harshitha Ramamurthy
  2026-03-25 14:08   ` kernel test robot
@ 2026-03-26  7:47   ` kernel test robot
  1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-03-26  7:47 UTC (permalink / raw)
  To: Harshitha Ramamurthy, netdev
  Cc: llvm, oe-kbuild-all, joshwash, hramamurthy, andrew+netdev, davem,
	edumazet, kuba, pabeni, richardcochran, willemb, nktgrg, jfraker,
	ziweixiao, maolson, thostet, jordanrhee, jefrogers, alok.a.tiwari,
	linux-kernel, Kevin Yang, Naman Gulati

Hi Harshitha,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 5446b8691eb8278f10deca92048fad84ffd1e4d5]

url:    https://github.com/intel-lab-lkp/linux/commits/Harshitha-Ramamurthy/gve-skip-error-logging-for-retryable-AdminQ-commands/20260324-133808
base:   5446b8691eb8278f10deca92048fad84ffd1e4d5
patch link:    https://lore.kernel.org/r/20260323234829.3185051-4-hramamurthy%40google.com
patch subject: [PATCH net-next 3/3] gve: implement PTP gettimex64
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20260326/202603261542.ki4x7Oq5-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260326/202603261542.ki4x7Oq5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603261542.ki4x7Oq5-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/google/gve/gve_ptp.c:187:10: warning: format specifies type 'unsigned long long' but the argument has type 'cycles_t' (aka 'unsigned long') [-Wformat]
     186 |                                             "AdminQ system clock cycle counts out of order. Expecting %llu <= %llu <= %llu <= %llu\n",
         |                                                                                                       ~~~~
         |                                                                                                       %lu
     187 |                                             sysclock.host_pre_cycles,
         |                                             ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:225:45: note: expanded from macro 'dev_err_ratelimited'
     225 |         dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__)
         |                                             ~~~    ^~~~~~~~~~~
   include/linux/dev_printk.h:215:25: note: expanded from macro 'dev_level_ratelimited'
     215 |                 dev_level(dev, fmt, ##__VA_ARGS__);                     \
         |                                ~~~    ^~~~~~~~~~~
   include/linux/dev_printk.h:154:65: note: expanded from macro 'dev_err'
     154 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                                ~~~     ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ~~~    ^~~~~~~~~~~
   drivers/net/ethernet/google/gve/gve_ptp.c:190:10: warning: format specifies type 'unsigned long long' but the argument has type 'cycles_t' (aka 'unsigned long') [-Wformat]
     186 |                                             "AdminQ system clock cycle counts out of order. Expecting %llu <= %llu <= %llu <= %llu\n",
         |                                                                                                                               ~~~~
         |                                                                                                                               %lu
     187 |                                             sysclock.host_pre_cycles,
     188 |                                             sysclock.nic_pre_cycles,
     189 |                                             sysclock.nic_post_cycles,
     190 |                                             sysclock.host_post_cycles);
         |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:225:45: note: expanded from macro 'dev_err_ratelimited'
     225 |         dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__)
         |                                             ~~~    ^~~~~~~~~~~
   include/linux/dev_printk.h:215:25: note: expanded from macro 'dev_level_ratelimited'
     215 |                 dev_level(dev, fmt, ##__VA_ARGS__);                     \
         |                                ~~~    ^~~~~~~~~~~
   include/linux/dev_printk.h:154:65: note: expanded from macro 'dev_err'
     154 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                                ~~~     ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ~~~    ^~~~~~~~~~~
   2 warnings generated.


vim +187 drivers/net/ethernet/google/gve/gve_ptp.c

   160	
   161	static int gve_ptp_gettimex64(struct ptp_clock_info *info,
   162				      struct timespec64 *ts,
   163				      struct ptp_system_timestamp *sts)
   164	{
   165		struct gve_ptp *ptp = container_of(info, struct gve_ptp, info);
   166		struct gve_sysclock_sample sysclock = {0};
   167		struct gve_priv *priv = ptp->priv;
   168		struct system_time_snapshot snap;
   169		u64 nic_ts;
   170		int err;
   171	
   172		/* Take system clock snapshot before sampling cycle counters */
   173		if (sts)
   174			ktime_get_snapshot(&snap);
   175	
   176		err = gve_clock_nic_ts_read(priv, &nic_ts, &sysclock);
   177		if (err)
   178			return err;
   179	
   180		if (sts) {
   181			/* Reject samples with out of order system clock values */
   182			if (!(sysclock.host_pre_cycles <= sysclock.nic_pre_cycles &&
   183			      sysclock.nic_pre_cycles  <= sysclock.nic_post_cycles &&
   184			      sysclock.nic_post_cycles <= sysclock.host_post_cycles)) {
   185				dev_err_ratelimited(&priv->pdev->dev,
   186						    "AdminQ system clock cycle counts out of order. Expecting %llu <= %llu <= %llu <= %llu\n",
 > 187						    sysclock.host_pre_cycles,
   188						    sysclock.nic_pre_cycles,
   189						    sysclock.nic_post_cycles,
   190						    sysclock.host_post_cycles);
   191				return -EBADMSG;
   192			}
   193	
   194			err = gve_cycles_to_timespec64(priv, sts->clockid, &snap,
   195						       sysclock.nic_pre_cycles,
   196						       &sts->pre_ts);
   197			if (err)
   198				return err;
   199	
   200			err = gve_cycles_to_timespec64(priv, sts->clockid, &snap,
   201						       sysclock.nic_post_cycles,
   202						       &sts->post_ts);
   203			if (err)
   204				return err;
   205		}
   206	
   207		*ts = ns_to_timespec64(nic_ts);
   208	
   209		return 0;
   210	}
   211	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-26  7:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 23:48 [PATCH net-next 0/3] gve: add support for PTP gettimex64 Harshitha Ramamurthy
2026-03-23 23:48 ` [PATCH net-next 1/3] gve: skip error logging for retryable AdminQ commands Harshitha Ramamurthy
2026-03-23 23:48 ` [PATCH net-next 2/3] gve: make nic clock reads thread safe Harshitha Ramamurthy
2026-03-23 23:48 ` [PATCH net-next 3/3] gve: implement PTP gettimex64 Harshitha Ramamurthy
2026-03-25 14:08   ` kernel test robot
2026-03-26  7:47   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox