From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795982454; b=1GM5Uozjw1wF0CSEQTJx/0t5jj8t14AicHQGz4AJSkuWBlLEWNwShDFIIbTIFZIZWNhG GxhFAH4k0O8VTLJi+ZLejNyN1ZiIvbFGLSV0UDCiaC1bgofJyfD09uS1oOt0i2dn8Djcy NbkExbjjlFs87f6lV2ZblpLjVO7nwQEb5V40PgQPKCRf0MULu5XwSBS9PDGqGCxHd8U2s 3WTVg4c/0Qurvg6QoBiD5xUrhS2ILQyl/bOSgfnGpjDeHhYiuRinDdPm7ggw51ohppTAk jlMBfA7+21uGCBHhv9WqF501KhrNZTs02iU9DaJFnrP8qeVR9Tji7oMSWqryKs9Xw1g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795982454; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=9m6ZX46cBithgIcFTPRuiC71Dup3TLxhvFDZlRpFun8=; b=GMp78RkgRBjaC+6M6vuDOhGc9Nu/VfLJbfVoueP/UaG1LbkqnOdCTMH3tFUGG7FuNOAS hQyURxOOjoW7ZS+XWGLeJt1I83VNnEWl2Cem5u5EErfCluyhLvLGmC40me2jl58Yt12ZU 6F/fS80NTF7iogqStYJGu1DEPNL+OqHJRAvgO78/b4NF84fMQ+m/y66XSxjQVqmGe8Zx/ 76zRmTRmxc0W11TEkr85ltwv/WutIyM16KEjX7eMYHK/e8t2M5AbRPofS8K6UqfKeOAoq 3RgHqxVnS9TQDLmj1bjGoloQvDJ3FDA865D+OM74Z2YSeNGWD/+m+0xr9TGJUCndhPA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=TtN4E1jp; arc=none smtp.remote-ip=209.85.221.44 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0409D606A323 for ; Sun, 29 Nov 2026 20:00:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0409D606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=TtN4E1jp Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-498f5fa4f70so8166583f8f.0 for ; Sun, 29 Nov 2026 12:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795982452; x=1796587252; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9m6ZX46cBithgIcFTPRuiC71Dup3TLxhvFDZlRpFun8=; b=TtN4E1jpGQGLKSa9KKA0r+TMTlgVaIhXARoojOcf1GtGp+vjRUJESTGA40YKAf13Fo IjEEEOWugbwjhecKUgx48UB21BHKSOC456koMohDOEaYZeCGwZ/vQ0R2Cdx54736MSAG Tw27BrN2PQcLogXqtKlepyMFPgLwJRLwCNlJv3h9iNNLdkk7wE4PPzdMKzFtgUW3sukU 6lJQFrORQpw+PDkSD06+b/c3wMCwGolLKl8H92eN2i1PoXjkwRqJOMqsjXHE0BO28gUY jtHcLSccbukrAURCuZXe81l7IydJbHKUITtgx1r5D3iSJieYQ6Z4uUoGHRBv0fhwo1TB Y2Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795982452; x=1796587252; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9m6ZX46cBithgIcFTPRuiC71Dup3TLxhvFDZlRpFun8=; b=G4uLxCPxMBrH/2Xu79uHc/A/A0vKPIIolBIB7qwSCaBC49fXLgefwXO7MiHoDAPjwX VTHxkPkEKduNCeYf61Xpx9rCBWUbrEWtg9Wz1VdOSqYBbRDohWsmok/ifgqsdSa8OXZd hHba/QNRcdqna0Xe5f7rAOHqJK4nt0X1BCTFqBv4NH6768IrEJ2XrqI6t6RhduxCTzSJ Ajr4fySHIpD19l7YhGKssUpet9MRDn5MLD2V1JQE41MhgHIrtTfI+PaBlXeCUA+GuKIP 9LCgmJPgWJdOVHB+hXL/AuUcFzwEbqSFgfP8IL0O4jlLxtrgJxqE3zQbZQFQWMtNTWDG JYaw== X-Forwarded-Encrypted: i=1; AL+hErFaAb5KbSWiAZAe2/UAoyTZNk/KJaXOU/AEGPYB+wQnFOwGOeXJB5BYaPUrfkZzd5XxmeUyXdoE1Qo=@vger.kernel.org X-Gm-Message-State: APuU4Z8XFfPUn5TmYeUy3+bNqSXB/6xXQQnLXVCuisz8uKmft+dxy7Ht C6DSDTZntjrnGloxXxesUYQr7XN7YUTz1pMfCX1iF/yQFFXEPIdwsLH3 X-Gm-Gg: AZFdTZe7BLbnEUr4F607J+OXqpUas1bhMx61j3rB63KeaUj5FZoeJzx4ERWjhvwK89x vDfcaWBQYiUqQG44RReDB9VPwJlfgrnVSx36jfrT/eLgBVtlWGEv1wfOxEi2m4RtT4g8z6ywmvZ n7q4NGK4c63fwPoROSVGlwbYgSqFwwSv6SinPmyMfBGTlRtUj1Uq3Hq7TvNcnE963CNVgUqWFxL cJx1uBGm+dysHdrZj9UdVUSJ8TdwxUGF9unuUurw3BQpSXQx1ey4TT5amwW969O7At40JUgxny9 XT2LBcZtWMhfjEZZjomhsbOo1NpI31SbPVJqIFx0wVTXcrm97XaIBcaPGnK5Ym8LHQkHdAMyoTM b9tLErFwCUjRI6VffVm+H0yDbZNlGlgAtRjAGyl1Qv0jg+BH4vbmls7LDtE5lMEcK9uSyO4tGbs anjTVzwgh0uBsQMsL1Xqwq9yHtMrMgXIVg01COnP7g5IMr2zmW3goRtM/LtGxcNcOcXVyAY0xQB Vf6J4K0G1FoZzpn37Pj7mOZ+MMcbOumhEq0Wrix9/ebsFL/X7NzTSdu5TkisuqFtXmn3MJA2ru8 CiJj2z/wAiszxL33MYXuwjNIlrkc325wfAgzGg== X-Received: by 2002:a5d:5888:0:b0:48d:f488:f32a with SMTP id ffacd0b85a97d-4abb55183b4mr59688046f8f.56.1795982452212; Sun, 29 Nov 2026 12:00:52 -0800 (PST) Received: from [10.56.169.198] ([95.179.249.152]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6b2050f1sm58801601f8f.38.2026.11.29.12.00.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 12:00:50 -0800 (PST) Message-ID: <9cd4ada9-00e1-4032-84a4-7ccd12b54f35@gmail.com> Date: Sun, 29 Nov 2026 21:00:44 +0100 X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RESEND] drm/vkms: Keep composition enabled for concurrent users To: Aditya Tipre , louis.chauvet@bootlin.com Cc: dri-devel@lists.freedesktop.org, hamohammed.sa@gmail.com, simona@ffwll.ch, melissa.srw@gmail.com, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261025194727.89093-1-tipreaditya@gmail.com> <20261129184141.14809-1-tipreaditya@gmail.com> Content-Language: en-US From: Oarora Etimis In-Reply-To: <20261129184141.14809-1-tipreaditya@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hello, On 11/29/26 7:41 PM, Aditya Tipre wrote: > From: atipre > > CRC capture and writeback share composer_enabled. Cleaning up a writeback > clears this flag even when CRC capture is still active. The composer then > stops producing CRC samples while the CRC data file remains open. Cleanup > of a prepared but uncommitted writeback can also disable composition for > another user. > > Replace the shared boolean with a user count protected by the output lock. > Hold one vblank reference for the combined lifetime of all composer users, > refunding redundant references when concurrent first users race. Track > whether each writeback job acquired a composer reference so its cleanup > only releases a reference it owns. Propagate CRC acquisition errors and > signal a failed writeback's own fence before cleaning up the unqueued job. > Read the user count under the output lock in the vblank callback and remove > the resolved documentation TODO. > > A local IGT kms_writeback@writeback-preserves-crc regression times out > reading CRCs on the unmodified kernel and passes with this change on ARM64 > QEMU with one and two CPUs. All four existing applicable writeback subtests > also pass; two unsupported XRGB2101010 subtests skip on both kernels. > > Fixes: dbd9d80c1b2e ("drm/vkms: Add support for writeback") > Signed-off-by: atipre > --- > Resending the October 25 submission; no changes to the code or commit > message. > > Retested on November 29 against mainline > ca20d5a011d35fc25e328fe31ac47f7aae557c5a (7.4-rc4), using the > posted IGT v4 series based on c9e2cc3119d9. Fresh baseline and patched > ARM64 kernels used the same configuration, with lockdep and atomic-sleep > checks enabled. With one and two CPUs in QEMU/HVF: > - The standalone regression times out reading CRCs on baseline and passes > with the fix. > - The full writeback suite reproduces the same distinction; all four > existing applicable subtests pass on both kernels. The two unsupported > XRGB2101010 subtests skip on both. > - No kernel WARN, Oops, panic, or hung-task diagnostics were detected. > > Both normal kernel builds and a focused W=1 VKMS build pass without > compiler warnings. An initial full-tree W=1 attempt stopped on existing > ARM64 syscall-table override-init diagnostics before applying the patch. > > Original submission: > https://lore.kernel.org/dri-devel/20261025194727.89093-1-tipreaditya@gmail.com/ > > The accompanying IGT regression is now available as v4: > https://lore.kernel.org/dri-devel/20261129180700.89278-1-tipreaditya@gmail.com/ > > There is also an overlapping composer-user series: > https://lore.kernel.org/dri-devel/20261119-composer-v4-0-5973fc9296ee@gmail.com/ > Please advise which implementation should move forward and how best to > coordinate. > > Documentation/gpu/vkms.rst | 5 --- > drivers/gpu/drm/vkms/vkms_composer.c | 47 ++++++++++++++++++++++----- > drivers/gpu/drm/vkms/vkms_crtc.c | 5 +-- > drivers/gpu/drm/vkms/vkms_drv.h | 9 ++--- > drivers/gpu/drm/vkms/vkms_writeback.c | 21 ++++++++++-- > 5 files changed, 64 insertions(+), 23 deletions(-) > > diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst > index 1e79e62a6bc4..fe7dc8def44a 100644 > --- a/Documentation/gpu/vkms.rst > +++ b/Documentation/gpu/vkms.rst > @@ -246,11 +246,6 @@ module through configfs. Use/Test-cases: > Writeback support > ----------------- > > -- The writeback and CRC capture operations share the use of composer_enabled > - boolean to ensure vblanks. Probably, when these operations work together, > - composer_enabled needs to refcounting the composer state to proper work. > - [Good to get started] > - > - Add support for cloned writeback outputs and related test cases using a > cloned output in the IGT kms_writeback. > > diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c > index 0fc915a954ba..5860e86e66b6 100644 > --- a/drivers/gpu/drm/vkms/vkms_composer.c > +++ b/drivers/gpu/drm/vkms/vkms_composer.c > @@ -711,19 +711,44 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *src_name, > return 0; > } > > -void vkms_set_composer(struct vkms_output *out, bool enabled) > +int vkms_composer_get(struct vkms_output *out) > { > - bool old_enabled; > + bool already_enabled; > + int ret; > > - if (enabled) > - drm_crtc_vblank_get(&out->crtc); > + spin_lock_irq(&out->lock); > + if (out->composer_users) { > + out->composer_users++; > + spin_unlock_irq(&out->lock); > + return 0; > + } > + spin_unlock_irq(&out->lock); > + > + ret = drm_crtc_vblank_get(&out->crtc); > + if (ret) > + return ret; > > spin_lock_irq(&out->lock); > - old_enabled = out->composer_enabled; > - out->composer_enabled = enabled; > + already_enabled = out->composer_users != 0; > + out->composer_users++; > spin_unlock_irq(&out->lock); > > - if (old_enabled) > + /* Another user may have enabled composition while we got vblank. */ > + if (already_enabled) > + drm_crtc_vblank_put(&out->crtc); > + > + return 0; > +} > + > +void vkms_composer_put(struct vkms_output *out) > +{ > + bool last_user; > + > + spin_lock_irq(&out->lock); > + last_user = --out->composer_users == 0; > + spin_unlock_irq(&out->lock); > + > + if (last_user) > drm_crtc_vblank_put(&out->crtc); > } > > @@ -734,8 +759,12 @@ int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name) > int ret = 0; > > ret = vkms_crc_parse_source(src_name, &enabled); > + if (ret) > + return ret; > > - vkms_set_composer(out, enabled); > + if (enabled) > + return vkms_composer_get(out); > > - return ret; > + vkms_composer_put(out); > + return 0; > } > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c > index fe17f49305a9..69ec6b14a864 100644 > --- a/drivers/gpu/drm/vkms/vkms_crtc.c > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c > @@ -17,7 +17,7 @@ static bool vkms_crtc_handle_vblank_timeout(struct drm_crtc *crtc) > { > struct vkms_output *output = drm_crtc_to_vkms_output(crtc); > struct vkms_crtc_state *state; > - bool ret, fence_cookie; > + bool ret, fence_cookie, composer_enabled; > > fence_cookie = dma_fence_begin_signalling(); > > @@ -27,9 +27,10 @@ static bool vkms_crtc_handle_vblank_timeout(struct drm_crtc *crtc) > DRM_ERROR("vkms failure on handling vblank"); > > state = output->composer_state; > + composer_enabled = output->composer_users != 0; > spin_unlock(&output->lock); > > - if (state && output->composer_enabled) { > + if (state && composer_enabled) { > u64 frame = drm_crtc_accurate_vblank_count(crtc); > > /* update frame_start only if a queued vkms_composer_worker() > diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h > index 381483aa4fb0..4919d8036668 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.h > +++ b/drivers/gpu/drm/vkms/vkms_drv.h > @@ -89,6 +89,7 @@ struct vkms_writeback_job { > struct iosys_map data[DRM_FORMAT_MAX_PLANES]; > struct vkms_frame_info wb_frame_info; > pixel_write_t pixel_write; > + bool composer_ref; > }; > > /** > @@ -210,8 +211,7 @@ struct vkms_crtc_state { > * vblank timestamps > * @composer_workq: Ordered workqueue for @composer_state.composer_work. > * @lock: Lock used to protect concurrent access to the composer > - * @composer_enabled: Protected by @lock, true when the VKMS composer is active (crc needed or > - * writeback) > + * @composer_users: Protected by @lock, number of CRC capture and writeback users > * @composer_state: Protected by @lock, current state of this VKMS output > * @composer_lock: Lock used internally to protect @composer_state members > */ > @@ -222,7 +222,7 @@ struct vkms_output { > struct workqueue_struct *composer_workq; > spinlock_t lock; > > - bool composer_enabled; > + unsigned int composer_users; > struct vkms_crtc_state *composer_state; > > spinlock_t composer_lock; > @@ -317,7 +317,8 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, > > /* Composer Support */ > void vkms_composer_worker(struct work_struct *work); > -void vkms_set_composer(struct vkms_output *out, bool enabled); > +int vkms_composer_get(struct vkms_output *out); > +void vkms_composer_put(struct vkms_output *out); > void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer *src_buffer, int y); > > /* Writeback */ > diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c > index ecf29a2c0c8e..584a71862aaf 100644 > --- a/drivers/gpu/drm/vkms/vkms_writeback.c > +++ b/drivers/gpu/drm/vkms/vkms_writeback.c > @@ -1,5 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0+ > > +#include > #include > > #include > @@ -118,7 +119,9 @@ static void vkms_wb_cleanup_job(struct drm_writeback_connector *connector, > > drm_framebuffer_put(vkmsjob->wb_frame_info.fb); > > - vkms_set_composer(vkms_output, false); > + /* Prepared jobs can be cleaned up without ever being committed. */ > + if (vkmsjob->composer_ref) > + vkms_composer_put(vkms_output); > kfree(vkmsjob); > } > > @@ -137,13 +140,25 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, > struct vkms_writeback_job *active_wb; > struct vkms_frame_info *wb_frame_info; > u32 wb_format = fb->format->format; > + int ret; > > if (!conn_state) > return; > > - vkms_set_composer(output, true); > - > active_wb = conn_state->writeback_job->priv; > + ret = vkms_composer_get(output); > + if (ret) { > + struct drm_writeback_job *job = conn_state->writeback_job; > + > + conn_state->writeback_job = NULL; > + if (job->out_fence) { > + dma_fence_set_error(job->out_fence, ret); > + dma_fence_signal(job->out_fence); > + } > + drm_writeback_cleanup_job(job); > + return; > + } > + active_wb->composer_ref = true; > wb_frame_info = &active_wb->wb_frame_info; > > spin_lock_irq(&output->composer_lock); vkms_wb_atomic_commit() is a void hook with no failure channel. drm_crtc_vblank_get() can fail only if vblank is unsupported, the pipe index is invalid, vblank is off while its refcount is non-zero, or the CRTC's enable_vblank callback fails. VKMS initializes vblank at probe, passes the CRTC's own index, wires enable_vblank to drm_crtc_vblank_helper_enable_vblank_timer (which always returns 0), and drm_atomic_connector_check() rejects a writeback job on an inactive CRTC; none of those conditions is reachable in vkms_wb_atomic_commit(). vkms_composer_get() therefore always succeeds at that call site, and the dma_fence_set_error()/signal()/cleanup path is unreachable there.