Commit d1c234e2 authored by Felix Kuehling's avatar Felix Kuehling Committed by Alex Deucher

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: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Tested-by: default avatarMark Nutter <Mark.Nutter@arm.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e2d3c414
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
config HSA_AMD config HSA_AMD
bool "HSA kernel driver for AMD GPU devices" bool "HSA kernel driver for AMD GPU devices"
depends on DRM_AMDGPU && X86_64 depends on DRM_AMDGPU && (X86_64 || ARM64)
imply AMD_IOMMU_V2 imply AMD_IOMMU_V2 if X86_64
select MMU_NOTIFIER select MMU_NOTIFIER
help help
Enable this if you want to use HSA features on AMD GPU devices. Enable this if you want to use HSA features on AMD GPU devices.
...@@ -863,6 +863,7 @@ static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size, ...@@ -863,6 +863,7 @@ static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size,
return 0; return 0;
} }
#if CONFIG_X86_64
static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size, static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
uint32_t *num_entries, uint32_t *num_entries,
struct crat_subtype_iolink *sub_type_hdr) 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, ...@@ -905,6 +906,7 @@ static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
return 0; return 0;
} }
#endif
/* kfd_create_vcrat_image_cpu - Create Virtual CRAT for CPU /* kfd_create_vcrat_image_cpu - Create Virtual CRAT for CPU
* *
...@@ -920,7 +922,9 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size) ...@@ -920,7 +922,9 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
struct crat_subtype_generic *sub_type_hdr; struct crat_subtype_generic *sub_type_hdr;
int avail_size = *size; int avail_size = *size;
int numa_node_id; int numa_node_id;
#ifdef CONFIG_X86_64
uint32_t entries = 0; uint32_t entries = 0;
#endif
int ret = 0; int ret = 0;
if (!pcrat_image || avail_size < VCRAT_SIZE_FOR_CPU) 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) ...@@ -982,6 +986,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
sub_type_hdr->length); sub_type_hdr->length);
/* Fill in Subtype: IO Link */ /* Fill in Subtype: IO Link */
#ifdef CONFIG_X86_64
ret = kfd_fill_iolink_info_for_cpu(numa_node_id, &avail_size, ret = kfd_fill_iolink_info_for_cpu(numa_node_id, &avail_size,
&entries, &entries,
(struct crat_subtype_iolink *)sub_type_hdr); (struct crat_subtype_iolink *)sub_type_hdr);
...@@ -992,6 +997,9 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size) ...@@ -992,6 +997,9 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr + sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
sub_type_hdr->length * entries); sub_type_hdr->length * entries);
#else
pr_info("IO link not available for non x86 platforms\n");
#endif
crat_table->num_domains++; crat_table->num_domains++;
} }
......
...@@ -1392,7 +1392,6 @@ int kfd_topology_enum_kfd_devices(uint8_t idx, struct kfd_dev **kdev) ...@@ -1392,7 +1392,6 @@ int kfd_topology_enum_kfd_devices(uint8_t idx, struct kfd_dev **kdev)
static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask) static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask)
{ {
const struct cpuinfo_x86 *cpuinfo;
int first_cpu_of_numa_node; int first_cpu_of_numa_node;
if (!cpumask || cpumask == cpu_none_mask) if (!cpumask || cpumask == cpu_none_mask)
...@@ -1400,9 +1399,11 @@ static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask) ...@@ -1400,9 +1399,11 @@ static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask)
first_cpu_of_numa_node = cpumask_first(cpumask); first_cpu_of_numa_node = cpumask_first(cpumask);
if (first_cpu_of_numa_node >= nr_cpu_ids) if (first_cpu_of_numa_node >= nr_cpu_ids)
return -1; return -1;
cpuinfo = &cpu_data(first_cpu_of_numa_node); #ifdef CONFIG_X86_64
return cpu_data(first_cpu_of_numa_node).apicid;
return cpuinfo->apicid; #else
return first_cpu_of_numa_node;
#endif
} }
/* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor /* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment