From patchwork Mon Jul 31 12:13:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 128673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2012034vqg; Mon, 31 Jul 2023 06:23:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlHljiJjFV+dskpUmhk/4ba6GKnDvKcyJTdR0PSIPJ6sxPcCQo7IUsEGC5GTAi2XS1SlPsXh X-Received: by 2002:a05:6a20:9384:b0:132:87da:5b57 with SMTP id x4-20020a056a20938400b0013287da5b57mr12334801pzh.59.1690809791585; Mon, 31 Jul 2023 06:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690809791; cv=none; d=google.com; s=arc-20160816; b=eGv9pVe6oU9r/u/b8tK6cGgs6/ijWc0JlobPYGik3IBWim8WvW2ejNjKn3527GQ5Jk Su1fgLmCva5RMdZ8LVqKN7pGtUQLqdNTAVdNLPU/yVYq/JUZZ5ODjpXLALMtLNXV3xUR NiDqe9veInBJ2tSoJDADToPJ/5ViZt1KIhqOf4zntIa0dckyoeD+cPHXifPpBSeWO7ae 9K2x4iR48iiIqzjkhtAATUTvfpE1VOpUnD6Qkg3QREG2ZJVw2FKqgWSQpX8nYkS/Myyj 22rK26hK6zX1XSxnjgNGp6x1TB907/H9jnmvNNmCklp7R4e1QYFgqtvcVV5AUca2M24u HWhw== 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=pkN7PvspG+rSAPyBaIB/RpI7bPGy9mARYwh86eYkFQk=; fh=3dRaTVkmeoE9w+dwbQ/zYjxzLA6zh4rIRHp1Wq+JdsI=; b=lhNuypFKz/T9EL93T3Nyn4BOBSYL97FA3xIYDulJQmHS7FTTu+5nWLfejYbqPIGXY5 EpZ5D2cpLwSYs3KPcu7xblQNo95yap2eAwZidHY55X6nCexp22bXZ03nXFguqWyObtzl tkNLrFJB8CC4vXDVSnqiYFruAGio0fT4F+11cS1f2id1cHfuoMmu9daPeUzdiJH1cQ1b URtfhileYQhn42foaYn5lxCFgxbaIdbfe5vJ2duMqMyjpJe5PnH/lhe+NbueQ2PVcxCK 0LdPqbAaeEFcUeBaGobIC8g38Ss28JufbTQyIscsZDRxIOYKM/CCkIDNoUDQKlSLFSdy Dt5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=jQCblDDr; 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 f10-20020a63de0a000000b00563e080a7c9si6984694pgg.759.2023.07.31.06.22.34; Mon, 31 Jul 2023 06:23:11 -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=jQCblDDr; 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 S230127AbjGaMNz (ORCPT + 99 others); Mon, 31 Jul 2023 08:13:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229761AbjGaMNx (ORCPT ); Mon, 31 Jul 2023 08:13:53 -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 1673210DF for ; Mon, 31 Jul 2023 05:13:50 -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 EAD045A4; Mon, 31 Jul 2023 14:12:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1690805566; bh=X0B++9ZJoOGXr2Q9dYZmjqsgjlJ16PlZ4syKyoxQEkU=; h=From:Date:Subject:To:Cc:From; b=jQCblDDrSZz+fpDqp24KCffbYEAStw0+unrpLi3Fsz+doawB+Te+cbH+pFj8wBfOv hRM6JPA1dynBc5l8OU7vqDmeF9xi8H7vrBIPnTqU+4wMDhaOwuag0rTU4OW7ihetRj it5zcIb+2lUJirgWyUWbpPOG8nq/0PrpZwqOBif8= From: Tomi Valkeinen Date: Mon, 31 Jul 2023 15:13:14 +0300 Subject: [PATCH v3] drm/bridge: Add debugfs print for bridge chains MIME-Version: 1.0 Message-Id: <20230731-drm-bridge-chain-debugfs-v3-1-7d0739f3efa3@ideasonboard.com> X-B4-Tracking: v=1; b=H4sIAFmlx2QC/43NPQ7DIAwF4KtUzKUC54ekU+9RdYBgEg+BClrUK srdSzJ3yPjs588LSxgJE7ueFhYxU6LgS6jOJzZM2o/IyZbMQEAlFEhu48xNJFs2pUCeWzTv0SU ujBlkA+AapVk5f0Z09Nnp+6PkidIrxO/+KcttegDNkkvetbJ2TmHXC3sjizoFb4KO9jKEmW12h qMeFE+11vV1Vau+hT/euq4/inZWbhcBAAA= To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Francesco Dolcini , Aradhya Bhatia , Alexander Stein Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4740; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=X0B++9ZJoOGXr2Q9dYZmjqsgjlJ16PlZ4syKyoxQEkU=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBkx6V3kIlljbcwEkPpF2jYccwrfJf2NhfvfkoG7 tcqoT6g4/aJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZMeldwAKCRD6PaqMvJYe 9XIFEACiIy/bIIupSs7y53f++sShmKTkED5D7Bt5qFAz3fvk2/RehoLljivqMQZLW6S/8hBtRE1 zR1erINCV0M1cuWBnRZU3NBIOVWOtVo2ZGflzu+5TXNnmp2N447JLwEQtFGumBQ63Pf1MY6+qQv IJZazVj8lLFhz607fWrUEAeJ/7B7f2iCc/e8pl+uHSMzcGZ62yhz4/OP6wICuuotSmrhk4JXUtb M28p7hoTH5deQciOi6L/SS1Y/4p82eJtsIYtSPMW9z8548Ct+Ud5I4nZYL3F1vO+5ED/jNVYSsK UQzzhPso0uQJp40dfnQyA1M/2P1T8vsyR9RZHDSonE8f7cxl9lFiNxeCEc2SJVmjjrLYNbxam22 yPBJo4bwLtirSTPqHPzmUm/P8r2N1qSSbx0sCStv6Z7a0JIzU/z8opb2T9INuF++AexY7n5C0g6 r+Kx/o9vvIfui7Oi9dJDDlVMI7E6E2DOKpPBsCNRsTcYKEN9S1jHqps6217Du8vqZ8v5aL1J7uf B7rtanVfi6s8VWbQcOOXRm8hRDKd5s7sjVHiKbLjITp7am4TMRmHOdNi7Uc/NNOKaOvFIKgVedg dNkvL5gXQClxfCwJ/Crq7TrC5tUQ7PTd8v1wBOnNAMeVGRkDF7InIOaWaWLhUEwvi9CXM79qF/l 1zlw9L+tVGJhF0A== 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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772044098566796868 X-GMAIL-MSGID: 1772942568307353954 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 Tested-by: Alexander Stein Reviewed-by: Laurent Pinchart --- Changes in v3: - Use drm_for_each_bridge_in_chain() - Drop extra comment - Fix whitespace issue - Call drm_bridge_debugfs_init() only if the driver uses modeset - Drop #ifdef for drm_bridge_debugfs_init() declaration - Link to v2: https://lore.kernel.org/r/20230721-drm-bridge-chain-debugfs-v2-1-76df94347962@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 | 46 +++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_debugfs.c | 3 +++ include/drm/drm_bridge.h | 3 +++ 3 files changed, 52 insertions(+) --- base-commit: a0c64d153d687756c8719b8d10e609d62e1cb6fd change-id: 20230721-drm-bridge-chain-debugfs-0bbc1522f57a Best regards, diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index c3d69af02e79..39e68e45bb12 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -27,8 +27,10 @@ #include #include +#include #include #include +#include #include #include @@ -1345,6 +1347,50 @@ 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); + + drm_for_each_bridge_in_chain(encoder, 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++; + } + } + + return 0; +} + +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 "); 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 a3a488205009..3b1de2c61c89 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -274,6 +275,8 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id, if (drm_drv_uses_atomic_modeset(dev)) { drm_atomic_debugfs_init(minor); + + drm_bridge_debugfs_init(minor); } if (drm_core_check_feature(dev, DRIVER_MODESET)) { diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index bf964cdfb330..cb10ee108538 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -949,4 +949,7 @@ static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, } #endif +struct drm_minor; +void drm_bridge_debugfs_init(struct drm_minor *minor); + #endif