dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Hellstrom <thellstrom@vmware.com>
To: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/ttm: alter cpu_writers to return -EBUSY in ttm_execbuf_util reservations
Date: Wed, 07 Nov 2012 13:17:41 +0100	[thread overview]
Message-ID: <509A5165.3070005@vmware.com> (raw)
In-Reply-To: <5099131F.6070505@canonical.com>

On 11/06/2012 02:39 PM, Maarten Lankhorst wrote:
> This is similar to other platforms that don't allow command submission
> to buffers locked on the cpu.
>      
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
>
> ---
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index bf6e4b5..2b3f69b 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1054,16 +1054,6 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
>   }
>   EXPORT_SYMBOL(ttm_bo_mem_space);
>   
> -int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait)
> -{
> -	if ((atomic_read(&bo->cpu_writers) > 0) && no_wait)
> -		return -EBUSY;
> -
> -	return wait_event_interruptible(bo->event_queue,
> -					atomic_read(&bo->cpu_writers) == 0);
> -}
> -EXPORT_SYMBOL(ttm_bo_wait_cpu);
> -
>   int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
>   			struct ttm_placement *placement,
>   			bool interruptible, bool no_wait_reserve,
> @@ -1797,8 +1787,7 @@ EXPORT_SYMBOL(ttm_bo_synccpu_write_grab);
>   
>   void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo)
>   {
> -	if (atomic_dec_and_test(&bo->cpu_writers))
> -		wake_up_all(&bo->event_queue);
> +	atomic_dec(&bo->cpu_writers);
>   }
>   EXPORT_SYMBOL(ttm_bo_synccpu_write_release);
>   
> diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
> index 1937069..7aa5073 100644
> --- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
> @@ -185,10 +185,7 @@ retry_this_bo:
>   			ttm_eu_backoff_reservation_locked(list);
>   			spin_unlock(&glob->lru_lock);
>   			ttm_eu_list_ref_sub(list);
> -			ret = ttm_bo_wait_cpu(bo, false);
> -			if (ret)
> -				return ret;
> -			goto retry;
> +			return -EBUSY;
>   		}
>   	}
>   
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index e8028ad..850424f 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -429,8 +429,9 @@ extern void ttm_bo_unlock_delayed_workqueue(struct ttm_bo_device *bdev,
>    * @no_wait: Return immediately if buffer is busy.
>    *
>    * Synchronizes a buffer object for CPU RW access. This means
> - * blocking command submission that affects the buffer and
> - * waiting for buffer idle. This lock is recursive.
> + * command submission that affects the buffer will return -EBUSY
> + * until ttm_bo_synccpu_write_release is called.
> + *
>    * Returns
>    * -EBUSY if the buffer is busy and no_wait is true.
>    * -ERESTARTSYS if interrupted by a signal.
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index d803b92..3e193f5 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -729,20 +729,6 @@ extern void ttm_bo_mem_put(struct ttm_buffer_object *bo,
>   extern void ttm_bo_mem_put_locked(struct ttm_buffer_object *bo,
>   				  struct ttm_mem_reg *mem);
>   
> -/**
> - * ttm_bo_wait_for_cpu
> - *
> - * @bo: Pointer to a struct ttm_buffer_object.
> - * @no_wait: Don't sleep while waiting.
> - *
> - * Wait until a buffer object is no longer sync'ed for CPU access.
> - * Returns:
> - * -EBUSY: Buffer object was sync'ed for CPU access. (only if no_wait == 1).
> - * -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
> - */
> -
> -extern int ttm_bo_wait_cpu(struct ttm_buffer_object *bo, bool no_wait);
> -
>   extern void ttm_bo_global_release(struct drm_global_reference *ref);
>   extern int ttm_bo_global_init(struct drm_global_reference *ref);
>   
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>

      reply	other threads:[~2012-11-07 12:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-06 13:39 [PATCH] drm/ttm: alter cpu_writers to return -EBUSY in ttm_execbuf_util reservations Maarten Lankhorst
2012-11-07 12:17 ` Thomas Hellstrom [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=509A5165.3070005@vmware.com \
    --to=thellstrom@vmware.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox