<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">
<p style="font-family:Arial;font-size:10pt;color:#0078D7;margin:15pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you very much for your review!<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> Tuikov, Luben <Luben.Tuikov@amd.com><br>
<b>Sent:</b> Saturday, December 21, 2019 5:52<br>
<b>To:</b> Alex Deucher <alexdeucher@gmail.com>; Yin, Tianci (Rico) <Tianci.Yin@amd.com><br>
<b>Cc:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Long, Gang <Gang.Long@amd.com>; Xu, Feifei <Feifei.Xu@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@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 1/2] drm/amdgpu: update the method to get fb_loc of memory training(V4)</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 2019-12-20 10:27 a.m., Alex Deucher wrote:<br>
> On Thu, Dec 19, 2019 at 9:00 PM Yin, Tianci (Rico) <Tianci.Yin@amd.com> wrote:<br>
>><br>
>> [AMD Official Use Only - Internal Distribution Only]<br>
>><br>
>><br>
>> Hi Luben,<br>
>><br>
>> May I have your Review-by?<br>
>><br>
<br>
If you'd like--it's completely up to you. If you choose to, like Alex's below.<br>
<br>
Regards,<br>
Luben<br>
<br>
> <br>
> Series is:<br>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
> <br>
>> Thanks a lot!<br>
>> Rico<br>
>> ________________________________<br>
>> From: Tuikov, Luben <Luben.Tuikov@amd.com><br>
>> Sent: Friday, December 20, 2019 3:47<br>
>> To: Yin, Tianci (Rico) <Tianci.Yin@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
>> Cc: Koenig, Christian <Christian.Koenig@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Xu, Feifei <Feifei.Xu@amd.com>; Yuan, Xiaojie <Xiaojie.Yuan@amd.com>; Long, Gang <Gang.Long@amd.com>; Wang, Kevin(Yang)
<Kevin1.Wang@amd.com><br>
>> Subject: Re: [PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training(V4)<br>
>><br>
>> Yep! That's perfect--good job!<br>
>><br>
>> Regards,<br>
>> Luben<br>
>><br>
>> On 2019-12-19 04:16, Tianci Yin wrote:<br>
>>> From: "Tianci.Yin" <tianci.yin@amd.com><br>
>>><br>
>>> The method of getting fb_loc changed from parsing VBIOS to<br>
>>> taking certain offset from top of VRAM<br>
>>><br>
>>> Change-Id: I053b42fdb1d822722fa7980b2cd9f86b3fdce539<br>
>>> Signed-off-by: Tianci.Yin <tianci.yin@amd.com><br>
>>> ---<br>
>>> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +-<br>
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 2 +-<br>
>>> .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 38 ++-----------------<br>
>>> .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h | 2 +-<br>
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 ++++-<br>
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 7 ++++<br>
>>> drivers/gpu/drm/amd/include/atomfirmware.h | 14 -------<br>
>>> 7 files changed, 23 insertions(+), 53 deletions(-)<br>
>>><br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
>>> index a78a363b1d71..fa2cf8e7bc07 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
>>> @@ -642,9 +642,8 @@ struct amdgpu_fw_vram_usage {<br>
>>> struct amdgpu_bo *reserved_bo;<br>
>>> void *va;<br>
>>><br>
>>> - /* Offset on the top of VRAM, used as c2p write buffer.<br>
>>> + /* GDDR6 training support flag.<br>
>>> */<br>
>>> - u64 mem_train_fb_loc;<br>
>>> bool mem_train_support;<br>
>>> };<br>
>>><br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c<br>
>>> index 9ba80d828876..fdd52d86a4d7 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c<br>
>>> @@ -2022,7 +2022,7 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)<br>
>>> if (adev->is_atom_fw) {<br>
>>> amdgpu_atomfirmware_scratch_regs_init(adev);<br>
>>> amdgpu_atomfirmware_allocate_fb_scratch(adev);<br>
>>> - ret = amdgpu_atomfirmware_get_mem_train_fb_loc(adev);<br>
>>> + ret = amdgpu_atomfirmware_get_mem_train_info(adev);<br>
>>> if (ret) {<br>
>>> DRM_ERROR("Failed to get mem train fb location.\n");<br>
>>> return ret;<br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c<br>
>>> index ff4eb96bdfb5..58f9d8c3a17a 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c<br>
>>> @@ -525,16 +525,12 @@ static int gddr6_mem_train_support(struct amdgpu_device *adev)<br>
>>> return ret;<br>
>>> }<br>
>>><br>
>>> -int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev)<br>
>>> +int amdgpu_atomfirmware_get_mem_train_info(struct amdgpu_device *adev)<br>
>>> {<br>
>>> struct atom_context *ctx = adev->mode_info.atom_context;<br>
>>> - unsigned char *bios = ctx->bios;<br>
>>> - struct vram_reserve_block *reserved_block;<br>
>>> - int index, block_number;<br>
>>> + int index;<br>
>>> uint8_t frev, crev;<br>
>>> uint16_t data_offset, size;<br>
>>> - uint32_t start_address_in_kb;<br>
>>> - uint64_t offset;<br>
>>> int ret;<br>
>>><br>
>>> adev->fw_vram_usage.mem_train_support = false;<br>
>>> @@ -569,32 +565,6 @@ int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev)<br>
>>> return -EINVAL;<br>
>>> }<br>
>>><br>
>>> - reserved_block = (struct vram_reserve_block *)<br>
>>> - (bios + data_offset + sizeof(struct atom_common_table_header));<br>
>>> - block_number = ((unsigned int)size - sizeof(struct atom_common_table_header))<br>
>>> - / sizeof(struct vram_reserve_block);<br>
>>> - reserved_block += (block_number > 0) ? block_number-1 : 0;<br>
>>> - DRM_DEBUG("block_number:0x%04x, last block: 0x%08xkb sz, %dkb fw, %dkb drv.\n",<br>
>>> - block_number,<br>
>>> - le32_to_cpu(reserved_block->start_address_in_kb),<br>
>>> - le16_to_cpu(reserved_block->used_by_firmware_in_kb),<br>
>>> - le16_to_cpu(reserved_block->used_by_driver_in_kb));<br>
>>> - if (reserved_block->used_by_firmware_in_kb > 0) {<br>
>>> - start_address_in_kb = le32_to_cpu(reserved_block->start_address_in_kb);<br>
>>> - offset = (uint64_t)start_address_in_kb * ONE_KiB;<br>
>>> - if ((offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {<br>
>>> - offset -= ONE_MiB;<br>
>>> - }<br>
>>> -<br>
>>> - offset &= ~(ONE_MiB - 1);<br>
>>> - adev->fw_vram_usage.mem_train_fb_loc = offset;<br>
>>> - adev->fw_vram_usage.mem_train_support = true;<br>
>>> - DRM_DEBUG("mem_train_fb_loc:0x%09llx.\n", offset);<br>
>>> - ret = 0;<br>
>>> - } else {<br>
>>> - DRM_ERROR("used_by_firmware_in_kb is 0!\n");<br>
>>> - ret = -EINVAL;<br>
>>> - }<br>
>>> -<br>
>>> - return ret;<br>
>>> + adev->fw_vram_usage.mem_train_support = true;<br>
>>> + return 0;<br>
>>> }<br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h<br>
>>> index f871af5ea6f3..434fe2fa0089 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h<br>
>>> @@ -31,7 +31,7 @@ void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev);<br>
>>> int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev);<br>
>>> int amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,<br>
>>> int *vram_width, int *vram_type, int *vram_vendor);<br>
>>> -int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev);<br>
>>> +int amdgpu_atomfirmware_get_mem_train_info(struct amdgpu_device *adev);<br>
>>> int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev);<br>
>>> int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device *adev);<br>
>>> bool amdgpu_atomfirmware_mem_ecc_supported(struct amdgpu_device *adev);<br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>> index 2ff63d0414c9..1515413fd356 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c<br>
>>> @@ -1687,6 +1687,14 @@ static int amdgpu_ttm_training_reserve_vram_fini(struct amdgpu_device *adev)<br>
>>> return 0;<br>
>>> }<br>
>>><br>
>>> +static u64 amdgpu_ttm_training_get_c2p_offset(u64 vram_size)<br>
>>> +{<br>
>>> + if ((vram_size & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) )<br>
>>> + vram_size -= ONE_MiB;<br>
>>> +<br>
>>> + return ALIGN(vram_size, ONE_MiB);<br>
>>> +}<br>
>>> +<br>
>>> /**<br>
>>> * amdgpu_ttm_training_reserve_vram_init - create bo vram reservation from memory training<br>
>>> *<br>
>>> @@ -1705,7 +1713,7 @@ static int amdgpu_ttm_training_reserve_vram_init(struct amdgpu_device *adev)<br>
>>> return 0;<br>
>>> }<br>
>>><br>
>>> - ctx->c2p_train_data_offset = adev->fw_vram_usage.mem_train_fb_loc;<br>
>>> + ctx->c2p_train_data_offset = amdgpu_ttm_training_get_c2p_offset(adev->gmc.mc_vram_size);<br>
>>> ctx->p2c_train_data_offset = (adev->gmc.mc_vram_size - GDDR6_MEM_TRAINING_OFFSET);<br>
>>> ctx->train_data_size = GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES;<br>
>>><br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h<br>
>>> index f1ebd424510c..19eb3e8456c7 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h<br>
>>> @@ -66,6 +66,13 @@ struct amdgpu_copy_mem {<br>
>>> unsigned long offset;<br>
>>> };<br>
>>><br>
>>> +/* Definitions for constance */<br>
>>> +enum amdgpu_internal_constants<br>
>>> +{<br>
>>> + ONE_KiB = 0x400,<br>
>>> + ONE_MiB = 0x100000,<br>
>>> +};<br>
>>> +<br>
>>> extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;<br>
>>> extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;<br>
>>><br>
>>> diff --git a/drivers/gpu/drm/amd/include/atomfirmware.h b/drivers/gpu/drm/amd/include/atomfirmware.h<br>
>>> index dd7cbc00a0aa..70146518174c 100644<br>
>>> --- a/drivers/gpu/drm/amd/include/atomfirmware.h<br>
>>> +++ b/drivers/gpu/drm/amd/include/atomfirmware.h<br>
>>> @@ -672,20 +672,6 @@ struct vram_usagebyfirmware_v2_1<br>
>>> uint16_t used_by_driver_in_kb;<br>
>>> };<br>
>>><br>
>>> -/* This is part of vram_usagebyfirmware_v2_1 */<br>
>>> -struct vram_reserve_block<br>
>>> -{<br>
>>> - uint32_t start_address_in_kb;<br>
>>> - uint16_t used_by_firmware_in_kb;<br>
>>> - uint16_t used_by_driver_in_kb;<br>
>>> -};<br>
>>> -<br>
>>> -/* Definitions for constance */<br>
>>> -enum atomfirmware_internal_constants<br>
>>> -{<br>
>>> - ONE_KiB = 0x400,<br>
>>> - ONE_MiB = 0x100000,<br>
>>> -};<br>
>>><br>
>>> /*<br>
>>> ***************************************************************************<br>
>>><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&data=02%7C01%7CLuben.Tuikov%40amd.com%7C3297c2cd4a9347a202ff08d7856137ad%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637124524929052366&sdata=0z7AeiekGUW1PsvttFCi%2FcxV1tmLlnRZU%2FkvTRUPm70%3D&reserved=0">
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7CLuben.Tuikov%40amd.com%7C3297c2cd4a9347a202ff08d7856137ad%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637124524929052366&sdata=0z7AeiekGUW1PsvttFCi%2FcxV1tmLlnRZU%2FkvTRUPm70%3D&reserved=0</a><br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>