On Fri, Oct 10, 2025 at 11:06 AM Lijo Lazar <[email protected]> wrote: > > For legacy SOCs, discovery binary is sideloaded. Instead of checking for > binary blob, use a flag to determine if discovery region needs to be > reserved. > > Signed-off-by: Lijo Lazar <[email protected]>
Reviewed-by: Alex Deucher <[email protected]> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 10 ++++++++- > drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 1 + > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 22 ++++++++----------- > 3 files changed, 19 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > index 02b661232db8..478cbfcc5b5d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > @@ -298,10 +298,15 @@ static int amdgpu_discovery_read_binary_from_mem(struct > amdgpu_device *adev, > else > vram_size <<= 20; > > + /* > + * If in VRAM, discovery TMR is marked for reservation. If it is in > system mem, > + * then it is not required to be reserved. > + */ > if (sz_valid) { > uint64_t pos = vram_size - DISCOVERY_TMR_OFFSET; > amdgpu_device_vram_access(adev, pos, (uint32_t *)binary, > adev->discovery.size, false); > + adev->discovery.reserve_tmr = true; > } else { > ret = amdgpu_discovery_read_binary_from_sysmem(adev, binary); > } > @@ -418,8 +423,11 @@ static int amdgpu_discovery_verify_npsinfo(struct > amdgpu_device *adev, > > static const char *amdgpu_discovery_get_fw_name(struct amdgpu_device *adev) > { > - if (amdgpu_discovery == 2) > + if (amdgpu_discovery == 2) { > + /* Assume there is valid discovery TMR in VRAM even if binary > is sideloaded */ > + adev->discovery.reserve_tmr = true; > return "amdgpu/ip_discovery.bin"; > + } > > switch (adev->asic_type) { > case CHIP_VEGA10: > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h > index b1eec3af3c4a..4ce04486cc31 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h > @@ -36,6 +36,7 @@ struct amdgpu_discovery_info { > struct ip_discovery_top *ip_top; > uint32_t size; > uint8_t *bin; > + bool reserve_tmr; > }; > > void amdgpu_discovery_fini(struct amdgpu_device *adev); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > index 5bf6bb3b2faa..d0a7379255e8 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > @@ -1767,18 +1767,14 @@ static int amdgpu_ttm_reserve_tmr(struct > amdgpu_device *adev) > ctx->init = PSP_MEM_TRAIN_RESERVE_SUCCESS; > } > > - if (!adev->gmc.is_app_apu) { > - ret = amdgpu_bo_create_kernel_at( > - adev, adev->gmc.real_vram_size - reserve_size, > - reserve_size, &adev->mman.fw_reserved_memory, NULL); > - if (ret) { > - dev_err(adev->dev, "alloc tmr failed(%d)!\n", ret); > - amdgpu_bo_free_kernel(&adev->mman.fw_reserved_memory, > - NULL, NULL); > - return ret; > - } > - } else { > - DRM_DEBUG_DRIVER("backdoor fw loading path for PSP TMR, no > reservation needed\n"); > + ret = amdgpu_bo_create_kernel_at( > + adev, adev->gmc.real_vram_size - reserve_size, reserve_size, > + &adev->mman.fw_reserved_memory, NULL); > + if (ret) { > + dev_err(adev->dev, "alloc tmr failed(%d)!\n", ret); > + amdgpu_bo_free_kernel(&adev->mman.fw_reserved_memory, NULL, > + NULL); > + return ret; > } > > return 0; > @@ -1955,7 +1951,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) > * If IP discovery enabled, a block of memory should be > * reserved for IP discovey. > */ > - if (adev->discovery.bin) { > + if (adev->discovery.reserve_tmr) { > r = amdgpu_ttm_reserve_tmr(adev); > if (r) > return r; > -- > 2.49.0 >
