drm/vkms: Let shadow-plane helpers prepare the plane's FB
Replace vkms' prepare_fb and cleanup_fb functions with the generic code for shadow-buffered planes. No functional changes. This change also fixes a problem where IGT kms_flip tests would create a segmentation fault within vkms. The driver's prepare_fb function did not report an error if a BO's vmap operation failed. The kernel later tried to operate on the non-mapped memory areas. The shared shadow-plane helpers handle errors correctly, so that the driver now avoids the segmantation fault. v2: * include paragraph about IGT tests in commit message (Melissa) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Melissa Wen <melissa.srw@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210705074633.9425-4-tzimmermann@suse.de
This commit is contained in:
parent
7602d42218
commit
b43e2ec03b
1 changed files with 1 additions and 37 deletions
|
@ -8,7 +8,6 @@
|
||||||
#include <drm/drm_gem_atomic_helper.h>
|
#include <drm/drm_gem_atomic_helper.h>
|
||||||
#include <drm/drm_gem_framebuffer_helper.h>
|
#include <drm/drm_gem_framebuffer_helper.h>
|
||||||
#include <drm/drm_plane_helper.h>
|
#include <drm/drm_plane_helper.h>
|
||||||
#include <drm/drm_gem_shmem_helper.h>
|
|
||||||
|
|
||||||
#include "vkms_drv.h"
|
#include "vkms_drv.h"
|
||||||
|
|
||||||
|
@ -150,45 +149,10 @@ static int vkms_plane_atomic_check(struct drm_plane *plane,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vkms_prepare_fb(struct drm_plane *plane,
|
|
||||||
struct drm_plane_state *state)
|
|
||||||
{
|
|
||||||
struct drm_gem_object *gem_obj;
|
|
||||||
struct dma_buf_map map;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!state->fb)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
gem_obj = drm_gem_fb_get_obj(state->fb, 0);
|
|
||||||
ret = drm_gem_shmem_vmap(gem_obj, &map);
|
|
||||||
if (ret)
|
|
||||||
DRM_ERROR("vmap failed: %d\n", ret);
|
|
||||||
|
|
||||||
return drm_gem_plane_helper_prepare_fb(plane, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vkms_cleanup_fb(struct drm_plane *plane,
|
|
||||||
struct drm_plane_state *old_state)
|
|
||||||
{
|
|
||||||
struct drm_gem_object *gem_obj;
|
|
||||||
struct drm_gem_shmem_object *shmem_obj;
|
|
||||||
struct dma_buf_map map;
|
|
||||||
|
|
||||||
if (!old_state->fb)
|
|
||||||
return;
|
|
||||||
|
|
||||||
gem_obj = drm_gem_fb_get_obj(old_state->fb, 0);
|
|
||||||
shmem_obj = to_drm_gem_shmem_obj(drm_gem_fb_get_obj(old_state->fb, 0));
|
|
||||||
dma_buf_map_set_vaddr(&map, shmem_obj->vaddr);
|
|
||||||
drm_gem_shmem_vunmap(gem_obj, &map);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = {
|
static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = {
|
||||||
.atomic_update = vkms_plane_atomic_update,
|
.atomic_update = vkms_plane_atomic_update,
|
||||||
.atomic_check = vkms_plane_atomic_check,
|
.atomic_check = vkms_plane_atomic_check,
|
||||||
.prepare_fb = vkms_prepare_fb,
|
DRM_GEM_SHADOW_PLANE_HELPER_FUNCS,
|
||||||
.cleanup_fb = vkms_cleanup_fb,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
|
struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
|
||||||
|
|
Loading…
Add table
Reference in a new issue