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/sun4i: layers: Use drm_fb_dma_get_gem_addr() to get display memory
Date: Tue, 10 Mar 2026 12:07:04 +1000	[thread overview]
Message-ID: <review-patch1-20260309165635.1138413-1-wens@kernel.org> (raw)
In-Reply-To: <20260309165635.1138413-1-wens@kernel.org>

Patch Review

**UI layer (`sun8i_ui_layer.c`) — Clean conversion:**

The old code:
```c
gem = drm_fb_dma_get_gem_obj(fb, 0);
bpp = fb->format->cpp[0];
dma_addr = gem->dma_addr + fb->offsets[0];
dma_addr += (state->src.x1 >> 16) * bpp;
dma_addr += (state->src.y1 >> 16) * fb->pitches[0];
```

is replaced by:
```c
dma_addr = drm_fb_dma_get_gem_addr(fb, state, 0);
```

For plane 0 with standard (non-block) formats, the helper computes `obj->dma_addr + offsets[0] + sample_x * char_per_block[0] + sample_y * pitches[0]`, which is equivalent. This conversion is correct.

**VI layer (`sun8i_vi_layer.c`) — Subtle behavioral difference:**

The old code explicitly aligns source coordinates to chroma subsampling boundaries before computing offsets:
```c
src_x = (state->src.x1 >> 16) & ~(format->hsub - 1);
src_y = (state->src.y1 >> 16) & ~(format->vsub - 1);
```

The helper does not perform this alignment — it just divides by hsub/vsub directly:
```c
sample_x = (state->src_x >> 16) / h_div;
sample_y = (state->src_y >> 16) / v_div;
```

For **plane > 0** (chroma planes), these produce the same result: integer division by hsub has the same effect as masking then dividing when the coordinates are valid (aligned to subsampling boundaries). The DRM atomic check framework should validate that source coordinates are properly aligned for subsampled formats.

For **plane 0** (luma), the old code applied the alignment mask before using the coordinates (`dx = src_x` without division), effectively rounding the luma offset down to a chroma-aligned boundary. The helper does not do this alignment for plane 0 (h_div=v_div=1). In practice, for valid state, source coordinates should already be aligned, so this is a no-op difference. If anything, the old behavior of rounding down luma coordinates was slightly wrong — it could silently shift the displayed region.

**Minor nits:**
- The `DRM_DEBUG_DRIVER("Using GEM @ %pad\n", ...)` debug prints are removed. This is fine — they add noise and the helper is well-established across many drivers. Other sun4i files (`sun4i_backend.c`, `sun4i_frontend.c`) already use this helper without such debug prints.
- The unused variable `format` (alias for `fb->format`) is left in `sun8i_vi_layer_update_buffer` — it's still used for `format->num_planes` in the loop, so that's fine.

**Verdict:** The patch is correct. The alignment difference in the VI layer is not a real-world concern since DRM enforces valid coordinates.

Reviewed-by: AI Review (informational, non-binding)

---
Generated by Claude Code Patch Reviewer

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 16:56 [PATCH] drm/sun4i: layers: Use drm_fb_dma_get_gem_addr() to get display memory Chen-Yu Tsai
2026-03-09 17:57 ` Jernej Škrabec
2026-03-10  2:07 ` Claude review: " Claude Code Review Bot
2026-03-10  2:07 ` Claude Code Review Bot [this message]

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-patch1-20260309165635.1138413-1-wens@kernel.org \
    --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