OSDN Git Service

drm/gem: Clear mapping addresses for unused framebuffer planes
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 30 Jul 2021 18:35:09 +0000 (20:35 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 2 Aug 2021 14:41:20 +0000 (16:41 +0200)
Set the returned mapping address to NULL if a framebuffer plane does
not have a BO associated with it. Likewise, ignore mappings of NULL
during framebuffer unmap operations. Allows users of the functions to
perform unmap operations of certain BOs by themselfes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210730183511.20080-4-tzimmermann@suse.de
drivers/gpu/drm/drm_gem_framebuffer_helper.c

index 2bc0605..5731a6a 100644 (file)
@@ -335,8 +335,10 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb,
 
        for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) {
                obj = drm_gem_fb_get_obj(fb, i);
-               if (!obj)
+               if (!obj) {
+                       dma_buf_map_clear(&map[i]);
                        continue;
+               }
                ret = drm_gem_vmap(obj, &map[i]);
                if (ret)
                        goto err_drm_gem_vunmap;
@@ -376,6 +378,8 @@ void drm_gem_fb_vunmap(struct drm_framebuffer *fb,
                obj = drm_gem_fb_get_obj(fb, i);
                if (!obj)
                        continue;
+               if (dma_buf_map_is_null(&map[i]))
+                       continue;
                drm_gem_vunmap(obj, &map[i]);
        }
 }