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 | 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
@@ -666,6 +666,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 +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) { + bo_va = container_of(base, struct amdgpu_bo_va, base); +if (bo_va && bo_va->is_xgmi) { + 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
@@ -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 */
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): 1553632516-23346-1-git-send-email-shaoyun.liu-5C7GfCeVMHo@public.gmane.org
Am 26.03.19 um 21:35 schrieb Liu, Shaoyun:
Quoted 23 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 | 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 +2
-0@@ -666,6 +666,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 710
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-0@@ -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) { + bo_va = container_of(base, struct amdgpu_bo_va, base);
Please use list_for_each_entry here instead of open coding it.
Christian.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7
-0+if (bo_va && bo_va->is_xgmi) { + 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 2055
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -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
[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): c42cc872-cddf-01b9-b46e-b2084f8a1bc3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
The next in struct amdgpu_vm_bo_base is not a list_head, I'm not sure whether we can use list_for_each_entry here.
Regards
shaoyun.liu
Quoted 57 lines · Christian König
Am 26.03.19 um 21:35 schrieb Liu, Shaoyun:
Quoted 24 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| 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 +2
-0@@ -666,6 +666,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;Quoted 7 lines
@@ -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) { +bo_va=container_of(base, struct amdgpu_bo_va, base);Please use
list_for_each_entryhere instead of open coding it.Christian.
Quoted 20 lines
+ if (
bo_va&&bo_va->is_xgmi) {
+ 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@@ -2048,7 +2048,8 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(structamdgpu_device *adev, INIT_LIST_HEAD(&bo_va->valids); INIT_LIST_HEAD(&bo_va->invalids);
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0- 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): 5d6e562d-012b-f22b-7ec9-2fdf33a9319d-5C7GfCeVMHo@public.gmane.org
Ah, of course. In this case feel free to go ahead.
BTW: What's the size of the structure now?
Christian.
Am 27.03.2019 16:22 schrieb "Liu, Shaoyun" <[email protected]>:
The next in struct amdgpu_vm_bo_base is not a list_head, I'm not sure whether we can use list_for_each_entry here.
Regards
shaoyun.liu
Quoted 57 lines · Christian König
Am 26.03.19 um 21:35 schrieb Liu, Shaoyun:
Quoted 29 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 | 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 +2
-0@@ -666,6 +666,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 +706,15 @@ int amdgpu_gem_op_ioctl(struct
drm_device
*dev, void *data,amdgpu_bo_unreserve(robj); break; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 710
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-0+for (base = robj->vm_bo; base; base = base->next) { + bo_va = container_of(base, struct amdgpu_bo_va, base);Please use
list_for_each_entryhere instead of open coding it.Christian.
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7
-0+if (bo_va && bo_va->is_xgmi) { + 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@@ -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);
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0- 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): 3e28a7df-4165-4bde-8a2e-926453ceb1d1-2ueSQiBKiTY7tOexoI0I+QC/[email protected]
you mean struct amdgpu_vm_bo_base ? It only has few pointer and a list_head , should be pretty small .
struct amdgpu_vm_bo_base {
/* constant after initialization */
struct amdgpu_vm *vm;
struct amdgpu_bo *bo;
/* protected by bo being reserved */
struct amdgpu_vm_bo_base *next;
/* protected by spinlock */
struct list_head vm_status;
/* protected by the BO being reserved */
bool moved;
};shaoyun.liu
On 2019-03-27 11:30 a.m., Koenig, Christian wrote:
Ah, of course. In this case feel free to go ahead.
BTW: What's the size of the structure now?
Christian.
Am 27.03.2019 16:22 schrieb "Liu, Shaoyun" <[email protected]><mailto:[email protected]>:
The next in struct amdgpu_vm_bo_base is not a list_head, I'm not
sure whether we can use list_for_each_entry here.
Regards
shaoyun.liu
Quoted 57 lines · Christian König
Am 26.03.19 um 21:35 schrieb Liu, Shaoyun:
Quoted 29 lines
Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device
Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2Signed-off-by shaoyunl <[email protected]><mailto:[email protected]>--- 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 +2
-0@@ -666,6 +666,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 +706,15 @@ int amdgpu_gem_op_ioctl(struct
drm_device
*dev, void *data,amdgpu_bo_unreserve(robj); break; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-0+for (base = robj->vm_bo; base; base = base->next) { + bo_va = container_of(base, struct amdgpu_bo_va, base);Please use
list_for_each_entryhere instead of open coding it.Christian.
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7
-0+if (bo_va && bo_va->is_xgmi) { + 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@@ -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);
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0- 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): fd7f4b68-26c2-d0ea-b254-fbc61a0d3956-5C7GfCeVMHo@public.gmane.org
Yeah, that one is intentionally very small because it is used so often.
When it grows over the next power of two by this change we need to figure out a different approach.
Christian.
Am 27.03.2019 16:34 schrieb "Liu, Shaoyun" <[email protected]>:
you mean struct amdgpu_vm_bo_base ? It only has few pointer and a list_head , should be pretty small .
struct amdgpu_vm_bo_base {
/* constant after initialization */
struct amdgpu_vm *vm;
struct amdgpu_bo *bo;
/* protected by bo being reserved */
struct amdgpu_vm_bo_base *next;
/* protected by spinlock */
struct list_head vm_status;
/* protected by the BO being reserved */
bool moved;
};shaoyun.liu
On 2019-03-27 11:30 a.m., Koenig, Christian wrote:
Ah, of course. In this case feel free to go ahead.
BTW: What's the size of the structure now?
Christian.
Am 27.03.2019 16:22 schrieb "Liu, Shaoyun" <[email protected]><mailto:[email protected]>:
The next in struct amdgpu_vm_bo_base is not a list_head, I'm not
sure whether we can use list_for_each_entry here.
Regards
shaoyun.liu
Quoted 57 lines · Christian König
Am 26.03.19 um 21:35 schrieb Liu, Shaoyun:
Quoted 29 lines
Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device
Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2Signed-off-by shaoyunl <[email protected]><mailto:[email protected]>--- 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 +2
-0@@ -666,6 +666,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 +706,15 @@ int amdgpu_gem_op_ioctl(struct
drm_device
*dev, void *data,amdgpu_bo_unreserve(robj); break; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-0+for (base = robj->vm_bo; base; base = base->next) { + bo_va = container_of(base, struct amdgpu_bo_va, base);Please use
list_for_each_entryhere instead of open coding it.Christian.
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7
-0+if (bo_va && bo_va->is_xgmi) { + 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@@ -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);
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0- 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): 68f7ccfa-646e-492f-bdd7-b24f2e2029da-2ueSQiBKiTY7tOexoI0I+QC/[email protected]
bool is_xgmi is added in bo_va structure , this change won't increase the size of struct amdgpu_vm_bo_base. Anyway , can I said it's reviewed by you now?
shaoyun.liu
On 2019-03-27 11:39 a.m., Koenig, Christian wrote:
Yeah, that one is intentionally very small because it is used so often.
When it grows over the next power of two by this change we need to figure out a different approach.
Christian.
Am 27.03.2019 16:34 schrieb "Liu, Shaoyun" <[email protected]><mailto:[email protected]>:
you mean struct amdgpu_vm_bo_base ? It only has few pointer and a list_head , should be pretty small .
struct amdgpu_vm_bo_base {
/* constant after initialization */
struct amdgpu_vm *vm;
struct amdgpu_bo *bo;
/* protected by bo being reserved */
struct amdgpu_vm_bo_base *next;
/* protected by spinlock */
struct list_head vm_status;
/* protected by the BO being reserved */
bool moved;
};shaoyun.liu
On 2019-03-27 11:30 a.m., Koenig, Christian wrote:
Ah, of course. In this case feel free to go ahead.
BTW: What's the size of the structure now?
Christian.
Am 27.03.2019 16:22 schrieb "Liu, Shaoyun" <[email protected]><mailto:[email protected]>:
The next in struct amdgpu_vm_bo_base is not a list_head, I'm not
sure whether we can use list_for_each_entry here.
Regards
shaoyun.liu
Quoted 57 lines · Christian König
Am 26.03.19 um 21:35 schrieb Liu, Shaoyun:
Quoted 29 lines
Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device
Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2Signed-off-by shaoyunl <[email protected]><mailto:[email protected]>--- 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 +2
-0@@ -666,6 +666,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 +706,15 @@ int amdgpu_gem_op_ioctl(struct
drm_device
*dev, void *data,amdgpu_bo_unreserve(robj); break; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-0+for (base = robj->vm_bo; base; base = base->next) { + bo_va = container_of(base, struct amdgpu_bo_va, base);Please use
list_for_each_entryhere instead of open coding it.Christian.
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7
-0+if (bo_va && bo_va->is_xgmi) { + 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@@ -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);
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0- 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]<mailto:[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): 7a3199ec-c851-6b50-7e1f-b467e5e78d13-5C7GfCeVMHo@public.gmane.org
Yeah, feel free to add my RB.
Christian.
Am 27.03.2019 16:43 schrieb "Liu, Shaoyun" <[email protected]>:
bool is_xgmi is added in bo_va structure , this change won't increase the size of struct amdgpu_vm_bo_base. Anyway , can I said it's reviewed by you now?
shaoyun.liu
On 2019-03-27 11:39 a.m., Koenig, Christian wrote:
Yeah, that one is intentionally very small because it is used so often.
When it grows over the next power of two by this change we need to figure out a different approach.
Christian.
Am 27.03.2019 16:34 schrieb "Liu, Shaoyun" <[email protected]><mailto:[email protected]>:
you mean struct amdgpu_vm_bo_base ? It only has few pointer and a list_head , should be pretty small .
struct amdgpu_vm_bo_base {
/* constant after initialization */
struct amdgpu_vm *vm;
struct amdgpu_bo *bo;
/* protected by bo being reserved */
struct amdgpu_vm_bo_base *next;
/* protected by spinlock */
struct list_head vm_status;
/* protected by the BO being reserved */
bool moved;
};shaoyun.liu
On 2019-03-27 11:30 a.m., Koenig, Christian wrote:
Ah, of course. In this case feel free to go ahead.
BTW: What's the size of the structure now?
Christian.
Am 27.03.2019 16:22 schrieb "Liu, Shaoyun" <[email protected]><mailto:[email protected]>:
The next in struct amdgpu_vm_bo_base is not a list_head, I'm not
sure whether we can use list_for_each_entry here.
Regards
shaoyun.liu
Quoted 57 lines · Christian König
Am 26.03.19 um 21:35 schrieb Liu, Shaoyun:
Quoted 29 lines
Avoid unnecessary XGMI hight pstate trigger when mapping none-vram memory for peer device
Change-Id I1881deff3da19f1f4b58d5765db03a590092a5b2Signed-off-by shaoyunl <[email protected]><mailto:[email protected]>--- 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 +2
-0@@ -666,6 +666,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 +706,15 @@ int amdgpu_gem_op_ioctl(struct
drm_device
*dev, void *data,amdgpu_bo_unreserve(robj); break; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-0+for (base = robj->vm_bo; base; base = base->next) { + bo_va = container_of(base, struct amdgpu_bo_va, base);Please use
list_for_each_entryhere instead of open coding it.Christian.
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +7
-0+if (bo_va && bo_va->is_xgmi) { + 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@@ -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);
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0- 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]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 23 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 | 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 +2
-0@@ -666,6 +666,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 711
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0@@ -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) { + bo_va = container_of(base, struct amdgpu_bo_va, base); +if (bo_va && bo_va->is_xgmi) {
The point here is to prevent transitions where a mapping moves from is_xgmi => !is_xgmi or from !is_xgmi => is_xgmi, because that would potentially require a XGMI pstate change.
This check catches the case of is_xgmi => !is_xgmi, but not the other way around. I think you should drop the is_xgmi condition here. Any BO that's shared between multiple GPUs should return -EINVAL here because moving it could result in an XGMI pstate change. It doesn't matter whether it's currently using XGMI or not.
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 2055
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -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
[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): 5e7addf1-61f7-a0f9-a709-5039ba1de840-5C7GfCeVMHo@public.gmane.org
Even the preferred_domains been changed for bo that original is none xgmi here , it doesn't means driver must change the XGMI status for the bo_va. From current design, only the bo later been added to the compute VM (through bo_add) will be enable the XGMI mapping. Without that call , the XGMI mapping will be disabled. Remove the XGMI checking may affect other sharing mechanism.
Shaoyun.liu
Quoted 60 lines · Felix
Quoted 23 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 | 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 +2
-0@@ -666,6 +666,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 711
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0@@ -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) { + bo_va = container_of(base, struct amdgpu_bo_va, base); +if (bo_va && bo_va->is_xgmi) {The point here is to prevent transitions where a mapping moves from
is_xgmi=> !is_xgmi or from !is_xgmi =>is_xgmi, because that would potentially require a XGMI pstate change.This check catches the case of
is_xgmi=> !is_xgmi, but not the other way around. I think you should drop theis_xgmicondition here. Any BO that's shared between multiple GPUs should return-EINVALhere because moving it could result in an XGMI pstate change. It doesn't matter whether it's currently using XGMI or not.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@@ -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);
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev, · line 2055
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