All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhoucm1 <zhoucm1-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
	<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 3/3] drm/amdgpu: set preferred_domain independent of fallback handling
Date: Wed, 11 Apr 2018 10:38:48 +0800	[thread overview]
Message-ID: <06295e11-12f1-6ca9-133e-f906cdf04ed7@amd.com> (raw)
In-Reply-To: <20180410134240.9515-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>



On 2018年04月10日 21:42, Christian König wrote:
> When GEM needs to fallback to GTT for VRAM BOs we still want the
> preferred domain to be untouched so that the BO has a cance to move back
> to VRAM in the future.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 14 +++++++++++---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 13 ++-----------
>   2 files changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> index 46b9ea4e6103..9dc0a190413c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> @@ -47,6 +47,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
>   			     struct reservation_object *resv,
>   			     struct drm_gem_object **obj)
>   {
> +	uint32_t domain = initial_domain;
>   	struct amdgpu_bo *bo;
>   	int r;
>   
> @@ -57,7 +58,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
>   	}
>   
>   retry:
> -	r = amdgpu_bo_create(adev, size, alignment, initial_domain,
> +	r = amdgpu_bo_create(adev, size, alignment, domain,
>   			     flags, type, resv, &bo);
>   	if (r) {
>   		if (r != -ERESTARTSYS) {
> @@ -66,8 +67,8 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
>   				goto retry;
>   			}
>   
> -			if (initial_domain == AMDGPU_GEM_DOMAIN_VRAM) {
> -				initial_domain |= AMDGPU_GEM_DOMAIN_GTT;
> +			if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
> +				domain |= AMDGPU_GEM_DOMAIN_GTT;
>   				goto retry;
>   			}
>   			DRM_DEBUG("Failed to allocate GEM object (%ld, %d, %u, %d)\n",
> @@ -75,6 +76,13 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
>   		}
>   		return r;
>   	}
> +
> +	bo->preferred_domains = initial_domain;
> +	bo->allowed_domains = initial_domain;
> +	if (type != ttm_bo_type_kernel &&
> +	    bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM)
> +		bo->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT;
It's an ugly change back after bo creation! Do you think it's better 
than previous?

Alternative way, you can add one parameter to amdgpu_bo_create, directly 
pass preferred_domains and allowed_domains to amdgpu_bo_create.

Regards,
David Zhou
> +
>   	*obj = &bo->gem_base;
>   
>   	return 0;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 6d08cde8443c..854d18d5cff4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -375,17 +375,8 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, unsigned long size,
>   	drm_gem_private_object_init(adev->ddev, &bo->gem_base, size);
>   	INIT_LIST_HEAD(&bo->shadow_list);
>   	INIT_LIST_HEAD(&bo->va);
> -	bo->preferred_domains = domain & (AMDGPU_GEM_DOMAIN_VRAM |
> -					 AMDGPU_GEM_DOMAIN_GTT |
> -					 AMDGPU_GEM_DOMAIN_CPU |
> -					 AMDGPU_GEM_DOMAIN_GDS |
> -					 AMDGPU_GEM_DOMAIN_GWS |
> -					 AMDGPU_GEM_DOMAIN_OA);
> -	bo->allowed_domains = bo->preferred_domains;
> -	if (type != ttm_bo_type_kernel &&
> -	    bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM)
> -		bo->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT;
> -
> +	bo->preferred_domains = domain;
> +	bo->allowed_domains = domain;
>   	bo->flags = flags;
>   
>   #ifdef CONFIG_X86_32

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-04-11  2:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 13:42 [PATCH 1/3] drm/amdgpu: revert "add new bo flag that indicates BOs don't need fallback (v2)" Christian König
     [not found] ` <20180410134240.9515-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-04-10 13:42   ` [PATCH 2/3] drm/amdgpu: revert "Don't change preferred domian when fallback GTT v6" Christian König
2018-04-10 13:42   ` [PATCH 3/3] drm/amdgpu: set preferred_domain independent of fallback handling Christian König
     [not found]     ` <20180410134240.9515-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-04-11  2:38       ` zhoucm1 [this message]
     [not found]         ` <06295e11-12f1-6ca9-133e-f906cdf04ed7-5C7GfCeVMHo@public.gmane.org>
2018-04-11  9:22           ` Christian König
     [not found]             ` <29b09ef5-a88a-daff-fc13-c875f975e26e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-04-16  8:57               ` Christian König
     [not found]                 ` <47328a0b-e56b-24fb-0838-271a5127a3bc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-04-16  9:04                   ` zhoucm1
     [not found]                     ` <845e35b3-3b2c-0ed0-ba27-9eb4e603df21-5C7GfCeVMHo@public.gmane.org>
2018-04-16  9:21                       ` zhoucm1
     [not found]                         ` <0df2d99a-a997-3842-e063-18543cd49aa2-5C7GfCeVMHo@public.gmane.org>
2018-04-16  9:36                           ` Christian König
     [not found]                             ` <f961f48e-7b37-d988-144c-5f6cfaaa9ec0-5C7GfCeVMHo@public.gmane.org>
2018-04-16 10:38                               ` zhoucm1

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=06295e11-12f1-6ca9-133e-f906cdf04ed7@amd.com \
    --to=zhoucm1-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.