AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Kuehling, Felix" <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
To: "Liu, Shaoyun" <Shaoyun.Liu-5C7GfCeVMHo@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH] drm/amdgpu: Add preferred_domain check when determine XGMI state
Date: Tue, 26 Mar 2019 20:02:21 +0000	[thread overview]
Message-ID: <56188445-4deb-ff89-8f1c-82eb5ac987c6@amd.com> (raw)
In-Reply-To: <1553626381-23351-1-git-send-email-shaoyun.liu-5C7GfCeVMHo@public.gmane.org>

On 2019-03-26 2:54 p.m., Liu, Shaoyun wrote:
> Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device
>
> Change-Id: I1881deff3da19f1f4b58d5765db03a590092a5b2
> Signed-off-by: shaoyunl <shaoyun.liu@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 9 +++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 3 ++-
>   2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> index a82c3b1..3c7ee71 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> @@ -664,8 +664,10 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
>   			struct drm_file *filp)
>   {
>   	struct amdgpu_device *adev = dev->dev_private;
> +	struct amdgpu_fpriv *fpriv = filp->driver_priv;
>   	struct drm_amdgpu_gem_op *args = data;
>   	struct drm_gem_object *gobj;
> +	struct amdgpu_bo_va *bo_va;
>   	struct amdgpu_bo *robj;
>   	int r;
>   
> @@ -704,6 +706,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
>   			amdgpu_bo_unreserve(robj);
>   			break;
>   		}
> +		bo_va = amdgpu_vm_bo_find(&fpriv->vm, robj);
> +		if (bo_va && bo_va->is_xgmi) {
> +			r = -EINVAL;
> +			amdgpu_bo_unreserve(robj);
> +			break;
> +		}
> +

Hmm, from the other discussion, GEM doesn't really support P2P of VRAM 
BOs between GPUs right now. The only way this function can affect a BO 
that's P2P shared is, if the BO is allocated with GEM and then imported 
into KFD. In that case you'll need to take into account mappings of the 
imported BO in all the KFD VMs, not the VMs in the fpriv->vm.

In other words, you need to find all bo_vas of the BO in all VMs and for 
each one check, whether it has is_xgmi set.

Regards,
   Felix


>   		robj->preferred_domains = args->value & (AMDGPU_GEM_DOMAIN_VRAM |
>   							AMDGPU_GEM_DOMAIN_GTT |
>   							AMDGPU_GEM_DOMAIN_CPU);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 76eee7e..f08dda2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -2048,7 +2048,8 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev,
>   	INIT_LIST_HEAD(&bo_va->valids);
>   	INIT_LIST_HEAD(&bo_va->invalids);
>   
> -	if (bo && amdgpu_xgmi_same_hive(adev, amdgpu_ttm_adev(bo->tbo.bdev))) {
> +	if (bo && amdgpu_xgmi_same_hive(adev, amdgpu_ttm_adev(bo->tbo.bdev)) &&
> +	    (bo->preferred_domains == AMDGPU_GEM_DOMAIN_VRAM)) {
>   		bo_va->is_xgmi = true;
>   		mutex_lock(&adev->vm_manager.lock_pstate);
>   		/* Power up XGMI if it can be potentially used */
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2019-03-26 20:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26 18:54 [PATCH] drm/amdgpu: Add preferred_domain check when determine XGMI state Liu, Shaoyun
     [not found] ` <1553626381-23351-1-git-send-email-shaoyun.liu-5C7GfCeVMHo@public.gmane.org>
2019-03-26 19:12   ` Christian König
2019-03-26 20:02   ` Kuehling, Felix [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-03-26 20:35 Liu, Shaoyun
     [not found] ` <1553632516-23346-1-git-send-email-shaoyun.liu-5C7GfCeVMHo@public.gmane.org>
2019-03-27  7:41   ` Christian König
     [not found]     ` <c42cc872-cddf-01b9-b46e-b2084f8a1bc3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-03-27 15:22       ` Liu, Shaoyun
     [not found]         ` <5d6e562d-012b-f22b-7ec9-2fdf33a9319d-5C7GfCeVMHo@public.gmane.org>
2019-03-27 15:30           ` Koenig, Christian
     [not found]             ` <3e28a7df-4165-4bde-8a2e-926453ceb1d1-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2019-03-27 15:34               ` Liu, Shaoyun
     [not found]                 ` <fd7f4b68-26c2-d0ea-b254-fbc61a0d3956-5C7GfCeVMHo@public.gmane.org>
2019-03-27 15:39                   ` Koenig, Christian
     [not found]                     ` <68f7ccfa-646e-492f-bdd7-b24f2e2029da-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2019-03-27 15:43                       ` Liu, Shaoyun
     [not found]                         ` <7a3199ec-c851-6b50-7e1f-b467e5e78d13-5C7GfCeVMHo@public.gmane.org>
2019-03-27 15:44                           ` Koenig, Christian
2019-03-27 15:52   ` Kuehling, Felix
     [not found]     ` <5e7addf1-61f7-a0f9-a709-5039ba1de840-5C7GfCeVMHo@public.gmane.org>
2019-03-27 16:24       ` Liu, Shaoyun
2019-03-28 17:55 Liu, Shaoyun
     [not found] ` <1553795695-6065-1-git-send-email-shaoyun.liu-5C7GfCeVMHo@public.gmane.org>
2019-03-28 19:18   ` Kuehling, Felix
     [not found]     ` <5744d324-0e7b-a19d-f4b5-a5242f664e8e-5C7GfCeVMHo@public.gmane.org>
2019-03-28 19:47       ` Liu, Shaoyun
     [not found]         ` <5187cc22-bf83-9617-d9df-c5ab1bca5735-5C7GfCeVMHo@public.gmane.org>
2019-03-28 19:58           ` Kuehling, Felix
2019-03-29 10:47   ` Christian König
2019-03-28 19:53 Liu, Shaoyun
2019-03-28 20:27 Liu, Shaoyun
2019-03-28 20:29 Liu, Shaoyun
2019-03-28 20:38 Liu, Shaoyun
     [not found] ` <1553805488-15372-1-git-send-email-shaoyun.liu-5C7GfCeVMHo@public.gmane.org>
2019-03-28 20:39   ` Kuehling, Felix
     [not found]     ` <a5df1503-edc9-f744-c340-4b45b243f29b-5C7GfCeVMHo@public.gmane.org>
2019-03-29 10:50       ` Christian König

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=56188445-4deb-ff89-8f1c-82eb5ac987c6@amd.com \
    --to=felix.kuehling-5c7gfcevmho@public.gmane.org \
    --cc=Shaoyun.Liu-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox