All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@redhat.com, daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 10/12] drm/ast: Fix cursor BO pinning and mapping
Date: Wed, 27 Jan 2021 14:40:57 +0100	[thread overview]
Message-ID: <3cdca7e9-c86b-facd-b634-7cb52f61c287@suse.de> (raw)
In-Reply-To: <20210127120302.13532-11-tzimmermann@suse.de>


[-- Attachment #1.1.1: Type: text/plain, Size: 4035 bytes --]



Am 27.01.21 um 13:03 schrieb Thomas Zimmermann:
> GEM vmap operations are not allowed in commit tail. Therefore, we cannot
> map the cursor source BO in atomic_update. Instead do this in prepare_fb.
> There was no pin operation for the BO, so add this as well.

Reviewing drm_gem_vram_vmap() I saw that is pins implicitly. I'll remove 
the pinning from the driver code in the patch's next iteration.

> 
> Hence the cursor source BO is now mapped while it's being displayed. The
> change will allow us to move all cursor damage handling from prepare_fb
> to atomic_update.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>   drivers/gpu/drm/ast/ast_mode.c | 37 +++++++++++++++++++++++++++++++---
>   1 file changed, 34 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index 199ad9f9c932..192d3d34b9ed 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -751,6 +751,10 @@ static void ast_set_cursor_enabled(struct ast_private *ast, bool enabled)
>   
>   struct ast_cursor_plane_state {
>   	struct drm_plane_state base;
> +
> +	/* Transitional state - do not export or duplicate */
> +
> +	struct dma_buf_map map;
>   };
>   
>   static inline struct ast_cursor_plane_state *
> @@ -771,6 +775,7 @@ ast_cursor_plane_helper_prepare_fb(struct drm_plane *plane,
>   	struct drm_framebuffer *fb = new_state->fb;
>   	struct dma_buf_map dst_map =
>   		ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].map;
> +	struct ast_cursor_plane_state *new_ast_state = to_ast_cursor_plane_state(new_state);
>   	struct drm_gem_vram_object *src_gbo;
>   	struct dma_buf_map src_map;
>   	void __iomem *dst;
> @@ -782,9 +787,13 @@ ast_cursor_plane_helper_prepare_fb(struct drm_plane *plane,
>   
>   	src_gbo = drm_gem_vram_of_gem(fb->obj[0]);
>   
> -	ret = drm_gem_vram_vmap(src_gbo, &src_map);
> +	ret = drm_gem_vram_pin(src_gbo, 0);
>   	if (ret)
>   		return ret;
> +
> +	ret = drm_gem_vram_vmap(src_gbo, &src_map);
> +	if (ret)
> +		goto err_drm_gem_vram_unpin;
>   	src = src_map.vaddr; /* TODO: Use mapping abstraction properly */
>   
>   	dst = dst_map.vaddr_iomem; /* TODO: Use mapping abstraction properly */
> @@ -792,9 +801,31 @@ ast_cursor_plane_helper_prepare_fb(struct drm_plane *plane,
>   	/* do data transfer to cursor BO */
>   	ast_update_cursor_image(dst, src, fb->width, fb->height);
>   
> -	drm_gem_vram_vunmap(src_gbo, &src_map);
> +	new_ast_state->map = src_map;
>   
>   	return 0;
> +
> +err_drm_gem_vram_unpin:
> +	drm_gem_vram_unpin(src_gbo);
> +	return ret;
> +}
> +
> +static void ast_cursor_plane_helper_cleanup_fb(struct drm_plane *plane,
> +					       struct drm_plane_state *old_state)
> +{
> +	struct ast_cursor_plane_state *old_ast_state = to_ast_cursor_plane_state(old_state);
> +	struct drm_framebuffer *fb = old_state->fb;
> +	struct drm_gem_vram_object *gbo;
> +	struct dma_buf_map map;
> +
> +	if (!fb)
> +		return;
> +
> +	gbo = drm_gem_vram_of_gem(fb->obj[0]);
> +	map = old_ast_state->map;
> +
> +	drm_gem_vram_vunmap(gbo, &map);
> +	drm_gem_vram_unpin(gbo);
>   }
>   
>   static int ast_cursor_plane_helper_atomic_check(struct drm_plane *plane,
> @@ -899,7 +930,7 @@ ast_cursor_plane_helper_atomic_disable(struct drm_plane *plane,
>   
>   static const struct drm_plane_helper_funcs ast_cursor_plane_helper_funcs = {
>   	.prepare_fb = ast_cursor_plane_helper_prepare_fb,
> -	.cleanup_fb = NULL, /* not required for cursor plane */
> +	.cleanup_fb = ast_cursor_plane_helper_cleanup_fb,
>   	.atomic_check = ast_cursor_plane_helper_atomic_check,
>   	.atomic_update = ast_cursor_plane_helper_atomic_update,
>   	.atomic_disable = ast_cursor_plane_helper_atomic_disable,
> 

-- 
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


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2021-01-27 13:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 12:02 [PATCH 00/12] drm/ast: Move cursor vmap calls out of commit tail Thomas Zimmermann
2021-01-27 12:02 ` [PATCH 01/12] drm/ast: Add constants for VGACRCB register bits Thomas Zimmermann
2021-01-27 12:02 ` [PATCH 02/12] drm/ast: Fix invalid usage of AST_MAX_HWC_WIDTH in cursor atomic_check Thomas Zimmermann
2021-01-27 12:02 ` [PATCH 03/12] drm/ast: Initialize planes in helper functions Thomas Zimmermann
2021-01-27 12:02 ` [PATCH 04/12] drm/ast: Allocate HW cursor BOs during cursor-plane initialization Thomas Zimmermann
2021-01-27 12:02 ` [PATCH 05/12] drm/ast: Inline ast cursor-update functions into modesetting code Thomas Zimmermann
2021-01-27 12:02 ` [PATCH 06/12] drm/ast: Add cursor-plane data structure Thomas Zimmermann
2021-01-27 12:02 ` [PATCH 07/12] drm/ast: Store cursor BOs in cursor plane Thomas Zimmermann
2021-01-27 12:02 ` [PATCH 08/12] drm/ast: Map HW cursor BOs permanently Thomas Zimmermann
2021-01-27 12:02 ` [PATCH 09/12] drm/ast: Introduce dedicated cursor-plane state Thomas Zimmermann
2021-01-27 12:03 ` [PATCH 10/12] drm/ast: Fix cursor BO pinning and mapping Thomas Zimmermann
2021-01-27 13:40   ` Thomas Zimmermann [this message]
2021-01-27 12:03 ` [PATCH 11/12] drm/ast: Move all of the cursor-update functionality to atomic_update Thomas Zimmermann
2021-01-27 12:03 ` [PATCH 12/12] drm/ast: Store each HW cursor offset after pinning the rsp BO Thomas Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3cdca7e9-c86b-facd-b634-7cb52f61c287@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.