drm/amdgpu: Add preferred_domain check when determine XGMI state
authorshaoyunl <shaoyun.liu@amd.com>
Tue, 26 Mar 2019 18:47:57 +0000 (14:47 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 3 Apr 2019 15:00:30 +0000 (10:00 -0500)
Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device

Signed-off-by: shaoyunl <shaoyun.liu@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index 61107cfc9af6c29f5279ffe403321b9be89b5f10..d4fcf5475464645f0661f4aea7c69e69b5dd96df 100644 (file)
@@ -31,6 +31,7 @@
 #include <drm/amdgpu_drm.h>
 #include "amdgpu.h"
 #include "amdgpu_display.h"
+#include "amdgpu_xgmi.h"
 
 void amdgpu_gem_object_free(struct drm_gem_object *gobj)
 {
@@ -668,6 +669,7 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
        struct amdgpu_device *adev = dev->dev_private;
        struct drm_amdgpu_gem_op *args = data;
        struct drm_gem_object *gobj;
+       struct amdgpu_vm_bo_base *base;
        struct amdgpu_bo *robj;
        int r;
 
@@ -706,6 +708,15 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
                        amdgpu_bo_unreserve(robj);
                        break;
                }
+               for (base = robj->vm_bo; base; base = base->next)
+                       if (amdgpu_xgmi_same_hive(amdgpu_ttm_adev(robj->tbo.bdev),
+                               amdgpu_ttm_adev(base->vm->root.base.bo->tbo.bdev))) {
+                               r = -EINVAL;
+                               amdgpu_bo_unreserve(robj);
+                               goto out;
+                       }
+
+
                robj->preferred_domains = args->value & (AMDGPU_GEM_DOMAIN_VRAM |
                                                        AMDGPU_GEM_DOMAIN_GTT |
                                                        AMDGPU_GEM_DOMAIN_CPU);
index fc7236af6a41a49a0fcc334185b3c80941f89033..a07c85815b7a65b1dc554a01cf607e8fd41332bb 100644 (file)
@@ -2037,7 +2037,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 */