From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380745; b=pyOunFrVXFDbIA1+pufOzIWZiagmXnVRPHBaVcYOlZfI+x3t0ZL5SYOrgAL5sH3RDqtm EmecbeWLoTYyh3H9nNAWqJWXuLXu4lLMkQMmwkk75Mf12ob1ugwaVmZ1ctgwKXJtoDu/0 YnwlRjgxs40p0B02ErjsFBbi7SpOtr84KGAApwhEbG4Ru+kuNJfEaTLHxfbglVUJ0vpcj gcnsdHhDSMnHgz5RJ8b2gmT+jTkQrZYBEcIkr4VtbDKignaQVguxasOOSKZtxjeHut2wS RG5zdzFTDC98BI4Sb5Gk9DubtpeFT6W77EpipCCH2m1NVH4AwoYfqimxrDGTTHWS5oQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380745; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=ZH5YQZpZ/EjACiEdfOLNktkd0yrKWK3UV0ScIWbbOnk=; b=KBpKMuBysbFxKourfplhH80vtzxqD3fASmtJt5EXSFdd3HxkjzTblr7EC2DCb5P8nQA9 /ISQr5G1Q3Q4JrcVInvyeeFOihWgcOWHjJ3XkOolqdqIaD26z6jsozZ95eMuLuW2BuRoR 85QYbDUbYIEg5U1t9KQ7Ys7RWQxs8siBLVOn7uz+OUsMNZAdUM2SzZWcfnwHrd+lyZbpz o8LZcyuuF9Fg2eX2WxXZk8vTKkOXkhmbO4YjvwAwj0DKB4ccmbwIuFNo4NaIXtNiSKcuS E23OSubMiAXCy+RA4lzB3iSy/ejlneRp+XZirr8jbv6UzwE+GAtePcuzOAupyZhpTkA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2rNyq4oH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DDAC606A322; Fri, 4 Dec 2026 10:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2rNyq4oH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95D371F000C2; Fri, 4 Dec 2026 10:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380745; bh=ZH5YQZpZ/EjACiEdfOLNktkd0yrKWK3UV0ScIWbbOnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2rNyq4oHW+n7/fGul+Sn5SH1D2e+FAabvp/owSoG6Oe7yxPCnj4JwTDUUac4Y1dRO MPUiX0wOkEzIL+udEC3ZAGq/4Z2Anel9lW0KjVuDXQ0CHDugF/2H4cv1yxLuH+84G/ U8LTOB6WnRjzSfXyhhWuTeKd9z4bR4DjJnG5dkaM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Iago Toral Quiroga , =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [PATCH 7.3 407/742] drm/vc4: Look up the async page flip fence before committing the flip Date: Fri, 4 Dec 2026 19:04:31 +0900 Message-ID: <20261204100645.907752215@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maíra Canal commit f9fc6da01a290609428d308033143f1d96ab658f upstream. vc4_async_page_flip_common() ignores dma_resv_get_singleton() failures. By then the plane state already points at the new framebuffer, so the flip is never completed. So, its state leaks, the vblank reference is never dropped and the event is never sent. Look up the fence before changing any state, so the error can be properly returned to userspace. Cc: stable@vger.kernel.org Fixes: d19e00ee06a9 ("drm/vc4: crtc: Fix out of order frames during asynchronous page flips") Reviewed-by: Iago Toral Quiroga Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-3-d33cbe99ed5d@igalia.com Signed-off-by: Maíra Canal Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vc4/vc4_crtc.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) --- a/drivers/gpu/drm/vc4/vc4_crtc.c +++ b/drivers/gpu/drm/vc4/vc4_crtc.c @@ -948,33 +948,22 @@ static void vc4_async_page_flip_fence_cb queue_work(vc4_crtc->async_flip_wq, &flip_state->work); } -static int vc4_async_set_fence_cb(struct drm_device *dev, - struct vc4_async_flip_state *flip_state) +static void vc4_async_set_fence_cb(struct vc4_async_flip_state *flip_state) { - struct drm_framebuffer *fb = flip_state->fb; - struct drm_gem_dma_object *dma_bo = drm_fb_dma_get_gem_obj(fb, 0); struct vc4_crtc *vc4_crtc = to_vc4_crtc(flip_state->crtc); - int ret; INIT_WORK(&flip_state->work, vc4_async_page_flip_work); - ret = dma_resv_get_singleton(dma_bo->base.resv, DMA_RESV_USAGE_READ, - &flip_state->fence); - if (ret) - return ret; - if (flip_state->fence && !dma_fence_add_callback(flip_state->fence, &flip_state->cb, vc4_async_page_flip_fence_cb)) - return 0; + return; /* No fence or the fence has already signaled. Complete the flip * immediately, after earlier queued flips. */ flush_workqueue(vc4_crtc->async_flip_wq); vc4_async_page_flip_work(&flip_state->work); - - return 0; } static int @@ -983,14 +972,22 @@ vc4_async_page_flip_common(struct drm_cr struct drm_pending_vblank_event *event, uint32_t flags) { - struct drm_device *dev = crtc->dev; + struct drm_gem_dma_object *dma_bo = drm_fb_dma_get_gem_obj(fb, 0); struct drm_plane *plane = crtc->primary; struct vc4_async_flip_state *flip_state; + int ret; flip_state = kzalloc_obj(*flip_state); if (!flip_state) return -ENOMEM; + ret = dma_resv_get_singleton(dma_bo->base.resv, DMA_RESV_USAGE_READ, + &flip_state->fence); + if (ret) { + kfree(flip_state); + return ret; + } + drm_framebuffer_get(fb); flip_state->fb = fb; flip_state->crtc = crtc; @@ -1016,7 +1013,7 @@ vc4_async_page_flip_common(struct drm_cr */ drm_atomic_set_fb_for_plane(plane->state, fb); - vc4_async_set_fence_cb(dev, flip_state); + vc4_async_set_fence_cb(flip_state); /* Driver takes ownership of state on successful async commit. */ return 0;