drm/amdgpu: Add amdgpu_discovery_info
Subsystems (2)
PATCH v3 1/2 drm/amdgpu: Add amdgpu_discovery_info
Add amdgpu_discovery_info structure to keep all discovery related information.
Signed-off-by Lijo Lazar <[email protected]>
---
v2: Remove superfluous discovery_ prefix for members (Alex)
v3: Keep the original NULL check for cleanup (Alex)
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 192 ++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 11 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 6 files changed, 129 insertions(+), 97 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -6
@@ -839,8 +839,6 @@ struct amd_powerplay {const struct amd_pm_funcs *pp_funcs; }; -struct ip_discovery_top ; -/* polaris10 kickers */ #define ASICID_IS_P20 (did, rid) (((did == 0x67DF) && \ ((rid == 0xE3) || \
@@ -972,8 +970,7 @@ struct amdgpu_device {struct notifier_block acpi_nb;struct notifier_block pm_nb;struct amdgpu_i2c_chan *i2c_bus[AMDGPU_MAX_I2C_BUS ]; -struct debugfs_blob_wrapper debugfs_vbios_blob; -struct debugfs_blob_wrapper debugfs_discovery_blob; +struct debugfs_blob_wrapper debugfs_vbios_blob;struct mutex srbm_mutex;/* GRBM index mutex. Protects concurrent access to GRBM index */ struct mutex grbm_idx_mutex;
@@ -1063,6 +1060,9 @@ struct amdgpu_device {u32 log2_max_MBps; } mm_stats; +/* discovery*/ +struct amdgpu_discovery_info discovery; +/* display */ bool enable_virtual_display;struct amdgpu_vkms_output *amdgpu_vkms_output;
@@ -1265,8 +1265,6 @@ struct amdgpu_device {struct list_head ras_list; -struct ip_discovery_top *ip_top; -struct amdgpu_reset_domain *reset_domain;struct mutex benchmark_mutex;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3 -4
@@ -2123,10 +2123,9 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)debugfs_create_blob ("amdgpu_vbios" ,0444 , root, &adev->debugfs_vbios_blob); - adev->debugfs_discovery_blob.data = adev->mman.discovery_bin; - adev->debugfs_discovery_blob.size = adev->mman.discovery_tmr_size; -debugfs_create_blob ("amdgpu_discovery" ,0444 , root, - &adev->debugfs_discovery_blob); +if (adev->discovery.debugfs_blob.size) +debugfs_create_blob ("amdgpu_discovery" ,0444 , root, + &adev->discovery.debugfs_blob);return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -2
@@ -2626,7 +2626,7 @@ static int amdgpu_device_parse_gpu_info_fw(struct amdgpu_device *adev) chip_name ="arcturus" ;break ;case CHIP_NAVI12 : -if (adev->mman.discovery_bin) +if (adev->discovery.bin)return 0 ; chip_name ="navi12" ;break ;
@@ -5038,7 +5038,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)if (IS_ENABLED (CONFIG_PERF_EVENTS ))amdgpu_pmu_fini (adev); -if (adev->mman.discovery_bin) +if (adev->discovery.bin)amdgpu_discovery_fini (adev);amdgpu_reset_put_reset_domain (adev->reset_domain);
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +108 -84
580 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +11 -0
@@ -24,9 +24,20 @@#ifndef __AMDGPU_DISCOVERY__#define __AMDGPU_DISCOVERY__ +#include <linux/debugfs.h> +#define DISCOVERY_TMR_SIZE (10 << 10)#define DISCOVERY_TMR_OFFSET (64 << 10) +struct ip_discovery_top ; + +struct amdgpu_discovery_info { +struct debugfs_blob_wrapper debugfs_blob; +struct ip_discovery_top *ip_top; +uint32_t size; +uint8_t *bin; +}; +void amdgpu_discovery_fini (struct amdgpu_device *adev);int amdgpu_discovery_set_ip_blocks (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -1955,7 +1955,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->mman.discovery_bin) { +if (adev->discovery.bin) { r =amdgpu_ttm_reserve_tmr (adev);if (r)return r;
Signature · 1 line
2.49.0
PATCH v3 2/2 drm/amdgpu: Reserve discovery TMR only if needed
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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +9 -1
@@ -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 :
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +1 -0
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9 -13
@@ -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;
Signature · 1 line
2.49.0
Re: [PATCH v3 2/2] drm/amdgpu: Reserve discovery TMR only if needed
Series is:
Reviewed-by Alex Deucher <[email protected]>
Quoted 101 lines · Lijo Lazar
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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +9
-1@@ -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 :drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +1
-0@@ -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);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9
-14@@ -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