<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<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>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Yeah, that's could be an issue, I have changed the logic and send the review again.<br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>发件人:</b> Alex Deucher <alexdeucher@gmail.com><br>
<b>发送时间:</b> 2016年8月2日 12:56:07<br>
<b>收件人:</b> Wang, Ken<br>
<b>抄送:</b> amd-gfx list<br>
<b>主题:</b> Re: [PATCH 2/2] drm/amdgpu: use the kernel zone memory size as the max remote memory in amdgpu</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On Wed, Jul 27, 2016 at 7:21 AM, Ken Wang <Qingqing.Wang@amd.com> wrote:<br>
> Change-Id: Ibf193cc2d9e20c3aefa1ce8ff24241dfbb6768ff<br>
> Signed-off-by: Ken Wang <Qingqing.Wang@amd.com><br>
> ---<br>
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h     |  2 ++<br>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++++-----<br>
>  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c   |  7 ++++++-<br>
>  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c   |  7 ++++++-<br>
>  4 files changed, 21 insertions(+), 7 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
> index 8bef7ec..b84153f 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
> @@ -2432,6 +2432,8 @@ uint32_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,<br>
>  void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 base);<br>
>  void amdgpu_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc);<br>
>  void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size);<br>
> +u64 amdgpu_ttm_get_gtt_mem_size(struct amdgpu_device *adev);<br>
> +int amdgpu_ttm_global_init(struct amdgpu_device *adev);<br>
>  void amdgpu_program_register_sequence(struct amdgpu_device *adev,<br>
>                                              const u32 *registers,<br>
>                                              const u32 array_size);<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
> index 145732a..5200381 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
> @@ -34,6 +34,7 @@<br>
>  #include <ttm/ttm_placement.h><br>
>  #include <ttm/ttm_module.h><br>
>  #include <ttm/ttm_page_alloc.h><br>
> +#include <ttm/ttm_memory.h><br>
>  #include <drm/drmP.h><br>
>  #include <drm/amdgpu_drm.h><br>
>  #include <linux/seq_file.h><br>
> @@ -74,7 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref)<br>
>         ttm_mem_global_release(ref->object);<br>
>  }<br>
><br>
> -static int amdgpu_ttm_global_init(struct amdgpu_device *adev)<br>
> +int amdgpu_ttm_global_init(struct amdgpu_device *adev)<br>
>  {<br>
>         struct drm_global_reference *global_ref;<br>
>         struct amdgpu_ring *ring;<br>
> @@ -998,10 +999,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)<br>
>         unsigned i, j;<br>
>         int r;<br>
><br>
> -       r = amdgpu_ttm_global_init(adev);<br>
> -       if (r) {<br>
> -               return r;<br>
> -       }<br>
>         /* No others user of address space so set it to 0 */<br>
>         r = ttm_bo_device_init(&adev->mman.bdev,<br>
>                                adev->mman.bo_global_ref.ref.object,<br>
> @@ -1398,3 +1395,8 @@ static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev)<br>
><br>
>  #endif<br>
>  }<br>
> +<br>
> +u64 amdgpu_ttm_get_gtt_mem_size(struct amdgpu_device *adev)<br>
> +{<br>
> +       return ttm_get_kernel_zone_memory_size(adev->mman.mem_global_ref.object);<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c<br>
> index a3b6048..b6ae925 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c<br>
> @@ -392,7 +392,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)<br>
>          * size equal to the 1024 or vram, whichever is larger.<br>
>          */<br>
>         if (amdgpu_gart_size == -1)<br>
> -               adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size);<br>
> +               adev->mc.gtt_size = amdgpu_ttm_get_gtt_mem_size(adev);<br>
<br>
Do we want to limit this to the min(amdgpu_ttm_get_gtt_mem_size, GPU<br>
address space - vram)?  GPU address space is only 40 bits.  You could<br>
theoretically have systems with a lot of system memory.<br>
<br>
Alex<br>
<br>
<br>
>         else<br>
>                 adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;<br>
><br>
> @@ -959,6 +959,11 @@ static int gmc_v7_0_sw_init(void *handle)<br>
>                 return r;<br>
>         }<br>
><br>
> +       r = amdgpu_ttm_global_init(adev);<br>
> +       if (r) {<br>
> +               return r;<br>
> +       }<br>
> +<br>
>         r = gmc_v7_0_mc_init(adev);<br>
>         if (r)<br>
>                 return r;<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c<br>
> index 02b6872..d46d76b 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c<br>
> @@ -469,7 +469,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)<br>
>          * size equal to the 1024 or vram, whichever is larger.<br>
>          */<br>
>         if (amdgpu_gart_size == -1)<br>
> -               adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size);<br>
> +               adev->mc.gtt_size = amdgpu_ttm_get_gtt_mem_size(adev);<br>
>         else<br>
>                 adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;<br>
><br>
> @@ -956,6 +956,11 @@ static int gmc_v8_0_sw_init(void *handle)<br>
>                 return r;<br>
>         }<br>
><br>
> +       r = amdgpu_ttm_global_init(adev);<br>
> +       if (r) {<br>
> +               return r;<br>
> +       }<br>
> +<br>
>         r = gmc_v8_0_mc_init(adev);<br>
>         if (r)<br>
>                 return r;<br>
> --<br>
> 2.7.4<br>
><br>
> _______________________________________________<br>
> amd-gfx mailing list<br>
> amd-gfx@lists.freedesktop.org<br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font>
</body>
</html>