drm/amdkfd: Initialize kfd_gpu_cache_info for KFD topology
Subsystems (3)
PATCH 1/1 drm/amdkfd: Initialize kfd_gpu_cache_info for KFD topology
The current kfd_gpu_cache_info structure is only partially filled in for some architectures. This means that for devices where we do not fill in some fields, we can returned uninitialized values through the KFD topology. Zero out the kfd_gpu_cache_info before asking the remaining fields to be filled in by lower-level functions.
--- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -0
@@ -1707,6 +1707,7 @@ static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct gpu_processor_id = dev->node_props.simd_id_base; +memset (cache_info,0 ,sizeof (struct kfd_gpu_cache_info ) *KFD_MAX_CACHE_TYPES ); pcache_info = cache_info; num_of_cache_types =kfd_get_gpu_cache_info (kdev, &pcache_info);if (!num_of_cache_types) {
Signature · 1 line
2.20.1
Felix Kuehling
maintainerQuoted 8 lines · Joseph Greathouse
The current
kfd_gpu_cache_infostructure is only partially filled in for some architectures. This means that for devices where we do not fill in some fields, we can returned uninitialized values through the KFD topology. Zero out thekfd_gpu_cache_infobefore asking the remaining fields to be filled in by lower-level functions.Signed-off-by Joseph Greathouse <[email protected]>
This fixes your previous patch "drm/amdkfd: Add cache line sizes to KFD topology". Alex, I think the previous patch hasn't gone upstream yet. Do you want a Fixes: tag or is is possible to squash this with Joe's previous patch before upstreaming?
One nit-pick below.
drivers/gpu/drm/amd/amdkfd/kfd_topology.c static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct · line 1710
Quoted 13 lines
--- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1
-0@@ -1707,6 +1707,7 @@ static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct gpu_processor_id = dev->node_props.simd_id_base; +memset (cache_info,0 ,sizeof (struct kfd_gpu_cache_info ) *KFD_MAX_CACHE_TYPES );
Just use sizeof(cache_info). No need to calculate the size of the array and risk getting it wrong.
Regards,
Felix
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +0
-0pcache_info = cache_info; num_of_cache_types =kfd_get_gpu_cache_info (kdev, &pcache_info);if (!num_of_cache_types) {
Deucher, Alexander
maintainer[AMD Official Use Only - General]
Quoted 18 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Tuesday, February 6, 2024 4:15 PM
To: Greathouse, Joseph <[email protected]>; amd- [email protected]; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdkfd: Initializekfd_gpu_cache_infofor KFD topologyQuoted 7 lines · Joseph Greathouse
The current
kfd_gpu_cache_infostructure is only partially filled in for some architectures. This means that for devices where we do not fill in some fields, we can returned uninitialized values through the KFD topology.
Zero out thekfd_gpu_cache_infobefore asking the remaining fields to be filled in by lower-level functions.
Quoted 6 lines
Quoted 1 line
Signed-off-by Joseph Greathouse <[email protected]>This fixes your previous patch "drm/amdkfd: Add cache line sizes to KFD topology". Alex, I think the previous patch hasn't gone upstream yet. Do you want a Fixes: tag or is is possible to squash this with Joe's previous patch before upstreaming?
Either way. I can fix up the tag when we upstream or squash it.
Alex
Quoted 31 lines
One nit-pick below.
Quoted 14 lines
--- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdkfd/kfd_topology.c +0
-0@@ -1707,6 +1707,7 @@ static void kfd_fill_cache_non_crat_info(struct
kfd_topology_device*dev, structgpu_processor_id = dev->node_props.simd_id_base;drivers/gpu/drm/amd/amdkfd/kfd_topology.c
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +2
-0+memset (cache_info,0 ,sizeof (struct kfd_gpu_cache_info ) * +KFD_MAX_CACHE_TYPES );Just use
sizeof(cache_info). No need to calculate the size of the array and risk getting it wrong.Regards,
FelixQuoted 3 lines
pcache_info = cache_info; num_of_cache_types = kfd_get_gpu_cache_info(kdev, &pcache_info); if (!num_of_cache_types) {
PATCH v2 1/1 drm/amdkfd: Initialize kfd_gpu_cache_info for KFD topology
In reply to Felix KuehlingThe current kfd_gpu_cache_info structure is only partially filled in for some architectures. This means that for devices where we do not fill in some fields, we can returned uninitialized values through the KFD topology. Zero out the kfd_gpu_cache_info before asking the remaining fields to be filled in by lower-level functions.
--- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -0
@@ -1707,6 +1707,7 @@ static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct gpu_processor_id = dev->node_props.simd_id_base; +memset (cache_info,0 ,sizeof (cache_info)); pcache_info = cache_info; num_of_cache_types =kfd_get_gpu_cache_info (kdev, &pcache_info);if (!num_of_cache_types) {
Signature · 1 line
2.20.1
Quoted 9 lines · Joseph Greathouse
The current
kfd_gpu_cache_infostructure is only partially filled in for some architectures. This means that for devices where we do not fill in some fields, we can returned uninitialized values through the KFD topology. Zero out thekfd_gpu_cache_infobefore asking the remaining fields to be filled in by lower-level functions.Fixes 04756ac9a24c ("drm/amdkfd: Add cache line sizes to KFD topology")Signed-off-by Joseph Greathouse <[email protected]>
Quoted 16 lines
--- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1
-0@@ -1707,6 +1707,7 @@ static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct gpu_processor_id = dev->node_props.simd_id_base; +memset (cache_info,0 ,sizeof (cache_info)); pcache_info = cache_info; num_of_cache_types =kfd_get_gpu_cache_info (kdev, &pcache_info);if (!num_of_cache_types) {