All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Wang, Kevin(Yang)" <Kevin1.Wang@amd.com>
To: "Yin, Tianci (Rico)" <Tianci.Yin@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "Long, Gang" <Gang.Long@amd.com>,
	"Xu, Feifei" <Feifei.Xu@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>
Subject: Re: [PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training
Date: Wed, 18 Dec 2019 05:32:37 +0000	[thread overview]
Message-ID: <MN2PR12MB3296E3ACC90169776F9E090EA2530@MN2PR12MB3296.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20191218022126.25205-1-tianci.yin@amd.com>


[-- Attachment #1.1: Type: text/plain, Size: 6771 bytes --]

[AMD Official Use Only - Internal Distribution Only]


________________________________
From: Tianci Yin <tianci.yin@amd.com>
Sent: Wednesday, December 18, 2019 10:21 AM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Cc: Tuikov, Luben <Luben.Tuikov@amd.com>; 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>; Yin, Tianci (Rico) <Tianci.Yin@amd.com>
Subject: [PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training

From: "Tianci.Yin" <tianci.yin@amd.com>

The method of getting fb_loc changed from parsing VBIOS to
taking certain offset from top of VRAM

Change-Id: I053b42fdb1d822722fa7980b2cd9f86b3fdce539
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  3 +-
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 36 ++-----------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |  6 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h       |  7 ++++
 drivers/gpu/drm/amd/include/atomfirmware.h    | 14 --------
 5 files changed, 16 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index a78a363b1d71..fa2cf8e7bc07 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -642,9 +642,8 @@ struct amdgpu_fw_vram_usage {
         struct amdgpu_bo *reserved_bo;
         void *va;

-       /* Offset on the top of VRAM, used as c2p write buffer.
+       /* GDDR6 training support flag.
         */
-       u64 mem_train_fb_loc;
         bool mem_train_support;
 };

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index ff4eb96bdfb5..009cb0b03d13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -528,13 +528,9 @@ static int gddr6_mem_train_support(struct amdgpu_device *adev)
 int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev)
 {
         struct atom_context *ctx = adev->mode_info.atom_context;
-       unsigned char *bios = ctx->bios;
-       struct vram_reserve_block *reserved_block;
-       int index, block_number;
+       int index;
         uint8_t frev, crev;
         uint16_t data_offset, size;
-       uint32_t start_address_in_kb;
-       uint64_t offset;
         int ret;

         adev->fw_vram_usage.mem_train_support = false;
@@ -569,32 +565,6 @@ int amdgpu_atomfirmware_get_mem_train_fb_loc(struct amdgpu_device *adev)
[kevin]:
this function is not return any address after change,
i think we'd better to rename this function to another is well.
the code can be merge to function gddr6_mem_train_support().

                 return -EINVAL;
         }

-       reserved_block = (struct vram_reserve_block *)
-               (bios + data_offset + sizeof(struct atom_common_table_header));
-       block_number = ((unsigned int)size - sizeof(struct atom_common_table_header))
-               / sizeof(struct vram_reserve_block);
-       reserved_block += (block_number > 0) ? block_number-1 : 0;
-       DRM_DEBUG("block_number:0x%04x, last block: 0x%08xkb sz, %dkb fw, %dkb drv.\n",
-                 block_number,
-                 le32_to_cpu(reserved_block->start_address_in_kb),
-                 le16_to_cpu(reserved_block->used_by_firmware_in_kb),
-                 le16_to_cpu(reserved_block->used_by_driver_in_kb));
-       if (reserved_block->used_by_firmware_in_kb > 0) {
-               start_address_in_kb = le32_to_cpu(reserved_block->start_address_in_kb);
-               offset = (uint64_t)start_address_in_kb * ONE_KiB;
-               if ((offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {
-                       offset -= ONE_MiB;
-               }
-
-               offset &= ~(ONE_MiB - 1);
-               adev->fw_vram_usage.mem_train_fb_loc = offset;
-               adev->fw_vram_usage.mem_train_support = true;
-               DRM_DEBUG("mem_train_fb_loc:0x%09llx.\n", offset);
-               ret = 0;
-       } else {
-               DRM_ERROR("used_by_firmware_in_kb is 0!\n");
-               ret = -EINVAL;
-       }
-
-       return ret;
+       adev->fw_vram_usage.mem_train_support = true;
+       return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 2ff63d0414c9..ce5cb854bdb9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1705,7 +1705,11 @@ static int amdgpu_ttm_training_reserve_vram_init(struct amdgpu_device *adev)
                 return 0;
         }

-       ctx->c2p_train_data_offset = adev->fw_vram_usage.mem_train_fb_loc;
+       ctx->c2p_train_data_offset = adev->gmc.mc_vram_size;
+       if ((ctx->c2p_train_data_offset & (ONE_MiB - 1)) < (4 * ONE_KiB + 1) ) {
+               ctx->c2p_train_data_offset -= ONE_MiB;
+       }
+       ctx->c2p_train_data_offset &= ~(ONE_MiB - 1);
         ctx->p2c_train_data_offset = (adev->gmc.mc_vram_size - GDDR6_MEM_TRAINING_OFFSET);
         ctx->train_data_size = GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES;

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index f1ebd424510c..19eb3e8456c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -66,6 +66,13 @@ struct amdgpu_copy_mem {
         unsigned long                   offset;
 };

+/* Definitions for constance */
+enum amdgpu_internal_constants
+{
+       ONE_KiB = 0x400,
+       ONE_MiB = 0x100000,
+};
+
 extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;
 extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;

diff --git a/drivers/gpu/drm/amd/include/atomfirmware.h b/drivers/gpu/drm/amd/include/atomfirmware.h
index dd7cbc00a0aa..70146518174c 100644
--- a/drivers/gpu/drm/amd/include/atomfirmware.h
+++ b/drivers/gpu/drm/amd/include/atomfirmware.h
@@ -672,20 +672,6 @@ struct vram_usagebyfirmware_v2_1
   uint16_t  used_by_driver_in_kb;
 };

-/* This is part of vram_usagebyfirmware_v2_1 */
-struct vram_reserve_block
-{
-       uint32_t start_address_in_kb;
-       uint16_t used_by_firmware_in_kb;
-       uint16_t used_by_driver_in_kb;
-};
-
-/* Definitions for constance */
-enum atomfirmware_internal_constants
-{
-       ONE_KiB = 0x400,
-       ONE_MiB = 0x100000,
-};

 /*
   ***************************************************************************
--
2.17.1


[-- Attachment #1.2: Type: text/html, Size: 12208 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2019-12-18  5:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18  2:21 [PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training Tianci Yin
2019-12-18  2:21 ` [PATCH 2/2] drm/amdgpu: remove memory training p2c buffer reservation(V2) Tianci Yin
2019-12-18  5:32 ` Wang, Kevin(Yang) [this message]
2019-12-18  8:52   ` [PATCH 1/2] drm/amdgpu: update the method to get fb_loc of memory training Yin, Tianci (Rico)
  -- strict thread matches above, loose matches on Subject: below --
2019-12-17 11:23 Tianci Yin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN2PR12MB3296E3ACC90169776F9E090EA2530@MN2PR12MB3296.namprd12.prod.outlook.com \
    --to=kevin1.wang@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Feifei.Xu@amd.com \
    --cc=Gang.Long@amd.com \
    --cc=Hawking.Zhang@amd.com \
    --cc=Luben.Tuikov@amd.com \
    --cc=Tianci.Yin@amd.com \
    --cc=Xiaojie.Yuan@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.