Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1686091rdb; Thu, 7 Dec 2023 06:19:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IESZUaTeCPDmgZIuEeqHWoXJpqnPXtCYKTyVq0EAiIo/yJNlW0zmXazK1jC+HC4yIPthbjt X-Received: by 2002:a92:cdad:0:b0:35d:6284:6b54 with SMTP id g13-20020a92cdad000000b0035d62846b54mr3409270ild.36.1701958780177; Thu, 07 Dec 2023 06:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701958780; cv=none; d=google.com; s=arc-20160816; b=VrWvG11fWOZNQz6wmpMatvJqt8ehfGX1HXVBIvEYIE5YKZGQC0R1SfsrvEBWmXxmEc ylZOqxVO+WrFJh8hbLFeR9PwATENotqe+B4OBbl6PsqgFM3aVlm5eSUK2D5yeZHN6OuD Yf7qh5pkidLKAUG0p1BYh/Kcz4KwSlsJQnpo18HodYrMzYyWmlyKzkJaX1KvRiPfIchv f22VJnr13Rq+M8+iioLTpA9RES4NTk/wJX1FaX4aHpODUbAh8dHVMVMpniemPdvEmvnt GN8s59Zfkx54YrPgfv1pw+dDrkP4JXt+R+dUTTnBkXEtWeZClbqCvRL5I637JjQfffx2 k+vg== 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=amRW9od0X0AyEMWJCtYrOhQXC+KTBW5+MThcQhiYCmRK+thwwKRwGGO+HqSklh2rsR oAP5mZspVmigPfpMnzIJUoH0mXTzj4Z3QOnNEa5t5bVMRM4gB7TZ8Pxj4AcpuJD855B7 9h2hWJs1vW+6VU59X0XPnTq8v1003B/Vdip63QKspTeVvgcRG+njknDQd0umui+d93TM XuhJusWDJb3CcLkpTu9bizy6Vt/lY5hOJh/joE87IoeVD+sXSzgL5FUtYUklKxyVsV7T O65oUIVZi2bh+MWLdAXDuN691xP2G+4SDu9GAD5h0I5O0GXLydBRG0iI71ZvO+fGRlKh Zg+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="P/zjBzBW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q9-20020a63f949000000b005c677919049si1218508pgk.757.2023.12.07.06.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 06:19:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="P/zjBzBW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 0D385803F7BC; Thu, 7 Dec 2023 06:19:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443401AbjLGOTN (ORCPT + 99 others); Thu, 7 Dec 2023 09:19:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443325AbjLGOSi (ORCPT ); Thu, 7 Dec 2023 09:18:38 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 572561FC0 for ; Thu, 7 Dec 2023 06:17:34 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a1e2f34467aso91279866b.2 for ; Thu, 07 Dec 2023 06:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1701958650; x=1702563450; 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=P/zjBzBWuo7MgP5j2NOsH5kzeNz9Is90YoKPKeZgsIF8KC9nt0v7TOEpU1ZXI12IRQ a4uHbSAh47vyEOX55uG1zsLH3XzSNMnmMCQTXywnmpPZtF02LYW6QbWkg1mVmtVwUdLy QVP+5KoPOMDURuj6UB2HD1VTqi+xJ2usuC1gk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701958650; x=1702563450; 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=vzjGWJD36OAHP86KZCD/IPOdPWhh4s3RMkgOuzHwvxVR86cIGaHYoxBr4PQGm+0Ddm cMi2OrV+45A4hj8xoQV9nHrM38ZjuCIpkk8KXVGVP5nbUJnwVgrc+ouXgBAGHKBYzvvq f2a2cIRq5HkAzIpx7taxgnjWm8L4eQCwJ3VX+wEfq1iu3lzX5DobK+lMb+vKBHFgq9Pa ROirWSJsCOB4iIdZusKRxIOkRXSVAbEW7ajydEknOYnmvfSOQQhmplXn2yS4jcDp0bXD SH8hT5gJ21mDE61NPJBuA6RMHNkkLuuD0Vu3JSYOXl8jTLrYw1zUKnuYB9RT9azJ7n6Z SwJg== X-Gm-Message-State: AOJu0YxzzJ9fg53DKo9YfJUxIJqbSBxhVfTNk6ZxxgU6vin1+XzC93S0 XWhg6I/YMm+szijoHc/vAKn75e8NJLuHuvEKslvY7Q== X-Received: by 2002:a17:906:ce32:b0:a1c:8b15:fc01 with SMTP id sd18-20020a170906ce3200b00a1c8b15fc01mr1663788ejb.33.1701958650470; Thu, 07 Dec 2023 06:17:30 -0800 (PST) Received: from localhost.localdomain ([2001:b07:6474:ebbf:9bf:959c:3c66:46c2]) by smtp.gmail.com with ESMTPSA id f24-20020a170906c09800b00a1e814b7155sm885421ejz.62.2023.12.07.06.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 06:17:30 -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 v5 02/10] drm/bridge: Fix a use case in the bridge disable logic Date: Thu, 7 Dec 2023 15:16:31 +0100 Message-ID: <20231207141723.108004-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231207141723.108004-1-dario.binacchi@amarulasolutions.com> References: <20231207141723.108004-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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 06:19:36 -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