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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 47F2EC43467 for ; Thu, 8 Oct 2020 11:27:07 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D189D2145D for ; Thu, 8 Oct 2020 11:27:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="I0K+QNqK"; dkim=temperror (0-bit key) header.d=cerno.tech header.i=@cerno.tech header.b="ATQJfsOY"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ZL3LJjja" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D189D2145D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=K9wPgSFSF8vUMGWcn8/ZleUIBBjiTiYYhz5rqKVNFzI=; b=I0K+QNqKiMovv4IYQUzPpLf1I 4vBOSpbj5AMhlDq/dDeHSAL44GaArAamfUIUbe8F5Zb/tgdv3NSf+jjU9gDxgTlb5/r8uF6NkF5Hp MyGzSm+eIJ8XXeaNMSPLHQ2DHpiEcDYuOGWFAn7zysA4iW8cFy0u8FZm+9qNMvC//IwSL7V74GoCu 6NhhQjY9uTs8k/LLL9tzXgj/+jr1E+qmy4Yez6xX8XI89Fl6jZOOdsHK4A4jOg/rBrd4kdqvU0a5U 3kjeDz6/F1fIlbcRD2GmpXz/4HZVZURz4ZDkG7rRPHAXI/6mpdTzxZv+Yqgu13s1gGc2UMwfsyFvG Nc7xb1Iog==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQU3J-0001My-6r; Thu, 08 Oct 2020 11:25:41 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQU37-0001JM-Sy; Thu, 08 Oct 2020 11:25:32 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201008_072530_063180_478EEA7E X-CRM114-Status: GOOD ( 18.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Tim Gover , Dave Stevenson , dri-devel@lists.freedesktop.org, Hoegeun Kwon , bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, Phil Elwell , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel