Skip to content

Commit ecad80f

Browse files
committed
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
1 parent eddc0ac commit ecad80f

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

‎drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ static void hibmc_plane_atomic_update(struct drm_plane *plane,
9696
{
9797
struct drm_plane_state *state = plane->state;
9898
u32 reg;
99-
int ret;
10099
s64 gpu_addr = 0;
101100
unsigned int line_l;
102101
struct hibmc_drm_private *priv = plane->dev->dev_private;
@@ -109,16 +108,9 @@ static void hibmc_plane_atomic_update(struct drm_plane *plane,
109108
hibmc_fb = to_hibmc_framebuffer(state->fb);
110109
gbo = drm_gem_vram_of_gem(hibmc_fb->obj);
111110

112-
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
113-
if (ret) {
114-
DRM_ERROR("failed to pin bo: %d", ret);
115-
return;
116-
}
117111
gpu_addr = drm_gem_vram_offset(gbo);
118-
if (gpu_addr < 0) {
119-
drm_gem_vram_unpin(gbo);
120-
return;
121-
}
112+
if (WARN_ON_ONCE(gpu_addr < 0))
113+
return; /* Bug: we didn't pin the BO to VRAM in prepare_fb. */
122114

123115
writel(gpu_addr, priv->mmio + HIBMC_CRT_FB_ADDRESS);
124116

@@ -157,6 +149,8 @@ static struct drm_plane_funcs hibmc_plane_funcs = {
157149
};
158150

159151
static const struct drm_plane_helper_funcs hibmc_plane_helper_funcs = {
152+
.prepare_fb = drm_gem_vram_plane_helper_prepare_fb,
153+
.cleanup_fb = drm_gem_vram_plane_helper_cleanup_fb,
160154
.atomic_check = hibmc_plane_atomic_check,
161155
.atomic_update = hibmc_plane_atomic_update,
162156
};

0 commit comments

Comments
 (0)