diff mbox

drm/i915: Skip fence installation for objects with rotated views (v3)

Message ID 1446081859-2032-1-git-send-email-vivek.kasireddy@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kasireddy, Vivek Oct. 29, 2015, 1:24 a.m. UTC
While pinning a fb object to the display plane, only install a fence
if the object is using a normal view. This corresponds with the
behavior found in i915_gem_object_do_pin() where the fencability
criteria is determined only for objects with normal views.

v2:
Look at the object's map_and_fenceable flag to determine whether to
install a fence or not (Chris).

v3:
Pin and unpin a fence only if the current view type is normal.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Tvrtko Ursulin Oct. 29, 2015, 10:31 a.m. UTC | #1
On 29/10/15 01:24, Vivek Kasireddy wrote:
> While pinning a fb object to the display plane, only install a fence
> if the object is using a normal view. This corresponds with the
> behavior found in i915_gem_object_do_pin() where the fencability
> criteria is determined only for objects with normal views.
>
> v2:
> Look at the object's map_and_fenceable flag to determine whether to
> install a fence or not (Chris).
>
> v3:
> Pin and unpin a fence only if the current view type is normal.
>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
> ---
>   drivers/gpu/drm/i915/intel_display.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 2fdfca1..ac06f8c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -2419,7 +2419,8 @@ intel_pin_and_fence_fb_obj(struct drm_plane *plane,
>   	 * framebuffer compression.  For simplicity, we always install
>   	 * a fence as the cost is not that onerous.
>   	 */
> -	ret = i915_gem_object_get_fence(obj);
> +	if (view.type == I915_GGTT_VIEW_NORMAL)
> +		ret = i915_gem_object_get_fence(obj);
>   	if (ret == -EDEADLK) {
>   		/*
>   		 * -EDEADLK means there are no free fences
> @@ -2460,7 +2461,9 @@ static void intel_unpin_fb_obj(struct drm_framebuffer *fb,
>   	ret = intel_fill_fb_ggtt_view(&view, fb, plane_state);
>   	WARN_ONCE(ret, "Couldn't get view from plane state!");
>
> -	i915_gem_object_unpin_fence(obj);
> +	if (view.type == I915_GGTT_VIEW_NORMAL)
> +		i915_gem_object_unpin_fence(obj);
> +
>   	i915_gem_object_unpin_from_display_plane(obj, &view);
>   }
>
>

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Ok to merge Chris and Ville ?

Regards,

Tvrtko
Ville Syrjälä Oct. 29, 2015, 1:20 p.m. UTC | #2
On Wed, Oct 28, 2015 at 06:24:19PM -0700, Vivek Kasireddy wrote:
> While pinning a fb object to the display plane, only install a fence
> if the object is using a normal view. This corresponds with the
> behavior found in i915_gem_object_do_pin() where the fencability
> criteria is determined only for objects with normal views.
> 
> v2:
> Look at the object's map_and_fenceable flag to determine whether to
> install a fence or not (Chris).
> 
> v3:
> Pin and unpin a fence only if the current view type is normal.
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 2fdfca1..ac06f8c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -2419,7 +2419,8 @@ intel_pin_and_fence_fb_obj(struct drm_plane *plane,
>  	 * framebuffer compression.  For simplicity, we always install
>  	 * a fence as the cost is not that onerous.
>  	 */
> -	ret = i915_gem_object_get_fence(obj);
> +	if (view.type == I915_GGTT_VIEW_NORMAL)
> +		ret = i915_gem_object_get_fence(obj);

Missing the same check for the pin_fence().

>  	if (ret == -EDEADLK) {
>  		/*
>  		 * -EDEADLK means there are no free fences
> @@ -2460,7 +2461,9 @@ static void intel_unpin_fb_obj(struct drm_framebuffer *fb,
>  	ret = intel_fill_fb_ggtt_view(&view, fb, plane_state);
>  	WARN_ONCE(ret, "Couldn't get view from plane state!");
>  
> -	i915_gem_object_unpin_fence(obj);
> +	if (view.type == I915_GGTT_VIEW_NORMAL)
> +		i915_gem_object_unpin_fence(obj);
> +
>  	i915_gem_object_unpin_from_display_plane(obj, &view);
>  }
>  
> -- 
> 2.4.3
Tvrtko Ursulin Oct. 29, 2015, 1:33 p.m. UTC | #3
On 29/10/15 13:20, Ville Syrjälä wrote:
> On Wed, Oct 28, 2015 at 06:24:19PM -0700, Vivek Kasireddy wrote:
>> While pinning a fb object to the display plane, only install a fence
>> if the object is using a normal view. This corresponds with the
>> behavior found in i915_gem_object_do_pin() where the fencability
>> criteria is determined only for objects with normal views.
>>
>> v2:
>> Look at the object's map_and_fenceable flag to determine whether to
>> install a fence or not (Chris).
>>
>> v3:
>> Pin and unpin a fence only if the current view type is normal.
>>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
>> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
>> ---
>>   drivers/gpu/drm/i915/intel_display.c | 7 +++++--
>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index 2fdfca1..ac06f8c 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -2419,7 +2419,8 @@ intel_pin_and_fence_fb_obj(struct drm_plane *plane,
>>   	 * framebuffer compression.  For simplicity, we always install
>>   	 * a fence as the cost is not that onerous.
>>   	 */
>> -	ret = i915_gem_object_get_fence(obj);
>> +	if (view.type == I915_GGTT_VIEW_NORMAL)
>> +		ret = i915_gem_object_get_fence(obj);
>
> Missing the same check for the pin_fence().

Well spotted. :(

So a fence leak and another testcase needed to exercise it.

Pin normal, then pin rotated, unpin both = leak one fence. Repeat 
num_fences times until no more fences and fail?

Regards,

Tvrtko
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 2fdfca1..ac06f8c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2419,7 +2419,8 @@  intel_pin_and_fence_fb_obj(struct drm_plane *plane,
 	 * framebuffer compression.  For simplicity, we always install
 	 * a fence as the cost is not that onerous.
 	 */
-	ret = i915_gem_object_get_fence(obj);
+	if (view.type == I915_GGTT_VIEW_NORMAL)
+		ret = i915_gem_object_get_fence(obj);
 	if (ret == -EDEADLK) {
 		/*
 		 * -EDEADLK means there are no free fences
@@ -2460,7 +2461,9 @@  static void intel_unpin_fb_obj(struct drm_framebuffer *fb,
 	ret = intel_fill_fb_ggtt_view(&view, fb, plane_state);
 	WARN_ONCE(ret, "Couldn't get view from plane state!");
 
-	i915_gem_object_unpin_fence(obj);
+	if (view.type == I915_GGTT_VIEW_NORMAL)
+		i915_gem_object_unpin_fence(obj);
+
 	i915_gem_object_unpin_from_display_plane(obj, &view);
 }