AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] drm/radeon: Inline drm_crtc_init()
@ 2026-11-17 14:04 Thomas Zimmermann
  2026-11-17 14:04 ` [PATCH v3 1/2] " Thomas Zimmermann
  2026-11-17 14:04 ` [PATCH v3 2/2] drm: Remove drm_crtc_init() Thomas Zimmermann
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Zimmermann @ 2026-11-17 14:04 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, airlied, simona,
	maarten.lankhorst, mripard
  Cc: amd-gfx, dri-devel, sashiko-reviews, Thomas Zimmermann

The helper drm_crtc_init() sets up a CRTC with a primary plane for
non-atomic mode setting. Only radeon still uses it.

Inline drm_crtc_init() into radeon and remove it from DRM. All new
code implements atomic mode setting, which does not use drm_crtc_init().
DRM support for kernel panic is not implemented by radeon. Clean it up.

With this series in place, DRM's helpers for drawing panic screens
can be further integrated with other drawing helpers, as outlined
in [1].

Tested on radeon with a Radeon HD 6570.

Requires the patch series at [2].

v3:
- keep plane->format_default for now
- remove some obsolete include statements
v2:
- add missing formats for primary plane
- drop amdgpu patches

[1] https://lore.kernel.org/dri-devel/20261019154612.777074-1-tzimmermann@suse.de/
[2] https://lore.kernel.org/amd-gfx/20261111151546.3105062-1-alexander.deucher@amd.com/

Thomas Zimmermann (2):
  drm/radeon: Inline drm_crtc_init()
  drm: Remove drm_crtc_init()

 drivers/gpu/drm/drm_crtc.c              | 19 +++----
 drivers/gpu/drm/drm_modeset_helper.c    | 76 -------------------------
 drivers/gpu/drm/radeon/radeon_display.c | 53 ++++++++++++++---
 include/drm/drm_modeset_helper.h        |  3 -
 4 files changed, 53 insertions(+), 98 deletions(-)


base-commit: 7d502136b31169f6b5575f7f89c3da60cdf7891d
prerequisite-patch-id: 29d74d364880d75af999879ea5eec1e61f99eee4
prerequisite-patch-id: c4aac512c186a1189b7e7d81e3a118b3e487f955
prerequisite-patch-id: 2e6a87a46e3157194ea11a2a4821ffbe38e7748e
-- 
2.56.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/2] drm/radeon: Inline drm_crtc_init()
  2026-11-17 14:04 [PATCH v3 0/2] drm/radeon: Inline drm_crtc_init() Thomas Zimmermann
@ 2026-11-17 14:04 ` Thomas Zimmermann
  2026-11-17 14:04 ` [PATCH v3 2/2] drm: Remove drm_crtc_init() Thomas Zimmermann
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Zimmermann @ 2026-11-17 14:04 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, airlied, simona,
	maarten.lankhorst, mripard
  Cc: amd-gfx, dri-devel, sashiko-reviews, Thomas Zimmermann

Inline drm_crtc_init() into radeon CRTC initialization. The helper is
only used by radeon to implement legacy mode setting.

As in drm_crtc_init(), create a primary plane for the CRTC. Use the same
formats as with drm_crtc_init(). Format modifiers are still marked as
unsupported and handled internally by the plane. For the CRTC, call
drm_crtc_init_with_planes() for initialization. Clean up on errors.

Radeon does not support DRM panic helpers. Therefore do not initialize
the primary plane's panic-helper callbacks.

v3:
- keep plane->format_default for now
v2:
- add missing formats for primary plane

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Maxime Ripard <mripard@kernel.org>
---
 drivers/gpu/drm/radeon/radeon_display.c | 53 +++++++++++++++++++++----
 1 file changed, 46 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index aac6733ddd82..2bc66b9ad121 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -38,6 +38,7 @@
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_modeset_helper.h>
+#include <drm/drm_plane_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
 #include <drm/radeon_drm.h>
@@ -47,6 +48,17 @@
 #include "radeon.h"
 #include "radeon_kms.h"
 
+static const u32 radeon_primary_plane_formats[] = {
+	DRM_FORMAT_XRGB8888,
+	DRM_FORMAT_ARGB8888,
+};
+
+static const struct drm_plane_funcs radeon_primary_plane_funcs = {
+	.update_plane = drm_plane_helper_update_primary,
+	.disable_plane = drm_plane_helper_disable_primary,
+	.destroy = drm_plane_helper_destroy,
+};
+
 static void avivo_crtc_load_lut(struct drm_crtc *crtc)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
@@ -680,20 +692,37 @@ static const struct drm_crtc_funcs radeon_crtc_funcs = {
 static void radeon_crtc_init(struct drm_device *dev, int index)
 {
 	struct radeon_device *rdev = dev->dev_private;
+	struct drm_plane *primary;
 	struct radeon_crtc *radeon_crtc;
+	int ret;
 
-	radeon_crtc = kzalloc_obj(*radeon_crtc);
-	if (radeon_crtc == NULL)
+	primary = __drm_universal_plane_alloc(dev, sizeof(*primary), 0, 0,
+					      &radeon_primary_plane_funcs,
+					      radeon_primary_plane_formats,
+					      ARRAY_SIZE(radeon_primary_plane_formats),
+					      NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
+	if (IS_ERR(primary))
 		return;
 
+	/*
+	 * TODO: Announce the correct formats and remove the format_default
+	 *       field from struct drm_plane.
+	 */
+	primary->format_default = true;
+
+	radeon_crtc = kzalloc_obj(*radeon_crtc);
+	if (!radeon_crtc)
+		goto err_drm_plane_cleanup;
+
 	radeon_crtc->flip_queue = alloc_workqueue("radeon-crtc",
 						  WQ_HIGHPRI | WQ_PERCPU, 0);
-	if (!radeon_crtc->flip_queue) {
-		kfree(radeon_crtc);
-		return;
-	}
+	if (!radeon_crtc->flip_queue)
+		goto err_kfree;
 
-	drm_crtc_init(dev, &radeon_crtc->base, &radeon_crtc_funcs);
+	ret = drm_crtc_init_with_planes(dev, &radeon_crtc->base, primary, NULL,
+					&radeon_crtc_funcs, NULL);
+	if (ret)
+		goto err_destroy_workqueue;
 
 	drm_mode_crtc_set_gamma_size(&radeon_crtc->base, 256);
 	radeon_crtc->crtc_id = index;
@@ -713,6 +742,16 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
 		radeon_atombios_init_crtc(dev, radeon_crtc);
 	else
 		radeon_legacy_init_crtc(dev, radeon_crtc);
+
+	return;
+
+err_destroy_workqueue:
+	destroy_workqueue(radeon_crtc->flip_queue);
+err_kfree:
+	kfree(radeon_crtc);
+err_drm_plane_cleanup:
+	drm_plane_cleanup(primary);
+	kfree(primary);
 }
 
 static const char *encoder_names[38] = {
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] drm: Remove drm_crtc_init()
  2026-11-17 14:04 [PATCH v3 0/2] drm/radeon: Inline drm_crtc_init() Thomas Zimmermann
  2026-11-17 14:04 ` [PATCH v3 1/2] " Thomas Zimmermann
@ 2026-11-17 14:04 ` Thomas Zimmermann
  2026-11-17 14:34   ` sashiko-bot
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Zimmermann @ 2026-11-17 14:04 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, airlied, simona,
	maarten.lankhorst, mripard
  Cc: amd-gfx, dri-devel, sashiko-reviews, Thomas Zimmermann

There are no remaining users of drm_crtc_init(), so remove the helper
and the internal data structures for the primary plane that the helper
creates.

v3:
- keep plane->format_default for now
- remove obsolete include statements

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Maxime Ripard <mripard@kernel.org>
---
 drivers/gpu/drm/drm_crtc.c           | 19 +++----
 drivers/gpu/drm/drm_modeset_helper.c | 76 ----------------------------
 include/drm/drm_modeset_helper.h     |  3 --
 3 files changed, 7 insertions(+), 91 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 5295ec122e0d..614876415479 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -334,10 +334,7 @@ static int __drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *
  * @funcs: callbacks for the new CRTC
  * @name: printf style format string for the CRTC name, or NULL for default name
  *
- * Inits a new object created as base part of a driver crtc object. Drivers
- * should use this function instead of drm_crtc_init(), which is only provided
- * for backwards compatibility with drivers which do not yet support universal
- * planes).
+ * Inits a new object created as base part of a driver crtc object.
  * The &drm_crtc_funcs.destroy hook should call drm_crtc_cleanup() and kfree()
  * the crtc structure. The crtc structure should not be allocated with
  * devm_kzalloc().
@@ -417,10 +414,7 @@ static int __drmm_crtc_init_with_planes(struct drm_device *dev,
  * @funcs: callbacks for the new CRTC
  * @name: printf style format string for the CRTC name, or NULL for default name
  *
- * Inits a new object created as base part of a driver crtc object. Drivers
- * should use this function instead of drm_crtc_init(), which is only provided
- * for backwards compatibility with drivers which do not yet support universal
- * planes).
+ * Inits a new object created as base part of a driver crtc object.
  *
  * Cleanup is automatically handled through registering
  * drmm_crtc_cleanup() with drmm_add_action(). The crtc structure should
@@ -806,10 +800,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
 
 		/*
 		 * Check whether the primary plane supports the fb pixel format.
-		 * Drivers not implementing the universal planes API use a
-		 * default formats list provided by the DRM core which doesn't
-		 * match real hardware capabilities. Skip the check in that
-		 * case.
+		 *
+		 * TODO:  Radeon does not implementing the universal planes API but
+		 *        uses a default formats list provided by the DRM core that
+		 *        doesn't match real hardware capabilities. Skip the check
+		 *        for now until radeon has been updated.
 		 */
 		if (!plane->format_default) {
 			if (!drm_plane_has_format(plane, fb->format->format, fb->modifier)) {
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index cca623eb23e5..6ec23f8e0905 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -27,8 +27,6 @@
 #include <drm/drm_fourcc.h>
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_modeset_helper.h>
-#include <drm/drm_panic_helper.h>
-#include <drm/drm_plane_helper.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 
@@ -101,80 +99,6 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct);
 
-/*
- * This is the minimal list of formats that seem to be safe for modeset use
- * with all current DRM drivers.  Most hardware can actually support more
- * formats than this and drivers may specify a more accurate list when
- * creating the primary plane.
- */
-static const uint32_t safe_modeset_formats[] = {
-	DRM_FORMAT_XRGB8888,
-	DRM_FORMAT_ARGB8888,
-};
-
-static const struct drm_plane_funcs primary_plane_funcs = {
-	DRM_PLANE_NON_ATOMIC_FUNCS,
-	DRM_PANIC_PLANE_FUNCS,
-};
-
-/**
- * drm_crtc_init - Legacy CRTC initialization function
- * @dev: DRM device
- * @crtc: CRTC object to init
- * @funcs: callbacks for the new CRTC
- *
- * Initialize a CRTC object with a default helper-provided primary plane and no
- * cursor plane.
- *
- * Note that we make some assumptions about hardware limitations that may not be
- * true for all hardware:
- *
- * 1. Primary plane cannot be repositioned.
- * 2. Primary plane cannot be scaled.
- * 3. Primary plane must cover the entire CRTC.
- * 4. Subpixel positioning is not supported.
- * 5. The primary plane must always be on if the CRTC is enabled.
- *
- * This is purely a backwards compatibility helper for old drivers. Drivers
- * should instead implement their own primary plane. Atomic drivers must do so.
- *
- * Returns:
- * Zero on success, error code on failure.
- */
-int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
-		  const struct drm_crtc_funcs *funcs)
-{
-	struct drm_plane *primary;
-	int ret;
-
-	/* possible_crtc's will be filled in later by crtc_init */
-	primary = __drm_universal_plane_alloc(dev, sizeof(*primary), 0, 0,
-					      &primary_plane_funcs,
-					      safe_modeset_formats,
-					      ARRAY_SIZE(safe_modeset_formats),
-					      NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
-	if (IS_ERR(primary))
-		return PTR_ERR(primary);
-
-	/*
-	 * Remove the format_default field from drm_plane when dropping
-	 * this helper.
-	 */
-	primary->format_default = true;
-
-	ret = drm_crtc_init_with_planes(dev, crtc, primary, NULL, funcs, NULL);
-	if (ret)
-		goto err_drm_plane_cleanup;
-
-	return 0;
-
-err_drm_plane_cleanup:
-	drm_plane_cleanup(primary);
-	kfree(primary);
-	return ret;
-}
-EXPORT_SYMBOL(drm_crtc_init);
-
 /**
  * drm_mode_config_helper_suspend - Modeset suspend helper
  * @dev: DRM device
diff --git a/include/drm/drm_modeset_helper.h b/include/drm/drm_modeset_helper.h
index 7e3d4c5a7f66..6b9421aee536 100644
--- a/include/drm/drm_modeset_helper.h
+++ b/include/drm/drm_modeset_helper.h
@@ -37,9 +37,6 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 				    const struct drm_format_info *info,
 				    const struct drm_mode_fb_cmd2 *mode_cmd);
 
-int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
-		  const struct drm_crtc_funcs *funcs);
-
 int drm_mode_config_helper_suspend(struct drm_device *dev);
 int drm_mode_config_helper_resume(struct drm_device *dev);
 
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 2/2] drm: Remove drm_crtc_init()
  2026-11-17 14:04 ` [PATCH v3 2/2] drm: Remove drm_crtc_init() Thomas Zimmermann
@ 2026-11-17 14:34   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-17 14:34 UTC (permalink / raw)
  To: Thomas Zimmermann; +Cc: amd-gfx, dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm: build failure in amdgpu DCE files after removing
  drm_crtc_init()
--

commit 6d664862f4e8731c606db322340f68e1b8885e4d
Author: Thomas Zimmermann <tzimmermann@suse.de>

drm: Remove drm_crtc_init()

This commit removes the legacy drm_crtc_init() helper and its associated
default primary plane structures.

> diff --git a/include/drm/drm_modeset_helper.h b/include/drm/drm_modeset_helper.h
> index 7e3d4c5a7f66d..6b9421aee5360 100644
> --- a/include/drm/drm_modeset_helper.h
> +++ b/include/drm/drm_modeset_helper.h
> @@ -37,9 +37,6 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
>  				    const struct drm_format_info *info,
>  				    const struct drm_mode_fb_cmd2 *mode_cmd);
>  
> -int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> -		  const struct drm_crtc_funcs *funcs);
> -
>  int drm_mode_config_helper_suspend(struct drm_device *dev);
>  int drm_mode_config_helper_resume(struct drm_device *dev);

[Severity: High]
As reported by kernel test robot on v2 [1], does removing drm_crtc_init()
break the build when CONFIG_DRM_AMDGPU is enabled?

Three legacy DCE display files in drivers/gpu/drm/amd/amdgpu/ still call
drm_crtc_init() in dce_v10_0_crtc_init(), dce_v8_0_crtc_init(), and
dce_v6_0_crtc_init():

drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:dce_v10_0_crtc_init() {
    ...
	drm_crtc_init(adev_to_drm(adev), &amdgpu_crtc->base, &dce_v10_0_crtc_funcs);
    ...
}

[1] https://lore.kernel.org/r/202611130312.g6BELEWG-lkp@intel.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117140750.541769-1-tzimmermann@suse.de?part=2

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-17 14:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 14:04 [PATCH v3 0/2] drm/radeon: Inline drm_crtc_init() Thomas Zimmermann
2026-11-17 14:04 ` [PATCH v3 1/2] " Thomas Zimmermann
2026-11-17 14:04 ` [PATCH v3 2/2] drm: Remove drm_crtc_init() Thomas Zimmermann
2026-11-17 14:34   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox