On Tue, Aug 29, 2023 at 05:30:54AM +0000, Brandon Pollack wrote:
> From: Jim Shargo <[email protected]>
>
> This change supports multiple CRTCs, encoders, connectors instead of one
> of each per device.
>
> Since ConfigFS-based devices will support multiple crtcs, it's useful to
> move all of the writeback/composition data from being per-"output" to
> being per-CRTC.
>
> Since there's still only ever one CRTC, this should be a no-op refactor.
>
> Signed-off-by: Jim Shargo <[email protected]>
> Signed-off-by: Brandon Pollack <[email protected]>
> +struct vkms_crtc {
> + struct drm_crtc base;
> +
> + struct drm_writeback_connector wb_connector;
> + struct hrtimer vblank_hrtimer;
> + ktime_t period_ns;
> + struct drm_pending_vblank_event *event;
> + /* ordered wq for composer_work */
> + struct workqueue_struct *composer_workq;
> + /* protects concurrent access to composer */
> + spinlock_t lock;
> + /* guarantees that if the composer is enabled, a job will be queued */
> + struct mutex enabled_lock;
> +
> + /* protected by @enabled_lock */
> + bool composer_enabled;
> + struct vkms_crtc_state *composer_state;
> +
> + spinlock_t composer_lock;
> +};
> +
> struct vkms_color_lut {
> struct drm_color_lut *base;
> size_t lut_length;
> @@ -97,25 +122,14 @@ struct vkms_crtc_state {
> };
>
> struct vkms_output {
I think this structure doesn't make sense anymore. If I didn't misread
then it's really only needed as a temporary structure during the default
vkms_output_init code anymore, and for that case I think we should just
completely delete it. Since vkms is now using drmm_ there's really not
need to track all our kms objects again ourselves.
With that this patch essentially becomes "creat vkms_crtc" (which moves
all the composer releated data from vkms_output to this new structure) and
then maybe a 2nd patch which deletes the leftovers of vkms_output.
> - struct drm_crtc crtc;
> - struct drm_encoder encoder;
> - struct drm_connector connector;
> - struct drm_writeback_connector wb_connector;
> - struct hrtimer vblank_hrtimer;
> - ktime_t period_ns;
> - struct drm_pending_vblank_event *event;
> - /* ordered wq for composer_work */
> - struct workqueue_struct *composer_workq;
> - /* protects concurrent access to composer */
> - spinlock_t lock;
> - /* guarantees that if the composer is enabled, a job will be queued */
> - struct mutex enabled_lock;
> -
> - /* protected by @enabled_lock */
> - bool composer_enabled;
> - struct vkms_crtc_state *composer_state;
> -
> - spinlock_t composer_lock;
> + int num_crtcs;
> + struct vkms_crtc crtcs[VKMS_MAX_OUTPUT_OBJECTS];
Uh can we please directly use the DRM limits here for these? I guess this
is because you have static arrays, but vkms really shouldn't need it's own
arrays to keep track of what drm already keeps track of.
Using DRM limits also means we can rely on the drm validation code instead
of having to duplicate that code in the vkms configfs validation
functions.
-Sima
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch