diff mbox

[1/2] drm/i915: Unset legacy_cursor_update early in intel_atomic_commit, v3.

Message ID 20170919121419.13708-1-maarten.lankhorst@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Maarten Lankhorst Sept. 19, 2017, 12:14 p.m. UTC
Commit b44d5c0c105a ("drm/i915: Always wait for flip_done, v2.") removed
the call to wait_for_vblanks and replaced it with flip_done.

Unfortunately legacy_cursor_update was unset too late, and the
replacement call drm_atomic_helper_wait_for_flip_done() was
a noop. Make sure that its unset before setup_commit() is
called to fix this issue.

Changes since v1:
- Force vblank wait for watermarks not yet converted to atomic too. (Ville)
- Use for_each_new_intel_crtc_in_state. (Ville)
Changes since v2:
- Move the optimization to a separate commit. (Ville)

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Fixes: b44d5c0c105a ("drm/i915: Always wait for flip_done, v2.")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102675
Testcase: kms_cursor_crc
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Reported-by: Marta Löfstedt <marta.lofstedt@intel.com>
Cc: Marta Löfstedt <marta.lofstedt@intel.com>
Tested-by: Marta Löfstedt <marta.lofstedt@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

Comments

Ville Syrjälä Sept. 19, 2017, 1:38 p.m. UTC | #1
On Tue, Sep 19, 2017 at 02:14:18PM +0200, Maarten Lankhorst wrote:
> Commit b44d5c0c105a ("drm/i915: Always wait for flip_done, v2.") removed
> the call to wait_for_vblanks and replaced it with flip_done.
> 
> Unfortunately legacy_cursor_update was unset too late, and the
> replacement call drm_atomic_helper_wait_for_flip_done() was
> a noop. Make sure that its unset before setup_commit() is
> called to fix this issue.
> 
> Changes since v1:
> - Force vblank wait for watermarks not yet converted to atomic too. (Ville)
> - Use for_each_new_intel_crtc_in_state. (Ville)
> Changes since v2:
> - Move the optimization to a separate commit. (Ville)
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Fixes: b44d5c0c105a ("drm/i915: Always wait for flip_done, v2.")
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102675
> Testcase: kms_cursor_crc
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Reported-by: Marta Löfstedt <marta.lofstedt@intel.com>
> Cc: Marta Löfstedt <marta.lofstedt@intel.com>
> Tested-by: Marta Löfstedt <marta.lofstedt@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 33 ++++++++++++++++-----------------
>  1 file changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 8599e425abb1..a85ca19a0c45 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -12517,21 +12517,10 @@ static int intel_atomic_commit(struct drm_device *dev,
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	int ret = 0;
>  
> -	ret = drm_atomic_helper_setup_commit(state, nonblock);
> -	if (ret)
> -		return ret;
> -
>  	drm_atomic_state_get(state);
>  	i915_sw_fence_init(&intel_state->commit_ready,
>  			   intel_atomic_commit_ready);
>  
> -	ret = intel_atomic_prepare_commit(dev, state);
> -	if (ret) {
> -		DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
> -		i915_sw_fence_commit(&intel_state->commit_ready);
> -		return ret;
> -	}
> -
>  	/*
>  	 * The intel_legacy_cursor_update() fast path takes care
>  	 * of avoiding the vblank waits for simple cursor
> @@ -12540,11 +12529,11 @@ static int intel_atomic_commit(struct drm_device *dev,
>  	 * updates happen during the correct frames. Gen9+ have
>  	 * double buffered watermarks and so shouldn't need this.
>  	 *
> -	 * Do this after drm_atomic_helper_setup_commit() and
> -	 * intel_atomic_prepare_commit() because we still want
> -	 * to skip the flip and fb cleanup waits. Although that
> -	 * does risk yanking the mapping from under the display
> -	 * engine.
> +	 * Unset state->legacy_cursor_update before the call to
> +	 * drm_atomic_helper_setup_commit() because otherwise
> +	 * drm_atomic_helper_wait_for_flip_done() is a noop and
> +	 * we get FIFO underruns because we didn't wait
> +	 * for vblank.
>  	 *
>  	 * FIXME doing watermarks and fb cleanup from a vblank worker
>  	 * (assuming we had any) would solve these problems.
> @@ -12552,7 +12541,17 @@ static int intel_atomic_commit(struct drm_device *dev,
>  	if (INTEL_GEN(dev_priv) < 9)
>  		state->legacy_cursor_update = false;
>  
> -	ret = drm_atomic_helper_swap_state(state, true);
> +	ret = intel_atomic_prepare_commit(dev, state);
> +	if (ret) {
> +		DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
> +		i915_sw_fence_commit(&intel_state->commit_ready);
> +		return ret;
> +	}
> +
> +	ret = drm_atomic_helper_setup_commit(state, nonblock);

Hmm. One thing I noticed here. Previously if this failed we just called
i915_sw_fence_commit(). Now we will also call
drm_atomic_helper_cleanup_planes(). Is that going to be a problem?

> +	if (!ret)
> +		ret = drm_atomic_helper_swap_state(state, true);
> +
>  	if (ret) {
>  		i915_sw_fence_commit(&intel_state->commit_ready);
>  
> -- 
> 2.14.1
Maarten Lankhorst Sept. 19, 2017, 1:50 p.m. UTC | #2
Op 19-09-17 om 15:38 schreef Ville Syrjälä:
> On Tue, Sep 19, 2017 at 02:14:18PM +0200, Maarten Lankhorst wrote:
>> Commit b44d5c0c105a ("drm/i915: Always wait for flip_done, v2.") removed
>> the call to wait_for_vblanks and replaced it with flip_done.
>>
>> Unfortunately legacy_cursor_update was unset too late, and the
>> replacement call drm_atomic_helper_wait_for_flip_done() was
>> a noop. Make sure that its unset before setup_commit() is
>> called to fix this issue.
>>
>> Changes since v1:
>> - Force vblank wait for watermarks not yet converted to atomic too. (Ville)
>> - Use for_each_new_intel_crtc_in_state. (Ville)
>> Changes since v2:
>> - Move the optimization to a separate commit. (Ville)
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> Fixes: b44d5c0c105a ("drm/i915: Always wait for flip_done, v2.")
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102675
>> Testcase: kms_cursor_crc
>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>> Reported-by: Marta Löfstedt <marta.lofstedt@intel.com>
>> Cc: Marta Löfstedt <marta.lofstedt@intel.com>
>> Tested-by: Marta Löfstedt <marta.lofstedt@intel.com>
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> ---
>>  drivers/gpu/drm/i915/intel_display.c | 33 ++++++++++++++++-----------------
>>  1 file changed, 16 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index 8599e425abb1..a85ca19a0c45 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -12517,21 +12517,10 @@ static int intel_atomic_commit(struct drm_device *dev,
>>  	struct drm_i915_private *dev_priv = to_i915(dev);
>>  	int ret = 0;
>>  
>> -	ret = drm_atomic_helper_setup_commit(state, nonblock);
>> -	if (ret)
>> -		return ret;
>> -
>>  	drm_atomic_state_get(state);
>>  	i915_sw_fence_init(&intel_state->commit_ready,
>>  			   intel_atomic_commit_ready);
>>  
>> -	ret = intel_atomic_prepare_commit(dev, state);
>> -	if (ret) {
>> -		DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
>> -		i915_sw_fence_commit(&intel_state->commit_ready);
>> -		return ret;
>> -	}
>> -
>>  	/*
>>  	 * The intel_legacy_cursor_update() fast path takes care
>>  	 * of avoiding the vblank waits for simple cursor
>> @@ -12540,11 +12529,11 @@ static int intel_atomic_commit(struct drm_device *dev,
>>  	 * updates happen during the correct frames. Gen9+ have
>>  	 * double buffered watermarks and so shouldn't need this.
>>  	 *
>> -	 * Do this after drm_atomic_helper_setup_commit() and
>> -	 * intel_atomic_prepare_commit() because we still want
>> -	 * to skip the flip and fb cleanup waits. Although that
>> -	 * does risk yanking the mapping from under the display
>> -	 * engine.
>> +	 * Unset state->legacy_cursor_update before the call to
>> +	 * drm_atomic_helper_setup_commit() because otherwise
>> +	 * drm_atomic_helper_wait_for_flip_done() is a noop and
>> +	 * we get FIFO underruns because we didn't wait
>> +	 * for vblank.
>>  	 *
>>  	 * FIXME doing watermarks and fb cleanup from a vblank worker
>>  	 * (assuming we had any) would solve these problems.
>> @@ -12552,7 +12541,17 @@ static int intel_atomic_commit(struct drm_device *dev,
>>  	if (INTEL_GEN(dev_priv) < 9)
>>  		state->legacy_cursor_update = false;
>>  
>> -	ret = drm_atomic_helper_swap_state(state, true);
>> +	ret = intel_atomic_prepare_commit(dev, state);
>> +	if (ret) {
>> +		DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
>> +		i915_sw_fence_commit(&intel_state->commit_ready);
>> +		return ret;
>> +	}
>> +
>> +	ret = drm_atomic_helper_setup_commit(state, nonblock);
> Hmm. One thing I noticed here. Previously if this failed we just called
> i915_sw_fence_commit(). Now we will also call
> drm_atomic_helper_cleanup_planes(). Is that going to be a problem?
This is intentional, intel_atomic_prepare_commit calls prepare_planes,
if that succeeds we'll need to call cleanup_planes too.

Ordering of setup_commit and prepare_planes doesn't matter.
>> +	if (!ret)
>> +		ret = drm_atomic_helper_swap_state(state, true);
>> +
>>  	if (ret) {
>>  		i915_sw_fence_commit(&intel_state->commit_ready);
>>  
>> -- 
>> 2.14.1
Ville Syrjälä Sept. 19, 2017, 2:15 p.m. UTC | #3
On Tue, Sep 19, 2017 at 03:50:47PM +0200, Maarten Lankhorst wrote:
> Op 19-09-17 om 15:38 schreef Ville Syrjälä:
> > On Tue, Sep 19, 2017 at 02:14:18PM +0200, Maarten Lankhorst wrote:
> >> Commit b44d5c0c105a ("drm/i915: Always wait for flip_done, v2.") removed
> >> the call to wait_for_vblanks and replaced it with flip_done.
> >>
> >> Unfortunately legacy_cursor_update was unset too late, and the
> >> replacement call drm_atomic_helper_wait_for_flip_done() was
> >> a noop. Make sure that its unset before setup_commit() is
> >> called to fix this issue.
> >>
> >> Changes since v1:
> >> - Force vblank wait for watermarks not yet converted to atomic too. (Ville)
> >> - Use for_each_new_intel_crtc_in_state. (Ville)
> >> Changes since v2:
> >> - Move the optimization to a separate commit. (Ville)
> >>
> >> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> >> Fixes: b44d5c0c105a ("drm/i915: Always wait for flip_done, v2.")
> >> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102675
> >> Testcase: kms_cursor_crc
> >> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> >> Reported-by: Marta Löfstedt <marta.lofstedt@intel.com>
> >> Cc: Marta Löfstedt <marta.lofstedt@intel.com>
> >> Tested-by: Marta Löfstedt <marta.lofstedt@intel.com>
> >> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >> ---
> >>  drivers/gpu/drm/i915/intel_display.c | 33 ++++++++++++++++-----------------
> >>  1 file changed, 16 insertions(+), 17 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> >> index 8599e425abb1..a85ca19a0c45 100644
> >> --- a/drivers/gpu/drm/i915/intel_display.c
> >> +++ b/drivers/gpu/drm/i915/intel_display.c
> >> @@ -12517,21 +12517,10 @@ static int intel_atomic_commit(struct drm_device *dev,
> >>  	struct drm_i915_private *dev_priv = to_i915(dev);
> >>  	int ret = 0;
> >>  
> >> -	ret = drm_atomic_helper_setup_commit(state, nonblock);
> >> -	if (ret)
> >> -		return ret;
> >> -
> >>  	drm_atomic_state_get(state);
> >>  	i915_sw_fence_init(&intel_state->commit_ready,
> >>  			   intel_atomic_commit_ready);
> >>  
> >> -	ret = intel_atomic_prepare_commit(dev, state);
> >> -	if (ret) {
> >> -		DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
> >> -		i915_sw_fence_commit(&intel_state->commit_ready);
> >> -		return ret;
> >> -	}
> >> -
> >>  	/*
> >>  	 * The intel_legacy_cursor_update() fast path takes care
> >>  	 * of avoiding the vblank waits for simple cursor
> >> @@ -12540,11 +12529,11 @@ static int intel_atomic_commit(struct drm_device *dev,
> >>  	 * updates happen during the correct frames. Gen9+ have
> >>  	 * double buffered watermarks and so shouldn't need this.
> >>  	 *
> >> -	 * Do this after drm_atomic_helper_setup_commit() and
> >> -	 * intel_atomic_prepare_commit() because we still want
> >> -	 * to skip the flip and fb cleanup waits. Although that
> >> -	 * does risk yanking the mapping from under the display
> >> -	 * engine.
> >> +	 * Unset state->legacy_cursor_update before the call to
> >> +	 * drm_atomic_helper_setup_commit() because otherwise
> >> +	 * drm_atomic_helper_wait_for_flip_done() is a noop and
> >> +	 * we get FIFO underruns because we didn't wait
> >> +	 * for vblank.
> >>  	 *
> >>  	 * FIXME doing watermarks and fb cleanup from a vblank worker
> >>  	 * (assuming we had any) would solve these problems.
> >> @@ -12552,7 +12541,17 @@ static int intel_atomic_commit(struct drm_device *dev,
> >>  	if (INTEL_GEN(dev_priv) < 9)
> >>  		state->legacy_cursor_update = false;
> >>  
> >> -	ret = drm_atomic_helper_swap_state(state, true);
> >> +	ret = intel_atomic_prepare_commit(dev, state);
> >> +	if (ret) {
> >> +		DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
> >> +		i915_sw_fence_commit(&intel_state->commit_ready);
> >> +		return ret;
> >> +	}
> >> +
> >> +	ret = drm_atomic_helper_setup_commit(state, nonblock);
> > Hmm. One thing I noticed here. Previously if this failed we just called
> > i915_sw_fence_commit(). Now we will also call
> > drm_atomic_helper_cleanup_planes(). Is that going to be a problem?
> This is intentional, intel_atomic_prepare_commit calls prepare_planes,
> if that succeeds we'll need to call cleanup_planes too.

Doh. Right.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> 
> Ordering of setup_commit and prepare_planes doesn't matter.
> >> +	if (!ret)
> >> +		ret = drm_atomic_helper_swap_state(state, true);
> >> +
> >>  	if (ret) {
> >>  		i915_sw_fence_commit(&intel_state->commit_ready);
> >>  
> >> -- 
> >> 2.14.1
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 8599e425abb1..a85ca19a0c45 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12517,21 +12517,10 @@  static int intel_atomic_commit(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	int ret = 0;
 
-	ret = drm_atomic_helper_setup_commit(state, nonblock);
-	if (ret)
-		return ret;
-
 	drm_atomic_state_get(state);
 	i915_sw_fence_init(&intel_state->commit_ready,
 			   intel_atomic_commit_ready);
 
-	ret = intel_atomic_prepare_commit(dev, state);
-	if (ret) {
-		DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
-		i915_sw_fence_commit(&intel_state->commit_ready);
-		return ret;
-	}
-
 	/*
 	 * The intel_legacy_cursor_update() fast path takes care
 	 * of avoiding the vblank waits for simple cursor
@@ -12540,11 +12529,11 @@  static int intel_atomic_commit(struct drm_device *dev,
 	 * updates happen during the correct frames. Gen9+ have
 	 * double buffered watermarks and so shouldn't need this.
 	 *
-	 * Do this after drm_atomic_helper_setup_commit() and
-	 * intel_atomic_prepare_commit() because we still want
-	 * to skip the flip and fb cleanup waits. Although that
-	 * does risk yanking the mapping from under the display
-	 * engine.
+	 * Unset state->legacy_cursor_update before the call to
+	 * drm_atomic_helper_setup_commit() because otherwise
+	 * drm_atomic_helper_wait_for_flip_done() is a noop and
+	 * we get FIFO underruns because we didn't wait
+	 * for vblank.
 	 *
 	 * FIXME doing watermarks and fb cleanup from a vblank worker
 	 * (assuming we had any) would solve these problems.
@@ -12552,7 +12541,17 @@  static int intel_atomic_commit(struct drm_device *dev,
 	if (INTEL_GEN(dev_priv) < 9)
 		state->legacy_cursor_update = false;
 
-	ret = drm_atomic_helper_swap_state(state, true);
+	ret = intel_atomic_prepare_commit(dev, state);
+	if (ret) {
+		DRM_DEBUG_ATOMIC("Preparing state failed with %i\n", ret);
+		i915_sw_fence_commit(&intel_state->commit_ready);
+		return ret;
+	}
+
+	ret = drm_atomic_helper_setup_commit(state, nonblock);
+	if (!ret)
+		ret = drm_atomic_helper_swap_state(state, true);
+
 	if (ret) {
 		i915_sw_fence_commit(&intel_state->commit_ready);