From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot 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 Message-ID: In-Reply-To: <20260313150956.1618635-9-adrian.larumbe@collabora.com> References: <20260313150956.1618635-1-adrian.larumbe@collabora.com> <20260313150956.1618635-9-adrian.larumbe@collabora.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 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