Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 00/11] Provide offset-adjusted framebuffer mappings
A framebuffer's offsets field might be non-zero to make the BO data start at the specified offset within the BO's memory. Handle this case in drm_gem_fb_vmap() and update all callers. So far, many drivers ignore the offsets, which can lead to visual artifacts. Patch 1 adds an optional argument to drm_gem_fb_vmap() to return the offset-adjusted data address for use with shadow-buffered planes. Patches 3 and 11 convert gud and vkms, which are the other callers of drm_gem_fb_vmap(). For gud, it's just a cleanup. Vkms will handle the framebuffer offsets correctly for its input and output framebuffers. The other patches convert users of shadow-buffered planes to use the data address. After conversion, each driver will use the correct data for non-zero offsets. Thomas Zimmermann (11): drm/gem: Provide offset-adjusted framebuffer BO mappings drm/ast: Use offset-adjusted shadow-plane mappings drm/gud: Get offset-adjusted mapping from drm_gem_fb_vmap() drm/hyperv: Use offset-adjusted shadow-plane mappings drm/mgag200: Use offset-adjusted shadow-plane mappings drm/cirrus: Use offset-adjusted shadow-plane mappings drm/gm12u320: Use offset-adjusted shadow-plane mappings drm/simpledrm: Use offset-adjusted shadow-plane mapping drm/udl: Use offset-adjusted shadow-plane mapping drm/vbox: Use offset-adjusted shadow-plane mappings drm/vkms: Use offset-adjusted shadow-plane mappings and output drivers/gpu/drm/ast/ast_mode.c | 2 +- drivers/gpu/drm/drm_gem_atomic_helper.c | 2 +- drivers/gpu/drm/drm_gem_framebuffer_helper.c | 17 ++++++++++++++++- drivers/gpu/drm/gud/gud_pipe.c | 5 +++-- drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 4 ++-- drivers/gpu/drm/mgag200/mgag200_mode.c | 4 ++-- drivers/gpu/drm/tiny/cirrus.c | 4 ++-- drivers/gpu/drm/tiny/gm12u320.c | 4 ++-- drivers/gpu/drm/tiny/simpledrm.c | 4 ++-- drivers/gpu/drm/udl/udl_modeset.c | 4 ++-- drivers/gpu/drm/vboxvideo/vbox_mode.c | 2 +- drivers/gpu/drm/vkms/vkms_composer.c | 2 +- drivers/gpu/drm/vkms/vkms_drv.h | 1 + drivers/gpu/drm/vkms/vkms_plane.c | 2 +- drivers/gpu/drm/vkms/vkms_writeback.c | 2 +- include/drm/drm_gem_atomic_helper.h | 8 ++++++++ include/drm/drm_gem_framebuffer_helper.h | 3 ++- 17 files changed, 48 insertions(+), 22 deletions(-) -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 01/11] drm/gem: Provide offset-adjusted framebuffer BO mappings
Add an additional argument to drm_gem_fb_vmap() to return each BO's mapping adjusted by the rsp offset. Update all callers. The newly returned values point to the first by of the data stored in the framebuffer BOs. Drivers that access the BO data should use it. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/drm_gem_atomic_helper.c | 2 +- drivers/gpu/drm/drm_gem_framebuffer_helper.c | 17 ++++++++++++++++- drivers/gpu/drm/gud/gud_pipe.c | 2 +- drivers/gpu/drm/vkms/vkms_writeback.c | 2 +- include/drm/drm_gem_atomic_helper.h | 8 ++++++++ include/drm/drm_gem_framebuffer_helper.h | 3 ++- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_atomic_helper.c b/drivers/gpu/drm/drm_gem_atomic_helper.c index b1cc19e47165..8410ec3c5db0 100644 --- a/drivers/gpu/drm/drm_gem_atomic_helper.c +++ b/drivers/gpu/drm/drm_gem_atomic_helper.c @@ -339,7 +339,7 @@ int drm_gem_prepare_shadow_fb(struct drm_plane *plane, struct drm_plane_state *p if (ret) return ret; - return drm_gem_fb_vmap(fb, shadow_plane_state->map); + return drm_gem_fb_vmap(fb, shadow_plane_state->map, shadow_plane_state->data); } EXPORT_SYMBOL(drm_gem_prepare_shadow_fb); diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c index 02928607a716..7f2bbe4f0053 100644 --- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c +++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c @@ -316,19 +316,25 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty); * drm_gem_fb_vmap - maps all framebuffer BOs into kernel address space * @fb: the framebuffer * @map: returns the mapping's address for each BO + * @data: returns the data address for each BO, can be NULL * * This function maps all buffer objects of the given framebuffer into * kernel address space and stores them in struct dma_buf_map. If the * mapping operation fails for one of the BOs, the function unmaps the * already established mappings automatically. * + * Callers that want to access a BO's stored data should pass @data. + * The argument returns the addresses of the data stored in each BO. This + * is different from @map if the framebuffer's offsets field is non-zero. + * * See drm_gem_fb_vunmap() for unmapping. * * Returns: * 0 on success, or a negative errno code otherwise. */ int drm_gem_fb_vmap(struct drm_framebuffer *fb, - struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES]) + struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES], + struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]) { struct drm_gem_object *obj; unsigned int i; @@ -345,6 +351,15 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, goto err_drm_gem_vunmap; } + if (data) { + for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) { + memcpy(&data[i], &map[i], sizeof(data[i])); + if (dma_buf_map_is_null(&data[i])) + continue; + dma_buf_map_incr(&data[i], fb->offsets[i]); + } + } + return 0; err_drm_gem_vunmap: diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c index 7e009f562b30..6270a1a32a65 100644 --- a/drivers/gpu/drm/gud/gud_pipe.c +++ b/drivers/gpu/drm/gud/gud_pipe.c @@ -162,7 +162,7 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb, if (len > gdrm->bulk_len) return -E2BIG; - ret = drm_gem_fb_vmap(fb, map); + ret = drm_gem_fb_vmap(fb, map, NULL); if (ret) return ret; diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index 425b6c6b8cad..3a8e2ed93e7c 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -75,7 +75,7 @@ static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector, if (!vkmsjob) return -ENOMEM; - ret = drm_gem_fb_vmap(job->fb, vkmsjob->map); + ret = drm_gem_fb_vmap(job->fb, vkmsjob->map, NULL); if (ret) { DRM_ERROR("vmap failed: %d\n", ret); goto err_kfree; diff --git a/include/drm/drm_gem_atomic_helper.h b/include/drm/drm_gem_atomic_helper.h index f9f8b6f0494a..48222a107873 100644 --- a/include/drm/drm_gem_atomic_helper.h +++ b/include/drm/drm_gem_atomic_helper.h @@ -42,6 +42,14 @@ struct drm_shadow_plane_state { * prepare_fb callback and removed in the cleanup_fb callback. */ struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]; + + /** + * @data: Address of each framebuffer BO's data + * + * The address of the data stored in each mapping. This is different + * for framebuffers with non-zero offset fields. + */ + struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]; }; /** diff --git a/include/drm/drm_gem_framebuffer_helper.h b/include/drm/drm_gem_framebuffer_helper.h index ff2024dd7b77..905727719ead 100644 --- a/include/drm/drm_gem_framebuffer_helper.h +++ b/include/drm/drm_gem_framebuffer_helper.h @@ -40,7 +40,8 @@ drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd); int drm_gem_fb_vmap(struct drm_framebuffer *fb, - struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES]); + struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES], + struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]); void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES]); int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir); -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 02/11] drm/ast: Use offset-adjusted shadow-plane mappings
For framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in ast. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/ast/ast_mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index 15319967164e..6bfaefa01818 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -808,7 +808,7 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane, ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].map; u64 dst_off ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].off; - struct dma_buf_map src_map = shadow_plane_state->map[0]; + struct dma_buf_map src_map = shadow_plane_state->data[0]; unsigned int offset_x, offset_y; u16 x, y; u8 x_offset, y_offset; -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 03/11] drm/gud: Get offset-adjusted mapping from drm_gem_fb_vmap()
Pass the data parameter to drm_gem_fb_vmap() to retrieve pointers to the data. This address is different from the mapping addresses for framebuffers with non-zero offsets. Replaces gud's internal computation. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/gud/gud_pipe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c index 6270a1a32a65..b9b0e435ea0f 100644 --- a/drivers/gpu/drm/gud/gud_pipe.c +++ b/drivers/gpu/drm/gud/gud_pipe.c @@ -153,6 +153,7 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb, struct dma_buf_attachment *import_attach = fb->obj[0]->import_attach; u8 compression = gdrm->compression; struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]; + struct dma_buf_map map_data[DRM_FORMAT_MAX_PLANES]; void *vaddr, *buf; size_t pitch, len; int ret = 0; @@ -162,11 +163,11 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb, if (len > gdrm->bulk_len) return -E2BIG; - ret = drm_gem_fb_vmap(fb, map, NULL); + ret = drm_gem_fb_vmap(fb, map, map_data); if (ret) return ret; - vaddr = map[0].vaddr + fb->offsets[0]; + vaddr = map_data[0].vaddr; ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE); if (ret) -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 04/11] drm/hyperv: Use offset-adjusted shadow-plane mappings
For framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in hyperv. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c b/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c index 3aaee4730ec6..6dd4717d3e1e 100644 --- a/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +++ b/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c @@ -105,7 +105,7 @@ static void hyperv_pipe_enable(struct drm_simple_display_pipe *pipe, crtc_state->mode.hdisplay, crtc_state->mode.vdisplay, plane_state->fb->pitches[0]); - hyperv_blit_to_vram_fullscreen(plane_state->fb, &shadow_plane_state->map[0]); + hyperv_blit_to_vram_fullscreen(plane_state->fb, &shadow_plane_state->data[0]); } static int hyperv_pipe_check(struct drm_simple_display_pipe *pipe, @@ -133,7 +133,7 @@ static void hyperv_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_rect rect; if (drm_atomic_helper_damage_merged(old_state, state, &rect)) { - hyperv_blit_to_vram_rect(state->fb, &shadow_plane_state->map[0], &rect); + hyperv_blit_to_vram_rect(state->fb, &shadow_plane_state->data[0], &rect); hyperv_update_dirt(hv->hdev, &rect); } } -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 05/11] drm/mgag200: Use offset-adjusted shadow-plane mappings
For framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in mgag200. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/mgag200/mgag200_mode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index 3b3059f471c2..6e2db8cfe3b7 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1601,7 +1601,7 @@ mgag200_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, mga_crtc_load_lut(crtc); mgag200_enable_display(mdev); - mgag200_handle_damage(mdev, fb, &fullscreen, &shadow_plane_state->map[0]); + mgag200_handle_damage(mdev, fb, &fullscreen, &shadow_plane_state->data[0]); } static void @@ -1650,7 +1650,7 @@ mgag200_simple_display_pipe_update(struct drm_simple_display_pipe *pipe, return; if (drm_atomic_helper_damage_merged(old_state, state, &damage)) - mgag200_handle_damage(mdev, fb, &damage, &shadow_plane_state->map[0]); + mgag200_handle_damage(mdev, fb, &damage, &shadow_plane_state->data[0]); } static const struct drm_simple_display_pipe_funcs -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 06/11] drm/cirrus: Use offset-adjusted shadow-plane mappings
For framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in cirrus. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/tiny/cirrus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c index a8b476a59c0d..4611ec408506 100644 --- a/drivers/gpu/drm/tiny/cirrus.c +++ b/drivers/gpu/drm/tiny/cirrus.c @@ -435,7 +435,7 @@ static void cirrus_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); cirrus_mode_set(cirrus, &crtc_state->mode, plane_state->fb); - cirrus_fb_blit_fullscreen(plane_state->fb, &shadow_plane_state->map[0]); + cirrus_fb_blit_fullscreen(plane_state->fb, &shadow_plane_state->data[0]); } static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe, @@ -451,7 +451,7 @@ static void cirrus_pipe_update(struct drm_simple_display_pipe *pipe, cirrus_mode_set(cirrus, &crtc->mode, state->fb); if (drm_atomic_helper_damage_merged(old_state, state, &rect)) - cirrus_fb_blit_rect(state->fb, &shadow_plane_state->map[0], &rect); + cirrus_fb_blit_rect(state->fb, &shadow_plane_state->data[0], &rect); } static const struct drm_simple_display_pipe_funcs cirrus_pipe_funcs = { -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 07/11] drm/gm12u320: Use offset-adjusted shadow-plane mappings
For framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in gm12u320. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/tiny/gm12u320.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c index cf7287fccd72..6bc0c298739c 100644 --- a/drivers/gpu/drm/tiny/gm12u320.c +++ b/drivers/gpu/drm/tiny/gm12u320.c @@ -554,7 +554,7 @@ static void gm12u320_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); gm12u320->fb_update.draw_status_timeout = FIRST_FRAME_TIMEOUT; - gm12u320_fb_mark_dirty(plane_state->fb, &shadow_plane_state->map[0], &rect); + gm12u320_fb_mark_dirty(plane_state->fb, &shadow_plane_state->data[0], &rect); } static void gm12u320_pipe_disable(struct drm_simple_display_pipe *pipe) @@ -572,7 +572,7 @@ static void gm12u320_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_rect rect; if (drm_atomic_helper_damage_merged(old_state, state, &rect)) - gm12u320_fb_mark_dirty(state->fb, &shadow_plane_state->map[0], &rect); + gm12u320_fb_mark_dirty(state->fb, &shadow_plane_state->data[0], &rect); } static const struct drm_simple_display_pipe_funcs gm12u320_pipe_funcs = { -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 08/11] drm/simpledrm: Use offset-adjusted shadow-plane mapping
For framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in simpledrm. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/tiny/simpledrm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c index 08ae66b1e6f5..481b48bde047 100644 --- a/drivers/gpu/drm/tiny/simpledrm.c +++ b/drivers/gpu/drm/tiny/simpledrm.c @@ -639,7 +639,7 @@ simpledrm_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, struct simpledrm_device *sdev = simpledrm_device_of_dev(pipe->crtc.dev); struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); struct drm_framebuffer *fb = plane_state->fb; - void *vmap = shadow_plane_state->map[0].vaddr; /* TODO: Use mapping abstraction properly */ + void *vmap = shadow_plane_state->data[0].vaddr; /* TODO: Use mapping abstraction */ struct drm_device *dev = &sdev->dev; int idx; @@ -677,7 +677,7 @@ simpledrm_simple_display_pipe_update(struct drm_simple_display_pipe *pipe, struct simpledrm_device *sdev = simpledrm_device_of_dev(pipe->crtc.dev); struct drm_plane_state *plane_state = pipe->plane.state; struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); - void *vmap = shadow_plane_state->map[0].vaddr; /* TODO: Use mapping abstraction properly */ + void *vmap = shadow_plane_state->data[0].vaddr; /* TODO: Use mapping abstraction */ struct drm_framebuffer *fb = plane_state->fb; struct drm_device *dev = &sdev->dev; struct drm_rect clip; -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 09/11] drm/udl: Use offset-adjusted shadow-plane mapping
For framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in udl. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/udl/udl_modeset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c index 8a6b94b1511b..32232228dae9 100644 --- a/drivers/gpu/drm/udl/udl_modeset.c +++ b/drivers/gpu/drm/udl/udl_modeset.c @@ -379,7 +379,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, udl->mode_buf_len = wrptr - buf; - udl_handle_damage(fb, &shadow_plane_state->map[0], 0, 0, fb->width, fb->height); + udl_handle_damage(fb, &shadow_plane_state->data[0], 0, 0, fb->width, fb->height); if (!crtc_state->mode_changed) return; @@ -422,7 +422,7 @@ udl_simple_display_pipe_update(struct drm_simple_display_pipe *pipe, return; if (drm_atomic_helper_damage_merged(old_plane_state, state, &rect)) - udl_handle_damage(fb, &shadow_plane_state->map[0], rect.x1, rect.y1, + udl_handle_damage(fb, &shadow_plane_state->data[0], rect.x1, rect.y1, rect.x2 - rect.x1, rect.y2 - rect.y1); } -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 10/11] drm/vbox: Use offset-adjusted shadow-plane mappings
For framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in vbox. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/vboxvideo/vbox_mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vboxvideo/vbox_mode.c b/drivers/gpu/drm/vboxvideo/vbox_mode.c index 972c83b720aa..4227a915b06a 100644 --- a/drivers/gpu/drm/vboxvideo/vbox_mode.c +++ b/drivers/gpu/drm/vboxvideo/vbox_mode.c @@ -398,7 +398,7 @@ static void vbox_cursor_atomic_update(struct drm_plane *plane, u32 height = new_state->crtc_h; struct drm_shadow_plane_state *shadow_plane_state to_drm_shadow_plane_state(new_state); - struct dma_buf_map map = shadow_plane_state->map[0]; + struct dma_buf_map map = shadow_plane_state->data[0]; u8 *src = map.vaddr; /* TODO: Use mapping abstraction properly */ size_t data_size, mask_size; u32 flags; -- 2.32.0
Thomas Zimmermann
2021-Aug-03 12:59 UTC
[PATCH 11/11] drm/vkms: Use offset-adjusted shadow-plane mappings and output
For framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in vkms. Also provide use the offset-adjusted data address for the writeback job's output buffers. Output framebuffers with non-zero offsets now have their content written to the correct location. Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> --- drivers/gpu/drm/vkms/vkms_composer.c | 2 +- drivers/gpu/drm/vkms/vkms_drv.h | 1 + drivers/gpu/drm/vkms/vkms_plane.c | 2 +- drivers/gpu/drm/vkms/vkms_writeback.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 49f109c3a2b3..9e8204be9a14 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -257,7 +257,7 @@ void vkms_composer_worker(struct work_struct *work) return; if (wb_pending) - vaddr_out = crtc_state->active_writeback->map[0].vaddr; + vaddr_out = crtc_state->active_writeback->data[0].vaddr; ret = compose_active_planes(&vaddr_out, primary_composer, crtc_state); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 8bc9e3f52e1f..d48c23d40ce5 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -22,6 +22,7 @@ struct vkms_writeback_job { struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]; + struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]; }; struct vkms_composer { diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 8a56fbf572b0..32409e15244b 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -111,7 +111,7 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, memcpy(&composer->src, &new_state->src, sizeof(struct drm_rect)); memcpy(&composer->dst, &new_state->dst, sizeof(struct drm_rect)); memcpy(&composer->fb, fb, sizeof(struct drm_framebuffer)); - memcpy(&composer->map, &shadow_plane_state->map, sizeof(composer->map)); + memcpy(&composer->map, &shadow_plane_state->data, sizeof(composer->map)); drm_framebuffer_get(&composer->fb); composer->offset = fb->offsets[0]; composer->pitch = fb->pitches[0]; diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index 3a8e2ed93e7c..8694227f555f 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -75,7 +75,7 @@ static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector, if (!vkmsjob) return -ENOMEM; - ret = drm_gem_fb_vmap(job->fb, vkmsjob->map, NULL); + ret = drm_gem_fb_vmap(job->fb, vkmsjob->map, vkmsjob->data); if (ret) { DRM_ERROR("vmap failed: %d\n", ret); goto err_kfree; -- 2.32.0
Sam Ravnborg
2021-Aug-03 16:21 UTC
[PATCH 00/11] Provide offset-adjusted framebuffer mappings
Hi Thomas, On Tue, Aug 03, 2021 at 02:59:17PM +0200, Thomas Zimmermann wrote:> A framebuffer's offsets field might be non-zero to make the BO data > start at the specified offset within the BO's memory. Handle this > case in drm_gem_fb_vmap() and update all callers. So far, many drivers > ignore the offsets, which can lead to visual artifacts. > > Patch 1 adds an optional argument to drm_gem_fb_vmap() to return the > offset-adjusted data address for use with shadow-buffered planes. > > Patches 3 and 11 convert gud and vkms, which are the other callers of > drm_gem_fb_vmap(). For gud, it's just a cleanup. Vkms will handle the > framebuffer offsets correctly for its input and output framebuffers. > > The other patches convert users of shadow-buffered planes to use the > data address. After conversion, each driver will use the correct data > for non-zero offsets. >> drm/ast: Use offset-adjusted shadow-plane mappings > drm/gud: Get offset-adjusted mapping from drm_gem_fb_vmap() > drm/hyperv: Use offset-adjusted shadow-plane mappings > drm/mgag200: Use offset-adjusted shadow-plane mappings > drm/cirrus: Use offset-adjusted shadow-plane mappings > drm/gm12u320: Use offset-adjusted shadow-plane mappings > drm/simpledrm: Use offset-adjusted shadow-plane mapping > drm/udl: Use offset-adjusted shadow-plane mapping > drm/vbox: Use offset-adjusted shadow-plane mappings > drm/vkms: Use offset-adjusted shadow-plane mappings and outputEverything looked good while reading through the patches. I cannot say if everything was properly converted but the patches looked good. So they are all: Acked-by: Sam Ravnborg <sam at ravnborg.org> There was a few TODO comments visible aboput using the mapping api properly. I assume this is coming in a later patch set.. Sam