mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
drm/udl: Move vmap out of commit tail
Vmap operations may acquire the dmabuf reservation lock, which is not allowed within atomic commit-tail functions. Therefore move vmap and vunmap from the damage handler into prepare_fb and cleanup_fb callbacks. The mapping is provided as GEM shadow-buffered plane. The functions in the commit tail use the pre-established mapping for damage handling. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Tested-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210208115538.6430-8-tzimmermann@suse.de
This commit is contained in:
parent
4ac0868d43
commit
5ceeb32863
1 changed files with 13 additions and 21 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include <drm/drm_crtc_helper.h>
|
#include <drm/drm_crtc_helper.h>
|
||||||
#include <drm/drm_damage_helper.h>
|
#include <drm/drm_damage_helper.h>
|
||||||
#include <drm/drm_fourcc.h>
|
#include <drm/drm_fourcc.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_gem_shmem_helper.h>
|
#include <drm/drm_gem_shmem_helper.h>
|
||||||
#include <drm/drm_modeset_helper_vtables.h>
|
#include <drm/drm_modeset_helper_vtables.h>
|
||||||
|
@ -266,18 +267,17 @@ static int udl_aligned_damage_clip(struct drm_rect *clip, int x, int y,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
|
static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_map *map,
|
||||||
int width, int height)
|
int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = fb->dev;
|
struct drm_device *dev = fb->dev;
|
||||||
struct dma_buf_attachment *import_attach = fb->obj[0]->import_attach;
|
struct dma_buf_attachment *import_attach = fb->obj[0]->import_attach;
|
||||||
|
void *vaddr = map->vaddr; /* TODO: Use mapping abstraction properly */
|
||||||
int i, ret, tmp_ret;
|
int i, ret, tmp_ret;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
struct urb *urb;
|
struct urb *urb;
|
||||||
struct drm_rect clip;
|
struct drm_rect clip;
|
||||||
int log_bpp;
|
int log_bpp;
|
||||||
struct dma_buf_map map;
|
|
||||||
void *vaddr;
|
|
||||||
|
|
||||||
ret = udl_log_cpp(fb->format->cpp[0]);
|
ret = udl_log_cpp(fb->format->cpp[0]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -297,17 +297,10 @@ static int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = drm_gem_shmem_vmap(fb->obj[0], &map);
|
|
||||||
if (ret) {
|
|
||||||
DRM_ERROR("failed to vmap fb\n");
|
|
||||||
goto out_dma_buf_end_cpu_access;
|
|
||||||
}
|
|
||||||
vaddr = map.vaddr; /* TODO: Use mapping abstraction properly */
|
|
||||||
|
|
||||||
urb = udl_get_urb(dev);
|
urb = udl_get_urb(dev);
|
||||||
if (!urb) {
|
if (!urb) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out_drm_gem_shmem_vunmap;
|
goto out_dma_buf_end_cpu_access;
|
||||||
}
|
}
|
||||||
cmd = urb->transfer_buffer;
|
cmd = urb->transfer_buffer;
|
||||||
|
|
||||||
|
@ -320,7 +313,7 @@ static int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
|
||||||
&cmd, byte_offset, dev_byte_offset,
|
&cmd, byte_offset, dev_byte_offset,
|
||||||
byte_width);
|
byte_width);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_drm_gem_shmem_vunmap;
|
goto out_dma_buf_end_cpu_access;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd > (char *)urb->transfer_buffer) {
|
if (cmd > (char *)urb->transfer_buffer) {
|
||||||
|
@ -336,8 +329,6 @@ static int udl_handle_damage(struct drm_framebuffer *fb, int x, int y,
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
out_drm_gem_shmem_vunmap:
|
|
||||||
drm_gem_shmem_vunmap(fb->obj[0], &map);
|
|
||||||
out_dma_buf_end_cpu_access:
|
out_dma_buf_end_cpu_access:
|
||||||
if (import_attach) {
|
if (import_attach) {
|
||||||
tmp_ret = dma_buf_end_cpu_access(import_attach->dmabuf,
|
tmp_ret = dma_buf_end_cpu_access(import_attach->dmabuf,
|
||||||
|
@ -375,6 +366,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
|
||||||
struct drm_framebuffer *fb = plane_state->fb;
|
struct drm_framebuffer *fb = plane_state->fb;
|
||||||
struct udl_device *udl = to_udl(dev);
|
struct udl_device *udl = to_udl(dev);
|
||||||
struct drm_display_mode *mode = &crtc_state->mode;
|
struct drm_display_mode *mode = &crtc_state->mode;
|
||||||
|
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
|
||||||
char *buf;
|
char *buf;
|
||||||
char *wrptr;
|
char *wrptr;
|
||||||
int color_depth = UDL_COLOR_DEPTH_16BPP;
|
int color_depth = UDL_COLOR_DEPTH_16BPP;
|
||||||
|
@ -400,7 +392,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
|
||||||
|
|
||||||
udl->mode_buf_len = wrptr - buf;
|
udl->mode_buf_len = wrptr - buf;
|
||||||
|
|
||||||
udl_handle_damage(fb, 0, 0, fb->width, fb->height);
|
udl_handle_damage(fb, &shadow_plane_state->map[0], 0, 0, fb->width, fb->height);
|
||||||
|
|
||||||
if (!crtc_state->mode_changed)
|
if (!crtc_state->mode_changed)
|
||||||
return;
|
return;
|
||||||
|
@ -435,6 +427,7 @@ udl_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
|
||||||
struct drm_plane_state *old_plane_state)
|
struct drm_plane_state *old_plane_state)
|
||||||
{
|
{
|
||||||
struct drm_plane_state *state = pipe->plane.state;
|
struct drm_plane_state *state = pipe->plane.state;
|
||||||
|
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(state);
|
||||||
struct drm_framebuffer *fb = state->fb;
|
struct drm_framebuffer *fb = state->fb;
|
||||||
struct drm_rect rect;
|
struct drm_rect rect;
|
||||||
|
|
||||||
|
@ -442,17 +435,16 @@ udl_simple_display_pipe_update(struct drm_simple_display_pipe *pipe,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (drm_atomic_helper_damage_merged(old_plane_state, state, &rect))
|
if (drm_atomic_helper_damage_merged(old_plane_state, state, &rect))
|
||||||
udl_handle_damage(fb, rect.x1, rect.y1, rect.x2 - rect.x1,
|
udl_handle_damage(fb, &shadow_plane_state->map[0], rect.x1, rect.y1,
|
||||||
rect.y2 - rect.y1);
|
rect.x2 - rect.x1, rect.y2 - rect.y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const
|
static const struct drm_simple_display_pipe_funcs udl_simple_display_pipe_funcs = {
|
||||||
struct drm_simple_display_pipe_funcs udl_simple_display_pipe_funcs = {
|
|
||||||
.mode_valid = udl_simple_display_pipe_mode_valid,
|
.mode_valid = udl_simple_display_pipe_mode_valid,
|
||||||
.enable = udl_simple_display_pipe_enable,
|
.enable = udl_simple_display_pipe_enable,
|
||||||
.disable = udl_simple_display_pipe_disable,
|
.disable = udl_simple_display_pipe_disable,
|
||||||
.update = udl_simple_display_pipe_update,
|
.update = udl_simple_display_pipe_update,
|
||||||
.prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
|
DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue