drm/amdgpu: Add preferred_domain check when determine XGMI state
Subsystems (2)
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
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13 -0
@@ -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,8 @@ 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_va *bo_va;struct amdgpu_bo *robj;int r;
@@ -704,6 +707,16 @@ 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) { + bo_va = container_of(base, struct amdgpu_bo_va, base); +if (bo_va && +amdgpu_xgmi_same_hive (adev,amdgpu_ttm_adev (robj->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
@@ -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): 1553795695-6065-1-git-send-email-shaoyun.liu-5C7GfCeVMHo@public.gmane.org
Quoted 31 lines · Shaoyun
Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device
Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2Signed-off-by shaoyunl <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0@@ -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,8 @@ 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_va *bo_va;struct amdgpu_bo *robj;int r;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 713
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4
-0@@ -704,6 +707,16 @@ 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) { + bo_va = container_of(base, struct amdgpu_bo_va, base); +if (bo_va && +amdgpu_xgmi_same_hive (adev,amdgpu_ttm_adev (robj->tbo.bdev))) {
adev and robj->tbo.bdev are the same in each loop iteration. Shouldn't we get one of the devices from the bo_va or amdgpu_vm_bo_base?
Regards,
Felix
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +6
-0+ 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
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): 5744d324-0e7b-a19d-f4b5-a5242f664e8e-5C7GfCeVMHo@public.gmane.org
I think we only care about the context device (adev) and the real device this bo been allocated(robj->tbo.bdev). The bo_va or base don't have the device pointer directly, it have a pointer to bo which should be the same as robj here. We can move the same_hive check out of the loop .
Regards
shaoyun.liu
Quoted 63 lines · Felix
Quoted 31 lines · Shaoyun
Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device
Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2Signed-off-by shaoyunl <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)I think we only care about the context device (adev) and the real device this bo been allocated ,
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0@@ -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,8 @@ 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_va *bo_va;struct amdgpu_bo *robj;int r;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 713
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4
-0@@ -704,6 +707,16 @@ 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) { + bo_va = container_of(base, struct amdgpu_bo_va, base); +if (bo_va && +amdgpu_xgmi_same_hive (adev,amdgpu_ttm_adev (robj->tbo.bdev))) {adev and
robj->tbo.bdevare the same in each loop iteration. Shouldn't we get one of the devices from thebo_vaoramdgpu_vm_bo_base?Regards,
FelixQuoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +6
-0+ 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@@ -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
A message that is not in the archive (sent off-list or not yet received): 5187cc22-bf83-9617-d9df-c5ab1bca5735-5C7GfCeVMHo@public.gmane.org
Quoted 5 lines · Shaoyun
I think we only care about the context device (adev) and the real device this bo been allocated(robj->tbo.bdev). The
bo_vaor base don't have the device pointer directly, it have a pointer to bo which should be the same as robj here. We can move the same_hive check out of the loop .
That doesn't make sense. The "same hive" check only makes sense if one of the devices is the one where the memory is physically located (robj->tbo.bdev), and the other one is where the memory is accessed from. That only makes sense inside the loop. The amdgpu_vm_bo_base should tell you the device that's mapping and potentially accessing the memory over XGMI. You could get it like this:
mapping_adev = base->vm->root.base.bo->tbo.bdev;
Regards,
Felix
Quoted 80 lines
Regards
shaoyun.liu
Quoted 73 lines · Felix
Quoted 31 lines · Shaoyun
Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device
Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2Signed-off-by shaoyunl <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)I think we only care about the context device (adev) and the real device this bo been allocated ,
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0@@ -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,8 @@ 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_va *bo_va;struct amdgpu_bo *robj;int r;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 713
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4
-0@@ -704,6 +707,16 @@ 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) { + bo_va = container_of(base, struct amdgpu_bo_va, base); +if (bo_va && +amdgpu_xgmi_same_hive (adev,amdgpu_ttm_adev (robj->tbo.bdev))) {adev and
robj->tbo.bdevare the same in each loop iteration. Shouldn't we get one of the devices from thebo_vaoramdgpu_vm_bo_base?Regards,
FelixQuoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +6
-0+ 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
-0drivers/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
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 28.03.19 um 18:55 schrieb Liu, Shaoyun:
Quoted 31 lines
Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device
Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2Signed-off-by shaoyunl <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 13 +++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0@@ -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,8 @@ 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_va *bo_va;struct amdgpu_bo *robj;int r;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 712
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0@@ -704,6 +707,16 @@ 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) { + bo_va = container_of(base, struct amdgpu_bo_va, base); + if (bo_va &&
bo_va can never be NULL here, apart from that looks good to me.
Christian.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7
-0+ amdgpu_xgmi_same_hive(adev,amdgpu_ttm_adev(robj->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
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