]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device
authorMichael Chen <michael.chen@amd.com>
Fri, 3 May 2024 19:31:08 +0000 (15:31 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 8 May 2024 22:46:26 +0000 (18:46 -0400)
Currently oem_id is defined as uint8_t[6] and casted to uint64_t*
in some use case. This would lead code scanner to complain about
access beyond. Re-define it in union to enforce 8-byte size and
alignment to avoid potential issue.

Signed-off-by: Michael Chen <michael.chen@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_crat.h
drivers/gpu/drm/amd/amdkfd/kfd_topology.c
drivers/gpu/drm/amd/amdkfd/kfd_topology.h

index 300634b9f66832dfd4b83e2cf341fcfc75df9a3a..a8ca7ecb6d271b00554b855fa5546a0d60735670 100644 (file)
@@ -42,8 +42,6 @@
 #define CRAT_OEMTABLEID_LENGTH 8
 #define CRAT_RESERVED_LENGTH   6
 
-#define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1)
-
 /* Compute Unit flags */
 #define COMPUTE_UNIT_CPU       (1 << 0)  /* Create Virtual CRAT for CPU */
 #define COMPUTE_UNIT_GPU       (1 << 1)  /* Create Virtual CRAT for GPU */
index 197277ce57764e320cbcad8c023ea7d565a3fcc0..8b42f15a284745bc2aa7eec70283ba3985cfae2b 100644 (file)
@@ -958,8 +958,7 @@ static void kfd_update_system_properties(void)
        dev = list_last_entry(&topology_device_list,
                        struct kfd_topology_device, list);
        if (dev) {
-               sys_props.platform_id =
-                       (*((uint64_t *)dev->oem_id)) & CRAT_OEMID_64BIT_MASK;
+               sys_props.platform_id = dev->oem_id64;
                sys_props.platform_oem = *((uint64_t *)dev->oem_table_id);
                sys_props.platform_rev = dev->oem_revision;
        }
index 27386ce9a021dad9a15fb7d9ac38deb32f36e8f3..2d1c9d771bef2df57cbac276b151a7bb5fb766a4 100644 (file)
@@ -154,7 +154,10 @@ struct kfd_topology_device {
        struct attribute                attr_gpuid;
        struct attribute                attr_name;
        struct attribute                attr_props;
-       uint8_t                         oem_id[CRAT_OEMID_LENGTH];
+       union {
+               uint8_t                         oem_id[CRAT_OEMID_LENGTH];
+               uint64_t                        oem_id64;
+       };
        uint8_t                         oem_table_id[CRAT_OEMTABLEID_LENGTH];
        uint32_t                        oem_revision;
 };