Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp200273rwo; Tue, 1 Aug 2023 15:32:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFA5FQERlb03YHw8ls37Pc8hcjoK/XUAPP+xNc6Vo82pLrHeE5KzRfX9ZNrFfCHiGOLVo8T X-Received: by 2002:a17:906:30d9:b0:997:6729:5f4b with SMTP id b25-20020a17090630d900b0099767295f4bmr5141459ejb.11.1690929160920; Tue, 01 Aug 2023 15:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690929160; cv=none; d=google.com; s=arc-20160816; b=WrgyNXpzOyhL9AI4PyWvdEHsym+fPeCtLl8pw0goTEHt1dcfdP92es/zf1BZBLCZxn olbobbVGEGyunpDA63JXKRu0d+h3SFX/Ix0WW59Mzd4IO4DchvT9KGBDVIjQguhNyXFF jc4JHmHJSY+Wnvmjh/96kpXEpyYTkRdtVgbu40n3FIYuSxXmxcpmUxMrx2onBFBLA/Kv s5Ff8Gc4a8dmO+dI5xayBudgV27dHiwKb+GrENDy8HmmtWTD/GbzMehA+qJLZTB6RUGb N/oSdAWrvENc7karx+IsXVn/9E9pbxnyDLTTwJ9JB1COEbSGttmzWB1HnldRwwFlsXdV nwKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vJuTcN3oUHNfnsUlH6RT2R5DboHB0ecOrZMVe53EG6A=; fh=0gnoR0bIQE5POQzjvZThGrsu0fTYqonDAxWxb2aRla4=; b=ETUPPLw/+rKnJxC1C1MSMrs90xB+GF982lLqIzl81GTfgRTr1MZJt6QTPTT5GTf0sg Hahejh5BAvhV85RATAhK5eRwcP1HyOORIuSSadXevg9WiAi+7Jzfuo57mQRGAKIiU03P D7brW5gobo6xbARtXXzW9YPkK4XeuL3zcSzz/hjAVgNObbLTKGgfFqYUrZ1IGsFNroDM hrrn2zLzZtA5zgiUUZ7g3gJIuxOF7ekIG35V5L7KbZsLr+x4ayY+M/JLF4XkbBvrZdA6 K918KPqxfff9Oupth87Z4DL9ZS99mZ/p5WJ+EkhGhdkjks0J0CvWVzvx7IxUT/Z6IHT6 J99A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=pXww2Bwi; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a170906524d00b009930c925bd9si8675045ejm.945.2023.08.01.15.32.13; Tue, 01 Aug 2023 15:32:40 -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=pXww2Bwi; 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 S232356AbjHAVfy (ORCPT + 99 others); Tue, 1 Aug 2023 17:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232314AbjHAVfx (ORCPT ); Tue, 1 Aug 2023 17:35:53 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 085C41710 for ; Tue, 1 Aug 2023 14:35:50 -0700 (PDT) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6F5678D; Tue, 1 Aug 2023 23:34:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1690925685; bh=MFrgXENkqlcRfX+EcNkS5B5eqVfsBlbWWD9455+s2wU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pXww2BwiAlcpMLRrthanfJuKSooNTgMfkM8H9jjdg/QIIDYgyM3+vFT+VwNq0kS4T 10vdRipTLIkDX5qB08/UsjMKX5YmQkrQ8LeyZHoc+CsOhpGarXUBS+eeAt7wnYTMpW P+O+/1AYseQWDYT9uBt9OPYCG7IzfuKap7dDMdzc= Date: Wed, 2 Aug 2023 00:35:54 +0300 From: Laurent Pinchart To: Tomi Valkeinen Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Francesco Dolcini , Aradhya Bhatia , Alexander Stein , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] drm/bridge: Add debugfs print for bridge chains Message-ID: <20230801213554.GE8578@pendragon.ideasonboard.com> References: <20230731-drm-bridge-chain-debugfs-v3-1-7d0739f3efa3@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230731-drm-bridge-chain-debugfs-v3-1-7d0739f3efa3@ideasonboard.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tomi, Thank you for the patch. On Mon, Jul 31, 2023 at 03:13:14PM +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 > > Signed-off-by: Tomi Valkeinen > --- > 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(+) > > 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); > + You could drop the blank line, up to you. > + 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; Let's move this to tbe beginning of the file with the other forward declarations. With this addressedn Reviewed-by: Laurent Pinchart > +void drm_bridge_debugfs_init(struct drm_minor *minor); > + > #endif > > --- > base-commit: a0c64d153d687756c8719b8d10e609d62e1cb6fd > change-id: 20230721-drm-bridge-chain-debugfs-0bbc1522f57a -- Regards, Laurent Pinchart