dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <deathsimple@vodafone.de>
To: "Michel Dänzer" <michel@daenzer.net>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/ttm: Don't evict BOs outside of the requested placement range
Date: Thu, 09 Oct 2014 11:53:00 +0200	[thread overview]
Message-ID: <54365AFC.5090900@vodafone.de> (raw)
In-Reply-To: <1412834579-24703-1-git-send-email-michel@daenzer.net>

Am 09.10.2014 um 08:02 schrieb Michel Dänzer:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> The radeon driver uses placement range restrictions for several reasons,
> in particular to make sure BOs in VRAM can be accessed by the CPU, e.g.
> during a page fault.
>
> Without this change, TTM could evict other BOs while trying to satisfy
> the requested placement, even if the evicted BOs were outside of the
> requested placement range. Doing so didn't free up any space in the
> requested placement range, so the (potentially high) eviction cost was
> incurred for no benefit.
>
> Nominating for stable because radeon driver changes in 3.17 made this
> much more noticeable than before.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84662
> Cc: stable@vger.kernel.org
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>

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

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c | 20 +++++++++++++++++---
>   1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 8f5cec6..407fa2d 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -709,6 +709,7 @@ out:
>   
>   static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
>   				uint32_t mem_type,
> +				const struct ttm_place *place,
>   				bool interruptible,
>   				bool no_wait_gpu)
>   {
> @@ -720,8 +721,21 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
>   	spin_lock(&glob->lru_lock);
>   	list_for_each_entry(bo, &man->lru, lru) {
>   		ret = __ttm_bo_reserve(bo, false, true, false, NULL);
> -		if (!ret)
> +		if (!ret) {
> +			if (place && (place->fpfn || place->lpfn)) {
> +				/* Don't evict this BO if it's outside of the
> +				 * requested placement range
> +				 */
> +				if (place->fpfn >= (bo->mem.start + bo->mem.size) ||
> +				    (place->lpfn && place->lpfn <= bo->mem.start)) {
> +					__ttm_bo_unreserve(bo);
> +					ret = -EBUSY;
> +					continue;
> +				}
> +			}
> +
>   			break;
> +		}
>   	}
>   
>   	if (ret) {
> @@ -782,7 +796,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
>   			return ret;
>   		if (mem->mm_node)
>   			break;
> -		ret = ttm_mem_evict_first(bdev, mem_type,
> +		ret = ttm_mem_evict_first(bdev, mem_type, place,
>   					  interruptible, no_wait_gpu);
>   		if (unlikely(ret != 0))
>   			return ret;
> @@ -1233,7 +1247,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
>   	spin_lock(&glob->lru_lock);
>   	while (!list_empty(&man->lru)) {
>   		spin_unlock(&glob->lru_lock);
> -		ret = ttm_mem_evict_first(bdev, mem_type, false, false);
> +		ret = ttm_mem_evict_first(bdev, mem_type, NULL, false, false);
>   		if (ret) {
>   			if (allow_errors) {
>   				return ret;

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2014-10-09  9:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-09  6:02 [PATCH] drm/ttm: Don't evict BOs outside of the requested placement range Michel Dänzer
2014-10-09  9:53 ` Christian König [this message]
2014-10-09 10:22 ` Alan Swanson
2014-10-10  3:20   ` Michel Dänzer
2014-10-10  8:51     ` Alan Swanson
2014-10-10  8:59       ` Michel Dänzer
2014-10-11 18:31         ` Daniel Vetter
2014-10-11 20:24           ` Greg KH
2014-10-14  6:10             ` Michel Dänzer
2014-10-10  9:03 ` [PATCH v2] " Michel Dänzer
2014-10-13 18:22 ` [PATCH] " Alex Deucher
2014-10-14  5:40   ` Thomas Hellstrom

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=54365AFC.5090900@vodafone.de \
    --to=deathsimple@vodafone.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=michel@daenzer.net \
    /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