public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: linux-kernel@vger.kernel.org
Cc: Amarula patchwork <linux-amarula@amarulasolutions.com>,
	michael@amarulasolutions.com,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	David Airlie <airlied@gmail.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH v4 02/10] drm/bridge: Fix a use case in the bridge disable logic
Date: Tue,  5 Dec 2023 11:52:49 +0100	[thread overview]
Message-ID: <20231205105341.4100896-3-dario.binacchi@amarulasolutions.com> (raw)
In-Reply-To: <20231205105341.4100896-1-dario.binacchi@amarulasolutions.com>

The patch fixes the code for finding the next bridge with the
"pre_enable_prev_first" flag set to false. In case this condition is
not verified, i. e. there is no subsequent bridge with the flag set to
false, the whole bridge list is traversed, invalidating the "next"
variable.

The use of a new iteration variable (i. e. "iter") ensures that the value
of the "next" variable is not invalidated.

Fixes: 4fb912e5e190 ("drm/bridge: Introduce pre_enable_prev_first to alter bridge init order")
Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

(no changes since v1)

 drivers/gpu/drm/drm_bridge.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index f66bf4925dd8..2e5781bf192e 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -662,7 +662,7 @@ void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
 					  struct drm_atomic_state *old_state)
 {
 	struct drm_encoder *encoder;
-	struct drm_bridge *next, *limit;
+	struct drm_bridge *iter, *next, *limit;
 
 	if (!bridge)
 		return;
@@ -680,14 +680,15 @@ void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
 				 * was enabled first, so disabled last
 				 */
 				limit = next;
+				iter = next;
 
 				/* Find the next bridge that has NOT requested
 				 * prev to be enabled first / disabled last
 				 */
-				list_for_each_entry_from(next, &encoder->bridge_chain,
+				list_for_each_entry_from(iter, &encoder->bridge_chain,
 							 chain_node) {
-					if (!next->pre_enable_prev_first) {
-						next = list_prev_entry(next, chain_node);
+					if (!iter->pre_enable_prev_first) {
+						next = list_prev_entry(iter, chain_node);
 						limit = next;
 						break;
 					}
-- 
2.43.0


  parent reply	other threads:[~2023-12-05 10:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05 10:52 [PATCH v4 00/10] Add displays support for bsh-smm-s2/pro boards Dario Binacchi
2023-12-05 10:52 ` [PATCH v4 01/10] drm/bridge: Fix bridge disable logic Dario Binacchi
2023-12-05 10:52 ` Dario Binacchi [this message]
2023-12-05 15:39   ` [PATCH v4 02/10] drm/bridge: Fix a use case in the " Dave Stevenson
2023-12-06 13:26     ` Dario Binacchi
2023-12-06 13:31       ` Jagan Teki
2023-12-06 13:57         ` Michael Nazzareno Trimarchi
2023-12-13 11:59           ` Dario Binacchi
2023-12-13 12:02             ` Jagan Teki
2023-12-13 12:17             ` Maxime Ripard
2023-12-05 10:52 ` [PATCH v4 03/10] drm: bridge: samsung-dsim: enter display mode in the enable() callback Dario Binacchi
2023-12-05 10:52 ` [PATCH v4 04/10] drm: bridge: samsung-dsim: complete the CLKLANE_STOP setting Dario Binacchi
2023-12-05 10:52 ` [PATCH v4 05/10] dt-bindings: display: panel: Add synaptics r63353 panel controller Dario Binacchi
2023-12-05 10:52 ` [PATCH v4 06/10] drm/panel: Add Synaptics R63353 panel driver Dario Binacchi
2023-12-07  5:26   ` Dan Carpenter
2023-12-05 10:52 ` [PATCH v4 07/10] dt-bindings: display: panel: Add Ilitek ili9805 panel controller Dario Binacchi
2023-12-06 14:33   ` Rob Herring
2023-12-07  9:29     ` Krzysztof Kozlowski
2023-12-07  9:41       ` Maxime Ripard
2023-12-05 10:52 ` [PATCH v4 08/10] drm/panel: Add Ilitek ILI9805 panel driver Dario Binacchi
2023-12-05 10:52 ` [PATCH v4 09/10] drm/panel: ilitek-ili9805: add support for Tianma TM041XDHG01 panel Dario Binacchi
2023-12-05 10:52 ` [PATCH v4 10/10] arm64: dts: imx8mn-bsh-smm-s2/pro: add display setup Dario Binacchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231205105341.4100896-3-dario.binacchi@amarulasolutions.com \
    --to=dario.binacchi@amarulasolutions.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linux-amarula@amarulasolutions.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=michael@amarulasolutions.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox