Skip to contentSkip to conversation

drm: fix some bridge api misunderstandings

PATCH Applied Peter Rosin 3 participants 5 messages Aug 6, 2018 – Sep 13, 2018

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

v2 cover drm: fix some bridge api misunderstandings

Hi!

The first patch was forgotten, so I improved the commit message based on the discussion from last time, and then added a patch with a requested documentation update.

See https://lkml.org/lkml/2018/5/2/81

Cheers,
Peter

Peter Rosin (2):
drm/sti: do not remove the drm_bridge that was never added
drm: bridge: document bridge attach/detach imbalance

 drivers/gpu/drm/drm_bridge.c   | 4 ++++
 drivers/gpu/drm/sti/sti_hda.c  | 1 -
 drivers/gpu/drm/sti/sti_hdmi.c | 1 -
 3 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 1/2 drm/sti: do not remove the drm_bridge that was never added

Removing the drm_bridge_remove call should avoid a NULL dereference during list processing in drm_bridge_remove if the error path is ever taken.

The more natural approach would perhaps be to add a drm_bridge_add, but there are several other bridges that never call drm_bridge_add. Just removing the drm_bridge_remove is the easier fix.

Fixes 84601dbdea36 ("drm: sti: rework init sequence")
---
 drivers/gpu/drm/sti/sti_hda.c  | 1 -
 drivers/gpu/drm/sti/sti_hdmi.c | 1 -
 2 files changed, 2 deletions(-)
drivers/gpu/drm/sti/sti_hda.c +0 -1
index 67bbdb49fffc..199db13f565c 100644
@@ -721,7 +721,6 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data)
 	return 0;
 
 err_sysfs:
-	drm_bridge_remove(bridge);
 	return -EINVAL;
 }
 
drivers/gpu/drm/sti/sti_hdmi.c +0 -1
index 58f431102512..932724784942 100644
@@ -1315,7 +1315,6 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)
 	return 0;
 
 err_sysfs:
-	drm_bridge_remove(bridge);
 	hdmi->drm_connector = NULL;
 	return -EINVAL;
 }
Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH v2 1/2] drm/sti: do not remove the drm_bridge that was never added

2018-08-06 8:19 GMT+02:00 Peter Rosin <[email protected]>:

Quoted 11 lines

Removing the drm_bridge_remove call should avoid a NULL dereference during list processing in drm_bridge_remove if the error path is ever taken.

The more natural approach would perhaps be to add a drm_bridge_add, but there are several other bridges that never call drm_bridge_add. Just removing the drm_bridge_remove is the easier fix.

Fixes 84601dbdea36 ("drm: sti: rework init sequence")

Pushed on drm-misc-next,

Thanks,
Benjamin

Quoted 32 lines
---
 drivers/gpu/drm/sti/sti_hda.c  | 1 -
 drivers/gpu/drm/sti/sti_hdmi.c | 1 -
 2 files changed, 2 deletions(-)
drivers/gpu/drm/sti/sti_hda.c +0 -1
index 67bbdb49fffc..199db13f565c 100644
@@ -721,7 +721,6 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data)
        return 0;
 
 err_sysfs:
-       drm_bridge_remove(bridge);
        return -EINVAL;
 }
 
drivers/gpu/drm/sti/sti_hdmi.c +0 -2
index 58f431102512..932724784942 100644
@@ -1315,7 +1315,6 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)
        return 0;
 
 err_sysfs:
-       drm_bridge_remove(bridge);
        hdmi->drm_connector = NULL;
        return -EINVAL;
 }
--

2.11.0

#3 lore raw

PATCH v2 2/2 drm: bridge: document bridge attach/detach imbalance

In reply to Peter Rosin

Since 4a878c03d562 ("drm: bridge: Detach bridge from encoder at encoder cleanup time"), it is generally no longer correct to detach bridges from encoders manually. Document that.

---
 drivers/gpu/drm/drm_bridge.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_bridge.c +4 -0
index 1638bfe9627c..ba7025041e46 100644
@@ -104,6 +104,10 @@ EXPORT_SYMBOL(drm_bridge_remove);
  * If non-NULL the previous bridge must be already attached by a call to this
  * function.
  *
+ * Note that bridges attached to encoders are auto-detached during encoder
+ * cleanup in drm_encoder_cleanup(), so drm_bridge_attach() should generally
+ * *not* be balanced with a drm_bridge_detach() in driver code.
+ *
  * RETURNS:
  * Zero on success, error code on failure
  */
Signature · 1 line
2.11.0
#4 lore raw

Re: [PATCH v2 2/2] drm: bridge: document bridge attach/detach imbalance

Quoted 14 lines · Peter Rosin

Since 4a878c03d562 ("drm: bridge: Detach bridge from encoder at encoder cleanup time"), it is generally no longer correct to detach bridges from encoders manually. Document that.

---
 drivers/gpu/drm/drm_bridge.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_bridge.c +0 -0
index 1638bfe9627c..ba7025041e46 100644

drivers/gpu/drm/drm_bridge.c EXPORT_SYMBOL(drm_bridge_remove); · line 113

Quoted 10 lines
drivers/gpu/drm/drm_bridge.c +4 -0
@@ -104,6 +104,10 @@ EXPORT_SYMBOL(drm_bridge_remove);
  * If non-NULL the previous bridge must be already attached by a call to this
  * function.
  *
+ * Note that bridges attached to encoders are auto-detached during encoder
+ * cleanup in drm_encoder_cleanup(), so drm_bridge_attach() should generally
+ * *not* be balanced with a drm_bridge_detach() in driver code.
+ *
  * RETURNS:
  * Zero on success, error code on failure
  */

Pushed to drm-misc-next.

--
Regards
Andrzej

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel