Skip to contentSkip to conversation

drm/sun4i: Remove dependency on DRM simple helpers

PATCH Applied Diogo Silva 5 participants 9 messages Jun 23 – Jul 6

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/sun4i: Remove dependency on DRM simple helpers

Simple KMS helper are deprecated since they only add an intermediate layer between drivers and the atomic modesetting.
This patch removes the dependency on drm simple helpers from sun4i DRM drivers.

---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c |  9 ++++++---
 drivers/gpu/drm/sun4i/sun4i_lvds.c     | 10 +++++++---
 drivers/gpu/drm/sun4i/sun4i_rgb.c      | 10 +++++++---
 drivers/gpu/drm/sun4i/sun4i_tv.c       | 10 +++++++---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 10 +++++++---
 drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c  |  8 ++++++--
 6 files changed, 40 insertions(+), 17 deletions(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +6 -3
index 8f64464621c9..e99f52ebb26f 100644
@@ -24,7 +24,6 @@
 #include <drm/drm_panel.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
 
 #include <drm/display/drm_hdmi_helper.h>
 #include <drm/display/drm_hdmi_state_helper.h>
@@ -172,6 +171,10 @@ static void sun4i_hdmi_enable(struct drm_encoder *encoder,
 	writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
 }
 
+static const struct drm_encoder_funcs sun4i_hdmi_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 static const struct drm_encoder_helper_funcs sun4i_hdmi_helper_funcs = {
 	.atomic_disable	= sun4i_hdmi_disable,
 	.atomic_enable	= sun4i_hdmi_enable,
@@ -624,8 +627,8 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
 
 	drm_encoder_helper_add(&hdmi->encoder,
 			       &sun4i_hdmi_helper_funcs);
-	ret = drm_simple_encoder_init(drm, &hdmi->encoder,
-				      DRM_MODE_ENCODER_TMDS);
+	ret = drm_encoder_init(drm, &hdmi->encoder, &sun4i_hdmi_funcs,
+			       DRM_MODE_ENCODER_TMDS, NULL);
 	if (ret) {
 		dev_err(dev, "Couldn't initialise the HDMI encoder\n");
 		goto err_put_ddc_i2c;
drivers/gpu/drm/sun4i/sun4i_lvds.c +7 -3
index 6716e895ae8a..35a3f987c37a 100644
@@ -8,11 +8,11 @@
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_encoder.h>
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
 
 #include "sun4i_crtc.h"
 #include "sun4i_tcon.h"
@@ -89,6 +89,10 @@ static void sun4i_lvds_encoder_disable(struct drm_encoder *encoder)
 	}
 }
 
+static const struct drm_encoder_funcs sun4i_lvds_enc_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 static const struct drm_encoder_helper_funcs sun4i_lvds_enc_helper_funcs = {
 	.disable	= sun4i_lvds_encoder_disable,
 	.enable		= sun4i_lvds_encoder_enable,
@@ -115,8 +119,8 @@ int sun4i_lvds_init(struct drm_device *drm, struct sun4i_tcon *tcon)
 
 	drm_encoder_helper_add(&lvds->encoder,
 			       &sun4i_lvds_enc_helper_funcs);
-	ret = drm_simple_encoder_init(drm, &lvds->encoder,
-				      DRM_MODE_ENCODER_LVDS);
+	ret = drm_encoder_init(drm, &lvds->encoder, &sun4i_lvds_enc_funcs,
+			       DRM_MODE_ENCODER_LVDS, NULL);
 	if (ret) {
 		dev_err(drm->dev, "Couldn't initialise the lvds encoder\n");
 		goto err_out;
drivers/gpu/drm/sun4i/sun4i_rgb.c +7 -3
index dfb6acc42f02..9c3fbf1b949e 100644
@@ -10,11 +10,11 @@
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_encoder.h>
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
 
 #include "sun4i_crtc.h"
 #include "sun4i_tcon.h"
@@ -180,6 +180,10 @@ static void sun4i_rgb_encoder_disable(struct drm_encoder *encoder)
 	}
 }
 
+static const struct drm_encoder_funcs sun4i_rgb_enc_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 static const struct drm_encoder_helper_funcs sun4i_rgb_enc_helper_funcs = {
 	.disable	= sun4i_rgb_encoder_disable,
 	.enable		= sun4i_rgb_encoder_enable,
@@ -207,8 +211,8 @@ int sun4i_rgb_init(struct drm_device *drm, struct sun4i_tcon *tcon)
 
 	drm_encoder_helper_add(&rgb->encoder,
 			       &sun4i_rgb_enc_helper_funcs);
-	ret = drm_simple_encoder_init(drm, &rgb->encoder,
-				      DRM_MODE_ENCODER_NONE);
+	ret = drm_encoder_init(drm, &rgb->encoder, &sun4i_rgb_enc_funcs,
+			       DRM_MODE_ENCODER_NONE, NULL);
 	if (ret) {
 		dev_err(drm->dev, "Couldn't initialise the rgb encoder\n");
 		goto err_out;
drivers/gpu/drm/sun4i/sun4i_tv.c +7 -3
index 814b77f278f6..ce22f1662c0c 100644
@@ -16,11 +16,11 @@
 
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_encoder.h>
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
 
 #include "sun4i_crtc.h"
 #include "sun4i_drv.h"
@@ -391,6 +391,10 @@ static void sun4i_tv_enable(struct drm_encoder *encoder,
 			   SUN4I_TVE_EN_ENABLE);
 }
 
+static const struct drm_encoder_funcs sun4i_tv_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 static const struct drm_encoder_helper_funcs sun4i_tv_helper_funcs = {
 	.atomic_disable	= sun4i_tv_disable,
 	.atomic_enable	= sun4i_tv_enable,
@@ -474,8 +478,8 @@ static int sun4i_tv_bind(struct device *dev, struct device *master,
 
 	drm_encoder_helper_add(&tv->encoder,
 			       &sun4i_tv_helper_funcs);
-	ret = drm_simple_encoder_init(drm, &tv->encoder,
-				      DRM_MODE_ENCODER_TVDAC);
+	ret = drm_encoder_init(drm, &tv->encoder, &sun4i_tv_funcs,
+			       DRM_MODE_ENCODER_TVDAC, NULL);
 	if (ret) {
 		dev_err(dev, "Couldn't initialise the TV encoder\n");
 		goto err_disable_clk;
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +7 -3
index c35b70d83e53..f0c9f0e573d2 100644
@@ -20,11 +20,11 @@
 #include <linux/slab.h>
 
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_encoder.h>
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_panel.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
 
 #include "sun4i_crtc.h"
 #include "sun4i_tcon.h"
@@ -842,6 +842,10 @@ static const struct drm_connector_funcs sun6i_dsi_connector_funcs = {
 	.atomic_destroy_state	= drm_atomic_helper_connector_destroy_state,
 };
 
+static const struct drm_encoder_funcs sun6i_dsi_enc_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 static const struct drm_encoder_helper_funcs sun6i_dsi_enc_helper_funcs = {
 	.disable	= sun6i_dsi_encoder_disable,
 	.enable		= sun6i_dsi_encoder_enable,
@@ -1056,8 +1060,8 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master,
 
 	drm_encoder_helper_add(&dsi->encoder,
 			       &sun6i_dsi_enc_helper_funcs);
-	ret = drm_simple_encoder_init(drm, &dsi->encoder,
-				      DRM_MODE_ENCODER_DSI);
+	ret = drm_encoder_init(drm, &dsi->encoder, &sun6i_dsi_enc_funcs,
+			       DRM_MODE_ENCODER_DSI, NULL);
 	if (ret) {
 		dev_err(dsi->dev, "Couldn't initialise the DSI encoder\n");
 		return ret;
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +6 -2
index 96532709c2a7..9694ad142a7d 100644
@@ -9,8 +9,8 @@
 #include <linux/platform_device.h>
 
 #include <drm/drm_modeset_helper_vtables.h>
+#include <drm/drm_encoder.h>
 #include <drm/drm_of.h>
-#include <drm/drm_simple_kms_helper.h>
 
 #include "sun8i_dw_hdmi.h"
 #include "sun8i_tcon_top.h"
@@ -23,6 +23,9 @@ static void sun8i_dw_hdmi_encoder_mode_set(struct drm_encoder *encoder,
 
 	clk_set_rate(hdmi->clk_tmds, mode->crtc_clock * 1000);
 }
+static const struct drm_encoder_funcs sun8i_dw_hdmi_encoder_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
 
 static const struct drm_encoder_helper_funcs
 sun8i_dw_hdmi_encoder_helper_funcs = {
@@ -180,7 +183,8 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
 		goto err_disable_clk_tmds;
 
 	drm_encoder_helper_add(encoder, &sun8i_dw_hdmi_encoder_helper_funcs);
-	drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);
+	drm_encoder_init(drm, encoder, &sun8i_dw_hdmi_encoder_funcs,
+			 DRM_MODE_ENCODER_TMDS, NULL);
 
 	plat_data->mode_valid = hdmi->quirks->mode_valid;
 	plat_data->use_drm_infoframe = hdmi->quirks->use_drm_infoframe;

---
base-commit: e2a6e04d045a56c6dc61e1eb9e2a6d7cf86512cd
change-id: 20260623-sun4i_simple-25c68885e359

Best regards,

Signature · 1 line
Diogo Silva <[email protected]>
#1 lore raw
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] This problem wasn't introduced by this patch, but the return value of drm_encoder_init() is ignored in sun8i_dw_hdmi_bind(), which leads to a potential kernel panic on the error path. --

commit 2d6b8f73fd3be1e78f02ca32197b62b5da0fb174
Author: Diogo Silva <[email protected]>

drm/sun4i: Remove dependency on DRM simple helpers

Simple KMS helper are deprecated since they only add an intermediate layer between drivers and the atomic modesetting. This patch removes the dependency on drm simple helpers from sun4i DRM drivers.

Quoted 4 lines
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +0 -0
index 96532709c2a7e..9694ad142a7de 100644

[ ... ]

drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, · line 187

Quoted 7 lines
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +2 -1
@@ -180,7 +183,8 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
 		goto err_disable_clk_tmds;
 
 	drm_encoder_helper_add(encoder, &sun8i_dw_hdmi_encoder_helper_funcs);
-	drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);
+	drm_encoder_init(drm, encoder, &sun8i_dw_hdmi_encoder_funcs,
+			 DRM_MODE_ENCODER_TMDS, NULL);

[Severity: High]
This isn't a bug introduced by this patch, but the return value of drm_encoder_init() is ignored here in sun8i_dw_hdmi_bind().

If drm_encoder_init() fails, the encoder remains uninitialized. If a subsequent initialization step like dw_hdmi_bind() then fails, the execution jumps to the cleanup_encoder error path:

    cleanup_encoder:
            drm_encoder_cleanup(encoder);

Could calling drm_encoder_cleanup() on an uninitialized encoder cause a kernel panic due to dereferencing NULL pointers (such as encoder->dev or a zero-initialized list_head)? Should the return code of drm_encoder_init() be checked and handled here?

Quoted 3 lines
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +0 -0
 	plat_data->mode_valid = hdmi->quirks->mode_valid;
 	plat_data->use_drm_infoframe = hdmi->quirks->use_drm_infoframe;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to Diogo Silva

Dne torek, 23. junij 2026 ob 22:34:40 Srednjeevropski poletni čas je Diogo Silva napisal(a):

Quoted 6 lines

Simple KMS helper are deprecated since they only add an intermediate layer between drivers and the atomic modesetting.
This patch removes the dependency on drm simple helpers from sun4i DRM drivers.

This doesn't look as useful change. Is this tree-wide attempt? If so, it should be done in one go in one patch series, coordinated with DRM maintainers.

Best regards,
Jernej

author
#3 lore raw

Hey,

I saw the task to open-code the drm_simple_encoder_init in the DRM tasks, and thought that sending individual patches for each platform would be the easiest. Thomas Zimmermann, is it ok if I do all drivers at once as a patch series?

BR,
Diogo

Quoted 16 lines · Jernej Škrabec

Dne torek, 23. junij 2026 ob 22:34:40 Srednjeevropski poletni čas je Diogo Silva napisal(a):

Quoted 6 lines

Simple KMS helper are deprecated since they only add an intermediate layer between drivers and the atomic modesetting.
This patch removes the dependency on drm simple helpers from sun4i DRM drivers.

This doesn't look as useful change. Is this tree-wide attempt? If so, it should be done in one go in one patch series, coordinated with DRM maintainers.

Best regards,
Jernej

author
#4 lore raw
In reply to Jernej Škrabec

Hey,

I saw the task to open-code the drm_simple_encoder_init in the DRM tasks, and thought that sending individual patches for each platform would be the easiest. Thomas Zimmermann, is it ok if I do all drivers at once as a patch series?

BR,
Diogo

Quoted 16 lines · Jernej Škrabec

Dne torek, 23. junij 2026 ob 22:34:40 Srednjeevropski poletni čas je Diogo Silva napisal(a):

Quoted 6 lines

Simple KMS helper are deprecated since they only add an intermediate layer between drivers and the atomic modesetting.
This patch removes the dependency on drm simple helpers from sun4i DRM drivers.

This doesn't look as useful change. Is this tree-wide attempt? If so, it should be done in one go in one patch series, coordinated with DRM maintainers.

Best regards,
Jernej

author
#5 lore raw
In reply to Jernej Škrabec

Hey,

I saw the task to open-code the drm_simple_encoder_init in the DRM tasks, and thought that sending individual patches for each platform would be the easiest. Thomas Zimmermann, is it ok if I do all drivers at once as a patch series?

BR,
Diogo

Quoted 16 lines · Jernej Škrabec

Dne torek, 23. junij 2026 ob 22:34:40 Srednjeevropski poletni čas je Diogo Silva napisal(a):

Quoted 6 lines

Simple KMS helper are deprecated since they only add an intermediate layer between drivers and the atomic modesetting.
This patch removes the dependency on drm simple helpers from sun4i DRM drivers.

This doesn't look as useful change. Is this tree-wide attempt? If so, it should be done in one go in one patch series, coordinated with DRM maintainers.

Best regards,
Jernej

#6 lore raw
In reply to Jernej Škrabec

Hi

Am 27.06.26 um 08:55 schrieb Jernej Škrabec:

Quoted 10 lines

Dne torek, 23. junij 2026 ob 22:34:40 Srednjeevropski poletni čas je Diogo Silva napisal(a):

Quoted 6 lines

Simple KMS helper are deprecated since they only add an intermediate layer between drivers and the atomic modesetting.
This patch removes the dependency on drm simple helpers from sun4i DRM drivers.

This doesn't look as useful change. Is this tree-wide attempt? If so, it should be done in one go in one patch series, coordinated with DRM maintainers.

Yes, the interface is supposed to go away because it is fairly useless.  It's a low-effort task for beginners. Hence many people send out such clean-up patches for the various drivers.  If the change is acceptable to you, it would be appreciated if you could merge it into the driver.

Best regards
Thomas

Quoted 5 lines

Best regards,
Jernej

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
maintainer Reviewed-by
#7 lore raw

Dne ponedeljek, 29. junij 2026 ob 08:51:52 Srednjeevropski poletni čas je Thomas Zimmermann napisal(a):

Quoted 10 lines

Hi

Am 27.06.26 um 08:55 schrieb Jernej Škrabec:

Quoted 7 lines

Dne torek, 23. junij 2026 ob 22:34:40 Srednjeevropski poletni čas je Diogo Silva napisal(a):

Quoted 6 lines

Simple KMS helper are deprecated since they only add an intermediate layer between drivers and the atomic modesetting.
This patch removes the dependency on drm simple helpers from sun4i DRM drivers.

Quoted 8 lines
Quoted 3 lines

This doesn't look as useful change. Is this tree-wide attempt? If so, it should be done in one go in one patch series, coordinated with DRM maintainers.

Yes, the interface is supposed to go away because it is fairly useless. It's a low-effort task for beginners. Hence many people send out such clean-up patches for the various drivers. If the change is acceptable to you, it would be appreciated if you could merge it into the driver.

Ok.

Best regards,
Jernej

maintainer Applied
#8 lore raw
In reply to Diogo Silva
Quoted 6 lines · Diogo Silva

Simple KMS helper are deprecated since they only add an intermediate layer between drivers and the atomic modesetting.
This patch removes the dependency on drm simple helpers from sun4i DRM drivers.

Applied to drm-misc-next in drm-misc, thanks!

[1/1] drm/sun4i: Remove dependency on DRM simple helpers

      commit: 34d85c43b6cb3abec03d6f9d8128fb28a7e2bfdf

Best regards,

Signature · 1 line
Chen-Yu Tsai <[email protected]>