Skip to content

Commit 8e4bb53

Browse files
tombasuperna9999
authored andcommitted
drm/bridge: Add debugfs print for bridge chains
DRM bridges are not visible to the userspace and it may not be immediately clear if the chain is somehow constructed incorrectly. I have had two separate instances of a bridge driver failing to do a drm_bridge_attach() call, resulting in the bridge connector not being part of the chain. In some situations this doesn't seem to cause issues, but it will if DRM_BRIDGE_ATTACH_NO_CONNECTOR flag is used. Add a debugfs file to print the bridge chains. For me, on this TI AM62 based platform, I get the following output: encoder[39] bridge[0] type: 0, ops: 0x0 bridge[1] type: 0, ops: 0x0, OF: /bus@f0000/i2c@20000000/dsi@e:toshiba,tc358778 bridge[2] type: 0, ops: 0x3, OF: /bus@f0000/i2c@20010000/hdmi@48:lontium,lt8912b bridge[3] type: 11, ops: 0x7, OF: /hdmi-connector:hdmi-connector Tested-by: Alexander Stein <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Tomi Valkeinen <[email protected]> Acked-by: Neil Armstrong <[email protected]> Signed-off-by: Neil Armstrong <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20230802-drm-bridge-chain-debugfs-v4-1-7e3ae3d137c0@ideasonboard.com
1 parent 76edfcf commit 8e4bb53

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

drivers/gpu/drm/drm_bridge.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
#include <linux/mutex.h>
2828

2929
#include <drm/drm_atomic_state_helper.h>
30+
#include <drm/drm_debugfs.h>
3031
#include <drm/drm_bridge.h>
3132
#include <drm/drm_encoder.h>
33+
#include <drm/drm_file.h>
3234
#include <drm/drm_of.h>
3335
#include <drm/drm_print.h>
3436

@@ -1345,6 +1347,50 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np)
13451347
EXPORT_SYMBOL(of_drm_find_bridge);
13461348
#endif
13471349

1350+
#ifdef CONFIG_DEBUG_FS
1351+
static int drm_bridge_chains_info(struct seq_file *m, void *data)
1352+
{
1353+
struct drm_debugfs_entry *entry = m->private;
1354+
struct drm_device *dev = entry->dev;
1355+
struct drm_printer p = drm_seq_file_printer(m);
1356+
struct drm_mode_config *config = &dev->mode_config;
1357+
struct drm_encoder *encoder;
1358+
unsigned int bridge_idx = 0;
1359+
1360+
list_for_each_entry(encoder, &config->encoder_list, head) {
1361+
struct drm_bridge *bridge;
1362+
1363+
drm_printf(&p, "encoder[%u]\n", encoder->base.id);
1364+
1365+
drm_for_each_bridge_in_chain(encoder, bridge) {
1366+
drm_printf(&p, "\tbridge[%u] type: %u, ops: %#x",
1367+
bridge_idx, bridge->type, bridge->ops);
1368+
1369+
#ifdef CONFIG_OF
1370+
if (bridge->of_node)
1371+
drm_printf(&p, ", OF: %pOFfc", bridge->of_node);
1372+
#endif
1373+
1374+
drm_printf(&p, "\n");
1375+
1376+
bridge_idx++;
1377+
}
1378+
}
1379+
1380+
return 0;
1381+
}
1382+
1383+
static const struct drm_debugfs_info drm_bridge_debugfs_list[] = {
1384+
{ "bridge_chains", drm_bridge_chains_info, 0 },
1385+
};
1386+
1387+
void drm_bridge_debugfs_init(struct drm_minor *minor)
1388+
{
1389+
drm_debugfs_add_files(minor->dev, drm_bridge_debugfs_list,
1390+
ARRAY_SIZE(drm_bridge_debugfs_list));
1391+
}
1392+
#endif
1393+
13481394
MODULE_AUTHOR("Ajay Kumar <[email protected]>");
13491395
MODULE_DESCRIPTION("DRM bridge infrastructure");
13501396
MODULE_LICENSE("GPL and additional rights");

drivers/gpu/drm/drm_debugfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include <drm/drm_atomic.h>
3333
#include <drm/drm_auth.h>
34+
#include <drm/drm_bridge.h>
3435
#include <drm/drm_client.h>
3536
#include <drm/drm_debugfs.h>
3637
#include <drm/drm_device.h>
@@ -274,6 +275,7 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
274275

275276
if (drm_drv_uses_atomic_modeset(dev)) {
276277
drm_atomic_debugfs_init(minor);
278+
drm_bridge_debugfs_init(minor);
277279
}
278280

279281
if (drm_core_check_feature(dev, DRIVER_MODESET)) {

include/drm/drm_bridge.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct drm_bridge;
3636
struct drm_bridge_timings;
3737
struct drm_connector;
3838
struct drm_display_info;
39+
struct drm_minor;
3940
struct drm_panel;
4041
struct edid;
4142
struct i2c_adapter;
@@ -949,4 +950,6 @@ static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm,
949950
}
950951
#endif
951952

953+
void drm_bridge_debugfs_init(struct drm_minor *minor);
954+
952955
#endif

0 commit comments

Comments
 (0)