Skip to contentSkip to conversation

drm/amdgpu: Use SKU instead of DID for FRU check

PATCH In review Kent Russell 2 participants 3 messages Sep 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Use SKU instead of DID for FRU check

The VG20 DIDs 66a0, 66a1 and 66a4 are used for various SKUs that may or may not have the FRU EEPROM on it. Parse the VBIOS to check for server SKU variants (D131 or D134) until a more general solution can be determined.

---
 .../gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c    | 37 +++++++++++++------
 1 file changed, 26 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +26 -11
index e811fecc540f..82207b758800 100644
@@ -34,18 +34,33 @@
 
 static bool is_fru_eeprom_supported(struct amdgpu_device *adev)
 {
-	/* TODO: Gaming SKUs don't have the FRU EEPROM.
-	 * Use this hack to address hangs on modprobe on gaming SKUs
-	 * until a proper solution can be implemented by only supporting
-	 * the explicit chip IDs for VG20 Server cards
-	 *
-	 * TODO: Add list of supported Arcturus DIDs once confirmed
+	/* TODO: See if we can figure this out dynamically instead of
+	 * having to parse VBIOS versions.
 	 */
-	if ((adev->asic_type == CHIP_VEGA20 && adev->pdev->device == 0x66a0) ||
-	    (adev->asic_type == CHIP_VEGA20 && adev->pdev->device == 0x66a1) ||
-	    (adev->asic_type == CHIP_VEGA20 && adev->pdev->device == 0x66a4))
-		return true;
-	return false;
+	struct atom_context *atom_ctx = adev->mode_info.atom_context;
+	char model[3];
+	int modelnum;
+
+	/* VBIOS is of the format ###-DXXXXYY-XX. We only want the first
+	 * 3 digits after the D, and if we convert it to a hex integer,
+	 * we can use switch for ease/speed/readability and potential
+	 * expandability if required
+	 */
+	strncpy(model, atom_ctx->vbios_version + 5, 3);
+	modelnum = strtoul(model, NULL, 16);
+	switch (adev->asic_type) {
+	case CHIP_VEGA20:
+		switch (modelnum) {
+		/* These are the server VG20 SKUs */
+		case 0x161:
+		case 0x163:
+			return true;
+		default:
+			return false;
+		}
+	default:
+		return false;
+	}
 }
 
 static int amdgpu_fru_read_eeprom(struct amdgpu_device *adev, uint32_t addrptr,
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

Am 2020-09-29 um 7:31 a.m. schrieb Kent Russell:

Quoted 26 lines

The VG20 DIDs 66a0, 66a1 and 66a4 are used for various SKUs that may or may not have the FRU EEPROM on it. Parse the VBIOS to check for server SKU variants (D131 or D134) until a more general solution can be determined.

---
 .../gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c    | 37 +++++++++++++------
 1 file changed, 26 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +2 -6
index e811fecc540f..82207b758800 100644
@@ -34,18 +34,33 @@
 
 static bool is_fru_eeprom_supported(struct amdgpu_device *adev)
 {
-	/* TODO: Gaming SKUs don't have the FRU EEPROM.
-	 * Use this hack to address hangs on modprobe on gaming SKUs
-	 * until a proper solution can be implemented by only supporting
-	 * the explicit chip IDs for VG20 Server cards
-	 *
-	 * TODO: Add list of supported Arcturus DIDs once confirmed
+	/* TODO: See if we can figure this out dynamically instead of
+	 * having to parse VBIOS versions.
 	 */

drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c line 44

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +5 -5
-	if ((adev->asic_type == CHIP_VEGA20 && adev->pdev->device == 0x66a0) ||
-	    (adev->asic_type == CHIP_VEGA20 && adev->pdev->device == 0x66a1) ||
-	    (adev->asic_type == CHIP_VEGA20 && adev->pdev->device == 0x66a4))
-		return true;
-	return false;
+	struct atom_context *atom_ctx = adev->mode_info.atom_context;
+	char model[3];
+	int modelnum;
+
+	/* VBIOS is of the format ###-DXXXXYY-XX. We only want the first

I'm not sure I understand the format here. There are four X, but you only want the first three of them?

What are the two X in the end? are they related to the first four X?

drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c line 49

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +5 -0
+	 * 3 digits after the D, and if we convert it to a hex integer,
+	 * we can use switch for ease/speed/readability and potential
+	 * expandability if required
+	 */
+	strncpy(model, atom_ctx->vbios_version + 5, 3);

This produces a string in _model_ that's not 0-terminated.

drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c line 50

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +1 -0
+	modelnum = strtoul(model, NULL, 16);

Using strtoul on a non-terminated string is not reliable.

Regards,
  Felix

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +6 -0
+	switch (adev->asic_type) {
+	case CHIP_VEGA20:
+		switch (modelnum) {
+		/* These are the server VG20 SKUs */
+		case 0x161:
+		case 0x163:

drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c line 66

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +7 -0
+			return true;
+		default:
+			return false;
+		}
+	default:
+		return false;
+	}
 }
 
 static int amdgpu_fru_read_eeprom(struct amdgpu_device *adev, uint32_t addrptr,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw

[AMD Public Use]

Quoted 49 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, September 29, 2020 10:37 AM
To: Russell, Kent <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Use SKU instead of DID for FRU check

Am 2020-09-29 um 7:31 a.m. schrieb Kent Russell:

Review

Quoted 10 lines

The VG20 DIDs 66a0, 66a1 and 66a4 are used for various SKUs that may or may not have the FRU EEPROM on it. Parse the VBIOS to check for server SKU variants (D131 or D134) until a more general solution can be determined.

---
 .../gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c    | 37 +++++++++++++------
 1 file changed, 26 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c

Quoted 16 lines

index e811fecc540f..82207b758800 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +2 -6
@@ -34,18 +34,33 @@
 
 static bool is_fru_eeprom_supported(struct amdgpu_device *adev)
 {
-	/* TODO: Gaming SKUs don't have the FRU EEPROM.
-	 * Use this hack to address hangs on modprobe on gaming SKUs
-	 * until a proper solution can be implemented by only supporting
-	 * the explicit chip IDs for VG20 Server cards
-	 *
-	 * TODO: Add list of supported Arcturus DIDs once confirmed
+	/* TODO: See if we can figure this out dynamically instead of
+	 * having to parse VBIOS versions.
 	 */

drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c line 44

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +5 -5
-	if ((adev->asic_type == CHIP_VEGA20 && adev->pdev->device == 0x66a0) ||
-	    (adev->asic_type == CHIP_VEGA20 && adev->pdev->device == 0x66a1) ||
-	    (adev->asic_type == CHIP_VEGA20 && adev->pdev->device == 0x66a4))
-		return true;
-	return false;
+	struct atom_context *atom_ctx = adev->mode_info.atom_context;
+	char model[3];
+	int modelnum;
+
+	/* VBIOS is of the format ###-DXXXXYY-XX. We only want the first

I'm not sure I understand the format here. There are four X, but you only want the first three of them?

Quoted 1 line

What are the two X in the end? are they related to the first four X?

I tried to edit it but made a mistake, it seems. It should be ###-DXXXYY-ZZ . And the last 2 are unrelated, they're for further differentiation.

Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c line 49

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +5 -0
+	 * 3 digits after the D, and if we convert it to a hex integer,
+	 * we can use switch for ease/speed/readability and potential
+	 * expandability if required
+	 */
+	strncpy(model, atom_ctx->vbios_version + 5, 3);

This produces a string in _model_ that's not 0-terminated.

Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c line 50

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +1 -0
+	modelnum = strtoul(model, NULL, 16);

Using strtoul on a non-terminated string is not reliable.

Right! Thanks, I'll clean that up.

Quoted 20 lines

Regards,
  Felix

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +13 -0
+	switch (adev->asic_type) {
+	case CHIP_VEGA20:
+		switch (modelnum) {
+		/* These are the server VG20 SKUs */
+		case 0x161:
+		case 0x163:
+			return true;
+		default:
+			return false;
+		}
+	default:
+		return false;
+	}
 }
 
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c line 66

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +0 -0
 static int amdgpu_fru_read_eeprom(struct amdgpu_device *adev, uint32_t addrptr,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx