All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/rockchip: rk3066_hdmi: convert to devm_drm_bridge_alloc() API
@ 2026-09-04 10:17 ` Johan Jonker via B4 Relay
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Jonker via B4 Relay @ 2026-09-04 10:17 UTC (permalink / raw)
  To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-rockchip, linux-arm-kernel, linux-kernel,
	Hüseyin BIYIK, Johan Jonker

From: Hüseyin BIYIK <boogiepop@gmx.com>

The function devm_drm_bridge_alloc() is the new API for allocating DRM bridges.
This conversion was missed during the initial conversion of all bridges to
the new API.

Signed-off-by: Hüseyin BIYIK <boogiepop@gmx.com>
Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---

Changed V3:
rebase
remove driver_private
---
 drivers/gpu/drm/rockchip/rk3066_hdmi.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
index f28d6a883e09..05dbbcc6f7b0 100644
--- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
+++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
@@ -702,8 +702,6 @@ rk3066_hdmi_register(struct drm_device *drm, struct rk3066_hdmi *hdmi)
 	drm_encoder_init(drm, encoder, &rk3066_hdmi_encoder_funcs,
 			 DRM_MODE_ENCODER_TMDS, NULL);
 
-	hdmi->bridge.driver_private = hdmi;
-	hdmi->bridge.funcs = &rk3066_hdmi_bridge_funcs;
 	hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
 			   DRM_BRIDGE_OP_EDID |
 			   DRM_BRIDGE_OP_HDMI |
@@ -747,9 +745,10 @@ static int rk3066_hdmi_bind(struct device *dev, struct device *master,
 	int irq;
 	int ret;
 
-	hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
-	if (!hdmi)
-		return -ENOMEM;
+	hdmi = devm_drm_bridge_alloc(dev, struct rk3066_hdmi, bridge,
+				     &rk3066_hdmi_bridge_funcs);
+	if (IS_ERR(hdmi))
+		return PTR_ERR(hdmi);
 
 	hdmi->dev = dev;
 	hdmi->drm_dev = drm;

---
base-commit: 9d80aa4617b32f5054c5aa471d06b66704854935
change-id: 20260904-drm-9d7835c33ad6

Best regards,
-- 
Johan Jonker <jbx6244@gmail.com>



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

* [PATCH v3] drm/rockchip: rk3066_hdmi: convert to devm_drm_bridge_alloc() API
@ 2026-09-04 10:17 ` Johan Jonker via B4 Relay
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Jonker via B4 Relay @ 2026-09-04 10:17 UTC (permalink / raw)
  To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-rockchip, linux-arm-kernel, linux-kernel,
	Hüseyin BIYIK, Johan Jonker

From: Hüseyin BIYIK <boogiepop@gmx.com>

The function devm_drm_bridge_alloc() is the new API for allocating DRM bridges.
This conversion was missed during the initial conversion of all bridges to
the new API.

Signed-off-by: Hüseyin BIYIK <boogiepop@gmx.com>
Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---

Changed V3:
rebase
remove driver_private
---
 drivers/gpu/drm/rockchip/rk3066_hdmi.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
index f28d6a883e09..05dbbcc6f7b0 100644
--- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
+++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
@@ -702,8 +702,6 @@ rk3066_hdmi_register(struct drm_device *drm, struct rk3066_hdmi *hdmi)
 	drm_encoder_init(drm, encoder, &rk3066_hdmi_encoder_funcs,
 			 DRM_MODE_ENCODER_TMDS, NULL);
 
-	hdmi->bridge.driver_private = hdmi;
-	hdmi->bridge.funcs = &rk3066_hdmi_bridge_funcs;
 	hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
 			   DRM_BRIDGE_OP_EDID |
 			   DRM_BRIDGE_OP_HDMI |
@@ -747,9 +745,10 @@ static int rk3066_hdmi_bind(struct device *dev, struct device *master,
 	int irq;
 	int ret;
 
-	hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
-	if (!hdmi)
-		return -ENOMEM;
+	hdmi = devm_drm_bridge_alloc(dev, struct rk3066_hdmi, bridge,
+				     &rk3066_hdmi_bridge_funcs);
+	if (IS_ERR(hdmi))
+		return PTR_ERR(hdmi);
 
 	hdmi->dev = dev;
 	hdmi->drm_dev = drm;

---
base-commit: 9d80aa4617b32f5054c5aa471d06b66704854935
change-id: 20260904-drm-9d7835c33ad6

Best regards,
-- 
Johan Jonker <jbx6244@gmail.com>



_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH v3] drm/rockchip: rk3066_hdmi: convert to devm_drm_bridge_alloc() API
@ 2026-09-04 10:17 ` Johan Jonker via B4 Relay
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Jonker @ 2026-09-04 10:17 UTC (permalink / raw)
  To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-rockchip, linux-arm-kernel, linux-kernel,
	Hüseyin BIYIK, Johan Jonker

From: Hüseyin BIYIK <boogiepop@gmx.com>

The function devm_drm_bridge_alloc() is the new API for allocating DRM bridges.
This conversion was missed during the initial conversion of all bridges to
the new API.

Signed-off-by: Hüseyin BIYIK <boogiepop@gmx.com>
Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---

Changed V3:
rebase
remove driver_private
---
 drivers/gpu/drm/rockchip/rk3066_hdmi.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
index f28d6a883e09..05dbbcc6f7b0 100644
--- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
+++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
@@ -702,8 +702,6 @@ rk3066_hdmi_register(struct drm_device *drm, struct rk3066_hdmi *hdmi)
 	drm_encoder_init(drm, encoder, &rk3066_hdmi_encoder_funcs,
 			 DRM_MODE_ENCODER_TMDS, NULL);
 
-	hdmi->bridge.driver_private = hdmi;
-	hdmi->bridge.funcs = &rk3066_hdmi_bridge_funcs;
 	hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
 			   DRM_BRIDGE_OP_EDID |
 			   DRM_BRIDGE_OP_HDMI |
@@ -747,9 +745,10 @@ static int rk3066_hdmi_bind(struct device *dev, struct device *master,
 	int irq;
 	int ret;
 
-	hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
-	if (!hdmi)
-		return -ENOMEM;
+	hdmi = devm_drm_bridge_alloc(dev, struct rk3066_hdmi, bridge,
+				     &rk3066_hdmi_bridge_funcs);
+	if (IS_ERR(hdmi))
+		return PTR_ERR(hdmi);
 
 	hdmi->dev = dev;
 	hdmi->drm_dev = drm;

---
base-commit: 9d80aa4617b32f5054c5aa471d06b66704854935
change-id: 20260904-drm-9d7835c33ad6

Best regards,
-- 
Johan Jonker <jbx6244@gmail.com>


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

* Re: [PATCH v3] drm/rockchip: rk3066_hdmi: convert to devm_drm_bridge_alloc() API
  2026-09-04 10:17 ` Johan Jonker via B4 Relay
  (?)
  (?)
@ 2026-09-04 10:27 ` sashiko-bot
  -1 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-09-04 10:27 UTC (permalink / raw)
  To: Johan Jonker; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Lifecycle mismatch: devm_* APIs used in component bind callback cause severe resource leaks, re-bind failures, and system hangs on unbind.
--

commit 55f99b0dc1074955624c3dfcd17a773dd54e5b91
Author: Hüseyin BIYIK <boogiepop@gmx.com>
Subject: drm/rockchip: rk3066_hdmi: convert to devm_drm_bridge_alloc() API

This commit converts the rk3066_hdmi driver to use the devm_drm_bridge_alloc()
API. This aligns the driver with the new standard for allocating DRM bridges
that was introduced during the initial bridge API conversion.

> diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
> index f28d6a883e099..05dbbcc6f7b03 100644
> --- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c
> +++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c
[ ... ]
> @@ -747,9 +745,10 @@ static int rk3066_hdmi_bind(struct device *dev, struct device *master,
>  	int irq;
>  	int ret;
>  
> -	hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
> -	if (!hdmi)
> -		return -ENOMEM;
> +	hdmi = devm_drm_bridge_alloc(dev, struct rk3066_hdmi, bridge,
> +				     &rk3066_hdmi_bridge_funcs);
> +	if (IS_ERR(hdmi))
> +		return PTR_ERR(hdmi);

[Severity: High]
This is a pre-existing issue, but is it safe to use device-managed APIs
like devm_drm_bridge_alloc() inside a component bind callback like
rk3066_hdmi_bind()?

Device-managed resources are tied to the platform device's probe and remove
lifecycle, not the component bind and unbind lifecycle. When
rk3066_hdmi_unbind() is called (e.g., during master deferred probe or driver
unload), the platform device isn't removed, so the devm allocations are not
released.

If the component is bound again, allocations will fail. For example,
devm_platform_ioremap_resource() will return -EBUSY because the memory
region is already claimed, completely breaking deferred probing.

Could this also cause a system hang on unbind? Since rk3066_hdmi_unbind()
calls clk_disable_unprepare() but the interrupt remains active via
devm_request_threaded_irq(), an HDMI hotplug event occurring after unbind
triggers rk3066_hdmi_hardirq(). Accessing unclocked registers there will
synchronously hang the system.

>  
>  	hdmi->dev = dev;
>  	hdmi->drm_dev = drm;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-drm-v3-1-5b36532a3b72@gmail.com?part=1

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

end of thread, other threads:[~2026-09-04 10:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 10:17 [PATCH v3] drm/rockchip: rk3066_hdmi: convert to devm_drm_bridge_alloc() API Johan Jonker via B4 Relay
2026-09-04 10:17 ` Johan Jonker
2026-09-04 10:17 ` Johan Jonker via B4 Relay
2026-09-04 10:27 ` 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.