<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>
<div dir="auto">Ah, of course. In this case feel free to go ahead.
<div dir="auto"> BTW: What's the size of the structure now?</div>
<div dir="auto"><br>
</div>
<div dir="auto">Christian.</div>
</div>
<div class="x_gmail_extra"><br>
<div class="x_gmail_quote">Am 27.03.2019 16:22 schrieb "Liu, Shaoyun" <Shaoyun.Liu@amd.com>:<br type="attribution">
</div>
</div>
</div>
<font size="2"><span style="font-size:11pt;">
<div class="PlainText">The  next in struct amdgpu_vm_bo_base  is not a  list_head,  I'm not
<br>
sure whether we can use list_for_each_entry here.<br>
<br>
Regards<br>
<br>
shaoyun.liu<br>
<br>
On 2019-03-27 3:41 a.m., Christian König wrote:<br>
> Am 26.03.19 um 21:35 schrieb Liu, Shaoyun:<br>
>> Avoid unnecessary XGMI hight pstate trigger when mapping none-vram <br>
>> memory for peer device<br>
>><br>
>> Change-Id: I1881deff3da19f1f4b58d5765db03a590092a5b2<br>
>> Signed-off-by: shaoyunl <shaoyun.liu@amd.com><br>
>> ---<br>
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 +++++++++++<br>
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  |  3 ++-<br>
>>   2 files changed, 13 insertions(+), 1 deletion(-)<br>
>><br>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c <br>
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
>> index a82c3b1..a0f56e4 100644<br>
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
>> @@ -666,6 +666,8 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, <br>
>> void *data,<br>
>>       struct amdgpu_device *adev = dev->dev_private;<br>
>>       struct drm_amdgpu_gem_op *args = data;<br>
>>       struct drm_gem_object *gobj;<br>
>> +    struct amdgpu_vm_bo_base *base;<br>
>> +    struct amdgpu_bo_va *bo_va;<br>
>>       struct amdgpu_bo *robj;<br>
>>       int r;<br>
>>   @@ -704,6 +706,15 @@ int amdgpu_gem_op_ioctl(struct drm_device <br>
>> *dev, void *data,<br>
>>               amdgpu_bo_unreserve(robj);<br>
>>               break;<br>
>>           }<br>
>> +        for (base = robj->vm_bo; base; base = base->next) {<br>
>> +            bo_va = container_of(base, struct amdgpu_bo_va, base);<br>
><br>
> Please use list_for_each_entry here instead of open coding it.<br>
><br>
> Christian.<br>
><br>
>> +            if (bo_va && bo_va->is_xgmi) {<br>
>> +                r = -EINVAL;<br>
>> +                amdgpu_bo_unreserve(robj);<br>
>> +                goto out;<br>
>> +            }<br>
>> +        }<br>
>> +<br>
>>           robj->preferred_domains = args->value & <br>
>> (AMDGPU_GEM_DOMAIN_VRAM |<br>
>>                               AMDGPU_GEM_DOMAIN_GTT |<br>
>>                               AMDGPU_GEM_DOMAIN_CPU);<br>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c <br>
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>> index 76eee7e..8ed23d2 100644<br>
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>> @@ -2048,7 +2048,8 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(struct <br>
>> amdgpu_device *adev,<br>
>>       INIT_LIST_HEAD(&bo_va->valids);<br>
>>       INIT_LIST_HEAD(&bo_va->invalids);<br>
>>   -    if (bo && amdgpu_xgmi_same_hive(adev, <br>
>> amdgpu_ttm_adev(bo->tbo.bdev))) {<br>
>> +    if (bo && amdgpu_xgmi_same_hive(adev, <br>
>> amdgpu_ttm_adev(bo->tbo.bdev)) &&<br>
>> +        (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM)) {<br>
>>           bo_va->is_xgmi = true;<br>
>>           mutex_lock(&adev->vm_manager.lock_pstate);<br>
>>           /* Power up XGMI if it can be potentially used */<br>
><br>
</div>
</span></font>
</body>
</html>