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/hibmc: Use gem-shmem with shadow-plane helpers for memory management
Date: Thu, 04 Jun 2026 14:13:48 +1000	[thread overview]
Message-ID: <review-patch4-20260601114756.51953-5-tzimmermann@suse.de> (raw)
In-Reply-To: <20260601114756.51953-5-tzimmermann@suse.de>

Patch Review

**Status: Good**

This is the main conversion patch. Key aspects:

**Shadow-plane pattern (hibmc_drm_de.c):** The damage-based copy from shadow buffer to VRAM follows the established pattern used in ast and mgag200:

```c
if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE) == 0) {
    ...
    drm_atomic_for_each_plane_damage(&iter, &damage) {
        struct iosys_map dst[DRM_FORMAT_MAX_PLANES] = {
            IOSYS_MAP_INIT_VADDR_IOMEM(priv->vram + gpu_addr),
        };
        iosys_map_incr(&dst[0],
                       drm_fb_clip_offset(fb->pitches[0], fb->format, &damage));
        drm_fb_memcpy(dst, fb->pitches, shadow_plane_state->data, fb, &damage);
    }
    drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
}
```

- `DMA_FROM_DEVICE` is correct: syncing for CPU read of a buffer that might have been written by a sharing device.
- The `dst` array is declared inside the loop body, so it's freshly initialized per damage rect. Correct.
- `gpu_addr = 0` is appropriate since there's a single primary plane and VRAM is dedicated to the scanout buffer starting at offset 0.
- `fb->pitches` as dst_pitch matches the `HIBMC_CRT_FB_WIDTH_OFFS` register programming, keeping source and destination layout consistent.

**VRAM mapping (hibmc_drm_drv.c):**

```c
priv->vram = devm_ioremap_wc(dev->dev, vram_base, vram_size);
```

Write-combining is the correct mapping for framebuffer VRAM -- provides optimal write performance for sequential memcpy patterns.

**Mode validation:**

```c
pitch = drm_format_info_min_pitch(info, 0, mode->hdisplay);
if (!pitch)
    return MODE_BAD_WIDTH;
else if (pitch > max_fb_size / mode->vdisplay)
    return MODE_MEM;
```

The division-based check (`pitch > max_fb_size / vdisplay`) avoids multiplication overflow and is slightly conservative (may reject modes right at the boundary due to integer division truncation), but this is the standard pattern and the conservative direction is the safe one.

**DRM core change (drm_gem_shmem_helper.c):** Exporting `drm_gem_shmem_create_with_handle` is a reasonable API addition. The function was already implemented as static; making it public with a kernel-doc comment and header prototype is clean. This enables drivers with custom `dumb_create` (needing alignment beyond what `drm_gem_shmem_dumb_create` provides) to use it directly.

**Kconfig:**

```diff
+	select DRM_GEM_SHMEM_HELPER
 	select DRM_KMS_HELPER
-	select DRM_VRAM_HELPER
-	select DRM_TTM
-	select DRM_TTM_HELPER
```

Clean removal of TTM dependencies, replaced with shmem. The `.fb_create = drm_gem_fb_create_with_dirty` and `DRM_GEM_SHADOW_PLANE_FUNCS`/`DRM_GEM_SHADOW_PLANE_HELPER_FUNCS` macros complete the conversion.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-06-04  4:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 11:45 [PATCH v3 0/4] drm/hibmc: Fix plane helpers and convert to gem-shmem Thomas Zimmermann
2026-06-01 11:45 ` [PATCH v3 1/4] drm/hibmc: Use drm_atomic_helper_check_plane_state() Thomas Zimmermann
2026-06-04  4:13   ` Claude review: " Claude Code Review Bot
2026-06-01 11:45 ` [PATCH v3 2/4] drm/hibmc: Fix list of formats on the primary plane Thomas Zimmermann
2026-06-04  4:13   ` Claude review: " Claude Code Review Bot
2026-06-01 11:45 ` [PATCH v3 3/4] drm/hibmc: Do not use cpp from struct drm_format_info Thomas Zimmermann
2026-06-04  4:13   ` Claude review: " Claude Code Review Bot
2026-06-01 11:45 ` [PATCH v3 4/4] drm/hibmc: Use gem-shmem with shadow-plane helpers for memory management Thomas Zimmermann
2026-06-04  4:13   ` Claude Code Review Bot [this message]
2026-06-04  4:13 ` Claude review: drm/hibmc: Fix plane helpers and convert to gem-shmem Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-04-20 12:09 [PATCH v2 0/4] " Thomas Zimmermann
2026-04-20 12:10 ` [PATCH v2 4/4] drm/hibmc: Use gem-shmem with shadow-plane helpers for memory management Thomas Zimmermann
2026-04-23  0: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-patch4-20260601114756.51953-5-tzimmermann@suse.de \
    --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