drm/amdgpu: Increase potential product_name to 64 characters
Subsystems (3)
PATCH 1/4 drm/amdgpu: Increase potential product_name to 64 characters
Having seen at least 1 42-character product_name, bump the number up to 64.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
@@ -1083,7 +1083,7 @@ struct amdgpu_device {/* Chip product information */ char product_number[16 ]; -char product_name[32 ]; +char product_name[64 ];char serial[20 ];atomic_t throttling_logging_enabled;
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +4 -4
@@ -88,7 +88,7 @@ static int amdgpu_fru_read_eeprom(struct amdgpu_device *adev, uint32_t addrptr,int amdgpu_fru_get_product_info (struct amdgpu_device *adev) { -unsigned char buff[34 ]; +unsigned char buff[66 ];u32 addrptr;int size, len;
@@ -131,11 +131,11 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) } len = size; -/* Product name should only be 32 characters. Any more, -* and something could be wrong. Cap it at 32 to be safe +/* Product name should logically be < 64 characters. Any more, +* and something could be wrong. Cap it at 64 to be safe */ if (len >=sizeof (adev->product_name)) { -DRM_WARN ("FRU Product Number is larger than 32 characters. This is likely a mistake" ); +DRM_WARN ("FRU Product Name is larger than 64 characters. This is likely a mistake" ); len =sizeof (adev->product_name) -1 ; }/* Start at 2 due to buff using fields 0 and 1 for the address */
Signature · 1 line
2.25.1
PATCH 2/4 drm/amdgpu: Enable unique_id for Aldebaran
It's supported, so support the unique_id sysfs file
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -1
@@ -2090,7 +2090,8 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_ }else if (DEVICE_ATTR_IS (unique_id)) {if (asic_type !=CHIP_VEGA10 && asic_type !=CHIP_VEGA20 && - asic_type !=CHIP_ARCTURUS ) + asic_type !=CHIP_ARCTURUS && + asic_type !=CHIP_ALDEBARAN ) *states =ATTR_STATE_UNSUPPORTED ; }else if (DEVICE_ATTR_IS (pp_features)) {if (adev->flags &AMD_IS_APU || asic_type <CHIP_VEGA10 )
Signature · 1 line
2.25.1
PATCH 3/4 drm/amdgpu: Only overwrite serial if field is empty
In reply to Kent RussellOn Aldebaran, the serial may be obtained from the FRU. Only overwrite the serial with the unique_id if the serial is empty. This will support printing serial numbers for mGPU devices where there are 2 unique_ids for the 2 GPUs, but only one serial number for the board
--- drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +2 -1
@@ -1615,7 +1615,8 @@ static void aldebaran_get_unique_id(struct smu_context *smu)mutex_unlock (&smu->metrics_lock); adev->unique_id = ((uint64_t )upper32 <<32 ) | lower32; -sprintf (adev->serial,"%016llx" , adev->unique_id); +if (adev->serial[0 ] =='\0' ) +sprintf (adev->serial,"%016llx" , adev->unique_id); }static bool aldebaran_is_baco_supported (struct smu_context *smu)
Signature · 1 line
2.25.1
PATCH 4/4 drm/amdgpu: Access the FRU on Aldebaran
In reply to Kent RussellThis is supported, although the offset is different from VG20, so fix that with a variable and enable getting the product name and serial number from the FRU.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +9 -3
@@ -56,6 +56,8 @@ static bool is_fru_eeprom_supported(struct amdgpu_device *adev)return true; else return false; +case CHIP_ALDEBARAN : +return true;default :return false; }
@@ -91,6 +93,10 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)unsigned char buff[66 ];u32 addrptr;int size, len; +int offset =2 ; + +if (adev->asic_type ==CHIP_ALDEBARAN ) + offset =0 ;if (!is_fru_eeprom_supported (adev))return 0 ;
@@ -139,7 +145,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) len =sizeof (adev->product_name) -1 ; }/* Start at 2 due to buff using fields 0 and 1 for the address */ -memcpy (adev->product_name, &buff[2 ], len); +memcpy (adev->product_name, &buff[offset], len); adev->product_name[len] ='\0' ; addrptr += size +1 ;
@@ -157,7 +163,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)DRM_WARN ("FRU Product Number is larger than 16 characters. This is likely a mistake" ); len =sizeof (adev->product_number) -1 ; } -memcpy (adev->product_number, &buff[2 ], len); +memcpy (adev->product_number, &buff[offset], len); adev->product_number[len] ='\0' ; addrptr += size +1 ;
@@ -184,7 +190,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)DRM_WARN ("FRU Serial Number is larger than 16 characters. This is likely a mistake" ); len =sizeof (adev->serial) -1 ; } -memcpy (adev->serial, &buff[2 ], len); +memcpy (adev->serial, &buff[offset], len); adev->serial[len] ='\0' ;return 0 ;
Signature · 1 line
2.25.1
RE: [PATCH 4/4] drm/amdgpu: Access the FRU on Aldebaran
[Public]
+ if (adev->asic_type == CHIP_ALDEBARAN)
+ offset = 0;
if (!is_fru_eeprom_supported(adev))
return 0;
I assume the logic should be adjusted. It's better to put the asic_type check after is_fru_eeprom_supported.
Regards,
Guchun
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kent Russell
Sent: Tuesday, December 14, 2021 3:34 AM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu: Access the FRU on Aldebaran
This is supported, although the offset is different from VG20, so fix that with a variable and enable getting the product name and serial number from the FRU.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +9 -3
@@ -56,6 +56,8 @@ static bool is_fru_eeprom_supported(struct amdgpu_device *adev)return true; else return false; +case CHIP_ALDEBARAN : +return true;default :return false; }
@@ -91,6 +93,10 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)unsigned char buff[66 ];u32 addrptr;int size, len; +int offset =2 ; + +if (adev->asic_type ==CHIP_ALDEBARAN ) + offset =0 ;if (!is_fru_eeprom_supported (adev))return 0 ;
@@ -139,7 +145,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) len =sizeof (adev->product_name) -1 ; }/* Start at 2 due to buff using fields 0 and 1 for the address */ -memcpy (adev->product_name, &buff[2 ], len); +memcpy (adev->product_name, &buff[offset], len); adev->product_name[len] ='\0' ; addrptr += size +1 ;
@@ -157,7 +163,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)DRM_WARN ("FRU Product Number is larger than 16 characters. This is likely a mistake" ); len =sizeof (adev->product_number) -1 ; } -memcpy (adev->product_number, &buff[2 ], len); +memcpy (adev->product_number, &buff[offset], len); adev->product_number[len] ='\0' ; addrptr += size +1 ;
@@ -184,7 +190,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)DRM_WARN ("FRU Serial Number is larger than 16 characters. This is likely a mistake" ); len =sizeof (adev->serial) -1 ; } -memcpy (adev->serial, &buff[2 ], len); +memcpy (adev->serial, &buff[offset], len); adev->serial[len] ='\0' ;return 0 ;
--
2.25.1
RE: [PATCH 4/4] drm/amdgpu: Access the FRU on Aldebaran
[Public]
BTW, does FRU exists on all the Aldebaran SKUs?
This patch acks FRU's presence when it's Aldebaran. So if some Aldebaran SKUs do not have a FRU, some i2c access failures will be observed during boot up. This is not friendly to user.
Please check Vega20 case we talked before, and there are some more strict checks for FRU on several Vega20 SKUs.
case CHIP_VEGA20:
/* D161 and D163 are the VG20 server SKUs */ if (strnstr(atom_ctx->vbios_version, "D161", sizeof(atom_ctx->vbios_version)) || strnstr(atom_ctx->vbios_version, "D163", sizeof(atom_ctx->vbios_version))) return true; else return false;
Regards,
Guchun
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Chen, Guchun
Sent: Tuesday, December 14, 2021 11:17 AM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Russell, Kent <[email protected]>
Subject: RE: [PATCH 4/4] drm/amdgpu: Access the FRU on Aldebaran
[Public]
+ if (adev->asic_type == CHIP_ALDEBARAN)
+ offset = 0;
if (!is_fru_eeprom_supported(adev))
return 0;
I assume the logic should be adjusted. It's better to put the asic_type check after is_fru_eeprom_supported.
Regards,
Guchun
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kent Russell
Sent: Tuesday, December 14, 2021 3:34 AM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu: Access the FRU on Aldebaran
This is supported, although the offset is different from VG20, so fix that with a variable and enable getting the product name and serial number from the FRU.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +9 -3
@@ -56,6 +56,8 @@ static bool is_fru_eeprom_supported(struct amdgpu_device *adev)return true; else return false; +case CHIP_ALDEBARAN : +return true;default :return false; }
@@ -91,6 +93,10 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)unsigned char buff[66 ];u32 addrptr;int size, len; +int offset =2 ; + +if (adev->asic_type ==CHIP_ALDEBARAN ) + offset =0 ;if (!is_fru_eeprom_supported (adev))return 0 ;
@@ -139,7 +145,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) len =sizeof (adev->product_name) -1 ; }/* Start at 2 due to buff using fields 0 and 1 for the address */ -memcpy (adev->product_name, &buff[2 ], len); +memcpy (adev->product_name, &buff[offset], len); adev->product_name[len] ='\0' ; addrptr += size +1 ;
@@ -157,7 +163,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)DRM_WARN ("FRU Product Number is larger than 16 characters. This is likely a mistake" ); len =sizeof (adev->product_number) -1 ; } -memcpy (adev->product_number, &buff[2 ], len); +memcpy (adev->product_number, &buff[offset], len); adev->product_number[len] ='\0' ; addrptr += size +1 ;
@@ -184,7 +190,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)DRM_WARN ("FRU Serial Number is larger than 16 characters. This is likely a mistake" ); len =sizeof (adev->serial) -1 ; } -memcpy (adev->serial, &buff[2 ], len); +memcpy (adev->serial, &buff[offset], len); adev->serial[len] ='\0' ;return 0 ;
--
2.25.1
RE: [PATCH 4/4] drm/amdgpu: Access the FRU on Aldebaran
I'm not aware of any Aldebaran SKUs that don't have the FRU, but I can look into it before submitting this patch.
Kent
Quoted 123 lines
-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Monday, December 13, 2021 10:39 PM
To: Chen, Guchun <[email protected]>; Russell, Kent <[email protected]>; [email protected]
Cc: Russell, Kent <[email protected]>
Subject: RE: [PATCH 4/4] drm/amdgpu: Access the FRU on Aldebaran[Public]
BTW, does FRU exists on all the Aldebaran SKUs?
This patch acks FRU's presence when it's Aldebaran. So if some Aldebaran SKUs do not have a FRU, some i2c access failures will be observed during boot up. This is not friendly to user.
Please check Vega20 case we talked before, and there are some more strict checks for FRU on several Vega20 SKUs.
case
CHIP_VEGA20:/* D161 and D163 are the VG20 server SKUs */ if (strnstr(atom_ctx->vbios_version, "D161", sizeof(atom_ctx->vbios_version)) || strnstr(atom_ctx->vbios_version, "D163", sizeof(atom_ctx->vbios_version))) return true; else return false;Regards,
Guchun-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Chen, Guchun
Sent: Tuesday, December 14, 2021 11:17 AM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Russell, Kent <[email protected]>
Subject: RE: [PATCH 4/4] drm/amdgpu: Access the FRU on Aldebaran[Public]
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +2
-0+if (adev->asic_type ==CHIP_ALDEBARAN ) + offset =0 ;if (!is_fru_eeprom_supported (adev))return 0 ;I assume the logic should be adjusted. It's better to put the
asic_typecheck afteris_fru_eeprom_supported.Regards,
Guchun-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kent Russell
Sent: Tuesday, December 14, 2021 3:34 AM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu: Access the FRU on AldebaranThis is supported, although the offset is different from VG20, so fix that with a variable and enable getting the product name and serial number from the FRU.
Signed-off-by Kent Russell <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +8
-2@@ -56,6 +56,8 @@ static bool is_fru_eeprom_supported(struct amdgpu_device *adev)return true; else return false; +case CHIP_ALDEBARAN : +return true;default :return false; }@@ -91,6 +93,10 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)unsigned char buff[66 ];u32 addrptr;int size, len; +int offset =2 ; + +if (adev->asic_type ==CHIP_ALDEBARAN ) + offset =0 ;if (!is_fru_eeprom_supported (adev))return 0 ;@@ -139,7 +145,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) len =sizeof (adev->product_name) -1 ; }/* Start at 2 due to buff using fields 0 and 1 for the address */ -memcpy (adev->product_name, &buff[2 ], len); +memcpy (adev->product_name, &buff[offset], len); adev->product_name[len] ='\0' ; addrptr += size +1 ;@@ -157,7 +163,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) DRM_WARN("FRU Product Number is larger than 16 characters. This is likely a mistake"); len = sizeof(adev->product_number) - 1; } -memcpy (adev->product_number, &buff[2 ], len); +memcpy (adev->product_number, &buff[offset], len); adev->product_number[len] ='\0' ;drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +1
-1addrptr += size +1 ;@@ -184,7 +190,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)DRM_WARN ("FRU Serial Number is larger than 16 characters. This is likely a mistake"); len =sizeof (adev->serial) -1 ; } -memcpy (adev->serial, &buff[2 ], len); +memcpy (adev->serial, &buff[offset], len); adev->serial[len] ='\0' ;return 0;
--
2.25.1
[Public]
How about set a define like PRODUCT_NAME_LEN to be 64, and use it in FRU code? In this case, if it needs to bump string length of product name later on, it will be simple.
#define PRODUCT_NAME_LEN 64
unsigned char buff[PRODUCT_NAME_LEN + 2];
Regards,
Guchun
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kent Russell
Sent: Tuesday, December 14, 2021 3:34 AM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH 1/4] drm/amdgpu: Increase potential product_name to 64 characters
Having seen at least 1 42-character product_name, bump the number up to 64.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
@@ -1083,7 +1083,7 @@ struct amdgpu_device {/* Chip product information */ char product_number[16 ]; -char product_name[32 ]; +char product_name[64 ];char serial[20 ];atomic_t throttling_logging_enabled;
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +5 -4
@@ -88,7 +88,7 @@ static int amdgpu_fru_read_eeprom(struct amdgpu_device *adev, uint32_t addrptr,int amdgpu_fru_get_product_info (struct amdgpu_device *adev) { -unsigned char buff[34 ]; +unsigned char buff[66 ];u32 addrptr;int size, len;
@@ -131,11 +131,11 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) } len = size; -/* Product name should only be 32 characters. Any more, -* and something could be wrong. Cap it at 32 to be safe +/* Product name should logically be < 64 characters. Any more, +* and something could be wrong. Cap it at 64 to be safe */ if (len >=sizeof (adev->product_name)) { -DRM_WARN ("FRU Product Number is larger than 32 characters. This is likely a mistake" ); + DRM_WARN("FRU Product Name is larger than 64 characters. This is +likely a mistake"); len = sizeof(adev->product_name) - 1; }
/* Start at 2 due to buff using fields 0 and 1 for the address */
--
2.25.1
Yeah that would make things a little clearer, and make it easier to change going forward. Thanks!
Kent
Quoted 81 lines
-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Monday, December 13, 2021 10:33 PM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Russell, Kent <[email protected]>
Subject: RE: [PATCH 1/4] drm/amdgpu: Increase potentialproduct_nameto 64 characters[Public]
How about set a define like
PRODUCT_NAME_LENto be 64, and use it in FRU code? In this case, if it needs to bump string length of product name later on, it will be simple.#define
PRODUCT_NAME_LEN64unsigned char buff[PRODUCT_NAME_LEN + 2];
Regards,
Guchun-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kent Russell
Sent: Tuesday, December 14, 2021 3:34 AM
To: [email protected]
Cc: Russell, Kent <[email protected]>
Subject: [PATCH 1/4] drm/amdgpu: Increase potentialproduct_nameto 64 charactersHaving seen at least 1 42-character
product_name, bump the number up to 64.Signed-off-by Kent Russell <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-1@@ -1083,7 +1083,7 @@ struct amdgpu_device {/* Chip product information */ char product_number[16 ]; -char product_name[32 ]; +char product_name[64 ];char serial[20 ];atomic_t throttling_logging_enabled;drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +5
-5@@ -88,7 +88,7 @@ static int amdgpu_fru_read_eeprom(struct amdgpu_device *adev,uint32_t addrptr, int amdgpu_fru_get_product_info(struct amdgpu_device *adev) { - unsigned char buff[34]; + unsigned char buff[66];u32 addrptr;int size, len;@@ -131,11 +131,11 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) } len = size; -/* Product name should only be 32 characters. Any more, -* and something could be wrong. Cap it at 32 to be safe +/* Product name should logically be < 64 characters. Any more, +* and something could be wrong. Cap it at 64 to be safe */ if (len >=sizeof (adev->product_name)) { - DRM_WARN("FRU Product Number is larger than 32 characters. This is likely a mistake"); + DRM_WARN("FRU Product Name is larger than 64 characters. This is +likely a mistake"); len = sizeof(adev->product_name) - 1; }/* Start at 2 due to buff using fields 0 and 1 for the address */ --2.25.1