Skip to content

Commit d1c234e

Browse files
fxkamdalexdeucher
authored andcommitted
drm/amdkfd: Allow building KFD on ARM64 (v2)
ifdef x86_64 specific code. Allow enabling CONFIG_HSA_AMD on ARM64. v2: Fixed a compiler warning due to an unused variable CC: Mark Nutter <Mark.Nutter@arm.com> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Tested-by: Mark Nutter <Mark.Nutter@arm.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent e2d3c41 commit d1c234e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

drivers/gpu/drm/amd/amdkfd/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
config HSA_AMD
66
bool "HSA kernel driver for AMD GPU devices"
7-
depends on DRM_AMDGPU && X86_64
8-
imply AMD_IOMMU_V2
7+
depends on DRM_AMDGPU && (X86_64 || ARM64)
8+
imply AMD_IOMMU_V2 if X86_64
99
select MMU_NOTIFIER
1010
help
1111
Enable this if you want to use HSA features on AMD GPU devices.

drivers/gpu/drm/amd/amdkfd/kfd_crat.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size,
863863
return 0;
864864
}
865865

866+
#if CONFIG_X86_64
866867
static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
867868
uint32_t *num_entries,
868869
struct crat_subtype_iolink *sub_type_hdr)
@@ -905,6 +906,7 @@ static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
905906

906907
return 0;
907908
}
909+
#endif
908910

909911
/* kfd_create_vcrat_image_cpu - Create Virtual CRAT for CPU
910912
*
@@ -920,7 +922,9 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
920922
struct crat_subtype_generic *sub_type_hdr;
921923
int avail_size = *size;
922924
int numa_node_id;
925+
#ifdef CONFIG_X86_64
923926
uint32_t entries = 0;
927+
#endif
924928
int ret = 0;
925929

926930
if (!pcrat_image || avail_size < VCRAT_SIZE_FOR_CPU)
@@ -982,6 +986,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
982986
sub_type_hdr->length);
983987

984988
/* Fill in Subtype: IO Link */
989+
#ifdef CONFIG_X86_64
985990
ret = kfd_fill_iolink_info_for_cpu(numa_node_id, &avail_size,
986991
&entries,
987992
(struct crat_subtype_iolink *)sub_type_hdr);
@@ -992,6 +997,9 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
992997

993998
sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
994999
sub_type_hdr->length * entries);
1000+
#else
1001+
pr_info("IO link not available for non x86 platforms\n");
1002+
#endif
9951003

9961004
crat_table->num_domains++;
9971005
}

drivers/gpu/drm/amd/amdkfd/kfd_topology.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,17 +1392,18 @@ int kfd_topology_enum_kfd_devices(uint8_t idx, struct kfd_dev **kdev)
13921392

13931393
static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask)
13941394
{
1395-
const struct cpuinfo_x86 *cpuinfo;
13961395
int first_cpu_of_numa_node;
13971396

13981397
if (!cpumask || cpumask == cpu_none_mask)
13991398
return -1;
14001399
first_cpu_of_numa_node = cpumask_first(cpumask);
14011400
if (first_cpu_of_numa_node >= nr_cpu_ids)
14021401
return -1;
1403-
cpuinfo = &cpu_data(first_cpu_of_numa_node);
1404-
1405-
return cpuinfo->apicid;
1402+
#ifdef CONFIG_X86_64
1403+
return cpu_data(first_cpu_of_numa_node).apicid;
1404+
#else
1405+
return first_cpu_of_numa_node;
1406+
#endif
14061407
}
14071408

14081409
/* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor

0 commit comments

Comments
 (0)