Currently selective fetch area calculation ends up as bogus area in at least following cases:
1. Updated plane is partially or fully outside pipe area 2. Big fb with only part of memory area used for plane
These end up as y1 = 0, y2 = 4 or y2 being outside pipe area. This patch set addresses these by ensuring update area is within pipe area or by falling back to full update.
Patch set also adds drm_dbg_once* macros to print out debug message only once. drm_dbg_once_kms is used to printout debug message when selective fetch area calculation fails.
v3: - Add drm_dbg_once* and use it when sel fetch area calculation fails - Move drm_rect_intersect to clip_area_update v2: - Update commit message of first patch - Set damaged_area x1 and x2 during initialization
Cc: José Roberto de Souza jose.souza@intel.com Cc: Mika Kahola mika.kahola@intel.com Cc: Mark Pearson markpearson@lenovo.com
Jouni Högander (3): drm/print: Add drm_debug_once* macros drm/i915/psr: Use full update In case of area calculation fails drm/i915: Ensure damage clip area is within pipe area
drivers/gpu/drm/i915/display/intel_psr.c | 36 +++++++++++++++++++----- include/drm/drm_print.h | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+), 7 deletions(-)
Add drm_debug_once* macros to allow printing out one time debug messages which can be still controlled via drm.debug parameter.
Cc: José Roberto de Souza jose.souza@intel.com Cc: Mika Kahola mika.kahola@intel.com Cc: Mark Pearson markpearson@lenovo.com Signed-off-by: Jouni Högander jouni.hogander@intel.com --- include/drm/drm_print.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 22fabdeed297..e339f47eeb6d 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -476,6 +476,35 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_dbg_drmres(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__)
+#define drm_dev_dbg_once(dev, cat, fmt, ...) \ +({ \ + static bool __print_once __read_mostly; \ + if (!__print_once) { \ + __print_once = true; \ + drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__); \ + } \ +}) + +#define drm_dbg_once_core(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__) +#define drm_dbg_once(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) +#define drm_dbg_once_kms(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__) +#define drm_dbg_once_prime(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_PRIME, fmt, ##__VA_ARGS__) +#define drm_dbg_once_atomic(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) +#define drm_dbg_once_vbl(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_VBL, fmt, ##__VA_ARGS__) +#define drm_dbg_once_state(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_STATE, fmt, ##__VA_ARGS__) +#define drm_dbg_once_lease(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_LEASE, fmt, ##__VA_ARGS__) +#define drm_dbg_once_dp(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DP, fmt, ##__VA_ARGS__) +#define drm_dbg_once_drmres(drm, fmt, ...) \ + drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__)
/* * printk based logging
On Tue, 2022-05-10 at 21:33 +0300, Jouni Högander wrote:
Add drm_debug_once* macros to allow printing out one time debug messages which can be still controlled via drm.debug parameter.
Reviewed-by: José Roberto de Souza jose.souza@intel.com
Cc: José Roberto de Souza jose.souza@intel.com Cc: Mika Kahola mika.kahola@intel.com Cc: Mark Pearson markpearson@lenovo.com Signed-off-by: Jouni Högander jouni.hogander@intel.com
include/drm/drm_print.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 22fabdeed297..e339f47eeb6d 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -476,6 +476,35 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_dbg_drmres(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__)
+#define drm_dev_dbg_once(dev, cat, fmt, ...) \ +({ \
- static bool __print_once __read_mostly; \
- if (!__print_once) { \
__print_once = true; \
drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__); \
- } \
+})
+#define drm_dbg_once_core(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__)
+#define drm_dbg_once(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_kms(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_prime(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_atomic(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_vbl(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_VBL, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_state(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_STATE, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_lease(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_dp(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DP, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_drmres(drm, fmt, ...) \
- drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__)
/*
- printk based logging
Currently we have some corner cases where area calculation fails. For these sel fetch area calculation ends up having update area as y1 = 0, y2 = 4. Instead of these values safer option is full update.
One of such for example is big fb with offset. We don't have usable offset in psr2_sel_fetch_update. Currently it's open what is the proper way to fix this corner case. Use full update for now.
v2: Commit message modified v3: Print out debug info once when area calculation fails
Cc: José Roberto de Souza jose.souza@intel.com Cc: Mika Kahola mika.kahola@intel.com Cc: Mark Pearson markpearson@lenovo.com Signed-off-by: Jouni Högander jouni.hogander@intel.com --- drivers/gpu/drm/i915/display/intel_psr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_psr.c b/drivers/gpu/drm/i915/display/intel_psr.c index 06db407e2749..3561c218cfb1 100644 --- a/drivers/gpu/drm/i915/display/intel_psr.c +++ b/drivers/gpu/drm/i915/display/intel_psr.c @@ -1685,6 +1685,7 @@ static bool psr2_sel_fetch_pipe_state_supported(const struct intel_crtc_state *c int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, struct intel_crtc *crtc) { + struct drm_i915_private *dev_priv = to_i915(state->base.dev); struct intel_crtc_state *crtc_state = intel_atomic_get_new_crtc_state(state, crtc); struct drm_rect pipe_clip = { .x1 = 0, .y1 = -1, .x2 = INT_MAX, .y2 = -1 }; struct intel_plane_state *new_plane_state, *old_plane_state; @@ -1770,6 +1771,17 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, clip_area_update(&pipe_clip, &damaged_area); }
+ /* + * TODO: For now we are just using full update in case + * selective fetch area calculation fails. To optimize this we + * should identify cases where this happens and fix the area + * calculation for those. + */ + if (pipe_clip.y1 == -1) { + drm_dbg_once_kms(&dev_priv->drm, "No selective fetch area, using full update"); + full_update = true; + } + if (full_update) goto skip_sel_fetch_set_loop;
On Tue, 2022-05-10 at 21:33 +0300, Jouni Högander wrote:
Currently we have some corner cases where area calculation fails. For these sel fetch area calculation ends up having update area as y1 = 0, y2 = 4. Instead of these values safer option is full update.
One of such for example is big fb with offset. We don't have usable offset in psr2_sel_fetch_update. Currently it's open what is the proper way to fix this corner case. Use full update for now.
v2: Commit message modified v3: Print out debug info once when area calculation fails
Cc: José Roberto de Souza jose.souza@intel.com Cc: Mika Kahola mika.kahola@intel.com Cc: Mark Pearson markpearson@lenovo.com Signed-off-by: Jouni Högander jouni.hogander@intel.com
drivers/gpu/drm/i915/display/intel_psr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_psr.c b/drivers/gpu/drm/i915/display/intel_psr.c index 06db407e2749..3561c218cfb1 100644 --- a/drivers/gpu/drm/i915/display/intel_psr.c +++ b/drivers/gpu/drm/i915/display/intel_psr.c @@ -1685,6 +1685,7 @@ static bool psr2_sel_fetch_pipe_state_supported(const struct intel_crtc_state *c int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, struct intel_crtc *crtc) {
- struct drm_i915_private *dev_priv = to_i915(state->base.dev); struct intel_crtc_state *crtc_state = intel_atomic_get_new_crtc_state(state, crtc); struct drm_rect pipe_clip = { .x1 = 0, .y1 = -1, .x2 = INT_MAX, .y2 = -1 }; struct intel_plane_state *new_plane_state, *old_plane_state;
@@ -1770,6 +1771,17 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, clip_area_update(&pipe_clip, &damaged_area); }
- /*
* TODO: For now we are just using full update in case
* selective fetch area calculation fails. To optimize this we
* should identify cases where this happens and fix the area
* calculation for those.
*/
- if (pipe_clip.y1 == -1) {
drm_dbg_once_kms(&dev_priv->drm, "No selective fetch area, using full update");
The debug message is misleading, a better message would be: Selective fetch area calculation failed in pipeA.
with that: Reviewed-by: José Roberto de Souza jose.souza@intel.com
full_update = true;
- }
- if (full_update) goto skip_sel_fetch_set_loop;
Current update area calculation is not handling situation where e.g. cursor plane is fully or partially outside pipe area.
Fix this by checking damage area against pipe_src area using drm_rect_intersect.
v2: Set x1 and x2 in damaged_area initialization v3: Move drm_rect_intersect into clip_area_update
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5440 Cc: José Roberto de Souza jose.souza@intel.com Cc: Mika Kahola mika.kahola@intel.com Cc: Mark Pearson markpearson@lenovo.com Signed-off-by: Jouni Högander jouni.hogander@intel.com --- drivers/gpu/drm/i915/display/intel_psr.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_psr.c b/drivers/gpu/drm/i915/display/intel_psr.c index 3561c218cfb1..f4b4c1c83d2b 100644 --- a/drivers/gpu/drm/i915/display/intel_psr.c +++ b/drivers/gpu/drm/i915/display/intel_psr.c @@ -1618,8 +1618,12 @@ static void psr2_man_trk_ctl_calc(struct intel_crtc_state *crtc_state, }
static void clip_area_update(struct drm_rect *overlap_damage_area, - struct drm_rect *damage_area) + struct drm_rect *damage_area, + struct drm_rect *draw_area) { + if (!drm_rect_intersect(damage_area, draw_area)) + return; + if (overlap_damage_area->y1 == -1) { overlap_damage_area->y1 = damage_area->y1; overlap_damage_area->y2 = damage_area->y2; @@ -1709,7 +1713,8 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, */ for_each_oldnew_intel_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { - struct drm_rect src, damaged_area = { .y1 = -1 }; + struct drm_rect src, damaged_area = { .x1 = 0, .y1 = -1, + .x2 = INT_MAX }; struct drm_atomic_helper_damage_iter iter; struct drm_rect clip;
@@ -1736,20 +1741,23 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, if (old_plane_state->uapi.visible) { damaged_area.y1 = old_plane_state->uapi.dst.y1; damaged_area.y2 = old_plane_state->uapi.dst.y2; - clip_area_update(&pipe_clip, &damaged_area); + clip_area_update(&pipe_clip, &damaged_area, + &crtc_state->pipe_src); }
if (new_plane_state->uapi.visible) { damaged_area.y1 = new_plane_state->uapi.dst.y1; damaged_area.y2 = new_plane_state->uapi.dst.y2; - clip_area_update(&pipe_clip, &damaged_area); + clip_area_update(&pipe_clip, &damaged_area, + &crtc_state->pipe_src); } continue; } else if (new_plane_state->uapi.alpha != old_plane_state->uapi.alpha) { /* If alpha changed mark the whole plane area as damaged */ damaged_area.y1 = new_plane_state->uapi.dst.y1; damaged_area.y2 = new_plane_state->uapi.dst.y2; - clip_area_update(&pipe_clip, &damaged_area); + clip_area_update(&pipe_clip, &damaged_area, + &crtc_state->pipe_src); continue; }
@@ -1760,7 +1768,8 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, &new_plane_state->uapi); drm_atomic_for_each_plane_damage(&iter, &clip) { if (drm_rect_intersect(&clip, &src)) - clip_area_update(&damaged_area, &clip); + clip_area_update(&damaged_area, &clip, + &crtc_state->pipe_src); }
if (damaged_area.y1 == -1) @@ -1768,7 +1777,8 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state,
damaged_area.y1 += new_plane_state->uapi.dst.y1 - src.y1; damaged_area.y2 += new_plane_state->uapi.dst.y1 - src.y1; - clip_area_update(&pipe_clip, &damaged_area); + + clip_area_update(&pipe_clip, &damaged_area, &crtc_state->pipe_src); }
/*
On Tue, 2022-05-10 at 21:33 +0300, Jouni Högander wrote:
Current update area calculation is not handling situation where e.g. cursor plane is fully or partially outside pipe area.
Fix this by checking damage area against pipe_src area using drm_rect_intersect.
v2: Set x1 and x2 in damaged_area initialization v3: Move drm_rect_intersect into clip_area_update
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5440 Cc: José Roberto de Souza jose.souza@intel.com Cc: Mika Kahola mika.kahola@intel.com Cc: Mark Pearson markpearson@lenovo.com Signed-off-by: Jouni Högander jouni.hogander@intel.com
drivers/gpu/drm/i915/display/intel_psr.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_psr.c b/drivers/gpu/drm/i915/display/intel_psr.c index 3561c218cfb1..f4b4c1c83d2b 100644 --- a/drivers/gpu/drm/i915/display/intel_psr.c +++ b/drivers/gpu/drm/i915/display/intel_psr.c @@ -1618,8 +1618,12 @@ static void psr2_man_trk_ctl_calc(struct intel_crtc_state *crtc_state, }
static void clip_area_update(struct drm_rect *overlap_damage_area,
struct drm_rect *damage_area)
struct drm_rect *damage_area,
struct drm_rect *draw_area)
s/draw_area/pipe_src?
{
- if (!drm_rect_intersect(damage_area, draw_area))
return;
- if (overlap_damage_area->y1 == -1) { overlap_damage_area->y1 = damage_area->y1; overlap_damage_area->y2 = damage_area->y2;
@@ -1709,7 +1713,8 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, */ for_each_oldnew_intel_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
struct drm_rect src, damaged_area = { .y1 = -1 };
struct drm_rect src, damaged_area = { .x1 = 0, .y1 = -1,
struct drm_atomic_helper_damage_iter iter; struct drm_rect clip;.x2 = INT_MAX };
@@ -1736,20 +1741,23 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, if (old_plane_state->uapi.visible) { damaged_area.y1 = old_plane_state->uapi.dst.y1; damaged_area.y2 = old_plane_state->uapi.dst.y2;
clip_area_update(&pipe_clip, &damaged_area);
clip_area_update(&pipe_clip, &damaged_area,
&crtc_state->pipe_src); } if (new_plane_state->uapi.visible) { damaged_area.y1 = new_plane_state->uapi.dst.y1; damaged_area.y2 = new_plane_state->uapi.dst.y2;
clip_area_update(&pipe_clip, &damaged_area);
clip_area_update(&pipe_clip, &damaged_area,
} else if (new_plane_state->uapi.alpha != old_plane_state->uapi.alpha) { /* If alpha changed mark the whole plane area as damaged */ damaged_area.y1 = new_plane_state->uapi.dst.y1; damaged_area.y2 = new_plane_state->uapi.dst.y2;&crtc_state->pipe_src); } continue;
clip_area_update(&pipe_clip, &damaged_area);
clip_area_update(&pipe_clip, &damaged_area,
}&crtc_state->pipe_src); continue;
@@ -1760,7 +1768,8 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, &new_plane_state->uapi); drm_atomic_for_each_plane_damage(&iter, &clip) { if (drm_rect_intersect(&clip, &src))
clip_area_update(&damaged_area, &clip);
clip_area_update(&damaged_area, &clip,
&crtc_state->pipe_src);
}
if (damaged_area.y1 == -1)
@@ -1768,7 +1777,8 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state,
damaged_area.y1 += new_plane_state->uapi.dst.y1 - src.y1; damaged_area.y2 += new_plane_state->uapi.dst.y1 - src.y1;
clip_area_update(&pipe_clip, &damaged_area);
clip_area_update(&pipe_clip, &damaged_area, &crtc_state->pipe_src);
white space ^
with those nits: Reviewed-by: José Roberto de Souza jose.souza@intel.com
}
/*
dri-devel@lists.freedesktop.org