drm/amdgpu: check ip_discovery fw file available
Subsystems (2)
PATCH 1/3 drm/amdgpu: check ip_discovery fw file available
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +16 -15
@@ -113,8 +113,7 @@#include "amdgpu_isp.h" #endif -#define FIRMWARE_IP_DISCOVERY "amdgpu/ip_discovery.bin" -MODULE_FIRMWARE (FIRMWARE_IP_DISCOVERY ); +MODULE_FIRMWARE ("amdgpu/ip_discovery.bin" );#define mmIP_DISCOVERY_VERSION 0x16A00#define mmRCC_CONFIG_MEMSIZE 0xde3
@@ -297,21 +296,13 @@ static int amdgpu_discovery_read_binary_from_mem(struct amdgpu_device *adev,return ret; } -static int amdgpu_discovery_read_binary_from_file (struct amdgpu_device *adev,uint8_t *binary) +static int amdgpu_discovery_read_binary_from_file (struct amdgpu_device *adev, +uint8_t *binary, +const char *fw_name) {const struct firmware *fw; -const char *fw_name;int r; -switch (amdgpu_discovery) { -case 2 : - fw_name =FIRMWARE_IP_DISCOVERY ; -break ; -default : -dev_warn (adev->dev,"amdgpu_discovery is not set properly\n" ); -return -EINVAL ; - } - r =request_firmware (&fw, fw_name, adev->dev);if (r) { dev_err(adev->dev, "can't load firmware \"%s\"\n",
@@ -404,10 +395,19 @@ static int amdgpu_discovery_verify_npsinfo(struct amdgpu_device *adev,return 0 ; } +static const char *amdgpu_discovery_get_fw_name (struct amdgpu_device *adev) +{ +if (amdgpu_discovery ==2 ) +return "amdgpu/ip_discovery.bin" ; + +return NULL ; +} +static int amdgpu_discovery_init (struct amdgpu_device *adev) {struct table_info *info;struct binary_header *bhdr; +const char *fw_name;uint16_t offset;uint16_t size;uint16_t checksum;
@@ -419,9 +419,10 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev)return -ENOMEM ;/* Read from file if it is the preferred option */ -if (amdgpu_discovery ==2 ) { + fw_name =amdgpu_discovery_get_fw_name (adev); +if (fw_name !=NULL ) {dev_info (adev->dev,"use ip discovery information from file" ); - r =amdgpu_discovery_read_binary_from_file (adev, adev->mman.discovery_bin); + r =amdgpu_discovery_read_binary_from_file (adev, adev->mman.discovery_bin, fw_name);if (r) {dev_err (adev->dev,"failed to read ip discovery binary from file\n" );
Signature · 1 line
2.43.0
PATCH 2/3 drm/amdgpu: use specific ip_discovery.bin for legacy asics
vega10/vega12/vega20/raven/raven2/picasso/arcturus/aldebaran
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +27 -1
@@ -114,6 +114,12 @@#endif MODULE_FIRMWARE ("amdgpu/ip_discovery.bin" ); +MODULE_FIRMWARE ("amdgpu/vega10_ip_discovery.bin" ); +MODULE_FIRMWARE ("amdgpu/vega12_ip_discovery.bin" ); +MODULE_FIRMWARE ("amdgpu/vega20_ip_discovery.bin" ); +MODULE_FIRMWARE ("amdgpu/raven_ip_discovery.bin" ); +MODULE_FIRMWARE ("amdgpu/raven2_ip_discovery.bin" ); +MODULE_FIRMWARE ("amdgpu/picasso_ip_discovery.bin" );#define mmIP_DISCOVERY_VERSION 0x16A00#define mmRCC_CONFIG_MEMSIZE 0xde3
@@ -400,7 +406,27 @@ static const char *amdgpu_discovery_get_fw_name(struct amdgpu_device *adev)if (amdgpu_discovery ==2 )return "amdgpu/ip_discovery.bin" ; -return NULL ; +switch (adev->asic_type) { +case CHIP_VEGA10 : +return "amdgpu/vega10_ip_discovery.bin" ; +case CHIP_VEGA12 : +return "amdgpu/vega12_ip_discovery.bin" ; +case CHIP_RAVEN : +if (adev->apu_flags &AMD_APU_IS_RAVEN2 ) +return "amdgpu/raven2_ip_discovery.bin" ; +else if (adev->apu_flags &AMD_APU_IS_PICASSO ) +return "amdgpu/picasso_ip_discovery.bin" ; +else +return "amdgpu/raven_ip_discovery.bin" ; +case CHIP_VEGA20 : +return "amdgpu/vega20_ip_discovery.bin" ; +case CHIP_ARCTURUS : +return "amdgpu/arcturus_ip_discovery.bin" ; +case CHIP_ALDEBARAN : +return "amdgpu/aldebaran_ip_discovery.bin" ; +default : +return NULL ; + } }static int amdgpu_discovery_init (struct amdgpu_device *adev)
Signature · 1 line
2.43.0
PATCH 3/3 drm/amdgpu/discovery: optionally use fw based ip discovery
In reply to Flora CuiFrom: Alex Deucher <[email protected]>
On chips without native IP discovery support, use the fw binary if available, otherwise we can continue without it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +30 -8
@@ -2536,6 +2536,36 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) {int r; +switch (adev->asic_type) { +case CHIP_VEGA10 : +case CHIP_VEGA12 : +case CHIP_RAVEN : +case CHIP_VEGA20 : +case CHIP_ARCTURUS : +case CHIP_ALDEBARAN : +/* this is not fatal. We have a fallback below +* if the new firmwares are not present. +*/ + r =amdgpu_discovery_reg_base_init (adev); +if (!r) { +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev); +amdgpu_discovery_get_vcn_info (adev); + } +break ; +default : + r =amdgpu_discovery_reg_base_init (adev); +if (r) +return -EINVAL ; + +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev); +amdgpu_discovery_get_vcn_info (adev); +break ; + } +switch (adev->asic_type) {case CHIP_VEGA10 :vega10_reg_base_init (adev);
@@ -2700,14 +2730,6 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) adev->ip_versions[XGMI_HWIP ][0 ] =IP_VERSION (6 ,1 ,0 );break ;default : - r =amdgpu_discovery_reg_base_init (adev); -if (r) -return -EINVAL ; - -amdgpu_discovery_harvest_ip (adev); -amdgpu_discovery_get_gfx_info (adev); -amdgpu_discovery_get_mall_info (adev); -amdgpu_discovery_get_vcn_info (adev);break ; }
Signature · 1 line
2.43.0
Re: [PATCH 3/3] drm/amdgpu/discovery: optionally use fw based ip discovery
Quoted 39 lines · Flora Cui
From: Alex Deucher <[email protected]>
On chips without native IP discovery support, use the fw binary if available, otherwise we can continue without it.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +21
-0@@ -2536,6 +2536,36 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) {int r; +switch (adev->asic_type) { +case CHIP_VEGA10 : +case CHIP_VEGA12 : +case CHIP_RAVEN : +case CHIP_VEGA20 : +case CHIP_ARCTURUS : +case CHIP_ALDEBARAN : +/* this is not fatal. We have a fallback below +* if the new firmwares are not present. +*/ + r =amdgpu_discovery_reg_base_init (adev); +if (!r) { +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev); +amdgpu_discovery_get_vcn_info (adev); + } +break ; +default : + r =amdgpu_discovery_reg_base_init (adev); +if (r)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) · line 2569
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +9
-0+return -EINVAL ; + +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev); +amdgpu_discovery_get_vcn_info (adev); +break ; + } +switch (adev->asic_type) {
Looks like this fallback gets executed regardless of the presence/absence of new firmware.
Thanks,
Lijo
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +0
-8case CHIP_VEGA10 :vega10_reg_base_init (adev);@@ -2700,14 +2730,6 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) adev->ip_versions[XGMI_HWIP ][0 ] =IP_VERSION (6 ,1 ,0 );break ;default : - r =amdgpu_discovery_reg_base_init (adev); -if (r) -return -EINVAL ; - -amdgpu_discovery_harvest_ip (adev); -amdgpu_discovery_get_gfx_info (adev); -amdgpu_discovery_get_mall_info (adev); -amdgpu_discovery_get_vcn_info (adev);break ; }
Re: [PATCH 3/3] drm/amdgpu/discovery: optionally use fw based ip discovery
Quoted 48 lines · Lijo
Quoted 44 lines · Flora Cui
From: Alex Deucher <[email protected]>
On chips without native IP discovery support, use the fw binary if available, otherwise we can continue without it.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +26
-0@@ -2536,6 +2536,36 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) {int r; +switch (adev->asic_type) { +case CHIP_VEGA10 : +case CHIP_VEGA12 : +case CHIP_RAVEN : +case CHIP_VEGA20 : +case CHIP_ARCTURUS : +case CHIP_ALDEBARAN : +/* this is not fatal. We have a fallback below +* if the new firmwares are not present. +*/ + r =amdgpu_discovery_reg_base_init (adev); +if (!r) { +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev); +amdgpu_discovery_get_vcn_info (adev); + } +break ; +default : + r =amdgpu_discovery_reg_base_init (adev); +if (r) +return -EINVAL ; + +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev);
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) · line 2569
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +4
-0+amdgpu_discovery_get_vcn_info (adev); +break ; + } +switch (adev->asic_type) {Looks like this fallback gets executed regardless of the presence/absence of new firmware.
That's by design. The hardcoded settings we have today are not quite the same as what the ip discovery table provides so we want them to override what comes from the firmware either way. We really just want the ip discovery table so that we can setup the sysfs ip discovery files because the ROCm profiler uses them for getting the GC register offsets and wants to have them available for all gfx9+ parts.
Alex
Quoted 22 lines
Thanks,
LijoQuoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +0
-8case CHIP_VEGA10 :vega10_reg_base_init (adev);@@ -2700,14 +2730,6 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) adev->ip_versions[XGMI_HWIP ][0 ] =IP_VERSION (6 ,1 ,0 );break ;default : - r =amdgpu_discovery_reg_base_init (adev); -if (r) -return -EINVAL ; - -amdgpu_discovery_harvest_ip (adev); -amdgpu_discovery_get_gfx_info (adev); -amdgpu_discovery_get_mall_info (adev); -amdgpu_discovery_get_vcn_info (adev);break ; }
RE: [PATCH 3/3] drm/amdgpu/discovery: optionally use fw based ip discovery
[AMD Official Use Only - AMD Internal Distribution Only]
Ping on this series.
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, March 14, 2025 9:28 PM
To: Lazar, Lijo <[email protected]>
Cc: Cui, Flora <[email protected]>; [email protected]; Deucher, Alexander <[email protected]>; Meng, Li (Jassmine) <[email protected]>
Subject: Re: [PATCH 3/3] drm/amdgpu/discovery: optionally use fw based ip discovery
Quoted 48 lines · Lijo
Quoted 44 lines · Flora Cui
From: Alex Deucher <[email protected]>
On chips without native IP discovery support, use the fw binary if available, otherwise we can continue without it.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +26
-0@@ -2536,6 +2536,36 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) {int r; +switch (adev->asic_type) { +case CHIP_VEGA10 : +case CHIP_VEGA12 : +case CHIP_RAVEN : +case CHIP_VEGA20 : +case CHIP_ARCTURUS : +case CHIP_ALDEBARAN : +/* this is not fatal. We have a fallback below +* if the new firmwares are not present. +*/ + r =amdgpu_discovery_reg_base_init (adev); +if (!r) { +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev); +amdgpu_discovery_get_vcn_info (adev); + } +break ; +default : + r =amdgpu_discovery_reg_base_init (adev); +if (r) +return -EINVAL ; + +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev);
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) · line 2569
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +4
-0+amdgpu_discovery_get_vcn_info (adev); +break ; + } +switch (adev->asic_type) {Looks like this fallback gets executed regardless of the presence/absence of new firmware.
That's by design. The hardcoded settings we have today are not quite the same as what the ip discovery table provides so we want them to override what comes from the firmware either way. We really just want the ip discovery table so that we can setup the sysfs ip discovery files because the ROCm profiler uses them for getting the GC register offsets and wants to have them available for all gfx9+ parts.
Alex
Quoted 22 lines
Thanks,
LijoQuoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +0
-8case CHIP_VEGA10 :vega10_reg_base_init (adev);@@ -2700,14 +2730,6 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) adev->ip_versions[XGMI_HWIP ][0 ] =IP_VERSION (6 ,1 ,0 );break ;default : - r =amdgpu_discovery_reg_base_init (adev); -if (r) -return -EINVAL ; - -amdgpu_discovery_harvest_ip (adev); -amdgpu_discovery_get_gfx_info (adev); -amdgpu_discovery_get_mall_info (adev); -amdgpu_discovery_get_vcn_info (adev);break ; }
Re: [PATCH 3/3] drm/amdgpu/discovery: optionally use fw based ip discovery
In reply to Flora CuiQuoted 18 lines · Flora Cui
From: Alex Deucher <[email protected]>
On chips without native IP discovery support, use the fw binary if available, otherwise we can continue without it.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +0
-0@@ -2536,6 +2536,36 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) {int r;
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) · line 2547
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +9
-0+switch (adev->asic_type) { +case CHIP_VEGA10 : +case CHIP_VEGA12 : +case CHIP_RAVEN : +case CHIP_VEGA20 : +case CHIP_ARCTURUS : +case CHIP_ALDEBARAN : +/* this is not fatal. We have a fallback below +* if the new firmwares are not present.
Update this comment to add that some of this will be overridden below to keep things consistent with the current behavior. With that fixed, the series is:
Quoted 42 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +21
-9+*/ + r =amdgpu_discovery_reg_base_init (adev); +if (!r) { +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev); +amdgpu_discovery_get_vcn_info (adev); + } +break ; +default : + r =amdgpu_discovery_reg_base_init (adev); +if (r) +return -EINVAL ; + +amdgpu_discovery_harvest_ip (adev); +amdgpu_discovery_get_gfx_info (adev); +amdgpu_discovery_get_mall_info (adev); +amdgpu_discovery_get_vcn_info (adev); +break ; + } +switch (adev->asic_type) {case CHIP_VEGA10 :vega10_reg_base_init (adev);@@ -2700,14 +2730,6 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev) adev->ip_versions[XGMI_HWIP ][0 ] =IP_VERSION (6 ,1 ,0 );break ;default : - r =amdgpu_discovery_reg_base_init (adev); -if (r) -return -EINVAL ; - -amdgpu_discovery_harvest_ip (adev); -amdgpu_discovery_get_gfx_info (adev); -amdgpu_discovery_get_mall_info (adev); -amdgpu_discovery_get_vcn_info (adev);break ; } --2.43.0