From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/panthor: Add support for repeated mappings
Date: Sat, 14 Mar 2026 06:48:46 +1000 [thread overview]
Message-ID: <review-patch8-20260313150956.1618635-9-adrian.larumbe@collabora.com> (raw)
In-Reply-To: <20260313150956.1618635-9-adrian.larumbe@collabora.com>
Patch Review
**Off-by-one in error cleanup path:**
```c
+err_unmap:
+ panthor_vm_unmap_pages(vm, iova, size * (i - 1));
+ return ret;
```
If the first iteration (`i=0`) fails, `i - 1` wraps to `U64_MAX` (since `i` is `u64`), which would be catastrophic. Even if it doesn't fail on `i=0`, when `i=1` and the second map fails, the cleanup should unmap `size * 1` bytes starting from `iova`, but `size * (i-1) = size * 0 = 0` would unmap nothing. The correct cleanup is `size * i`:
```c
err_unmap:
panthor_vm_unmap_pages(vm, iova, size * i);
return ret;
```
Because at iteration `i`, maps 0 through i-1 succeeded, so `i * size` bytes need unmapping.
**Declaration after statement:**
```c
+ u64 repeat_count = size;
+
+ if (do_div(repeat_count, repeat_range))
+ return -EINVAL;
```
This `u64 repeat_count` declaration is after the preceding `if` statement block. While C99/GNU89 allows this and the kernel has moved to accept it, some coding style checkers may flag it. More importantly, `repeat_count` is not used after the check -- it's only used to verify divisibility. A comment would help clarity.
**UAPI: `bo_repeat_range` added after `syncs` in `drm_panthor_vm_bind_op`:**
```c
+ __u64 bo_repeat_range;
};
```
This is added at the end of the struct, which is correct for UAPI extensibility. However, the existing struct ends with `struct drm_panthor_obj_array syncs;` followed by an empty line and `};`. The new field is after `syncs`. Since userspace that doesn't know about this field will pass a smaller struct, the kernel copy_from_user logic (via `PANTHOR_UOBJ`) needs to handle this gracefully (zero-filling unknown trailing bytes). The panthor UOBJ infrastructure does handle this, so this should be fine.
**`vm->base.flags |= DRM_GPUVM_HAS_REPEAT_MAPS` without locking consideration:** This is done inside `panthor_gpuva_sm_step_map` which should be called under appropriate locks, but worth confirming.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-03-13 20:48 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 15:09 [PATCH v5 00/11] Support repeated mappings in GPUVM and Panthor Adrián Larumbe
2026-03-13 15:09 ` [PATCH v5 01/11] drm/panthor: Expose GPU page sizes to UM Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 15:09 ` [PATCH v5 02/11] drm/gpuvm: Remove dead code Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 15:09 ` [PATCH v5 03/11] drm/gpuvm: Fix comment to reflect remap operation operand status Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 15:09 ` [PATCH v5 04/11] drm/gpuvm: Add a helper to check if two VA can be merged Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 15:09 ` [PATCH v5 05/11] drm/gpuvm: Add a flags field to drm_gpuva_op_map Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 15:09 ` [PATCH v5 06/11] drm/gpuvm: Add DRM_GPUVA_REPEAT flag and logic Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 15:09 ` [PATCH v5 07/11] drm/gpuvm: Ensure correctness of unmap/remaps of repeated regions Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 15:09 ` [PATCH v5 08/11] drm/panthor: Add support for repeated mappings Adrián Larumbe
2026-03-13 20:48 ` Claude Code Review Bot [this message]
2026-03-13 15:09 ` [PATCH v5 09/11] drm/panthor: Handle remap case " Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 15:09 ` [PATCH v5 10/11] drm/panthor: Pass vm_bind_op to vm_prepare_map_op_ctx Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 15:09 ` [PATCH v5 11/11] drm/panthor: Bump the driver version to 1.8 Adrián Larumbe
2026-03-13 20:48 ` Claude review: " Claude Code Review Bot
2026-03-13 20:48 ` Claude review: Support repeated mappings in GPUVM and Panthor 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-patch8-20260313150956.1618635-9-adrian.larumbe@collabora.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