Skip to contentSkip to conversation

drm/dp_mst: Handle torn-down topology gracefully in drm_dp_mst_topology_queue_probe()

PATCH In review Jonas Emilsson 3 participants 4 messages May 3 – May 7

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

PATCH 1/1 drm/dp_mst: Handle torn-down topology gracefully in drm_dp_mst_topology_queue_probe()

A hotplug or link-loss event can tear down the MST topology (setting mgr->mst_state = false and mgr->mst_primary = NULL) concurrently with a caller invoking drm_dp_mst_topology_queue_probe(). Since the check is already performed under mgr->lock, the condition is not a programming error but a valid race -- the topology was valid when the caller decided to call this function, but was torn down before the lock was acquired.

Replace the drm_WARN_ON() with a graceful early return. This eliminates spurious kernel warnings and the resulting compositor crashes observed when connecting/disconnecting DP MST monitors, while keeping the correct behavior of doing nothing when MST is not active. A drm_dbg_mst() trace is added so the skipped probe remains observable under MST debug logging.

The existing WARN_ON(mgr->mst_primary) in drm_dp_mst_topology_mgr_set_mst() already catches the case where the topology is initialized twice, so no diagnostic coverage is lost.

Fixes dbaeef363ea5 ("drm/dp_mst: Add a helper to queue a topology probe")
Cc Imre Deak <[email protected]>
Cc Lyude Paul <[email protected]>
---
 drivers/gpu/drm/display/drm_dp_mst_topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/display/drm_dp_mst_topology.c +3 -1
index 8757972e8..0cb341ce1 100644
@@ -3738,8 +3738,10 @@ void drm_dp_mst_topology_queue_probe(struct drm_dp_mst_topology_mgr *mgr)
 {
 	mutex_lock(&mgr->lock);
 
-	if (drm_WARN_ON(mgr->dev, !mgr->mst_state || !mgr->mst_primary))
+	if (!mgr->mst_state || !mgr->mst_primary) {
+		drm_dbg_mst(mgr->dev, "queue_probe skipped: topology torn down\n");
 		goto out_unlock;
+	}
 
 	drm_dp_mst_topology_mgr_invalidate_mstb(mgr->mst_primary);
Signature · 1 line
2.51.2
#1 lore raw

✗ LGCI.VerificationFailed: failure for drm/dp_mst: Handle torn-down topology gracefully in drm_dp_mst_topology_queue_probe()

== Series Details ==

== Series Details ==

Series: drm/dp_mst: Handle torn-down topology gracefully in drm_dp_mst_topology_queue_probe()
URL : https://patchwork.freedesktop.org/series/165902/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

Reviewed-by on v1 1/1
#2 lore raw
In reply to Jonas Emilsson

Will push upstream in just a moment

Quoted 60 lines · Jonas Emilsson

A hotplug or link-loss event can tear down the MST topology (setting mgr->mst_state = false and mgr->mst_primary = NULL) concurrently
with a caller invoking drm_dp_mst_topology_queue_probe(). Since the check
is already performed under mgr->lock, the condition is not a programming
error but a valid race -- the topology was valid when the caller decided
to call this function, but was torn down before the lock was acquired.

Replace the drm_WARN_ON() with a graceful early return. This eliminates
spurious kernel warnings and the resulting compositor crashes observed
when connecting/disconnecting DP MST monitors, while keeping the correct
behavior of doing nothing when MST is not active. A drm_dbg_mst() trace
is added so the skipped probe remains observable under MST debug logging.

The existing WARN_ON(mgr->mst_primary) in drm_dp_mst_topology_mgr_set_mst()
already catches the case where the topology is initialized twice, so no
diagnostic coverage is lost.

Fixes dbaeef363ea5 ("drm/dp_mst: Add a helper to queue a topology

probe")

---
 drivers/gpu/drm/display/drm_dp_mst_topology.c | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/display/drm_dp_mst_topology.c +3 -1
index 8757972e8..0cb341ce1 100644
@@ -3738,8 +3738,10 @@ void drm_dp_mst_topology_queue_probe(struct
 drm_dp_mst_topology_mgr *mgr)
  {
  	mutex_lock(&mgr->lock);
 
-	if (drm_WARN_ON(mgr->dev, !mgr->mst_state || !mgr-
 >mst_primary))
+	if (!mgr->mst_state || !mgr->mst_primary) {
+		drm_dbg_mst(mgr->dev, "queue_probe skipped: topology
 torn down\n");
  		goto out_unlock;
+	}

  drm_dp_mst_topology_mgr_invalidate_mstb(mgr->mst_primary);

#3 lore raw
In reply to Jonas Emilsson

Actually sorry - I need to take back the r-b, there's a couple of issues in this patch that I didn't immediately notice because it had trouble applying (though I don't have a clue why)

Quoted 47 lines · Jonas Emilsson

A hotplug or link-loss event can tear down the MST topology (setting mgr->mst_state = false and mgr->mst_primary = NULL) concurrently
with a caller invoking drm_dp_mst_topology_queue_probe(). Since the check
is already performed under mgr->lock, the condition is not a programming
error but a valid race -- the topology was valid when the caller decided
to call this function, but was torn down before the lock was acquired.

Replace the drm_WARN_ON() with a graceful early return. This eliminates
spurious kernel warnings and the resulting compositor crashes observed
when connecting/disconnecting DP MST monitors, while keeping the correct
behavior of doing nothing when MST is not active. A drm_dbg_mst() trace
is added so the skipped probe remains observable under MST debug logging.

The existing WARN_ON(mgr->mst_primary) in drm_dp_mst_topology_mgr_set_mst()
already catches the case where the topology is initialized twice, so no
diagnostic coverage is lost.

Fixes dbaeef363ea5 ("drm/dp_mst: Add a helper to queue a topology

probe")

---
 drivers/gpu/drm/display/drm_dp_mst_topology.c | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/display/drm_dp_mst_topology.c +0 -0
index 8757972e8..0cb341ce1 100644

drivers/gpu/drm/display/drm_dp_mst_topology.c void drm_dp_mst_topology_queue_probe(struct · line 3745

Quoted 9 lines
drivers/gpu/drm/display/drm_dp_mst_topology.c +2 -1
@@ -3738,8 +3738,10 @@ void drm_dp_mst_topology_queue_probe(struct
 drm_dp_mst_topology_mgr *mgr)
  {
  	mutex_lock(&mgr->lock);
 
-	if (drm_WARN_ON(mgr->dev, !mgr->mst_state || !mgr-
 >mst_primary))
+	if (!mgr->mst_state || !mgr->mst_primary) {
+		drm_dbg_mst(mgr->dev, "queue_probe skipped: topology
 torn down\n");

There is no such function named drm_dbg_mst, can you switch this to drm_dbg_kms() like the rest of the file and make sure it builds before sending another version?

Quoted 4 lines
drivers/gpu/drm/display/drm_dp_mst_topology.c +1 -0
  		goto out_unlock;
+	}

  drm_dp_mst_topology_mgr_invalidate_mstb(mgr->mst_primary);