Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/hisilicon/hibmc: Use GEM VRAM's prepare_fb() and cleanup_fb() helpers

This patch implements prepare_fb() and cleanup_fb() in hibmc with the
GEM VRAM helpers. In the current code, pinning the BO is performed by
hibmc_plane_atomic_update(), where the operation does not belong.

This patch also fixes a bug where the pinned BO was never unpinned.
Pinning multiple BOs would have exhaused the available VRAM and further
pin operations would have failed, leaving the display in a corrupt
state.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20191024081404.6978-4-tzimmermann@suse.de

+4 -10
+4 -10
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
··· 96 96 { 97 97 struct drm_plane_state *state = plane->state; 98 98 u32 reg; 99 - int ret; 100 99 s64 gpu_addr = 0; 101 100 unsigned int line_l; 102 101 struct hibmc_drm_private *priv = plane->dev->dev_private; ··· 108 109 hibmc_fb = to_hibmc_framebuffer(state->fb); 109 110 gbo = drm_gem_vram_of_gem(hibmc_fb->obj); 110 111 111 - ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM); 112 - if (ret) { 113 - DRM_ERROR("failed to pin bo: %d", ret); 114 - return; 115 - } 116 112 gpu_addr = drm_gem_vram_offset(gbo); 117 - if (gpu_addr < 0) { 118 - drm_gem_vram_unpin(gbo); 119 - return; 120 - } 113 + if (WARN_ON_ONCE(gpu_addr < 0)) 114 + return; /* Bug: we didn't pin the BO to VRAM in prepare_fb. */ 121 115 122 116 writel(gpu_addr, priv->mmio + HIBMC_CRT_FB_ADDRESS); 123 117 ··· 149 157 }; 150 158 151 159 static const struct drm_plane_helper_funcs hibmc_plane_helper_funcs = { 160 + .prepare_fb = drm_gem_vram_plane_helper_prepare_fb, 161 + .cleanup_fb = drm_gem_vram_plane_helper_cleanup_fb, 152 162 .atomic_check = hibmc_plane_atomic_check, 153 163 .atomic_update = hibmc_plane_atomic_update, 154 164 };