linux/include/drm
Thomas Zimmermann 60b5fa6edf drm/hibmc: Use gem-shmem with shadow-plane helpers for memory management
Replace the gem-vram memory manager with gem-shmem. Makes the driver more
robust and enables dma-buf sharing with other hardware.

Gem-vram was created from various drivers that used TTM for their memory
management. All these drivers have meanwhile been converted to gem-shmem.
Using gem-vram is deprecated because it has several problems.

* TTM requires significant overcommitment of video memory for reliable
page flips. There needs to be 3 times the size of the largest possible
framebuffer available or page flips can fail. This leaves the display
dark without further warning. Hibmc hardware with 32 MiB and a maximum
framebuffer size of 1920x2000 is at the limit.

* No dma-buf sharing without GTT support. Neither gem-vram nor hibmc
hardware support a GTT address space. This is required to share buffers
with other devices via dma-buf interfaces.

* TTM requires hardware-accelerated rendering into video memory for
optimal results. As hibmc hardware cannot do this, hibmc renders in
system memory and copies the result to video memory. This can be more
effectively implemented with gem-shmem and DRM's shadow-plane helpers.

Converting hibmc to gem-shmem and shadow-plane helpers.

* Replace gem-vram entry points in struct drm_driver with gem-shmem
equivalents. This makes the driver allocate struct drm_gem_shmem_object
for its buffers.

* Use DRM_GEM_SHADOW_*_PLANE for its plane funcs and plane-helper
funcs. The shadow-plane helpers map a plane's gem buffer objects into
kernel address space during a page flip, so that atomic_update can
copy them to video memory.

* Handle framebuffer damage in hibmc_plane_atomic_update(). This updates
video memory from the plane's framebuffer. It automatically synchronizes
shared buffers with other devices. Create the framebuffer with
drm_gem_fb_create_with_dirty() to trigger the update on each page flip.

* Initialize the plane with drm_plane_enable_fb_damage_clips() to limit
the damage updates to the framebuffer areas that changed. We don't want
to do a full-buffer memcpy if only a small area has changed.

* Test display modes against the available video memory in
hibmc_mode_config_mode_valid(). We only want to announce display modes
that fit into display memory.

* Map the display memory itself into kernel address space.

* Do not set drm_mode_config.prefer_shadow. This would advise user space
to install a shadow buffer. But with gem-shmem, the gem buffer object
already acts as a shadow buffer for video memory.

We use these patterns in many other drivers with similar limitation as
hibmc and its hardware. With these changes in place, hibmc is more robust
and better integrated into the overall DRM framework.

v3:
- fix coding style
v2:
- do not select TTM symbols

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Yongbang Shi <shiyongbang@huawei.com>
Link: https://patch.msgid.link/20260618123142.92298-7-tzimmermann@suse.de
2026-06-24 08:57:29 +02:00
..
amd drm/amd/amdgpu: Add helper functions for isp buffers 2025-07-16 16:17:35 -04:00
bridge drm/bridge: analogix_dp: Add support for RK3576 2026-06-02 22:09:03 +02:00
clients drm/client: Move public client header to clients/ subdirectory 2024-11-15 09:42:13 +01:00
display drm/dp: Add max bpp delta computation constants 2026-06-24 09:27:33 +05:30
intel - A Revert of a Kconfig patch that broke some builds (Jani) 2026-05-15 15:37:16 +10:00
ttm Linux 7.1-rc5 2026-05-28 09:58:36 +02:00
amd_asic_type.h drm/amdgpu: make amd_asic_type.h self-contained 2024-03-07 17:17:25 +02:00
drm_accel.h drm: move drm based debugfs funcs to drm_debugfs.c 2025-07-04 15:58:22 +02:00
drm_atomic_helper.h drm/atomic-helper: Add HDMI bridge output bus formats helper 2026-06-09 21:03:50 +01:00
drm_atomic_state_helper.h drm/atomic-state-helper: Remove drm_atomic_helper_bridge_reset() 2026-06-22 11:24:57 +02:00
drm_atomic_uapi.h drm/plane: Add COLOR PIPELINE property 2025-11-26 23:03:32 +01:00
drm_atomic.h drm/atomic: Expand atomic_create_state expectations for drm_private_obj 2026-05-29 11:41:49 +02:00
drm_audio_component.h
drm_auth.h
drm_blend.h drm: Rename struct drm_atomic_state to drm_atomic_commit 2026-05-04 14:05:04 +10:00
drm_bridge_connector.h
drm_bridge_helper.h drm/bridge: Add helper to reset bridge pipeline 2025-03-20 14:45:48 +01:00
drm_bridge.h drm/bridge: Remove atomic_reset support 2026-06-22 11:25:00 +02:00
drm_buddy.h gpu: Move DRM buddy allocator one level up (part two) 2026-02-06 11:38:35 +10:00
drm_cache.h
drm_client_event.h drm/client: Pass force parameter to client restore 2025-11-25 08:43:46 +01:00
drm_client.h drm/client: Export drm_client_buffer_create() 2026-03-03 09:28:31 +01:00
drm_color_mgmt.h drm: Add helper to extract lut from struct drm_color_lut32 2025-11-26 23:03:35 +01:00
drm_colorop.h drm/colorop: Create drm_atomic_helper_colorop_create_state() 2026-05-29 11:41:50 +02:00
drm_connector.h drm/connector: Let connectors have a say in their color format 2026-06-09 21:03:50 +01:00
drm_crtc_helper.h drm: Rename struct drm_atomic_state to drm_atomic_commit 2026-05-04 14:05:04 +10:00
drm_crtc.h drm/crtc: Add new atomic_create_state callback 2026-05-29 11:41:53 +02:00
drm_damage_helper.h drm: Rename struct drm_atomic_state to drm_atomic_commit 2026-05-04 14:05:04 +10:00
drm_debugfs_crc.h drm/crc: Fix typo in doc for drm_crtc_crc 2026-05-04 14:26:53 +02:00
drm_debugfs.h drm: Remove DRIVER_GEM_GPUVA feature flag 2026-05-29 19:03:10 +02:00
drm_device.h drm/gem: Make the GEM LRU lock part of drm_device 2026-05-18 15:16:47 +02:00
drm_drv.h drm: Remove DRIVER_GEM_GPUVA feature flag 2026-05-29 19:03:10 +02:00
drm_dumb_buffers.h drm/dumb-buffers: Provide helper to set pitch and size 2025-09-29 13:57:43 +02:00
drm_edid.h Revert "drm/edid: add CTA Video Format Data Block support" 2026-05-06 11:22:15 +02:00
drm_eld.h
drm_encoder.h drm/encoder: add mutex to protect the bridge chain 2026-04-16 09:08:42 +02:00
drm_exec.h drm/exec, drm/xe, drm/amdgpu: Add an accessor for struct drm_exec::ticket 2026-05-25 10:45:38 +02:00
drm_fb_dma_helper.h drm/fb_dma: s/drm_panic_gem_get_scanout_buffer/drm_fb_dma_get_scanout_buffer 2024-04-15 13:50:40 -03:00
drm_fb_helper.h drm/amdgpu: fix build for CONFIG_DRM_FBDEV_EMULATION=n 2026-04-28 15:43:04 -04:00
drm_fbdev_dma.h drm/fbdev-dma: Remove obsolete setup function 2024-09-26 09:31:27 +02:00
drm_fbdev_shmem.h drm/fbdev-shmem: Remove obsolete setup function 2024-09-26 09:31:28 +02:00
drm_fbdev_ttm.h drm/fbdev-ttm: Remove obsolete setup function 2024-09-26 09:31:29 +02:00
drm_file.h drm/syncobj: Convert syncobj idr to xarray 2025-12-18 09:05:30 +00:00
drm_fixed.h drm: Add helper for conversion from signed-magnitude 2025-11-26 22:16:13 +01:00
drm_flip_work.h
drm_format_helper.h drm/format-helper: Remove drm_fb_blit() 2025-09-23 15:06:06 +02:00
drm_fourcc.h drm: Pass pixel_format+modifier directly to drm_get_format_info() 2025-07-16 20:01:13 +03:00
drm_framebuffer.h drm/framebuffer: Acquire internal references on GEM handles 2025-07-09 14:03:28 +02:00
drm_gem_atomic_helper.h
drm_gem_dma_helper.h fs: move FMODE_UNSIGNED_OFFSET to fop_flags 2024-08-30 08:22:36 +02:00
drm_gem_framebuffer_helper.h drm/gem/afbc: Eliminate redundant drm_get_format_info() 2025-07-16 20:06:22 +03:00
drm_gem_shmem_helper.h drm/hibmc: Use gem-shmem with shadow-plane helpers for memory management 2026-06-24 08:57:29 +02:00
drm_gem_ttm_helper.h
drm_gem_vram_helper.h drm/gem-vram: Un-export pin helpers 2025-05-30 09:47:28 +02:00
drm_gem.h drm: Remove DRIVER_GEM_GPUVA feature flag 2026-05-29 19:03:10 +02:00
drm_gpusvm.h drm/gpusvm: Drop redundant @flags.* kernel-doc on struct drm_gpusvm_pages 2026-05-07 00:17:15 -07:00
drm_gpuvm.h drm/gpuvm: use const for drm_gpuva_op_* ptrs 2026-01-08 18:06:56 +01:00
drm_ioctl.h
drm_kunit_helpers.h drm: Rename struct drm_atomic_state to drm_atomic_commit 2026-05-04 14:05:04 +10:00
drm_lease.h drm/lease: make drm_lease.h self-contained 2024-03-07 17:17:25 +02:00
drm_managed.h drm/managed: fix drmm_add_action() kernel-doc 2026-06-03 11:24:52 +02:00
drm_mipi_dbi.h drm: Rename struct drm_atomic_state to drm_atomic_commit 2026-05-04 14:05:04 +10:00
drm_mipi_dsi.h drm/mipi-dsi: add flag for sending all DSC slices in one packet 2026-06-07 02:31:01 +03:00
drm_mm.h drm/mm: replace drm_print.h include with a forward declaration 2025-10-31 10:34:56 +02:00
drm_mode_config.h drm/mode-config: Create drm_mode_config_create_initial_state() 2026-05-29 11:42:45 +02:00
drm_mode_object.h drm/mode_object: add drm_object_immutable_property_get_value() 2026-01-14 02:18:31 +02:00
drm_modes.h drm: Move drm_set_preferred_mode() helper from drm_edid to drm_modes 2024-01-05 21:14:46 +01:00
drm_modeset_helper_vtables.h drm: Rename struct drm_atomic_state to drm_atomic_commit 2026-05-04 14:05:04 +10:00
drm_modeset_helper.h drm: Allow the caller to pass in the format info to drm_helper_mode_fill_fb_struct() 2025-07-16 20:04:45 +03:00
drm_modeset_lock.h
drm_module.h
drm_of.h drm/of: add helper to count data-lanes on a remote endpoint 2026-04-18 02:10:37 +03:00
drm_pagemap_util.h drm/pagemap_util: Add a utility to assign an owner to a set of interconnected gpus 2025-12-23 10:00:47 +01:00
drm_pagemap.h drm/pagemap: Drop source_peer_migrates flag and assume true 2026-04-12 20:51:11 -07:00
drm_panel.h drm/panel: Make drm_panel_init() static 2026-05-11 09:14:21 +02:00
drm_panic.h drm/panic: Add a private field to struct drm_scanout_buffer 2025-06-27 11:48:22 +02:00
drm_pciids.h
drm_plane_helper.h
drm_plane.h drm/plane: Add new atomic_create_state callback 2026-05-29 11:41:52 +02:00
drm_prime.h drm/shmem-helper: Import dmabuf without mapping its sg_table 2025-06-03 09:21:01 +02:00
drm_print.h drm/print: describe 6th & 9th bit of drm.debug 2026-06-03 11:24:52 +02:00
drm_privacy_screen_consumer.h
drm_privacy_screen_driver.h
drm_privacy_screen_machine.h
drm_probe_helper.h drm/probe-helper: Do not fail from drmm_kms_helper_poll_init() 2025-03-24 09:31:03 +01:00
drm_property.h drm/atomic: add max_size check to drm_property_replace_blob_from_id() 2026-01-14 02:18:31 +02:00
drm_ras_genl_family.h drm/ras: Introduce the DRM RAS infrastructure over generic netlink 2026-03-05 19:38:55 -05:00
drm_ras.h drm/drm_ras: Add clear-error-counter netlink command to drm_ras 2026-04-24 08:43:42 -04:00
drm_rect.h drm/rect: Add drm_rect_overlap() 2024-08-23 16:47:56 +02:00
drm_self_refresh_helper.h drm: Rename struct drm_atomic_state to drm_atomic_commit 2026-05-04 14:05:04 +10:00
drm_simple_kms_helper.h drm/simple-kms: Deprecate simple-kms helpers 2026-03-25 15:05:22 +01:00
drm_suballoc.h drm/sa: Split drm_suballoc_new() into SA alloc and init helpers 2026-02-20 10:54:02 -08:00
drm_syncobj.h
drm_sysfs.h
drm_util.h drm: Move for_each_if() to util_macros.h for wider use 2025-02-17 14:27:35 +01:00
drm_utils.h drm: panel-backlight-quirks: Add brightness mask quirk 2025-09-03 10:23:01 -05:00
drm_vblank_helper.h drm: Rename struct drm_atomic_state to drm_atomic_commit 2026-05-04 14:05:04 +10:00
drm_vblank_work.h drm: Add drm_vblank_work_flush_all(). 2024-06-24 18:03:18 +02:00
drm_vblank.h drm/vblank: add return value to drm_crtc_wait_one_vblank() 2025-12-11 16:55:36 +02:00
drm_vma_manager.h
drm_writeback.h drm: writeback: Create drmm variants for drm_writeback_connector initialization 2025-01-21 10:32:33 +01:00
gpu_scheduler.h drm/sched: Remove drm_sched_init_args->num_rqs 2026-04-17 14:43:30 +02:00
gud.h
Makefile kbuild: Let kernel-doc.py use PYTHON3 override 2025-11-08 19:42:22 -07:00
spsc_queue.h drm/sched: Increment job count before swapping tail spsc queue 2025-07-01 16:14:47 -07:00
task_barrier.h