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 F2E26CCA47B for ; Tue, 28 Jun 2022 02:23:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5053A10F0DE; Tue, 28 Jun 2022 02:23:04 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id B8FEC10F0DE for ; Tue, 28 Jun 2022 02:23:00 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2AC2F6185C; Tue, 28 Jun 2022 02:23:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A68AC36AE2; Tue, 28 Jun 2022 02:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656382979; bh=mZorZnBDhd8tM4rvi3iSjxVRtl1UH9oN/D4gw/tPpL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G1A/7izxd8ZfUnP++fvQU2Y3ixUS9ouGMbAvDj8cahTx7lGBWDzKhMAvDE+lLCcjL 0y45jUpN6uxgFXyi04aU8rTFhrZFvRlA3dvNbfC3GzZ3Ea5Wqzw/0smq7/ZQ0iT1y7 tumR+8yqYta3k+HjgnmMBbHqbscKtXRl/vFKtzlPV0naBmGpEqkfoFS9oLTdf2Xfln isxR6rMADrbOBLggggAhHcxFK4SdwPGlKV3o48dzgzm8e67uCSjpEsgLwqO0MQyCBA KbBc9UAX8LhPET9vgzMAGt2vlJsRhlS3mVSf2n8f6qY6vez5AlDnRC4E8a58mhfCG3 hkxaGU0QjZO/g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 08/34] drm/vc4: crtc: Move the BO handling out of common page-flip callback Date: Mon, 27 Jun 2022 22:22:15 -0400 Message-Id: <20220628022241.595835-8-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220628022241.595835-1-sashal@kernel.org> References: <20220628022241.595835-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit 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: Sasha Levin , emma@anholt.net, airlied@linux.ie, dri-devel@lists.freedesktop.org, Melissa Wen , Maxime Ripard Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Maxime Ripard [ Upstream commit 4d12c36fb73b5c49fe2f95d06515fd9846010fd2 ] We'll soon introduce another completion callback source that won't need to use the BO reference counting, so let's move it around to create a function we will be able to share between both callbacks. Reviewed-by: Melissa Wen Signed-off-by: Maxime Ripard Link: https://lore.kernel.org/r/20220610115149.964394-11-maxime@cerno.tech Signed-off-by: Sasha Levin --- drivers/gpu/drm/vc4/vc4_crtc.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c index c0332b69d22c..94bc20247ef9 100644 --- a/drivers/gpu/drm/vc4/vc4_crtc.c +++ b/drivers/gpu/drm/vc4/vc4_crtc.c @@ -722,21 +722,8 @@ vc4_async_page_flip_complete(struct vc4_async_flip_state *flip_state) drm_crtc_vblank_put(crtc); drm_framebuffer_put(flip_state->fb); - /* Decrement the BO usecnt in order to keep the inc/dec calls balanced - * when the planes are updated through the async update path. - * FIXME: we should move to generic async-page-flip when it's - * available, so that we can get rid of this hand-made cleanup_fb() - * logic. - */ - if (flip_state->old_fb) { - struct drm_gem_cma_object *cma_bo; - struct vc4_bo *bo; - - cma_bo = drm_fb_cma_get_gem_obj(flip_state->old_fb, 0); - bo = to_vc4_bo(&cma_bo->base); - vc4_bo_dec_usecnt(bo); + if (flip_state->old_fb) drm_framebuffer_put(flip_state->old_fb); - } kfree(flip_state); @@ -747,8 +734,27 @@ static void vc4_async_page_flip_seqno_complete(struct vc4_seqno_cb *cb) { struct vc4_async_flip_state *flip_state = container_of(cb, struct vc4_async_flip_state, cb.seqno); + struct vc4_bo *bo = NULL; + + if (flip_state->old_fb) { + struct drm_gem_cma_object *cma_bo = + drm_fb_cma_get_gem_obj(flip_state->old_fb, 0); + bo = to_vc4_bo(&cma_bo->base); + } vc4_async_page_flip_complete(flip_state); + + /* + * Decrement the BO usecnt in order to keep the inc/dec + * calls balanced when the planes are updated through + * the async update path. + * + * FIXME: we should move to generic async-page-flip when + * it's available, so that we can get rid of this + * hand-made cleanup_fb() logic. + */ + if (bo) + vc4_bo_dec_usecnt(bo); } /* Implements async (non-vblank-synced) page flips. -- 2.35.1