Skip to contentSkip to conversation

drm/msm: use correct lifetime devices for devm_drm_bridge_add

PATCH New Dmitry Baryshkov 1 participant 4 messages Oct 11, 2023

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

cover drm/msm: use correct lifetime devices for devm_drm_bridge_add

While reworking the drm/msm driver to use devm_drm_bridge_add() I didn't notice that the drm_bridge instances are allocated with the drm_device used as a lifetime parameter instead of corresponding platform_device. This mostly works fine, in rare cases of device reprobing resulting in the oops such as the following:

Call trace:
 of_drm_find_bridge+0x54/0xa4
 drm_of_find_panel_or_bridge+0xb8/0xdc
 devm_drm_of_get_bridge+0x3c/0x8c
 msm_dsi_manager_ext_bridge_init+0x4c/0x19c
 msm_dsi_modeset_init+0x70/0x118
 _dpu_kms_drm_obj_init+0xec/0x6f0
 dpu_kms_hw_init+0x310/0x458
 msm_drm_kms_init+0x84/0x328
 msm_drm_bind+0x230/0x43c
 try_to_bring_up_aggregate_device+0x164/0x1d0
 __component_add+0xa8/0x170
 component_add+0x14/0x20
 dsi_dev_attach+0x20/0x2c
 dsi_host_attach+0x9c/0x144
 devm_mipi_dsi_attach+0x34/0xb4
 lt9611uxc_attach_dsi.isra.0+0x84/0xfc
 lt9611uxc_probe+0x5ac/0x66c
 i2c_device_probe+0x148/0x290
 really_probe+0x148/0x2ac
 __driver_probe_device+0x78/0x12c
 driver_probe_device+0x3c/0x160
 __device_attach_driver+0xb8/0x138
 bus_for_each_drv+0x80/0xdc
 __device_attach+0x9c/0x188
 device_initial_probe+0x14/0x20
 bus_probe_device+0xac/0xb0
 deferred_probe_work_func+0x8c/0xc8
 process_one_work+0x1ec/0x51c
 worker_thread+0x1ec/0x3e4
 kthread+0x120/0x124
 ret_from_fork+0x10/0x20

Dmitry Baryshkov (3):
drm/msm/dsi: use correct lifetime device for devm_drm_bridge_add drm/msm/hdmi: use correct lifetime device for devm_drm_bridge_add drm/msm/dp: use correct lifetime device for devm_drm_bridge_add

 drivers/gpu/drm/msm/dp/dp_drm.c        | 2 +-
 drivers/gpu/drm/msm/dsi/dsi_manager.c  | 2 +-
 drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/3 drm/msm/dsi: use correct lifetime device for devm_drm_bridge_add

The lifetime of the created drm_bridge is attached to the drm_device rather than the DSI's platform_device. Use correct lifetime for devm_drm_bridge_add() call.

Fixes 5f403fd7d5c2 ("drm/msm/dsi: switch to devm_drm_bridge_add()")
---
 drivers/gpu/drm/msm/dsi/dsi_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/dsi_manager.c +1 -1
index 17aa19bb6510..896f369fdd53 100644
@@ -485,7 +485,7 @@ int msm_dsi_manager_bridge_init(struct msm_dsi *msm_dsi)
 	bridge = &dsi_bridge->base;
 	bridge->funcs = &dsi_mgr_bridge_funcs;
 
-	ret = devm_drm_bridge_add(&msm_dsi->pdev->dev, bridge);
+	ret = devm_drm_bridge_add(msm_dsi->dev->dev, bridge);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/3 drm/msm/hdmi: use correct lifetime device for devm_drm_bridge_add

In reply to Dmitry Baryshkov

The lifetime of the created drm_bridge is attached to the drm_device rather than the HDMI's platform_device. Use correct lifetime for devm_drm_bridge_add() call.

Fixes 719093a67c7f ("drm/msm/hdmi: switch to devm_drm_bridge_add()")
---
 drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +1 -1
index 0b7a6a56677e..f5e01471b0b0 100644
@@ -331,7 +331,7 @@ int msm_hdmi_bridge_init(struct hdmi *hdmi)
 		DRM_BRIDGE_OP_DETECT |
 		DRM_BRIDGE_OP_EDID;
 
-	ret = devm_drm_bridge_add(&hdmi->pdev->dev, bridge);
+	ret = devm_drm_bridge_add(hdmi->dev->dev, bridge);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.39.2
#3 lore raw

PATCH 3/3 drm/msm/dp: use correct lifetime device for devm_drm_bridge_add

In reply to Dmitry Baryshkov

The lifetime of the created drm_bridge is attached to the drm_device rather than the DP's platform_device. Use correct lifetime for devm_drm_bridge_add() call.

Fixes 61a72d5efce5 ("drm/msm/dp: switch to devm_drm_bridge_add()")
---
 drivers/gpu/drm/msm/dp/dp_drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_drm.c +1 -1
index 284ff7df058a..40e7344180e3 100644
@@ -307,7 +307,7 @@ int dp_bridge_init(struct msm_dp *dp_display, struct drm_device *dev,
 			DRM_BRIDGE_OP_MODES;
 	}
 
-	rc = devm_drm_bridge_add(&dp_display->pdev->dev, bridge);
+	rc = devm_drm_bridge_add(dev->dev, bridge);
 	if (rc) {
 		DRM_ERROR("failed to add bridge, rc=%d\n", rc);
 
Signature · 1 line
2.39.2