Skip to contentSkip to conversation

drm/vkms: Remove usage of legacy drm_crtc members

PATCH In review Louis Chauvet 2 participants 3 messages Oct 3, 2024 – Nov 5, 2024

Subsystems (3)
lore
Share & tools
lore

Louis Chauvet

author maintainer
#0 lore raw

PATCH 1/1 drm/vkms: Remove usage of legacy drm_crtc members

Some members of the drm_crtc structure have been deprecated in favor of equivalent members in the drm_crtc_state structure. As reported by Ville Syrjala [1], the VKMS driver was still using these deprecated fields. This commit updates the VKMS driver to use the new drm_crtc_state fields instead.

Additionally, this commit removes the call to drm_calc_timestamping_constants in vkms_enable_vblank as it is redundant. This calculation is already performed in vkms_atomic_commit_tail by calling drm_atomic_helper_commit_modeset_disables.

[1]:https://lore.kernel.org/all/[email protected]/

---
 drivers/gpu/drm/vkms/vkms_composer.c  | 4 ++--
 drivers/gpu/drm/vkms/vkms_crtc.c      | 2 --
 drivers/gpu/drm/vkms/vkms_writeback.c | 4 ++--
 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/vkms/vkms_composer.c +2 -2
index 57a5769fc994..3f0977d746be 100644
@@ -187,7 +187,7 @@ static void blend(struct vkms_writeback_job *wb,
 
 	const struct pixel_argb_u16 background_color = { .a = 0xffff };
 
-	size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;
+	size_t crtc_y_limit = crtc_state->base.mode.vdisplay;
 
 	/*
 	 * The planes are composed line-by-line to avoid heavy memory usage. It is a necessary
@@ -270,7 +270,7 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb,
 	if (WARN_ON(check_format_funcs(crtc_state, active_wb)))
 		return -EINVAL;
 
-	line_width = crtc_state->base.crtc->mode.hdisplay;
+	line_width = crtc_state->base.mode.hdisplay;
 	stage_buffer.n_pixels = line_width;
 	output_buffer.n_pixels = line_width;
 
drivers/gpu/drm/vkms/vkms_crtc.c +0 -2
index a40295c18b48..bbf080d32d2c 100644
@@ -64,8 +64,6 @@ static int vkms_enable_vblank(struct drm_crtc *crtc)
 	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
 	struct vkms_output *out = drm_crtc_to_vkms_output(crtc);
 
-	drm_calc_timestamping_constants(crtc, &crtc->mode);
-
 	hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	out->vblank_hrtimer.function = &vkms_vblank_simulate;
 	out->period_ns = ktime_set(0, vblank->framedur_ns);
drivers/gpu/drm/vkms/vkms_writeback.c +2 -2
index bc724cbd5e3a..999d5c01ea81 100644
@@ -131,8 +131,8 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn,
 	struct drm_connector_state *conn_state = wb_conn->base.state;
 	struct vkms_crtc_state *crtc_state = output->composer_state;
 	struct drm_framebuffer *fb = connector_state->writeback_job->fb;
-	u16 crtc_height = crtc_state->base.crtc->mode.vdisplay;
-	u16 crtc_width = crtc_state->base.crtc->mode.hdisplay;
+	u16 crtc_height = crtc_state->base.mode.vdisplay;
+	u16 crtc_width = crtc_state->base.mode.hdisplay;
 	struct vkms_writeback_job *active_wb;
 	struct vkms_frame_info *wb_frame_info;
 	u32 wb_format = fb->format->format;

---
base-commit: cbc1e8696fbea0010a73bf93534c712f9ad177db
change-id: 20241003-remove-legacy-a2683a7bbcd5

Best regards,

Signature · 1 line
Louis Chauvet <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Louis Chauvet

Some members of the drm_crtc structure have been deprecated in favor of equivalent members in the drm_crtc_state structure. As reported by Ville Syrjala [1], the VKMS driver was still using these deprecated fields. This commit updates the VKMS driver to use the new drm_crtc_state fields instead.

Additionally, this commit removes the call to drm_calc_timestamping_constants in vkms_enable_vblank as it is redundant. This calculation is already performed in vkms_atomic_commit_tail by calling drm_atomic_helper_commit_modeset_disables.

One slight difference here is that drm_atomic_helper_calc_timestamping_constants() passes in crtc_state->adjusted_mode instead of crtc_state->mode, but doesn't look look vkms mangles either in any way so they should stay identical after drm_atomic_helper_check_modeset()->mode_fixup() has done the copy.

Quoted 68 lines

[1]:https://lore.kernel.org/all/[email protected]/

---
 drivers/gpu/drm/vkms/vkms_composer.c  | 4 ++--
 drivers/gpu/drm/vkms/vkms_crtc.c      | 2 --
 drivers/gpu/drm/vkms/vkms_writeback.c | 4 ++--
 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/vkms/vkms_composer.c +2 -2
index 57a5769fc994..3f0977d746be 100644
@@ -187,7 +187,7 @@ static void blend(struct vkms_writeback_job *wb,
 
 	const struct pixel_argb_u16 background_color = { .a = 0xffff };
 
-	size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;
+	size_t crtc_y_limit = crtc_state->base.mode.vdisplay;
 
 	/*
 	 * The planes are composed line-by-line to avoid heavy memory usage. It is a necessary
@@ -270,7 +270,7 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb,
 	if (WARN_ON(check_format_funcs(crtc_state, active_wb)))
 		return -EINVAL;
 
-	line_width = crtc_state->base.crtc->mode.hdisplay;
+	line_width = crtc_state->base.mode.hdisplay;
 	stage_buffer.n_pixels = line_width;
 	output_buffer.n_pixels = line_width;
 
drivers/gpu/drm/vkms/vkms_crtc.c +0 -2
index a40295c18b48..bbf080d32d2c 100644
@@ -64,8 +64,6 @@ static int vkms_enable_vblank(struct drm_crtc *crtc)
 	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
 	struct vkms_output *out = drm_crtc_to_vkms_output(crtc);
 
-	drm_calc_timestamping_constants(crtc, &crtc->mode);
-
 	hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	out->vblank_hrtimer.function = &vkms_vblank_simulate;
 	out->period_ns = ktime_set(0, vblank->framedur_ns);
drivers/gpu/drm/vkms/vkms_writeback.c +2 -3
index bc724cbd5e3a..999d5c01ea81 100644
@@ -131,8 +131,8 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn,
 	struct drm_connector_state *conn_state = wb_conn->base.state;
 	struct vkms_crtc_state *crtc_state = output->composer_state;
 	struct drm_framebuffer *fb = connector_state->writeback_job->fb;
-	u16 crtc_height = crtc_state->base.crtc->mode.vdisplay;
-	u16 crtc_width = crtc_state->base.crtc->mode.hdisplay;
+	u16 crtc_height = crtc_state->base.mode.vdisplay;
+	u16 crtc_width = crtc_state->base.mode.hdisplay;
 	struct vkms_writeback_job *active_wb;
 	struct vkms_frame_info *wb_frame_info;
 	u32 wb_format = fb->format->format;
 
---

base-commit: cbc1e8696fbea0010a73bf93534c712f9ad177db
change-id: 20241003-remove-legacy-a2683a7bbcd5

Best regards,

Signature · 1 line
Louis Chauvet <[email protected]>
Signature · 2 lines
Ville Syrjälä
Intel
author maintainer
#2 lore raw
In reply to Louis Chauvet
Quoted 12 lines · Louis Chauvet

Some members of the drm_crtc structure have been deprecated in favor of equivalent members in the drm_crtc_state structure. As reported by Ville Syrjala [1], the VKMS driver was still using these deprecated fields. This commit updates the VKMS driver to use the new drm_crtc_state fields instead.

Additionally, this commit removes the call to drm_calc_timestamping_constants in vkms_enable_vblank as it is redundant. This calculation is already performed in vkms_atomic_commit_tail by calling drm_atomic_helper_commit_modeset_disables.

Quoted 3 lines

[1]:https://lore.kernel.org/all/[email protected]/

Applied on drm-misc-next:
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/aafc45d5f88843a4645e1a53328a0601601d0c12

Quoted 65 lines
---
 drivers/gpu/drm/vkms/vkms_composer.c  | 4 ++--
 drivers/gpu/drm/vkms/vkms_crtc.c      | 2 --
 drivers/gpu/drm/vkms/vkms_writeback.c | 4 ++--
 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/vkms/vkms_composer.c +2 -2
index 57a5769fc994..3f0977d746be 100644
@@ -187,7 +187,7 @@ static void blend(struct vkms_writeback_job *wb,
 
 	const struct pixel_argb_u16 background_color = { .a = 0xffff };
 
-	size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay;
+	size_t crtc_y_limit = crtc_state->base.mode.vdisplay;
 
 	/*
 	 * The planes are composed line-by-line to avoid heavy memory usage. It is a necessary
@@ -270,7 +270,7 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb,
 	if (WARN_ON(check_format_funcs(crtc_state, active_wb)))
 		return -EINVAL;
 
-	line_width = crtc_state->base.crtc->mode.hdisplay;
+	line_width = crtc_state->base.mode.hdisplay;
 	stage_buffer.n_pixels = line_width;
 	output_buffer.n_pixels = line_width;
 
drivers/gpu/drm/vkms/vkms_crtc.c +0 -2
index a40295c18b48..bbf080d32d2c 100644
@@ -64,8 +64,6 @@ static int vkms_enable_vblank(struct drm_crtc *crtc)
 	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
 	struct vkms_output *out = drm_crtc_to_vkms_output(crtc);
 
-	drm_calc_timestamping_constants(crtc, &crtc->mode);
-
 	hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	out->vblank_hrtimer.function = &vkms_vblank_simulate;
 	out->period_ns = ktime_set(0, vblank->framedur_ns);
drivers/gpu/drm/vkms/vkms_writeback.c +2 -3
index bc724cbd5e3a..999d5c01ea81 100644
@@ -131,8 +131,8 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn,
 	struct drm_connector_state *conn_state = wb_conn->base.state;
 	struct vkms_crtc_state *crtc_state = output->composer_state;
 	struct drm_framebuffer *fb = connector_state->writeback_job->fb;
-	u16 crtc_height = crtc_state->base.crtc->mode.vdisplay;
-	u16 crtc_width = crtc_state->base.crtc->mode.hdisplay;
+	u16 crtc_height = crtc_state->base.mode.vdisplay;
+	u16 crtc_width = crtc_state->base.mode.hdisplay;
 	struct vkms_writeback_job *active_wb;
 	struct vkms_frame_info *wb_frame_info;
 	u32 wb_format = fb->format->format;
 
---

base-commit: cbc1e8696fbea0010a73bf93534c712f9ad177db
change-id: 20241003-remove-legacy-a2683a7bbcd5

Best regards,

Signature · 1 line
Louis Chauvet <[email protected]>