diff mbox

[5/8] drm/radeon: cope with foreign fences inside display

Message ID 1410957305-10190-6-git-send-email-maarten.lankhorst@canonical.com (mailing list archive)
State New, archived
Headers show

Commit Message

Maarten Lankhorst Sept. 17, 2014, 12:35 p.m. UTC
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
---
 drivers/gpu/drm/radeon/radeon.h         |  2 +-
 drivers/gpu/drm/radeon/radeon_display.c | 30 +++++++++++++++++++-----------
 2 files changed, 20 insertions(+), 12 deletions(-)

Comments

Christian König Sept. 17, 2014, 1:16 p.m. UTC | #1
Am 17.09.2014 um 14:35 schrieb Maarten Lankhorst:
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/radeon/radeon.h         |  2 +-
>   drivers/gpu/drm/radeon/radeon_display.c | 30 +++++++++++++++++++-----------
>   2 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index 82b0e11ade89..9aa75c1af4f4 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -710,7 +710,7 @@ struct radeon_flip_work {
>   	uint64_t			base;
>   	struct drm_pending_vblank_event *event;
>   	struct radeon_bo		*old_rbo;
> -	struct radeon_fence		*fence;
> +	struct fence			*fence;
>   };
>   
>   struct r500_irq_stat_regs {
> diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
> index 4eb37976f879..00ead8c2758a 100644
> --- a/drivers/gpu/drm/radeon/radeon_display.c
> +++ b/drivers/gpu/drm/radeon/radeon_display.c
> @@ -402,14 +402,21 @@ static void radeon_flip_work_func(struct work_struct *__work)
>   
>           down_read(&rdev->exclusive_lock);
>   	if (work->fence) {
> -		r = radeon_fence_wait(work->fence, false);
> -		if (r == -EDEADLK) {
> -			up_read(&rdev->exclusive_lock);
> -			do {
> -				r = radeon_gpu_reset(rdev);
> -			} while (r == -EAGAIN);
> -			down_read(&rdev->exclusive_lock);
> -		}
> +		struct radeon_fence *fence;
> +
> +		fence = to_radeon_fence(work->fence);
> +		if (fence && fence->rdev == rdev) {
> +			r = radeon_fence_wait(fence, false);
> +			if (r == -EDEADLK) {
> +				up_read(&rdev->exclusive_lock);
> +				do {
> +					r = radeon_gpu_reset(rdev);
> +				} while (r == -EAGAIN);
> +				down_read(&rdev->exclusive_lock);
> +			}
> +		} else
> +			r = fence_wait(work->fence, false);
> +
>   		if (r)
>   			DRM_ERROR("failed to wait on page flip fence (%d)!\n", r);
>   
> @@ -418,7 +425,8 @@ static void radeon_flip_work_func(struct work_struct *__work)
>   		 * confused about which BO the CRTC is scanning out
>   		 */
>   
> -		radeon_fence_unref(&work->fence);
> +		fence_put(work->fence);
> +		work->fence = NULL;
>   	}
>   
>   	/* We borrow the event spin lock for protecting flip_status */
> @@ -494,7 +502,7 @@ static int radeon_crtc_page_flip(struct drm_crtc *crtc,
>   		DRM_ERROR("failed to pin new rbo buffer before flip\n");
>   		goto cleanup;
>   	}
> -	work->fence = (struct radeon_fence *)fence_get(reservation_object_get_excl(new_rbo->tbo.resv));
> +	work->fence = fence_get(reservation_object_get_excl(new_rbo->tbo.resv));
>   	radeon_bo_get_tiling_flags(new_rbo, &tiling_flags, NULL);
>   	radeon_bo_unreserve(new_rbo);
>   
> @@ -576,7 +584,7 @@ pflip_cleanup:
>   
>   cleanup:
>   	drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base);
> -	radeon_fence_unref(&work->fence);
> +	fence_put(work->fence);
>   	kfree(work);
>   	return r;
>   }
diff mbox

Patch

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 82b0e11ade89..9aa75c1af4f4 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -710,7 +710,7 @@  struct radeon_flip_work {
 	uint64_t			base;
 	struct drm_pending_vblank_event *event;
 	struct radeon_bo		*old_rbo;
-	struct radeon_fence		*fence;
+	struct fence			*fence;
 };
 
 struct r500_irq_stat_regs {
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 4eb37976f879..00ead8c2758a 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -402,14 +402,21 @@  static void radeon_flip_work_func(struct work_struct *__work)
 
         down_read(&rdev->exclusive_lock);
 	if (work->fence) {
-		r = radeon_fence_wait(work->fence, false);
-		if (r == -EDEADLK) {
-			up_read(&rdev->exclusive_lock);
-			do {
-				r = radeon_gpu_reset(rdev);
-			} while (r == -EAGAIN);
-			down_read(&rdev->exclusive_lock);
-		}
+		struct radeon_fence *fence;
+
+		fence = to_radeon_fence(work->fence);
+		if (fence && fence->rdev == rdev) {
+			r = radeon_fence_wait(fence, false);
+			if (r == -EDEADLK) {
+				up_read(&rdev->exclusive_lock);
+				do {
+					r = radeon_gpu_reset(rdev);
+				} while (r == -EAGAIN);
+				down_read(&rdev->exclusive_lock);
+			}
+		} else
+			r = fence_wait(work->fence, false);
+
 		if (r)
 			DRM_ERROR("failed to wait on page flip fence (%d)!\n", r);
 
@@ -418,7 +425,8 @@  static void radeon_flip_work_func(struct work_struct *__work)
 		 * confused about which BO the CRTC is scanning out
 		 */
 
-		radeon_fence_unref(&work->fence);
+		fence_put(work->fence);
+		work->fence = NULL;
 	}
 
 	/* We borrow the event spin lock for protecting flip_status */
@@ -494,7 +502,7 @@  static int radeon_crtc_page_flip(struct drm_crtc *crtc,
 		DRM_ERROR("failed to pin new rbo buffer before flip\n");
 		goto cleanup;
 	}
-	work->fence = (struct radeon_fence *)fence_get(reservation_object_get_excl(new_rbo->tbo.resv));
+	work->fence = fence_get(reservation_object_get_excl(new_rbo->tbo.resv));
 	radeon_bo_get_tiling_flags(new_rbo, &tiling_flags, NULL);
 	radeon_bo_unreserve(new_rbo);
 
@@ -576,7 +584,7 @@  pflip_cleanup:
 
 cleanup:
 	drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base);
-	radeon_fence_unref(&work->fence);
+	fence_put(work->fence);
 	kfree(work);
 	return r;
 }