From patchwork Tue Mar 28 17:07:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2823 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 867DA4147B for ; Tue, 28 Mar 2023 19:08:17 +0200 (CEST) Received: by mail-pf1-f199.google.com with SMTP id o14-20020a62f90e000000b0062d87d997eesf2862992pfh.18 for ; Tue, 28 Mar 2023 10:08:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680023296; cv=pass; d=google.com; s=arc-20160816; b=FgBHLRHBwBrXk2fxjnb6oTYOWDzUoHxARGp5JBYb8EBihGcXX1iQN+8GHNpriWrYhW cfe0Hz0AnK7EKyvldF9zA2Sc+oixweMuDMSC7ogUegYAG/2FWYcIEMNhNs6qC+NpiEDZ xHigI4c2eddwJIOg4qJhCE4p3L00X0MssV/FPR+misLkLRpQxhlfeMJpEsplmvz3WaCz HGNVJ/2FwIN+ZndDulIsNhwfzc2ZIvyTslBxM0LjALTq8XDxUkH556wbNxFPhwmxEnJr Oucwo48ZHcqr2iPAqKmfqI+OxGuIp9xkjjqFRQUnY6oPdfG3Cn3ySYIaXT0+FMU0FU0X mwrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=tK8A/UnDAf5nWRLW3sxGzwwcbVZCDIACPEMf9jJuZsI=; b=DVMRMd62lMgJYJs13OkaTzhtXaQ7VzX9krSRfusqt5WhGC7Qx3XoEdq2IrIXgXrX+O 3U4vnGshIdOjp8JqthKADsVlz5nyrILm1hZcE2WoziP4WdJilAt3nXujddMNr5lCo0t4 mgMUsj0EXfxj6wcm8Hmg8ggeIa9KSXUhvWGQV0EOSeh6slH7YxbAozh+f0L9FLRAWFmd VbzjDTrdYhp+TUHcEY7ptUyckzCMQJNJLmGi2J7KWjyRtM48uMzldmDwaDjykWULNcwI ZjwywZxbsIbTeIlGvF0kljYsOJDdDQ/SHTkgwyKqp9Ra22UZ2hb9w3iJJvbDnj/OMETw +++g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="lL/wtX/B"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680023296; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=tK8A/UnDAf5nWRLW3sxGzwwcbVZCDIACPEMf9jJuZsI=; b=EsT7Vd2IR/VZZZ+T/dMOmmjvlIRYjviCE335ean9bOVJil71rbJT/yaaMliZTAsuFH MeVTH5Wf2yNrLeWJGiGWwgzPGxfujaT60YtbHA4aYh+5MAqftRsiTFnazhHsB4hu7uRP EqFcrwrKz+LE3Ox0TOJ4HhUn3E8AhwNvhCHJw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680023296; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tK8A/UnDAf5nWRLW3sxGzwwcbVZCDIACPEMf9jJuZsI=; b=zU83ZARWFrtgOs9au3kY9lsqSE3M6h35HBoKPIDHbishbAcNie10o39eexzTqD34F7 i+9GNo6UJE1pFYMB2gSoO18bQeB4jkTxVP5BtDNhRwZGRrJ+KPlzyhAotH0KsNQ8NvzG XEwvJn5cl9FHLJepcS7Riubb6kSOa4kc6yFiUSM973QqE/rchey6seMsDKVocns+PkTY coTQne3v6jz0Net1oPQGBmk/k0PCE5pBNVlIEPNL5aNqsK3aVucGZgmbN0cDvC2YfTZ/ 7ocTZCHOWbxQ7WAeJbRVnAMYvR7ATCV+iSqHxohqJGerBdGW3VfQcC7j8UnwahnryRPD 03Iw== X-Gm-Message-State: AAQBX9ex6YdNyqlM6hOpiu+ToNRmhhuordZwbZbJiycZzhZrrnuUoUop XXPSloF6CYoDQOlU5jGVV0teDDbR X-Google-Smtp-Source: AKy350aIO9j28u4gF0H+LrJY7hZardITcPHd/h+xFMahJp61EDJD5MpwrB3F5L33pxl57Xqk41tMaA== X-Received: by 2002:a17:902:9041:b0:1a1:bbc5:be8e with SMTP id w1-20020a170902904100b001a1bbc5be8emr6006370plz.11.1680023296078; Tue, 28 Mar 2023 10:08:16 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:ecca:b0:199:50f5:6729 with SMTP id a10-20020a170902ecca00b0019950f56729ls10421915plh.11.-pod-prod-gmail; Tue, 28 Mar 2023 10:08:15 -0700 (PDT) X-Received: by 2002:a17:902:d48b:b0:1a0:4046:23f2 with SMTP id c11-20020a170902d48b00b001a0404623f2mr19657287plg.56.1680023294911; Tue, 28 Mar 2023 10:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680023294; cv=none; d=google.com; s=arc-20160816; b=w+m5wlODfCh/O4OUinKuQEUyOAZNsx5vwAbrtBGsNAUBCklllPVSrJJ88QIQ/9CUjP MyB73786O0t864bpm37N9cuZ49PG7s6FSoi6ncp6J7OV7eybgZziB/KO7+KV/Hsy2ozl h5l+POr+Z25haAHpnjvVONkOV8s+qtaDdcGh0HzBvpqhradeNxzkxsve2csGmQpW4Zzd ytiet7eHKVI5Oa1yCFCw3AA00ylkE+l/+0p81kK6e2oc9lS/n0JmHzKguB0LI8O9fLOg RX5/QdFcA1PiGdGKLqVKfVX7fGvd7pTFFfYBfnqHSfsdspYzQh3PuqekNn7sjINzH7lv YMmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=O72nQMvXwuS9p7u9XEXsCt0AwfhA6j8fJBtuOxggIi4=; b=dISKYzSzhdrMcEGEsxO3Issh6jaONSv78+t++uqtzQb7sWs7l1pDEWl54cmvb6IhmO AgoOYCK4ox+yjqrYOEZF8hDIrVq++s1wENoSw4LB2meT12Aa15yuPUWRDiS6BdVXLmwg f2JgKxGnZBYydNqDq/fOhtC/5E7RDh2I9EOS+IdEsA9G0AOEc8LkAKHxZmEoiEuzUOml qp3OglsCMvpvQ+Wiyk0IZzXdqvlE9BZwhpsrlw+o7CSsYlKqRUnXrZqlotMqcXkkZcHb 2w1Kn6aF4XxQe6+xuTrnZ+sHX1Fp3f9Z12s2szgzypcXjJ92LkxqBcFjDcjRlRf5ji9g PZ4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="lL/wtX/B"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id j23-20020a170902759700b001a21fceff32sor4123605pll.79.2023.03.28.10.08.14 for (Google Transport Security); Tue, 28 Mar 2023 10:08:14 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:902:d4c3:b0:19f:36ae:c29f with SMTP id o3-20020a170902d4c300b0019f36aec29fmr21442520plg.46.1680023294314; Tue, 28 Mar 2023 10:08:14 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c00a:a047:2fbc:aff5:d52a:cc2c]) by smtp.gmail.com with ESMTPSA id y17-20020a170902b49100b0019f114570b0sm20470349plr.152.2023.03.28.10.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 10:08:13 -0700 (PDT) From: Jagan Teki To: Dave Stevenson , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong Cc: dri-devel@lists.freedesktop.org, Marek Vasut , linux-amarula , Jagan Teki Subject: [PATCH v2 1/2] drm/bridge: Fix improper bridge init order with pre_enable_prev_first Date: Tue, 28 Mar 2023 22:37:51 +0530 Message-Id: <20230328170752.1102347-1-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="lL/wtX/B"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , For a given bridge pipeline if any bridge sets pre_enable_prev_first flag then the pre_enable for the previous bridge will be called before pre_enable of this bridge and opposite is done for post_disable. These are the potential bridge flags to alter bridge init order in order to satisfy the MIPI DSI host and downstream panel or bridge to function. However the existing pre_enable_prev_first logic with associated bridge ordering has broken for both pre_enable and post_disable calls. [pre_enable] The altered bridge ordering has failed if two consecutive bridges on a given pipeline enables the pre_enable_prev_first flag. Example: - Panel - Bridge 1 - Bridge 2 pre_enable_prev_first - Bridge 3 - Bridge 4 pre_enable_prev_first - Bridge 5 pre_enable_prev_first - Bridge 6 - Encoder In this example, Bridge 4 and Bridge 5 have pre_enable_prev_first. The logic looks for a bridge which enabled pre_enable_prev_first flag on each iteration and assigned the previou bridge to limit pointer if the bridge doesn't enable pre_enable_prev_first flags. If control found Bridge 2 is pre_enable_prev_first then the iteration looks for Bridge 3 and found it is not pre_enable_prev_first and assigns it's previous Bridge 4 to limit pointer and calls pre_enable of Bridge 3 and Bridge 2 and assign iter pointer with limit which is Bridge 4. Here is the actual problem, for the next iteration control look for Bridge 5 instead of Bridge 4 has iter pointer in previous iteration moved to Bridge 4 so this iteration skips the Bridge 4. The iteration found Bridge 6 doesn't pre_enable_prev_first flags so the limit assigned to Encoder. From next iteration Encoder skips as it is the last bridge for reverse order pipeline. So, the resulting pre_enable bridge order would be, - Panel, Bridge 1, Bridge 3, Bridge 2, Bridge 6, Bridge 5. This patch fixes this by assigning limit to next pointer instead of previous bridge since the iteration always looks for bridge that does NOT request prev so assigning next makes sure the last bridge on a given iteration what exactly the limit bridge is. So, the resulting pre_enable bridge order with fix would be, - Panel, Bridge 1, Bridge 3, Bridge 2, Bridge 6, Bridge 5, Bridge 4, Encoder. [post_disable] The altered bridge ordering has failed if two consecutive bridges on a given pipeline enables the pre_enable_prev_first flag. Example: - Panel - Bridge 1 - Bridge 2 pre_enable_prev_first - Bridge 3 - Bridge 4 pre_enable_prev_first - Bridge 5 pre_enable_prev_first - Bridge 6 - Encoder In this example Bridge 5 and Bridge 4 have pre_enable_prev_first. The logic looks for a bridge which enabled pre_enable_prev_first flags on each iteration and assigned the previou bridge to next and next to limit pointer if the bridge does enable pre_enable_prev_first flag. If control starts from Bridge 6 then it found next Bridge 5 is pre_enable_prev_first and immediately the next assigned to previous Bridge 6 and limit assignments to next Bridge 6 and call post_enable of Bridge 6 even though the next consecutive Bridge 5 is enabled with pre_enable_prev_first. This clearly misses the logic to find the state of next conducive bridge as everytime the next and limit assigns previous bridge if given bridge enabled pre_enable_prev_first. So, the resulting post_disable bridge order would be, - Encoder, Bridge 6, Bridge 5, Bridge 4, Bridge 3, Bridge 2, Bridge 1, Panel. This patch fixes this by assigning next with previou bridge only if the bridge doesn't enable pre_enable_prev_first flag and the next further assign it to limit. This way we can find the bridge that NOT requested prev to disable last. So, the resulting pre_enable bridge order with fix would be, - Encoder, Bridge 4, Bridge 5, Bridge 6, Bridge 2, Bridge 3, Bridge 1, Panel. Validated the bridge init ordering by incorporating dummy bridges in the sun6i-mipi-dsi pipeline Fixes: 4fb912e5e190 ("drm/bridge: Introduce pre_enable_prev_first to alter bridge init order") Signed-off-by: Jagan Teki Reviewed-by: Dave Stevenson --- Changes for v2: - add missing dri-devel in CC drivers/gpu/drm/drm_bridge.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index c3d69af02e79..052a8e6c9961 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -684,11 +684,17 @@ void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, */ list_for_each_entry_from(next, &encoder->bridge_chain, chain_node) { - if (next->pre_enable_prev_first) { + if (!next->pre_enable_prev_first) { next = list_prev_entry(next, chain_node); limit = next; break; } + + if (list_is_last(&next->chain_node, + &encoder->bridge_chain)) { + limit = next; + break; + } } /* Call these bridges in reverse order */ @@ -771,7 +777,7 @@ void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, /* Found first bridge that does NOT * request prev to be enabled first */ - limit = list_prev_entry(next, chain_node); + limit = next; break; } }