dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 05/23] drm: Add local 'plane' variable for primary/cursor planes
Date: Mon, 26 Mar 2018 22:49:06 +0200	[thread overview]
Message-ID: <20180326204906.GC14155@phenom.ffwll.local> (raw)
In-Reply-To: <20180322152313.6561-6-ville.syrjala@linux.intel.com>

On Thu, Mar 22, 2018 at 05:22:55PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Make the code a bit more readable by storing the plane pointer in a
> local variable rather than having to do crtc->{primary,cursor} all the
> time.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_crtc.c  | 32 +++++++++++++++++++-------------
>  drivers/gpu/drm/drm_plane.c | 32 ++++++++++++++++++--------------
>  2 files changed, 37 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 7a973ada7195..8552ed419056 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -402,6 +402,7 @@ int drm_mode_getcrtc(struct drm_device *dev,
>  {
>  	struct drm_mode_crtc *crtc_resp = data;
>  	struct drm_crtc *crtc;
> +	struct drm_plane *plane;
>  
>  	if (!drm_core_check_feature(dev, DRIVER_MODESET))
>  		return -EINVAL;
> @@ -410,21 +411,23 @@ int drm_mode_getcrtc(struct drm_device *dev,
>  	if (!crtc)
>  		return -ENOENT;
>  
> +	plane = crtc->primary;
> +
>  	crtc_resp->gamma_size = crtc->gamma_size;
>  
> -	drm_modeset_lock(&crtc->primary->mutex, NULL);
> -	if (crtc->primary->state && crtc->primary->state->fb)
> -		crtc_resp->fb_id = crtc->primary->state->fb->base.id;
> -	else if (!crtc->primary->state && crtc->primary->fb)
> -		crtc_resp->fb_id = crtc->primary->fb->base.id;
> +	drm_modeset_lock(&plane->mutex, NULL);
> +	if (plane->state && plane->state->fb)
> +		crtc_resp->fb_id = plane->state->fb->base.id;
> +	else if (!plane->state && plane->fb)
> +		crtc_resp->fb_id = plane->fb->base.id;
>  	else
>  		crtc_resp->fb_id = 0;
>  
> -	if (crtc->primary->state) {
> -		crtc_resp->x = crtc->primary->state->src_x >> 16;
> -		crtc_resp->y = crtc->primary->state->src_y >> 16;
> +	if (plane->state) {
> +		crtc_resp->x = plane->state->src_x >> 16;
> +		crtc_resp->y = plane->state->src_y >> 16;
>  	}
> -	drm_modeset_unlock(&crtc->primary->mutex);
> +	drm_modeset_unlock(&plane->mutex);
>  
>  	drm_modeset_lock(&crtc->mutex, NULL);
>  	if (crtc->state) {
> @@ -554,6 +557,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
>  	struct drm_mode_config *config = &dev->mode_config;
>  	struct drm_mode_crtc *crtc_req = data;
>  	struct drm_crtc *crtc;
> +	struct drm_plane *plane;
>  	struct drm_connector **connector_set = NULL, *connector;
>  	struct drm_framebuffer *fb = NULL;
>  	struct drm_display_mode *mode = NULL;
> @@ -580,6 +584,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,

Could do the same for setconfig_internal's tmp->primary, if you're bored.

>  	}
>  	DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
>  
> +	plane = crtc->primary;
> +
>  	mutex_lock(&crtc->dev->mode_config.mutex);
>  	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
>  retry:
> @@ -590,12 +596,12 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
>  		/* If we have a mode we need a framebuffer. */
>  		/* If we pass -1, set the mode with the currently bound fb */
>  		if (crtc_req->fb_id == -1) {
> -			if (!crtc->primary->fb) {
> +			if (!plane->fb) {
>  				DRM_DEBUG_KMS("CRTC doesn't have current FB\n");
>  				ret = -EINVAL;
>  				goto out;
>  			}
> -			fb = crtc->primary->fb;
> +			fb = plane->fb;
>  			/* Make refcounting symmetric with the lookup path. */
>  			drm_framebuffer_get(fb);
>  		} else {
> @@ -627,8 +633,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
>  		 * match real hardware capabilities. Skip the check in that
>  		 * case.
>  		 */
> -		if (!crtc->primary->format_default) {
> -			ret = drm_plane_check_pixel_format(crtc->primary,
> +		if (!plane->format_default) {
> +			ret = drm_plane_check_pixel_format(plane,
>  							   fb->format->format,
>  							   fb->modifier);
>  			if (ret) {
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 6d2a6e428a3e..38e2a628bfa2 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -756,6 +756,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
>  				     struct drm_modeset_acquire_ctx *ctx)
>  {
>  	struct drm_device *dev = crtc->dev;
> +	struct drm_plane *plane = crtc->cursor;
>  	struct drm_framebuffer *fb = NULL;
>  	struct drm_mode_fb_cmd2 fbreq = {
>  		.width = req->width,
> @@ -769,8 +770,8 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
>  	uint32_t src_w = 0, src_h = 0;
>  	int ret = 0;
>  
> -	BUG_ON(!crtc->cursor);
> -	WARN_ON(crtc->cursor->crtc != crtc && crtc->cursor->crtc != NULL);
> +	BUG_ON(!plane);
> +	WARN_ON(plane->crtc != crtc && plane->crtc != NULL);
>  
>  	/*
>  	 * Obtain fb we'll be using (either new or existing) and take an extra
> @@ -790,7 +791,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
>  			fb = NULL;
>  		}
>  	} else {
> -		fb = crtc->cursor->fb;
> +		fb = plane->fb;
>  		if (fb)
>  			drm_framebuffer_get(fb);
>  	}
> @@ -810,7 +811,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
>  		src_h = fb->height << 16;
>  	}
>  
> -	ret = __setplane_internal(crtc->cursor, crtc, fb,
> +	ret = __setplane_internal(plane, crtc, fb,
>  				  crtc_x, crtc_y, crtc_w, crtc_h,
>  				  0, 0, src_w, src_h, ctx);
>  
> @@ -931,6 +932,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  {
>  	struct drm_mode_crtc_page_flip_target *page_flip = data;
>  	struct drm_crtc *crtc;
> +	struct drm_plane *plane;
>  	struct drm_framebuffer *fb = NULL;
>  	struct drm_pending_vblank_event *e = NULL;
>  	u32 target_vblank = page_flip->sequence;
> @@ -959,6 +961,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  	if (!crtc)
>  		return -ENOENT;
>  
> +	plane = crtc->primary;
> +
>  	if (crtc->funcs->page_flip_target) {
>  		u32 current_vblank;
>  		int r;
> @@ -1003,11 +1007,11 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  	ret = drm_modeset_lock(&crtc->mutex, &ctx);
>  	if (ret)
>  		goto out;
> -	ret = drm_modeset_lock(&crtc->primary->mutex, &ctx);
> +	ret = drm_modeset_lock(&plane->mutex, &ctx);
>  	if (ret)
>  		goto out;
>  
> -	if (crtc->primary->fb == NULL) {
> +	if (plane->fb == NULL) {
>  		/* The framebuffer is currently unbound, presumably
>  		 * due to a hotplug event, that userspace has not
>  		 * yet discovered.
> @@ -1023,7 +1027,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  	}
>  
>  	if (crtc->state) {
> -		const struct drm_plane_state *state = crtc->primary->state;
> +		const struct drm_plane_state *state = plane->state;
>  
>  		ret = drm_framebuffer_check_src_coords(state->src_x,
>  						       state->src_y,
> @@ -1036,7 +1040,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  	if (ret)
>  		goto out;
>  
> -	if (crtc->primary->fb->format != fb->format) {
> +	if (plane->fb->format != fb->format) {
>  		DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer format.\n");
>  		ret = -EINVAL;
>  		goto out;
> @@ -1060,7 +1064,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  		}
>  	}
>  
> -	crtc->primary->old_fb = crtc->primary->fb;
> +	plane->old_fb = plane->fb;
>  	if (crtc->funcs->page_flip_target)
>  		ret = crtc->funcs->page_flip_target(crtc, fb, e,
>  						    page_flip->flags,
> @@ -1073,9 +1077,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  		if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT)
>  			drm_event_cancel_free(dev, &e->base);
>  		/* Keep the old fb, don't unref it. */
> -		crtc->primary->old_fb = NULL;
> +		plane->old_fb = NULL;
>  	} else {
> -		crtc->primary->fb = fb;
> +		plane->fb = fb;
>  		/* Unref only the old framebuffer. */
>  		fb = NULL;
>  	}
> @@ -1083,9 +1087,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  out:
>  	if (fb)
>  		drm_framebuffer_put(fb);
> -	if (crtc->primary->old_fb)
> -		drm_framebuffer_put(crtc->primary->old_fb);
> -	crtc->primary->old_fb = NULL;
> +	if (plane->old_fb)
> +		drm_framebuffer_put(plane->old_fb);
> +	plane->old_fb = NULL;
>  

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

>  	if (ret == -EDEADLK) {
>  		ret = drm_modeset_backoff(&ctx);
> -- 
> 2.16.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-03-26 20:49 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22 15:22 [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers Ville Syrjala
2018-03-22 15:22 ` [PATCH 01/23] Revert "drm/atomic-helper: Fix leak in disable_all" Ville Syrjala
2018-03-22 15:22 ` [PATCH 02/23] drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers Ville Syrjala
2018-03-26 20:28   ` Daniel Vetter
2018-03-29 16:32     ` Ville Syrjälä
2018-03-26 20:43   ` Daniel Vetter
2018-03-22 15:22 ` [PATCH 03/23] drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc() Ville Syrjala
2018-03-26 20:41   ` Daniel Vetter
2018-03-22 15:22 ` [PATCH 04/23] drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state Ville Syrjala
2018-03-26 20:42   ` [Intel-gfx] " Daniel Vetter
2018-03-22 15:22 ` [PATCH 05/23] drm: Add local 'plane' variable for primary/cursor planes Ville Syrjala
2018-03-26 20:49   ` Daniel Vetter [this message]
2018-03-22 15:22 ` [PATCH 06/23] drm: Adjust whitespace for legibility Ville Syrjala
2018-03-26 20:49   ` Daniel Vetter
2018-03-22 15:22 ` [PATCH 07/23] drm: Make the fb refcount handover less magic Ville Syrjala
2018-03-27  7:49   ` Daniel Vetter
2018-03-22 15:22 ` [PATCH 08/23] drm: Use plane->state->fb over plane->fb Ville Syrjala
2018-03-27  8:10   ` Daniel Vetter
2018-03-22 15:22 ` [PATCH 09/23] drm/i915: Stop consulting plane->fb Ville Syrjala
     [not found] ` <20180322152313.6561-1-ville.syrjala-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-03-22 15:23   ` [PATCH 10/23] drm/msm: " Ville Syrjala
2018-03-22 15:23   ` [PATCH 19/23] drm/msm: Stop updating plane->fb/crtc Ville Syrjala
2018-03-27  8:21   ` [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers Daniel Vetter
2018-03-22 15:23 ` [PATCH 11/23] drm/sti: Stop consulting plane->fb Ville Syrjala
2018-03-22 16:25   ` Benjamin Gaignard
2018-03-22 15:23 ` [PATCH 12/23] drm/vmwgfx: " Ville Syrjala
2018-03-22 15:53   ` Thomas Hellstrom
2018-03-22 15:23 ` [PATCH 13/23] drm/zte: " Ville Syrjala
2018-03-22 16:12   ` Maarten Lankhorst
2018-03-22 17:40   ` [PATCH v2 " Ville Syrjala
2018-03-26  7:25     ` Shawn Guo
2018-03-26 12:14   ` [PATCH v3 13/23] drm/zte: Stop consulting plane->crtc Ville Syrjala
2018-03-22 15:23 ` [PATCH 14/23] drm/atmel-hlcdc: Stop using plane->fb Ville Syrjala
2018-03-22 16:14   ` Maarten Lankhorst
2018-03-22 17:30     ` Ville Syrjälä
2018-03-27  8:13   ` Daniel Vetter
2018-03-22 15:23 ` [PATCH 15/23] drm: Stop updating plane->crtc/fb/old_fb on atomic drivers Ville Syrjala
2018-03-26 20:52   ` Daniel Vetter
2018-03-26 20:56     ` [Intel-gfx] " Daniel Vetter
2018-03-27  7:57   ` Daniel Vetter
2018-03-27  9:44     ` [Intel-gfx] " Ville Syrjälä
2018-03-22 15:23 ` [PATCH 16/23] drm/amdgpu/dc: Stop updating plane->fb Ville Syrjala
2018-03-23 20:23   ` Harry Wentland
2018-03-22 15:23 ` [PATCH 17/23] drm/i915: Stop updating plane->fb/crtc Ville Syrjala
2018-03-22 15:23 ` [PATCH 18/23] drm/exynos: Stop updating plane->crtc Ville Syrjala
2018-03-22 15:23 ` [PATCH 20/23] drm/virtio: Stop updating plane->fb Ville Syrjala
2018-03-22 16:11   ` Gerd Hoffmann
2018-03-22 17:40   ` [PATCH v2 20/23] drm/virtio: Stop updating plane->crtc Ville Syrjala
2018-03-22 15:23 ` [PATCH 21/23] drm/vc4: Stop updating plane->fb/crtc Ville Syrjala
2018-03-22 16:50   ` Maarten Lankhorst
2018-03-22 15:23 ` [PATCH 22/23] drm/i915: Restore planes after load detection Ville Syrjala
2018-03-22 15:23 ` [PATCH 23/23] drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug Ville Syrjala
2018-03-22 16:49   ` Maarten Lankhorst
2018-03-22 17:41   ` [PATCH v2 " Ville Syrjala
2018-03-22 16:51 ` [PATCH 00/23] drm: Eliminate plane->fb/crtc usage for atomic drivers Noralf Trønnes
     [not found]   ` <b92fe986-295c-fecb-dca1-82cb9bf7b7b1-L59+Z2yzLopAfugRpC6u6w@public.gmane.org>
2018-03-22 18:49     ` Ville Syrjälä
2018-03-22 23:28       ` Noralf Trønnes
2018-03-22 17:54 ` Emil Velikov
     [not found]   ` <CACvgo53B4zLLUqw9y18skpjacmjt-iAYBcG19HkmE=jFwcb4+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-03-22 18:03     ` Harry Wentland
     [not found]       ` <a0d3ec32-be68-c96e-607c-0af4a97a3dd6-5C7GfCeVMHo@public.gmane.org>
2018-03-22 18:34         ` Emil Velikov

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=20180326204906.GC14155@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.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