Skip to contentSkip to conversation

drm: Improve logic behind damage handling

PATCH Superseded Thomas Zimmermann 5 participants 29 messages May 30 – Jun 1

Subsystems (29)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH v4 1/10 drm/damage-helper: Do not alter damage clips on modeset, but ignore them

In reply to Thomas Zimmermann

User space supplies rectangles for damage clipping in a plane property. For full mode sets, drivers still require a full plane update. In this case, leave the information as-is and set the ignore_damage_clips flag instead. The damage iterator will later ignore any damage information.

Also fixes a bug where ignore_damage_clips was not cleared across plane- state duplications.

Leaving the damage information as-is might be helpful to drivers that benefit from this information even on full modesets (e.g., for cache management). It will also help with consolidating the damage-handling logic.

Also add a new unit test that evaluates the ignore_damage_clips flag. It sets two damage clips plus the flag and tests if the reported damage covers the entire framebuffer.

v4:
- slightly reword the commit description

Fixes 35ed38d58257 ("drm: Allow drivers to indicate the damage helpers to ignore damage clips")
Cc <[email protected]> # v6.10+
---
 drivers/gpu/drm/drm_atomic_state_helper.c     |  1 +
 drivers/gpu/drm/drm_damage_helper.c           |  6 ++--
 .../gpu/drm/tests/drm_damage_helper_test.c    | 28 +++++++++++++++++++
 3 files changed, 31 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_atomic_state_helper.c +1 -0
index cc70508d4fdb..84d5231ccac1 100644
@@ -359,6 +359,7 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
 	state->fence = NULL;
 	state->commit = NULL;
 	state->fb_damage_clips = NULL;
+	state->ignore_damage_clips = false;
 	state->color_mgmt_changed = false;
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
drivers/gpu/drm/drm_damage_helper.c +2 -4
index 74a7f4252ecf..945fac8dc27b 100644
@@ -78,10 +78,8 @@ void drm_atomic_helper_check_plane_damage(struct drm_atomic_commit *state,
 		if (WARN_ON(!crtc_state))
 			return;
 
-		if (drm_atomic_crtc_needs_modeset(crtc_state)) {
-			drm_property_blob_put(plane_state->fb_damage_clips);
-			plane_state->fb_damage_clips = NULL;
-		}
+		if (drm_atomic_crtc_needs_modeset(crtc_state))
+			plane_state->ignore_damage_clips = true;
 	}
 }
 EXPORT_SYMBOL(drm_atomic_helper_check_plane_damage);
drivers/gpu/drm/tests/drm_damage_helper_test.c +28 -0
index 0df2e1a54b0d..64f038a62ffe 100644
@@ -603,6 +603,33 @@ static void drm_test_damage_iter_damage_not_visible(struct kunit *test)
 	KUNIT_EXPECT_EQ_MSG(test, num_hits, 0, "Should not return any damage.");
 }
 
+static void drm_test_damage_iter_damage_ignore(struct kunit *test)
+{
+	struct drm_damage_mock *mock = test->priv;
+	struct drm_atomic_helper_damage_iter iter;
+	struct drm_property_blob damage_blob;
+	struct drm_mode_rect damage[2];
+	struct drm_rect clip;
+	u32 num_hits = 0;
+
+	set_plane_src(&mock->old_state, 0, 0, 1024 << 16, 768 << 16);
+	set_plane_src(&mock->state, 0, 0, 1024 << 16, 768 << 16);
+	/* 2 damage clips, but ignore them. */
+	set_damage_clip(&damage[0], 20, 30, 200, 180);
+	set_damage_clip(&damage[1], 240, 200, 280, 250);
+	set_damage_blob(&damage_blob, &damage[0], sizeof(damage));
+	set_plane_damage(&mock->state, &damage_blob);
+	mock->state.ignore_damage_clips = true;
+	drm_atomic_helper_damage_iter_init(&iter, &mock->old_state, &mock->state);
+	drm_atomic_for_each_plane_damage(&iter, &clip) {
+		if (num_hits == 0)
+			check_damage_clip(test, &clip, 0, 0, 1024, 768);
+		num_hits++;
+	}
+
+	KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return full-framebuffer damage.");
+}
+
 static struct kunit_case drm_damage_helper_tests[] = {
 	KUNIT_CASE(drm_test_damage_iter_no_damage),
 	KUNIT_CASE(drm_test_damage_iter_no_damage_fractional_src),
@@ -625,6 +652,7 @@ static struct kunit_case drm_damage_helper_tests[] = {
 	KUNIT_CASE(drm_test_damage_iter_damage_one_outside),
 	KUNIT_CASE(drm_test_damage_iter_damage_src_moved),
 	KUNIT_CASE(drm_test_damage_iter_damage_not_visible),
+	KUNIT_CASE(drm_test_damage_iter_damage_ignore),
 	{ }
 };
 
Signature · 1 line
2.54.0
author maintainer
#4 lore raw

PATCH v4 2/10 drm/atomic-helpers: Evaluate plane damage after atomic_check

In reply to Thomas Zimmermann

Each plane's and CRTC's atomic_check might trigger a full modeset. As this affects the plane's damage handling, evaluate damage clips after running the atomic_check helpers.

Examples can be found in a number of drivers, such as ast, gud, ingenic, mgag200 or vmwgfx, which all set mode_changed in the CRTC state to true. Ingenic even re-evaluates damage information in its plane's atomic_check. Doing this after the atomic_check helpers ran benefits all drivers.

There's already a damage evaluation before the calls to atomic_check. With a few fixes to drivers, this can be removed.

---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +4 -0
index 51f39edc31ed..4c37299e8ccb 100644
@@ -1065,6 +1065,10 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 		}
 	}
 
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+		drm_atomic_helper_check_plane_damage(state, new_plane_state);
+	}
+
 	return ret;
 }
 EXPORT_SYMBOL(drm_atomic_helper_check_planes);
Signature · 1 line
2.54.0

Thomas Zimmermann

author maintainer
#0 lore raw

v4 cover drm: Improve logic behind damage handling

DRM clients can supply information on framebuffer areas to update as part of each page flip, called damage clipping rectangles. But DRM's processing of this information is inconsistent and prone to errors.

- There are multiple fields and tests that decide if damage clips should be taken or ignored.

- Sometimes damage clips are removed behind the back of the DRM client.

- Atomic helpers evaluate damage clipping in the middle of the atomic
check: after connectors and encoders, but before planes and CRTCs. Hence pipeline stages have an inconsistent view.

- Which leads to drivers (ingenic) doing a re-evaluation if necessary.

- Tests of plane source coordinates only happen during commits. At this point, the driver should already know if damage clips are to be taken or not. Because of this, some drivers (appletbdrm) might operate on incorrect damage information for their internal workings. This also leads to excessive use of the old plane state.

Therefore go through DRM helpers and drivers and fix the logic.

- Run all of the atomic checks with the damage information supplied by DRM clients. Afterwards evaluate plane and CRTC states on whether to take or ignore damage clips. Do all related tests in a single atomic helper.

- Do not discard damage clips. Set ignore_damage_clips in struct drm_plane_state instead. This includes changes to plane source-coordinates. The damage iterator now only has to look at this flag to detect if it should use the damage clips.

- Go over drivers and fix the damage handling in the plane's atomic_update helpers. Most drivers no longer need the old plane state in their update.

- The appletbdrm driver requires a fix in how it uses damage information. Ingenic and vmwgfx can be simplified. These changes improve the drivers' code organization.

- Kunit tests require some changes. Drop some obsolete tests and add a new one for ignore_damage_flags.

Tested with bochs, mgag200, Kunit tests.

v4:
- reorder patches to avoid error-prone intermediate state v3:
- fix error path in appletbdrm
v2:
- rebase on latest upstream

Thomas Zimmermann (10):
drm/damage-helper: Do not alter damage clips on modeset, but ignore
them
drm/atomic-helpers: Evaluate plane damage after atomic_check drm/ingenic: Remove calls to drm_atomic_helper_check_plane_damage() drm/appletbdrm: Allocate request/response buffers in begin_fb_access drm/atomic_helper: Do not evaluate plane damage before atomic_check drm/damage-helper: Test src coord in
drm_atomic_helper_check_plane_damage()
drm/damage-helper: Remove old state from
drm_atomic_helper_damage_iter_init()
drm/damage-helper: Remove old state from
drm_atomic_helper_damage_merged()
drm/damage-helper: Rename state parameters in damage helpers drm/vmwgfx: Remove unused field struct
vmwgfx_du_update_plane.old_state

 drivers/gpu/drm/ast/ast_cursor.c              |   3 +-
 drivers/gpu/drm/ast/ast_mode.c                |   2 +-
 drivers/gpu/drm/drm_atomic_helper.c           |   6 +-
 drivers/gpu/drm/drm_atomic_state_helper.c     |   1 +
 drivers/gpu/drm/drm_damage_helper.c           |  44 ++--
 drivers/gpu/drm/drm_fb_dma_helper.c           |   2 +-
 drivers/gpu/drm/drm_mipi_dbi.c                |   3 +-
 drivers/gpu/drm/gud/gud_pipe.c                |   3 +-
 drivers/gpu/drm/hyperv/hyperv_drm_modeset.c   |   3 +-
 drivers/gpu/drm/i915/display/intel_plane.c    |  11 +-
 drivers/gpu/drm/i915/display/intel_psr.c      |   3 +-
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c     |   3 -
 drivers/gpu/drm/ingenic/ingenic-ipu.c         |   8 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c        |   3 +-
 drivers/gpu/drm/sitronix/st7571.c             |   3 +-
 drivers/gpu/drm/sitronix/st7586.c             |   3 +-
 drivers/gpu/drm/sitronix/st7920.c             |   3 +-
 drivers/gpu/drm/solomon/ssd130x.c             |   9 +-
 drivers/gpu/drm/sysfb/drm_sysfb_modeset.c     |   3 +-
 .../gpu/drm/tests/drm_damage_helper_test.c    | 200 +++---------------
 drivers/gpu/drm/tiny/appletbdrm.c             |  59 +++---
 drivers/gpu/drm/tiny/bochs.c                  |   3 +-
 drivers/gpu/drm/tiny/cirrus-qemu.c            |   2 +-
 drivers/gpu/drm/tiny/gm12u320.c               |   2 +-
 drivers/gpu/drm/tiny/ili9225.c                |   3 +-
 drivers/gpu/drm/tiny/repaper.c                |   2 +-
 drivers/gpu/drm/tiny/sharp-memory.c           |   3 +-
 drivers/gpu/drm/udl/udl_modeset.c             |   3 +-
 drivers/gpu/drm/virtio/virtgpu_plane.c        |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c           |   5 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h           |   2 -
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c          |  12 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c          |  15 +-
 include/drm/drm_damage_helper.h               |   9 +-
 34 files changed, 123 insertions(+), 315 deletions(-)

base-commit: 4f554688dffcacf48630c14f9fb77a9f60394c1c

Signature · 1 line
2.54.0
author maintainer
#10 lore raw

PATCH v4 4/10 drm/appletbdrm: Allocate request/response buffers in begin_fb_access

In atomic_check, damage handling is not fully evaluated. Another atomic_check helper could trigger a full modeset and thus invalidate damage clips.

Allocation of the request/response buffers in appletbdrm depends on correct damage information. Otherwise it might allocate incorrectly sized buffers. Allocate the buffers in the driver's begin_fb_access helper. It runs early during the commit when damage clipping has been fully evaluated.

v2:
- allocate before drm_gem_begin_shadow_fb_access() to avoid leak on error

---
 drivers/gpu/drm/tiny/appletbdrm.c | 53 +++++++++++++++++--------------
 1 file changed, 30 insertions(+), 23 deletions(-)
drivers/gpu/drm/tiny/appletbdrm.c +30 -23
index cdd35af49892..b683dcb35b0b 100644
@@ -315,33 +315,16 @@ static const u32 appletbdrm_primary_plane_formats[] = {
 	DRM_FORMAT_XRGB8888, /* emulated */
 };
 
-static int appletbdrm_primary_plane_helper_atomic_check(struct drm_plane *plane,
-						   struct drm_atomic_commit *state)
+static int appletbdrm_primary_plane_helper_begin_fb_access(struct drm_plane *plane,
+							   struct drm_plane_state *new_plane_state)
 {
-	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
-	struct drm_crtc *new_crtc = new_plane_state->crtc;
-	struct drm_crtc_state *new_crtc_state = NULL;
 	struct appletbdrm_plane_state *appletbdrm_state = to_appletbdrm_plane_state(new_plane_state);
+	size_t frames_size = 0;
 	struct drm_atomic_helper_damage_iter iter;
 	struct drm_rect damage;
-	size_t frames_size = 0;
 	size_t request_size;
-	int ret;
-
-	if (new_crtc)
-		new_crtc_state = drm_atomic_get_new_crtc_state(state, new_crtc);
 
-	ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state,
-						  DRM_PLANE_NO_SCALING,
-						  DRM_PLANE_NO_SCALING,
-						  false, false);
-	if (ret)
-		return ret;
-	else if (!new_plane_state->visible)
-		return 0;
-
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, new_plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, NULL, new_plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		frames_size += struct_size((struct appletbdrm_frame *)0, buf, rect_size(&damage));
 	}
@@ -366,6 +349,29 @@ static int appletbdrm_primary_plane_helper_atomic_check(struct drm_plane *plane,
 	appletbdrm_state->request_size = request_size;
 	appletbdrm_state->frames_size = frames_size;
 
+	return drm_gem_begin_shadow_fb_access(plane, new_plane_state);
+}
+
+static int appletbdrm_primary_plane_helper_atomic_check(struct drm_plane *plane,
+							struct drm_atomic_commit *state)
+{
+	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
+	struct drm_crtc *new_crtc = new_plane_state->crtc;
+	struct drm_crtc_state *new_crtc_state = NULL;
+	int ret;
+
+	if (new_crtc)
+		new_crtc_state = drm_atomic_get_new_crtc_state(state, new_crtc);
+
+	ret = drm_atomic_helper_check_plane_state(new_plane_state, new_crtc_state,
+						  DRM_PLANE_NO_SCALING,
+						  DRM_PLANE_NO_SCALING,
+						  false, false);
+	if (ret)
+		return ret;
+	else if (!new_plane_state->visible)
+		return 0;
+
 	return 0;
 }
 
@@ -468,7 +474,7 @@ static int appletbdrm_flush_damage(struct appletbdrm_device *adev,
 }
 
 static void appletbdrm_primary_plane_helper_atomic_update(struct drm_plane *plane,
-						     struct drm_atomic_commit *old_state)
+							  struct drm_atomic_commit *old_state)
 {
 	struct appletbdrm_device *adev = drm_to_adev(plane->dev);
 	struct drm_device *drm = plane->dev;
@@ -552,7 +558,8 @@ static void appletbdrm_primary_plane_destroy_state(struct drm_plane *plane,
 }
 
 static const struct drm_plane_helper_funcs appletbdrm_primary_plane_helper_funcs = {
-	DRM_GEM_SHADOW_PLANE_HELPER_FUNCS,
+	.begin_fb_access = appletbdrm_primary_plane_helper_begin_fb_access,
+	.end_fb_access = drm_gem_end_shadow_fb_access,
 	.atomic_check = appletbdrm_primary_plane_helper_atomic_check,
 	.atomic_update = appletbdrm_primary_plane_helper_atomic_update,
 	.atomic_disable = appletbdrm_primary_plane_helper_atomic_disable,
Signature · 1 line
2.54.0
author maintainer
#7 lore raw

PATCH v4 3/10 drm/ingenic: Remove calls to drm_atomic_helper_check_plane_damage()

In reply to Thomas Zimmermann

Atomic helpers call drm_atomic_helper_check_plane_damage() after the atomic_check anyway. See atomic_helper_check_planes(). Remove the calls from the planes' atomic_check.

---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 3 ---
 drivers/gpu/drm/ingenic/ingenic-ipu.c     | 8 ++------
 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0 -3
index 42c86f195c66..e99b44e3ac92 100644
@@ -519,9 +519,6 @@ static int ingenic_drm_plane_atomic_check(struct drm_plane *plane,
 	     old_plane_state->fb->format->format != new_plane_state->fb->format->format))
 		crtc_state->mode_changed = true;
 
-	if (priv->soc_info->map_noncoherent)
-		drm_atomic_helper_check_plane_damage(state, new_plane_state);
-
 	return 0;
 }
 
drivers/gpu/drm/ingenic/ingenic-ipu.c +2 -6
index 56143a191f36..fd17c642c7ac 100644
@@ -594,7 +594,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
 
 	if (!new_plane_state->crtc ||
 	    !crtc_state->mode.hdisplay || !crtc_state->mode.vdisplay)
-		goto out_check_damage;
+		return 0;
 
 	/* Plane must be fully visible */
 	if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0 ||
@@ -611,7 +611,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 
 	if (!osd_changed(new_plane_state, old_plane_state))
-		goto out_check_damage;
+		return 0;
 
 	crtc_state->mode_changed = true;
 
@@ -645,10 +645,6 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
 	ipu_state->denom_w = denom_w;
 	ipu_state->denom_h = denom_h;
 
-out_check_damage:
-	if (ingenic_drm_map_noncoherent(ipu->master))
-		drm_atomic_helper_check_plane_damage(state, new_plane_state);
-
 	return 0;
 }
 
Signature · 1 line
2.54.0
author maintainer
#13 lore raw

PATCH v4 5/10 drm/atomic_helper: Do not evaluate plane damage before atomic_check

In reply to Thomas Zimmermann

Remove the call to drm_atomic_helper_check_plane_damage() from before calling the atomic_check helpers. The call has no longer any purpose, as the actual evaluation happens after running atomic_check.

---
 drivers/gpu/drm/drm_atomic_helper.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -2
index 4c37299e8ccb..37eb6cbbf3ea 100644
@@ -1034,8 +1034,6 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 
 		drm_atomic_helper_plane_changed(state, old_plane_state, new_plane_state, plane);
 
-		drm_atomic_helper_check_plane_damage(state, new_plane_state);
-
 		if (!funcs || !funcs->atomic_check)
 			continue;
 
Signature · 1 line
2.54.0
author maintainer
#18 lore raw

PATCH v4 7/10 drm/damage-helper: Remove old state from drm_atomic_helper_damage_iter_init()

In reply to Thomas Zimmermann

Nothing in drm_atomic_helper_damage_iter_init() requires the old plane state. Remove the parameter and mass-convert callers.

Most callers now no longer require the old plane state in their plane's atomic_update helper. Remove it as well.

---
 drivers/gpu/drm/ast/ast_mode.c                |  2 +-
 drivers/gpu/drm/drm_damage_helper.c           |  4 +-
 drivers/gpu/drm/drm_fb_dma_helper.c           |  2 +-
 drivers/gpu/drm/gud/gud_pipe.c                |  3 +-
 drivers/gpu/drm/hyperv/hyperv_drm_modeset.c   |  3 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c        |  3 +-
 drivers/gpu/drm/sitronix/st7571.c             |  3 +-
 drivers/gpu/drm/sitronix/st7920.c             |  3 +-
 drivers/gpu/drm/solomon/ssd130x.c             |  9 +--
 drivers/gpu/drm/sysfb/drm_sysfb_modeset.c     |  3 +-
 .../gpu/drm/tests/drm_damage_helper_test.c    | 55 ++++++-------------
 drivers/gpu/drm/tiny/appletbdrm.c             |  8 +--
 drivers/gpu/drm/tiny/bochs.c                  |  3 +-
 drivers/gpu/drm/tiny/cirrus-qemu.c            |  2 +-
 drivers/gpu/drm/udl/udl_modeset.c             |  3 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c           |  5 +-
 include/drm/drm_damage_helper.h               |  3 +-
 17 files changed, 37 insertions(+), 77 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +1 -1
index d5ed8c5c7925..6fe3fda6d145 100644
@@ -579,7 +579,7 @@ static void ast_primary_plane_helper_atomic_update(struct drm_plane *plane,
 
 	/* if the buffer comes from another device */
 	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE) == 0) {
-		drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+		drm_atomic_helper_damage_iter_init(&iter, plane_state);
 		drm_atomic_for_each_plane_damage(&iter, &damage) {
 			ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage,
 					  &shadow_plane_state->fmtcnv_state);
drivers/gpu/drm/drm_damage_helper.c +1 -3
index f492a59edbeb..28f26234523d 100644
@@ -209,7 +209,6 @@ EXPORT_SYMBOL(drm_atomic_helper_dirtyfb);
 /**
  * drm_atomic_helper_damage_iter_init - Initialize the damage iterator.
  * @iter: The iterator to initialize.
- * @old_state: Unused, pass NULL.
  * @state: Plane state from which to iterate the damage clips.
  *
  * Initialize an iterator, which clips plane damage
@@ -226,7 +225,6 @@ EXPORT_SYMBOL(drm_atomic_helper_dirtyfb);
  */
 void
 drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,
-				   const struct drm_plane_state *old_state,
 				   const struct drm_plane_state *state)
 {
 	struct drm_rect src;
@@ -324,7 +322,7 @@ bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state,
 	rect->x2 = 0;
 	rect->y2 = 0;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_state, state);
+	drm_atomic_helper_damage_iter_init(&iter, state);
 	drm_atomic_for_each_plane_damage(&iter, &clip) {
 		rect->x1 = min(rect->x1, clip.x1);
 		rect->y1 = min(rect->y1, clip.y1);
drivers/gpu/drm/drm_fb_dma_helper.c +1 -1
index fd71969d2fb1..bbad16d32b6f 100644
@@ -138,7 +138,7 @@ void drm_fb_dma_sync_non_coherent(struct drm_device *drm,
 			continue;
 
 		daddr = drm_fb_dma_get_gem_addr(state->fb, state, i);
-		drm_atomic_helper_damage_iter_init(&iter, old_state, state);
+		drm_atomic_helper_damage_iter_init(&iter, state);
 
 		drm_atomic_for_each_plane_damage(&iter, &clip) {
 			/* Ignore x1/x2 values, invalidate complete lines */
drivers/gpu/drm/gud/gud_pipe.c +1 -2
index 5ef887d8485a..758990cd78aa 100644
@@ -618,7 +618,6 @@ void gud_plane_atomic_update(struct drm_plane *plane,
 {
 	struct drm_device *drm = plane->dev;
 	struct gud_device *gdrm = to_gud_device(drm);
-	struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(atomic_state, plane);
 	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(atomic_state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(new_state);
 	struct drm_framebuffer *fb = new_state->fb;
@@ -647,7 +646,7 @@ void gud_plane_atomic_update(struct drm_plane *plane,
 	if (ret)
 		goto out;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_state, new_state);
+	drm_atomic_helper_damage_iter_init(&iter, new_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage)
 		gud_fb_handle_damage(gdrm, fb, &shadow_plane_state->data[0], &damage);
 
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +1 -2
index 1bbb7de5ab49..9f74365c4d7e 100644
@@ -171,14 +171,13 @@ static void hyperv_plane_atomic_update(struct drm_plane *plane,
 				       struct drm_atomic_commit *state)
 {
 	struct hyperv_drm_device *hv = to_hv(plane->dev);
-	struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(new_state);
 	struct drm_rect damage;
 	struct drm_rect dst_clip;
 	struct drm_atomic_helper_damage_iter iter;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_state, new_state);
+	drm_atomic_helper_damage_iter_init(&iter, new_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		dst_clip = new_state->dst;
 
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -2
index 7e07fc3f1a60..ea121428adf2 100644
@@ -503,14 +503,13 @@ void mgag200_primary_plane_helper_atomic_update(struct drm_plane *plane,
 	struct drm_device *dev = plane->dev;
 	struct mga_device *mdev = to_mga_device(dev);
 	struct drm_plane_state *plane_state = plane->state;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(old_state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_framebuffer *fb = plane_state->fb;
 	struct drm_atomic_helper_damage_iter iter;
 	struct drm_rect damage;
 
 	mgag200_set_datasiz(mdev, fb->format->format);
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		mgag200_handle_damage(mdev, shadow_plane_state->data, fb, &damage);
 	}
drivers/gpu/drm/sitronix/st7571.c +1 -2
index 20954c33eca9..bc0e59c2600c 100644
@@ -342,7 +342,6 @@ static int st7571_primary_plane_helper_atomic_check(struct drm_plane *plane,
 static void st7571_primary_plane_helper_atomic_update(struct drm_plane *plane,
 						      struct drm_atomic_commit *state)
 {
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_framebuffer *fb = plane_state->fb;
@@ -362,7 +361,7 @@ static void st7571_primary_plane_helper_atomic_update(struct drm_plane *plane,
 	if (!drm_dev_enter(drm, &idx))
 		goto out_drm_gem_fb_end_cpu_access;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		st7571->pformat->prepare_buffer(st7571,
 						&shadow_plane_state->data[0],
drivers/gpu/drm/sitronix/st7920.c +1 -2
index d320391801f3..7ee45a2b2d3e 100644
@@ -390,7 +390,6 @@ static void st7920_primary_plane_atomic_update(struct drm_plane *plane,
 					       struct drm_atomic_commit *state)
 {
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, plane_state->crtc);
 	struct st7920_crtc_state *st7920_crtc_state =  to_st7920_crtc_state(crtc_state);
@@ -407,7 +406,7 @@ static void st7920_primary_plane_atomic_update(struct drm_plane *plane,
 		return;
 
 	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE) == 0) {
-		drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+		drm_atomic_helper_damage_iter_init(&iter, plane_state);
 		drm_atomic_for_each_plane_damage(&iter, &damage) {
 			dst_clip = plane_state->dst;
 
drivers/gpu/drm/solomon/ssd130x.c +3 -6
index cae92a3ae8a4..4b55532da31b 100644
@@ -1198,7 +1198,6 @@ static void ssd130x_primary_plane_atomic_update(struct drm_plane *plane,
 						struct drm_atomic_commit *state)
 {
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, plane_state->crtc);
 	struct ssd130x_crtc_state *ssd130x_crtc_state =  to_ssd130x_crtc_state(crtc_state);
@@ -1216,7 +1215,7 @@ static void ssd130x_primary_plane_atomic_update(struct drm_plane *plane,
 	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE))
 		goto out_drm_dev_exit;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		dst_clip = plane_state->dst;
 
@@ -1239,7 +1238,6 @@ static void ssd132x_primary_plane_atomic_update(struct drm_plane *plane,
 						struct drm_atomic_commit *state)
 {
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, plane_state->crtc);
 	struct ssd130x_crtc_state *ssd130x_crtc_state =  to_ssd130x_crtc_state(crtc_state);
@@ -1257,7 +1255,7 @@ static void ssd132x_primary_plane_atomic_update(struct drm_plane *plane,
 	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE))
 		goto out_drm_dev_exit;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		dst_clip = plane_state->dst;
 
@@ -1280,7 +1278,6 @@ static void ssd133x_primary_plane_atomic_update(struct drm_plane *plane,
 						struct drm_atomic_commit *state)
 {
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, plane_state->crtc);
 	struct ssd130x_crtc_state *ssd130x_crtc_state =  to_ssd130x_crtc_state(crtc_state);
@@ -1297,7 +1294,7 @@ static void ssd133x_primary_plane_atomic_update(struct drm_plane *plane,
 	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE))
 		goto out_drm_dev_exit;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		dst_clip = plane_state->dst;
 
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +1 -2
index d2de29caf89e..9f1ae5ca9a11 100644
@@ -331,7 +331,6 @@ void drm_sysfb_plane_helper_atomic_update(struct drm_plane *plane, struct drm_at
 	struct drm_device *dev = plane->dev;
 	struct drm_sysfb_device *sysfb = to_drm_sysfb_device(dev);
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_sysfb_plane_state *sysfb_plane_state = to_drm_sysfb_plane_state(plane_state);
 	struct drm_shadow_plane_state *shadow_plane_state = &sysfb_plane_state->base;
 	struct drm_framebuffer *fb = plane_state->fb;
@@ -351,7 +350,7 @@ void drm_sysfb_plane_helper_atomic_update(struct drm_plane *plane, struct drm_at
 	if (!drm_dev_enter(dev, &idx))
 		goto out_drm_gem_fb_end_cpu_access;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		struct iosys_map dst = sysfb->fb_addr;
 		struct drm_rect dst_clip = plane_state->dst;
drivers/gpu/drm/tests/drm_damage_helper_test.c +16 -39

229 lines not on this page · raw message

drivers/gpu/drm/tiny/appletbdrm.c +3 -5
index b683dcb35b0b..eadc3aed7277 100644
@@ -324,7 +324,7 @@ static int appletbdrm_primary_plane_helper_begin_fb_access(struct drm_plane *pla
 	struct drm_rect damage;
 	size_t request_size;
 
-	drm_atomic_helper_damage_iter_init(&iter, NULL, new_plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, new_plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		frames_size += struct_size((struct appletbdrm_frame *)0, buf, rect_size(&damage));
 	}
@@ -376,7 +376,6 @@ static int appletbdrm_primary_plane_helper_atomic_check(struct drm_plane *plane,
 }
 
 static int appletbdrm_flush_damage(struct appletbdrm_device *adev,
-				   struct drm_plane_state *old_state,
 				   struct drm_plane_state *state)
 {
 	struct appletbdrm_plane_state *appletbdrm_state = to_appletbdrm_plane_state(state);
@@ -412,7 +411,7 @@ static int appletbdrm_flush_damage(struct appletbdrm_device *adev,
 
 	frame = (struct appletbdrm_frame *)request->data;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_state, state);
+	drm_atomic_helper_damage_iter_init(&iter, state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		struct drm_rect dst_clip = state->dst;
 		struct iosys_map dst = IOSYS_MAP_INIT_VADDR(frame->buf);
@@ -479,13 +478,12 @@ static void appletbdrm_primary_plane_helper_atomic_update(struct drm_plane *plan
 	struct appletbdrm_device *adev = drm_to_adev(plane->dev);
 	struct drm_device *drm = plane->dev;
 	struct drm_plane_state *plane_state = plane->state;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(old_state, plane);
 	int idx;
 
 	if (!drm_dev_enter(drm, &idx))
 		return;
 
-	appletbdrm_flush_damage(adev, old_plane_state, plane_state);
+	appletbdrm_flush_damage(adev, plane_state);
 
 	drm_dev_exit(idx);
 }
drivers/gpu/drm/tiny/bochs.c +1 -2
index e2d957e51505..1e19e98694c0 100644
@@ -447,7 +447,6 @@ static void bochs_primary_plane_helper_atomic_update(struct drm_plane *plane,
 	struct drm_device *dev = plane->dev;
 	struct bochs_device *bochs = to_bochs_device(dev);
 	struct drm_plane_state *plane_state = plane->state;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_framebuffer *fb = plane_state->fb;
 	struct drm_atomic_helper_damage_iter iter;
@@ -456,7 +455,7 @@ static void bochs_primary_plane_helper_atomic_update(struct drm_plane *plane,
 	if (!fb || !bochs->stride)
 		return;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		struct iosys_map dst = IOSYS_MAP_INIT_VADDR_IOMEM(bochs->fb_map);
 
drivers/gpu/drm/tiny/cirrus-qemu.c +1 -1
index 075221b431d3..44ffce563e51 100644
@@ -350,7 +350,7 @@ static void cirrus_primary_plane_helper_atomic_update(struct drm_plane *plane,
 	if (!old_fb || old_fb->pitches[0] != fb->pitches[0])
 		cirrus_pitch_set(cirrus, fb->pitches[0]);
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		unsigned int offset = drm_fb_clip_offset(fb->pitches[0], fb->format, &damage);
 		struct iosys_map dst = IOSYS_MAP_INIT_OFFSET(&vaddr, offset);
drivers/gpu/drm/udl/udl_modeset.c +1 -2
index 289711035b67..ac981ffca5d9 100644
@@ -286,7 +286,6 @@ static void udl_primary_plane_helper_atomic_update(struct drm_plane *plane,
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_framebuffer *fb = plane_state->fb;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_atomic_helper_damage_iter iter;
 	struct drm_rect damage;
 	int ret, idx;
@@ -301,7 +300,7 @@ static void udl_primary_plane_helper_atomic_update(struct drm_plane *plane,
 	if (!drm_dev_enter(dev, &idx))
 		goto out_drm_gem_fb_end_cpu_access;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		udl_handle_damage(fb, &shadow_plane_state->data[0], &damage);
 	}
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2 -3
index 1b407b61f683..32617eb9538e 100644
@@ -1733,7 +1733,6 @@ void vmw_kms_lost_device(struct drm_device *dev)
 int vmw_du_helper_plane_update(struct vmw_du_update_plane *update)
 {
 	struct drm_plane_state *state = update->plane->state;
-	struct drm_plane_state *old_state = update->old_state;
 	struct drm_atomic_helper_damage_iter iter;
 	struct drm_rect clip;
 	struct drm_rect bb;
@@ -1750,7 +1749,7 @@ int vmw_du_helper_plane_update(struct vmw_du_update_plane *update)
 	 * Iterate in advance to check if really need plane update and find the
 	 * number of clips that actually are in plane src for fifo allocation.
 	 */
-	drm_atomic_helper_damage_iter_init(&iter, old_state, state);
+	drm_atomic_helper_damage_iter_init(&iter, state);
 	drm_atomic_for_each_plane_damage(&iter, &clip)
 		num_hits++;
 
@@ -1818,7 +1817,7 @@ int vmw_du_helper_plane_update(struct vmw_du_update_plane *update)
 	bb.x2 = INT_MIN;
 	bb.y2 = INT_MIN;
 
-	drm_atomic_helper_damage_iter_init(&iter, old_state, state);
+	drm_atomic_helper_damage_iter_init(&iter, state);
 	drm_atomic_for_each_plane_damage(&iter, &clip) {
 		uint32_t fb_x = clip.x1;
 		uint32_t fb_y = clip.y1;
include/drm/drm_damage_helper.h +1 -2
index e93eaa0fbcb6..fafe29b50fc6 100644
@@ -73,8 +73,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
 			      unsigned int num_clips);
 void
 drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,
-				   const struct drm_plane_state *old_state,
-				   const struct drm_plane_state *new_state);
+				   const struct drm_plane_state *state);
 bool
 drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter,
 				   struct drm_rect *rect);
Signature · 1 line
2.54.0
author maintainer
#15 lore raw

PATCH v4 6/10 drm/damage-helper: Test src coord in drm_atomic_helper_check_plane_damage()

In reply to Thomas Zimmermann

Planes require a full update if the source coordinates change across atomic commits. Evaluate this during the atomic-check and set the flag ignore_damage_clips in the plane state, if so. Remove the check from drm_atomic_helper_damage_iter_init().

This will help with removing the old state from the atomic-commit phase and simplify atomic_update helpers a bit.

Several unit tests check against the change of the src coordinate. Drop them as they do no longer serve a purpose. If the src coordinate changes across commits, atomic helpers will set the plane state's ignore_damage_clips flag, for which a separate unit test exists.

---
 drivers/gpu/drm/drm_atomic_helper.c           |   2 +-
 drivers/gpu/drm/drm_damage_helper.c           |  20 ++-
 .../gpu/drm/tests/drm_damage_helper_test.c    | 151 ------------------
 include/drm/drm_damage_helper.h               |   3 +-
 4 files changed, 15 insertions(+), 161 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +1 -1
index 37eb6cbbf3ea..57ffa8c8d641 100644
@@ -1064,7 +1064,7 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 	}
 
 	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
-		drm_atomic_helper_check_plane_damage(state, new_plane_state);
+		drm_atomic_helper_check_plane_damage(state, old_plane_state, new_plane_state);
 	}
 
 	return ret;
drivers/gpu/drm/drm_damage_helper.c +12 -8
index 945fac8dc27b..f492a59edbeb 100644
@@ -55,7 +55,8 @@ static void convert_clip_rect_to_rect(const struct drm_clip_rect *src,
 /**
  * drm_atomic_helper_check_plane_damage - Verify plane damage on atomic_check.
  * @state: The driver state object.
- * @plane_state: Plane state for which to verify damage.
+ * @old_plane_state: Old plane state to verify against.
+ * @new_plane_state: Plane state for which to verify damage.
  *
  * This helper function makes sure that damage from plane state is discarded
  * for full modeset. If there are more reasons a driver would want to do a full
@@ -67,19 +68,23 @@ static void convert_clip_rect_to_rect(const struct drm_clip_rect *src,
  * &drm_plane_state.src as damage.
  */
 void drm_atomic_helper_check_plane_damage(struct drm_atomic_commit *state,
-					  struct drm_plane_state *plane_state)
+					  const struct drm_plane_state *old_plane_state,
+					  struct drm_plane_state *new_plane_state)
 {
 	struct drm_crtc_state *crtc_state;
 
-	if (plane_state->crtc) {
+	if (!drm_rect_equals(&new_plane_state->src, &old_plane_state->src))
+		new_plane_state->ignore_damage_clips = true;
+
+	if (new_plane_state->crtc) {
 		crtc_state = drm_atomic_get_new_crtc_state(state,
-							   plane_state->crtc);
+							   new_plane_state->crtc);
 
 		if (WARN_ON(!crtc_state))
 			return;
 
 		if (drm_atomic_crtc_needs_modeset(crtc_state))
-			plane_state->ignore_damage_clips = true;
+			new_plane_state->ignore_damage_clips = true;
 	}
 }
 EXPORT_SYMBOL(drm_atomic_helper_check_plane_damage);
@@ -204,7 +209,7 @@ EXPORT_SYMBOL(drm_atomic_helper_dirtyfb);
 /**
  * drm_atomic_helper_damage_iter_init - Initialize the damage iterator.
  * @iter: The iterator to initialize.
- * @old_state: Old plane state for validation.
+ * @old_state: Unused, pass NULL.
  * @state: Plane state from which to iterate the damage clips.
  *
  * Initialize an iterator, which clips plane damage
@@ -241,8 +246,7 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,
 	iter->plane_src.x2 = (src.x2 >> 16) + !!(src.x2 & 0xFFFF);
 	iter->plane_src.y2 = (src.y2 >> 16) + !!(src.y2 & 0xFFFF);
 
-	if (!iter->clips || state->ignore_damage_clips ||
-	    !drm_rect_equals(&state->src, &old_state->src)) {
+	if (!iter->clips || state->ignore_damage_clips) {
 		iter->clips = NULL;
 		iter->num_clips = 0;
 		iter->full_update = true;
drivers/gpu/drm/tests/drm_damage_helper_test.c +0 -151

184 lines not on this page · raw message

include/drm/drm_damage_helper.h +2 -1
index 3661aeab2cd3..e93eaa0fbcb6 100644
@@ -65,7 +65,8 @@ struct drm_atomic_helper_damage_iter {
 };
 
 void drm_atomic_helper_check_plane_damage(struct drm_atomic_commit *state,
-					  struct drm_plane_state *plane_state);
+					  const struct drm_plane_state *old_plane_state,
+					  struct drm_plane_state *new_plane_state);
 int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
 			      struct drm_file *file_priv, unsigned int flags,
 			      unsigned int color, struct drm_clip_rect *clips,
Signature · 1 line
2.54.0
author maintainer
#24 lore raw

PATCH v4 9/10 drm/damage-helper: Rename state parameters in damage helpers

In reply to Thomas Zimmermann

Rename some of the state parameters of the damage-helper functions to align them with each other and other helpers. No functional changes.

---
 drivers/gpu/drm/drm_damage_helper.c | 20 ++++++++++----------
 include/drm/drm_damage_helper.h     |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/drm_damage_helper.c +10 -10
index 28b847636253..23701e5c51b7 100644
@@ -209,7 +209,7 @@ EXPORT_SYMBOL(drm_atomic_helper_dirtyfb);
 /**
  * drm_atomic_helper_damage_iter_init - Initialize the damage iterator.
  * @iter: The iterator to initialize.
- * @state: Plane state from which to iterate the damage clips.
+ * @plane_state: Plane state from which to iterate the damage clips.
  *
  * Initialize an iterator, which clips plane damage
  * &drm_plane_state.fb_damage_clips to plane &drm_plane_state.src. This iterator
@@ -225,26 +225,26 @@ EXPORT_SYMBOL(drm_atomic_helper_dirtyfb);
  */
 void
 drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,
-				   const struct drm_plane_state *state)
+				   const struct drm_plane_state *plane_state)
 {
 	struct drm_rect src;
 	memset(iter, 0, sizeof(*iter));
 
-	if (!state || !state->crtc || !state->fb || !state->visible)
+	if (!plane_state || !plane_state->crtc || !plane_state->fb || !plane_state->visible)
 		return;
 
-	iter->clips = (struct drm_rect *)drm_plane_get_damage_clips(state);
-	iter->num_clips = drm_plane_get_damage_clips_count(state);
+	iter->clips = (struct drm_rect *)drm_plane_get_damage_clips(plane_state);
+	iter->num_clips = drm_plane_get_damage_clips_count(plane_state);
 
 	/* Round down for x1/y1 and round up for x2/y2 to catch all pixels */
-	src = drm_plane_state_src(state);
+	src = drm_plane_state_src(plane_state);
 
 	iter->plane_src.x1 = src.x1 >> 16;
 	iter->plane_src.y1 = src.y1 >> 16;
 	iter->plane_src.x2 = (src.x2 >> 16) + !!(src.x2 & 0xFFFF);
 	iter->plane_src.y2 = (src.y2 >> 16) + !!(src.y2 & 0xFFFF);
 
-	if (!iter->clips || state->ignore_damage_clips) {
+	if (!iter->clips || plane_state->ignore_damage_clips) {
 		iter->clips = NULL;
 		iter->num_clips = 0;
 		iter->full_update = true;
@@ -296,7 +296,7 @@ EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next);
 
 /**
  * drm_atomic_helper_damage_merged - Merged plane damage
- * @state: Plane state from which to iterate the damage clips.
+ * @plane_state: Plane state from which to iterate the damage clips.
  * @rect: Returns the merged damage rectangle
  *
  * This function merges any valid plane damage clips into one rectangle and
@@ -308,7 +308,7 @@ EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next);
  * Returns:
  * True if there is valid plane damage otherwise false.
  */
-bool drm_atomic_helper_damage_merged(const struct drm_plane_state *state,
+bool drm_atomic_helper_damage_merged(const struct drm_plane_state *plane_state,
 				     struct drm_rect *rect)
 {
 	struct drm_atomic_helper_damage_iter iter;
@@ -320,7 +320,7 @@ bool drm_atomic_helper_damage_merged(const struct drm_plane_state *state,
 	rect->x2 = 0;
 	rect->y2 = 0;
 
-	drm_atomic_helper_damage_iter_init(&iter, state);
+	drm_atomic_helper_damage_iter_init(&iter, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &clip) {
 		rect->x1 = min(rect->x1, clip.x1);
 		rect->y1 = min(rect->y1, clip.y1);
include/drm/drm_damage_helper.h +2 -2
index b5a4de779db6..4a1ac47b9051 100644
@@ -73,11 +73,11 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
 			      unsigned int num_clips);
 void
 drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,
-				   const struct drm_plane_state *state);
+				   const struct drm_plane_state *plane_state);
 bool
 drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter,
 				   struct drm_rect *rect);
-bool drm_atomic_helper_damage_merged(const struct drm_plane_state *state,
+bool drm_atomic_helper_damage_merged(const struct drm_plane_state *plane_state,
 				     struct drm_rect *rect);
 
 #endif
Signature · 1 line
2.54.0
author maintainer
#21 lore raw

PATCH v4 8/10 drm/damage-helper: Remove old state from drm_atomic_helper_damage_merged()

In reply to Thomas Zimmermann

Nothing in drm_atomic_helper_damage_merged() requires the old plane state. Remove the parameter and mass-convert callers.

Most callers now no longer require the old plane state in their plane's atomic_update helper. Remove it as well.

---
 drivers/gpu/drm/ast/ast_cursor.c           |  3 +--
 drivers/gpu/drm/drm_damage_helper.c        |  4 +---
 drivers/gpu/drm/drm_mipi_dbi.c             |  3 +--
 drivers/gpu/drm/i915/display/intel_plane.c | 11 ++---------
 drivers/gpu/drm/i915/display/intel_psr.c   |  3 +--
 drivers/gpu/drm/sitronix/st7586.c          |  3 +--
 drivers/gpu/drm/tiny/gm12u320.c            |  2 +-
 drivers/gpu/drm/tiny/ili9225.c             |  3 +--
 drivers/gpu/drm/tiny/repaper.c             |  2 +-
 drivers/gpu/drm/tiny/sharp-memory.c        |  3 +--
 drivers/gpu/drm/virtio/virtgpu_plane.c     |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c       |  4 +---
 include/drm/drm_damage_helper.h            |  3 +--
 13 files changed, 14 insertions(+), 32 deletions(-)
drivers/gpu/drm/ast/ast_cursor.c +1 -2
index fd19c45f2abe..12d5f93eec5f 100644
@@ -251,7 +251,6 @@ static void ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
 	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_framebuffer *fb = plane_state->fb;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct ast_device *ast = to_ast_device(plane->dev);
 	struct drm_rect damage;
 	u64 dst_off = ast_plane->offset;
@@ -266,7 +265,7 @@ static void ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
 	 * engine to the offset.
 	 */
 
-	if (drm_atomic_helper_damage_merged(old_plane_state, plane_state, &damage)) {
+	if (drm_atomic_helper_damage_merged(plane_state, &damage)) {
 		const u8 *argb4444 = ast_cursor_plane_get_argb4444(ast_cursor_plane,
 								   shadow_plane_state,
 								   &damage);
drivers/gpu/drm/drm_damage_helper.c +1 -3
index 28f26234523d..28b847636253 100644
@@ -296,7 +296,6 @@ EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next);
 
 /**
  * drm_atomic_helper_damage_merged - Merged plane damage
- * @old_state: Old plane state for validation.
  * @state: Plane state from which to iterate the damage clips.
  * @rect: Returns the merged damage rectangle
  *
@@ -309,8 +308,7 @@ EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next);
  * Returns:
  * True if there is valid plane damage otherwise false.
  */
-bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state,
-				     const struct drm_plane_state *state,
+bool drm_atomic_helper_damage_merged(const struct drm_plane_state *state,
 				     struct drm_rect *rect)
 {
 	struct drm_atomic_helper_damage_iter iter;
drivers/gpu/drm/drm_mipi_dbi.c +1 -2
index 25cf04d029f7..4da201c38c93 100644
@@ -380,7 +380,6 @@ void drm_mipi_dbi_plane_helper_atomic_update(struct drm_plane *plane,
 	struct drm_plane_state *plane_state = plane->state;
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_framebuffer *fb = plane_state->fb;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_rect rect;
 	int idx;
 
@@ -388,7 +387,7 @@ void drm_mipi_dbi_plane_helper_atomic_update(struct drm_plane *plane,
 		return;
 
 	if (drm_dev_enter(plane->dev, &idx)) {
-		if (drm_atomic_helper_damage_merged(old_plane_state, plane_state, &rect))
+		if (drm_atomic_helper_damage_merged(plane_state, &rect))
 			mipi_dbi_fb_dirty(&shadow_plane_state->data[0], fb, &rect,
 					  &shadow_plane_state->fmtcnv_state);
 		drm_dev_exit(idx);
drivers/gpu/drm/i915/display/intel_plane.c +2 -9
index 2a52b36c646c..3560e222a3ea 100644
@@ -346,7 +346,6 @@ static void intel_plane_clear_hw_state(struct intel_plane_state *plane_state)
 
 static void
 intel_plane_copy_uapi_plane_damage(struct intel_plane_state *new_plane_state,
-				   const struct intel_plane_state *old_uapi_plane_state,
 				   const struct intel_plane_state *new_uapi_plane_state)
 {
 	struct intel_display *display = to_intel_display(new_plane_state);
@@ -356,10 +355,9 @@ intel_plane_copy_uapi_plane_damage(struct intel_plane_state *new_plane_state,
 	if (DISPLAY_VER(display) < 12)
 		return;
 
-	if (!drm_atomic_helper_damage_merged(&old_uapi_plane_state->uapi,
-					     &new_uapi_plane_state->uapi,
+	if (!drm_atomic_helper_damage_merged(&new_uapi_plane_state->uapi,
 					     damage))
-		/* Incase helper fails, mark whole plane region as damage */
+		/* In case the helper fails, mark whole plane region as damage */
 		*damage = drm_plane_state_src(&new_uapi_plane_state->uapi);
 }
 
@@ -815,7 +813,6 @@ static int plane_atomic_check(struct intel_atomic_state *state,
 	const struct intel_plane_state *old_plane_state =
 		intel_atomic_get_old_plane_state(state, plane);
 	const struct intel_plane_state *new_primary_crtc_plane_state;
-	const struct intel_plane_state *old_primary_crtc_plane_state;
 	struct intel_crtc *crtc = intel_crtc_for_pipe(display, plane->pipe);
 	const struct intel_crtc_state *old_crtc_state =
 		intel_atomic_get_old_crtc_state(state, crtc);
@@ -830,15 +827,11 @@ static int plane_atomic_check(struct intel_atomic_state *state,
 
 		new_primary_crtc_plane_state =
 			intel_atomic_get_new_plane_state(state, primary_crtc_plane);
-		old_primary_crtc_plane_state =
-			intel_atomic_get_old_plane_state(state, primary_crtc_plane);
 	} else {
 		new_primary_crtc_plane_state = new_plane_state;
-		old_primary_crtc_plane_state = old_plane_state;
 	}
 
 	intel_plane_copy_uapi_plane_damage(new_plane_state,
-					   old_primary_crtc_plane_state,
 					   new_primary_crtc_plane_state);
 
 	intel_plane_copy_uapi_to_hw_state(new_plane_state,
drivers/gpu/drm/i915/display/intel_psr.c +1 -2
index 5047e3fdc9ff..185c065aaebb 100644
@@ -3015,8 +3015,7 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state,
 		src = drm_plane_state_src(&new_plane_state->uapi);
 		drm_rect_fp_to_int(&src, &src);
 
-		if (!drm_atomic_helper_damage_merged(&old_plane_state->uapi,
-						     &new_plane_state->uapi, &damaged_area))
+		if (!drm_atomic_helper_damage_merged(&new_plane_state->uapi, &damaged_area))
 			continue;
 
 		damaged_area.y1 += new_plane_state->uapi.dst.y1 - src.y1;
drivers/gpu/drm/sitronix/st7586.c +1 -2
index 28b2245f6b79..2cc0312595a4 100644
@@ -176,7 +176,6 @@ static void st7586_plane_helper_atomic_update(struct drm_plane *plane,
 	struct drm_plane_state *plane_state = plane->state;
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_framebuffer *fb = plane_state->fb;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_rect rect;
 	int idx;
 
@@ -186,7 +185,7 @@ static void st7586_plane_helper_atomic_update(struct drm_plane *plane,
 	if (!drm_dev_enter(plane->dev, &idx))
 		return;
 
-	if (drm_atomic_helper_damage_merged(old_plane_state, plane_state, &rect))
+	if (drm_atomic_helper_damage_merged(plane_state, &rect))
 		st7586_fb_dirty(&shadow_plane_state->data[0], fb, &rect,
 				&shadow_plane_state->fmtcnv_state);
 
drivers/gpu/drm/tiny/gm12u320.c +1 -1
index d73dfebb4353..880b965e283a 100644
@@ -582,7 +582,7 @@ static void gm12u320_pipe_update(struct drm_simple_display_pipe *pipe,
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(state);
 	struct drm_rect rect;
 
-	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
+	if (drm_atomic_helper_damage_merged(state, &rect))
 		gm12u320_fb_mark_dirty(state->fb, &shadow_plane_state->data[0], &rect);
 }
 
drivers/gpu/drm/tiny/ili9225.c +1 -2
index 5bf52a8fd75b..d821a659a585 100644
@@ -185,7 +185,6 @@ static void ili9225_plane_helper_atomic_update(struct drm_plane *plane,
 	struct drm_plane_state *plane_state = plane->state;
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_framebuffer *fb = plane_state->fb;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_rect rect;
 	int idx;
 
@@ -195,7 +194,7 @@ static void ili9225_plane_helper_atomic_update(struct drm_plane *plane,
 	if (!drm_dev_enter(drm, &idx))
 		return;
 
-	if (drm_atomic_helper_damage_merged(old_plane_state, plane_state, &rect))
+	if (drm_atomic_helper_damage_merged(plane_state, &rect))
 		ili9225_fb_dirty(&shadow_plane_state->data[0], fb, &rect,
 				 &shadow_plane_state->fmtcnv_state);
 
drivers/gpu/drm/tiny/repaper.c +1 -1
index c8270591afc7..531831d2b73f 100644
@@ -837,7 +837,7 @@ static void repaper_pipe_update(struct drm_simple_display_pipe *pipe,
 	if (!pipe->crtc.state->active)
 		return;
 
-	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
+	if (drm_atomic_helper_damage_merged(state, &rect))
 		repaper_fb_dirty(state->fb, shadow_plane_state->data,
 				 &shadow_plane_state->fmtcnv_state);
 }
drivers/gpu/drm/tiny/sharp-memory.c +1 -2
index 506e6432e70d..1dacd41ddbaa 100644
@@ -241,7 +241,6 @@ static int sharp_memory_plane_atomic_check(struct drm_plane *plane,
 static void sharp_memory_plane_atomic_update(struct drm_plane *plane,
 					     struct drm_atomic_commit *state)
 {
-	struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_plane_state *plane_state = plane->state;
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct sharp_memory_device *smd;
@@ -251,7 +250,7 @@ static void sharp_memory_plane_atomic_update(struct drm_plane *plane,
 	if (!smd->crtc.state->active)
 		return;
 
-	if (drm_atomic_helper_damage_merged(old_state, plane_state, &rect))
+	if (drm_atomic_helper_damage_merged(plane_state, &rect))
 		sharp_memory_fb_dirty(plane_state->fb, shadow_plane_state->data,
 				      &rect, &shadow_plane_state->fmtcnv_state);
 }
drivers/gpu/drm/virtio/virtgpu_plane.c +1 -1
index 1d1b27ece62a..4728047315a2 100644
@@ -260,7 +260,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
 		return;
 	}
 
-	if (!drm_atomic_helper_damage_merged(old_state, plane->state, &rect))
+	if (!drm_atomic_helper_damage_merged(plane->state, &rect))
 		return;
 
 	bo = gem_to_virtio_gpu_obj(plane->state->fb->obj[0]);
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +1 -3
index 4139837f4caf..f0df2b1c8465 100644
@@ -977,7 +977,6 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,
 	enum stdu_content_type new_content_type;
 	struct vmw_framebuffer_surface *new_vfbs;
 	uint32_t hdisplay = new_state->crtc_w, vdisplay = new_state->crtc_h;
-	struct drm_plane_state *old_state = plane->state;
 	struct drm_rect rect;
 	int ret;
 
@@ -1101,8 +1100,7 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,
 		struct vmw_surface *surf = vmw_user_object_surface(&vps->uo);
 		struct vmw_resource *res = &surf->res;
 
-		if (!res->res_dirty && drm_atomic_helper_damage_merged(old_state,
-								       new_state,
+		if (!res->res_dirty && drm_atomic_helper_damage_merged(new_state,
 								       &rect)) {
 			/*
 			 * At some point it might be useful to actually translate
include/drm/drm_damage_helper.h +1 -2
index fafe29b50fc6..b5a4de779db6 100644
@@ -77,8 +77,7 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter,
 bool
 drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter,
 				   struct drm_rect *rect);
-bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state,
-				     const struct drm_plane_state *state,
+bool drm_atomic_helper_damage_merged(const struct drm_plane_state *state,
 				     struct drm_rect *rect);
 
 #endif
Signature · 1 line
2.54.0
author maintainer
#26 lore raw

PATCH v4 10/10 drm/vmwgfx: Remove unused field struct vmwgfx_du_update_plane.old_state

In reply to Thomas Zimmermann

Plane updates no longer require the old plane state. Remove the field from struct vmwgfx_du_update_plane and fix all callers.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |  2 --
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 12 ++----------
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 11 ++---------
 3 files changed, 4 insertions(+), 21 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +0 -2
index 2224d7d91d1b..8c2072b82062 100644
@@ -19,7 +19,6 @@
 /**
  * struct vmw_du_update_plane - Closure structure for vmw_du_helper_plane_update
  * @plane: Plane which is being updated.
- * @old_state: Old state of plane.
  * @dev_priv: Device private.
  * @du: Display unit on which to update the plane.
  * @vfb: Framebuffer which is blitted to display unit.
@@ -102,7 +101,6 @@ struct vmw_du_update_plane {
 				    struct drm_rect *bb);
 
 	struct drm_plane *plane;
-	struct drm_plane_state *old_state;
 	struct vmw_private *dev_priv;
 	struct vmw_display_unit *du;
 	struct vmw_framebuffer *vfb;
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +2 -10
index c83061cf7455..fa84bc7ab5bb 100644
@@ -530,7 +530,6 @@ static uint32_t vmw_stud_bo_post_clip(struct vmw_du_update_plane  *update,
  */
 static int vmw_sou_plane_update_bo(struct vmw_private *dev_priv,
 				   struct drm_plane *plane,
-				   struct drm_plane_state *old_state,
 				   struct vmw_framebuffer *vfb,
 				   struct vmw_fence_obj **out_fence)
 {
@@ -538,7 +537,6 @@ static int vmw_sou_plane_update_bo(struct vmw_private *dev_priv,
 
 	memset(&bo_update, 0, sizeof(struct vmw_du_update_plane_buffer));
 	bo_update.base.plane = plane;
-	bo_update.base.old_state = old_state;
 	bo_update.base.dev_priv = dev_priv;
 	bo_update.base.du = vmw_crtc_to_du(plane->state->crtc);
 	bo_update.base.vfb = vfb;
@@ -692,7 +690,6 @@ static uint32_t vmw_sou_surface_post_clip(struct vmw_du_update_plane *update,
  */
 static int vmw_sou_plane_update_surface(struct vmw_private *dev_priv,
 					struct drm_plane *plane,
-					struct drm_plane_state *old_state,
 					struct vmw_framebuffer *vfb,
 					struct vmw_fence_obj **out_fence)
 {
@@ -700,7 +697,6 @@ static int vmw_sou_plane_update_surface(struct vmw_private *dev_priv,
 
 	memset(&srf_update, 0, sizeof(struct vmw_du_update_plane_surface));
 	srf_update.base.plane = plane;
-	srf_update.base.old_state = old_state;
 	srf_update.base.dev_priv = dev_priv;
 	srf_update.base.du = vmw_crtc_to_du(plane->state->crtc);
 	srf_update.base.vfb = vfb;
@@ -721,7 +717,6 @@ static void
 vmw_sou_primary_plane_atomic_update(struct drm_plane *plane,
 				    struct drm_atomic_commit *state)
 {
-	struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
 	struct drm_crtc *crtc = new_state->crtc;
 	struct vmw_fence_obj *fence = NULL;
@@ -734,12 +729,9 @@ vmw_sou_primary_plane_atomic_update(struct drm_plane *plane,
 			vmw_framebuffer_to_vfb(new_state->fb);
 
 		if (vfb->bo)
-			ret = vmw_sou_plane_update_bo(dev_priv, plane,
-						      old_state, vfb, &fence);
+			ret = vmw_sou_plane_update_bo(dev_priv, plane, vfb, &fence);
 		else
-			ret = vmw_sou_plane_update_surface(dev_priv, plane,
-							   old_state, vfb,
-							   &fence);
+			ret = vmw_sou_plane_update_surface(dev_priv, plane, vfb, &fence);
 		if (ret != 0)
 			DRM_ERROR("Failed to update screen.\n");
 	} else {
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +2 -9
index f0df2b1c8465..474e3badb80f 100644
@@ -1240,7 +1240,6 @@ vmw_stdu_bo_populate_update_cpu(struct vmw_du_update_plane  *update, void *cmd,
  */
 static int vmw_stdu_plane_update_bo(struct vmw_private *dev_priv,
 				    struct drm_plane *plane,
-				    struct drm_plane_state *old_state,
 				    struct vmw_framebuffer *vfb,
 				    struct vmw_fence_obj **out_fence)
 {
@@ -1248,7 +1247,6 @@ static int vmw_stdu_plane_update_bo(struct vmw_private *dev_priv,
 
 	memset(&bo_update, 0, sizeof(struct vmw_du_update_plane_buffer));
 	bo_update.base.plane = plane;
-	bo_update.base.old_state = old_state;
 	bo_update.base.dev_priv = dev_priv;
 	bo_update.base.du = vmw_crtc_to_du(plane->state->crtc);
 	bo_update.base.vfb = vfb;
@@ -1350,7 +1348,6 @@ vmw_stdu_surface_populate_update(struct vmw_du_update_plane  *update, void *cmd,
  */
 static int vmw_stdu_plane_update_surface(struct vmw_private *dev_priv,
 					 struct drm_plane *plane,
-					 struct drm_plane_state *old_state,
 					 struct vmw_framebuffer *vfb,
 					 struct vmw_fence_obj **out_fence)
 {
@@ -1363,7 +1360,6 @@ static int vmw_stdu_plane_update_surface(struct vmw_private *dev_priv,
 
 	memset(&srf_update, 0, sizeof(struct vmw_du_update_plane));
 	srf_update.plane = plane;
-	srf_update.old_state = old_state;
 	srf_update.dev_priv = dev_priv;
 	srf_update.du = vmw_crtc_to_du(plane->state->crtc);
 	srf_update.vfb = vfb;
@@ -1424,12 +1420,9 @@ vmw_stdu_primary_plane_atomic_update(struct drm_plane *plane,
 			DRM_ERROR("Failed to bind surface to STDU.\n");
 
 		if (vfb->bo)
-			ret = vmw_stdu_plane_update_bo(dev_priv, plane,
-						       old_state, vfb, &fence);
+			ret = vmw_stdu_plane_update_bo(dev_priv, plane, vfb, &fence);
 		else
-			ret = vmw_stdu_plane_update_surface(dev_priv, plane,
-							    old_state, vfb,
-							    &fence);
+			ret = vmw_stdu_plane_update_surface(dev_priv, plane, vfb, &fence);
 		if (ret)
 			DRM_ERROR("Failed to update STDU.\n");
 	} else {
Signature · 1 line
2.54.0
#8 lore raw

Re: [PATCH v4 03/10] drm/ingenic: Remove calls to drm_atomic_helper_check_plane_damage()

In reply to Thomas Zimmermann
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Setting crtc_state->mode_changed = true inside plane_atomic_check without re-calling drm_atomic_helper_check_modeset() bypasses necessary modeset validations and state updates, leading to incomplete modesets. --

commit 0b5b8aa5c5b9f98bc80329fb6bac6de5430060f3
Author: Thomas Zimmermann <[email protected]>

drm/ingenic: Remove calls to drm_atomic_helper_check_plane_damage()

Atomic helpers call drm_atomic_helper_check_plane_damage() after the atomic_check anyway. Remove the calls from the planes' atomic_check.

Quoted 4 lines
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0 -0
index 42c86f195c66b..e99b44e3ac923 100644

[ ... ]

drivers/gpu/drm/ingenic/ingenic-drm-drv.c static int ingenic_drm_plane_atomic_check(struct drm_plane *plane, · line 521

Quoted 4 lines
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0 -0
@@ -519,9 +519,6 @@ static int ingenic_drm_plane_atomic_check(struct drm_plane *plane,
 	     old_plane_state->fb->format->format != new_plane_state->fb->format->format))
 		crtc_state->mode_changed = true;
 

[Severity: High]
This is a pre-existing issue, but does setting crtc_state->mode_changed to true here in ingenic_drm_plane_atomic_check() bypass necessary validations?

The DRM core documentation notes that if drivers set mode_changed = true during the plane check, they must re-call drm_atomic_helper_check_modeset(). Since the ingenic driver assigns drm_atomic_helper_check() directly to its global .atomic_check hook, check_modeset() runs before check_planes().

If a modeset check is not re-evaluated after planes alter the modeset requirement, affected connectors and bridges might never be added to the atomic state via drm_atomic_add_affected_connectors().

Will this cause the display pipeline to skip bridge and encoder modesets during the commit phase, potentially desynchronizing the output?

Quoted 10 lines
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0 -3
-	if (priv->soc_info->map_noncoherent)
-		drm_atomic_helper_check_plane_damage(state, new_plane_state);
-
 	return 0;
 }
 
drivers/gpu/drm/ingenic/ingenic-ipu.c +0 -0
index 56143a191f361..fd17c642c7ac5 100644

[ ... ]

drivers/gpu/drm/ingenic/ingenic-ipu.c static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane, · line 617

Quoted 9 lines
drivers/gpu/drm/ingenic/ingenic-ipu.c +1 -1
@@ -611,7 +611,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 
 	if (!osd_changed(new_plane_state, old_plane_state))
-		goto out_check_damage;
+		return 0;
 
 	crtc_state->mode_changed = true;
 

[Severity: High]
This is also a pre-existing issue, but similar to the above, does setting crtc_state->mode_changed to true here in ingenic_ipu_plane_atomic_check() result in the same missing validation?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#5 lore raw

Re: [PATCH v4 02/10] drm/atomic-helpers: Evaluate plane damage after atomic_check

In reply to Thomas Zimmermann
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Modifying `ignore_damage_clips` after `plane->atomic_check` runs invalidates resource allocations…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Modifying ignore_damage_clips after plane->atomic_check runs invalidates resource allocations based on partial damage clips, leading to heap buffer overflows. --

commit 395f91f063087b27412023cba7e5d824633a9392
Author: Thomas Zimmermann <[email protected]>

drm/atomic-helpers: Evaluate plane damage after atomic_check

This commit evaluates damage clips after running the atomic_check helpers. It adds a loop calling drm_atomic_helper_check_plane_damage() after the driver's plane and CRTC atomic_check hooks have executed. This allows the damage handling to account for full modesets triggered by the check hooks.

Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index 51f39edc31edc..4c37299e8ccb7 100644

[ ... ]

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_check_planes(struct drm_device *dev, · line 1071

Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c +4 -0
@@ -1065,6 +1065,10 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 		}
 	}
 
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+		drm_atomic_helper_check_plane_damage(state, new_plane_state);
+	}
+

[Severity: High]
Does modifying ignore_damage_clips after plane->atomic_check has already run invalidate resource allocations in drivers that use partial damage clips?

For example, in drivers/gpu/drm/tiny/appletbdrm.c:appletbdrm_primary_plane_helper_atomic_check(), the driver sizes a buffer precisely to the damage clips evaluated during atomic_check:

	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, new_plane_state);
	drm_atomic_for_each_plane_damage(&iter, &damage) {
		frames_size += struct_size((struct appletbdrm_frame *)0, buf, rect_size(&damage));
	}
	...
	appletbdrm_state->request = kvzalloc(request_size, GFP_KERNEL);

If a modeset is triggered during the check hooks and this second loop sets ignore_damage_clips to true, won't drm_atomic_helper_damage_iter_init() later return a full-screen damage clip during atomic_update? Could this cause the driver to copy full-screen damage into the buffer allocated only for partial damage, resulting in a heap buffer overflow?

I understand this is explicitly acknowledged and fixed later in the patch series by commit 72afced3e1b6baa294269874c7c4d9d05230889c ('drm/appletbdrm:
Allocate request/response buffers in begin_fb_access').

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
 	return ret;
 }
 EXPORT_SYMBOL(drm_atomic_helper_check_planes);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#16 lore raw

Re: [PATCH v4 06/10] drm/damage-helper: Test src coord in drm_atomic_helper_check_plane_damage()

In reply to Thomas Zimmermann
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Accessor functions `drm_plane_get_damage_clips()` and `drm_plane_get_damage_clips_count()` return…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Accessor functions drm_plane_get_damage_clips() and drm_plane_get_damage_clips_count() return outdated partial clips instead of forcing a full update when ignore_damage_clips is set, causing drivers to skip full plane updates during modesets and src coordinate changes. --

commit 18363d38b23996b07f12d04823d811d72b0f24d4
Author: Thomas Zimmermann <[email protected]>

drm/damage-helper: Test src coord in drm_atomic_helper_check_plane_damage()

This commit updates drm_atomic_helper_check_plane_damage() to evaluate if the source coordinates change across atomic commits. If they do, it sets the ignore_damage_clips flag in the plane state to force a full update, and removes this check from drm_atomic_helper_damage_iter_init().

Quoted 4 lines
drivers/gpu/drm/drm_damage_helper.c +0 -0
index 945fac8dc27b6..f492a59edbeb5 100644

[ ... ]

Quoted 4 lines
drivers/gpu/drm/drm_damage_helper.c +0 -0
@@ -67,19 +68,23 @@ static void convert_clip_rect_to_rect(const struct drm_clip_rect *src,
  * &drm_plane_state.src as damage.
  */
 void drm_atomic_helper_check_plane_damage(struct drm_atomic_commit *state,

drivers/gpu/drm/drm_damage_helper.c static void convert_clip_rect_to_rect(const struct drm_clip_rect *src, · line 78

Quoted 10 lines
drivers/gpu/drm/drm_damage_helper.c +5 -2
-					  struct drm_plane_state *plane_state)
+					  const struct drm_plane_state *old_plane_state,
+					  struct drm_plane_state *new_plane_state)
 {
 	struct drm_crtc_state *crtc_state;
 
-	if (plane_state->crtc) {
+	if (!drm_rect_equals(&new_plane_state->src, &old_plane_state->src))
+		new_plane_state->ignore_damage_clips = true;
+

[Severity: High]
Will this cause display corruption in drivers that manually read the damage clips?

The accessors drm_plane_get_damage_clips_count() and __drm_plane_get_damage_clips() in drivers/gpu/drm/drm_plane.c do not check the ignore_damage_clips flag.

If a driver calls them directly, such as AMDGPU in fill_dc_dirty_rects():

    num_clips = drm_plane_get_damage_clips_count(new_plane_state);
    clips = drm_plane_get_damage_clips(new_plane_state);

won't it receive the stale or partial user-provided damage clips instead of performing a full update when the src coordinates change or during a full modeset?

Quoted 13 lines
drivers/gpu/drm/drm_damage_helper.c +3 -2
+	if (new_plane_state->crtc) {
 		crtc_state = drm_atomic_get_new_crtc_state(state,
-							   plane_state->crtc);
+							   new_plane_state->crtc);
 
 		if (WARN_ON(!crtc_state))
 			return;
 
 		if (drm_atomic_crtc_needs_modeset(crtc_state))
-			plane_state->ignore_damage_clips = true;
+			new_plane_state->ignore_damage_clips = true;
 	}
 }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
#11 lore raw

Re: [PATCH v4 04/10] drm/appletbdrm: Allocate request/response buffers in begin_fb_access

In reply to Thomas Zimmermann
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Critical] Passing NULL as the old_state parameter to drm_atomic_helper_damage_iter_init() causes a kernel panic due to a NULL pointer dereference.

Pre-existing issues:
- [Critical] Accumulating damage clip sizes in frames_size can overflow on 32-bit platforms, causing an undersized buffer allocation and a subsequent heap buffer overflow. --

commit 72afced3e1b6baa294269874c7c4d9d05230889c
Author: Thomas Zimmermann <[email protected]>

drm/appletbdrm: Allocate request/response buffers in begin_fb_access

In atomic_check, damage handling is not fully evaluated. Another atomic_check helper could trigger a full modeset and thus invalidate damage clips.

Allocation of the request/response buffers in appletbdrm depends on correct damage information. Otherwise it might allocate incorrectly sized buffers. Allocate the buffers in the driver's begin_fb_access helper. It runs early during the commit when damage clipping has been fully evaluated.

Quoted 5 lines
drivers/gpu/drm/tiny/appletbdrm.c +0 -0
index cdd35af498920..b683dcb35b0be 100644
@@ -315,33 +315,16 @@ static const u32 appletbdrm_primary_plane_formats[] = {

[ ... ]

drivers/gpu/drm/tiny/appletbdrm.c static const u32 appletbdrm_primary_plane_formats[] = { · line 327

Quoted 2 lines
drivers/gpu/drm/tiny/appletbdrm.c +1 -1
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, new_plane_state);
+	drm_atomic_helper_damage_iter_init(&iter, NULL, new_plane_state);

[Severity: Critical]
Does passing NULL as the old_state parameter to drm_atomic_helper_damage_iter_init() cause a kernel panic?

If userspace has provided damage clips, drm_atomic_helper_damage_iter_init() evaluates !drm_rect_equals(&state->src, &old_state->src) to check if the source coordinates changed:

drivers/gpu/drm/drm_damage_helper.c:drm_atomic_helper_damage_iter_init() {
    ...
	if (!iter->clips || state->ignore_damage_clips ||
	    !drm_rect_equals(&state->src, &old_state->src)) {
    ...
}

This appears to pass the address of src offset from the NULL pointer to drm_rect_equals(), which would immediately dereference it and trigger an oops. This could allow any userspace process with display access to trivially crash the system by attaching a damage clip.

I found the fix for this regression later in the patch series in the commit 'drm/damage-helper: Remove old state from drm_atomic_helper_damage_iter_init()', but I am reporting it here since it breaks at this step in the git history.

drivers/gpu/drm/tiny/appletbdrm.c static const u32 appletbdrm_primary_plane_formats[] = { · line 329

Quoted 2 lines
drivers/gpu/drm/tiny/appletbdrm.c +0 -0
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		frames_size += struct_size((struct appletbdrm_frame *)0, buf, rect_size(&damage));

[Severity: Critical]
This is a pre-existing issue, but can this unchecked accumulation overflow frames_size on 32-bit platforms?

Because userspace can submit an arbitrary number of overlapping damage clips up to the maximum property blob size, this unchecked addition could wrap around a 32-bit size_t counter, causing kvzalloc() to allocate an undersized buffer.

During appletbdrm_flush_damage(), the driver loops over the same clips and uses drm_fb_memcpy() to write the full, un-overflowed volume of pixel data into the undersized allocation:

drivers/gpu/drm/tiny/appletbdrm.c:appletbdrm_flush_damage() {
    ...
		switch (fb->format->format) {
		case DRM_FORMAT_XRGB8888:
			drm_fb_xrgb8888_to_bgr888(&dst, NULL, &shadow_plane_state->data[0], fb, &damage, &shadow_plane_state->fmtcnv_state);
			break;
		default:
			drm_fb_memcpy(&dst, NULL, &shadow_plane_state->data[0], fb, &damage);
			break;
		}
    ...
}

This causes an out-of-bounds heap write, which could potentially be exploited.

Quoted 1 line

}

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#2 lore raw

Re: [PATCH v4 01/10] drm/damage-helper: Do not alter damage clips on modeset, but ignore them

In reply to Thomas Zimmermann
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Drivers using raw damage clip getters bypass the newly introduced `ignore_damage_clips` flag…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Drivers using raw damage clip getters bypass the newly introduced ignore_damage_clips flag, leading to partial screen updates during full modesets. --

commit 8480930644dc907381d0145f944fe144e2010b34
Author: Thomas Zimmermann <[email protected]>

drm/damage-helper: Do not alter damage clips on modeset, but ignore them

This commit changes the behavior of drm_atomic_helper_check_plane_damage() to preserve fb_damage_clips during a modeset. Instead of clearing the clips, it now sets a new ignore_damage_clips flag, which the damage iterator respects.

Quoted 4 lines
drivers/gpu/drm/drm_damage_helper.c +0 -0
index 74a7f4252ecff..945fac8dc27b6 100644

[ ... ]

drivers/gpu/drm/drm_damage_helper.c void drm_atomic_helper_check_plane_damage(struct drm_atomic_commit *state, · line 84

Quoted 12 lines
drivers/gpu/drm/drm_damage_helper.c +2 -4
@@ -78,10 +78,8 @@ void drm_atomic_helper_check_plane_damage(struct drm_atomic_commit *state,
 		if (WARN_ON(!crtc_state))
 			return;
 
-		if (drm_atomic_crtc_needs_modeset(crtc_state)) {
-			drm_property_blob_put(plane_state->fb_damage_clips);
-			plane_state->fb_damage_clips = NULL;
-		}
+		if (drm_atomic_crtc_needs_modeset(crtc_state))
+			plane_state->ignore_damage_clips = true;
 	}
 }

[Severity: High]
Does this change cause a regression for drivers that use the raw damage clip getters instead of the iterator?

Several drivers call drm_plane_get_damage_clips() and drm_plane_get_damage_clips_count() directly. These raw getters return the fb_damage_clips without evaluating the new ignore_damage_clips flag:

drivers/gpu/drm/drm_plane.c:drm_plane_get_damage_clips() {
    ...
    return __drm_plane_get_damage_clips(state);
}

Before this patch, fb_damage_clips was forced to NULL on modeset, which caused drivers to correctly fall back to a full frame update. Now they will see num_clips > 0 and attempt a partial screen update during a full modeset.

For example, in amdgpu, the full frame update fallback is skipped:

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:fill_dc_dirty_rects() {
    ...
    num_clips = drm_plane_get_damage_clips_count(new_plane_state);
    clips = drm_plane_get_damage_clips(new_plane_state);
    ...
}

Similarly in vboxvideo:

drivers/gpu/drm/vboxvideo/vbox_mode.c:vbox_primary_atomic_update() {
    ...
    clips = drm_plane_get_damage_clips(new_state);
    num_clips = drm_plane_get_damage_clips_count(new_state);
    ...
}

And in vmwgfx:

drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c:vmw_ldu_primary_plane_atomic_update() {
    ...
    struct drm_mode_rect *damage_rects = drm_plane_get_damage_clips(new_state);
    u32 rect_count = drm_plane_get_damage_clips_count(new_state);
    ...
}

Should the raw getters be updated to check ignore_damage_clips, or should these drivers be transitioned to use the damage iterator?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#22 lore raw

Re: [PATCH v4 08/10] drm/damage-helper: Remove old state from drm_atomic_helper_damage_merged()

In reply to Thomas Zimmermann
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The i915 driver fails to perform full plane updates when source coordinates change (e.g., panning…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The i915 driver fails to perform full plane updates when source coordinates change (e.g., panning or cropping), leading to visual corruption. --

commit 020ae3c303979cf114157a7b95370725231ed90b
Author: Thomas Zimmermann <[email protected]>

drm/damage-helper: Remove old state from drm_atomic_helper_damage_merged()

Nothing in drm_atomic_helper_damage_merged() requires the old plane state. Remove the parameter and mass-convert callers. Most callers now no longer require the old plane state in their plane's atomic_update helper.

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_plane.c +0 -0
index 2a52b36c646c7..3560e222a3eae 100644

[ ... ]

Quoted 9 lines
drivers/gpu/drm/i915/display/intel_plane.c +0 -1
@@ -346,7 +346,6 @@ static void intel_plane_clear_hw_state(struct intel_plane_state *plane_state)
 
 static void
 intel_plane_copy_uapi_plane_damage(struct intel_plane_state *new_plane_state,
-				   const struct intel_plane_state *old_uapi_plane_state,
 				   const struct intel_plane_state *new_uapi_plane_state)
 {
 	struct intel_display *display = to_intel_display(new_plane_state);

drivers/gpu/drm/i915/display/intel_plane.c intel_plane_copy_uapi_plane_damage(struct intel_plane_state *new_plane_state, · line 359

Quoted 7 lines
drivers/gpu/drm/i915/display/intel_plane.c +1 -2
@@ -356,10 +355,9 @@ intel_plane_copy_uapi_plane_damage(struct intel_plane_state *new_plane_state,
 	if (DISPLAY_VER(display) < 12)
 		return;
 
-	if (!drm_atomic_helper_damage_merged(&old_uapi_plane_state->uapi,
-					     &new_uapi_plane_state->uapi,
+	if (!drm_atomic_helper_damage_merged(&new_uapi_plane_state->uapi,
 					     damage))

[Severity: High]
Does this code risk missing full plane updates when source coordinates change?

It appears that with the removal of the old state, the fallback checking for source coordinate changes (like panning) was also removed from the damage iterators. The DRM core now expects drivers to call drm_atomic_helper_check_plane_damage() to set ignore_damage_clips = true when the source changes.

Because i915 implements a custom atomic check phase in intel_atomic_check() that does not call drm_atomic_helper_check_planes() or drm_atomic_helper_check_plane_damage(), ignore_damage_clips remains unset.

Will drm_atomic_helper_damage_merged() incorrectly return only partial damage here when the plane is panned, missing the full update?

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_plane.c +1 -1
-		/* Incase helper fails, mark whole plane region as damage */
+		/* In case the helper fails, mark whole plane region as damage */
 		*damage = drm_plane_state_src(&new_uapi_plane_state->uapi);
 }

[ ... ]

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_psr.c +0 -0
index e138982dc91f6..22bab263d85d4 100644

[ ... ]

drivers/gpu/drm/i915/display/intel_psr.c int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, · line 3021

Quoted 7 lines
drivers/gpu/drm/i915/display/intel_psr.c +1 -2
@@ -3018,8 +3018,7 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state,
 		src = drm_plane_state_src(&new_plane_state->uapi);
 		drm_rect_fp_to_int(&src, &src);
 
-		if (!drm_atomic_helper_damage_merged(&old_plane_state->uapi,
-						     &new_plane_state->uapi, &damaged_area))
+		if (!drm_atomic_helper_damage_merged(&new_plane_state->uapi, &damaged_area))

[Severity: High]
Can this cause severe visual corruption for PSR2 selective fetch?

If intel_psr2_sel_fetch_update() no longer forces a full update on source coordinate changes, it seems this might only fetch the small damaged area (such as a blinking cursor) while leaving the rest of the panned screen stale.

Quoted 3 lines
drivers/gpu/drm/i915/display/intel_psr.c +0 -0
 			continue;
 
 		damaged_area.y1 += new_plane_state->uapi.dst.y1 - src.y1;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
#28 lore raw

✗ Fi.CI.BUILD: failure for drm: Improve logic behind damage handling (rev3)

In reply to Thomas Zimmermann
== Series Details ==

== Series Details ==

Series: drm: Improve logic behind damage handling (rev3)
URL : https://patchwork.freedesktop.org/series/166107/
State : failure

== Summary ==

Error: patch https://patchwork.freedesktop.org/api/1.0/series/166107/revisions/3/mbox/ not applied
Applying: drm/damage-helper: Do not alter damage clips on modeset, but ignore them
Applying: drm/atomic-helpers: Evaluate plane damage after atomic_check
Applying: drm/ingenic: Remove calls to drm_atomic_helper_check_plane_damage()
Applying: drm/appletbdrm: Allocate request/response buffers in begin_fb_access
Applying: drm/atomic_helper: Do not evaluate plane damage before atomic_check
Applying: drm/damage-helper: Test src coord in drm_atomic_helper_check_plane_damage()
Applying: drm/damage-helper: Remove old state from drm_atomic_helper_damage_iter_init() Using index info to reconstruct a base tree...
M drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0007 drm/damage-helper: Remove old state from drm_atomic_helper_damage_iter_init() When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced

maintainer Reviewed-by on v4 1/10
#3 lore raw

Re: [PATCH v4 01/10] drm/damage-helper: Do not alter damage clips on modeset, but ignore them

In reply to Thomas Zimmermann

Thomas Zimmermann <[email protected]> writes:

Hello Thomas,

Quoted 36 lines

User space supplies rectangles for damage clipping in a plane property. For full mode sets, drivers still require a full plane update. In this case, leave the information as-is and set the ignore_damage_clips flag instead. The damage iterator will later ignore any damage information.

Also fixes a bug where ignore_damage_clips was not cleared across plane- state duplications.

Leaving the damage information as-is might be helpful to drivers that benefit from this information even on full modesets (e.g., for cache management). It will also help with consolidating the damage-handling logic.

Also add a new unit test that evaluates the ignore_damage_clips flag. It sets two damage clips plus the flag and tests if the reported damage covers the entire framebuffer.

v4:
- slightly reword the commit description

Fixes 35ed38d58257 ("drm: Allow drivers to indicate the damage helpers to ignore damage clips")
Cc <[email protected]> # v6.10+
---
 drivers/gpu/drm/drm_atomic_state_helper.c     |  1 +
 drivers/gpu/drm/drm_damage_helper.c           |  6 ++--
 .../gpu/drm/tests/drm_damage_helper_test.c    | 28 +++++++++++++++++++
 3 files changed, 31 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_atomic_state_helper.c +0 -0
index cc70508d4fdb..84d5231ccac1 100644

drivers/gpu/drm/drm_atomic_state_helper.c void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane, · line 364

Quoted 6 lines
drivers/gpu/drm/drm_atomic_state_helper.c +1 -0
@@ -359,6 +359,7 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
 	state->fence = NULL;
 	state->commit = NULL;
 	state->fb_damage_clips = NULL;
+	state->ignore_damage_clips = false;
 	state->color_mgmt_changed = false;
 }

I would split this as a separate patch since is the bug you are fixing for commit 35ed38d58257 ("drm: Allow drivers to indicate the damage helpers to ignore damage clips").

Quoted 7 lines
drivers/gpu/drm/drm_atomic_state_helper.c +0 -0
 EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
drivers/gpu/drm/drm_damage_helper.c +0 -0
index 74a7f4252ecf..945fac8dc27b 100644
@@ -78,10 +78,8 @@ void drm_atomic_helper_check_plane_damage(struct drm_atomic_commit *state,
 		if (WARN_ON(!crtc_state))

drivers/gpu/drm/drm_damage_helper.c void drm_atomic_helper_check_plane_damage(struct drm_atomic_commit *state, · line 84

Quoted 10 lines
drivers/gpu/drm/drm_damage_helper.c +2 -4
 			return;
 
-		if (drm_atomic_crtc_needs_modeset(crtc_state)) {
-			drm_property_blob_put(plane_state->fb_damage_clips);
-			plane_state->fb_damage_clips = NULL;
-		}
+		if (drm_atomic_crtc_needs_modeset(crtc_state))
+			plane_state->ignore_damage_clips = true;
 	}
 }

This makes sense to me as well and I agree that re-using the flag for this is better than making plane_state->fb_damage_clips == NULL the condition.

As mentioned though, I would make it a separate patch. Both changes look good to me:

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v4 2/10
#6 lore raw

Re: [PATCH v4 02/10] drm/atomic-helpers: Evaluate plane damage after atomic_check

In reply to Thomas Zimmermann
Quoted 23 lines · Thomas Zimmermann

Each plane's and CRTC's atomic_check might trigger a full modeset. As this affects the plane's damage handling, evaluate damage clips after running the atomic_check helpers.

Examples can be found in a number of drivers, such as ast, gud, ingenic, mgag200 or vmwgfx, which all set mode_changed in the CRTC state to true. Ingenic even re-evaluates damage information in its plane's atomic_check. Doing this after the atomic_check helpers ran benefits all drivers.

There's already a damage evaluation before the calls to atomic_check. With a few fixes to drivers, this can be removed.

---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index 51f39edc31ed..4c37299e8ccb 100644

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_check_planes(struct drm_device *dev, · line 1071

Quoted 7 lines
drivers/gpu/drm/drm_atomic_helper.c +4 -0
@@ -1065,6 +1065,10 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 		}
 	}
 
+	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+		drm_atomic_helper_check_plane_damage(state, new_plane_state);
+	}
+

I wonder if it's worth to mention this in the drm_atomic_helper_check_planes() function kernel-doc comment. But regardless, the change makes sense to me:

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v4 3/10
#9 lore raw

Re: [PATCH v4 03/10] drm/ingenic: Remove calls to drm_atomic_helper_check_plane_damage()

In reply to Thomas Zimmermann
Quoted 7 lines · Thomas Zimmermann

Atomic helpers call drm_atomic_helper_check_plane_damage() after the atomic_check anyway. See atomic_helper_check_planes(). Remove the calls from the planes' atomic_check.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v4 4/10
#12 lore raw

Re: [PATCH v4 04/10] drm/appletbdrm: Allocate request/response buffers in begin_fb_access

In reply to Thomas Zimmermann
Quoted 4 lines · Thomas Zimmermann

In atomic_check, damage handling is not fully evaluated. Another atomic_check helper could trigger a full modeset and thus invalidate damage clips.

Quoted 8 lines

Allocation of the request/response buffers in appletbdrm depends on correct damage information. Otherwise it might allocate incorrectly sized buffers. Allocate the buffers in the driver's begin_fb_access helper. It runs early during the commit when damage clipping has been fully evaluated.

v2:
- allocate before drm_gem_begin_shadow_fb_access() to avoid leak on error

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v4 5/10
#14 lore raw

Re: [PATCH v4 05/10] drm/atomic_helper: Do not evaluate plane damage before atomic_check

In reply to Thomas Zimmermann
Quoted 7 lines · Thomas Zimmermann

Remove the call to drm_atomic_helper_check_plane_damage() from before calling the atomic_check helpers. The call has no longer any purpose, as the actual evaluation happens after running atomic_check.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v4 6/10
#17 lore raw

Re: [PATCH v4 06/10] drm/damage-helper: Test src coord in drm_atomic_helper_check_plane_damage()

In reply to Thomas Zimmermann
Quoted 8 lines · Thomas Zimmermann

Planes require a full update if the source coordinates change across atomic commits. Evaluate this during the atomic-check and set the flag ignore_damage_clips in the plane state, if so. Remove the check from drm_atomic_helper_damage_iter_init().

This will help with removing the old state from the atomic-commit phase and simplify atomic_update helpers a bit.

Quoted 8 lines

Several unit tests check against the change of the src coordinate. Drop them as they do no longer serve a purpose. If the src coordinate changes across commits, atomic helpers will set the plane state's ignore_damage_clips flag, for which a separate unit test exists.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v4 7/10
#19 lore raw

Re: [PATCH v4 07/10] drm/damage-helper: Remove old state from drm_atomic_helper_damage_iter_init()

In reply to Thomas Zimmermann
Quoted 9 lines · Thomas Zimmermann

Nothing in drm_atomic_helper_damage_iter_init() requires the old plane state. Remove the parameter and mass-convert callers.

Most callers now no longer require the old plane state in their plane's atomic_update helper. Remove it as well.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v4 8/10
#23 lore raw

Re: [PATCH v4 08/10] drm/damage-helper: Remove old state from drm_atomic_helper_damage_merged()

In reply to Thomas Zimmermann
Quoted 9 lines · Thomas Zimmermann

Nothing in drm_atomic_helper_damage_merged() requires the old plane state. Remove the parameter and mass-convert callers.

Most callers now no longer require the old plane state in their plane's atomic_update helper. Remove it as well.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v4 9/10
#25 lore raw

Re: [PATCH v4 09/10] drm/damage-helper: Rename state parameters in damage helpers

In reply to Thomas Zimmermann
Quoted 6 lines · Thomas Zimmermann

Rename some of the state parameters of the damage-helper functions to align them with each other and other helpers. No functional changes.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v4 10/10
#27 lore raw

Re: [PATCH v4 10/10] drm/vmwgfx: Remove unused field struct vmwgfx_du_update_plane.old_state

In reply to Thomas Zimmermann
Quoted 6 lines · Thomas Zimmermann

Plane updates no longer require the old plane state. Remove the field from struct vmwgfx_du_update_plane and fix all callers.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Acked-by on v4 7/10
#20 lore raw

Re: [PATCH v4 07/10] drm/damage-helper: Remove old state from drm_atomic_helper_damage_iter_init()

In reply to Thomas Zimmermann
Quoted 9 lines · Thomas Zimmermann

Nothing in drm_atomic_helper_damage_iter_init() requires the old plane state. Remove the parameter and mass-convert callers.

Most callers now no longer require the old plane state in their plane's atomic_update helper. Remove it as well.

---