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: drm: verisilicon: add support for cursor planes
Date: Tue, 10 Mar 2026 12:36:01 +1000	[thread overview]
Message-ID: <review-patch2-20260309085302.3132732-3-zhengxingda@iscas.ac.cn> (raw)
In-Reply-To: <20260309085302.3132732-3-zhengxingda@iscas.ac.cn>

Patch Review

**Bug (critical) — Negative coordinate offset values not shifted to bit field positions:**

In `vs_cursor_plane_atomic_update()`, when handling negative `crtc_x`:
```c
regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
                   VSDC_CURSOR_CONFIG_X_OFF_MASK,
                   -state->crtc_x);
```
`VSDC_CURSOR_CONFIG_X_OFF_MASK` is `GENMASK(20, 16)` (bits 20:16), but `-state->crtc_x` is not shifted to that position. Since `regmap_update_bits` performs `(old & ~mask) | (val & mask)`, the unshifted value will be ANDed with `0x1F0000`, yielding zero for any small coordinate value. The X offset will always be programmed as 0.

The fix is to use the existing shift macro:
```c
VSDC_CURSOR_CONFIG_X_OFF(-state->crtc_x)
```

The same bug exists for negative `crtc_y`:
```c
regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
                   VSDC_CURSOR_CONFIG_Y_OFF_MASK,
                   -state->crtc_y);
```
`VSDC_CURSOR_CONFIG_Y_OFF_MASK` is `GENMASK(12, 8)`, but the value is not shifted. Should use `VSDC_CURSOR_CONFIG_Y_OFF(-state->crtc_y)`.

**Bug — Off-by-one errors in coordinate range checks:**

```c
#define VSDC_CURSOR_LOCATION_MAX_POSITIVE BIT_MASK(15)
#define VSDC_CURSOR_LOCATION_MAX_NEGATIVE BIT_MASK(5)
```
`BIT_MASK(n)` in the kernel is `(1UL << n)`, so `BIT_MASK(15)` = 32768 and `BIT_MASK(5)` = 32. But the LOCATION X/Y fields are 15 bits wide (`GENMASK(14, 0)` / `GENMASK(30, 16)`), which can hold 0–32767 max. And the offset fields are 5 bits wide, which can hold 0–31 max. The checks `coord <= BIT_MASK(15)` and `(-coord) <= BIT_MASK(5)` each allow one value too many. These should use `BIT_MASK(15) - 1` and `BIT_MASK(5) - 1`, or equivalently `GENMASK(14, 0)` and `GENMASK(4, 0)`.

**Comment typo:**
```c
 * To for positive left-top  coordinates the
```
Should be "For positive left-top coordinates the" (extra word "To" and double space).

**Typos in register defines** (`vs_cursor_plane_regs.h`):
```c
#define VSDC_CURSOR_BACKGRUOND_DEFAULT	0x00FFFFFF
#define VSDC_CURSOR_FOREGRUOND_DEFAULT	0x00AAAAAA
```
`BACKGRUOND` → `BACKGROUND`, `FOREGRUOND` → `FOREGROUND`. These are unused currently but will cause confusion if referenced later.

**Unrelated copyright change** in `vs_primary_plane_regs.h`: This patch changes the copyright header of `vs_primary_plane_regs.h` from Icenowy Zheng's personal email to the ISCAS institutional copyright and updates the year. This is unrelated to cursor plane support and should be a separate patch if desired.

**Missing `.prepare_fb` helper:** The cursor plane helper funcs don't include `.prepare_fb = drm_gem_plane_helper_prepare_fb` (or the shadow-plane equivalent). The primary plane appears to also omit this, so it may be handled elsewhere, but it's worth verifying that GEM buffer pinning/mapping is handled correctly for cursor buffers.

**`drmm_universal_plane_alloc` usage:**
```c
plane = drmm_universal_plane_alloc(drm_dev, struct drm_plane, dev, 0, ...);
```
The `member` argument `dev` refers to the `struct drm_device *dev` pointer within `struct drm_plane`. This is unusual — normally the macro is used with a wrapping struct where `member` names the embedded `struct drm_plane`. However, this matches the primary plane's existing usage and appears to be an existing pattern in this driver, so not an issue introduced by this series.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-03-10  2:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09  8:53 [PATCH -next 0/2] drm: verisilicon: add hardware cursor support Icenowy Zheng
2026-03-09  8:53 ` [PATCH -next 1/2] drm: verisilicon: add max cursor size to HWDB Icenowy Zheng
2026-03-10  2:36   ` Claude review: " Claude Code Review Bot
2026-03-09  8:53 ` [PATCH -next 2/2] drm: verisilicon: add support for cursor planes Icenowy Zheng
2026-03-10  2:36   ` Claude Code Review Bot [this message]
2026-03-10  2:36 ` Claude review: drm: verisilicon: add hardware cursor support Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-24  6:02 [PATCH -next v2 0/2] " Icenowy Zheng
2026-03-24  6:02 ` [PATCH -next v2 2/2] drm: verisilicon: add support for cursor planes Icenowy Zheng
2026-03-24 21:03   ` Claude review: " 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-patch2-20260309085302.3132732-3-zhengxingda@iscas.ac.cn \
    --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