Message ID | 20230721-drm-bridge-chain-debugfs-v2-1-76df94347962@ideasonboard.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp280588vqg; Fri, 21 Jul 2023 08:22:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlFssDPb1ZmGCzRdl1Cw55/VVlg4DSeFv+I4CW4agC6f6mnRrmi9WDGJP4J1XA9cM+Jv5m9m X-Received: by 2002:a05:6a00:1993:b0:661:4a00:1ea5 with SMTP id d19-20020a056a00199300b006614a001ea5mr364653pfl.20.1689952944337; Fri, 21 Jul 2023 08:22:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689952944; cv=none; d=google.com; s=arc-20160816; b=eiWATZmBsJO/4G+7mfv+ECIa6L02U6UhAiW3qQczfUv/PNFKBFWvQNGAMSnaRPGZUD Wc2SXEZl2VOEoNTpBK84lo/QGvBu3StXOnT33n7KNyBxy75qIxPt8Xru/Qw2sdWDjOM6 RoXDzxDkrGfdMkeyIVC+RTJhoBOY74cZBj0ujT5qklbs5eljmwKDsEK1SqkxVWjh8tBD JKFwMWqgJa0s1M6v3AHBjbm6rmfjEB/n9uEhIhB0R3dEn3vBBjax9DQ24KaBPXLx8aKP z/k0eLbIjqnaSkKw6zM9q6Ck7r3K2R/OrJQFmVTvb0uiY1eBf18P1D6DKfW/seFE4BF+ AGOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=jtcTAbM/aeHptFlLpbK/w/ChPncm6FaDDUmF3vbTFL4=; fh=mQ8C+yYLvlnBJV0Si8H71HFJDb5+m61ZakC/SKvSh9w=; b=bBQrCOgLMeUXIbgstkodzqv/IGjqMAZO6s68c8SxS8mB03sJiEvO+wWBSOf9BnWqix 4IyJL6LlMbnlv7q9N+RcRI+S8xBheS/K6Iszuo41YVrYpPAkImLSGWW4SBwJd7de+KPc Gcj+e5pE+2diczvG+4uJTZbh+UlljpDdFWLqfIVe9uaZVuxQNGvUIHrZQ9XSIG/l73pK fsKJzVhvgvzaGu6CC3Nk1zgsIX410QbcNtZfMZf4SDwrdbC0VIy/vREv1bbm8YhSQwu4 x9jKb06abcaIri1VCl9tgU5x6ZDNeERmTmCyyN9yRLSPWq0l2PUDfth6U8xIliIQHGww uObg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=XNFuBZUD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r78-20020a632b51000000b00543cc3151f9si3251366pgr.461.2023.07.21.08.22.10; Fri, 21 Jul 2023 08:22:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=XNFuBZUD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230355AbjGUPCC (ORCPT <rfc822;assdfgzxcv4@gmail.com> + 99 others); Fri, 21 Jul 2023 11:02:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229682AbjGUPB7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Jul 2023 11:01:59 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9210B19B6 for <linux-kernel@vger.kernel.org>; Fri, 21 Jul 2023 08:01:56 -0700 (PDT) Received: from [127.0.1.1] (91-154-35-171.elisa-laajakaista.fi [91.154.35.171]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AAAFE373D; Fri, 21 Jul 2023 17:00:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1689951658; bh=4nm4wx+l0xwMFnD7iQ7DJRq8Sf5u93Eqf1FNBIrZtOw=; h=From:Date:Subject:To:Cc:From; b=XNFuBZUDo6HNewWVHMh44DfIZmRoPecUxykc/LjVzH2qvdKhF1Qnim5Nu21n0Wddb W/p2Be5Q6Q7P+9/hZZGLHH3R4Jt60LRBBE0pvx5RiuVjLoqCsqSAWmqT+OcsZBNQl0 MqqEK6QKWwYXU1UqLv6G5ABNGBeG71Ki9cjsmIS8= From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Date: Fri, 21 Jul 2023 18:01:39 +0300 Subject: [PATCH v2] drm/bridge: Add debugfs print for bridge chains MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230721-drm-bridge-chain-debugfs-v2-1-76df94347962@ideasonboard.com> X-B4-Tracking: v=1; b=H4sIANKdumQC/42NSw6CMBCGr0JmbU1bRdCV9zAsWmYKs6AlUyUaw t2tnMDl9z9XyCRMGW7VCkILZ06xgD1U0I8uDqQYC4PV9qQbaxTKpLwwFqcEOCok/xpCVtr73tT WhrpxUOqzUOD3Pv3oCo+cn0k++9Nifuofo4tRRrUXcw6hofaq8c5ILqfokxM89mmCbtu2L0HkN PrHAAAA To: Andrzej Hajda <andrzej.hajda@intel.com>, Neil Armstrong <neil.armstrong@linaro.org>, Robert Foss <rfoss@kernel.org>, Laurent Pinchart <Laurent.pinchart@ideasonboard.com>, Jonas Karlman <jonas@kwiboo.se>, Jernej Skrabec <jernej.skrabec@gmail.com>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Francesco Dolcini <francesco.dolcini@toradex.com>, Aradhya Bhatia <a-bhatia1@ti.com> Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4609; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=4nm4wx+l0xwMFnD7iQ7DJRq8Sf5u93Eqf1FNBIrZtOw=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBkup3gY3JTBj4iBgQmW0jNX5bUcf+8iCQuTi8jj mXY9zufs+SJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZLqd4AAKCRD6PaqMvJYe 9WtEEACyKk2djT/HNrT5YHgOGzzZeFC/3ChyS02RzteuOzqRnqxml2CfMR2lCOIc9mxDyBks1VL 4gnT9zRK8CZN7GHiEChvBprlv7UcmIYp/un8ImuST87cpmneqS+VrihqI8a6XdN9YYZPkTNRDX3 803LSWjWH7msGKRFUZzLRtIEhSmj+T0I78wZekbLn+qlyz9cTPBRcvigbsG9Z7pZn4j6QLqXPMd jGHI5lDDkogZa92Oewb50RSiRmKdS2/PikiNjrWEYVpZOFYPY/0UAvqP9msk9ogjDhdHLLdR7/P aeFMwdggsW2OXXjjU67bksXzUjBzs8RAxdCtWEIgRg9kkHwW59Ud9G7MfFQxJZYylpwGHbMlD1S Cm53whKwkrr23VzkR/VFk7hYSwvZ7j8RWvLEPVlyoSlOH+8CGeJhe0ViHRUl2T7y09NQBhQKT19 e3TpN4kHrRfaqS9sViSNgbsfIB4gtkzl4WcZSa+A4Yy/3o0qKzslttD8zxeQINuyBA14jh7TNY/ iyEEmR+1DFMu02VlGwc5LF5+Xue6070lCbaGxQlyojQuhWMIjNOc/dSKJSwKM+ukQ4UZZ3E5WAW NYScjdcwJQHveoJlJkz4K42w/R/8IgmemTrZkDp+nD8wUMLy9qocBu656zvDls9Yg3ZFrlrAWp3 qIo5Wuw+x5aVIWw== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772044098566796868 X-GMAIL-MSGID: 1772044098566796868 |
Series |
[v2] drm/bridge: Add debugfs print for bridge chains
|
|
Commit Message
Tomi Valkeinen
July 21, 2023, 3:01 p.m. UTC
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
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
Changes in v2:
- Fixed compilation issue when !CONFIG_OF
- Link to v1: https://lore.kernel.org/r/20230721-drm-bridge-chain-debugfs-v1-1-8614ff7e890d@ideasonboard.com
---
drivers/gpu/drm/drm_bridge.c | 50 +++++++++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/drm_debugfs.c | 3 +++
include/drm/drm_bridge.h | 5 +++++
3 files changed, 58 insertions(+)
---
base-commit: c7a472297169156252a50d76965eb36b081186e2
change-id: 20230721-drm-bridge-chain-debugfs-0bbc1522f57a
Best regards,
Comments
Hi Tomi, Am Freitag, 21. Juli 2023, 17:01:39 CEST schrieb Tomi Valkeinen: > 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 I like the idea and it works on an imx8mp based board for the DRI display devices which have connectors attached: $ cat /sys/kernel/debug/dri/1/bridge_chains encoder[36] bridge[0] type: 16, ops: 0x0, OF: /soc@0/bus@32c00000/ dsi@32e60000:fsl,imx8mp-mipi-dsim bridge[1] type: 10, ops: 0x3, OF: /soc@0/bus@30800000/i2c@30a30000/ bridge@f:toshiba,tc9595 $ cat /sys/kernel/debug/dri/2/bridge_chains encoder[36] bridge[0] type: 0, ops: 0x0, OF: /soc@0/bus@32c00000/display- bridge@32fc4000:fsl,imx8mp-hdmi-pvi bridge[1] type: 0, ops: 0x7, OF: /soc@0/bus@32c00000/ hdmi@32fd8000:fsl,imx8mp-hdmi Unfortunately this oopses on GPU device without connectors: $ cat /sys/kernel/debug/dri/0/name etnaviv dev=etnaviv unique=etnaviv $ cat /sys/kernel/debug/dri/0/bridge_chains Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 Mem abort info: ESR = 0x0000000096000004 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x04: level 0 translation fault Data abort info: ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 CM = 0, WnR = 0, TnD = 0, TagAccess = 0 GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 user pgtable: 4k pages, 48-bit VAs, pgdp=0000000045842000 [0000000000000010] pgd=0000000000000000, p4d=0000000000000000 Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP Modules linked in: dw_hdmi_cec mcp320x hantro_vpu snd_soc_fsl_asoc_card snd_soc_fsl_sai snd_soc_tlv320aic32x4_i2c snd_soc_imx_audmux snd_soc_fsl_utils snd_soc_tlv320aic32x4 snd_soc_simple_card_utils imx_pcm_dma snd_soc_core dw100 v4l2_vp9 8021q snd_pcm_dmaengine v4l2_h264 snd_pcm videobuf2_dma_contig garp imx8mp_hdmi crct10dif_ce v4l2_mem2mem mrp dw_hdmi tc358767 videobuf2_memops stp bluetooth llc synopsys_edac videobuf2_v4l2 cec videobuf2_common phy_fsl_samsung_hdmi imx8mp_hdmi_pvi samsung_dsim snd_timer cfg80211 snd flexcan drm_display_helper imx_sdma soundcore virt_dma can_dev clk_renesas_pcie coresight_etm4x coresight_tmc coresight_funnel pwm_imx27 coresight imx8mm_thermal iio_hwmon fuse ipv6 CPU: 3 PID: 485 Comm: cat Not tainted 6.5.0-rc3-next-20230724+ #1822 41dd31be02d36f174370d905469174492535c29d Hardware name: TQ-Systems i.MX8MPlus TQMa8MPxL on MBa8MPxL (DT) pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : drm_bridge_chains_info+0xfc/0x1d0 lr : drm_bridge_chains_info+0xf8/0x1d0 sp : ffff8000831c39e0 x29: ffff8000831c39e0 x28: ffff8000811759f0 x27: ffff800081175a08 x26: ffff800081175000 x25: ffff000002d592b0 x24: ffff000002d59000 x23: ffff800081175a70 x22: ffff800081175a50 x21: fffffffffffffff8 x20: 0000000000000000 x19: 0000000000000000 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000000 x13: 3836613136616661 x12: 3030303030303030 x11: 203a7473696c5f72 x10: 65646f636e65205d x9 : 6c5f7265646f636e x8 : 65205d6d72645b20 x7 : 0000000000000003 x6 : ffff8000818627a0 x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff8000831c3a68 Call trace: drm_bridge_chains_info+0xfc/0x1d0 seq_read_iter+0x1a8/0x484 seq_read+0x88/0xbc full_proxy_read+0x5c/0xa8 vfs_read+0xac/0x1e0 ksys_read+0x68/0xf4 __arm64_sys_read+0x18/0x20 invoke_syscall+0x6c/0xec el0_svc_common.constprop.0+0xb8/0xd8 do_el0_svc+0x28/0x34 el0_svc+0x1c/0x50 el0t_64_sync_handler+0xb8/0xbc el0t_64_sync+0x14c/0x150 Code: aa1903e2 f94037e1 9401d66f 910223e0 (b9401aa2) ---[ end trace 0000000000000000 ]--- This boils down to the connector_list setup incorrectly? Here is some debug output from drm_bridge_chains_info: > etnaviv etnaviv: [drm] encoder_list: 00000000afa61a68 > etnaviv etnaviv: [drm] num_encoder: 0 > etnaviv etnaviv: [drm] list_empty: 0 > etnaviv etnaviv: [drm] encoder: fffffffffffffff8 > etnaviv etnaviv: [drm] encoder->head: 0000000000000000 list_empty(&config->encoder_list)) not returning true and num_encoder being 0 seems off to me. Best regards, Alexander > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > --- > Changes in v2: > - Fixed compilation issue when !CONFIG_OF > - Link to v1: > https://lore.kernel.org/r/20230721-drm-bridge-chain-debugfs-v1-1-8614ff7e89 > 0d@ideasonboard.com --- > drivers/gpu/drm/drm_bridge.c | 50 > +++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_debugfs.c | > 3 +++ > include/drm/drm_bridge.h | 5 +++++ > 3 files changed, 58 insertions(+) > > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c > index c3d69af02e79..d3eb62d5ef3b 100644 > --- a/drivers/gpu/drm/drm_bridge.c > +++ b/drivers/gpu/drm/drm_bridge.c > @@ -27,8 +27,10 @@ > #include <linux/mutex.h> > > #include <drm/drm_atomic_state_helper.h> > +#include <drm/drm_debugfs.h> > #include <drm/drm_bridge.h> > #include <drm/drm_encoder.h> > +#include <drm/drm_file.h> > #include <drm/drm_of.h> > #include <drm/drm_print.h> > > @@ -1345,6 +1347,54 @@ struct drm_bridge *of_drm_find_bridge(struct > device_node *np) EXPORT_SYMBOL(of_drm_find_bridge); > #endif > > +#ifdef CONFIG_DEBUG_FS > +static int drm_bridge_chains_info(struct seq_file *m, void *data) > +{ > + struct drm_debugfs_entry *entry = m->private; > + struct drm_device *dev = entry->dev; > + struct drm_printer p = drm_seq_file_printer(m); > + struct drm_mode_config *config = &dev->mode_config; > + struct drm_encoder *encoder; > + unsigned int bridge_idx = 0; > + > + list_for_each_entry(encoder, &config->encoder_list, head) { > + struct drm_bridge *bridge; > + > + drm_printf(&p, "encoder[%u]\n", encoder->base.id); > + > + bridge = drm_bridge_chain_get_first_bridge(encoder); > + > + while (bridge) { > + drm_printf(&p, "\tbridge[%u] type: %u, ops: %#x", > + bridge_idx, bridge->type, bridge- >ops); > + > +#ifdef CONFIG_OF > + if (bridge->of_node) > + drm_printf(&p, ", OF: %pOFfc", bridge- >of_node); > +#endif > + > + drm_printf(&p, "\n"); > + > + bridge_idx++; > + bridge = drm_bridge_get_next_bridge(bridge); > + } > + } > + > + return 0; > +} > + > +/* any use in debugfs files to dump individual planes/crtc/etc? */ > +static const struct drm_debugfs_info drm_bridge_debugfs_list[] = { > + {"bridge_chains", drm_bridge_chains_info, 0}, > +}; > + > +void drm_bridge_debugfs_init(struct drm_minor *minor) > +{ > + drm_debugfs_add_files(minor->dev, drm_bridge_debugfs_list, > + ARRAY_SIZE(drm_bridge_debugfs_list)); > +} > +#endif > + > MODULE_AUTHOR("Ajay Kumar <ajaykumar.rs@samsung.com>"); > MODULE_DESCRIPTION("DRM bridge infrastructure"); > MODULE_LICENSE("GPL and additional rights"); > diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c > index c90dbcffa0dc..3e89559d68cd 100644 > --- a/drivers/gpu/drm/drm_debugfs.c > +++ b/drivers/gpu/drm/drm_debugfs.c > @@ -31,6 +31,7 @@ > > #include <drm/drm_atomic.h> > #include <drm/drm_auth.h> > +#include <drm/drm_bridge.h> > #include <drm/drm_client.h> > #include <drm/drm_debugfs.h> > #include <drm/drm_device.h> > @@ -272,6 +273,8 @@ int drm_debugfs_init(struct drm_minor *minor, int > minor_id, > > drm_debugfs_add_files(minor->dev, drm_debugfs_list, DRM_DEBUGFS_ENTRIES); > > + drm_bridge_debugfs_init(minor); > + > if (drm_drv_uses_atomic_modeset(dev)) { > drm_atomic_debugfs_init(minor); > } > diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h > index bf964cdfb330..60dbee6bd1e6 100644 > --- a/include/drm/drm_bridge.h > +++ b/include/drm/drm_bridge.h > @@ -949,4 +949,9 @@ static inline struct drm_bridge > *drmm_of_get_bridge(struct drm_device *drm, } > #endif > > +#ifdef CONFIG_DEBUG_FS > +struct drm_minor; > +void drm_bridge_debugfs_init(struct drm_minor *minor); > +#endif > + > #endif > > --- > base-commit: c7a472297169156252a50d76965eb36b081186e2 > change-id: 20230721-drm-bridge-chain-debugfs-0bbc1522f57a > > Best regards,
Hi Tomi, Thank you for the patch. On Fri, Jul 21, 2023 at 06:01:39PM +0300, Tomi Valkeinen wrote: > 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 Names would be more readable than numbers, but I'm not sure that's really worth it. It can always be improved on top if desired. > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > --- > Changes in v2: > - Fixed compilation issue when !CONFIG_OF > - Link to v1: https://lore.kernel.org/r/20230721-drm-bridge-chain-debugfs-v1-1-8614ff7e890d@ideasonboard.com > --- > drivers/gpu/drm/drm_bridge.c | 50 +++++++++++++++++++++++++++++++++++++++++++ > drivers/gpu/drm/drm_debugfs.c | 3 +++ > include/drm/drm_bridge.h | 5 +++++ > 3 files changed, 58 insertions(+) > > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c > index c3d69af02e79..d3eb62d5ef3b 100644 > --- a/drivers/gpu/drm/drm_bridge.c > +++ b/drivers/gpu/drm/drm_bridge.c > @@ -27,8 +27,10 @@ > #include <linux/mutex.h> > > #include <drm/drm_atomic_state_helper.h> > +#include <drm/drm_debugfs.h> > #include <drm/drm_bridge.h> > #include <drm/drm_encoder.h> > +#include <drm/drm_file.h> > #include <drm/drm_of.h> > #include <drm/drm_print.h> > > @@ -1345,6 +1347,54 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np) > EXPORT_SYMBOL(of_drm_find_bridge); > #endif > > +#ifdef CONFIG_DEBUG_FS > +static int drm_bridge_chains_info(struct seq_file *m, void *data) > +{ > + struct drm_debugfs_entry *entry = m->private; > + struct drm_device *dev = entry->dev; > + struct drm_printer p = drm_seq_file_printer(m); > + struct drm_mode_config *config = &dev->mode_config; As Alexander reported, there's a crash for GPU drivers, as mode_config isn't initialized in that case. I would skip creating the debugfs entry if DRIVER_MODESET isn't set. > + struct drm_encoder *encoder; > + unsigned int bridge_idx = 0; > + > + list_for_each_entry(encoder, &config->encoder_list, head) { > + struct drm_bridge *bridge; > + > + drm_printf(&p, "encoder[%u]\n", encoder->base.id); > + > + bridge = drm_bridge_chain_get_first_bridge(encoder); > + > + while (bridge) { Would drm_for_each_bridge_in_chain() help ? > + drm_printf(&p, "\tbridge[%u] type: %u, ops: %#x", > + bridge_idx, bridge->type, bridge->ops); > + > +#ifdef CONFIG_OF > + if (bridge->of_node) > + drm_printf(&p, ", OF: %pOFfc", bridge->of_node); > +#endif > + > + drm_printf(&p, "\n"); > + > + bridge_idx++; > + bridge = drm_bridge_get_next_bridge(bridge); > + } > + } > + > + return 0; > +} > + > +/* any use in debugfs files to dump individual planes/crtc/etc? */ Those can easily be listed from userspace, so I don't think that's needed. > +static const struct drm_debugfs_info drm_bridge_debugfs_list[] = { > + {"bridge_chains", drm_bridge_chains_info, 0}, Missing spaces after '{' and before '}'. > +}; > + > +void drm_bridge_debugfs_init(struct drm_minor *minor) > +{ > + drm_debugfs_add_files(minor->dev, drm_bridge_debugfs_list, > + ARRAY_SIZE(drm_bridge_debugfs_list)); > +} > +#endif > + > MODULE_AUTHOR("Ajay Kumar <ajaykumar.rs@samsung.com>"); > MODULE_DESCRIPTION("DRM bridge infrastructure"); > MODULE_LICENSE("GPL and additional rights"); > diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c > index c90dbcffa0dc..3e89559d68cd 100644 > --- a/drivers/gpu/drm/drm_debugfs.c > +++ b/drivers/gpu/drm/drm_debugfs.c > @@ -31,6 +31,7 @@ > > #include <drm/drm_atomic.h> > #include <drm/drm_auth.h> > +#include <drm/drm_bridge.h> > #include <drm/drm_client.h> > #include <drm/drm_debugfs.h> > #include <drm/drm_device.h> > @@ -272,6 +273,8 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id, > > drm_debugfs_add_files(minor->dev, drm_debugfs_list, DRM_DEBUGFS_ENTRIES); > > + drm_bridge_debugfs_init(minor); > + > if (drm_drv_uses_atomic_modeset(dev)) { > drm_atomic_debugfs_init(minor); > } > diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h > index bf964cdfb330..60dbee6bd1e6 100644 > --- a/include/drm/drm_bridge.h > +++ b/include/drm/drm_bridge.h > @@ -949,4 +949,9 @@ static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, > } > #endif > > +#ifdef CONFIG_DEBUG_FS You could drop the conditional compilation, it wouldn't hurt. > +struct drm_minor; > +void drm_bridge_debugfs_init(struct drm_minor *minor); > +#endif > + > #endif > > --- > base-commit: c7a472297169156252a50d76965eb36b081186e2 > change-id: 20230721-drm-bridge-chain-debugfs-0bbc1522f57a
On 25/07/2023 14:37, Laurent Pinchart wrote: > Hi Tomi, > > Thank you for the patch. > > On Fri, Jul 21, 2023 at 06:01:39PM +0300, Tomi Valkeinen wrote: >> 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 > > Names would be more readable than numbers, but I'm not sure that's > really worth it. It can always be improved on top if desired. For type and ops? I agree, but it might also make the output more cluttered. To be honest, I'm not sure if type and ops are useful here, I just felt that I should print something else than just the OF node =). >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> >> --- >> Changes in v2: >> - Fixed compilation issue when !CONFIG_OF >> - Link to v1: https://lore.kernel.org/r/20230721-drm-bridge-chain-debugfs-v1-1-8614ff7e890d@ideasonboard.com >> --- >> drivers/gpu/drm/drm_bridge.c | 50 +++++++++++++++++++++++++++++++++++++++++++ >> drivers/gpu/drm/drm_debugfs.c | 3 +++ >> include/drm/drm_bridge.h | 5 +++++ >> 3 files changed, 58 insertions(+) >> >> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c >> index c3d69af02e79..d3eb62d5ef3b 100644 >> --- a/drivers/gpu/drm/drm_bridge.c >> +++ b/drivers/gpu/drm/drm_bridge.c >> @@ -27,8 +27,10 @@ >> #include <linux/mutex.h> >> >> #include <drm/drm_atomic_state_helper.h> >> +#include <drm/drm_debugfs.h> >> #include <drm/drm_bridge.h> >> #include <drm/drm_encoder.h> >> +#include <drm/drm_file.h> >> #include <drm/drm_of.h> >> #include <drm/drm_print.h> >> >> @@ -1345,6 +1347,54 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np) >> EXPORT_SYMBOL(of_drm_find_bridge); >> #endif >> >> +#ifdef CONFIG_DEBUG_FS >> +static int drm_bridge_chains_info(struct seq_file *m, void *data) >> +{ >> + struct drm_debugfs_entry *entry = m->private; >> + struct drm_device *dev = entry->dev; >> + struct drm_printer p = drm_seq_file_printer(m); >> + struct drm_mode_config *config = &dev->mode_config; > > As Alexander reported, there's a crash for GPU drivers, as mode_config > isn't initialized in that case. I would skip creating the debugfs entry > if DRIVER_MODESET isn't set. Yes, makes sense. >> + struct drm_encoder *encoder; >> + unsigned int bridge_idx = 0; >> + >> + list_for_each_entry(encoder, &config->encoder_list, head) { >> + struct drm_bridge *bridge; >> + >> + drm_printf(&p, "encoder[%u]\n", encoder->base.id); >> + >> + bridge = drm_bridge_chain_get_first_bridge(encoder); >> + >> + while (bridge) { > > Would drm_for_each_bridge_in_chain() help ? Yes. >> + drm_printf(&p, "\tbridge[%u] type: %u, ops: %#x", >> + bridge_idx, bridge->type, bridge->ops); >> + >> +#ifdef CONFIG_OF >> + if (bridge->of_node) >> + drm_printf(&p, ", OF: %pOFfc", bridge->of_node); >> +#endif >> + >> + drm_printf(&p, "\n"); >> + >> + bridge_idx++; >> + bridge = drm_bridge_get_next_bridge(bridge); >> + } >> + } >> + >> + return 0; >> +} >> + >> +/* any use in debugfs files to dump individual planes/crtc/etc? */ > > Those can easily be listed from userspace, so I don't think that's > needed. Oops. That comment is not supposed to be there. It was a copy-paste error. >> +static const struct drm_debugfs_info drm_bridge_debugfs_list[] = { >> + {"bridge_chains", drm_bridge_chains_info, 0}, > > Missing spaces after '{' and before '}'. Yep. >> +}; >> + >> +void drm_bridge_debugfs_init(struct drm_minor *minor) >> +{ >> + drm_debugfs_add_files(minor->dev, drm_bridge_debugfs_list, >> + ARRAY_SIZE(drm_bridge_debugfs_list)); >> +} >> +#endif >> + >> MODULE_AUTHOR("Ajay Kumar <ajaykumar.rs@samsung.com>"); >> MODULE_DESCRIPTION("DRM bridge infrastructure"); >> MODULE_LICENSE("GPL and additional rights"); >> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c >> index c90dbcffa0dc..3e89559d68cd 100644 >> --- a/drivers/gpu/drm/drm_debugfs.c >> +++ b/drivers/gpu/drm/drm_debugfs.c >> @@ -31,6 +31,7 @@ >> >> #include <drm/drm_atomic.h> >> #include <drm/drm_auth.h> >> +#include <drm/drm_bridge.h> >> #include <drm/drm_client.h> >> #include <drm/drm_debugfs.h> >> #include <drm/drm_device.h> >> @@ -272,6 +273,8 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id, >> >> drm_debugfs_add_files(minor->dev, drm_debugfs_list, DRM_DEBUGFS_ENTRIES); >> >> + drm_bridge_debugfs_init(minor); >> + >> if (drm_drv_uses_atomic_modeset(dev)) { >> drm_atomic_debugfs_init(minor); >> } >> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h >> index bf964cdfb330..60dbee6bd1e6 100644 >> --- a/include/drm/drm_bridge.h >> +++ b/include/drm/drm_bridge.h >> @@ -949,4 +949,9 @@ static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, >> } >> #endif >> >> +#ifdef CONFIG_DEBUG_FS > > You could drop the conditional compilation, it wouldn't hurt. I used the same style as in drm_crtc_internal.h. But you're right, the ifdef doesn't really do much here. >> +struct drm_minor; >> +void drm_bridge_debugfs_init(struct drm_minor *minor); >> +#endif >> + >> #endif >> >> --- >> base-commit: c7a472297169156252a50d76965eb36b081186e2 >> change-id: 20230721-drm-bridge-chain-debugfs-0bbc1522f57a > Tomi
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index c3d69af02e79..d3eb62d5ef3b 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -27,8 +27,10 @@ #include <linux/mutex.h> #include <drm/drm_atomic_state_helper.h> +#include <drm/drm_debugfs.h> #include <drm/drm_bridge.h> #include <drm/drm_encoder.h> +#include <drm/drm_file.h> #include <drm/drm_of.h> #include <drm/drm_print.h> @@ -1345,6 +1347,54 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np) EXPORT_SYMBOL(of_drm_find_bridge); #endif +#ifdef CONFIG_DEBUG_FS +static int drm_bridge_chains_info(struct seq_file *m, void *data) +{ + struct drm_debugfs_entry *entry = m->private; + struct drm_device *dev = entry->dev; + struct drm_printer p = drm_seq_file_printer(m); + struct drm_mode_config *config = &dev->mode_config; + struct drm_encoder *encoder; + unsigned int bridge_idx = 0; + + list_for_each_entry(encoder, &config->encoder_list, head) { + struct drm_bridge *bridge; + + drm_printf(&p, "encoder[%u]\n", encoder->base.id); + + bridge = drm_bridge_chain_get_first_bridge(encoder); + + while (bridge) { + drm_printf(&p, "\tbridge[%u] type: %u, ops: %#x", + bridge_idx, bridge->type, bridge->ops); + +#ifdef CONFIG_OF + if (bridge->of_node) + drm_printf(&p, ", OF: %pOFfc", bridge->of_node); +#endif + + drm_printf(&p, "\n"); + + bridge_idx++; + bridge = drm_bridge_get_next_bridge(bridge); + } + } + + return 0; +} + +/* any use in debugfs files to dump individual planes/crtc/etc? */ +static const struct drm_debugfs_info drm_bridge_debugfs_list[] = { + {"bridge_chains", drm_bridge_chains_info, 0}, +}; + +void drm_bridge_debugfs_init(struct drm_minor *minor) +{ + drm_debugfs_add_files(minor->dev, drm_bridge_debugfs_list, + ARRAY_SIZE(drm_bridge_debugfs_list)); +} +#endif + MODULE_AUTHOR("Ajay Kumar <ajaykumar.rs@samsung.com>"); MODULE_DESCRIPTION("DRM bridge infrastructure"); MODULE_LICENSE("GPL and additional rights"); diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index c90dbcffa0dc..3e89559d68cd 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -31,6 +31,7 @@ #include <drm/drm_atomic.h> #include <drm/drm_auth.h> +#include <drm/drm_bridge.h> #include <drm/drm_client.h> #include <drm/drm_debugfs.h> #include <drm/drm_device.h> @@ -272,6 +273,8 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id, drm_debugfs_add_files(minor->dev, drm_debugfs_list, DRM_DEBUGFS_ENTRIES); + drm_bridge_debugfs_init(minor); + if (drm_drv_uses_atomic_modeset(dev)) { drm_atomic_debugfs_init(minor); } diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index bf964cdfb330..60dbee6bd1e6 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -949,4 +949,9 @@ static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, } #endif +#ifdef CONFIG_DEBUG_FS +struct drm_minor; +void drm_bridge_debugfs_init(struct drm_minor *minor); +#endif + #endif