Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 4/9] drm/i915: Introduce fb->min_alignment
Date: Thu, 13 Jun 2024 13:33:52 +0300	[thread overview]
Message-ID: <ZmrLEHg5IZWLx+WJ@ideak-desk.fi.intel.com> (raw)
In-Reply-To: <20240612204712.31404-5-ville.syrjala@linux.intel.com>

On Wed, Jun 12, 2024 at 11:47:07PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Different planes could have different alignment requirements
> even for the same format/modifier. Collect the alignment
> requirements across all planes capable of scanning out the
> fb such that the alignment is satisfactory to all those
> planes.
> 
> So far this was sort of handle by making sure intel_surf_alignment()
> declares the superset of all planes' alignment requirements,
> but maintaining that manually is annoying. So we're going to move
> towards each plane declaring only its own requirements, and thus
> we need code to generate the superset.
> 
> v2: Drop the borked per-plane vma optimization (Imre)
>     Assert that the plane's declared alignment is POT (Imre)
> 
> Cc: Imre Deak <imre.deak@intel.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Imre Deak <imre.deak@intel.com>

> ---
>  .../drm/i915/display/intel_display_types.h    |  2 ++
>  drivers/gpu/drm/i915/display/intel_fb.c       | 29 +++++++++++++++++++
>  drivers/gpu/drm/i915/display/intel_fb_pin.c   |  5 ++--
>  drivers/gpu/drm/i915/display/intel_fbdev.c    | 18 +-----------
>  4 files changed, 34 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 0c165572fbd0..af7cc3d6c82b 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -146,6 +146,8 @@ struct intel_framebuffer {
>  	};
>  
>  	struct i915_address_space *dpt_vm;
> +
> +	unsigned int min_alignment;
>  };
>  
>  enum intel_hotplug_state {
> diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
> index b3a48754a417..0abb80972885 100644
> --- a/drivers/gpu/drm/i915/display/intel_fb.c
> +++ b/drivers/gpu/drm/i915/display/intel_fb.c
> @@ -11,6 +11,7 @@
>  
>  #include "gem/i915_gem_object.h"
>  #include "i915_drv.h"
> +#include "intel_atomic_plane.h"
>  #include "intel_display.h"
>  #include "intel_display_types.h"
>  #include "intel_dpt.h"
> @@ -1617,6 +1618,32 @@ bool intel_fb_supports_90_270_rotation(const struct intel_framebuffer *fb)
>  	       fb->base.modifier == I915_FORMAT_MOD_Yf_TILED;
>  }
>  
> +static unsigned int intel_fb_min_alignment(const struct drm_framebuffer *fb)
> +{
> +	struct drm_i915_private *i915 = to_i915(fb->dev);
> +	struct intel_plane *plane;
> +	unsigned int min_alignment = 0;
> +
> +	for_each_intel_plane(&i915->drm, plane) {
> +		unsigned int plane_min_alignment;
> +
> +		if (!drm_plane_has_format(&plane->base, fb->format->format, fb->modifier))
> +			continue;
> +
> +		plane_min_alignment = plane->min_alignment(plane, fb, 0);
> +
> +		drm_WARN_ON(&i915->drm, plane_min_alignment &&
> +			    !is_power_of_2(plane_min_alignment));
> +
> +		if (intel_plane_needs_physical(plane))
> +			continue;
> +
> +		min_alignment = max(min_alignment, plane_min_alignment);
> +	}
> +
> +	return min_alignment;
> +}
> +
>  int intel_fill_fb_info(struct drm_i915_private *i915, struct intel_framebuffer *fb)
>  {
>  	struct drm_i915_gem_object *obj = intel_fb_obj(&fb->base);
> @@ -1699,6 +1726,8 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct intel_framebuffer *
>  		return -EINVAL;
>  	}
>  
> +	fb->min_alignment = intel_fb_min_alignment(&fb->base);
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c b/drivers/gpu/drm/i915/display/intel_fb_pin.c
> index 9b0f1ea41b70..575b271e012b 100644
> --- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
> +++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
> @@ -233,10 +233,9 @@ void intel_fb_unpin_vma(struct i915_vma *vma, unsigned long flags)
>  static unsigned int
>  intel_plane_fb_min_alignment(const struct intel_plane_state *plane_state)
>  {
> -	struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
> -	const struct drm_framebuffer *fb = plane_state->hw.fb;
> +	const struct intel_framebuffer *fb = to_intel_framebuffer(plane_state->hw.fb);
>  
> -	return plane->min_alignment(plane, fb, 0);
> +	return fb->min_alignment;
>  }
>  
>  static unsigned int
> diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c
> index 6e5f88f20482..49a1ac4f5491 100644
> --- a/drivers/gpu/drm/i915/display/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
> @@ -47,7 +47,6 @@
>  #include "gem/i915_gem_object.h"
>  
>  #include "i915_drv.h"
> -#include "intel_crtc.h"
>  #include "intel_display_types.h"
>  #include "intel_fb.h"
>  #include "intel_fb_pin.h"
> @@ -173,21 +172,6 @@ static const struct fb_ops intelfb_ops = {
>  
>  __diag_pop();
>  
> -static unsigned int intel_fbdev_min_alignment(const struct drm_framebuffer *fb)
> -{
> -	struct drm_i915_private *i915 = to_i915(fb->dev);
> -	struct intel_plane *plane;
> -	struct intel_crtc *crtc;
> -
> -	crtc = intel_first_crtc(i915);
> -	if (!crtc)
> -		return 0;
> -
> -	plane = to_intel_plane(crtc->base.primary);
> -
> -	return plane->min_alignment(plane, fb, 0);
> -}
> -
>  static int intelfb_create(struct drm_fb_helper *helper,
>  			  struct drm_fb_helper_surface_size *sizes)
>  {
> @@ -245,7 +229,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
>  	 * BIOS is suitable for own access.
>  	 */
>  	vma = intel_fb_pin_to_ggtt(&fb->base, &view,
> -				   intel_fbdev_min_alignment(&fb->base), 0,
> +				   fb->min_alignment, 0,
>  				   false, &flags);
>  	if (IS_ERR(vma)) {
>  		ret = PTR_ERR(vma);
> -- 
> 2.44.2
> 

  reply	other threads:[~2024-06-13 10:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12 20:47 [PATCH v2 0/9] drm/i915: Polish plane surface alignment handling Ville Syrjala
2024-06-12 20:47 ` [PATCH v2 1/9] drm: Rename drm_plane_check_pixel_format() to drm_plane_has_format() Ville Syrjala
2024-06-12 20:47 ` [PATCH v2 2/9] drm: Export drm_plane_has_format() Ville Syrjala
2024-06-17 14:25   ` Daniel Vetter
2024-06-19 11:31   ` [PATCH v3 " Ville Syrjala
2024-06-19 11:34     ` Daniel Stone
2024-06-12 20:47 ` [PATCH v2 3/9] drm/i915: Introduce the plane->min_alignment() vfunc Ville Syrjala
2024-06-12 20:47 ` [PATCH v2 4/9] drm/i915: Introduce fb->min_alignment Ville Syrjala
2024-06-13 10:33   ` Imre Deak [this message]
2024-06-12 20:47 ` [PATCH v2 5/9] drm/i915: Split cursor alignment to per-platform vfuncs Ville Syrjala
2024-06-12 20:47 ` [PATCH v2 6/9] drm/i915: Split pre-skl platforms out from intel_surf_alignment() Ville Syrjala
2024-06-12 20:47 ` [PATCH v2 7/9] drm/i915: Move intel_surf_alignment() into skl_univerals_plane.c Ville Syrjala
2024-06-12 20:47 ` [PATCH v2 8/9] drm/i915: Update plane alignment requirements for TGL+ Ville Syrjala
2024-06-12 20:47 ` [PATCH v2 9/9] drm/i915: Nuke the TGL+ chroma plane tile row alignment stuff Ville Syrjala
2024-06-13  8:52 ` ✗ Fi.CI.SPARSE: warning for drm/i915: Polish plane surface alignment handling (rev2) Patchwork
2024-06-13  9:09 ` ✓ Fi.CI.BAT: success " Patchwork
2024-06-14  3:22 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-06-19 11:38 ` [PATCH v2 0/9] drm/i915: Polish plane surface alignment handling Ville Syrjälä
2024-06-19 16:53   ` Ville Syrjälä
2024-06-19 18:59     ` Rodrigo Vivi
2024-06-24 14:33   ` Ville Syrjälä
2024-06-19 16:48 ` ✗ Fi.CI.SPARSE: warning for drm/i915: Polish plane surface alignment handling (rev3) Patchwork
2024-06-19 16:58 ` ✓ Fi.CI.BAT: success " Patchwork
2024-06-19 20:50 ` ✗ 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=ZmrLEHg5IZWLx+WJ@ideak-desk.fi.intel.com \
    --to=imre.deak@intel.com \
    --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