<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Guchun, <br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks very much for your suggestion.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I will refine it and send it out later.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Rico<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Chen, Guchun <Guchun.Chen@amd.com><br>
<b>Sent:</b> Tuesday, December 17, 2019 22:11<br>
<b>To:</b> Yin, Tianci (Rico) <Tianci.Yin@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Long, Gang <Gang.Long@amd.com>; Yin, Tianci (Rico) <Tianci.Yin@amd.com>; Xu, Feifei <Feifei.Xu@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; Tuikov, Luben <Luben.Tuikov@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Zhang, Hawking
 <Hawking.Zhang@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Yuan, Xiaojie <Xiaojie.Yuan@amd.com><br>
<b>Subject:</b> RE: [PATCH 2/2] drm/amdgpu: remove memory training p2c buffer reservation</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">[AMD Official Use Only - Internal Distribution Only]<br>
<br>
<br>
<br>
<br>
-----Original Message-----<br>
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Tianci Yin<br>
Sent: Tuesday, December 17, 2019 7:23 PM<br>
To: amd-gfx@lists.freedesktop.org<br>
Cc: Long, Gang <Gang.Long@amd.com>; Yin, Tianci (Rico) <Tianci.Yin@amd.com>; Xu, Feifei <Feifei.Xu@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; Tuikov, Luben <Luben.Tuikov@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>;
 Koenig, Christian <Christian.Koenig@amd.com>; Yuan, Xiaojie <Xiaojie.Yuan@amd.com><br>
Subject: [PATCH 2/2] drm/amdgpu: remove memory training p2c buffer reservation<br>
<br>
From: "Tianci.Yin" <tianci.yin@amd.com><br>
<br>
IP discovery TMR(occupied the top VRAM with size DISCOVERY_TMR_SIZE) has been reserved, and the p2c buffer is in the range of this TMR, so the p2c buffer reservation is unnecessary.<br>
<br>
Change-Id: Ib1f2f2b4a1f3869c03ffe22e2836cdbee17ba99f<br>
Signed-off-by: Tianci.Yin <tianci.yin@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 -  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 --------------<br>
 2 files changed, 15 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
index 5f8fd3e3535b..3265487b859f 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
@@ -202,7 +202,6 @@ struct psp_memory_training_context {<br>
 <br>
         /*vram offset of the p2c training data*/<br>
         u64 p2c_train_data_offset;<br>
-       struct amdgpu_bo *p2c_bo;<br>
 <br>
         /*vram offset of the c2p training data*/<br>
         u64 c2p_train_data_offset;<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
index ce5cb854bdb9..6f0ad1d1d4d7 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
@@ -1681,9 +1681,6 @@ static int amdgpu_ttm_training_reserve_vram_fini(struct amdgpu_device *adev)<br>
         amdgpu_bo_free_kernel(&ctx->c2p_bo, NULL, NULL);<br>
         ctx->c2p_bo = NULL;<br>
 <br>
-       amdgpu_bo_free_kernel(&ctx->p2c_bo, NULL, NULL);<br>
-       ctx->p2c_bo = NULL;<br>
-<br>
         return 0;<br>
 }<br>
 <br>
@@ -1718,17 +1715,6 @@ static int amdgpu_ttm_training_reserve_vram_init(struct amdgpu_device *adev)<br>
                   ctx->p2c_train_data_offset,<br>
                   ctx->c2p_train_data_offset);<br>
 <br>
-       ret = amdgpu_bo_create_kernel_at(adev,<br>
-                                        ctx->p2c_train_data_offset,<br>
-                                        ctx->train_data_size,<br>
-                                        AMDGPU_GEM_DOMAIN_VRAM,<br>
-                                        &ctx->p2c_bo,<br>
-                                        NULL);<br>
-       if (ret) {<br>
-               DRM_ERROR("alloc p2c_bo failed(%d)!\n", ret);<br>
-               goto Err_out;<br>
-       }<br>
-<br>
         ret = amdgpu_bo_create_kernel_at(adev,<br>
                                          ctx->c2p_train_data_offset,<br>
                                          ctx->train_data_size,<br>
[Guchun] If we have to remove such buffer reservation, from coding style's perspective, I suggest removing error handler code by "goto" too in amdgpu_ttm_training_reserve_vram_init.<br>
After removing p2c buffer reservation from this function, there is only one buffer reservation case for c2p. So direct error handle and return should be better.<br>
<br>
--<br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cguchun.chen%40amd.com%7C888c561716c342aa9ecc08d782e397d0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637121786693411170&amp;sdata=pH1rob4R5ljvEGo8PSjn1te7ctWLG1Wctv30lNCLyx4%3D&amp;reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cguchun.chen%40amd.com%7C888c561716c342aa9ecc08d782e397d0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637121786693411170&amp;sdata=pH1rob4R5ljvEGo8PSjn1te7ctWLG1Wctv30lNCLyx4%3D&amp;reserved=0</a><br>
</div>
</span></font></div>
</body>
</html>