mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 1/4] drm/komeda: Use the bridge connector
@ 2026-11-30  2:55 Luo Liu
  2026-11-30  2:55 ` [PATCH v4 2/4] drm/komeda: Use drmm_mode_config_init() Luo Liu
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Luo Liu @ 2026-11-30  2:55 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Liviu Dudau,
	Russell King, dri-devel
  Cc: Ayan Halder, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Kory Maincent,
	Luca Ceresoli, David Airlie, Simona Vetter, linux-kernel,
	cix-kernel-upstream, Wuyi.Shen

Bridges following the new DRM bridge model no longer create a connector
themselves: the display driver has to attach them with
DRM_BRIDGE_ATTACH_NO_CONNECTOR and create one connector for the whole
chain with drm_bridge_connector_init().

Convert komeda to that model, so it keeps working with bridges that
have moved to the new one. The bridges komeda binds to in mainline
support connector-less attach, so boards using them are unaffected.

Select DRM_BRIDGE_CONNECTOR for drm_bridge_connector_init() and
DRM_DISPLAY_HELPER, as the bridge connector is only visible when the
display helper is enabled.

Signed-off-by: Luo Liu <Luo.Liu@cixtech.com>
---
 drivers/gpu/drm/arm/display/Kconfig            |  2 ++
 .../gpu/drm/arm/display/komeda/komeda_crtc.c   | 18 +++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/Kconfig b/drivers/gpu/drm/arm/display/Kconfig
index 415c10a6374b..d88fdd3808be 100644
--- a/drivers/gpu/drm/arm/display/Kconfig
+++ b/drivers/gpu/drm/arm/display/Kconfig
@@ -6,6 +6,8 @@ config DRM_KOMEDA
 	select DRM_CLIENT_SELECTION
 	select DRM_KMS_HELPER
 	select DRM_GEM_DMA_HELPER
+	select DRM_DISPLAY_HELPER
+	select DRM_BRIDGE_CONNECTOR
 	select VIDEOMODE_HELPERS
 	help
 	  Choose this option if you want to compile the ARM Komeda display
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index 0fd069fc3386..3d5f06e085fa 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -15,6 +15,7 @@
 #include <drm/drm_print.h>
 #include <drm/drm_vblank.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_bridge_connector.h>
 #include <drm/drm_panel.h>
 
 #include "komeda_dev.h"
@@ -617,6 +618,7 @@ static int komeda_attach_bridge(struct device *dev,
 				struct drm_encoder *encoder)
 {
 	struct drm_device *drm = encoder->dev;
+	struct drm_connector *connector;
 	struct drm_bridge *bridge;
 	int err;
 
@@ -626,12 +628,22 @@ static int komeda_attach_bridge(struct device *dev,
 		return dev_err_probe(dev, PTR_ERR(bridge), "remote bridge not found for pipe: %s\n",
 				     of_node_full_name(pipe->of_node));
 
-	err = drm_bridge_attach(encoder, bridge, NULL, 0);
-	if (err)
+	err = drm_bridge_attach(encoder, bridge, NULL,
+				DRM_BRIDGE_ATTACH_NO_CONNECTOR);
+	if (err) {
 		drm_err(drm, "bridge_attach() failed for pipe: %s\n",
 			of_node_full_name(pipe->of_node));
+		return err;
+	}
 
-	return err;
+	connector = drm_bridge_connector_init(drm, encoder);
+	if (IS_ERR(connector)) {
+		drm_err(drm, "bridge connector init failed for pipe: %s\n",
+			of_node_full_name(pipe->of_node));
+		return PTR_ERR(connector);
+	}
+
+	return 0;
 }
 
 static const struct drm_encoder_funcs komeda_encoder_funcs = {
-- 
2.25.1


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

* [PATCH v4 2/4] drm/komeda: Use drmm_mode_config_init()
  2026-11-30  2:55 [PATCH v4 1/4] drm/komeda: Use the bridge connector Luo Liu
@ 2026-11-30  2:55 ` Luo Liu
  2026-11-30 13:25   ` Liviu Dudau
  2026-11-30  2:55 ` [PATCH v4 3/4] drm/komeda: Free the IRQ before clearing dev_private Luo Liu
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Luo Liu @ 2026-11-30  2:55 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Liviu Dudau,
	Russell King, dri-devel
  Cc: Ayan Halder, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Kory Maincent,
	Luca Ceresoli, David Airlie, Simona Vetter, linux-kernel,
	cix-kernel-upstream, Wuyi.Shen

drm_bridge_connector_init() creates the connector with
drmm_connector_init(), which does not allow a ->destroy hook and registers
its own cleanup action instead. Calling drm_mode_config_cleanup()
explicitly drops the connector's last reference, so drm_connector_free()
ends up calling a NULL ->destroy pointer. That happens on the
komeda_kms_attach() error paths, and on unbind as soon as no other
component holds a connector reference.

Let DRM release the mode configuration: switch to drmm_mode_config_init()
and drop the explicit drm_mode_config_cleanup() calls. The managed cleanup
is registered before the connectors are created, so it runs after the
connector cleanup actions and finds an empty connector list.

The mode configuration teardown now happens after komeda_kms_detach() has
returned, so komeda can no longer rely on drm_mode_config_cleanup()
detaching the encoders' bridges before komeda_kms_cleanup_private_objs()
walks mode_config.privobj_list - the bridges are private objects there as
well, and finalizing them a second time when the encoders are cleaned up
would corrupt the list and free their state twice. Since the komeda
private objects belong to the pipeline components, finalize them by
walking the pipelines instead of the shared list.

Signed-off-by: Luo Liu <Luo.Liu@cixtech.com>
---
 .../gpu/drm/arm/display/komeda/komeda_kms.c   | 36 +++++++++++--------
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  2 +-
 .../arm/display/komeda/komeda_private_obj.c   | 23 +++++++++---
 3 files changed, 40 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index faa8b041373a..37388d45b31f 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -253,12 +253,15 @@ static const struct drm_mode_config_funcs komeda_mode_config_funcs = {
 	.atomic_commit		= drm_atomic_helper_commit,
 };
 
-static void komeda_kms_mode_config_init(struct komeda_kms_dev *kms,
-					struct komeda_dev *mdev)
+static int komeda_kms_mode_config_init(struct komeda_kms_dev *kms,
+				       struct komeda_dev *mdev)
 {
 	struct drm_mode_config *config = &kms->base.mode_config;
+	int err;
 
-	drm_mode_config_init(&kms->base);
+	err = drmm_mode_config_init(&kms->base);
+	if (err)
+		return err;
 
 	komeda_kms_setup_crtcs(kms, mdev);
 
@@ -270,6 +273,8 @@ static void komeda_kms_mode_config_init(struct komeda_kms_dev *kms,
 
 	config->funcs = &komeda_mode_config_funcs;
 	config->helper_private = &komeda_mode_config_helpers;
+
+	return 0;
 }
 
 struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
@@ -287,27 +292,29 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 
 	drm->dev_private = mdev;
 
-	komeda_kms_mode_config_init(kms, mdev);
+	err = komeda_kms_mode_config_init(kms, mdev);
+	if (err)
+		return ERR_PTR(err);
 
 	err = komeda_kms_add_private_objs(kms, mdev);
 	if (err)
-		goto cleanup_mode_config;
+		goto cleanup_private_objs;
 
 	err = komeda_kms_add_planes(kms, mdev);
 	if (err)
-		goto cleanup_mode_config;
+		goto cleanup_private_objs;
 
 	err = drm_vblank_init(drm, kms->n_crtcs);
 	if (err)
-		goto cleanup_mode_config;
+		goto cleanup_private_objs;
 
 	err = komeda_kms_add_crtcs(kms, mdev);
 	if (err)
-		goto cleanup_mode_config;
+		goto cleanup_private_objs;
 
 	err = komeda_kms_add_wb_connectors(kms, mdev);
 	if (err)
-		goto cleanup_mode_config;
+		goto cleanup_private_objs;
 
 	drm_mode_config_reset(drm);
 
@@ -315,7 +322,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 			       komeda_kms_irq_handler, IRQF_SHARED,
 			       drm->driver->name, drm);
 	if (err)
-		goto cleanup_mode_config;
+		goto cleanup_private_objs;
 
 	drm_kms_helper_poll_init(drm);
 
@@ -327,9 +334,8 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 
 free_interrupts:
 	drm_kms_helper_poll_fini(drm);
-cleanup_mode_config:
-	drm_mode_config_cleanup(drm);
-	komeda_kms_cleanup_private_objs(kms);
+cleanup_private_objs:
+	komeda_kms_cleanup_private_objs(mdev);
 	drm->dev_private = NULL;
 	return ERR_PTR(err);
 }
@@ -337,12 +343,12 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 void komeda_kms_detach(struct komeda_kms_dev *kms)
 {
 	struct drm_device *drm = &kms->base;
+	struct komeda_dev *mdev = drm->dev_private;
 
 	drm_dev_unregister(drm);
 	drm_kms_helper_poll_fini(drm);
 	drm_atomic_helper_shutdown(drm);
-	drm_mode_config_cleanup(drm);
-	komeda_kms_cleanup_private_objs(kms);
+	komeda_kms_cleanup_private_objs(mdev);
 	drm->dev_private = NULL;
 }
 
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
index 83e61c4080c2..6f1e6c1773f0 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
@@ -181,7 +181,7 @@ int komeda_kms_add_private_objs(struct komeda_kms_dev *kms,
 				struct komeda_dev *mdev);
 int komeda_kms_add_wb_connectors(struct komeda_kms_dev *kms,
 				 struct komeda_dev *mdev);
-void komeda_kms_cleanup_private_objs(struct komeda_kms_dev *kms);
+void komeda_kms_cleanup_private_objs(struct komeda_dev *mdev);
 
 void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
 			      struct komeda_events *evts);
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c b/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c
index 77b3f361091f..51be98ab570e 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c
@@ -502,11 +502,24 @@ int komeda_kms_add_private_objs(struct komeda_kms_dev *kms,
 	return 0;
 }
 
-void komeda_kms_cleanup_private_objs(struct komeda_kms_dev *kms)
+void komeda_kms_cleanup_private_objs(struct komeda_dev *mdev)
 {
-	struct drm_mode_config *config = &kms->base.mode_config;
-	struct drm_private_obj *obj, *next;
+	struct komeda_component *c;
+	struct komeda_pipeline *pipe;
+	unsigned long avail_comps;
+	int i, id;
+
+	for (i = 0; i < mdev->n_pipelines; i++) {
+		pipe = mdev->pipelines[i];
 
-	list_for_each_entry_safe(obj, next, &config->privobj_list, head)
-		drm_atomic_private_obj_fini(obj);
+		if (pipe->obj.funcs)
+			drm_atomic_private_obj_fini(&pipe->obj);
+
+		avail_comps = pipe->avail_comps;
+		for_each_set_bit(id, &avail_comps, 32) {
+			c = komeda_pipeline_get_component(pipe, id);
+			if (c && c->obj.funcs)
+				drm_atomic_private_obj_fini(&c->obj);
+		}
+	}
 }
-- 
2.25.1


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

* [PATCH v4 3/4] drm/komeda: Free the IRQ before clearing dev_private
  2026-11-30  2:55 [PATCH v4 1/4] drm/komeda: Use the bridge connector Luo Liu
  2026-11-30  2:55 ` [PATCH v4 2/4] drm/komeda: Use drmm_mode_config_init() Luo Liu
@ 2026-11-30  2:55 ` Luo Liu
  2026-11-30 13:27   ` Liviu Dudau
  2026-11-30 17:38   ` Luca Ceresoli
  2026-11-30  2:55 ` [PATCH v4 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support Luo Liu
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Luo Liu @ 2026-11-30  2:55 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Liviu Dudau,
	Russell King, dri-devel
  Cc: Ayan Halder, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Kory Maincent,
	Luca Ceresoli, David Airlie, Simona Vetter, linux-kernel,
	cix-kernel-upstream, Wuyi.Shen

The interrupt is requested with devm_request_irq(), so it remains
registered until the device is removed and its devres resources are
released. komeda_kms_detach(), and the komeda_kms_attach() error path
taken when drm_dev_register() fails, clear drm->dev_private before that,
while komeda_kms_irq_handler() still reads mdev from it. The interrupt
line is shared, so another device can raise it in that window and make
the handler dereference a NULL pointer.

Free the interrupt explicitly with devm_free_irq() before dropping
drm->dev_private. free_irq() removes the action and synchronizes with
any handler in flight, so the handler cannot run afterwards.

Fixes: 2cfb1981dd0d ("drm/komeda: Make Komeda interrupts shareable")
Signed-off-by: Luo Liu <Luo.Liu@cixtech.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index 37388d45b31f..4fabe1aba25f 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -334,6 +334,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 
 free_interrupts:
 	drm_kms_helper_poll_fini(drm);
+	devm_free_irq(drm->dev, mdev->irq, drm);
 cleanup_private_objs:
 	komeda_kms_cleanup_private_objs(mdev);
 	drm->dev_private = NULL;
@@ -348,6 +349,8 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)
 	drm_dev_unregister(drm);
 	drm_kms_helper_poll_fini(drm);
 	drm_atomic_helper_shutdown(drm);
+	/* The handler dereferences drm->dev_private, which is about to go. */
+	devm_free_irq(drm->dev, mdev->irq, drm);
 	komeda_kms_cleanup_private_objs(mdev);
 	drm->dev_private = NULL;
 }
-- 
2.25.1


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

* [PATCH v4 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support
  2026-11-30  2:55 [PATCH v4 1/4] drm/komeda: Use the bridge connector Luo Liu
  2026-11-30  2:55 ` [PATCH v4 2/4] drm/komeda: Use drmm_mode_config_init() Luo Liu
  2026-11-30  2:55 ` [PATCH v4 3/4] drm/komeda: Free the IRQ before clearing dev_private Luo Liu
@ 2026-11-30  2:55 ` Luo Liu
  2026-11-30 14:32   ` Liviu Dudau
  2026-11-30  9:53 ` [PATCH v4 1/4] drm/komeda: Use the bridge connector Kory Maincent
  2026-11-30 13:23 ` Liviu Dudau
  4 siblings, 1 reply; 11+ messages in thread
From: Luo Liu @ 2026-11-30  2:55 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Liviu Dudau,
	Russell King, dri-devel
  Cc: Ayan Halder, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Kory Maincent,
	Luca Ceresoli, David Airlie, Simona Vetter, linux-kernel,
	cix-kernel-upstream, Wuyi.Shen

When attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR, the connector is
created by drm_bridge_connector_init() and the driver's own connector
stays uninitialised. The mode set then reads an empty display_info and
always runs in DVI mode, get_eld returns an empty ELD and hotplug events
are never sent.

The connector passed to the detect and EDID read operations cannot be
cached: the bridge API forbids storing it, it is released with the DRM
device, and those operations are not always called.

Take the display information and ELD from the connector state in the
bridge atomic check, resolve the connector and adjusted mode from the
atomic state when enabling the bridge, which is where the infoframe and
audio setup now runs, report hotplug through drm_bridge_hpd_notify() for
a connector created outside the driver, and advertise interlaced mode
support through the bridge.

Since hotplug is now reported through the bridge, unregister the bridge
after the interrupt and the detect work have been stopped, so a pending
notification cannot take the HPD lock once drm_bridge_remove() has
destroyed it.

Fixes: c76a8be4feec ("drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR")
Signed-off-by: Luo Liu <Luo.Liu@cixtech.com>
---
 drivers/gpu/drm/bridge/tda998x_drv.c | 146 ++++++++++++++++++---------
 1 file changed, 97 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
index 0b966c9844e7..5a59302e09ec 100644
--- a/drivers/gpu/drm/bridge/tda998x_drv.c
+++ b/drivers/gpu/drm/bridge/tda998x_drv.c
@@ -57,9 +57,11 @@ struct tda998x_priv {
 	u8 cec_addr;
 	u8 current_page;
 	bool is_on;
+	bool rgb_quant_range_selectable;
 	bool supports_infoframes;
 	bool sink_has_audio;
 	enum hdmi_quantization_range rgb_quant_range;
+	u8 eld[MAX_ELD_BYTES];
 	u8 vip_cntrl_0;
 	u8 vip_cntrl_1;
 	u8 vip_cntrl_2;
@@ -769,6 +771,14 @@ static int tda998x_edid_delay_wait(struct tda998x_priv *priv)
 	return wait_event_killable(priv->edid_delay_waitq, !priv->edid_delay_active);
 }
 
+static enum drm_connector_status tda998x_conn_detect(struct tda998x_priv *priv)
+{
+	u8 val = cec_read(priv, REG_CEC_RXSHPDLEV);
+
+	return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected :
+			connector_status_disconnected;
+}
+
 /*
  * We need to run the KMS hotplug event helper outside of our threaded
  * interrupt routine as this can call back into our get_modes method,
@@ -778,10 +788,11 @@ static void tda998x_detect_work(struct work_struct *work)
 {
 	struct tda998x_priv *priv =
 		container_of(work, struct tda998x_priv, detect_work);
-	struct drm_device *dev = priv->connector.dev;
 
-	if (dev)
-		drm_kms_helper_hotplug_event(dev);
+	if (priv->connector.dev)
+		drm_kms_helper_hotplug_event(priv->connector.dev);
+	else
+		drm_bridge_hpd_notify(&priv->bridge, tda998x_conn_detect(priv));
 }
 
 /*
@@ -857,26 +868,27 @@ static void tda998x_write_aif(struct tda998x_priv *priv,
 }
 
 static void
-tda998x_write_avi(struct tda998x_priv *priv, const struct drm_display_mode *mode)
+tda998x_write_avi(struct tda998x_priv *priv, struct drm_connector *connector,
+		  const struct drm_display_mode *mode)
 {
 	union hdmi_infoframe frame;
 
-	drm_hdmi_avi_infoframe_from_display_mode(&frame.avi,
-						 &priv->connector, mode);
+	drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, connector, mode);
 	frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_FULL;
-	drm_hdmi_avi_infoframe_quant_range(&frame.avi, &priv->connector, mode,
+	drm_hdmi_avi_infoframe_quant_range(&frame.avi, connector, mode,
 					   priv->rgb_quant_range);
 
 	tda998x_write_if(priv, DIP_IF_FLAGS_IF2, REG_IF2_HB0, &frame);
 }
 
 static void tda998x_write_vsi(struct tda998x_priv *priv,
+			      struct drm_connector *connector,
 			      const struct drm_display_mode *mode)
 {
 	union hdmi_infoframe frame;
 
 	if (drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
-							&priv->connector,
+							connector,
 							mode))
 		reg_clear(priv, REG_DIP_IF_FLAGS, DIP_IF_FLAGS_IF1);
 	else
@@ -1154,8 +1166,7 @@ static int tda998x_audio_get_eld(struct device *dev, void *data,
 	struct tda998x_priv *priv = dev_get_drvdata(dev);
 
 	mutex_lock(&priv->audio_mutex);
-	memcpy(buf, priv->connector.eld,
-	       min(sizeof(priv->connector.eld), len));
+	memcpy(buf, priv->eld, min(sizeof(priv->eld), len));
 	mutex_unlock(&priv->audio_mutex);
 
 	return 0;
@@ -1193,14 +1204,6 @@ static int tda998x_audio_codec_init(struct tda998x_priv *priv,
 
 /* DRM connector functions */
 
-static enum drm_connector_status tda998x_conn_detect(struct tda998x_priv *priv)
-{
-	u8 val = cec_read(priv, REG_CEC_RXSHPDLEV);
-
-	return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected :
-			connector_status_disconnected;
-}
-
 static enum drm_connector_status
 tda998x_connector_detect(struct drm_connector *connector, bool force)
 {
@@ -1394,6 +1397,26 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge)
 		drm_connector_cleanup(&priv->connector);
 }
 
+static int tda998x_bridge_atomic_check(struct drm_bridge *bridge,
+				       struct drm_bridge_state *bridge_state,
+				       struct drm_crtc_state *crtc_state,
+				       struct drm_connector_state *conn_state)
+{
+	struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
+	struct drm_connector *connector = conn_state->connector;
+
+	priv->rgb_quant_range_selectable =
+		connector->display_info.rgb_quant_range_selectable;
+
+	mutex_lock(&connector->eld_mutex);
+	mutex_lock(&priv->audio_mutex);
+	memcpy(priv->eld, connector->eld, sizeof(priv->eld));
+	mutex_unlock(&priv->audio_mutex);
+	mutex_unlock(&connector->eld_mutex);
+
+	return 0;
+}
+
 static enum drm_mode_status tda998x_bridge_mode_valid(struct drm_bridge *bridge,
 				     const struct drm_display_info *info,
 				     const struct drm_display_mode *mode)
@@ -1411,9 +1434,59 @@ static enum drm_mode_status tda998x_bridge_mode_valid(struct drm_bridge *bridge,
 }
 
 static void tda998x_bridge_enable(struct drm_bridge *bridge,
-				  struct drm_atomic_commit *commit)
+				  struct drm_atomic_commit *state)
 {
 	struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
+	struct drm_connector *connector;
+	struct drm_connector_state *conn_state;
+	struct drm_crtc_state *crtc_state;
+	const struct drm_display_mode *adjusted_mode;
+	u8 reg;
+
+	connector = drm_atomic_get_new_connector_for_encoder(state,
+							     bridge->encoder);
+	conn_state = drm_atomic_get_new_connector_state(state, connector);
+
+	mutex_lock(&priv->audio_mutex);
+
+	if (conn_state && conn_state->crtc) {
+		crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
+		adjusted_mode = &crtc_state->adjusted_mode;
+
+		/*
+		 * CEA-861B section 6 says that:
+		 * CEA version 1 (CEA-861) has no support for infoframes.
+		 * CEA version 2 (CEA-861A) supports version 1 AVI infoframes,
+		 * and optional basic audio.
+		 * CEA version 3 (CEA-861B) supports version 1 and 2 AVI infoframes,
+		 * and optional digital audio, with audio infoframes.
+		 *
+		 * Since we only support generation of version 2 AVI infoframes,
+		 * ignore CEA version 2 and below (iow, behave as if we're a
+		 * CEA-861 source.)
+		 */
+		priv->supports_infoframes = connector->display_info.cea_rev >= 3;
+
+		if (priv->supports_infoframes) {
+			/* We need to turn HDMI HDCP stuff on to get audio through */
+			reg = TBG_CNTRL_1_TGL_EN;
+			if (crtc_state->mode.flags & DRM_MODE_FLAG_NHSYNC)
+				reg |= TBG_CNTRL_1_H_TGL;
+			if (crtc_state->mode.flags & DRM_MODE_FLAG_NVSYNC)
+				reg |= TBG_CNTRL_1_V_TGL;
+			reg_write(priv, REG_TBG_CNTRL_1, reg);
+			reg_write(priv, REG_ENC_CNTRL, ENC_CNTRL_CTL_CODE(1));
+			reg_set(priv, REG_TX33, TX33_HDMI);
+
+			tda998x_write_avi(priv, connector, adjusted_mode);
+			tda998x_write_vsi(priv, connector, adjusted_mode);
+
+			if (priv->sink_has_audio)
+				tda998x_configure_audio(priv);
+		}
+	}
+
+	mutex_unlock(&priv->audio_mutex);
 
 	if (!priv->is_on) {
 		/* enable video ports, audio will be enabled later */
@@ -1465,7 +1538,7 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
 	 * it, otherwise reduce to limited-range.
 	 */
 	priv->rgb_quant_range =
-		priv->connector.display_info.rgb_quant_range_selectable ?
+		priv->rgb_quant_range_selectable ?
 		HDMI_QUANTIZATION_RANGE_FULL :
 		drm_default_rgb_quant_range(adjusted_mode);
 
@@ -1663,33 +1736,6 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
 	/* must be last register set: */
 	reg_write(priv, REG_TBG_CNTRL_0, 0);
 
-	/* CEA-861B section 6 says that:
-	 * CEA version 1 (CEA-861) has no support for infoframes.
-	 * CEA version 2 (CEA-861A) supports version 1 AVI infoframes,
-	 * and optional basic audio.
-	 * CEA version 3 (CEA-861B) supports version 1 and 2 AVI infoframes,
-	 * and optional digital audio, with audio infoframes.
-	 *
-	 * Since we only support generation of version 2 AVI infoframes,
-	 * ignore CEA version 2 and below (iow, behave as if we're a
-	 * CEA-861 source.)
-	 */
-	priv->supports_infoframes = priv->connector.display_info.cea_rev >= 3;
-
-	if (priv->supports_infoframes) {
-		/* We need to turn HDMI HDCP stuff on to get audio through */
-		reg &= ~TBG_CNTRL_1_DWIN_DIS;
-		reg_write(priv, REG_TBG_CNTRL_1, reg);
-		reg_write(priv, REG_ENC_CNTRL, ENC_CNTRL_CTL_CODE(1));
-		reg_set(priv, REG_TX33, TX33_HDMI);
-
-		tda998x_write_avi(priv, adjusted_mode);
-		tda998x_write_vsi(priv, adjusted_mode);
-
-		if (priv->sink_has_audio)
-			tda998x_configure_audio(priv);
-	}
-
 	mutex_unlock(&priv->audio_mutex);
 }
 
@@ -1747,6 +1793,7 @@ static void tda998x_bridge_hpd_disable(struct drm_bridge *bridge)
 }
 
 static const struct drm_bridge_funcs tda998x_bridge_funcs = {
+	.atomic_check = tda998x_bridge_atomic_check,
 	.atomic_create_state = drm_atomic_helper_bridge_create_state,
 	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
 	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
@@ -2011,6 +2058,7 @@ tda998x_probe(struct i2c_client *client)
 
 	priv->bridge.ops |= DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
 	priv->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
+	priv->bridge.interlace_allowed = true;
 	drm_bridge_add(&priv->bridge);
 
 	return 0;
@@ -2035,8 +2083,6 @@ static void tda998x_remove(struct i2c_client *client)
 {
 	struct tda998x_priv *priv = dev_get_drvdata(&client->dev);
 
-	drm_bridge_remove(&priv->bridge);
-
 	if (priv->audio_pdev)
 		platform_device_unregister(priv->audio_pdev);
 
@@ -2053,6 +2099,8 @@ static void tda998x_remove(struct i2c_client *client)
 
 	timer_delete_sync(&priv->edid_delay_timer);
 	cancel_work_sync(&priv->detect_work);
+
+	drm_bridge_remove(&priv->bridge);
 }
 
 #ifdef CONFIG_OF
-- 
2.25.1


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

* Re: [PATCH v4 1/4] drm/komeda: Use the bridge connector
  2026-11-30  2:55 [PATCH v4 1/4] drm/komeda: Use the bridge connector Luo Liu
                   ` (2 preceding siblings ...)
  2026-11-30  2:55 ` [PATCH v4 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support Luo Liu
@ 2026-11-30  9:53 ` Kory Maincent
  2026-11-30 11:45   ` 回复: " Luo Liu
  2026-11-30 13:23 ` Liviu Dudau
  4 siblings, 1 reply; 11+ messages in thread
From: Kory Maincent @ 2026-11-30  9:53 UTC (permalink / raw)
  To: Luo Liu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Liviu Dudau, Russell King, dri-devel
  Cc: Ayan Halder, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	David Airlie, Simona Vetter, linux-kernel, cix-kernel-upstream,
	Wuyi.Shen

Missing the cover letter?
Also please send fixes separate from new features. This won't be merged 
in the same tree.

On 11/30/26 03:55, Luo Liu wrote:
> Bridges following the new DRM bridge model no longer create a connector
> themselves: the display driver has to attach them with
> DRM_BRIDGE_ATTACH_NO_CONNECTOR and create one connector for the whole
> chain with drm_bridge_connector_init().
> 
> Convert komeda to that model, so it keeps working with bridges that
> have moved to the new one. The bridges komeda binds to in mainline
> support connector-less attach, so boards using them are unaffected.
> 
> Select DRM_BRIDGE_CONNECTOR for drm_bridge_connector_init() and
> DRM_DISPLAY_HELPER, as the bridge connector is only visible when the
> display helper is enabled.

Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>

Thank you!
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com


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

* 回复: [PATCH v4 1/4] drm/komeda: Use the bridge connector
  2026-11-30  9:53 ` [PATCH v4 1/4] drm/komeda: Use the bridge connector Kory Maincent
@ 2026-11-30 11:45   ` Luo Liu
  0 siblings, 0 replies; 11+ messages in thread
From: Luo Liu @ 2026-11-30 11:45 UTC (permalink / raw)
  To: Kory Maincent, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Liviu Dudau, Russell King, dri-devel
  Cc: Ayan Halder, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	David Airlie, Simona Vetter, linux-kernel, cix-kernel-upstream,
	Wuyi Shen (沈武义)

Hi Kory,

	Thank you very much for your review and suggestions.

> -----邮件原件-----
> 发件人: Kory Maincent <kory.maincent@bootlin.com>
> 发送时间: 2026年11月30日 17:54
> 收件人: Luo Liu <Luo.Liu@cixtech.com>; Maarten Lankhorst
> <maarten.lankhorst@linux.intel.com>; Maxime Ripard <mripard@kernel.org>;
> Thomas Zimmermann <tzimmermann@suse.de>; Liviu Dudau
> <liviu.dudau@arm.com>; Russell King <linux@armlinux.org.uk>;
> dri-devel@lists.freedesktop.org
> 抄送: Ayan Halder <Ayan.Halder@arm.com>; Andrzej Hajda
> <andrzej.hajda@intel.com>; Neil Armstrong <neil.armstrong@linaro.org>;
> Robert Foss <rfoss@kernel.org>; Laurent Pinchart
> <laurent.pinchart@ideasonboard.com>; Jonas Karlman <jonas@kwiboo.se>;
> Jernej Skrabec <jernej.skrabec@gmail.com>; Luca Ceresoli
> <luca.ceresoli@bootlin.com>; David Airlie <airlied@gmail.com>; Simona Vetter
> <simona@ffwll.ch>; linux-kernel@vger.kernel.org; cix-kernel-upstream
> <cix-kernel-upstream@cixtech.com>; Wuyi Shen (沈武义)
> <Wuyi.Shen@cixtech.com>
> 主题: Re: [PATCH v4 1/4] drm/komeda: Use the bridge connector
> 
> EXTERNAL EMAIL
> 
> Missing the cover letter?
> Also please send fixes separate from new features. This won't be merged in the
> same tree.

I have split the series as you suggested. v5 only contains the conversion
of komeda to the new bridge connector model: the bridge connector patch
and the drmm_mode_config_init() change that the connector needs.

The the komeda detach/cleanup fixes and the tda998x DRM_BRIDGE_ATTACH_NO_CONNECTOR fix
are independent changes

Best regards,
Luo

> 
> On 11/30/26 03:55, Luo Liu wrote:
> > Bridges following the new DRM bridge model no longer create a
> > connector
> > themselves: the display driver has to attach them with
> > DRM_BRIDGE_ATTACH_NO_CONNECTOR and create one connector for the
> whole
> > chain with drm_bridge_connector_init().
> >
> > Convert komeda to that model, so it keeps working with bridges that
> > have moved to the new one. The bridges komeda binds to in mainline
> > support connector-less attach, so boards using them are unaffected.
> >
> > Select DRM_BRIDGE_CONNECTOR for drm_bridge_connector_init() and
> > DRM_DISPLAY_HELPER, as the bridge connector is only visible when the
> > display helper is enabled.
> 
> Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
> 
> Thank you!
> --
> Köry Maincent, Bootlin
> Embedded Linux and kernel engineering
> https://bootlin.com


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

* Re: [PATCH v4 1/4] drm/komeda: Use the bridge connector
  2026-11-30  2:55 [PATCH v4 1/4] drm/komeda: Use the bridge connector Luo Liu
                   ` (3 preceding siblings ...)
  2026-11-30  9:53 ` [PATCH v4 1/4] drm/komeda: Use the bridge connector Kory Maincent
@ 2026-11-30 13:23 ` Liviu Dudau
  4 siblings, 0 replies; 11+ messages in thread
From: Liviu Dudau @ 2026-11-30 13:23 UTC (permalink / raw)
  To: Luo Liu
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Russell King, dri-devel, Ayan Halder, Andrzej Hajda,
	Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Kory Maincent, Luca Ceresoli, David Airlie,
	Simona Vetter, linux-kernel, cix-kernel-upstream, Wuyi.Shen

On Mon, Nov 30, 2026 at 10:55:17AM +0800, Luo Liu wrote:
> Bridges following the new DRM bridge model no longer create a connector
> themselves: the display driver has to attach them with
> DRM_BRIDGE_ATTACH_NO_CONNECTOR and create one connector for the whole
> chain with drm_bridge_connector_init().
> 
> Convert komeda to that model, so it keeps working with bridges that
> have moved to the new one. The bridges komeda binds to in mainline
> support connector-less attach, so boards using them are unaffected.
> 
> Select DRM_BRIDGE_CONNECTOR for drm_bridge_connector_init() and
> DRM_DISPLAY_HELPER, as the bridge connector is only visible when the
> display helper is enabled.
> 
> Signed-off-by: Luo Liu <Luo.Liu@cixtech.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

Best regards,
Liviu

> ---
>  drivers/gpu/drm/arm/display/Kconfig            |  2 ++
>  .../gpu/drm/arm/display/komeda/komeda_crtc.c   | 18 +++++++++++++++---
>  2 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/Kconfig b/drivers/gpu/drm/arm/display/Kconfig
> index 415c10a6374b..d88fdd3808be 100644
> --- a/drivers/gpu/drm/arm/display/Kconfig
> +++ b/drivers/gpu/drm/arm/display/Kconfig
> @@ -6,6 +6,8 @@ config DRM_KOMEDA
>  	select DRM_CLIENT_SELECTION
>  	select DRM_KMS_HELPER
>  	select DRM_GEM_DMA_HELPER
> +	select DRM_DISPLAY_HELPER
> +	select DRM_BRIDGE_CONNECTOR
>  	select VIDEOMODE_HELPERS
>  	help
>  	  Choose this option if you want to compile the ARM Komeda display
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> index 0fd069fc3386..3d5f06e085fa 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
> @@ -15,6 +15,7 @@
>  #include <drm/drm_print.h>
>  #include <drm/drm_vblank.h>
>  #include <drm/drm_bridge.h>
> +#include <drm/drm_bridge_connector.h>
>  #include <drm/drm_panel.h>
>  
>  #include "komeda_dev.h"
> @@ -617,6 +618,7 @@ static int komeda_attach_bridge(struct device *dev,
>  				struct drm_encoder *encoder)
>  {
>  	struct drm_device *drm = encoder->dev;
> +	struct drm_connector *connector;
>  	struct drm_bridge *bridge;
>  	int err;
>  
> @@ -626,12 +628,22 @@ static int komeda_attach_bridge(struct device *dev,
>  		return dev_err_probe(dev, PTR_ERR(bridge), "remote bridge not found for pipe: %s\n",
>  				     of_node_full_name(pipe->of_node));
>  
> -	err = drm_bridge_attach(encoder, bridge, NULL, 0);
> -	if (err)
> +	err = drm_bridge_attach(encoder, bridge, NULL,
> +				DRM_BRIDGE_ATTACH_NO_CONNECTOR);
> +	if (err) {
>  		drm_err(drm, "bridge_attach() failed for pipe: %s\n",
>  			of_node_full_name(pipe->of_node));
> +		return err;
> +	}
>  
> -	return err;
> +	connector = drm_bridge_connector_init(drm, encoder);
> +	if (IS_ERR(connector)) {
> +		drm_err(drm, "bridge connector init failed for pipe: %s\n",
> +			of_node_full_name(pipe->of_node));
> +		return PTR_ERR(connector);
> +	}
> +
> +	return 0;
>  }
>  
>  static const struct drm_encoder_funcs komeda_encoder_funcs = {
> -- 
> 2.25.1
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

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

* Re: [PATCH v4 2/4] drm/komeda: Use drmm_mode_config_init()
  2026-11-30  2:55 ` [PATCH v4 2/4] drm/komeda: Use drmm_mode_config_init() Luo Liu
@ 2026-11-30 13:25   ` Liviu Dudau
  0 siblings, 0 replies; 11+ messages in thread
From: Liviu Dudau @ 2026-11-30 13:25 UTC (permalink / raw)
  To: Luo Liu
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Russell King, dri-devel, Ayan Halder, Andrzej Hajda,
	Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Kory Maincent, Luca Ceresoli, David Airlie,
	Simona Vetter, linux-kernel, cix-kernel-upstream, Wuyi.Shen

On Mon, Nov 30, 2026 at 10:55:18AM +0800, Luo Liu wrote:
> drm_bridge_connector_init() creates the connector with
> drmm_connector_init(), which does not allow a ->destroy hook and registers
> its own cleanup action instead. Calling drm_mode_config_cleanup()
> explicitly drops the connector's last reference, so drm_connector_free()
> ends up calling a NULL ->destroy pointer. That happens on the
> komeda_kms_attach() error paths, and on unbind as soon as no other
> component holds a connector reference.
> 
> Let DRM release the mode configuration: switch to drmm_mode_config_init()
> and drop the explicit drm_mode_config_cleanup() calls. The managed cleanup
> is registered before the connectors are created, so it runs after the
> connector cleanup actions and finds an empty connector list.
> 
> The mode configuration teardown now happens after komeda_kms_detach() has
> returned, so komeda can no longer rely on drm_mode_config_cleanup()
> detaching the encoders' bridges before komeda_kms_cleanup_private_objs()
> walks mode_config.privobj_list - the bridges are private objects there as
> well, and finalizing them a second time when the encoders are cleaned up
> would corrupt the list and free their state twice. Since the komeda
> private objects belong to the pipeline components, finalize them by
> walking the pipelines instead of the shared list.
> 
> Signed-off-by: Luo Liu <Luo.Liu@cixtech.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

Best regards,
Liviu

> ---
>  .../gpu/drm/arm/display/komeda/komeda_kms.c   | 36 +++++++++++--------
>  .../gpu/drm/arm/display/komeda/komeda_kms.h   |  2 +-
>  .../arm/display/komeda/komeda_private_obj.c   | 23 +++++++++---
>  3 files changed, 40 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> index faa8b041373a..37388d45b31f 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> @@ -253,12 +253,15 @@ static const struct drm_mode_config_funcs komeda_mode_config_funcs = {
>  	.atomic_commit		= drm_atomic_helper_commit,
>  };
>  
> -static void komeda_kms_mode_config_init(struct komeda_kms_dev *kms,
> -					struct komeda_dev *mdev)
> +static int komeda_kms_mode_config_init(struct komeda_kms_dev *kms,
> +				       struct komeda_dev *mdev)
>  {
>  	struct drm_mode_config *config = &kms->base.mode_config;
> +	int err;
>  
> -	drm_mode_config_init(&kms->base);
> +	err = drmm_mode_config_init(&kms->base);
> +	if (err)
> +		return err;
>  
>  	komeda_kms_setup_crtcs(kms, mdev);
>  
> @@ -270,6 +273,8 @@ static void komeda_kms_mode_config_init(struct komeda_kms_dev *kms,
>  
>  	config->funcs = &komeda_mode_config_funcs;
>  	config->helper_private = &komeda_mode_config_helpers;
> +
> +	return 0;
>  }
>  
>  struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
> @@ -287,27 +292,29 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
>  
>  	drm->dev_private = mdev;
>  
> -	komeda_kms_mode_config_init(kms, mdev);
> +	err = komeda_kms_mode_config_init(kms, mdev);
> +	if (err)
> +		return ERR_PTR(err);
>  
>  	err = komeda_kms_add_private_objs(kms, mdev);
>  	if (err)
> -		goto cleanup_mode_config;
> +		goto cleanup_private_objs;
>  
>  	err = komeda_kms_add_planes(kms, mdev);
>  	if (err)
> -		goto cleanup_mode_config;
> +		goto cleanup_private_objs;
>  
>  	err = drm_vblank_init(drm, kms->n_crtcs);
>  	if (err)
> -		goto cleanup_mode_config;
> +		goto cleanup_private_objs;
>  
>  	err = komeda_kms_add_crtcs(kms, mdev);
>  	if (err)
> -		goto cleanup_mode_config;
> +		goto cleanup_private_objs;
>  
>  	err = komeda_kms_add_wb_connectors(kms, mdev);
>  	if (err)
> -		goto cleanup_mode_config;
> +		goto cleanup_private_objs;
>  
>  	drm_mode_config_reset(drm);
>  
> @@ -315,7 +322,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
>  			       komeda_kms_irq_handler, IRQF_SHARED,
>  			       drm->driver->name, drm);
>  	if (err)
> -		goto cleanup_mode_config;
> +		goto cleanup_private_objs;
>  
>  	drm_kms_helper_poll_init(drm);
>  
> @@ -327,9 +334,8 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
>  
>  free_interrupts:
>  	drm_kms_helper_poll_fini(drm);
> -cleanup_mode_config:
> -	drm_mode_config_cleanup(drm);
> -	komeda_kms_cleanup_private_objs(kms);
> +cleanup_private_objs:
> +	komeda_kms_cleanup_private_objs(mdev);
>  	drm->dev_private = NULL;
>  	return ERR_PTR(err);
>  }
> @@ -337,12 +343,12 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
>  void komeda_kms_detach(struct komeda_kms_dev *kms)
>  {
>  	struct drm_device *drm = &kms->base;
> +	struct komeda_dev *mdev = drm->dev_private;
>  
>  	drm_dev_unregister(drm);
>  	drm_kms_helper_poll_fini(drm);
>  	drm_atomic_helper_shutdown(drm);
> -	drm_mode_config_cleanup(drm);
> -	komeda_kms_cleanup_private_objs(kms);
> +	komeda_kms_cleanup_private_objs(mdev);
>  	drm->dev_private = NULL;
>  }
>  
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> index 83e61c4080c2..6f1e6c1773f0 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
> @@ -181,7 +181,7 @@ int komeda_kms_add_private_objs(struct komeda_kms_dev *kms,
>  				struct komeda_dev *mdev);
>  int komeda_kms_add_wb_connectors(struct komeda_kms_dev *kms,
>  				 struct komeda_dev *mdev);
> -void komeda_kms_cleanup_private_objs(struct komeda_kms_dev *kms);
> +void komeda_kms_cleanup_private_objs(struct komeda_dev *mdev);
>  
>  void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
>  			      struct komeda_events *evts);
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c b/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c
> index 77b3f361091f..51be98ab570e 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_private_obj.c
> @@ -502,11 +502,24 @@ int komeda_kms_add_private_objs(struct komeda_kms_dev *kms,
>  	return 0;
>  }
>  
> -void komeda_kms_cleanup_private_objs(struct komeda_kms_dev *kms)
> +void komeda_kms_cleanup_private_objs(struct komeda_dev *mdev)
>  {
> -	struct drm_mode_config *config = &kms->base.mode_config;
> -	struct drm_private_obj *obj, *next;
> +	struct komeda_component *c;
> +	struct komeda_pipeline *pipe;
> +	unsigned long avail_comps;
> +	int i, id;
> +
> +	for (i = 0; i < mdev->n_pipelines; i++) {
> +		pipe = mdev->pipelines[i];
>  
> -	list_for_each_entry_safe(obj, next, &config->privobj_list, head)
> -		drm_atomic_private_obj_fini(obj);
> +		if (pipe->obj.funcs)
> +			drm_atomic_private_obj_fini(&pipe->obj);
> +
> +		avail_comps = pipe->avail_comps;
> +		for_each_set_bit(id, &avail_comps, 32) {
> +			c = komeda_pipeline_get_component(pipe, id);
> +			if (c && c->obj.funcs)
> +				drm_atomic_private_obj_fini(&c->obj);
> +		}
> +	}
>  }
> -- 
> 2.25.1
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

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

* Re: [PATCH v4 3/4] drm/komeda: Free the IRQ before clearing dev_private
  2026-11-30  2:55 ` [PATCH v4 3/4] drm/komeda: Free the IRQ before clearing dev_private Luo Liu
@ 2026-11-30 13:27   ` Liviu Dudau
  2026-11-30 17:38   ` Luca Ceresoli
  1 sibling, 0 replies; 11+ messages in thread
From: Liviu Dudau @ 2026-11-30 13:27 UTC (permalink / raw)
  To: Luo Liu
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Russell King, dri-devel, Ayan Halder, Andrzej Hajda,
	Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Kory Maincent, Luca Ceresoli, David Airlie,
	Simona Vetter, linux-kernel, cix-kernel-upstream, Wuyi.Shen

On Mon, Nov 30, 2026 at 10:55:19AM +0800, Luo Liu wrote:
> The interrupt is requested with devm_request_irq(), so it remains
> registered until the device is removed and its devres resources are
> released. komeda_kms_detach(), and the komeda_kms_attach() error path
> taken when drm_dev_register() fails, clear drm->dev_private before that,
> while komeda_kms_irq_handler() still reads mdev from it. The interrupt
> line is shared, so another device can raise it in that window and make
> the handler dereference a NULL pointer.
> 
> Free the interrupt explicitly with devm_free_irq() before dropping
> drm->dev_private. free_irq() removes the action and synchronizes with
> any handler in flight, so the handler cannot run afterwards.
> 
> Fixes: 2cfb1981dd0d ("drm/komeda: Make Komeda interrupts shareable")
> Signed-off-by: Luo Liu <Luo.Liu@cixtech.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

Best regards,
Liviu

> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> index 37388d45b31f..4fabe1aba25f 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> @@ -334,6 +334,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
>  
>  free_interrupts:
>  	drm_kms_helper_poll_fini(drm);
> +	devm_free_irq(drm->dev, mdev->irq, drm);
>  cleanup_private_objs:
>  	komeda_kms_cleanup_private_objs(mdev);
>  	drm->dev_private = NULL;
> @@ -348,6 +349,8 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)
>  	drm_dev_unregister(drm);
>  	drm_kms_helper_poll_fini(drm);
>  	drm_atomic_helper_shutdown(drm);
> +	/* The handler dereferences drm->dev_private, which is about to go. */
> +	devm_free_irq(drm->dev, mdev->irq, drm);
>  	komeda_kms_cleanup_private_objs(mdev);
>  	drm->dev_private = NULL;
>  }
> -- 
> 2.25.1
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

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

* Re: [PATCH v4 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support
  2026-11-30  2:55 ` [PATCH v4 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support Luo Liu
@ 2026-11-30 14:32   ` Liviu Dudau
  0 siblings, 0 replies; 11+ messages in thread
From: Liviu Dudau @ 2026-11-30 14:32 UTC (permalink / raw)
  To: Luo Liu
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Russell King, dri-devel, Ayan Halder, Andrzej Hajda,
	Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Kory Maincent, Luca Ceresoli, David Airlie,
	Simona Vetter, linux-kernel, cix-kernel-upstream, Wuyi.Shen

On Mon, Nov 30, 2026 at 10:55:20AM +0800, Luo Liu wrote:
> When attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR, the connector is
> created by drm_bridge_connector_init() and the driver's own connector
> stays uninitialised. The mode set then reads an empty display_info and
> always runs in DVI mode, get_eld returns an empty ELD and hotplug events
> are never sent.
> 
> The connector passed to the detect and EDID read operations cannot be
> cached: the bridge API forbids storing it, it is released with the DRM
> device, and those operations are not always called.
> 
> Take the display information and ELD from the connector state in the
> bridge atomic check, resolve the connector and adjusted mode from the
> atomic state when enabling the bridge, which is where the infoframe and
> audio setup now runs, report hotplug through drm_bridge_hpd_notify() for
> a connector created outside the driver, and advertise interlaced mode
> support through the bridge.
> 
> Since hotplug is now reported through the bridge, unregister the bridge
> after the interrupt and the detect work have been stopped, so a pending
> notification cannot take the HPD lock once drm_bridge_remove() has
> destroyed it.
> 
> Fixes: c76a8be4feec ("drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR")
> Signed-off-by: Luo Liu <Luo.Liu@cixtech.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

Best regards,
Liviu

> ---
>  drivers/gpu/drm/bridge/tda998x_drv.c | 146 ++++++++++++++++++---------
>  1 file changed, 97 insertions(+), 49 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
> index 0b966c9844e7..5a59302e09ec 100644
> --- a/drivers/gpu/drm/bridge/tda998x_drv.c
> +++ b/drivers/gpu/drm/bridge/tda998x_drv.c
> @@ -57,9 +57,11 @@ struct tda998x_priv {
>  	u8 cec_addr;
>  	u8 current_page;
>  	bool is_on;
> +	bool rgb_quant_range_selectable;
>  	bool supports_infoframes;
>  	bool sink_has_audio;
>  	enum hdmi_quantization_range rgb_quant_range;
> +	u8 eld[MAX_ELD_BYTES];
>  	u8 vip_cntrl_0;
>  	u8 vip_cntrl_1;
>  	u8 vip_cntrl_2;
> @@ -769,6 +771,14 @@ static int tda998x_edid_delay_wait(struct tda998x_priv *priv)
>  	return wait_event_killable(priv->edid_delay_waitq, !priv->edid_delay_active);
>  }
>  
> +static enum drm_connector_status tda998x_conn_detect(struct tda998x_priv *priv)
> +{
> +	u8 val = cec_read(priv, REG_CEC_RXSHPDLEV);
> +
> +	return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected :
> +			connector_status_disconnected;
> +}
> +
>  /*
>   * We need to run the KMS hotplug event helper outside of our threaded
>   * interrupt routine as this can call back into our get_modes method,
> @@ -778,10 +788,11 @@ static void tda998x_detect_work(struct work_struct *work)
>  {
>  	struct tda998x_priv *priv =
>  		container_of(work, struct tda998x_priv, detect_work);
> -	struct drm_device *dev = priv->connector.dev;
>  
> -	if (dev)
> -		drm_kms_helper_hotplug_event(dev);
> +	if (priv->connector.dev)
> +		drm_kms_helper_hotplug_event(priv->connector.dev);
> +	else
> +		drm_bridge_hpd_notify(&priv->bridge, tda998x_conn_detect(priv));
>  }
>  
>  /*
> @@ -857,26 +868,27 @@ static void tda998x_write_aif(struct tda998x_priv *priv,
>  }
>  
>  static void
> -tda998x_write_avi(struct tda998x_priv *priv, const struct drm_display_mode *mode)
> +tda998x_write_avi(struct tda998x_priv *priv, struct drm_connector *connector,
> +		  const struct drm_display_mode *mode)
>  {
>  	union hdmi_infoframe frame;
>  
> -	drm_hdmi_avi_infoframe_from_display_mode(&frame.avi,
> -						 &priv->connector, mode);
> +	drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, connector, mode);
>  	frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_FULL;
> -	drm_hdmi_avi_infoframe_quant_range(&frame.avi, &priv->connector, mode,
> +	drm_hdmi_avi_infoframe_quant_range(&frame.avi, connector, mode,
>  					   priv->rgb_quant_range);
>  
>  	tda998x_write_if(priv, DIP_IF_FLAGS_IF2, REG_IF2_HB0, &frame);
>  }
>  
>  static void tda998x_write_vsi(struct tda998x_priv *priv,
> +			      struct drm_connector *connector,
>  			      const struct drm_display_mode *mode)
>  {
>  	union hdmi_infoframe frame;
>  
>  	if (drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> -							&priv->connector,
> +							connector,
>  							mode))
>  		reg_clear(priv, REG_DIP_IF_FLAGS, DIP_IF_FLAGS_IF1);
>  	else
> @@ -1154,8 +1166,7 @@ static int tda998x_audio_get_eld(struct device *dev, void *data,
>  	struct tda998x_priv *priv = dev_get_drvdata(dev);
>  
>  	mutex_lock(&priv->audio_mutex);
> -	memcpy(buf, priv->connector.eld,
> -	       min(sizeof(priv->connector.eld), len));
> +	memcpy(buf, priv->eld, min(sizeof(priv->eld), len));
>  	mutex_unlock(&priv->audio_mutex);
>  
>  	return 0;
> @@ -1193,14 +1204,6 @@ static int tda998x_audio_codec_init(struct tda998x_priv *priv,
>  
>  /* DRM connector functions */
>  
> -static enum drm_connector_status tda998x_conn_detect(struct tda998x_priv *priv)
> -{
> -	u8 val = cec_read(priv, REG_CEC_RXSHPDLEV);
> -
> -	return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected :
> -			connector_status_disconnected;
> -}
> -
>  static enum drm_connector_status
>  tda998x_connector_detect(struct drm_connector *connector, bool force)
>  {
> @@ -1394,6 +1397,26 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge)
>  		drm_connector_cleanup(&priv->connector);
>  }
>  
> +static int tda998x_bridge_atomic_check(struct drm_bridge *bridge,
> +				       struct drm_bridge_state *bridge_state,
> +				       struct drm_crtc_state *crtc_state,
> +				       struct drm_connector_state *conn_state)
> +{
> +	struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
> +	struct drm_connector *connector = conn_state->connector;
> +
> +	priv->rgb_quant_range_selectable =
> +		connector->display_info.rgb_quant_range_selectable;
> +
> +	mutex_lock(&connector->eld_mutex);
> +	mutex_lock(&priv->audio_mutex);
> +	memcpy(priv->eld, connector->eld, sizeof(priv->eld));
> +	mutex_unlock(&priv->audio_mutex);
> +	mutex_unlock(&connector->eld_mutex);
> +
> +	return 0;
> +}
> +
>  static enum drm_mode_status tda998x_bridge_mode_valid(struct drm_bridge *bridge,
>  				     const struct drm_display_info *info,
>  				     const struct drm_display_mode *mode)
> @@ -1411,9 +1434,59 @@ static enum drm_mode_status tda998x_bridge_mode_valid(struct drm_bridge *bridge,
>  }
>  
>  static void tda998x_bridge_enable(struct drm_bridge *bridge,
> -				  struct drm_atomic_commit *commit)
> +				  struct drm_atomic_commit *state)
>  {
>  	struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
> +	struct drm_connector *connector;
> +	struct drm_connector_state *conn_state;
> +	struct drm_crtc_state *crtc_state;
> +	const struct drm_display_mode *adjusted_mode;
> +	u8 reg;
> +
> +	connector = drm_atomic_get_new_connector_for_encoder(state,
> +							     bridge->encoder);
> +	conn_state = drm_atomic_get_new_connector_state(state, connector);
> +
> +	mutex_lock(&priv->audio_mutex);
> +
> +	if (conn_state && conn_state->crtc) {
> +		crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
> +		adjusted_mode = &crtc_state->adjusted_mode;
> +
> +		/*
> +		 * CEA-861B section 6 says that:
> +		 * CEA version 1 (CEA-861) has no support for infoframes.
> +		 * CEA version 2 (CEA-861A) supports version 1 AVI infoframes,
> +		 * and optional basic audio.
> +		 * CEA version 3 (CEA-861B) supports version 1 and 2 AVI infoframes,
> +		 * and optional digital audio, with audio infoframes.
> +		 *
> +		 * Since we only support generation of version 2 AVI infoframes,
> +		 * ignore CEA version 2 and below (iow, behave as if we're a
> +		 * CEA-861 source.)
> +		 */
> +		priv->supports_infoframes = connector->display_info.cea_rev >= 3;
> +
> +		if (priv->supports_infoframes) {
> +			/* We need to turn HDMI HDCP stuff on to get audio through */
> +			reg = TBG_CNTRL_1_TGL_EN;
> +			if (crtc_state->mode.flags & DRM_MODE_FLAG_NHSYNC)
> +				reg |= TBG_CNTRL_1_H_TGL;
> +			if (crtc_state->mode.flags & DRM_MODE_FLAG_NVSYNC)
> +				reg |= TBG_CNTRL_1_V_TGL;
> +			reg_write(priv, REG_TBG_CNTRL_1, reg);
> +			reg_write(priv, REG_ENC_CNTRL, ENC_CNTRL_CTL_CODE(1));
> +			reg_set(priv, REG_TX33, TX33_HDMI);
> +
> +			tda998x_write_avi(priv, connector, adjusted_mode);
> +			tda998x_write_vsi(priv, connector, adjusted_mode);
> +
> +			if (priv->sink_has_audio)
> +				tda998x_configure_audio(priv);
> +		}
> +	}
> +
> +	mutex_unlock(&priv->audio_mutex);
>  
>  	if (!priv->is_on) {
>  		/* enable video ports, audio will be enabled later */
> @@ -1465,7 +1538,7 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
>  	 * it, otherwise reduce to limited-range.
>  	 */
>  	priv->rgb_quant_range =
> -		priv->connector.display_info.rgb_quant_range_selectable ?
> +		priv->rgb_quant_range_selectable ?
>  		HDMI_QUANTIZATION_RANGE_FULL :
>  		drm_default_rgb_quant_range(adjusted_mode);
>  
> @@ -1663,33 +1736,6 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
>  	/* must be last register set: */
>  	reg_write(priv, REG_TBG_CNTRL_0, 0);
>  
> -	/* CEA-861B section 6 says that:
> -	 * CEA version 1 (CEA-861) has no support for infoframes.
> -	 * CEA version 2 (CEA-861A) supports version 1 AVI infoframes,
> -	 * and optional basic audio.
> -	 * CEA version 3 (CEA-861B) supports version 1 and 2 AVI infoframes,
> -	 * and optional digital audio, with audio infoframes.
> -	 *
> -	 * Since we only support generation of version 2 AVI infoframes,
> -	 * ignore CEA version 2 and below (iow, behave as if we're a
> -	 * CEA-861 source.)
> -	 */
> -	priv->supports_infoframes = priv->connector.display_info.cea_rev >= 3;
> -
> -	if (priv->supports_infoframes) {
> -		/* We need to turn HDMI HDCP stuff on to get audio through */
> -		reg &= ~TBG_CNTRL_1_DWIN_DIS;
> -		reg_write(priv, REG_TBG_CNTRL_1, reg);
> -		reg_write(priv, REG_ENC_CNTRL, ENC_CNTRL_CTL_CODE(1));
> -		reg_set(priv, REG_TX33, TX33_HDMI);
> -
> -		tda998x_write_avi(priv, adjusted_mode);
> -		tda998x_write_vsi(priv, adjusted_mode);
> -
> -		if (priv->sink_has_audio)
> -			tda998x_configure_audio(priv);
> -	}
> -
>  	mutex_unlock(&priv->audio_mutex);
>  }
>  
> @@ -1747,6 +1793,7 @@ static void tda998x_bridge_hpd_disable(struct drm_bridge *bridge)
>  }
>  
>  static const struct drm_bridge_funcs tda998x_bridge_funcs = {
> +	.atomic_check = tda998x_bridge_atomic_check,
>  	.atomic_create_state = drm_atomic_helper_bridge_create_state,
>  	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
>  	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
> @@ -2011,6 +2058,7 @@ tda998x_probe(struct i2c_client *client)
>  
>  	priv->bridge.ops |= DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
>  	priv->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
> +	priv->bridge.interlace_allowed = true;
>  	drm_bridge_add(&priv->bridge);
>  
>  	return 0;
> @@ -2035,8 +2083,6 @@ static void tda998x_remove(struct i2c_client *client)
>  {
>  	struct tda998x_priv *priv = dev_get_drvdata(&client->dev);
>  
> -	drm_bridge_remove(&priv->bridge);
> -
>  	if (priv->audio_pdev)
>  		platform_device_unregister(priv->audio_pdev);
>  
> @@ -2053,6 +2099,8 @@ static void tda998x_remove(struct i2c_client *client)
>  
>  	timer_delete_sync(&priv->edid_delay_timer);
>  	cancel_work_sync(&priv->detect_work);
> +
> +	drm_bridge_remove(&priv->bridge);
>  }
>  
>  #ifdef CONFIG_OF
> -- 
> 2.25.1
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

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

* Re: [PATCH v4 3/4] drm/komeda: Free the IRQ before clearing dev_private
  2026-11-30  2:55 ` [PATCH v4 3/4] drm/komeda: Free the IRQ before clearing dev_private Luo Liu
  2026-11-30 13:27   ` Liviu Dudau
@ 2026-11-30 17:38   ` Luca Ceresoli
  1 sibling, 0 replies; 11+ messages in thread
From: Luca Ceresoli @ 2026-11-30 17:38 UTC (permalink / raw)
  To: Luo Liu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Liviu Dudau, Russell King, dri-devel
  Cc: Ayan Halder, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Kory Maincent,
	Luca Ceresoli, David Airlie, Simona Vetter, linux-kernel,
	cix-kernel-upstream, Wuyi.Shen

On Mon Nov 30, 2026 at 3:55 AM CET, Luo Liu wrote:
> The interrupt is requested with devm_request_irq(), so it remains
> registered until the device is removed and its devres resources are
> released. komeda_kms_detach(), and the komeda_kms_attach() error path
> taken when drm_dev_register() fails, clear drm->dev_private before that,
> while komeda_kms_irq_handler() still reads mdev from it. The interrupt
> line is shared, so another device can raise it in that window and make
> the handler dereference a NULL pointer.
>
> Free the interrupt explicitly with devm_free_irq() before dropping
> drm->dev_private. free_irq() removes the action and synchronizes with
> any handler in flight, so the handler cannot run afterwards.
>
> Fixes: 2cfb1981dd0d ("drm/komeda: Make Komeda interrupts shareable")
> Signed-off-by: Luo Liu <Luo.Liu@cixtech.com>
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> index 37388d45b31f..4fabe1aba25f 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> @@ -334,6 +334,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
>
>  free_interrupts:
>  	drm_kms_helper_poll_fini(drm);
> +	devm_free_irq(drm->dev, mdev->irq, drm);
>  cleanup_private_objs:
>  	komeda_kms_cleanup_private_objs(mdev);
>  	drm->dev_private = NULL;
> @@ -348,6 +349,8 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)
>  	drm_dev_unregister(drm);
>  	drm_kms_helper_poll_fini(drm);
>  	drm_atomic_helper_shutdown(drm);
> +	/* The handler dereferences drm->dev_private, which is about to go. */
> +	devm_free_irq(drm->dev, mdev->irq, drm);
>  	komeda_kms_cleanup_private_objs(mdev);
>  	drm->dev_private = NULL;
>  }

I understand this is a simple and quick fix, so it's kind of OK.

However dev_private is deprecated [0]. Would you consider improving the
driver to use the recommended practice?

[0] https://elixir.bootlin.com/linux/v7.4-rc2/source/include/drm/drm_device.h#L126-L136

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30  2:55 [PATCH v4 1/4] drm/komeda: Use the bridge connector Luo Liu
2026-11-30  2:55 ` [PATCH v4 2/4] drm/komeda: Use drmm_mode_config_init() Luo Liu
2026-11-30 13:25   ` Liviu Dudau
2026-11-30  2:55 ` [PATCH v4 3/4] drm/komeda: Free the IRQ before clearing dev_private Luo Liu
2026-11-30 13:27   ` Liviu Dudau
2026-11-30 17:38   ` Luca Ceresoli
2026-11-30  2:55 ` [PATCH v4 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support Luo Liu
2026-11-30 14:32   ` Liviu Dudau
2026-11-30  9:53 ` [PATCH v4 1/4] drm/komeda: Use the bridge connector Kory Maincent
2026-11-30 11:45   ` 回复: " Luo Liu
2026-11-30 13:23 ` Liviu Dudau

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

all inboxes | Powered by JetHome®