Skip to contentSkip to conversation

drm/amdgpu: Add preferred_domain check when determine XGMI state

PATCH In review Liu, Shaoyun 3 participants 3 messages Mar 28, 2019 – Mar 29, 2019 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Add preferred_domain check when determine XGMI state

Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device

Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 +++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  |  3 ++-
 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +11 -0
index 9ee8d7a..7b84036 100644
@@ -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)
 {
@@ -666,6 +667,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;
 
@@ -704,6 +706,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);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
index 3d221f0..eb242a1 100644
@@ -2025,7 +2025,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 */
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1553805488-15372-1-git-send-email-shaoyun.liu-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 4 lines · Shaoyun

Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device

Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2

This patch is Reviewed-by: Felix Kuehling <[email protected]>

Please also give Christian a chance to review this one before you submit.

Thanks,
  Felix

Quoted 46 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 +++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  |  3 ++-
  2 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +11 -0
index 9ee8d7a..7b84036 100644
@@ -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)
  {
@@ -666,6 +667,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;
 
@@ -704,6 +706,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);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index 3d221f0..eb242a1 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev, · line 2032

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
@@ -2025,7 +2025,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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): a5df1503-edc9-f744-c340-4b45b243f29b-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Am 28.03.19 um 21:39 schrieb Kuehling, Felix:

Quoted 8 lines · Shaoyun
Quoted 4 lines

Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device

Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2

This patch is Reviewed-by: Felix Kuehling <[email protected]>

Please also give Christian a chance to review this one before you submit.

Looks good to me as well, feel free to also add my rb.

Christian.

Quoted 54 lines

Thanks,
  Felix

Quoted 49 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 +++++++++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  |  3 ++-
   2 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +11 -0
index 9ee8d7a..7b84036 100644
@@ -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)
   {
@@ -666,6 +667,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;
 
@@ -704,6 +706,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);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index 3d221f0..eb242a1 100644
@@ -2025,7 +2025,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);
 
Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev, · line 2032

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
-	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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx