drm/vkms: Keep composition enabled for concurrent users
PATCH v2 1/1 drm/vkms: Keep composition enabled for concurrent users
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. Read the user count under the output lock in the vblank callback and remove the resolved documentation TODO.
The atomic helpers enable the CRTC before issuing writeback, so warn if acquiring the writeback reference unexpectedly fails. Opening the CRC data file can race with a CRTC disable, so return any error from acquiring its composer reference.
The IGT kms_writeback@writeback-preserves-crc regression times out reading CRCs on unmodified mainline and passes with this change on ARM64 QEMU with one and two CPUs. Four existing writeback subtests pass on both kernels. IGT skips the two XRGB2101010 subtests because the format is unsupported.
---
Changes in v2:
- Remove the manual fence-error and job-cleanup branch from the writeback commit hook. DRM enables the CRTC and makes vblank available before dispatching writeback. Record a successful get for job cleanup and warn if this invariant fails. Keep CRC-open error propagation (Oarora Etimis).
- Retest the IGT v4 standalone regression and writeback suite with one and two CPUs on ARM64 QEMU/HVF, with lockdep and atomic-sleep checks enabled. Baseline and v2 use mainline ca20d5a011d3 and the same configuration. The focused VKMS W=1 build is clean.
Original submission:
https://lore.kernel.org/r/[email protected]/
Review:
https://lore.kernel.org/r/[email protected]/
IGT regression:
https://lore.kernel.org/r/[email protected]/
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 | 9 +++-- 5 files changed, 52 insertions(+), 23 deletions(-)
Documentation/gpu/vkms.rst +0 -5
@@ -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.
drivers/gpu/drm/vkms/vkms_composer.c +38 -9
65 lines not on this page · raw message
drivers/gpu/drm/vkms/vkms_crtc.c +3 -2
@@ -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()
drivers/gpu/drm/vkms/vkms_drv.h +5 -4
@@ -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 */
drivers/gpu/drm/vkms/vkms_writeback.c +6 -3
@@ -118,7 +118,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); }
@@ -141,9 +143,10 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn,if (!conn_state)return ; -vkms_set_composer (output, true); - active_wb = conn_state->writeback_job->priv; +/* The commit helper enables the CRTC before issuing writeback. */ + active_wb->composer_ref = !vkms_composer_get (output); +drm_WARN_ON_ONCE (conn->dev, !active_wb->composer_ref); wb_frame_info = &active_wb->wb_frame_info;spin_lock_irq (&output->composer_lock);
base-commit: ca20d5a011d35fc25e328fe31ac47f7aae557c5a
Signature · 1 line
2.50.1 (Apple Git-155)