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/hibmc: Use gem-shmem with shadow-plane helpers for memory management Date: Thu, 04 Jun 2026 14:13:48 +1000 Message-ID: In-Reply-To: <20260601114756.51953-5-tzimmermann@suse.de> References: <20260601114756.51953-1-tzimmermann@suse.de> <20260601114756.51953-5-tzimmermann@suse.de> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 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