diff mbox

[34/37] drm/ttm: fix fence locking in ttm_buffer_object_transfer

Message ID 1355317637-16742-35-git-send-email-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter Dec. 12, 2012, 1:07 p.m. UTC
Noticed while reviewing the fence locking in the radone pageflip
handler.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/ttm/ttm_bo_util.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Jerome Glisse Dec. 12, 2012, 2:48 p.m. UTC | #1
On Wed, Dec 12, 2012 at 8:07 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Noticed while reviewing the fence locking in the radone pageflip
> handler.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/ttm/ttm_bo_util.c |    2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index b9c4e51..5c8b207 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -441,7 +441,9 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
>         fbo->vm_node = NULL;
>         atomic_set(&fbo->cpu_writers, 0);
>
> +       spin_lock(&bdev->fence_lock);
>         fbo->sync_obj = driver->sync_obj_ref(bo->sync_obj);
> +       spin_unlock(&bdev->fence_lock);
>         kref_init(&fbo->list_kref);
>         kref_init(&fbo->kref);
>         fbo->destroy = &ttm_transfered_destroy;
> --

Instead of that i would just move the call to
ttm_buffer_object_transfer to happen before releasing the fence_lock
in ttm_bo_move_accel_cleanup , something like :


set_bit(TTM_BO_PRIV_FLAG_MOVING, &bo->priv_flags);
ret = ttm_buffer_object_transfer(bo, &ghost_obj);
spin_unlock(&bdev->fence_lock);
if (tmp_obj)
  driver->sync_obj_unref(&tmp_obj);

if (ret)
   return ret;

Cheers,
Jerome
Daniel Vetter Dec. 12, 2012, 3:42 p.m. UTC | #2
On Wed, Dec 12, 2012 at 3:48 PM, Jerome Glisse <j.glisse@gmail.com> wrote:
> Instead of that i would just move the call to
> ttm_buffer_object_transfer to happen before releasing the fence_lock
> in ttm_bo_move_accel_cleanup , something like :

Yeah, looks better. Fixed up locally.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index b9c4e51..5c8b207 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -441,7 +441,9 @@  static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
 	fbo->vm_node = NULL;
 	atomic_set(&fbo->cpu_writers, 0);
 
+	spin_lock(&bdev->fence_lock);
 	fbo->sync_obj = driver->sync_obj_ref(bo->sync_obj);
+	spin_unlock(&bdev->fence_lock);
 	kref_init(&fbo->list_kref);
 	kref_init(&fbo->kref);
 	fbo->destroy = &ttm_transfered_destroy;