The usefulness of /sys/kernel/debug/dri/bridges is limited as it only shows bridges betweeb drm_bridge_add() and drm_bridge_remove(). However refcounted bridges can stay allocated for way longer, and a memory leak due to a missing drm_bridge_put() would not be visible in this debugfs file. Add removed bridges to the /sys/kernel/debug/dri/bridges output. Now however if a bridge is added and removed multiple times (as in hot-pluggable hardware) and not freed immediately, there would be multiple identical entries for the same bridge model/driver. To distinguish between each instance add the bridge pointer to the output. Signed-off-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx> --- This patch was added in v6. --- drivers/gpu/drm/drm_debugfs.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 629074247ffec4fa18df7af2d9023255abed501c..b04e1fba8faf7320794277c2017c97216320f017 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -740,12 +740,16 @@ void drm_debugfs_crtc_remove(struct drm_crtc *crtc) crtc->debugfs_entry = NULL; } -static void bridge_print(struct drm_printer *p, struct drm_bridge *bridge, unsigned int idx) +static void bridge_print(struct drm_printer *p, struct drm_bridge *bridge, unsigned int idx, + bool removed) { drm_printf(p, "bridge[%u]: %ps\n", idx, bridge->funcs); + drm_printf(p, "\taddr: %p\n", bridge); + if (drm_bridge_is_refcounted(bridge)) - drm_printf(p, "\trefcount: %u\n", kref_read(&bridge->refcount)); + drm_printf(p, "\trefcount: %u%s\n", kref_read(&bridge->refcount), + removed ? " [removed]" : ""); else drm_printf(p, "\trefcount: N/A\n"); @@ -753,7 +757,8 @@ static void bridge_print(struct drm_printer *p, struct drm_bridge *bridge, unsig bridge->type, drm_get_connector_type_name(bridge->type)); - if (bridge->of_node) + /* The OF node could be freed after drm_bridge_remove() */ + if (bridge->of_node && !removed) drm_printf(p, "\tOF: %pOFfc\n", bridge->of_node); drm_printf(p, "\tops: [0x%x]", bridge->ops); @@ -778,7 +783,7 @@ static int bridges_show(struct seq_file *m, void *data) unsigned int idx = 0; drm_for_each_bridge_in_chain(encoder, bridge) - bridge_print(&p, bridge, idx++); + bridge_print(&p, bridge, idx++, false); return 0; } @@ -822,7 +827,10 @@ static int allbridges_show(struct seq_file *m, void *data) mutex_lock(&bridge_lock); list_for_each_entry(bridge, &bridge_list, list) - bridge_print(&p, bridge, idx++); + bridge_print(&p, bridge, idx++, false); + + list_for_each_entry(bridge, &bridge_removed_list, list) + bridge_print(&p, bridge, idx++, true); mutex_unlock(&bridge_lock); -- 2.34.1