dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: Dongwon Kim <dongwon.kim@intel.com>, dri-devel@lists.freedesktop.org
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>, kraxel@redhat.com
Subject: Re: [RFC PATCH 2/3] drm/virtio: new fence for every plane update
Date: Fri, 18 Aug 2023 05:21:23 +0300	[thread overview]
Message-ID: <e21c96f5-1f82-5afb-c117-e5ae48164073@collabora.com> (raw)
In-Reply-To: <20230712224424.30158-3-dongwon.kim@intel.com>

...
> +static struct
> +drm_plane_state *virtio_gpu_plane_duplicate_state(struct drm_plane *plane)
> +{
> +	struct virtio_gpu_plane_state *new;
> +
> +	if (WARN_ON(!plane->state))
> +		return NULL;

When plane->state can be NULL?

> +	new = kzalloc(sizeof(*new), GFP_KERNEL);
> +	if (!new)
> +		return NULL;
> +
> +	__drm_atomic_helper_plane_duplicate_state(plane, &new->base);
> +
> +	return &new->base;
> +}
> +
> +static void virtio_gpu_plane_destroy_state(struct drm_plane *plane,
> +					   struct drm_plane_state *state)
> +{
> +	__drm_atomic_helper_plane_destroy_state(state);
> +	kfree(to_virtio_gpu_plane_state(state));
> +}
> +
>  static const struct drm_plane_funcs virtio_gpu_plane_funcs = {
>  	.update_plane		= drm_atomic_helper_update_plane,
>  	.disable_plane		= drm_atomic_helper_disable_plane,
>  	.reset			= drm_atomic_helper_plane_reset,
> -	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
> -	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
> +	.atomic_duplicate_state = virtio_gpu_plane_duplicate_state,
> +	.atomic_destroy_state	= virtio_gpu_plane_destroy_state,

Similar to the other email, please see how container_of() works. There
is no need change .atomic_destroy_state

...
> @@ -237,41 +262,29 @@ static int virtio_gpu_plane_prepare_fb(struct drm_plane *plane,
>  	struct drm_device *dev = plane->dev;
>  	struct virtio_gpu_device *vgdev = dev->dev_private;
>  	struct virtio_gpu_framebuffer *vgfb;
> +	struct virtio_gpu_plane_state *vgplane_st;
>  	struct virtio_gpu_object *bo;
>  
>  	if (!new_state->fb)
>  		return 0;
>  
>  	vgfb = to_virtio_gpu_framebuffer(new_state->fb);
> +	vgplane_st = to_virtio_gpu_plane_state(new_state);
>  	bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
>  	if (!bo || (plane->type == DRM_PLANE_TYPE_PRIMARY && !bo->guest_blob))
>  		return 0;
>  
> -	if (bo->dumb && (plane->state->fb != new_state->fb)) {
> -		vgfb->fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context,
> +	if (bo->dumb) {

Why "&& (plane->state->fb != new_state->fb)" disappeared?

> +		vgplane_st->fence = virtio_gpu_fence_alloc(vgdev,
> +						     vgdev->fence_drv.context,
>  						     0);
> -		if (!vgfb->fence)
> +		if (!vgplane_st->fence)
>  			return -ENOMEM;
>  	}
>  
>  	return 0;
>  }
>  
> -static void virtio_gpu_plane_cleanup_fb(struct drm_plane *plane,
> -					struct drm_plane_state *state)
> -{
> -	struct virtio_gpu_framebuffer *vgfb;
> -
> -	if (!state->fb)
> -		return;
> -
> -	vgfb = to_virtio_gpu_framebuffer(state->fb);
> -	if (vgfb->fence) {
> -		dma_fence_put(&vgfb->fence->f);
> -		vgfb->fence = NULL;
> -	}
> -}
How come that virtio_gpu_plane_cleanup_fb() isn't needed anymore? You
created fence in prepare_fb(), you must release it in cleanup_fb() if
fence still presents.

-- 
Best regards,
Dmitry


  reply	other threads:[~2023-08-18  2:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-12 22:44 [PFC PATCH 0/3] drm/virtio: synchronous guest framebuffer update Dongwon Kim
2023-07-12 22:44 ` [RFC PATCH 1/3] drm/virtio: .release ops for virtgpu fence release Dongwon Kim
2023-08-15  4:18   ` Dmitry Osipenko
2023-08-16 18:10     ` Kim, Dongwon
2023-08-17  5:05       ` Dmitry Osipenko
2023-08-17  5:25         ` Kim, Dongwon
2023-08-18  2:09           ` Dmitry Osipenko
2023-08-18  2:36         ` Kim, Dongwon
2023-07-12 22:44 ` [RFC PATCH 2/3] drm/virtio: new fence for every plane update Dongwon Kim
2023-08-18  2:21   ` Dmitry Osipenko [this message]
2023-08-21  2:28     ` Kim, Dongwon
2023-07-12 22:44 ` [RFC PATCH 3/3] drm/virtio: drm_gem_plane_helper_prepare_fb for obj synchronization Dongwon Kim
2023-08-18  2:33   ` Dmitry Osipenko
2023-08-20 20:58     ` Kim, Dongwon
2023-08-24  3:52       ` Dmitry Osipenko
2023-08-24 17:58         ` Kim, Dongwon
2023-08-31 22:51           ` Dmitry Osipenko
2023-09-05 21:08             ` Kim, Dongwon
2023-10-04 23:31               ` Dmitry Osipenko
2023-10-04 23:44                 ` Kim, Dongwon
  -- strict thread matches above, loose matches on Subject: below --
2022-09-26 23:06 [PFC PATCH 0/3] drm/virtio: synchronous guest framebuffer update Dongwon Kim
2022-09-26 23:06 ` [RFC PATCH 2/3] drm/virtio: new fence for every plane update Dongwon Kim

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=e21c96f5-1f82-5afb-c117-e5ae48164073@collabora.com \
    --to=dmitry.osipenko@collabora.com \
    --cc=dongwon.kim@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=vivek.kasireddy@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox