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: Thu, 07 May 2026 13:14:48 +1000	[thread overview]
Message-ID: <review-patch2-20260506175610.2542888-3-zhengxingda@iscas.ac.cn> (raw)
In-Reply-To: <20260506175610.2542888-3-zhengxingda@iscas.ac.cn>

Patch Review

**Bug (critical) — Missing field shift macros for negative coordinate offsets:**

In `vs_cursor_plane_atomic_update()`, when writing negative X/Y offsets, the raw value is passed without shifting it to the register field position:

```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)` — it covers bits 16 through 20. The value `-state->crtc_x` is a small positive integer (1–31), which has no bits set in the 16–20 range. `regmap_update_bits` applies `val & mask`, so the offset will always be written as **zero**. The cursor will jump to position 0 instead of being partially offscreen.

The same bug applies to Y_OFF at `GENMASK(12, 8)`.

Fix: use the defined shift macros:
```c
VSDC_CURSOR_CONFIG_X_OFF(-state->crtc_x)
VSDC_CURSOR_CONFIG_Y_OFF(-state->crtc_y)
```

The header already defines `VSDC_CURSOR_CONFIG_X_OFF(v)` as `((v) << 16)` and `VSDC_CURSOR_CONFIG_Y_OFF(v)` as `((v) << 8)`, but they are never used.

**Bug (off-by-one) — Coordinate range checks allow values that overflow the register fields:**

```c
#define VSDC_CURSOR_LOCATION_MAX_POSITIVE BIT_MASK(15)
#define VSDC_CURSOR_LOCATION_MAX_NEGATIVE BIT_MASK(5)
```

`BIT_MASK(15)` = `1UL << 15` = 32768, but `VSDC_CURSOR_LOCATION_X_MASK` is `GENMASK(14, 0)` which is 15 bits holding values 0–32767. The check `coord <= 32768` accepts coord=32768, which cannot be represented in the field and would silently wrap to 0.

Similarly, `BIT_MASK(5)` = 32, but the 5-bit offset fields (`GENMASK(12, 8)` / `GENMASK(20, 16)`) hold values 0–31. The check `(-coord) <= 32` accepts 32, which overflows.

Both comparisons should use `<` instead of `<=`:
```c
return coord < VSDC_CURSOR_LOCATION_MAX_POSITIVE;
return (-coord) < VSDC_CURSOR_LOCATION_MAX_NEGATIVE;
```

**Issue — Missing `cursor_width`/`cursor_height` in mode_config:**

The driver never sets `drm->mode_config.cursor_width` or `drm->mode_config.cursor_height`. Userspace queries these via `DRM_CAP_CURSOR_WIDTH` / `DRM_CAP_CURSOR_HEIGHT`; they default to 64, which happens to match the current HWDB entries. But if a DC variant with `max_cursor_size = 256` is added later, userspace would still see 64. Consider setting these in `vs_mode_config_init()` or after the CRTCs are created.

**Nit — Typos in register header:**

```c
#define VSDC_CURSOR_BACKGRUOND_DEFAULT  0x00FFFFFF
#define VSDC_CURSOR_FOREGRUOND_DEFAULT  0x00AAAAAA
```

"BACKGRUOND" and "FOREGRUOND" should be "BACKGROUND" and "FOREGROUND". These macros are unused now but will rot if not fixed before someone references them.

**Nit — Garbled comment:**

```c
 * values are unsigned. To for positive left-top  coordinates the
```

"To for positive" doesn't parse. Probably should be "For positive". Also has a double space before "coordinates".

**Nit — License inconsistency:**

`vs_cursor_plane.c` uses `GPL-2.0-only` while `vs_cursor_plane_regs.h` uses `GPL-2.0-or-later`. Both are valid choices but the inconsistency within a single feature is worth noting.

**Minor — Unused `fb` variable when invisible:**

In `vs_cursor_plane_atomic_check()`, `fb` is assigned from `new_plane_state->fb` at the top but only used after the visibility check. This is harmless (no dereference on the invisible path) but could be moved down for clarity.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-05-07  3:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 17:56 [PATCH v3 0/2] drm: verisilicon: add hardware cursor support Icenowy Zheng
2026-05-06 17:56 ` [PATCH v3 1/2] drm: verisilicon: add max cursor size to HWDB Icenowy Zheng
2026-05-07  3:14   ` Claude review: " Claude Code Review Bot
2026-05-06 17:56 ` [PATCH v3 2/2] drm: verisilicon: add support for cursor planes Icenowy Zheng
2026-05-07  3:14   ` Claude Code Review Bot [this message]
2026-05-07  3:14 ` 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
2026-03-09  8:53 [PATCH -next 0/2] drm: verisilicon: add hardware cursor support Icenowy Zheng
2026-03-09  8:53 ` [PATCH -next 2/2] drm: verisilicon: add support for cursor planes Icenowy Zheng
2026-03-10  2:36   ` 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-20260506175610.2542888-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