public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: Re: [PATCH] drm/panthor: extend timestamp query with flags
Date: Wed, 25 Mar 2026 06:49:24 +1000	[thread overview]
Message-ID: <review-patch4-72a93cdd-b105-41aa-bf12-d6caf7e90078@arm.com> (raw)
In-Reply-To: <72a93cdd-b105-41aa-bf12-d6caf7e90078@arm.com>

Patch Review

This is the latest version with Boris's Reviewed-by. Detailed review:

**Bug: `timens_add_monotonic` applied to `CLOCK_MONOTONIC_RAW`**

```c
	if (flags & DRM_PANTHOR_TIMESTAMP_CPU_TYPE_MASK) {
		timens_add_monotonic(&cpu_ts);

		arg->cpu_timestamp_sec = cpu_ts.tv_sec;
		arg->cpu_timestamp_nsec = cpu_ts.tv_nsec;
```

`timens_add_monotonic()` adds the time namespace monotonic offset (from `include/linux/time_namespace.h:78`):
```c
	*ts = timespec64_add(*ts, ns_offsets->monotonic);
```

This is **incorrect** when `DRM_PANTHOR_TIMESTAMP_CPU_MONOTONIC_RAW` is selected. `CLOCK_MONOTONIC_RAW` is explicitly immune to time namespace adjustments — that's its defining characteristic versus `CLOCK_MONOTONIC`. The kernel's own `posix-timers.c` and `clock_gettime` paths do not apply timens offsets to `CLOCK_MONOTONIC_RAW`. This should be:

```c
	if ((flags & DRM_PANTHOR_TIMESTAMP_CPU_TYPE_MASK) ==
	     DRM_PANTHOR_TIMESTAMP_CPU_MONOTONIC) {
		timens_add_monotonic(&cpu_ts);
	}
```

Or simply skip `timens_add_monotonic` for the RAW case.

**Minor: `duration_nsec` is `__u32`**

```c
	/** @duration_nsec: Duration of time query. */
	__u32 duration_nsec;
```

A `__u32` can hold ~4.29 seconds of nanoseconds, which is plenty for this use case (a few register reads). However, `local_clock()` returns `u64`, and the subtraction `local_clock() - query_start_time` produces a `u64` that gets silently truncated:

```c
		arg->duration_nsec = local_clock() - query_start_time;
```

This is practically fine since the query should complete in microseconds, but documenting the maximum representable duration or using a cast to make the truncation explicit would be cleaner.

**Observation: preempt_disable + local_irq_save ordering**

```c
	if (minimize_interruption) {
		preempt_disable();
		local_irq_save(irq_flags);
	}
```

This ordering is fine — `local_irq_save` implicitly disables preemption, so the explicit `preempt_disable` first is redundant but harmless. The restore order (irq_restore then preempt_enable) is correct.

**Observation: `ktime_get_ts64` with IRQs disabled**

Calling `ktime_get_ts64()` and `ktime_get_raw_ts64()` with interrupts disabled is safe — they use seqcount-based reads of the timekeeping data and don't sleep or take locks that require IRQs.

**Style: "Nanseconds" typo**

```c
	/** @cpu_timestamp_nsec: Nanseconds part of CPU timestamp. */
```

Should be "Nanoseconds".

**Observation: backward compatibility is correct**

The `copy_struct_from_user` + flags=0 default approach works well:
- Old userspace passes `args->size` = 24 (original struct size)
- `copy_struct_from_user` zero-fills the new fields including `flags`
- `flags == 0` triggers the default path returning the same data as before
- `PANTHOR_UOBJ_SET` copies back only 24 bytes, omitting new fields
- Old userspace is unaware of the extension

**Observation: CPU_TYPE_MASK reserves 3 bits (values 0-7) but only uses 0-2**

This is good forward-thinking design, reserving space for future CPU clock types (e.g., `CLOCK_BOOTTIME` could be value 3).

**Summary for v4**: The patch is well-designed with one real bug (`timens_add_monotonic` applied unconditionally to both MONOTONIC and MONOTONIC_RAW) and one typo. The backward compatibility approach is sound and the IRQ-disable section for timestamp correlation is appropriate. The `timens_add_monotonic` bug should be fixed before merging.

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-03-24 20:49 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 11:29 [PATCH] drm/panthor: extend timestamp query with flags Marcin Slusarz
2026-03-18 12:10 ` Boris Brezillon
2026-03-18 14:51   ` Marcin Ślusarz
2026-03-18 15:20     ` Steven Price
2026-03-18 16:06       ` Boris Brezillon
2026-03-18 16:27         ` Marcin Ślusarz
2026-03-18 16:37           ` Boris Brezillon
2026-03-18 16:34       ` Boris Brezillon
2026-03-24 20:49       ` Claude Code Review Bot [this message]
2026-03-21 18:32     ` Claude review: " Claude Code Review Bot
2026-03-21 18:32   ` Claude Code Review Bot
2026-03-19  8:25 ` [PATCH v2] " Marcin Slusarz
2026-03-19 10:15   ` Boris Brezillon
2026-03-19 11:00 ` [PATCH v3] " Marcin Slusarz
2026-03-19 11:10   ` Boris Brezillon
2026-03-19 11:43   ` Liviu Dudau
2026-03-19 12:39     ` Marcin Ślusarz
2026-03-19 15:17       ` Liviu Dudau
2026-03-19 15:33         ` Marcin Ślusarz
2026-03-23 13:16           ` Liviu Dudau
2026-03-23 16:12             ` Marcin Ślusarz
2026-03-24 10:41               ` Liviu Dudau
2026-03-24 13:26                 ` Marcin Ślusarz
2026-03-21 18:24 ` Claude review: " Claude Code Review Bot
2026-03-21 18:32 ` Claude Code Review Bot
2026-03-24 13:25 ` [PATCH v4] " Marcin Slusarz
2026-03-24 15:25   ` Liviu Dudau
2026-03-24 16:05   ` Liviu Dudau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch4-72a93cdd-b105-41aa-bf12-d6caf7e90078@arm.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox