<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">The problem is that userspace could add
it first and then change the domain.<br>
<br>
Pretty unlikely thought,<br>
Christian.<br>
<br>
Am 26.03.19 um 14:15 schrieb Liu, Shaoyun:<br>
</div>
<blockquote type="cite"
cite="mid:DM6PR12MB3241D607634C7D7A58742D3BF45F0@DM6PR12MB3241.namprd12.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
I think in a real usage ( tensorflow ex), it's rarely only the
system memory (no vram) will be mapped for peer access.
<br>
Anyway, how about add preferred_domain check for xgmi ? I think
even user use ioctl to change the preferred_domain, bo_add should
still be called before the real mapping.
<br>
<br>
Regards<br>
Shaoyun.liu
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
face="Calibri, sans-serif" color="#000000"><b>From:</b>
amd-gfx <a class="moz-txt-link-rfc2396E" href="mailto:amd-gfx-bounces@lists.freedesktop.org"><amd-gfx-bounces@lists.freedesktop.org></a> on
behalf of Kuehling, Felix <a class="moz-txt-link-rfc2396E" href="mailto:Felix.Kuehling@amd.com"><Felix.Kuehling@amd.com></a><br>
<b>Sent:</b> March 25, 2019 6:28:32 PM<br>
<b>To:</b> Liu, Shaoyun; <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: XGMI pstate switch
initial support</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span
style="font-size:11pt;">
<div class="PlainText">I don't see any check for the memory
type. As far as I can tell you'll
<br>
power up XGMI even for system memory mappings. See inline.<br>
<br>
On 2019-03-22 3:28 p.m., Liu, Shaoyun wrote:<br>
> Driver vote low to high pstate switch whenever there
is an outstanding<br>
> XGMI mapping request. Driver vote high to low pstate
when all the<br>
> outstanding XGMI mapping is terminated.<br>
><br>
> Change-Id: I197501f853c47f844055c0e28c0ac00a1ff06607<br>
> Signed-off-by: shaoyunl <a class="moz-txt-link-rfc2396E" href="mailto:shaoyun.liu@amd.com"><shaoyun.liu@amd.com></a><br>
> ---<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4
++++<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 ++<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 21
+++++++++++++++++++++<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4
++++<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 16
+++++++++++++++-<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 10
++++++++++<br>
> 6 files changed, 56 insertions(+), 1 deletion(-)<br>
><br>
> diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> index ec9562d..c4c61e9 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> @@ -2018,6 +2018,10 @@ static void
amdgpu_device_ip_late_init_func_handler(struct work_struct
*work)<br>
> r = amdgpu_device_enable_mgpu_fan_boost();<br>
> if (r)<br>
> DRM_ERROR("enable mgpu fan boost
failed (%d).\n", r);<br>
> +<br>
> + /*set to low pstate by default */<br>
> + amdgpu_xgmi_set_pstate(adev, 0);<br>
> +<br>
> }<br>
> <br>
> static void
amdgpu_device_delay_enable_gfx_off(struct work_struct
*work)<br>
> diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
> index 220a6a7..c430e82 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
> @@ -72,6 +72,8 @@ struct amdgpu_bo_va {<br>
> <br>
> /* If the mappings are cleared or filled */<br>
> bool cleared;<br>
> +<br>
> + bool is_xgmi;<br>
> };<br>
> <br>
> struct amdgpu_bo {<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
> index 729da1c..a7247d5 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
> @@ -34,6 +34,7 @@<br>
> #include "amdgpu_trace.h"<br>
> #include "amdgpu_amdkfd.h"<br>
> #include "amdgpu_gmc.h"<br>
> +#include "amdgpu_xgmi.h"<br>
> <br>
> /**<br>
> * DOC: GPUVM<br>
> @@ -2072,6 +2073,15 @@ struct amdgpu_bo_va
*amdgpu_vm_bo_add(struct amdgpu_device *adev,<br>
> INIT_LIST_HEAD(&bo_va->valids);<br>
> INIT_LIST_HEAD(&bo_va->invalids);<br>
> <br>
> + if (bo && amdgpu_xgmi_same_hive(adev,
amdgpu_ttm_adev(bo->tbo.bdev))) {<br>
> + bo_va->is_xgmi = true;<br>
<br>
You're setting this to true even for system memory BOs
that don't <br>
involve XGMI mappings. That means you'll power up XGMI
unnecessarily in <br>
many cases because KFD processes always have system memory
mappings that <br>
are mapped to all GPUs (e.g. the signal page).<br>
<br>
Regards,<br>
Felix<br>
<br>
<br>
> +
mutex_lock(&adev->vm_manager.lock_pstate);<br>
> + /* Power up XGMI if it can be
potentially used */<br>
> + if
(++adev->vm_manager.xgmi_map_counter == 1)<br>
> + amdgpu_xgmi_set_pstate(adev,
1);<br>
> +
mutex_unlock(&adev->vm_manager.lock_pstate);<br>
> + }<br>
> +<br>
> return bo_va;<br>
> }<br>
> <br>
> @@ -2490,6 +2500,14 @@ void amdgpu_vm_bo_rmv(struct
amdgpu_device *adev,<br>
> }<br>
> <br>
> dma_fence_put(bo_va->last_pt_update);<br>
> +<br>
> + if (bo && bo_va->is_xgmi) {<br>
> +
mutex_lock(&adev->vm_manager.lock_pstate);<br>
> + if
(--adev->vm_manager.xgmi_map_counter == 0)<br>
> + amdgpu_xgmi_set_pstate(adev,
0);<br>
> +
mutex_unlock(&adev->vm_manager.lock_pstate);<br>
> + }<br>
> +<br>
> kfree(bo_va);<br>
> }<br>
> <br>
> @@ -2997,6 +3015,9 @@ void
amdgpu_vm_manager_init(struct amdgpu_device *adev)<br>
> <br>
> idr_init(&adev->vm_manager.pasid_idr);<br>
>
spin_lock_init(&adev->vm_manager.pasid_lock);<br>
> +<br>
> + adev->vm_manager.xgmi_map_counter = 0;<br>
> +
mutex_init(&adev->vm_manager.lock_pstate);<br>
> }<br>
> <br>
> /**<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
> index 520122b..f586b38 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
> @@ -324,6 +324,10 @@ struct amdgpu_vm_manager {<br>
> */<br>
> struct idr
pasid_idr;<br>
> spinlock_t
pasid_lock;<br>
> +<br>
> + /* counter of mapped memory through xgmi */<br>
> + uint32_t
xgmi_map_counter;<br>
> + struct mutex
lock_pstate;<br>
> };<br>
> <br>
> #define amdgpu_vm_copy_pte(adev, ib, pe, src,
count)
((adev)->vm_manager.vm_pte_funcs->copy_pte((ib),
(pe), (src), (count)))<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
> index fcc4b05..3368347 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
> @@ -200,12 +200,26 @@ struct amdgpu_hive_info
*amdgpu_get_xgmi_hive(struct amdgpu_device *adev, int lo<br>
> <br>
> if (lock)<br>
> mutex_lock(&tmp->hive_lock);<br>
> -<br>
> + tmp->pstate = -1;<br>
> mutex_unlock(&xgmi_mutex);<br>
> <br>
> return tmp;<br>
> }<br>
> <br>
> +int amdgpu_xgmi_set_pstate(struct amdgpu_device
*adev, int pstate)<br>
> +{<br>
> + int ret = 0;<br>
> + struct amdgpu_hive_info *hive =
amdgpu_get_xgmi_hive(adev, 0);<br>
> +<br>
> + if (!hive)<br>
> + return 0;<br>
> +<br>
> + if (hive->pstate == pstate)<br>
> + return 0;<br>
> + /* Todo : sent the message to SMU for pstate
change */<br>
> + return ret;<br>
> +}<br>
> +<br>
> int amdgpu_xgmi_update_topology(struct
amdgpu_hive_info *hive, struct amdgpu_device *adev)<br>
> {<br>
> int ret = -EINVAL;<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h<br>
> index 24a3b03..3e9c91e 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h<br>
> @@ -33,11 +33,21 @@ struct amdgpu_hive_info {<br>
> struct kobject *kobj;<br>
> struct device_attribute dev_attr;<br>
> struct amdgpu_device *adev;<br>
> + int pstate; /*0 -- low , 1 -- high , -1
unknown*/<br>
> };<br>
> <br>
> struct amdgpu_hive_info
*amdgpu_get_xgmi_hive(struct amdgpu_device *adev, int
lock);<br>
> int amdgpu_xgmi_update_topology(struct
amdgpu_hive_info *hive, struct amdgpu_device *adev);<br>
> int amdgpu_xgmi_add_device(struct amdgpu_device
*adev);<br>
> void amdgpu_xgmi_remove_device(struct amdgpu_device
*adev);<br>
> +int amdgpu_xgmi_set_pstate(struct amdgpu_device
*adev, int pstate);<br>
> +<br>
> +static inline bool amdgpu_xgmi_same_hive(struct
amdgpu_device *adev,<br>
> + struct amdgpu_device *bo_adev)<br>
> +{<br>
> + return (adev != bo_adev &&<br>
> + adev->gmc.xgmi.hive_id &&<br>
> + adev->gmc.xgmi.hive_id ==
bo_adev->gmc.xgmi.hive_id);<br>
> +}<br>
> <br>
> #endif<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<a
href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx"
moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></div>
</span></font></div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
amd-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></pre>
</blockquote>
<br>
</body>
</html>