All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Imre Deak <imre.deak@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 14/23] drm/i915/intel_fb: Factor out convert_plane_offset_to_xy()
Date: Thu, 11 Mar 2021 18:37:43 +0200	[thread overview]
Message-ID: <YEpHV8pwKXJ2m2tA@intel.com> (raw)
In-Reply-To: <YEpGDj7E4KBbPRiO@intel.com>

On Thu, Mar 11, 2021 at 06:32:14PM +0200, Ville Syrjälä wrote:
> On Thu, Mar 11, 2021 at 12:17:27AM +0200, Imre Deak wrote:
> > Factor out to a new function the logic to convert the FB plane offset to
> > x/y and check the validity of x/y, with the goal to make
> > intel_fill_fb_info() more readable.
> > 
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_fb.c | 70 +++++++++++++++----------
> >  1 file changed, 42 insertions(+), 28 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
> > index b96849ec32df..806341c229f0 100644
> > --- a/drivers/gpu/drm/i915/display/intel_fb.c
> > +++ b/drivers/gpu/drm/i915/display/intel_fb.c
> > @@ -400,10 +400,10 @@ static int intel_fb_offset_to_xy(int *x, int *y,
> >  	return 0;
> >  }
> >  
> > -static int intel_fb_check_ccs_xy(struct drm_framebuffer *fb, int ccs_plane, int x, int y)
> > +static int intel_fb_check_ccs_xy(const struct drm_framebuffer *fb, int ccs_plane, int x, int y)
> >  {
> >  	struct drm_i915_private *i915 = to_i915(fb->dev);
> > -	struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
> > +	const struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
> >  	int main_plane;
> >  	int hsub, vsub;
> >  	int tile_width, tile_height;
> > @@ -520,6 +520,45 @@ static bool intel_plane_needs_remap(const struct intel_plane_state *plane_state)
> >  	return stride > max_stride;
> >  }
> >  
> > +static int convert_plane_offset_to_xy(const struct intel_framebuffer *fb, int color_plane,
> > +				      int plane_width, int *x, int *y)
> > +{
> > +	const struct drm_framebuffer *drm_fb = &fb->base;
> 
> Not a fan of these aliasing pointers. I know that the fb 
> stuff is a bit of a mess when it comes to the drm_ vs. intel_
> usage.
> 
> We've mostly cleaned up that stuff for plane/crtc/etc. by just
> avoiding the aliasing pointers and just using foo->base where
> appropriate. Not sure how that sort of approach would look in
> the end of fbs?

Anyways, apart from that annoyance this seems fine.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> 
> > +	struct drm_i915_gem_object *obj = intel_fb_obj(drm_fb);
> > +	int ret;
> > +
> > +	ret = intel_fb_offset_to_xy(x, y, drm_fb, color_plane);
> > +	if (ret) {
> > +		drm_dbg_kms(drm_fb->dev,
> > +			    "bad fb plane %d offset: 0x%x\n",
> > +			    color_plane, drm_fb->offsets[color_plane]);
> > +		return ret;
> > +	}
> > +
> > +	ret = intel_fb_check_ccs_xy(drm_fb, color_plane, *x, *y);
> > +	if (ret)
> > +		return ret;
> > +
> > +	/*
> > +	 * The fence (if used) is aligned to the start of the object
> > +	 * so having the framebuffer wrap around across the edge of the
> > +	 * fenced region doesn't really work. We have no API to configure
> > +	 * the fence start offset within the object (nor could we probably
> > +	 * on gen2/3). So it's just easier if we just require that the
> > +	 * fb layout agrees with the fence layout. We already check that the
> > +	 * fb stride matches the fence stride elsewhere.
> > +	 */
> > +	if (color_plane == 0 && i915_gem_object_is_tiled(obj) &&
> > +	    (*x + plane_width) * drm_fb->format->cpp[color_plane] > drm_fb->pitches[color_plane]) {
> > +		drm_dbg_kms(drm_fb->dev,
> > +			    "bad fb plane %d offset: 0x%x\n",
> > +			    color_plane, drm_fb->offsets[color_plane]);
> > +		return -EINVAL;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  /*
> >   * Setup the rotated view for an FB plane and return the size the GTT mapping
> >   * requires for this view.
> > @@ -611,35 +650,10 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb
> >  		cpp = fb->format->cpp[i];
> >  		intel_fb_plane_dims(&width, &height, fb, i);
> >  
> > -		ret = intel_fb_offset_to_xy(&x, &y, fb, i);
> > -		if (ret) {
> > -			drm_dbg_kms(&i915->drm,
> > -				    "bad fb plane %d offset: 0x%x\n",
> > -				    i, fb->offsets[i]);
> > -			return ret;
> > -		}
> > -
> > -		ret = intel_fb_check_ccs_xy(fb, i, x, y);
> > +		ret = convert_plane_offset_to_xy(intel_fb, i, width, &x, &y);
> >  		if (ret)
> >  			return ret;
> >  
> > -		/*
> > -		 * The fence (if used) is aligned to the start of the object
> > -		 * so having the framebuffer wrap around across the edge of the
> > -		 * fenced region doesn't really work. We have no API to configure
> > -		 * the fence start offset within the object (nor could we probably
> > -		 * on gen2/3). So it's just easier if we just require that the
> > -		 * fb layout agrees with the fence layout. We already check that the
> > -		 * fb stride matches the fence stride elsewhere.
> > -		 */
> > -		if (i == 0 && i915_gem_object_is_tiled(obj) &&
> > -		    (x + width) * cpp > fb->pitches[i]) {
> > -			drm_dbg_kms(&i915->drm,
> > -				    "bad fb plane %d offset: 0x%x\n",
> > -				     i, fb->offsets[i]);
> > -			return -EINVAL;
> > -		}
> > -
> >  		/*
> >  		 * First pixel of the framebuffer from
> >  		 * the start of the normal gtt mapping.
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Ville Syrjälä
> Intel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2021-03-11 16:37 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 22:17 [Intel-gfx] [PATCH 00/23] drm/i915: Add support for FBs requiring a POT stride padding Imre Deak
2021-03-10 22:17 ` [Intel-gfx] [PATCH 01/23] drm/i915: Fix rotation setup during plane HW readout Imre Deak
2021-03-11 16:04   ` Ville Syrjälä
2021-03-11 16:52     ` Imre Deak
2021-03-11 17:25       ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 02/23] drm/i915/selftest: Fix error handling in igt_vma_remapped_gtt() Imre Deak
2021-03-11 16:05   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 03/23] drm/i915/selftest: Fix debug message " Imre Deak
2021-03-11 16:06   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 04/23] drm/i915: Make sure i915_ggtt_view is inited when creating an FB Imre Deak
2021-03-11 16:07   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 05/23] drm/i915/selftest: Make sure to init i915_ggtt_view in igt_vma_rotate_remap() Imre Deak
2021-03-11 16:11   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 06/23] drm/i915: Remove duplicate intel_surf_alignment() declaration Imre Deak
2021-03-11 16:12   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 07/23] drm/i915/intel_fb: Pull FB plane functions from intel_display_types.h Imre Deak
2021-03-11 16:15   ` Ville Syrjälä
2021-03-11 16:31     ` Imre Deak
2021-03-10 22:17 ` [Intel-gfx] [PATCH 08/23] drm/i915/intel_fb: Pull FB plane functions from skl_universal_plane.c Imre Deak
2021-03-11 16:18   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 09/23] drm/i915/intel_fb: Pull is_surface_linear() from intel_display.c/skl_universal_plane.c Imre Deak
2021-03-11 16:19   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 10/23] drm/i915/intel_fb: Pull FB plane functions from intel_sprite.c Imre Deak
2021-03-11 16:20   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 11/23] drm/i915/intel_fb: Pull FB plane functions from intel_display.c Imre Deak
2021-03-11 16:23   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 12/23] drm/i915/intel_fb: Unexport intel_fb_check_stride() Imre Deak
2021-03-11 16:23   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 13/23] drm/i915/intel_fb: s/dev_priv/i915/ Imre Deak
2021-03-11 16:23   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 14/23] drm/i915/intel_fb: Factor out convert_plane_offset_to_xy() Imre Deak
2021-03-11 16:32   ` Ville Syrjälä
2021-03-11 16:37     ` Ville Syrjälä [this message]
2021-03-11 16:57     ` Imre Deak
2021-03-10 22:17 ` [Intel-gfx] [PATCH 15/23] drm/i915/intel_fb: Factor out calc_plane_aligned_offset() Imre Deak
2021-03-11 16:39   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 16/23] drm/i915/intel_fb: Factor out calc_plane_normal_size() Imre Deak
2021-03-11 16:52   ` Ville Syrjälä
2021-03-11 17:02     ` Imre Deak
2021-03-11 17:26       ` Ville Syrjälä
2021-03-11 17:47         ` Imre Deak
2021-03-11 17:58           ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 17/23] drm/i915/intel_fb: Factor out plane_calc_remap_info() Imre Deak
2021-03-11 17:21   ` Ville Syrjälä
2021-03-11 19:04     ` Imre Deak
2021-03-11 19:35       ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 18/23] drm/i915: Shrink the size of intel_remapped_plane_info struct Imre Deak
2021-03-11 19:45   ` Ville Syrjälä
2021-03-11 22:19     ` Imre Deak
2021-03-12 18:09       ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 19/23] drm/i915/selftest: Unify use of intel_remapped_plane_info in igt_vma_rotate_remap() Imre Deak
2021-03-11 21:17   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 20/23] drm/i915: s/stride/src_stride/ in the intel_remapped_plane_info struct Imre Deak
2021-03-12 17:51   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 21/23] drm/i915: Add support for FBs requiring a POT stride alignment Imre Deak
2021-03-12 18:02   ` Ville Syrjälä
2021-03-13 14:36     ` Imre Deak
2021-03-15 14:44       ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 22/23] drm/i915/selftest: Add remap/rotate vma subtests when dst_stride!=width/height Imre Deak
2021-03-12 18:03   ` Ville Syrjälä
2021-03-10 22:17 ` [Intel-gfx] [PATCH 23/23] drm/i915: For-CI: Force remapping the FB with a POT aligned stride Imre Deak
2021-03-10 23:53 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Add support for FBs requiring a POT stride padding Patchwork
2021-03-10 23:54 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-03-11  0:22 ` [Intel-gfx] ✗ Fi.CI.BAT: 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=YEpHV8pwKXJ2m2tA@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@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.