diff options
| author | Lijo Lazar <lijo.lazar@amd.com> | 2026-03-26 11:11:39 +0530 |
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2026-04-03 13:50:20 -0400 |
| commit | 6845355a08c2dc7e5af3c37b7d8f61afbfec1939 (patch) | |
| tree | 5d522c75d96b76d92a97566606cddf43e618d4e1 /drivers/gpu/drm/amd/amdgpu | |
| parent | 7b0af16044b7669685f923d2c83c20d3aba72e18 (diff) | |
| download | linux-next-6845355a08c2dc7e5af3c37b7d8f61afbfec1939.tar.gz linux-next-6845355a08c2dc7e5af3c37b7d8f61afbfec1939.zip | |
drm/amdgpu: Move validation of reserve region info
Keep validation of reserved regions also as part of filling details. If
the information is invalid, size is kept as 0 so that it's not
considered for reservation.
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 8d072eb4af78..212b489845a9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1748,6 +1748,8 @@ static void amdgpu_ttm_init_mem_train_resv_region(struct amdgpu_device *adev) static void amdgpu_ttm_init_vram_resv_regions(struct amdgpu_device *adev) { + uint64_t vram_size = adev->gmc.visible_vram_size; + /* Initialize memory reservations as required for VGA. * This is used for VGA emulation and pre-OS scanout buffers to * avoid display artifacts while transitioning between pre-OS @@ -1756,6 +1758,12 @@ static void amdgpu_ttm_init_vram_resv_regions(struct amdgpu_device *adev) amdgpu_gmc_init_vga_resv_regions(adev); amdgpu_ttm_init_fw_resv_region(adev); amdgpu_ttm_init_mem_train_resv_region(adev); + + if (adev->mman.resv_region[AMDGPU_RESV_FW_VRAM_USAGE].size > vram_size) + adev->mman.resv_region[AMDGPU_RESV_FW_VRAM_USAGE].size = 0; + + if (adev->mman.resv_region[AMDGPU_RESV_DRV_VRAM_USAGE].size > vram_size) + adev->mman.resv_region[AMDGPU_RESV_DRV_VRAM_USAGE].size = 0; } int amdgpu_ttm_mark_vram_reserved(struct amdgpu_device *adev, @@ -2122,27 +2130,17 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) *The reserved vram for firmware must be pinned to the specified *place on the VRAM, so reserve it early. */ - if (adev->mman.resv_region[AMDGPU_RESV_FW_VRAM_USAGE].size > - adev->gmc.visible_vram_size) { - adev->mman.resv_region[AMDGPU_RESV_FW_VRAM_USAGE].size = 0; - } else { - r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_FW_VRAM_USAGE); - if (r) - return r; - } + r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_FW_VRAM_USAGE); + if (r) + return r; /* * The reserved VRAM for the driver must be pinned to a specific * location in VRAM, so reserve it early. */ - if (adev->mman.resv_region[AMDGPU_RESV_DRV_VRAM_USAGE].size > - adev->gmc.visible_vram_size) { - adev->mman.resv_region[AMDGPU_RESV_DRV_VRAM_USAGE].size = 0; - } else { - r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_DRV_VRAM_USAGE); - if (r) - return r; - } + r = amdgpu_ttm_mark_vram_reserved(adev, AMDGPU_RESV_DRV_VRAM_USAGE); + if (r) + return r; /* * only NAVI10 and later ASICs support IP discovery. |
