Skip to content

Commit 8ac37c8

Browse files
author
Rob Clark
committed
drm/msm: Refcount framebuffer pins
We were already keeping a refcount of # of prepares (pins), to clear the iova array. Use that to avoid unpinning the iova until the last cleanup (unpin). This way, when msm_gem_unpin_iova() actually tears down the mapping, we won't have problems if the fb is being scanned out on another display (for example). Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com> Tested-by: Antonino Maniscalco <antomani103@gmail.com> Reviewed-by: Antonino Maniscalco <antomani103@gmail.com> Patchwork: https://patchwork.freedesktop.org/patch/661477/
1 parent 4d0f62e commit 8ac37c8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/gpu/drm/msm/msm_fb.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb, bool needs_dirtyfb)
8585
if (needs_dirtyfb)
8686
refcount_inc(&msm_fb->dirtyfb);
8787

88-
atomic_inc(&msm_fb->prepare_count);
88+
if (atomic_inc_return(&msm_fb->prepare_count) > 1)
89+
return 0;
8990

9091
for (i = 0; i < n; i++) {
9192
ret = msm_gem_get_and_pin_iova(fb->obj[i], vm, &msm_fb->iova[i]);
@@ -108,11 +109,13 @@ void msm_framebuffer_cleanup(struct drm_framebuffer *fb, bool needed_dirtyfb)
108109
if (needed_dirtyfb)
109110
refcount_dec(&msm_fb->dirtyfb);
110111

112+
if (atomic_dec_return(&msm_fb->prepare_count))
113+
return;
114+
115+
memset(msm_fb->iova, 0, sizeof(msm_fb->iova));
116+
111117
for (i = 0; i < n; i++)
112118
msm_gem_unpin_iova(fb->obj[i], vm);
113-
114-
if (!atomic_dec_return(&msm_fb->prepare_count))
115-
memset(msm_fb->iova, 0, sizeof(msm_fb->iova));
116119
}
117120

118121
uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb, int plane)

0 commit comments

Comments
 (0)