All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 3/6] drm/i915: Clean up intel_find_initial_plane_obj() a bit
Date: Wed, 9 Jun 2021 07:36:01 -0400	[thread overview]
Message-ID: <YMCnofgoTGL0Qwp0@intel.com> (raw)
In-Reply-To: <20210609085632.22026-4-ville.syrjala@linux.intel.com>

On Wed, Jun 09, 2021 at 11:56:29AM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Sort out the mess with the local variables in
> intel_find_initial_plane_obj(). Get rid of all aliasing pointers
> and use standard naming/types.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 113 ++++++++++---------
>  1 file changed, 62 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 78815a1ac0ca..1615501685c9 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -1914,20 +1914,50 @@ static void intel_dpt_unpin(struct i915_address_space *vm)
>  	i915_vma_put(dpt->vma);
>  }
>  
> +static bool
> +intel_reuse_initial_plane_obj(struct drm_i915_private *i915,
> +			      const struct intel_initial_plane_config *plane_config,
> +			      struct drm_framebuffer **fb,
> +			      struct i915_vma **vma)
> +{
> +	struct intel_crtc *crtc;
> +
> +	for_each_intel_crtc(&i915->drm, crtc) {
> +		struct intel_crtc_state *crtc_state =
> +			to_intel_crtc_state(crtc->base.state);
> +		struct intel_plane *plane =
> +			to_intel_plane(crtc->base.primary);
> +		struct intel_plane_state *plane_state =
> +			to_intel_plane_state(plane->base.state);
> +
> +		if (!crtc_state->uapi.active)
> +			continue;
> +
> +		if (!plane_state->ggtt_vma)
> +			continue;
> +
> +		if (intel_plane_ggtt_offset(plane_state) == plane_config->base) {
> +			*fb = plane_state->hw.fb;
> +			*vma = plane_state->ggtt_vma;
> +			return true;
> +		}
> +	}
> +
> +	return false;
> +}
> +
>  static void
> -intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
> +intel_find_initial_plane_obj(struct intel_crtc *crtc,
>  			     struct intel_initial_plane_config *plane_config)
>  {
> -	struct drm_device *dev = intel_crtc->base.dev;
> +	struct drm_device *dev = crtc->base.dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
> -	struct drm_crtc *c;
> -	struct drm_plane *primary = intel_crtc->base.primary;
> -	struct drm_plane_state *plane_state = primary->state;
> -	struct intel_plane *intel_plane = to_intel_plane(primary);
> -	struct intel_plane_state *intel_state =
> -		to_intel_plane_state(plane_state);
>  	struct intel_crtc_state *crtc_state =
> -		to_intel_crtc_state(intel_crtc->base.state);
> +		to_intel_crtc_state(crtc->base.state);
> +	struct intel_plane *plane =
> +		to_intel_plane(crtc->base.primary);
> +	struct intel_plane_state *plane_state =
> +		to_intel_plane_state(plane->base.state);
>  	struct drm_framebuffer *fb;
>  	struct i915_vma *vma;
>  
> @@ -1939,7 +1969,7 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
>  	if (!plane_config->fb)
>  		return;
>  
> -	if (intel_alloc_initial_plane_obj(intel_crtc, plane_config)) {
> +	if (intel_alloc_initial_plane_obj(crtc, plane_config)) {
>  		fb = &plane_config->fb->base;
>  		vma = plane_config->vma;
>  		goto valid_fb;
> @@ -1949,25 +1979,8 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
>  	 * Failed to alloc the obj, check to see if we should share
>  	 * an fb with another CRTC instead
>  	 */
> -	for_each_crtc(dev, c) {
> -		struct intel_plane_state *state;
> -
> -		if (c == &intel_crtc->base)
> -			continue;
> -
> -		if (!to_intel_crtc_state(c->state)->uapi.active)
> -			continue;
> -
> -		state = to_intel_plane_state(c->primary->state);
> -		if (!state->ggtt_vma)
> -			continue;
> -
> -		if (intel_plane_ggtt_offset(state) == plane_config->base) {
> -			fb = state->hw.fb;
> -			vma = state->ggtt_vma;
> -			goto valid_fb;
> -		}
> -	}
> +	if (intel_reuse_initial_plane_obj(dev_priv, plane_config, &fb, &vma))
> +		goto valid_fb;
>  
>  	/*
>  	 * We've failed to reconstruct the BIOS FB.  Current display state
> @@ -1976,7 +1989,7 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
>  	 * simplest solution is to just disable the primary plane now and
>  	 * pretend the BIOS never had it enabled.
>  	 */
> -	intel_plane_disable_noatomic(intel_crtc, intel_plane);
> +	intel_plane_disable_noatomic(crtc, plane);
>  	if (crtc_state->bigjoiner) {
>  		struct intel_crtc *slave =
>  			crtc_state->bigjoiner_linked_crtc;
> @@ -1986,40 +1999,38 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
>  	return;
>  
>  valid_fb:
> -	plane_state->rotation = plane_config->rotation;
> -	intel_fb_fill_view(to_intel_framebuffer(fb), plane_state->rotation,
> -			   &intel_state->view);
> +	plane_state->uapi.rotation = plane_config->rotation;
> +	intel_fb_fill_view(to_intel_framebuffer(fb),
> +			   plane_state->uapi.rotation, &plane_state->view);
>  
>  	__i915_vma_pin(vma);
> -	intel_state->ggtt_vma = i915_vma_get(vma);
> -	if (intel_plane_uses_fence(intel_state) && i915_vma_pin_fence(vma) == 0)
> -		if (vma->fence)
> -			intel_state->flags |= PLANE_HAS_FENCE;
> +	plane_state->ggtt_vma = i915_vma_get(vma);
> +	if (intel_plane_uses_fence(plane_state) &&
> +	    i915_vma_pin_fence(vma) == 0 && vma->fence)
> +		plane_state->flags |= PLANE_HAS_FENCE;
>  
> -	plane_state->src_x = 0;
> -	plane_state->src_y = 0;
> -	plane_state->src_w = fb->width << 16;
> -	plane_state->src_h = fb->height << 16;
> +	plane_state->uapi.src_x = 0;
> +	plane_state->uapi.src_y = 0;
> +	plane_state->uapi.src_w = fb->width << 16;
> +	plane_state->uapi.src_h = fb->height << 16;
>  
> -	plane_state->crtc_x = 0;
> -	plane_state->crtc_y = 0;
> -	plane_state->crtc_w = fb->width;
> -	plane_state->crtc_h = fb->height;
> +	plane_state->uapi.crtc_x = 0;
> +	plane_state->uapi.crtc_y = 0;
> +	plane_state->uapi.crtc_w = fb->width;
> +	plane_state->uapi.crtc_h = fb->height;
>  
>  	if (plane_config->tiling)
>  		dev_priv->preserve_bios_swizzle = true;
>  
> -	plane_state->fb = fb;
> +	plane_state->uapi.fb = fb;

I believe we should have a separated patch for these plane_state uapi changes

>  	drm_framebuffer_get(fb);
>  
> -	plane_state->crtc = &intel_crtc->base;
> -	intel_plane_copy_uapi_to_hw_state(intel_state, intel_state,
> -					  intel_crtc);
> +	plane_state->uapi.crtc = &crtc->base;
> +	intel_plane_copy_uapi_to_hw_state(plane_state, plane_state, crtc);
>  
>  	intel_frontbuffer_flush(to_intel_frontbuffer(fb), ORIGIN_DIRTYFB);
>  
> -	atomic_or(to_intel_plane(primary)->frontbuffer_bit,
> -		  &to_intel_frontbuffer(fb)->bits);
> +	atomic_or(plane->frontbuffer_bit, &to_intel_frontbuffer(fb)->bits);
>  }
>  
>  unsigned int
> -- 
> 2.31.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2021-06-09 11:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09  8:56 [Intel-gfx] [PATCH 0/6] drm/i915: Cleanup intel_crtc leftovers Ville Syrjala
2021-06-09  8:56 ` [Intel-gfx] [PATCH 1/6] drm/i915: Stop hand rolling drm_crtc_mask() Ville Syrjala
2021-06-09 11:25   ` Rodrigo Vivi
2021-06-09  8:56 ` [Intel-gfx] [PATCH 2/6] drm/i915: Clean up intel_get_load_detect_pipe() a bit Ville Syrjala
2021-06-09 11:27   ` Rodrigo Vivi
2021-06-09  8:56 ` [Intel-gfx] [PATCH 3/6] drm/i915: Clean up intel_find_initial_plane_obj() " Ville Syrjala
2021-06-09 11:36   ` Rodrigo Vivi [this message]
2021-06-09 12:15     ` Ville Syrjälä
2021-06-09 21:05       ` Rodrigo Vivi
2021-06-09  8:56 ` [Intel-gfx] [PATCH 4/6] drm/i915: Clean up pre-skl wm calling convention Ville Syrjala
2021-06-09 11:44   ` Rodrigo Vivi
2021-06-09  8:56 ` [Intel-gfx] [PATCH 5/6] drm/i915: Clean up intel_fbdev_init_bios() a bit Ville Syrjala
2021-06-09 11:46   ` Rodrigo Vivi
2021-06-09 21:06     ` Rodrigo Vivi
2021-06-09  8:56 ` [Intel-gfx] [PATCH 6/6] drm/i915: s/intel_crtc/crtc/ Ville Syrjala
2021-06-09 11:49   ` Rodrigo Vivi
2021-06-09  9:39 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Cleanup intel_crtc leftovers Patchwork
2021-06-09  9:41 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-06-09 10:09 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-06-09 10:09 ` [Intel-gfx] ✗ Fi.CI.BUILD: warning " Patchwork
2021-06-09 12:42 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

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=YMCnofgoTGL0Qwp0@intel.com \
    --to=rodrigo.vivi@intel.com \
    --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 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.