From patchwork Sun Nov 26 15:44:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 13468879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 113C1C07D5B for ; Sun, 26 Nov 2023 15:46:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 55C5010E0F4; Sun, 26 Nov 2023 15:46:43 +0000 (UTC) Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by gabe.freedesktop.org (Postfix) with ESMTPS id D5F4110E0F4 for ; Sun, 26 Nov 2023 15:46:40 +0000 (UTC) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a00a9c6f1e9so488558266b.3 for ; Sun, 26 Nov 2023 07:46:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1701013599; x=1701618399; darn=lists.freedesktop.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=Rkry2TXy9v8Ltpk1YMw/r+hGlx4cQUBLxCLGgMeYLSI/Ky9e4e+Q/Aj5LSYqipZVh3 GL7KmAo/X1GheUXp7WNj9M9rvdAidB8AI26dKQObCN/rmzY9fscRqjpS+OEZ2gD5DJlS v0JrC437HiaBIpLHN/mvswMfeDfBY5AkGMAFM= 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=jzDPPvZaaccy00oQcoiFXACVadytN4WXRP30sGtZZBv5BNO4OfHspNqXiOntCpOEcM oE4lMHvPTTVlGY7DrDPVI1JNyUbO+6MUk9kOnajFjkSxZe09TSzIWyMHJg6ZPcMmB6lz u2MDDGjhmC+w+IzylMY8Ty96g2e72Jwjyx5TV6cb3pq5mZW/AvXEVhFQYn+uhaSrGRU+ 7PHCZthriJe8Uwyu02MfSy5E7go94x0R5Nna8r8M5jvcMzjQDPdowyGorVkPTWwtGcw/ D/hj9WbxWfKrb7mG3C9dZjb6qgqQO9jc0tJ4gWMILIjUffM8RVgAJSmK0QVbjmfd2DCD 9vqA== X-Gm-Message-State: AOJu0Yxhk5cKQ829A8b5j6/09pLmCS4pfLD5eNgNEG6E8P8aUXOrdAvJ VQ9rwB/j9njCTh4J3NrVAXzMFQ== X-Google-Smtp-Source: AGHT+IHYhBHEjGL+XT3j6Y6Bjm9VsxzehQvLDMtko3qtuBBCcOV0B5xoVy15karuyYZL/vnEhKjU1g== 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Neil Armstrong , Dario Binacchi , Robert Foss , Andrzej Hajda , Thomas Zimmermann , Dave Stevenson , dri-devel@lists.freedesktop.org, Jonas Karlman , Frieder Schrempf , Jernej Skrabec , michael@amarulasolutions.com, Amarula patchwork , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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; }