From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88634C04EBE for ; Thu, 8 Oct 2020 11:25:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37EC12145D for ; Thu, 8 Oct 2020 11:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726012AbgJHLZ2 (ORCPT ); Thu, 8 Oct 2020 07:25:28 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:46609 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbgJHLZ2 (ORCPT ); Thu, 8 Oct 2020 07:25:28 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id AF696580314; Thu, 8 Oct 2020 07:25:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 08 Oct 2020 07:25:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=Zb15ltGpiJZp1 2wFhpBRBUlaJhC/18C0bN04Lnu613k=; b=ATQJfsOYvHV1lk6/+4PkMGvJQa5St idM5qGm6WJnTvHABr9T1jmcJQrnGeAzsaTsePKymRcACZcfQmWG8gR/AHnmqMwfM uL7w6sbUSGRt1ZMDZuNSAodznqgz88JbY2iGF2/hYdlUa+K2vVBNb0TeMY3v5kPp cIIESt3fUDXiDPSCxKQyLFAbGW7jEZZsc/dO/t9gBu2VIK2BJuD55MWZD9rmtRHv zBj76ExSgCMJOLMISK2JXomUujE693adDEBRuCtvCrB3oxBf95Ue700QLEUMHlmR ZcyzcDrYh8Lf9D5E8clqyUNEHHwjWXTjA9Ed/OnCDkaQyBC+BsQL5sGFQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=Zb15ltGpiJZp12wFhpBRBUlaJhC/18C0bN04Lnu613k=; b=ZL3LJjja smZVoihJBxrZaSQHv9F+eHK4HEH7uHHbdHJCRWbrfH0NkNy/se+O5I8oONRbfge6 Q9+WzY6VxZvitEMdM0idTc72Wx6MvQ3ePO5q7+dpds/ufIRrZQKd/2IZ1q9aMKq0 cygFBRzWNIGgpCpRs7uajx8KySqZ2iVuU6wjtV9Mkn8TZuBv6Cfq8S83w0cTiIpG VZCQOxYuk401BdbLWThdTySHoVDDD3ACgmlYBJEn2hoDqOU3bdStjAwzCzovcXBZ zw02NHr9o/hkP1awSb3eOA6d097lcCVPPJhjEa2uT+GGYbNqWvfiF+tAoZCxTLxi azY26NEp08omPw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrgeelgddufecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucfkphepledtrdekledrieekrdejieenucevlhhushhtvghrufhiiigvpedvnecurf grrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 27DC53064683; Thu, 8 Oct 2020 07:25:26 -0400 (EDT) From: Maxime Ripard To: Mark Rutland , Rob Herring , Frank Rowand , Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Eric Anholt Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, Dave Stevenson , Tim Gover , Phil Elwell , Hoegeun Kwon Subject: [PATCH 4/4] drm/vc4: kms: Fix VBLANK reporting on a disabled CRTC Date: Thu, 8 Oct 2020 13:25:19 +0200 Message-Id: <20201008112519.43691-4-maxime@cerno.tech> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201008112519.43691-1-maxime@cerno.tech> References: <20201008112519.43691-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org If a CRTC is enabled but not active, and that we're then doing a page flip on another CRTC, drm_atomic_get_crtc_state will bring the first CRTC state into the global state, and will make us wait for its vblank as well, even though that might never occur. Fix this by considering all the enabled CRTCs by either using their new state in the global state, or using their current state if they aren't part of the new state being checked, to remove their assigned channel from the pool before started to assign channels to CRTCs enabled by the state. Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically") Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_kms.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c index c9dfd5535a7e..0751ce5c6467 100644 --- a/drivers/gpu/drm/vc4/vc4_kms.c +++ b/drivers/gpu/drm/vc4/vc4_kms.c @@ -645,6 +645,14 @@ static const struct drm_private_state_funcs vc4_load_tracker_state_funcs = { * need to consider all the running CRTCs in the DRM device to assign * a FIFO, not just the one in the state. * + * - To fix the above, we can't use drm_atomic_get_crtc_state on all + * enabled CRTCs to pull their CRTC state into the global state, since + * a page flip would start considering their vblank to complete. Since + * we don't have a guarantee that they are actually active, that + * vblank might never happen, and shouldn't even be considered if we + * want to do a page flip on a single CRTC. That can be tested by + * doing a modetest -v first on HDMI1 and then on HDMI0. + * * - Since we need the pixelvalve to be disabled and enabled back when * the FIFO is changed, we should keep the FIFO assigned for as long * as the CRTC is enabled, only considering it free again once that @@ -656,6 +664,7 @@ static int vc4_pv_muxing_atomic_check(struct drm_device *dev, { unsigned long unassigned_channels = GENMASK(NUM_CHANNELS - 1, 0); struct drm_crtc_state *old_crtc_state, *new_crtc_state; + struct drm_crtc_state *crtc_state; struct drm_crtc *crtc; unsigned int i; @@ -667,15 +676,14 @@ static int vc4_pv_muxing_atomic_check(struct drm_device *dev, * the same CRTCs, instead of evaluating only the CRTC being * modified. */ - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { - struct drm_crtc_state *crtc_state; + for_each_new_or_current_crtc_state(state, crtc, crtc_state) { + struct vc4_crtc_state *vc4_crtc_state; - if (!crtc->state->enable) + if (!crtc_state->enable) continue; - crtc_state = drm_atomic_get_crtc_state(state, crtc); - if (IS_ERR(crtc_state)) - return PTR_ERR(crtc_state); + vc4_crtc_state = to_vc4_crtc_state(crtc_state); + unassigned_channels &= ~BIT(vc4_crtc_state->assigned_channel); } for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { @@ -690,10 +698,8 @@ static int vc4_pv_muxing_atomic_check(struct drm_device *dev, if (!new_crtc_state->enable) continue; - if (new_vc4_crtc_state->assigned_channel != VC4_HVS_CHANNEL_DISABLED) { - unassigned_channels &= ~BIT(new_vc4_crtc_state->assigned_channel); + if (new_vc4_crtc_state->assigned_channel != VC4_HVS_CHANNEL_DISABLED) continue; - } /* * The problem we have to solve here is that we have -- 2.26.2