diff mbox series

[v5,4/7] drm/i915/display: update and store the plane damage clips

Message ID 20250128155418.305595-5-vinod.govindapillai@intel.com (mailing list archive)
State New
Headers show
Series drm/i915/xe3: FBC Dirty rect feature support | expand

Commit Message

Vinod Govindapillai Jan. 28, 2025, 3:54 p.m. UTC
Userspace can pass damage area clips per plane to track
changes in a plane and some display components can utilze
these damage clips for efficiently handling use cases like
FBC, PSR etc. A merged damage area is generated and its
coordinates are updated relative to viewport and HW and
stored in the plane_state. This merged damage areas will be
used for FBC dirty rect support in xe3 in the follow-up
patch.

Signed-off-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
---
 .../gpu/drm/i915/display/intel_atomic_plane.c |  5 ++
 .../drm/i915/display/intel_display_types.h    |  2 +
 .../drm/i915/display/skl_universal_plane.c    | 47 +++++++++++++++++++
 3 files changed, 54 insertions(+)

Comments

Ville Syrjala Jan. 28, 2025, 4:14 p.m. UTC | #1
On Tue, Jan 28, 2025 at 05:54:15PM +0200, Vinod Govindapillai wrote:
> Userspace can pass damage area clips per plane to track
> changes in a plane and some display components can utilze
> these damage clips for efficiently handling use cases like
> FBC, PSR etc. A merged damage area is generated and its
> coordinates are updated relative to viewport and HW and
> stored in the plane_state. This merged damage areas will be
> used for FBC dirty rect support in xe3 in the follow-up
> patch.
> 
> Signed-off-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
> ---
>  .../gpu/drm/i915/display/intel_atomic_plane.c |  5 ++
>  .../drm/i915/display/intel_display_types.h    |  2 +
>  .../drm/i915/display/skl_universal_plane.c    | 47 +++++++++++++++++++
>  3 files changed, 54 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> index 8da7ee13447c..3d463cfe1f3c 100644
> --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> @@ -36,6 +36,7 @@
>  
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_blend.h>
> +#include <drm/drm_damage_helper.h>
>  #include <drm/drm_fourcc.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_atomic_helper.h>
> @@ -713,6 +714,10 @@ int intel_plane_atomic_check(struct intel_atomic_state *state,
>  					  new_primary_crtc_plane_state,
>  					  crtc);
>  
> +	/* Verify plane damage - damage discarded on full modeset */
> +	drm_atomic_helper_check_plane_damage(&state->base,
> +					     &new_plane_state->uapi);

That guy doesn't seem to do anything that we want.

> +
>  	new_plane_state->uapi.visible = false;
>  	if (!new_crtc_state)
>  		return 0;
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index bc65c4bd9dc0..495c497645c0 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -695,6 +695,8 @@ struct intel_plane_state {
>  	u64 ccval;
>  
>  	const char *no_fbc_reason;
> +
> +	struct drm_rect damage_merged;
>  };
>  
>  struct intel_initial_plane_config {
> diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> index 8d09a1f8c3e1..fc5b9d56c8bc 100644
> --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> @@ -2249,6 +2249,47 @@ static void check_protection(struct intel_plane_state *plane_state)
>  		!plane_state->decrypt;
>  }
>  
> +static void
> +skl_plane_check_plane_damage(const struct intel_plane_state *old_plane_state,
> +			     struct intel_plane_state *new_plane_state)
> +{
> +	struct drm_rect *damage_merged = &new_plane_state->damage_merged;
> +
> +	drm_atomic_helper_damage_merged(&old_plane_state->uapi,
> +					&new_plane_state->uapi,
> +					damage_merged);

You're calling that too late. With bigjoiner it's now going to
use the uapi state from the wrong plane. This thing needs to be
done in intel_plane_copy_uapi_to_hw_state().

> +}
> +
> +static void
> +skl_plane_check_damage_with_viewport(struct intel_plane_state *plane_state)
> +{
> +	struct drm_rect *damage_merged = &plane_state->damage_merged;
> +	const struct drm_framebuffer *fb = plane_state->hw.fb;
> +	unsigned int rotation = plane_state->hw.rotation;
> +	struct drm_rect *src = &plane_state->uapi.src;
> +
> +	if (drm_rotation_90_or_270(rotation)) {
> +		drm_rect_rotate(damage_merged, fb->width, fb->height,
> +				DRM_MODE_ROTATE_270);
> +		drm_rect_translate(damage_merged, -(src->y1 >> 16),
> +				   -(src->x1 >> 16));
> +	} else {
> +		drm_rect_translate(damage_merged, -(src->x1 >> 16),
> +				   -(src->y1 >> 16));
> +	}
> +}
> +
> +static void
> +skl_plane_check_damage_with_plane_surf(struct intel_plane_state *plane_state)
> +{
> +	struct drm_rect *damage_merged = &plane_state->damage_merged;
> +	struct drm_rect src;
> +
> +	drm_rect_fp_to_int(&src, &plane_state->uapi.src);
> +	drm_rect_translate(damage_merged, src.x1, src.y1);
> +	drm_rect_intersect(damage_merged, &src);
> +}
> +
>  static int skl_plane_check(struct intel_crtc_state *crtc_state,
>  			   const struct intel_plane_state *old_plane_state,
>  			   struct intel_plane_state *plane_state)
> @@ -2275,6 +2316,10 @@ static int skl_plane_check(struct intel_crtc_state *crtc_state,
>  	if (ret)
>  		return ret;
>  
> +	skl_plane_check_plane_damage(old_plane_state, plane_state);
> +
> +	skl_plane_check_damage_with_viewport(plane_state);
> +
>  	ret = skl_check_plane_surface(plane_state);
>  	if (ret)
>  		return ret;
> @@ -2290,6 +2335,8 @@ static int skl_plane_check(struct intel_crtc_state *crtc_state,
>  	if (ret)
>  		return ret;
>  
> +	skl_plane_check_damage_with_plane_surf(plane_state);
> +
>  	ret = skl_plane_check_nv12_rotation(plane_state);
>  	if (ret)
>  		return ret;
> -- 
> 2.43.0
Vinod Govindapillai Jan. 29, 2025, 9:14 a.m. UTC | #2
On Tue, 2025-01-28 at 18:14 +0200, Ville Syrjälä wrote:
> On Tue, Jan 28, 2025 at 05:54:15PM +0200, Vinod Govindapillai wrote:
> > Userspace can pass damage area clips per plane to track
> > changes in a plane and some display components can utilze
> > these damage clips for efficiently handling use cases like
> > FBC, PSR etc. A merged damage area is generated and its
> > coordinates are updated relative to viewport and HW and
> > stored in the plane_state. This merged damage areas will be
> > used for FBC dirty rect support in xe3 in the follow-up
> > patch.
> > 
> > Signed-off-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
> > ---
> >  .../gpu/drm/i915/display/intel_atomic_plane.c |  5 ++
> >  .../drm/i915/display/intel_display_types.h    |  2 +
> >  .../drm/i915/display/skl_universal_plane.c    | 47 +++++++++++++++++++
> >  3 files changed, 54 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > index 8da7ee13447c..3d463cfe1f3c 100644
> > --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > @@ -36,6 +36,7 @@
> >  
> >  #include <drm/drm_atomic_helper.h>
> >  #include <drm/drm_blend.h>
> > +#include <drm/drm_damage_helper.h>
> >  #include <drm/drm_fourcc.h>
> >  #include <drm/drm_gem.h>
> >  #include <drm/drm_gem_atomic_helper.h>
> > @@ -713,6 +714,10 @@ int intel_plane_atomic_check(struct intel_atomic_state *state,
> >  					  new_primary_crtc_plane_state,
> >  					  crtc);
> >  
> > +	/* Verify plane damage - damage discarded on full modeset */
> > +	drm_atomic_helper_check_plane_damage(&state->base,
> > +					     &new_plane_state->uapi);
> 
> That guy doesn't seem to do anything that we want.

Hi Ville,

Thanks your time in reviewing this!!

Okay. I thought this will cause the damage_help return the whole region in case of a full modeset.

> 
> > +
> >  	new_plane_state->uapi.visible = false;
> >  	if (!new_crtc_state)
> >  		return 0;
> > diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h
> > b/drivers/gpu/drm/i915/display/intel_display_types.h
> > index bc65c4bd9dc0..495c497645c0 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> > +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> > @@ -695,6 +695,8 @@ struct intel_plane_state {
> >  	u64 ccval;
> >  
> >  	const char *no_fbc_reason;
> > +
> > +	struct drm_rect damage_merged;
> >  };
> >  
> >  struct intel_initial_plane_config {
> > diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> > b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> > index 8d09a1f8c3e1..fc5b9d56c8bc 100644
> > --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> > +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> > @@ -2249,6 +2249,47 @@ static void check_protection(struct intel_plane_state *plane_state)
> >  		!plane_state->decrypt;
> >  }
> >  
> > +static void
> > +skl_plane_check_plane_damage(const struct intel_plane_state *old_plane_state,
> > +			     struct intel_plane_state *new_plane_state)
> > +{
> > +	struct drm_rect *damage_merged = &new_plane_state->damage_merged;
> > +
> > +	drm_atomic_helper_damage_merged(&old_plane_state->uapi,
> > +					&new_plane_state->uapi,
> > +					damage_merged);
> 
> You're calling that too late. With bigjoiner it's now going to
> use the uapi state from the wrong plane. This thing needs to be
> done in intel_plane_copy_uapi_to_hw_state().

Ok. So I have to get and store the damage_merged before the copy.
You mentioned that to be done inside intel_plane_copy_uapi_to_hw_state()! Any specific reason? The
reason I am asking this is because, the drm_atomic_helper_damage_merged() expects old_plane_state as
a mean to check the rect changes and returns full region as damaged in case of src rect is not equal
between old and new plane states. So wondering if I need to pass the old_plane_state to
intel_plane_copy_uapi_to_hw_state()?

And then just wanted to double check that the rest of the coordinate conversions you suggested
earlier stays as it is in case of bigjoiner?

If the plane_state is not visible, drm_atomic_helper_damage_merged() return false. You mentioned
before that we might need a state variable to track the validity of the damage_merged and update the
FBC dirty_rect  registers only if it is valid. So fare in my trials all the case where we end up in
atomic_commit_tail->fbc_dirty_rect upadte->page_flip, usually ends up having valid damage_merged
coordinates. Do you see any other cases and suggest to have such state variable required?

Thanks
Vinod

> 
> > +}
> > +
> > +static void
> > +skl_plane_check_damage_with_viewport(struct intel_plane_state *plane_state)
> > +{
> > +	struct drm_rect *damage_merged = &plane_state->damage_merged;
> > +	const struct drm_framebuffer *fb = plane_state->hw.fb;
> > +	unsigned int rotation = plane_state->hw.rotation;
> > +	struct drm_rect *src = &plane_state->uapi.src;
> > +
> > +	if (drm_rotation_90_or_270(rotation)) {
> > +		drm_rect_rotate(damage_merged, fb->width, fb->height,
> > +				DRM_MODE_ROTATE_270);
> > +		drm_rect_translate(damage_merged, -(src->y1 >> 16),
> > +				   -(src->x1 >> 16));
> > +	} else {
> > +		drm_rect_translate(damage_merged, -(src->x1 >> 16),
> > +				   -(src->y1 >> 16));
> > +	}
> > +}
> > +
> > +static void
> > +skl_plane_check_damage_with_plane_surf(struct intel_plane_state *plane_state)
> > +{
> > +	struct drm_rect *damage_merged = &plane_state->damage_merged;
> > +	struct drm_rect src;
> > +
> > +	drm_rect_fp_to_int(&src, &plane_state->uapi.src);
> > +	drm_rect_translate(damage_merged, src.x1, src.y1);
> > +	drm_rect_intersect(damage_merged, &src);
> > +}
> > +
> >  static int skl_plane_check(struct intel_crtc_state *crtc_state,
> >  			   const struct intel_plane_state *old_plane_state,
> >  			   struct intel_plane_state *plane_state)
> > @@ -2275,6 +2316,10 @@ static int skl_plane_check(struct intel_crtc_state *crtc_state,
> >  	if (ret)
> >  		return ret;
> >  
> > +	skl_plane_check_plane_damage(old_plane_state, plane_state);
> > +
> > +	skl_plane_check_damage_with_viewport(plane_state);
> > +
> >  	ret = skl_check_plane_surface(plane_state);
> >  	if (ret)
> >  		return ret;
> > @@ -2290,6 +2335,8 @@ static int skl_plane_check(struct intel_crtc_state *crtc_state,
> >  	if (ret)
> >  		return ret;
> >  
> > +	skl_plane_check_damage_with_plane_surf(plane_state);
> > +
> >  	ret = skl_plane_check_nv12_rotation(plane_state);
> >  	if (ret)
> >  		return ret;
> > -- 
> > 2.43.0
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index 8da7ee13447c..3d463cfe1f3c 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -36,6 +36,7 @@ 
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_blend.h>
+#include <drm/drm_damage_helper.h>
 #include <drm/drm_fourcc.h>
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_atomic_helper.h>
@@ -713,6 +714,10 @@  int intel_plane_atomic_check(struct intel_atomic_state *state,
 					  new_primary_crtc_plane_state,
 					  crtc);
 
+	/* Verify plane damage - damage discarded on full modeset */
+	drm_atomic_helper_check_plane_damage(&state->base,
+					     &new_plane_state->uapi);
+
 	new_plane_state->uapi.visible = false;
 	if (!new_crtc_state)
 		return 0;
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index bc65c4bd9dc0..495c497645c0 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -695,6 +695,8 @@  struct intel_plane_state {
 	u64 ccval;
 
 	const char *no_fbc_reason;
+
+	struct drm_rect damage_merged;
 };
 
 struct intel_initial_plane_config {
diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
index 8d09a1f8c3e1..fc5b9d56c8bc 100644
--- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
+++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
@@ -2249,6 +2249,47 @@  static void check_protection(struct intel_plane_state *plane_state)
 		!plane_state->decrypt;
 }
 
+static void
+skl_plane_check_plane_damage(const struct intel_plane_state *old_plane_state,
+			     struct intel_plane_state *new_plane_state)
+{
+	struct drm_rect *damage_merged = &new_plane_state->damage_merged;
+
+	drm_atomic_helper_damage_merged(&old_plane_state->uapi,
+					&new_plane_state->uapi,
+					damage_merged);
+}
+
+static void
+skl_plane_check_damage_with_viewport(struct intel_plane_state *plane_state)
+{
+	struct drm_rect *damage_merged = &plane_state->damage_merged;
+	const struct drm_framebuffer *fb = plane_state->hw.fb;
+	unsigned int rotation = plane_state->hw.rotation;
+	struct drm_rect *src = &plane_state->uapi.src;
+
+	if (drm_rotation_90_or_270(rotation)) {
+		drm_rect_rotate(damage_merged, fb->width, fb->height,
+				DRM_MODE_ROTATE_270);
+		drm_rect_translate(damage_merged, -(src->y1 >> 16),
+				   -(src->x1 >> 16));
+	} else {
+		drm_rect_translate(damage_merged, -(src->x1 >> 16),
+				   -(src->y1 >> 16));
+	}
+}
+
+static void
+skl_plane_check_damage_with_plane_surf(struct intel_plane_state *plane_state)
+{
+	struct drm_rect *damage_merged = &plane_state->damage_merged;
+	struct drm_rect src;
+
+	drm_rect_fp_to_int(&src, &plane_state->uapi.src);
+	drm_rect_translate(damage_merged, src.x1, src.y1);
+	drm_rect_intersect(damage_merged, &src);
+}
+
 static int skl_plane_check(struct intel_crtc_state *crtc_state,
 			   const struct intel_plane_state *old_plane_state,
 			   struct intel_plane_state *plane_state)
@@ -2275,6 +2316,10 @@  static int skl_plane_check(struct intel_crtc_state *crtc_state,
 	if (ret)
 		return ret;
 
+	skl_plane_check_plane_damage(old_plane_state, plane_state);
+
+	skl_plane_check_damage_with_viewport(plane_state);
+
 	ret = skl_check_plane_surface(plane_state);
 	if (ret)
 		return ret;
@@ -2290,6 +2335,8 @@  static int skl_plane_check(struct intel_crtc_state *crtc_state,
 	if (ret)
 		return ret;
 
+	skl_plane_check_damage_with_plane_surf(plane_state);
+
 	ret = skl_plane_check_nv12_rotation(plane_state);
 	if (ret)
 		return ret;