Provide offset-adjusted framebuffer mappings
Subsystems (13)
Thomas Zimmermann
maintainercover 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
maintainerPATCH 1/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.
--- 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(-)
drivers/gpu/drm/drm_gem_atomic_helper.c +1 -1
@@ -339,7 +339,7 @@ int drm_gem_prepare_shadow_fb(struct drm_plane *plane, struct drm_plane_state *pif (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);
drivers/gpu/drm/drm_gem_framebuffer_helper.c +16 -1
@@ -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:
drivers/gpu/drm/gud/gud_pipe.c +1 -1
@@ -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;
drivers/gpu/drm/vkms/vkms_writeback.c +1 -1
@@ -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;
include/drm/drm_gem_atomic_helper.h +8 -0
@@ -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 ]; };/**
include/drm/drm_gem_framebuffer_helper.h +2 -1
@@ -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);
Signature · 1 line
2.32.0
Re: [PATCH 01/11] drm/gem: Provide offset-adjusted framebuffer BO mappings
Hi Thomas,
Quoted 2 lines · Thomas Zimmermann
Add an additional argument to
drm_gem_fb_vmap()to return each BO's mapping adjusted by the rsp offset. Update all callers.
rsp? respective?
Quoted 2 lines
The newly returned values point to the first by of the data stored
by => byte
Quoted 4 lines
in the framebuffer BOs. Drivers that access the BO data should use it.
Signed-off-by Thomas Zimmermann <[email protected]>
Quoted 130 lines
--- 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(-)drivers/gpu/drm/drm_gem_atomic_helper.c +1
-1@@ -339,7 +339,7 @@ int drm_gem_prepare_shadow_fb(struct drm_plane *plane, struct drm_plane_state *pif (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);drivers/gpu/drm/drm_gem_framebuffer_helper.c +16
-1@@ -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:drivers/gpu/drm/gud/gud_pipe.c +1
-1@@ -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;drivers/gpu/drm/vkms/vkms_writeback.c +1
-1@@ -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;include/drm/drm_gem_atomic_helper.h +8
-0@@ -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 ]; };/** include/drm/drm_gem_framebuffer_helper.h +2
-1@@ -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);Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 2/11 drm/ast: Use offset-adjusted shadow-plane mappings
In reply to Thomas ZimmermannFor framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in ast.
--- drivers/gpu/drm/ast/ast_mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_mode.c +1 -1
@@ -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;
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 3/11 drm/gud: Get offset-adjusted mapping from drm_gem_fb_vmap()
In reply to Thomas ZimmermannPass 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.
--- drivers/gpu/drm/gud/gud_pipe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/gud/gud_pipe.c +3 -2
@@ -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)
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 4/11 drm/hyperv: Use offset-adjusted shadow-plane mappings
In reply to Thomas ZimmermannFor framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in hyperv.
--- drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +2 -2
@@ -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); } }
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 5/11 drm/mgag200: Use offset-adjusted shadow-plane mappings
In reply to Thomas ZimmermannFor framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in mgag200.
--- drivers/gpu/drm/mgag200/mgag200_mode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/mgag200/mgag200_mode.c +2 -2
@@ -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
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 6/11 drm/cirrus: Use offset-adjusted shadow-plane mappings
In reply to Thomas ZimmermannFor framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in cirrus.
--- drivers/gpu/drm/tiny/cirrus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tiny/cirrus.c +2 -2
@@ -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 = {
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 7/11 drm/gm12u320: Use offset-adjusted shadow-plane mappings
In reply to Thomas ZimmermannFor framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in gm12u320.
--- drivers/gpu/drm/tiny/gm12u320.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tiny/gm12u320.c +2 -2
@@ -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 = {
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 8/11 drm/simpledrm: Use offset-adjusted shadow-plane mapping
In reply to Thomas ZimmermannFor framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in simpledrm.
--- drivers/gpu/drm/tiny/simpledrm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +2 -2
@@ -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;
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 9/11 drm/udl: Use offset-adjusted shadow-plane mapping
In reply to Thomas ZimmermannFor framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in udl.
--- drivers/gpu/drm/udl/udl_modeset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/udl/udl_modeset.c +2 -2
@@ -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); }
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 10/11 drm/vbox: Use offset-adjusted shadow-plane mappings
In reply to Thomas ZimmermannFor framebuffers with non-zero offset fields, shadow-plane helpers provide a pointer to the first byte of the contained data. Use it in vbox.
--- drivers/gpu/drm/vboxvideo/vbox_mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vboxvideo/vbox_mode.c +1 -1
@@ -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;
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 11/11 drm/vkms: Use offset-adjusted shadow-plane mappings and output
In reply to Thomas ZimmermannFor 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.
--- 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(-)
drivers/gpu/drm/vkms/vkms_composer.c +1 -1
@@ -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);
drivers/gpu/drm/vkms/vkms_drv.h +1 -0
@@ -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 {
drivers/gpu/drm/vkms/vkms_plane.c +1 -1
@@ -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 ];
drivers/gpu/drm/vkms/vkms_writeback.c +1 -1
@@ -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;
Signature · 1 line
2.32.0
Hi Thomas,
Quoted 17 lines · Thomas Zimmermann
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.
Quoted 10 lines
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
Everything looked good while reading through the patches.
I cannot say if everything was properly converted but the patches looked good.
So they are all:
There was a few TODO comments visible aboput using the mapping api properly. I assume this is coming in a later patch set..
Sam
Thomas Zimmermann
maintainerHi Sam
Am 03.08.21 um 18:21 schrieb Sam Ravnborg:
Quoted 30 lines
Hi Thomas,
Quoted 17 lines · Thomas Zimmermann
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.
Quoted 10 lines
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
Quoted 6 lines
Everything 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 <[email protected]>
Thanks!
Quoted 3 lines
There was a few TODO comments visible aboput using the mapping api properly. I assume this is coming in a later patch set..
There are indeed quite a few such comments. When we introduced the dma_buf_map type to solve the fbdev issue on sparc64, in many places I simply put the existing vaddr pointers into the map structure, and vice versa.
The code works as expected, but in the future we may want to use dma_buf_map for all framebuffer pointers. This would, for example, require format conversion helpers that operate on these structures. Adding that will require a number of changes throughout these helpers.
Best regards
Thomas
Quoted 3 lines
Sam
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer