From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/msm: Add PERFCNTR_CONFIG ioctl
Date: Mon, 25 May 2026 21:26:30 +1000 [thread overview]
Message-ID: <review-patch13-20260520162454.18391-14-robin.clark@oss.qualcomm.com> (raw)
In-Reply-To: <20260520162454.18391-14-robin.clark@oss.qualcomm.com>
Patch Review
This is the main ioctl patch. Several observations:
**Include style**: The includes use `"linux/anon_inodes.h"` (quotes) rather than `<linux/anon_inodes.h>` (angle brackets). Kernel convention is angle brackets for kernel headers:
```c
+#include "linux/anon_inodes.h"
+#include "linux/gfp_types.h"
+#include "linux/poll.h"
+#include "linux/slab.h"
```
Should be `<linux/...>`.
**`copy_from_user` with `group_stride`**: The ioctl copies `args->group_stride` bytes from each user group entry:
```c
if (copy_from_user(&g, userptr, args->group_stride))
```
There's no validation that `args->group_stride <= sizeof(struct drm_msm_perfcntr_group)`. If userspace passes a `group_stride` larger than the kernel's struct size, this overflows the stack-allocated `g`. The stride should be clamped to `min(args->group_stride, sizeof(g))`.
**`bufsz_shift` validation**: `stream->fifo_size = 1 << args->bufsz_shift`. If `bufsz_shift` is very large (e.g., 63), this is undefined behavior due to left-shifting past the type width. There's a later check `stream->fifo_size > SZ_128M`, but the UB happens first. Should validate `bufsz_shift` is reasonable (e.g., `<= 27` for 128M) before the shift.
**Non-blocking read returns 0**: In `msm_perfcntrs_stream_read()`, when `O_NONBLOCK` is set and the FIFO is empty, `fifo_count_to_end()` returns 0, so `count` becomes 0, `copy_to_user` copies nothing, and the function returns 0. A non-blocking read on an empty fd should return `-EAGAIN`, not 0. Returning 0 signals EOF to userspace.
**`fifo_space` in `sample_worker`**: The `fifo_space()` macro reads `stream->fifo.tail` without `smp_load_acquire`. This is the producer reading the consumer's tail — per the kernel circ_buf documentation, this should use `READ_ONCE()` at minimum (the macro uses `CIRC_SPACE` which doesn't include barriers). In practice, this likely works because the kthread worker is the only producer and the mutex-protected read path is the only consumer, but it would be more correct to use `READ_ONCE` on the tail read.
**Counter allocation not reverted on error**: In the ioctl, when processing groups with `MSM_PERFCNTR_STREAM`, the code sets `perfcntrs->groups[idx]->allocated_counters` and copies countables. If a later group fails validation (e.g., `-E2BIG` or `-EFAULT` from a subsequent `copy_from_user`), these already-modified group states are not rolled back. This could leave stale `allocated_counters` values since the `perfcntrs->groups[]` state is persistent (pre-allocated).
**UAPI comment typo**: "The data read from the has the following format" — missing noun after "from the".
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-25 11:26 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 16:23 [PATCH v8 00/16] drm/msm: Add PERFCNTR_CONFIG ioctl Rob Clark
2026-05-20 16:23 ` [PATCH v8 01/16] drm/msm: Remove obsolete perf infrastructure Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 02/16] drm/msm: Allow CAP_PERFMON for setting SYSPROF Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 03/16] drm/msm/adreno: Sync registers from mesa Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 04/16] drm/msm/registers: Sync gen_header.py " Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 05/16] drm/msm/registers: Add perfcntr json Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 06/16] drm/msm: Add a6xx+ perfcntr tables Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 07/16] drm/msm: Add sysprof accessors Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 08/16] drm/msm/a6xx: Add yield & flush helper Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 09/16] drm/msm: Add per-context perfcntr state Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 10/16] drm/msm: Add basic perfcntr infrastructure Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 11/16] drm/msm/a6xx+: Add support to configure perfcntrs Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:23 ` [PATCH v8 12/16] drm/msm/a8xx: Add perfcntr flush sequence Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:24 ` [PATCH v8 13/16] drm/msm: Add PERFCNTR_CONFIG ioctl Rob Clark
2026-05-25 11:26 ` Claude Code Review Bot [this message]
2026-05-20 16:24 ` [PATCH v8 14/16] drm/msm/a6xx: Increase pwrup_reglist size Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:24 ` [PATCH v8 15/16] drm/msm/a6xx: Append SEL regs to dyn pwrup reglist Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-20 16:24 ` [PATCH v8 16/16] drm/msm/a6xx: Allow IFPC with perfcntr stream Rob Clark
2026-05-25 11:26 ` Claude review: " Claude Code Review Bot
2026-05-25 11:26 ` Claude review: drm/msm: Add PERFCNTR_CONFIG ioctl Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-05-26 14:50 [PATCH v10 00/16] " Rob Clark
2026-05-26 14:50 ` [PATCH v10 13/16] " Rob Clark
2026-05-27 4:42 ` Claude review: " Claude Code Review Bot
2026-05-27 4:42 ` Claude Code Review Bot
2026-05-22 17:32 [PATCH v9 00/16] " Rob Clark
2026-05-22 17:32 ` [PATCH v9 13/16] " Rob Clark
2026-05-25 8:21 ` Claude review: " Claude Code Review Bot
2026-05-25 8:21 ` Claude Code Review Bot
2026-05-14 13:39 [PATCH v6 00/16] " Rob Clark
2026-05-14 13:40 ` [PATCH v6 13/16] " Rob Clark
2026-05-16 0:50 ` Claude review: " Claude Code Review Bot
2026-05-16 0:50 ` Claude Code Review Bot
2026-05-11 12:59 [PATCH v5 00/16] " Rob Clark
2026-05-11 12:59 ` [PATCH v5 13/16] " Rob Clark
2026-05-16 5:20 ` Claude review: " Claude Code Review Bot
2026-05-16 5:20 ` Claude Code Review Bot
2026-05-06 17:10 [PATCH v3 00/16] " Rob Clark
2026-05-06 17:10 ` [PATCH v4 13/16] " Rob Clark
2026-05-07 3:19 ` Claude review: " Claude Code Review Bot
2026-05-07 3:19 ` Claude Code Review Bot
2026-05-04 19:06 [PATCH v3 00/16] " Rob Clark
2026-05-04 19:06 ` [PATCH v3 13/16] " Rob Clark
2026-05-04 22:06 ` Claude review: " Claude Code Review Bot
2026-05-04 22:06 ` Claude Code Review Bot
2026-04-20 22:25 [PATCH 00/13] " Rob Clark
2026-04-20 22:25 ` [PATCH 13/13] " Rob Clark
2026-04-22 23:13 ` Claude review: " Claude Code Review Bot
2026-04-22 23:13 ` Claude Code Review Bot
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-patch13-20260520162454.18391-14-robin.clark@oss.qualcomm.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