Skip to contentSkip to conversation

drm/amdgpu: fix the unit of the SR-IOV IP discovery size check

PATCH In review YuBiao Wang 1 participant 2 messages Sep 24 – Sep 29

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

PATCH 1/1 drm/amdgpu: fix the unit of the SR-IOV IP discovery size check

ip_discovery_size_in_kb is in KB but was compared against DISCOVERY_TMR_SIZE, a byte count, so the check never fired.

Compare both sides in KB against a new 16KB SR-IOV bound, since 10KB does not cover new ASICs which need 0x2840, and drop the duplicate check below.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c      | 11 ++---------
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +1 -0
index 6e1d55e78790..94964efa7dac 100644
@@ -28,6 +28,7 @@
 #include "discovery.h"
 
 #define DISCOVERY_TMR_SIZE      (10 << 10)
+#define DISCOVERY_TMR_SIZE_SRIOV (16 << 10)
 #define DISCOVERY_TMR_OFFSET    (64 << 10)
 
 struct ip_discovery_top;
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -9
index a454c6f12d38..73d9072f0c6c 100644
@@ -1115,7 +1115,8 @@ int amdgpu_virt_init_critical_region(struct amdgpu_device *adev)
 	/* Validation and initialization for each table entry */
 	if (IS_SRIOV_CRIT_REGN_ENTRY_VALID(init_data_hdr, AMD_SRIOV_MSG_IPD_TABLE_ID)) {
 		if (!init_data_hdr->ip_discovery_size_in_kb ||
-				init_data_hdr->ip_discovery_size_in_kb > DISCOVERY_TMR_SIZE) {
+				init_data_hdr->ip_discovery_size_in_kb >
+					(DISCOVERY_TMR_SIZE_SRIOV >> 10)) {
 			dev_err(adev->dev, "Invalid %s size: 0x%x\n",
 				amdgpu_virt_dynamic_crit_table_name[AMD_SRIOV_MSG_IPD_TABLE_ID],
 				init_data_hdr->ip_discovery_size_in_kb);
@@ -1189,14 +1190,6 @@ int amdgpu_virt_init_critical_region(struct amdgpu_device *adev)
 			init_data_hdr->bad_page_size_in_kb;
 	}
 
-	/* Validation for critical region info */
-	if (adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].size_kb > DISCOVERY_TMR_SIZE) {
-		dev_err(adev->dev, "Invalid IP discovery size: 0x%x\n",
-				adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].size_kb);
-		r = -EINVAL;
-		goto out;
-	}
-
 	/* reserved memory starts from crit region base offset with the size of 5MB */
 	amdgpu_ttm_init_vram_resv(adev, AMDGPU_RESV_FW_VRAM_USAGE,
 				  adev->virt.crit_regn.offset,
Signature · 1 line
2.34.1
#1 lore raw

Ping.

Quoted 54 lines · YuBiao Wang

ip_discovery_size_in_kb is in KB but was compared against DISCOVERY_TMR_SIZE, a byte count, so the check never fired.

Compare both sides in KB against a new 16KB SR-IOV bound, since 10KB does not cover new ASICs which need 0x2840, and drop the duplicate check below.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c      | 11 ++---------
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +1 -0
index 6e1d55e78790..94964efa7dac 100644
@@ -28,6 +28,7 @@
 #include "discovery.h"
 
 #define DISCOVERY_TMR_SIZE      (10 << 10)
+#define DISCOVERY_TMR_SIZE_SRIOV (16 << 10)
 #define DISCOVERY_TMR_OFFSET    (64 << 10)
 
 struct ip_discovery_top;
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +2 -9
index a454c6f12d38..73d9072f0c6c 100644
@@ -1115,7 +1115,8 @@ int amdgpu_virt_init_critical_region(struct amdgpu_device *adev)
 	/* Validation and initialization for each table entry */
 	if (IS_SRIOV_CRIT_REGN_ENTRY_VALID(init_data_hdr, AMD_SRIOV_MSG_IPD_TABLE_ID)) {
 		if (!init_data_hdr->ip_discovery_size_in_kb ||
-				init_data_hdr->ip_discovery_size_in_kb > DISCOVERY_TMR_SIZE) {
+				init_data_hdr->ip_discovery_size_in_kb >
+					(DISCOVERY_TMR_SIZE_SRIOV >> 10)) {
 			dev_err(adev->dev, "Invalid %s size: 0x%x\n",
 				amdgpu_virt_dynamic_crit_table_name[AMD_SRIOV_MSG_IPD_TABLE_ID],
 				init_data_hdr->ip_discovery_size_in_kb);
@@ -1189,14 +1190,6 @@ int amdgpu_virt_init_critical_region(struct amdgpu_device *adev)
 			init_data_hdr->bad_page_size_in_kb;
 	}
 
-	/* Validation for critical region info */
-	if (adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].size_kb > DISCOVERY_TMR_SIZE) {
-		dev_err(adev->dev, "Invalid IP discovery size: 0x%x\n",
-				adev->virt.crit_regn_tbl[AMD_SRIOV_MSG_IPD_TABLE_ID].size_kb);
-		r = -EINVAL;
-		goto out;
-	}
-
 	/* reserved memory starts from crit region base offset with the size of 5MB */
 	amdgpu_ttm_init_vram_resv(adev, AMDGPU_RESV_FW_VRAM_USAGE,
 				  adev->virt.crit_regn.offset,