Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2481853rdh; Sun, 26 Nov 2023 07:55:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXqphocadO7FOGz+Rtavb6Zb5AzoHFBIqkGrx0epmM8a4s9nIo1/UJaIVLcBdpoc6MMyi/ X-Received: by 2002:a05:6a00:23d6:b0:6cb:8c70:47c3 with SMTP id g22-20020a056a0023d600b006cb8c7047c3mr19572343pfc.0.1701014103736; Sun, 26 Nov 2023 07:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701014103; cv=none; d=google.com; s=arc-20160816; b=Bub5piK7kLTVbG21IiHRCj0iNelsuTEqFzvtQBY5GcP4bkaP1tfHH+rSpcEd40xbL/ OuBOS2RQdTQ4bXGPH6k7LMzA/8RwutxlTAAJhqaFm1G4rXlXLbXCm9HdBdOFWwAoI0nP yYsw316R5dryLYj9jaGpOntNq45P6aUxlGM9P2Gsbqc7dWFQ/fJh4TmV9yeCs95Lqu// amT251sgNMKPS+chpjoJ+pSOJ5dUKO6E/noWCPN27FZFtOQPl4XcjbL06ZzOb6DZhvS0 scyVncZJCRkoGDMR9CEqV00LRNAO0wbCWRGr9Et1BbNQQ7WYiSQhD3+YNOkMfxcMjjIT JcXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=beJZbKgVXOvauoKe8Q8WUu/Tdv6GIAu4T+G5aSDiyXw=; fh=yrurfj0wqsNBtuv2/DS7hXM5gjUdNl0RGba7zZuGnHQ=; b=DMPG3b0oftWEOtKfwIpzJOz6na1Mv1PX+Gxhc9+/auWZU4lMYUvHCD59HurB0WJxjX CHFbTtoKRQrH10yNE0Cc+kF3IUtqm4sd+foZL7TKdglQ2jHFW/oO/7c5mw9H+sThbJTm lWoJGKiobGNafkB+vLX+TORNx4/8o6Wk5GE/m2rbd+jNRV2pYguXur4aS6Xk78pMtv8f 0j9ERxDCpHbi0jnV/5LvSosF5NEAQM6yL9iQOKQVYR1b3rIVbrT7sh/Yzv4bd1JBT+rg /l1O/YBP3kth2f3u2lEKoVfY9R3Uvg/PGJd97iQLYqVhPlcZvk+t4Jb6zrW+tZ1w45zI h1ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ilvDmsPF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x190-20020a6263c7000000b006cb997a5f83si7405389pfb.31.2023.11.26.07.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 07:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ilvDmsPF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 492A580B028C; Sun, 26 Nov 2023 07:54:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231475AbjKZPrP (ORCPT + 99 others); Sun, 26 Nov 2023 10:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230243AbjKZPqe (ORCPT ); Sun, 26 Nov 2023 10:46:34 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2212E107 for ; Sun, 26 Nov 2023 07:46:41 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a00cbb83c82so488912666b.2 for ; Sun, 26 Nov 2023 07:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1701013599; x=1701618399; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=beJZbKgVXOvauoKe8Q8WUu/Tdv6GIAu4T+G5aSDiyXw=; b=ilvDmsPFXBSj0Us7+oJysEEVrS2Bo6JJQmyeJwrNeMK/GFBpdZ8JYSdbLdJTaz7dkY OYLfSGTHeg4IAdM2sY2gTxk2VbFhWtQj6TKmD6wXKNXSrJx7eWvmaGMm10LgoHxHqkcO pznZND6wrjvdAAVzHE/30Z3psxkUorB4WWTaY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701013599; x=1701618399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=beJZbKgVXOvauoKe8Q8WUu/Tdv6GIAu4T+G5aSDiyXw=; b=Kx75JlNIXTIaVX7Flr4ZOta5SkFsPgREk5viNwZrnNdzaOWo8ou8DAk2I2K5yQpOzP UIbBMQYLdjWbAmSSuufBmXTxICzq2IjMAIXWM3r4SiRjVlgCBqgZmz+eI8uX2xX3c3re TcMiNfu7+UTTCOyewQIpYNb2GW0+pBfNHdiUpV/wy9bHh9vl0boYDBKKOoH1as2uUwK4 TKoN7ZUoNnzSDwaoomQz86AkZ1Ovuj8vjUsdSDPtEkBlNSlcMZwZJ8j+m0K3qU6pzMEQ v3ItadtWrFm41YlJ36uZd82Kfup/vNP9v8Rj2UEtL9Sq8MOFLBLVxlsz6Az3CFhsoceB MrhA== X-Gm-Message-State: AOJu0YxvG6O09RjCsw7Rg6u+OQVW3wgIWT1T1pBgJJ1JaKXNH+APE81x 7BBl+NzXfXVlx4fGzW0z8HYJ9euWbEfFe1SEKRwiGw== X-Received: by 2002:a17:906:1d2:b0:a08:e229:5659 with SMTP id 18-20020a17090601d200b00a08e2295659mr5777948ejj.17.1701013599386; Sun, 26 Nov 2023 07:46:39 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-244-100-54.retail.telecomitalia.it. [95.244.100.54]) by smtp.gmail.com with ESMTPSA id h24-20020a170906591800b009fdc684a79esm4656158ejq.124.2023.11.26.07.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 07:46:38 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , Andrzej Hajda , Daniel Vetter , Dave Stevenson , David Airlie , Frieder Schrempf , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Robert Foss , Thomas Zimmermann , dri-devel@lists.freedesktop.org Subject: [PATCH v2 02/11] drm/bridge: Fix a use case in the bridge disable logic Date: Sun, 26 Nov 2023 16:44:54 +0100 Message-ID: <20231126154605.15767-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231126154605.15767-1-dario.binacchi@amarulasolutions.com> References: <20231126154605.15767-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sun, 26 Nov 2023 07:54:59 -0800 (PST) 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 Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- (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.42.0