Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp338833rdb; Thu, 30 Nov 2023 06:17:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3AShzYtIz27IpS57cGergXhaL2Ixo3+CmBJqFnPVXL5QFj6SNNFqIN2jz3V2TSZrGrnaG X-Received: by 2002:aca:901:0:b0:3b8:5c87:767f with SMTP id 1-20020aca0901000000b003b85c87767fmr17511707oij.51.1701353850637; Thu, 30 Nov 2023 06:17:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701353850; cv=none; d=google.com; s=arc-20160816; b=kMMv+2PUnbQn+0JCtpbbQeIf2gyDQOnxsaxK/MiTjv6Kee4aMw04610++nsoH048Io fANpkzmSsf3tA4UWXVNouNZIS2+NhcF443PZHyxUSTjCtxdC0u94ja/LyDATjcX4JMpn 6WaxJoD6v6u49XvfOlTa3I3l1gH9PrDMtuDi4BktFSw1lkpGU8Sweh0XykaccmE7yosb HumOkipDZ5m7MP+poX+0AOFFC9rf/XDXrosEg2aTr5mb0NzPGmw0ovDdTVe8qjFvwbOL hiCsz9jyV8JCk5MohB0qial0eB5fA28Np2W1kSRR/Voa3gp0Giu43e6UZnNztRrns2p9 Ce3Q== 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=fu0Px4Tbxip0tKoFWKIyTvbcuMI1IJ2fyAiFtPcJOWc=; fh=yrurfj0wqsNBtuv2/DS7hXM5gjUdNl0RGba7zZuGnHQ=; b=WwtXYGbo9tnH83d87DVbvacQ2i9Xc6gVzETDII0XvbK+O2FRwojs1dEcgeeow4X/SF 7a1oF1Qq0Yr2SGiLHVNmOMmjcICGkzoPPkFrWzFI5WbZanIeNbLJ0gh7+iKFtsGXPEGL n9HxQw6Y3aIkKqlYNNrcfguu1Aki+c9m+uTb7A9qsDRqj/CK1Zo1XDevqGMs01aTscEj y+5K9qNkvYqro/x/kQ8tbH+b3B7g7wsT3+tDG/4P3etReIc9sYoT2UWqqlYUbt2PQ5BT uyqIOF6kPYbcHkR03yuMcceDL+WLoUGxcFi+F7BAKdU4zwvyO0X4ZY3OIym2juOwPpw2 rOig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WKUeHvW1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m1-20020a0568080f0100b003b844ca526esi509235oiw.324.2023.11.30.06.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 06:17:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WKUeHvW1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 44EEB8026DCC; Thu, 30 Nov 2023 06:17:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345946AbjK3ORO (ORCPT + 99 others); Thu, 30 Nov 2023 09:17:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345930AbjK3ORL (ORCPT ); Thu, 30 Nov 2023 09:17:11 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D404F85 for ; Thu, 30 Nov 2023 06:17:17 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-54bfa9b3ffaso1116953a12.1 for ; Thu, 30 Nov 2023 06:17:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1701353836; x=1701958636; 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=fu0Px4Tbxip0tKoFWKIyTvbcuMI1IJ2fyAiFtPcJOWc=; b=WKUeHvW1UfvIzoIM+Zt/rulv0IcAV84RRBZR2M9w+hEa2zTAkcpXUF6qRBGaJvF8qT jkzCuRSgpiSm2+wL/YmT8OIWDtisvmGogX4AD/OfzWui44McQKJPsHe6tmZhjY8Cnqtw duO86GnfrgKNjbaa5s1bosIXPWorU6xArM/NI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701353836; x=1701958636; 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=fu0Px4Tbxip0tKoFWKIyTvbcuMI1IJ2fyAiFtPcJOWc=; b=GfBhR+ynLp5qogncFz59Akjw6wlGCncI88sOTYJCdcoN5JrSMEgUyPPkrS+1+QR7a0 PjuZLFayc3MAibq2sBsV1Db5exGI1RP0arGXRaqw6uXUaDr/kAhM6o1aTWT73vPG7ail uOR/jqZ8VXWmMlkYfiUik+UyPPxr6rAYIAgJc0J8lDD2TW4VkZ9M2wVxsIWSPR+wKaBA OZlYD8Qnrq4ISREQShwOPVPO7U4xdsKx+NUHJ95g0FOG4PzFPTzAeLD5RXcacikPElJ5 +piPAm4QDdwWd6cazYggMkghrbrvnl+aQQ6od/aa7k9Q2tH2/5Udrz98h9gRb7eM61VO 3Ybg== X-Gm-Message-State: AOJu0Ywss+lz0IRuKEQbr8MRmu36gPB7BiR7j6RHSDtsxT6fCUVnpbsX EAqvpjMcoKLMtrstPtiT00Qp9JYqrl76zAVGR2/QCA== X-Received: by 2002:a17:907:1051:b0:a18:bb79:9a0 with SMTP id oy17-20020a170907105100b00a18bb7909a0mr1186409ejb.58.1701353835975; Thu, 30 Nov 2023 06:17:15 -0800 (PST) Received: from localhost.localdomain ([2001:b07:6474:ebbf:d1eb:b106:516d:db0a]) by smtp.gmail.com with ESMTPSA id my18-20020a1709065a5200b009f28db2b702sm716064ejc.209.2023.11.30.06.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 06:17:15 -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 v3 02/10] drm/bridge: Fix a use case in the bridge disable logic Date: Thu, 30 Nov 2023 15:16:19 +0100 Message-ID: <20231130141705.1796672-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231130141705.1796672-1-dario.binacchi@amarulasolutions.com> References: <20231130141705.1796672-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_NONE, SPF_HELO_NONE,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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 06:17:29 -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.43.0