Skip to contentSkip to conversation

drm/amdgpu: Fix static assertion failure issue

PATCH In review YiPeng Chai 3 participants 4 messages Feb 26 – Feb 27

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

PATCH 1/1 drm/amdgpu: Fix static assertion failure issue

Since the PAGE_SIZE is 8KB on sparc64, the size of structure amdsriov_ras_telemetry will exceed 64KB, so use absolute value to fix the buffer size.

Fixes the issue:
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:522:2: error: static assertion failed due to requirement 'sizeof(struct amdsriov_ras_telemetry) <= 64 << 10': amdsriov_ras_telemetry must be 64 KB | sizeof(struct amdsriov_ras_telemetry) <=

	AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10,
 drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:522:40: note:
	expression evaluates to '115616 <= 65536'
 |   sizeof(struct amdsriov_ras_telemetry) <=
	AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10,
Fixes cb48a6b2b61d ("drm/amd/ras: use dedicated memory as vf ras command buffer")
---
 drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h           | 5 +++--
 drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h +3 -2
index 4870c03627df..a841f342a3eb 100644
@@ -476,9 +476,10 @@ union amd_sriov_ras_host_push {
 	struct amd_sriov_ras_chk_criti chk_criti;
 };
 
-#define AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (PAGE_SIZE * 13)
+#define AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE 4096
+#define AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (4096 * 13)
 struct amd_sriov_uniras_shared_mem {
-	uint8_t blocks_ecc_buf[PAGE_SIZE];
+	uint8_t blocks_ecc_buf[AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE];
 	uint8_t cmd_buf[AMD_SRIOV_UNIRAS_CMD_MAX_SIZE];
 };
 
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c +2 -2
index 3e8b500caec1..81553230dca4 100644
@@ -63,7 +63,7 @@ static int amdgpu_virt_ras_get_cmd_shared_mem(struct ras_core_context *ras_core,
 				ras_telemetry_offset);
 
 	if (cmd == RAS_CMD__GET_ALL_BLOCK_ECC_STATUS) {
-		if (mem_size > PAGE_SIZE)
+		if (mem_size > AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE)
 			return -ENOMEM;
 
 		shared_mem->cpu_addr = ras_telemetry_cpu->uniras_shared_mem.blocks_ecc_buf;
@@ -504,7 +504,7 @@ int amdgpu_virt_ras_hw_init(struct amdgpu_device *adev)
 	memset(blks_ecc, 0, sizeof(*blks_ecc));
 	if (amdgpu_virt_ras_get_cmd_shared_mem(ras_mgr->ras_core,
 			RAS_CMD__GET_ALL_BLOCK_ECC_STATUS,
-			PAGE_SIZE, &blks_ecc->shared_mem))
+			AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE, &blks_ecc->shared_mem))
 		return -ENOMEM;
 
 	return 0;
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Quoted 82 lines

-----Original Message-----
From: Chai, Thomas <[email protected]>
Sent: Thursday, February 26, 2026 7:50 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Zhou1, Tao <[email protected]>; Li, Candice <[email protected]>; Yang, Stanley <[email protected]>; Su, Joe <[email protected]>; Chai, Thomas <[email protected]>; kernel test robot <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix static assertion failure issue

Since the PAGE_SIZE is 8KB on sparc64, the size of structure amdsriov_ras_telemetry will exceed 64KB, so use absolute value to fix the buffer size.

Fixes the issue:
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:522:2: error: static assertion failed
due to requirement 'sizeof(struct
amdsriov_ras_telemetry) <= 64 << 10': amdsriov_ras_telemetry must be 64 KB |
sizeof(struct amdsriov_ras_telemetry) <=

      AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10,
 drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:522:40: note:
      expression evaluates to '115616 <= 65536'
 |   sizeof(struct amdsriov_ras_telemetry) <=
      AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10,
Fixes cb48a6b2b61d ("drm/amd/ras: use dedicated memory as vf ras command

buffer")

---
 drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h           | 5 +++--
 drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h +3 -2
index 4870c03627df..a841f342a3eb 100644
@@ -476,9 +476,10 @@ union amd_sriov_ras_host_push {
      struct amd_sriov_ras_chk_criti chk_criti;  };
 
-#define AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (PAGE_SIZE * 13)
+#define AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE 4096 #define
+AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (4096 * 13)
 struct amd_sriov_uniras_shared_mem {
-     uint8_t blocks_ecc_buf[PAGE_SIZE];
+     uint8_t blocks_ecc_buf[AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE];
      uint8_t cmd_buf[AMD_SRIOV_UNIRAS_CMD_MAX_SIZE];
 };
 
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c +1 -1
index 3e8b500caec1..81553230dca4 100644
@@ -63,7 +63,7 @@ static int amdgpu_virt_ras_get_cmd_shared_mem(struct
 ras_core_context *ras_core,
                              ras_telemetry_offset);
 
      if (cmd == RAS_CMD__GET_ALL_BLOCK_ECC_STATUS) {
-             if (mem_size > PAGE_SIZE)
+             if (mem_size > AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE)
                      return -ENOMEM;
 
              shared_mem->cpu_addr = ras_telemetry_cpu-
Quoted 1 line

uniras_shared_mem.blocks_ecc_buf;

drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c +1 -1
@@ -504,7 +504,7 @@ int amdgpu_virt_ras_hw_init(struct amdgpu_device *adev)
      memset(blks_ecc, 0, sizeof(*blks_ecc));
      if (amdgpu_virt_ras_get_cmd_shared_mem(ras_mgr->ras_core,
                      RAS_CMD__GET_ALL_BLOCK_ECC_STATUS,
-                     PAGE_SIZE, &blks_ecc->shared_mem))
+                     AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE, &blks_ecc-
 >shared_mem))
              return -ENOMEM;
 
      return 0;

--
2.43.0

Tested-by on v1 1/1
#2 lore raw
In reply to YiPeng Chai
Quoted 19 lines · YiPeng Chai

Since the PAGE_SIZE is 8KB on sparc64, the size of structure amdsriov_ras_telemetry will exceed 64KB, so use absolute value to fix the buffer size.

Fixes the issue:
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:522:2: error: static assertion failed due to requirement 'sizeof(struct amdsriov_ras_telemetry) <= 64 << 10': amdsriov_ras_telemetry must be 64 KB | sizeof(struct amdsriov_ras_telemetry) <= AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10, drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:522:40: note:
expression evaluates to '115616 <= 65536'
| sizeof(struct amdsriov_ras_telemetry) <=
AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10,

Quoted 7 lines
Fixes cb48a6b2b61d ("drm/amd/ras: use dedicated memory as vf ras command buffer")

---

IBM CI has also reported the same issue, and tested this patch and it fixes the reported build issue.

Link to upstream report: https://lore.kernel.org/all/[email protected]/

Regards,
Venkat.

Quoted 46 lines

drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 5 +++--
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c | 4 ++--

2 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h +3 -2
index 4870c03627df..a841f342a3eb 100644
@@ -476,9 +476,10 @@ union amd_sriov_ras_host_push {
 struct amd_sriov_ras_chk_criti chk_criti;
 };
 
-#define AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (PAGE_SIZE * 13)
+#define AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE 4096
+#define AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (4096 * 13)
 struct amd_sriov_uniras_shared_mem {
- uint8_t blocks_ecc_buf[PAGE_SIZE];
+ uint8_t blocks_ecc_buf[AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE];
 uint8_t cmd_buf[AMD_SRIOV_UNIRAS_CMD_MAX_SIZE];
 };
 
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c +2 -2
index 3e8b500caec1..81553230dca4 100644
@@ -63,7 +63,7 @@ static int amdgpu_virt_ras_get_cmd_shared_mem(struct ras_core_context *ras_core,
 ras_telemetry_offset);
 
 if (cmd == RAS_CMD__GET_ALL_BLOCK_ECC_STATUS) {
- if (mem_size > PAGE_SIZE)
+ if (mem_size > AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE)
 return -ENOMEM;
 
 shared_mem->cpu_addr = ras_telemetry_cpu->uniras_shared_mem.blocks_ecc_buf;
@@ -504,7 +504,7 @@ int amdgpu_virt_ras_hw_init(struct amdgpu_device *adev)
 memset(blks_ecc, 0, sizeof(*blks_ecc));
 if (amdgpu_virt_ras_get_cmd_shared_mem(ras_mgr->ras_core,
 RAS_CMD__GET_ALL_BLOCK_ECC_STATUS,
- PAGE_SIZE, &blks_ecc->shared_mem))
+ AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE, &blks_ecc->shared_mem))
 return -ENOMEM;
 
 return 0;
Signature · 1 line
2.43.0
Tested-by on v1 1/1
#3 lore raw
In reply to YiPeng Chai
Quoted 19 lines · YiPeng Chai

Since the PAGE_SIZE is 8KB on sparc64, the size of structure amdsriov_ras_telemetry will exceed 64KB, so use absolute value to fix the buffer size.

Fixes the issue:
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:522:2: error: static assertion failed due to requirement 'sizeof(struct amdsriov_ras_telemetry) <= 64 << 10': amdsriov_ras_telemetry must be 64 KB | sizeof(struct amdsriov_ras_telemetry) <= AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10, drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:522:40: note:
expression evaluates to '115616 <= 65536'
| sizeof(struct amdsriov_ras_telemetry) <=
AMD_SRIOV_MSG_RAS_TELEMETRY_SIZE_KB_V1 << 10,

Quoted 7 lines
Fixes cb48a6b2b61d ("drm/amd/ras: use dedicated memory as vf ras command buffer")

---

Resending. Looks like earlier response didn’t go through.

IBM CI has also reported the same issue, and tested this patch and it fixes the reported build issue.

Link to upstream report: https://lore.kernel.org/all/[email protected]/

Regards,
Venkat.

Quoted 46 lines

drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 5 +++--
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c | 4 ++--

2 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h +3 -2
index 4870c03627df..a841f342a3eb 100644
@@ -476,9 +476,10 @@ union amd_sriov_ras_host_push {
 struct amd_sriov_ras_chk_criti chk_criti;
 };
 
-#define AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (PAGE_SIZE * 13)
+#define AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE 4096
+#define AMD_SRIOV_UNIRAS_CMD_MAX_SIZE (4096 * 13)
 struct amd_sriov_uniras_shared_mem {
- uint8_t blocks_ecc_buf[PAGE_SIZE];
+ uint8_t blocks_ecc_buf[AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE];
 uint8_t cmd_buf[AMD_SRIOV_UNIRAS_CMD_MAX_SIZE];
 };
 
drivers/gpu/drm/amd/ras/ras_mgr/amdgpu_virt_ras_cmd.c +2 -2
index 3e8b500caec1..81553230dca4 100644
@@ -63,7 +63,7 @@ static int amdgpu_virt_ras_get_cmd_shared_mem(struct ras_core_context *ras_core,
 ras_telemetry_offset);
 
 if (cmd == RAS_CMD__GET_ALL_BLOCK_ECC_STATUS) {
- if (mem_size > PAGE_SIZE)
+ if (mem_size > AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE)
 return -ENOMEM;
 
 shared_mem->cpu_addr = ras_telemetry_cpu->uniras_shared_mem.blocks_ecc_buf;
@@ -504,7 +504,7 @@ int amdgpu_virt_ras_hw_init(struct amdgpu_device *adev)
 memset(blks_ecc, 0, sizeof(*blks_ecc));
 if (amdgpu_virt_ras_get_cmd_shared_mem(ras_mgr->ras_core,
 RAS_CMD__GET_ALL_BLOCK_ECC_STATUS,
- PAGE_SIZE, &blks_ecc->shared_mem))
+ AMD_SRIOV_UNIRAS_BLOCKS_BUF_SIZE, &blks_ecc->shared_mem))
 return -ENOMEM;
 
 return 0;
Signature · 1 line
2.43.0