* [PATCH 0/6] drm: Open-code drm_simple_encoder_init() in several drivers
@ 2026-05-31 7:35 ` Naman Arora
0 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:35 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona, stefan,
alison.wang, jyri.sarha, tomi.valkeinen, kraxel, dmitry.osipenko,
neil.armstrong, khilman, linux-kernel, virtualization,
linux-amlogic, linux-arm-kernel, Naman Arora
drm_simple_encoder_init() is a thin wrapper around drm_encoder_init()
that provides a simple destroy-only encoder funcs struct. This series
removes the dependency on drm_simple_kms_helper in six drivers by
open-coding the encoder initialization directly.
Each patch adds a static drm_encoder_funcs struct with a destroy
callback and replaces drm_simple_encoder_init() with drm_encoder_init().
The drm_simple_kms_helper.h include is removed where it is no longer
needed.
Drivers converted in this series:
- fsl-dcu
- tidss
- virtio
- meson (encoder_cvbs, encoder_hdmi, encoder_dsi)
Naman Arora (6):
drm/fsl-dcu: Open-code drm_simple_encoder_init()
drm/tidss: Open-code drm_simple_encoder_init()
drm/virtio: Open-code drm_simple_encoder_init()
drm/meson: Open-code drm_simple_encoder_init() in encoder_cvbs
drm/meson: Open-code drm_simple_encoder_init() in encoder_hdmi
drm/meson: Open-code drm_simple_encoder_init() in encoder_dsi
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 10 +++++++---
drivers/gpu/drm/meson/meson_encoder_cvbs.c | 10 +++++++---
drivers/gpu/drm/meson/meson_encoder_dsi.c | 10 +++++++---
drivers/gpu/drm/meson/meson_encoder_hdmi.c | 10 +++++++---
drivers/gpu/drm/tidss/tidss_encoder.c | 10 +++++++---
drivers/gpu/drm/virtio/virtgpu_display.c | 8 ++++++--
6 files changed, 41 insertions(+), 17 deletions(-)
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 0/6] drm: Open-code drm_simple_encoder_init() in several drivers
@ 2026-05-31 7:35 ` Naman Arora
0 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:35 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona, stefan,
alison.wang, jyri.sarha, tomi.valkeinen, kraxel, dmitry.osipenko,
neil.armstrong, khilman, linux-kernel, virtualization,
linux-amlogic, linux-arm-kernel, Naman Arora
drm_simple_encoder_init() is a thin wrapper around drm_encoder_init()
that provides a simple destroy-only encoder funcs struct. This series
removes the dependency on drm_simple_kms_helper in six drivers by
open-coding the encoder initialization directly.
Each patch adds a static drm_encoder_funcs struct with a destroy
callback and replaces drm_simple_encoder_init() with drm_encoder_init().
The drm_simple_kms_helper.h include is removed where it is no longer
needed.
Drivers converted in this series:
- fsl-dcu
- tidss
- virtio
- meson (encoder_cvbs, encoder_hdmi, encoder_dsi)
Naman Arora (6):
drm/fsl-dcu: Open-code drm_simple_encoder_init()
drm/tidss: Open-code drm_simple_encoder_init()
drm/virtio: Open-code drm_simple_encoder_init()
drm/meson: Open-code drm_simple_encoder_init() in encoder_cvbs
drm/meson: Open-code drm_simple_encoder_init() in encoder_hdmi
drm/meson: Open-code drm_simple_encoder_init() in encoder_dsi
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 10 +++++++---
drivers/gpu/drm/meson/meson_encoder_cvbs.c | 10 +++++++---
drivers/gpu/drm/meson/meson_encoder_dsi.c | 10 +++++++---
drivers/gpu/drm/meson/meson_encoder_hdmi.c | 10 +++++++---
drivers/gpu/drm/tidss/tidss_encoder.c | 10 +++++++---
drivers/gpu/drm/virtio/virtgpu_display.c | 8 ++++++--
6 files changed, 41 insertions(+), 17 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/6] drm/fsl-dcu: Open-code drm_simple_encoder_init()
2026-05-31 7:35 ` Naman Arora
@ 2026-05-31 7:35 ` Naman Arora
-1 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:35 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona, stefan,
alison.wang, jyri.sarha, tomi.valkeinen, kraxel, dmitry.osipenko,
neil.armstrong, khilman, linux-kernel, virtualization,
linux-amlogic, linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
index 84eff7519..a16c6013e 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
@@ -14,11 +14,14 @@
#include <drm/drm_of.h>
#include <drm/drm_panel.h>
#include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include "fsl_dcu_drm_drv.h"
#include "fsl_tcon.h"
+static const struct drm_encoder_funcs fsl_dcu_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev,
struct drm_crtc *crtc)
{
@@ -31,8 +34,9 @@ int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev,
if (fsl_dev->tcon)
fsl_tcon_bypass_enable(fsl_dev->tcon);
- ret = drm_simple_encoder_init(fsl_dev->drm, encoder,
- DRM_MODE_ENCODER_LVDS);
+ ret = drm_encoder_init(fsl_dev->drm, encoder,
+ &fsl_dcu_drm_encoder_funcs,
+ DRM_MODE_ENCODER_LVDS, NULL);
if (ret < 0)
return ret;
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 1/6] drm/fsl-dcu: Open-code drm_simple_encoder_init()
@ 2026-05-31 7:35 ` Naman Arora
0 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:35 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona, stefan,
alison.wang, jyri.sarha, tomi.valkeinen, kraxel, dmitry.osipenko,
neil.armstrong, khilman, linux-kernel, virtualization,
linux-amlogic, linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
index 84eff7519..a16c6013e 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
@@ -14,11 +14,14 @@
#include <drm/drm_of.h>
#include <drm/drm_panel.h>
#include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include "fsl_dcu_drm_drv.h"
#include "fsl_tcon.h"
+static const struct drm_encoder_funcs fsl_dcu_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev,
struct drm_crtc *crtc)
{
@@ -31,8 +34,9 @@ int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev,
if (fsl_dev->tcon)
fsl_tcon_bypass_enable(fsl_dev->tcon);
- ret = drm_simple_encoder_init(fsl_dev->drm, encoder,
- DRM_MODE_ENCODER_LVDS);
+ ret = drm_encoder_init(fsl_dev->drm, encoder,
+ &fsl_dcu_drm_encoder_funcs,
+ DRM_MODE_ENCODER_LVDS, NULL);
if (ret < 0)
return ret;
--
2.20.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 2/6] drm/tidss: Open-code drm_simple_encoder_init()
2026-05-31 7:35 ` Naman Arora
@ 2026-05-31 7:35 ` Naman Arora
-1 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:35 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona, stefan,
alison.wang, jyri.sarha, tomi.valkeinen, kraxel, dmitry.osipenko,
neil.armstrong, khilman, linux-kernel, virtualization,
linux-amlogic, linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/tidss/tidss_encoder.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/tidss/tidss_encoder.c b/drivers/gpu/drm/tidss/tidss_encoder.c
index 81a04f767..4d73a271c 100644
--- a/drivers/gpu/drm/tidss/tidss_encoder.c
+++ b/drivers/gpu/drm/tidss/tidss_encoder.c
@@ -13,7 +13,6 @@
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_panel.h>
#include <drm/drm_of.h>
-#include <drm/drm_simple_kms_helper.h>
#include "tidss_crtc.h"
#include "tidss_drv.h"
@@ -81,6 +80,10 @@ static const struct drm_bridge_funcs tidss_bridge_funcs = {
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
};
+static const struct drm_encoder_funcs tidss_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int tidss_encoder_create(struct tidss_device *tidss,
struct drm_bridge *next_bridge,
u32 encoder_type, u32 possible_crtcs)
@@ -95,8 +98,9 @@ int tidss_encoder_create(struct tidss_device *tidss,
if (IS_ERR(t_enc))
return PTR_ERR(t_enc);
- ret = drm_simple_encoder_init(&tidss->ddev, &t_enc->encoder,
- encoder_type);
+ ret = drm_encoder_init(&tidss->ddev, &t_enc->encoder,
+ &tidss_drm_encoder_funcs,
+ encoder_type, NULL);
if (ret)
return ret;
--
2.20.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 2/6] drm/tidss: Open-code drm_simple_encoder_init()
@ 2026-05-31 7:35 ` Naman Arora
0 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:35 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona, stefan,
alison.wang, jyri.sarha, tomi.valkeinen, kraxel, dmitry.osipenko,
neil.armstrong, khilman, linux-kernel, virtualization,
linux-amlogic, linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/tidss/tidss_encoder.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/tidss/tidss_encoder.c b/drivers/gpu/drm/tidss/tidss_encoder.c
index 81a04f767..4d73a271c 100644
--- a/drivers/gpu/drm/tidss/tidss_encoder.c
+++ b/drivers/gpu/drm/tidss/tidss_encoder.c
@@ -13,7 +13,6 @@
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_panel.h>
#include <drm/drm_of.h>
-#include <drm/drm_simple_kms_helper.h>
#include "tidss_crtc.h"
#include "tidss_drv.h"
@@ -81,6 +80,10 @@ static const struct drm_bridge_funcs tidss_bridge_funcs = {
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
};
+static const struct drm_encoder_funcs tidss_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int tidss_encoder_create(struct tidss_device *tidss,
struct drm_bridge *next_bridge,
u32 encoder_type, u32 possible_crtcs)
@@ -95,8 +98,9 @@ int tidss_encoder_create(struct tidss_device *tidss,
if (IS_ERR(t_enc))
return PTR_ERR(t_enc);
- ret = drm_simple_encoder_init(&tidss->ddev, &t_enc->encoder,
- encoder_type);
+ ret = drm_encoder_init(&tidss->ddev, &t_enc->encoder,
+ &tidss_drm_encoder_funcs,
+ encoder_type, NULL);
if (ret)
return ret;
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 3/6] drm/virtio: Open-code drm_simple_encoder_init()
2026-05-31 7:35 ` Naman Arora
@ 2026-05-31 7:35 ` Naman Arora
-1 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:35 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona, stefan,
alison.wang, jyri.sarha, tomi.valkeinen, kraxel, dmitry.osipenko,
neil.armstrong, khilman, linux-kernel, virtualization,
linux-amlogic, linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/virtio/virtgpu_display.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index f1dae9569..5b99cce17 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -32,7 +32,6 @@
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include <drm/drm_vblank.h>
#include <drm/drm_vblank_helper.h>
@@ -271,6 +270,10 @@ static const struct drm_connector_funcs virtio_gpu_connector_funcs = {
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
};
+static const struct drm_encoder_funcs virtio_gpu_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
{
struct drm_device *dev = vgdev->ddev;
@@ -306,7 +309,8 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
if (vgdev->has_edid)
drm_connector_attach_edid_property(connector);
- drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);
+ drm_encoder_init(dev, encoder, &virtio_gpu_drm_encoder_funcs,
+ DRM_MODE_ENCODER_VIRTUAL, NULL);
drm_encoder_helper_add(encoder, &virtio_gpu_enc_helper_funcs);
encoder->possible_crtcs = 1 << index;
--
2.20.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 3/6] drm/virtio: Open-code drm_simple_encoder_init()
@ 2026-05-31 7:35 ` Naman Arora
0 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:35 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona, stefan,
alison.wang, jyri.sarha, tomi.valkeinen, kraxel, dmitry.osipenko,
neil.armstrong, khilman, linux-kernel, virtualization,
linux-amlogic, linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/virtio/virtgpu_display.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index f1dae9569..5b99cce17 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -32,7 +32,6 @@
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include <drm/drm_vblank.h>
#include <drm/drm_vblank_helper.h>
@@ -271,6 +270,10 @@ static const struct drm_connector_funcs virtio_gpu_connector_funcs = {
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
};
+static const struct drm_encoder_funcs virtio_gpu_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
{
struct drm_device *dev = vgdev->ddev;
@@ -306,7 +309,8 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
if (vgdev->has_edid)
drm_connector_attach_edid_property(connector);
- drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);
+ drm_encoder_init(dev, encoder, &virtio_gpu_drm_encoder_funcs,
+ DRM_MODE_ENCODER_VIRTUAL, NULL);
drm_encoder_helper_add(encoder, &virtio_gpu_enc_helper_funcs);
encoder->possible_crtcs = 1 << index;
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 4/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_cvbs
2026-05-31 7:35 ` Naman Arora
@ 2026-05-31 7:46 ` Naman Arora
-1 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:46 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona,
neil.armstrong, khilman, linux-kernel, linux-amlogic,
linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/meson/meson_encoder_cvbs.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
index 41071d6e0..496100ba2 100644
--- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c
+++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
@@ -18,7 +18,6 @@
#include <drm/drm_device.h>
#include <drm/drm_edid.h>
#include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include "meson_registers.h"
#include "meson_vclk.h"
@@ -218,6 +217,10 @@ static const struct drm_bridge_funcs meson_encoder_cvbs_bridge_funcs = {
.atomic_reset = drm_atomic_helper_bridge_reset,
};
+static const struct drm_encoder_funcs meson_encoder_cvbs_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int meson_encoder_cvbs_probe(struct meson_drm *priv)
{
struct drm_device *drm = priv->drm;
@@ -257,8 +260,9 @@ int meson_encoder_cvbs_probe(struct meson_drm *priv)
meson_encoder_cvbs->priv = priv;
/* Encoder */
- ret = drm_simple_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
- DRM_MODE_ENCODER_TVDAC);
+ ret = drm_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
+ &meson_encoder_cvbs_drm_encoder_funcs,
+ DRM_MODE_ENCODER_TVDAC, NULL);
if (ret)
return dev_err_probe(priv->dev, ret,
"Failed to init CVBS encoder\n");
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 4/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_cvbs
@ 2026-05-31 7:46 ` Naman Arora
0 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:46 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona,
neil.armstrong, khilman, linux-kernel, linux-amlogic,
linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/meson/meson_encoder_cvbs.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
index 41071d6e0..496100ba2 100644
--- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c
+++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
@@ -18,7 +18,6 @@
#include <drm/drm_device.h>
#include <drm/drm_edid.h>
#include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include "meson_registers.h"
#include "meson_vclk.h"
@@ -218,6 +217,10 @@ static const struct drm_bridge_funcs meson_encoder_cvbs_bridge_funcs = {
.atomic_reset = drm_atomic_helper_bridge_reset,
};
+static const struct drm_encoder_funcs meson_encoder_cvbs_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int meson_encoder_cvbs_probe(struct meson_drm *priv)
{
struct drm_device *drm = priv->drm;
@@ -257,8 +260,9 @@ int meson_encoder_cvbs_probe(struct meson_drm *priv)
meson_encoder_cvbs->priv = priv;
/* Encoder */
- ret = drm_simple_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
- DRM_MODE_ENCODER_TVDAC);
+ ret = drm_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
+ &meson_encoder_cvbs_drm_encoder_funcs,
+ DRM_MODE_ENCODER_TVDAC, NULL);
if (ret)
return dev_err_probe(priv->dev, ret,
"Failed to init CVBS encoder\n");
--
2.20.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 5/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_hdmi
2026-05-31 7:46 ` Naman Arora
@ 2026-05-31 7:46 ` Naman Arora
-1 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:46 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona,
neil.armstrong, khilman, linux-kernel, linux-amlogic,
linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/meson/meson_encoder_hdmi.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
index 1abb0572b..0a0ec34e3 100644
--- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
@@ -24,7 +24,6 @@
#include <drm/drm_device.h>
#include <drm/drm_edid.h>
#include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include <linux/media-bus-format.h>
#include <linux/videodev2.h>
@@ -369,6 +368,10 @@ static const struct drm_bridge_funcs meson_encoder_hdmi_bridge_funcs = {
.atomic_reset = drm_atomic_helper_bridge_reset,
};
+static const struct drm_encoder_funcs meson_encoder_hdmi_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int meson_encoder_hdmi_probe(struct meson_drm *priv)
{
struct meson_encoder_hdmi *meson_encoder_hdmi;
@@ -407,8 +410,9 @@ int meson_encoder_hdmi_probe(struct meson_drm *priv)
meson_encoder_hdmi->priv = priv;
/* Encoder */
- ret = drm_simple_encoder_init(priv->drm, &meson_encoder_hdmi->encoder,
- DRM_MODE_ENCODER_TMDS);
+ ret = drm_encoder_init(priv->drm, &meson_encoder_hdmi->encoder,
+ &meson_encoder_hdmi_drm_encoder_funcs,
+ DRM_MODE_ENCODER_TMDS, NULL);
if (ret) {
dev_err_probe(priv->dev, ret, "Failed to init HDMI encoder\n");
goto err_put_node;
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 5/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_hdmi
@ 2026-05-31 7:46 ` Naman Arora
0 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:46 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona,
neil.armstrong, khilman, linux-kernel, linux-amlogic,
linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/meson/meson_encoder_hdmi.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
index 1abb0572b..0a0ec34e3 100644
--- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
@@ -24,7 +24,6 @@
#include <drm/drm_device.h>
#include <drm/drm_edid.h>
#include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include <linux/media-bus-format.h>
#include <linux/videodev2.h>
@@ -369,6 +368,10 @@ static const struct drm_bridge_funcs meson_encoder_hdmi_bridge_funcs = {
.atomic_reset = drm_atomic_helper_bridge_reset,
};
+static const struct drm_encoder_funcs meson_encoder_hdmi_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int meson_encoder_hdmi_probe(struct meson_drm *priv)
{
struct meson_encoder_hdmi *meson_encoder_hdmi;
@@ -407,8 +410,9 @@ int meson_encoder_hdmi_probe(struct meson_drm *priv)
meson_encoder_hdmi->priv = priv;
/* Encoder */
- ret = drm_simple_encoder_init(priv->drm, &meson_encoder_hdmi->encoder,
- DRM_MODE_ENCODER_TMDS);
+ ret = drm_encoder_init(priv->drm, &meson_encoder_hdmi->encoder,
+ &meson_encoder_hdmi_drm_encoder_funcs,
+ DRM_MODE_ENCODER_TMDS, NULL);
if (ret) {
dev_err_probe(priv->dev, ret, "Failed to init HDMI encoder\n");
goto err_put_node;
--
2.20.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 6/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_dsi
2026-05-31 7:46 ` Naman Arora
@ 2026-05-31 7:46 ` Naman Arora
-1 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:46 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona,
neil.armstrong, khilman, linux-kernel, linux-amlogic,
linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/meson/meson_encoder_dsi.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_encoder_dsi.c b/drivers/gpu/drm/meson/meson_encoder_dsi.c
index eba246791..e14da1f71 100644
--- a/drivers/gpu/drm/meson/meson_encoder_dsi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_dsi.c
@@ -10,7 +10,6 @@
#include <linux/of_graph.h>
#include <drm/drm_atomic_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_bridge_connector.h>
#include <drm/drm_device.h>
@@ -99,6 +98,10 @@ static const struct drm_bridge_funcs meson_encoder_dsi_bridge_funcs = {
.atomic_reset = drm_atomic_helper_bridge_reset,
};
+static const struct drm_encoder_funcs meson_encoder_dsi_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int meson_encoder_dsi_probe(struct meson_drm *priv)
{
struct meson_encoder_dsi *meson_encoder_dsi;
@@ -133,8 +136,9 @@ int meson_encoder_dsi_probe(struct meson_drm *priv)
meson_encoder_dsi->priv = priv;
/* Encoder */
- ret = drm_simple_encoder_init(priv->drm, &meson_encoder_dsi->encoder,
- DRM_MODE_ENCODER_DSI);
+ ret = drm_encoder_init(priv->drm, &meson_encoder_dsi->encoder,
+ &meson_encoder_dsi_drm_encoder_funcs,
+ DRM_MODE_ENCODER_DSI, NULL);
if (ret)
return dev_err_probe(priv->dev, ret,
"Failed to init DSI encoder\n");
--
2.20.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 6/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_dsi
@ 2026-05-31 7:46 ` Naman Arora
0 siblings, 0 replies; 19+ messages in thread
From: Naman Arora @ 2026-05-31 7:46 UTC (permalink / raw)
To: dri-devel
Cc: tzimmermann, maarten.lankhorst, mripard, airlied, simona,
neil.armstrong, khilman, linux-kernel, linux-amlogic,
linux-arm-kernel, Naman Arora
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
Signed-off-by: Naman Arora <namanarora029@gmail.com>
---
drivers/gpu/drm/meson/meson_encoder_dsi.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_encoder_dsi.c b/drivers/gpu/drm/meson/meson_encoder_dsi.c
index eba246791..e14da1f71 100644
--- a/drivers/gpu/drm/meson/meson_encoder_dsi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_dsi.c
@@ -10,7 +10,6 @@
#include <linux/of_graph.h>
#include <drm/drm_atomic_helper.h>
-#include <drm/drm_simple_kms_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_bridge_connector.h>
#include <drm/drm_device.h>
@@ -99,6 +98,10 @@ static const struct drm_bridge_funcs meson_encoder_dsi_bridge_funcs = {
.atomic_reset = drm_atomic_helper_bridge_reset,
};
+static const struct drm_encoder_funcs meson_encoder_dsi_drm_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
int meson_encoder_dsi_probe(struct meson_drm *priv)
{
struct meson_encoder_dsi *meson_encoder_dsi;
@@ -133,8 +136,9 @@ int meson_encoder_dsi_probe(struct meson_drm *priv)
meson_encoder_dsi->priv = priv;
/* Encoder */
- ret = drm_simple_encoder_init(priv->drm, &meson_encoder_dsi->encoder,
- DRM_MODE_ENCODER_DSI);
+ ret = drm_encoder_init(priv->drm, &meson_encoder_dsi->encoder,
+ &meson_encoder_dsi_drm_encoder_funcs,
+ DRM_MODE_ENCODER_DSI, NULL);
if (ret)
return dev_err_probe(priv->dev, ret,
"Failed to init DSI encoder\n");
--
2.20.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 2/6] drm/tidss: Open-code drm_simple_encoder_init()
2026-05-31 7:35 ` Naman Arora
(?)
@ 2026-05-31 7:57 ` sashiko-bot
-1 siblings, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-05-31 7:57 UTC (permalink / raw)
To: Naman Arora; +Cc: neil.armstrong, linux-amlogic
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-After-Free on driver unbind or probe failure due to mixed devm/drmm lifecycles for the combined encoder/bridge structure.
--
commit b7421f2a0634d4a6488478cb165139b91f9afc7d
Author: Naman Arora <namanarora029@gmail.com>
drm/tidss: Open-code drm_simple_encoder_init()
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
> diff --git a/drivers/gpu/drm/tidss/tidss_encoder.c b/drivers/gpu/drm/tidss/tidss_encoder.c
> index 34db8d2a3792e..1841dc14c739b 100644
> --- a/drivers/gpu/drm/tidss/tidss_encoder.c
> +++ b/drivers/gpu/drm/tidss/tidss_encoder.c
[ ... ]
> @@ -95,8 +98,9 @@ int tidss_encoder_create(struct tidss_device *tidss,
> if (IS_ERR(t_enc))
> return PTR_ERR(t_enc);
>
> - ret = drm_simple_encoder_init(&tidss->ddev, &t_enc->encoder,
> - encoder_type);
> + ret = drm_encoder_init(&tidss->ddev, &t_enc->encoder,
> + &tidss_drm_encoder_funcs,
> + encoder_type, NULL);
[Severity: High]
This is a pre-existing issue, but could this mix of devm and drm lifecycles
lead to a use-after-free during driver unbind or probe failure?
The t_enc struct is allocated using devm_drm_bridge_alloc(), giving it an
initial refcount of 1. Here, drm_encoder_init() registers the embedded
t_enc->encoder. Later in this function, drm_bridge_attach() will increase
the refcount to 2.
During driver unbind, devres LIFO cleanup executes the bridge release action,
calling drm_bridge_put() and dropping the refcount to 1. Next, the drm_device
release action triggers drm_mode_config_cleanup(), which calls
drm_encoder_cleanup().
Inside drm_encoder_cleanup(), calling drm_bridge_detach() drops the final
refcount to 0, causing t_enc to be freed. Immediately after that,
drm_encoder_cleanup() accesses the now-freed encoder structure.
A similar issue appears to happen if drm_bridge_attach() fails during probe,
as devres would free t_enc, leaving a dangling pointer for
drm_mode_config_cleanup() to trip over.
> if (ret)
> return ret;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260531074627.8936-1-namanarora029@gmail.com?part=2
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/6] drm/virtio: Open-code drm_simple_encoder_init()
2026-05-31 7:35 ` Naman Arora
(?)
@ 2026-05-31 8:00 ` sashiko-bot
-1 siblings, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-05-31 8:00 UTC (permalink / raw)
To: Naman Arora; +Cc: neil.armstrong, linux-amlogic
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, meaning failures during initialization go undetected and could lead to a kernel panic or oops.
--
commit 2aea64f30defed1555346f1f9a6d96e4b1c548c9
Author: Naman Arora <namanarora029@gmail.com>
drm/virtio: Open-code drm_simple_encoder_init()
This commit replaces the drm_simple_encoder_init() wrapper with an open-coded
drm_encoder_init() in the virtio driver to remove the dependency on the
drm_simple_kms_helper.
> diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
> --- a/drivers/gpu/drm/virtio/virtgpu_display.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
[ ... ]
> @@ -306,7 +309,8 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
> if (vgdev->has_edid)
> drm_connector_attach_edid_property(connector);
>
> - drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);
> + drm_encoder_init(dev, encoder, &virtio_gpu_drm_encoder_funcs,
> + DRM_MODE_ENCODER_VIRTUAL, NULL);
[Severity: High]
This isn't a bug introduced by this patch, but should the return value of
drm_encoder_init() be checked in vgdev_output_init() here?
If drm_encoder_init() fails (for example, returning -ENOMEM if allocating
the encoder name fails), the error is ignored. Does this allow the code to
proceed and attach an incompletely initialized encoder to the connector,
potentially leading to a NULL pointer dereference or crash later when the DRM
core interacts with it?
> drm_encoder_helper_add(encoder, &virtio_gpu_enc_helper_funcs);
> encoder->possible_crtcs = 1 << index;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260531074627.8936-1-namanarora029@gmail.com?part=3
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 4/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_cvbs
2026-05-31 7:46 ` Naman Arora
` (2 preceding siblings ...)
(?)
@ 2026-05-31 8:08 ` sashiko-bot
-1 siblings, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-05-31 8:08 UTC (permalink / raw)
To: Naman Arora; +Cc: linux-amlogic, neil.armstrong
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-after-free during drm_encoder_cleanup() due to bridge refcount dropping to 0.
--
commit e742cfdccd21fa2f8380ad2c61f49c99edf808e1
Author: Naman Arora <namanarora029@gmail.com>
drm/meson: Open-code drm_simple_encoder_init() in encoder_cvbs
The helper drm_simple_encoder_init() is replaced with an open-coded
drm_encoder_init() to remove the dependency on drm_simple_kms_helper.
A simple destroy-only encoder funcs struct is added.
> diff --git a/drivers/gpu/drm/meson/meson_encoder_cvbs.c b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
> index 8b26a0031cde0..9797e3f57e0be 100644
> --- a/drivers/gpu/drm/meson/meson_encoder_cvbs.c
> +++ b/drivers/gpu/drm/meson/meson_encoder_cvbs.c
[ ... ]
> @@ -257,8 +260,9 @@ int meson_encoder_cvbs_probe(struct meson_drm *priv)
> meson_encoder_cvbs->priv = priv;
>
> /* Encoder */
> - ret = drm_simple_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
> - DRM_MODE_ENCODER_TVDAC);
> + ret = drm_encoder_init(priv->drm, &meson_encoder_cvbs->encoder,
> + &meson_encoder_cvbs_drm_encoder_funcs,
> + DRM_MODE_ENCODER_TVDAC, NULL);
[Severity: High]
This is a pre-existing issue, but does tying the encoder cleanup directly to
drm_encoder_cleanup() lead to a use-after-free during device unbind?
If the driver is unbound while userspace holds an open DRM device
reference, the platform unbind will drop the devm reference to the
meson_encoder_cvbs bridge container. The bridge is then kept alive
only by the attach reference.
When userspace finally closes the file descriptor, drm_mode_config_cleanup()
calls the encoder's destroy hook, which maps to drm_encoder_cleanup().
Inside drm_encoder_cleanup(), it drops the final bridge reference:
drm_encoder.c:drm_encoder_cleanup() {
...
list_for_each_entry_safe(bridge, next, &tmplist, chain_node)
drm_bridge_detach(bridge);
...
This frees the meson_encoder_cvbs container. However, drm_encoder_cleanup()
continues to access the embedded encoder:
drm_mode_object_unregister(dev, &encoder->base);
kfree(encoder->name);
list_del(&encoder->head);
...
memset(encoder, 0, sizeof(*encoder));
}
Could this sequence corrupt memory when it accesses the already freed
encoder structure?
> if (ret)
> return dev_err_probe(priv->dev, ret,
> "Failed to init CVBS encoder\n");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260531074627.8936-1-namanarora029@gmail.com?part=4
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 5/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_hdmi
2026-05-31 7:46 ` Naman Arora
(?)
@ 2026-05-31 8:17 ` sashiko-bot
-1 siblings, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-05-31 8:17 UTC (permalink / raw)
To: Naman Arora; +Cc: neil.armstrong, linux-amlogic
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The `drm_encoder` is embedded in a `devm`-allocated structure but is never explicitly removed from the DRM device's encoder list on unbind, leading to a use-after-free.
- [High] Memory leak and dangling bridge pointer on probe error paths due to missing `drm_bridge_remove()`.
--
commit b2fc3d021ba4d558d56f29caf06c9583a6e5c48f
Author: Naman Arora <namanarora029@gmail.com>
drm/meson: Open-code drm_simple_encoder_init() in encoder_hdmi
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
> diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
> index 55c0601df3c62..0da46af7371ea 100644
> --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
> +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
[ ... ]
> @@ -407,8 +410,9 @@ int meson_encoder_hdmi_probe(struct meson_drm *priv)
> meson_encoder_hdmi->priv = priv;
>
> /* Encoder */
> - ret = drm_simple_encoder_init(priv->drm, &meson_encoder_hdmi->encoder,
> - DRM_MODE_ENCODER_TMDS);
> + ret = drm_encoder_init(priv->drm, &meson_encoder_hdmi->encoder,
> + &meson_encoder_hdmi_drm_encoder_funcs,
> + DRM_MODE_ENCODER_TMDS, NULL);
[Severity: High]
This is a pre-existing issue, but can this lead to a use-after-free when
unbinding the device?
The meson_encoder_hdmi structure, which embeds the drm_encoder, is allocated
via devm_drm_bridge_alloc(). This means its memory is freed when the device
unbinds. However, meson_encoder_hdmi_remove() fails to call
drm_encoder_cleanup(), leaving the encoder linked in the DRM device's
mode_config.encoder_list.
If a userspace process keeps the DRM device file descriptor open, the DRM
device outlives the driver binding. When the DRM device is finally destroyed,
drm_mode_config_cleanup() iterates over the encoder_list and calls the
destroy hook on the already freed encoder:
drivers/gpu/drm/meson/meson_encoder_hdmi.c:meson_encoder_hdmi_remove() {
if (priv->encoders[MESON_ENC_HDMI]) {
meson_encoder_hdmi = priv->encoders[MESON_ENC_HDMI];
drm_bridge_remove(&meson_encoder_hdmi->bridge);
...
}
}
Is it necessary to explicitly remove the encoder from the list during remove?
> if (ret) {
> dev_err_probe(priv->dev, ret, "Failed to init HDMI encoder\n");
> goto err_put_node;
[Severity: High]
This is a pre-existing issue, but does this error path leak the bridge and
leave a dangling pointer in the global bridge list?
Earlier in meson_encoder_hdmi_probe(), drm_bridge_add() increments the
bridge's reference count and adds it to the global bridge_list:
drm_bridge_add(&meson_encoder_hdmi->bridge);
If the initialization steps fail here and jump to err_put_node, the code
returns without calling drm_bridge_remove(). The devm cleanup only drops the
initial reference taken by devm_drm_bridge_alloc().
This leaves the bridge in the global list indefinitely. Furthermore, because
the parent meson_drm structure is subsequently freed by devm upon probe
failure, meson_encoder_hdmi->priv becomes a dangling pointer. If another
driver searches the list via of_drm_find_and_get_bridge() and calls an op on
this bridge, it could dereference the freed priv structure, causing a
use-after-free crash.
Should drm_bridge_remove() be called on this and other error paths?
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260531074627.8936-1-namanarora029@gmail.com?part=5
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 6/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_dsi
2026-05-31 7:46 ` Naman Arora
(?)
@ 2026-05-31 8:25 ` sashiko-bot
-1 siblings, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-05-31 8:25 UTC (permalink / raw)
To: Naman Arora; +Cc: neil.armstrong, linux-amlogic
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The encoder atomic enable callback uses a sleeping polling function, which violates DRM atomic context rules.
--
commit 7905b259e0fff97b6803c2360bf97ff0dc74dae2
Author: Naman Arora <namanarora029@gmail.com>
drm/meson: Open-code drm_simple_encoder_init() in encoder_dsi
The helper drm_simple_encoder_init() is a thin wrapper around
drm_encoder_init() with a simple destroy-only encoder funcs struct.
Remove the dependency on drm_simple_kms_helper by open-coding the
encoder initialization directly in the driver.
> diff --git a/drivers/gpu/drm/meson/meson_encoder_dsi.c b/drivers/gpu/drm/meson/meson_encoder_dsi.c
> index c1f4685073bbc..bbb5b65cb0d94 100644
> --- a/drivers/gpu/drm/meson/meson_encoder_dsi.c
> +++ b/drivers/gpu/drm/meson/meson_encoder_dsi.c
[ ... ]
> @@ -99,6 +98,10 @@ static const struct drm_bridge_funcs meson_encoder_dsi_bridge_funcs = {
> .atomic_reset = drm_atomic_helper_bridge_reset,
> };
[Severity: High]
This is a pre-existing issue, but does this bridge configuration cause a
sleep in atomic context?
Looking at the atomic_enable path for this bridge in
drivers/gpu/drm/meson/meson_encoder_dsi.c:
meson_encoder_dsi_atomic_enable()
meson_encl_load_gamma()
meson_encl_set_gamma_table()
In drivers/gpu/drm/meson/meson_venc.c, meson_encl_set_gamma_table() calls:
readl_relaxed_poll_timeout(..., 10, 10000)
The readl_relaxed_poll_timeout macro expands to usleep_range when a non-zero
delay is provided (like 10 here), which will cause the thread to sleep.
Since bridge atomic_enable callbacks execute in an atomic context where
sleeping is strictly forbidden, could this cause kernel warnings (might_sleep)
or potential deadlocks if locks are held?
Should this code path use a non-sleeping polling mechanism such as
readl_relaxed_poll_timeout_atomic instead?
> +static const struct drm_encoder_funcs meson_encoder_dsi_drm_encoder_funcs = {
> + .destroy = drm_encoder_cleanup,
> +};
> +
> int meson_encoder_dsi_probe(struct meson_drm *priv)
> {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260531074627.8936-1-namanarora029@gmail.com?part=6
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-05-31 8:25 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-31 7:35 [PATCH 0/6] drm: Open-code drm_simple_encoder_init() in several drivers Naman Arora
2026-05-31 7:35 ` Naman Arora
2026-05-31 7:35 ` [PATCH 1/6] drm/fsl-dcu: Open-code drm_simple_encoder_init() Naman Arora
2026-05-31 7:35 ` Naman Arora
2026-05-31 7:35 ` [PATCH 2/6] drm/tidss: " Naman Arora
2026-05-31 7:35 ` Naman Arora
2026-05-31 7:57 ` sashiko-bot
2026-05-31 7:35 ` [PATCH 3/6] drm/virtio: " Naman Arora
2026-05-31 7:35 ` Naman Arora
2026-05-31 8:00 ` sashiko-bot
2026-05-31 7:46 ` [PATCH 4/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_cvbs Naman Arora
2026-05-31 7:46 ` Naman Arora
2026-05-31 7:46 ` [PATCH 5/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_hdmi Naman Arora
2026-05-31 7:46 ` Naman Arora
2026-05-31 8:17 ` sashiko-bot
2026-05-31 7:46 ` [PATCH 6/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_dsi Naman Arora
2026-05-31 7:46 ` Naman Arora
2026-05-31 8:25 ` sashiko-bot
2026-05-31 8:08 ` [PATCH 4/6] drm/meson: Open-code drm_simple_encoder_init() in encoder_cvbs sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.