Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1333352pxb; Thu, 21 Oct 2021 21:46:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFlaa33cplFdYdFDenAEIcX/qRNSxJewV050+OC2f8Hpmd5Uwtaco2sKbFCAS31zZN8/PX X-Received: by 2002:a50:c31a:: with SMTP id a26mr13596755edb.193.1634877983006; Thu, 21 Oct 2021 21:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634877982; cv=none; d=google.com; s=arc-20160816; b=pDNUm7e+2XloJC05il5mzutbyXnX5rof4PLL1pV08kAIJekPjDXEicdUs8R7TIRTK7 If3UjHhNJGwaQ37DOrlCVK2uVHcY102Dglb9otrYCJGCiQLspAsn/wop2eBz54vsPzRV FpU51PtSpHIQgffuQo0UGK0RFUAasAwgQsDN6O67/jAoMBIIOIsVtWEaQ1tP6pXIptPF 6sIPXa+vAjcOv9stxM5yKXKJjIJnBKpzYKxDZkmqY+7PBUqT3e8JfFHJdJvbvZd45MmD J11WCoQ5Le7tMhD1w/4ntPXYAU/ZLIvJ7GBPFPWlg3J192RtUT2uMZSdxd9I8OQCmpfh CNCQ== 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=XZjo7gagt7hbXFVA5iGfVGhtWnqmqtLICxqNJUuRJ3w=; b=lXkYGXMZgIBJn25J8GBFCr59BIuRKycZuEyqtPm0Ua3htqEx3mD7m2UJJ75UEMItg2 h6ZBbID5G2APxUCQuTJzkRdnJMgImU3z/2x60StkMQIcImGxWi9jnQLar7KhRnRAYDin TTAzMyvDwqAJ2YymHyI4PQMOCI9KVs4ffE/N8lzcVxsZS0fDhuK2VVipnxTv6NDJTSqU naYjFL/Jx5XqleP0A/0Bt89EksQ4BUreFeBQAZYRmICofIJmflh8qxish5Z7Q54sc1Y3 LuWwXpf3BI3bTjriv8/g4vWfmXBaJOEv5beZMMUVI1oMxi7/DGm5YkVmjrmBhX13vyX+ hVZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=KCypfD8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si9594160ejd.91.2021.10.21.21.45.58; Thu, 21 Oct 2021 21:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=KCypfD8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232054AbhJVEq0 (ORCPT + 99 others); Fri, 22 Oct 2021 00:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231997AbhJVEqZ (ORCPT ); Fri, 22 Oct 2021 00:46:25 -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 46527C061764 for ; Thu, 21 Oct 2021 21:44:07 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 286C151D; Fri, 22 Oct 2021 06:44:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634877844; bh=eSwlb6YuqsR3uV5jKVNohlQDel9PmJlvK6dwAOAjDsE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KCypfD8VKzEQ/+Vk1MA66r5q6tixJm3CmYwu9qPcUX/i+r81BRaHbjC5WCmEwHKYh 0nNPUAPt+OC7sJMfebGkRQsQ3oyGBOCNI0ssp5ZPgq0PiFU6q0UjJFaPHCs9TwiB+3 VeGUGrrvKImkXOt9fiYUXcPWV6SAXB/c9X38IN/s= Date: Fri, 22 Oct 2021 07:43:44 +0300 From: Laurent Pinchart To: Douglas Anderson Cc: dri-devel@lists.freedesktop.org, Philip Chen , Boris Brezillon , Daniel Vetter , David Airlie , Jagan Teki , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Robert Foss , Thomas Zimmermann , linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/bridge: Fix the bridge chain order for pre_enable / post_disable Message-ID: References: <20211021122719.1.I56d382006dea67ed8f30729a751fbc75434315b2@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211021122719.1.I56d382006dea67ed8f30729a751fbc75434315b2@changeid> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Doug, Thank you for the patch. On Thu, Oct 21, 2021 at 12:29:01PM -0700, Douglas Anderson wrote: > Right now, the chaining order of > pre_enable/enable/disable/post_disable looks like this: > > pre_enable: start from connector and move to encoder > enable: start from encoder and move to connector > disable: start from connector and move to encoder > post_disable: start from encoder and move to connector > > In the above, it can be seen that at least pre_enable() and > post_disable() are opposites of each other and enable() and disable() > are opposites. However, it seems broken that pre_enable() and enable() > would not move in the same direction. In other parts of Linux you can > see that various stages move in the same order. For instance, during > system suspend the "early" calls run in the same order as the normal > calls run in the same order as the "late" calls run in the same order > as the "noirq" calls. > > Let fix the above so that it makes more sense. Now we'll have: > > pre_enable: start from encoder and move to connector > enable: start from encoder and move to connector > disable: start from connector and move to encoder > post_disable: start from connector and move to encoder > > This order is chosen because if there are parent-child relationships > anywhere I would expect that the encoder would be a parent and the > connector a child--not the other way around. > > This can be important when using the DP AUX bus to instantiate a > panel. The DP AUX bus is likely part of a bridge driver and is a > parent of the panel. We'd like the bridge to be pre_enabled before the > panel and the panel to be post_disabled before the > bridge. Specifically, this allows pm_runtime_put_sync_suspend() in a > bridge driver's post_suspend to work properly even a panel is under > it. > > NOTE: it's entirely possible that this change could break someone who > was relying on the old order. Hopefully this isn't the case, but if > this does break someone it seems like it's better to do it sonner > rather than later so we can fix everyone to handle the order that > makes the most sense. I'm less hopeful than you are on this, changing the order of operations is very risky. I'm also concerned about hardware damage, the pre-enable operation is often used to power up devices, and powering up a source before a sink is dangerous as many devices don't like having I/O voltage applied to their pins before they get powered up. If you really want to land this, the patch needs very very broad testing, as well as a plan to address the power up issue. > A FURTHER NOTE: Looking closer at commit 4e5763f03e10 ("drm/bridge: > ti-sn65dsi86: Wrap panel with panel-bridge") you can see that patch > inadvertently changed the order of things. The order used to be > correct (panel prepare was at the tail of the bridge enable) but it > became backwards. We'll restore the original order with this patch. > > Fixes: 4e5763f03e10 ("drm/bridge: ti-sn65dsi86: Wrap panel with panel-bridge") > Fixes: 05193dc38197 ("drm/bridge: Make the bridge chain a double-linked list") > Signed-off-by: Douglas Anderson > --- > > drivers/gpu/drm/drm_bridge.c | 28 ++++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c > index c96847fc0ebc..98808af59afd 100644 > --- a/drivers/gpu/drm/drm_bridge.c > +++ b/drivers/gpu/drm/drm_bridge.c > @@ -583,18 +583,14 @@ EXPORT_SYMBOL(drm_bridge_chain_mode_set); > void drm_bridge_chain_pre_enable(struct drm_bridge *bridge) > { > struct drm_encoder *encoder; > - struct drm_bridge *iter; > > if (!bridge) > return; > > encoder = bridge->encoder; > - list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { > - if (iter->funcs->pre_enable) > - iter->funcs->pre_enable(iter); > - > - if (iter == bridge) > - break; > + list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { > + if (bridge->funcs->pre_enable) > + bridge->funcs->pre_enable(bridge); > } > } > EXPORT_SYMBOL(drm_bridge_chain_pre_enable); > @@ -684,26 +680,30 @@ void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, > struct drm_atomic_state *old_state) > { > struct drm_encoder *encoder; > + struct drm_bridge *iter; > > if (!bridge) > return; > > encoder = bridge->encoder; > - list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { > - if (bridge->funcs->atomic_post_disable) { > + list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { > + if (iter->funcs->atomic_post_disable) { > struct drm_bridge_state *old_bridge_state; > > old_bridge_state = > drm_atomic_get_old_bridge_state(old_state, > - bridge); > + iter); > if (WARN_ON(!old_bridge_state)) > return; > > - bridge->funcs->atomic_post_disable(bridge, > - old_bridge_state); > - } else if (bridge->funcs->post_disable) { > - bridge->funcs->post_disable(bridge); > + iter->funcs->atomic_post_disable(iter, > + old_bridge_state); > + } else if (iter->funcs->post_disable) { > + iter->funcs->post_disable(iter); > } > + > + if (iter == bridge) > + break; > } > } > EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable); -- Regards, Laurent Pinchart