From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot 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 Message-ID: In-Reply-To: <72a93cdd-b105-41aa-bf12-d6caf7e90078@arm.com> References: <20260318112952.645160-1-marcin.slusarz@arm.com> <72a93cdd-b105-41aa-bf12-d6caf7e90078@arm.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 =3D cpu_ts.tv_sec; arg->cpu_timestamp_nsec =3D cpu_ts.tv_nsec; ``` `timens_add_monotonic()` adds the time namespace monotonic offset (from `in= clude/linux/time_namespace.h:78`): ```c *ts =3D timespec64_add(*ts, ns_offsets->monotonic); ``` This is **incorrect** when `DRM_PANTHOR_TIMESTAMP_CPU_MONOTONIC_RAW` is sel= ected. `CLOCK_MONOTONIC_RAW` is explicitly immune to time namespace adjustm= ents =E2=80=94 that's its defining characteristic versus `CLOCK_MONOTONIC`.= The kernel's own `posix-timers.c` and `clock_gettime` paths do not apply t= imens offsets to `CLOCK_MONOTONIC_RAW`. This should be: ```c if ((flags & DRM_PANTHOR_TIMESTAMP_CPU_TYPE_MASK) =3D=3D 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 u= se case (a few register reads). However, `local_clock()` returns `u64`, and= the subtraction `local_clock() - query_start_time` produces a `u64` that g= ets silently truncated: ```c arg->duration_nsec =3D local_clock() - query_start_time; ``` This is practically fine since the query should complete in microseconds, b= ut documenting the maximum representable duration or using a cast to make t= he 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 =E2=80=94 `local_irq_save` implicitly disables preemp= tion, so the explicit `preempt_disable` first is redundant but harmless. Th= e 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 disab= led is safe =E2=80=94 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=3D0 default approach works well: - Old userspace passes `args->size` =3D 24 (original struct size) - `copy_struct_from_user` zero-fills the new fields including `flags` - `flags =3D=3D 0` triggers the default path returning the same data as bef= ore - `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_a= dd_monotonic` applied unconditionally to both MONOTONIC and MONOTONIC_RAW) = and one typo. The backward compatibility approach is sound and the IRQ-disa= ble section for timestamp correlation is appropriate. The `timens_add_monot= onic` bug should be fixed before merging. --- Generated by Claude Code Patch Reviewer