Skip to content

Commit af72151

Browse files
Lijo Lazargregkh
authored andcommitted
drm/amdgpu: Use apt name for FW reserved region
commit db3b5cb upstream Use the generic term fw_reserved_memory for FW reserve region. This region may also hold discovery TMR in addition to other reserve regions. This region size could be larger than discovery tmr size, hence don't change the discovery tmr size based on this. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Le Ma <le.ma@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> [ This change fixes reading IP discovery from debugfs. It needed to be hand modified because: * GC 9.4.3 support isn't introduced in older kernels until 228ce17 ("drm/amdgpu: Handle VRAM dependencies on GFXIP9.4.3") * It also changed because of 58ab2c0 (drm/amdgpu: use VRAM|GTT for a bunch of kernel allocations) not being present. Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2748 ] Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3d0a34c commit af72151

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,14 +1625,15 @@ static int amdgpu_ttm_training_reserve_vram_fini(struct amdgpu_device *adev)
16251625
return 0;
16261626
}
16271627

1628-
static void amdgpu_ttm_training_data_block_init(struct amdgpu_device *adev)
1628+
static void amdgpu_ttm_training_data_block_init(struct amdgpu_device *adev,
1629+
uint32_t reserve_size)
16291630
{
16301631
struct psp_memory_training_context *ctx = &adev->psp.mem_train_ctx;
16311632

16321633
memset(ctx, 0, sizeof(*ctx));
16331634

16341635
ctx->c2p_train_data_offset =
1635-
ALIGN((adev->gmc.mc_vram_size - adev->mman.discovery_tmr_size - SZ_1M), SZ_1M);
1636+
ALIGN((adev->gmc.mc_vram_size - reserve_size - SZ_1M), SZ_1M);
16361637
ctx->p2c_train_data_offset =
16371638
(adev->gmc.mc_vram_size - GDDR6_MEM_TRAINING_OFFSET);
16381639
ctx->train_data_size =
@@ -1650,9 +1651,10 @@ static void amdgpu_ttm_training_data_block_init(struct amdgpu_device *adev)
16501651
*/
16511652
static int amdgpu_ttm_reserve_tmr(struct amdgpu_device *adev)
16521653
{
1653-
int ret;
16541654
struct psp_memory_training_context *ctx = &adev->psp.mem_train_ctx;
16551655
bool mem_train_support = false;
1656+
uint32_t reserve_size = 0;
1657+
int ret;
16561658

16571659
if (!amdgpu_sriov_vf(adev)) {
16581660
if (amdgpu_atomfirmware_mem_training_supported(adev))
@@ -1668,14 +1670,15 @@ static int amdgpu_ttm_reserve_tmr(struct amdgpu_device *adev)
16681670
* Otherwise, fallback to legacy approach to check and reserve tmr block for ip
16691671
* discovery data and G6 memory training data respectively
16701672
*/
1671-
adev->mman.discovery_tmr_size =
1672-
amdgpu_atomfirmware_get_fw_reserved_fb_size(adev);
1673-
if (!adev->mman.discovery_tmr_size)
1674-
adev->mman.discovery_tmr_size = DISCOVERY_TMR_OFFSET;
1673+
if (adev->bios)
1674+
reserve_size =
1675+
amdgpu_atomfirmware_get_fw_reserved_fb_size(adev);
1676+
if (!reserve_size)
1677+
reserve_size = DISCOVERY_TMR_OFFSET;
16751678

16761679
if (mem_train_support) {
16771680
/* reserve vram for mem train according to TMR location */
1678-
amdgpu_ttm_training_data_block_init(adev);
1681+
amdgpu_ttm_training_data_block_init(adev, reserve_size);
16791682
ret = amdgpu_bo_create_kernel_at(adev,
16801683
ctx->c2p_train_data_offset,
16811684
ctx->train_data_size,
@@ -1690,13 +1693,14 @@ static int amdgpu_ttm_reserve_tmr(struct amdgpu_device *adev)
16901693
}
16911694

16921695
ret = amdgpu_bo_create_kernel_at(adev,
1693-
adev->gmc.real_vram_size - adev->mman.discovery_tmr_size,
1694-
adev->mman.discovery_tmr_size,
1695-
&adev->mman.discovery_memory,
1696+
adev->gmc.real_vram_size - reserve_size,
1697+
reserve_size,
1698+
&adev->mman.fw_reserved_memory,
16961699
NULL);
16971700
if (ret) {
16981701
DRM_ERROR("alloc tmr failed(%d)!\n", ret);
1699-
amdgpu_bo_free_kernel(&adev->mman.discovery_memory, NULL, NULL);
1702+
amdgpu_bo_free_kernel(&adev->mman.fw_reserved_memory,
1703+
NULL, NULL);
17001704
return ret;
17011705
}
17021706

@@ -1890,8 +1894,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
18901894
/* return the stolen vga memory back to VRAM */
18911895
amdgpu_bo_free_kernel(&adev->mman.stolen_vga_memory, NULL, NULL);
18921896
amdgpu_bo_free_kernel(&adev->mman.stolen_extended_memory, NULL, NULL);
1893-
/* return the IP Discovery TMR memory back to VRAM */
1894-
amdgpu_bo_free_kernel(&adev->mman.discovery_memory, NULL, NULL);
1897+
/* return the FW reserved memory back to VRAM */
1898+
amdgpu_bo_free_kernel(&adev->mman.fw_reserved_memory, NULL,
1899+
NULL);
18951900
if (adev->mman.stolen_reserved_size)
18961901
amdgpu_bo_free_kernel(&adev->mman.stolen_reserved_memory,
18971902
NULL, NULL);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ struct amdgpu_mman {
7878
/* discovery */
7979
uint8_t *discovery_bin;
8080
uint32_t discovery_tmr_size;
81-
struct amdgpu_bo *discovery_memory;
81+
/* fw reserved memory */
82+
struct amdgpu_bo *fw_reserved_memory;
8283

8384
/* firmware VRAM reservation */
8485
u64 fw_vram_usage_start_offset;

0 commit comments

Comments
 (0)