[RFC] drm/atomic: Abuse legacy cursor update flag for legacy gamma update too
diff mbox

Message ID 20180213091201.12776-1-maarten.lankhorst@linux.intel.com
State New
Headers show

Commit Message

Maarten Lankhorst Feb. 13, 2018, 9:12 a.m. UTC
Programs like redshift set the legacy gamma for X.org every 5 seconds.
Because atomic commits wait for vblank completion, we get a frame drop
every 5 seconds because of the legacy gamma update.

Work around this by setting the legacy_cursor_update flag, to force
legacy gamma updates not to be synced against vblank.

Reported-by: Tholin #intel-gfx
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Chris Wilson Feb. 13, 2018, 9:16 a.m. UTC | #1
Quoting Maarten Lankhorst (2018-02-13 09:12:01)
> Programs like redshift set the legacy gamma for X.org every 5 seconds.
> Because atomic commits wait for vblank completion, we get a frame drop
> every 5 seconds because of the legacy gamma update.
> 
> Work around this by setting the legacy_cursor_update flag, to force
> legacy gamma updates not to be synced against vblank.
> 
> Reported-by: Tholin #intel-gfx
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Reminiscing: Remember the time we had all those vblank workers patches,
one of which was to do async gamma updates (apply the last one on the
vblank). Motivated by gnome-shell and the ilk doing a gamma animation
for fade-out on logout (which I guess they gave up on since it happened
to be so slow as to extend logout ;).
-Chris
Maarten Lankhorst Feb. 13, 2018, 9:33 a.m. UTC | #2
Hey,

Op 13-02-18 om 10:16 schreef Chris Wilson:
> Quoting Maarten Lankhorst (2018-02-13 09:12:01)
>> Programs like redshift set the legacy gamma for X.org every 5 seconds.
>> Because atomic commits wait for vblank completion, we get a frame drop
>> every 5 seconds because of the legacy gamma update.
>>
>> Work around this by setting the legacy_cursor_update flag, to force
>> legacy gamma updates not to be synced against vblank.
>>
>> Reported-by: Tholin #intel-gfx
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Reminiscing: Remember the time we had all those vblank workers patches,
> one of which was to do async gamma updates (apply the last one on the
> vblank). Motivated by gnome-shell and the ilk doing a gamma animation
> for fade-out on logout (which I guess they gave up on since it happened
> to be so slow as to extend logout ;).

That special case could be handled by userspace with atomic commits, I don't
think it's worth optimizing it further..
Ville Syrjälä Feb. 13, 2018, 1:29 p.m. UTC | #3
On Tue, Feb 13, 2018 at 10:33:28AM +0100, Maarten Lankhorst wrote:
> Hey,
> 
> Op 13-02-18 om 10:16 schreef Chris Wilson:
> > Quoting Maarten Lankhorst (2018-02-13 09:12:01)
> >> Programs like redshift set the legacy gamma for X.org every 5 seconds.
> >> Because atomic commits wait for vblank completion, we get a frame drop
> >> every 5 seconds because of the legacy gamma update.
> >>
> >> Work around this by setting the legacy_cursor_update flag, to force
> >> legacy gamma updates not to be synced against vblank.
> >>
> >> Reported-by: Tholin #intel-gfx
> >> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Reminiscing: Remember the time we had all those vblank workers patches,
> > one of which was to do async gamma updates (apply the last one on the
> > vblank). Motivated by gnome-shell and the ilk doing a gamma animation
> > for fade-out on logout (which I guess they gave up on since it happened
> > to be so slow as to extend logout ;).
> 
> That special case could be handled by userspace with atomic commits, I don't
> think it's worth optimizing it further..

We need to eventually move the gamma updates (and other single buffered
registers) to a vblank worker or something similar. Otherwise they will
tear.
Daniel Vetter Feb. 19, 2018, 2:34 p.m. UTC | #4
On Tue, Feb 13, 2018 at 10:12:01AM +0100, Maarten Lankhorst wrote:
> Programs like redshift set the legacy gamma for X.org every 5 seconds.
> Because atomic commits wait for vblank completion, we get a frame drop
> every 5 seconds because of the legacy gamma update.
> 
> Work around this by setting the legacy_cursor_update flag, to force
> legacy gamma updates not to be synced against vblank.
> 
> Reported-by: Tholin #intel-gfx
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index ae3cbfe9e01c..f37ab26ef4d2 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3806,6 +3806,9 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
>  	if (!state)
>  		return -ENOMEM;
>  
> +	/* Don't wait for vblank after updating gamma. */
> +	state->legacy_cursor_update = true;

The legacy_cursor_update hack is a fairly serious hack, and I'd kinda want
to avoid inflicting it on everyone. The cursor hack is a lot less minimal
(because few drivers have cursors, and we'd have the async plane update
stuff from Gustavo at least). Do we really need this?

Making sure that no one can trample over async gamma table updates,
especially when we eventually go to a vblank worker for them, sounds like
serious amounts of pain. I'd prefer we teach -modesetting to just push the
gamma update with the next frame as an atomic commit, or in the
blockhandler (to avoid delaying it).
-Daniel

> +
>  	blob = drm_property_create_blob(dev,
>  					sizeof(struct drm_color_lut) * size,
>  					NULL);
> -- 
> 2.16.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index ae3cbfe9e01c..f37ab26ef4d2 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3806,6 +3806,9 @@  int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 	if (!state)
 		return -ENOMEM;
 
+	/* Don't wait for vblank after updating gamma. */
+	state->legacy_cursor_update = true;
+
 	blob = drm_property_create_blob(dev,
 					sizeof(struct drm_color_lut) * size,
 					NULL);