From f64af991f1ac6b2736d27952a6c18045a16d94bc Mon Sep 17 00:00:00 2001 From: Harish Kasiviswanathan Date: Wed, 26 Apr 2017 13:45:43 -0500 Subject: [PATCH 1270/4131] drm/amdkfd: Call ACPI only if platform supports Change-Id: I63049a0c831f36a3800a3021c253f2249b5c0610 Signed-off-by: Harish Kasiviswanathan --- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 14 ++++++++++++-- drivers/gpu/drm/amd/amdkfd/kfd_crat.h | 2 ++ drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c index e5a5574..99344e5 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -684,6 +684,7 @@ static int kfd_fill_gpu_cache_info(struct kfd_dev *kdev, * * Return 0 if successful else return -ve value */ +#ifdef CONFIG_ACPI int kfd_create_crat_image_acpi(void **crat_image, size_t *size) { struct acpi_table_header *crat_table; @@ -726,6 +727,7 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size) return 0; } +#endif /* Memory required to create Virtual CRAT. * Since there is no easy way to predict the amount of memory required, the @@ -875,13 +877,15 @@ static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size, static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size) { struct crat_header *crat_table = (struct crat_header *)pcrat_image; - struct acpi_table_header *acpi_table; - acpi_status status; struct crat_subtype_generic *sub_type_hdr; int avail_size = *size; int numa_node_id; uint32_t entries = 0; int ret = 0; +#ifdef CONFIG_ACPI + struct acpi_table_header *acpi_table; + acpi_status status; +#endif if (pcrat_image == NULL || avail_size < VCRAT_SIZE_FOR_CPU) return -EINVAL; @@ -897,6 +901,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size) memcpy(&crat_table->signature, CRAT_SIGNATURE, sizeof(crat_table->signature)); crat_table->length = sizeof(struct crat_header); +#ifdef CONFIG_ACPI status = acpi_get_table("DSDT", 0, &acpi_table); if (status == AE_NOT_FOUND) pr_warn("DSDT table not found for OEM information\n"); @@ -905,6 +910,11 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size) memcpy(crat_table->oem_id, acpi_table->oem_id, CRAT_OEMID_LENGTH); memcpy(crat_table->oem_table_id, acpi_table->oem_table_id, CRAT_OEMTABLEID_LENGTH); } +#else + crat_table->oem_revision = 0; + memcpy(crat_table->oem_id, "INV", CRAT_OEMID_LENGTH); + memcpy(crat_table->oem_table_id, "UNAVAIL", CRAT_OEMTABLEID_LENGTH); +#endif crat_table->total_entries = 0; crat_table->num_domains = 0; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h index 9af3745..f01aea2 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h @@ -308,7 +308,9 @@ struct cdit_header { #pragma pack() +#ifdef CONFIG_ACPI int kfd_create_crat_image_acpi(void **crat_image, size_t *size); +#endif void kfd_destroy_crat_image(void *crat_image); int kfd_parse_crat_table(void *crat_image, struct list_head *device_list, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c index 82a3960..f022cbc 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c @@ -972,6 +972,7 @@ static void kfd_add_non_crat_information(struct kfd_topology_device *kdev) /* TODO: For GPU node, rearrange code from kfd_topology_add_device */ } +#ifdef CONFIG_ACPI /* kfd_is_acpi_crat_invalid - CRAT from ACPI is valid only for AMD APU devices. * Ignore CRAT for all other devices. AMD APU is identified if both CPU * and GPU cores are present. @@ -998,6 +999,7 @@ static void kfd_delete_topology_device_list(struct list_head *device_list) list_for_each_entry_safe(dev, tmp, device_list, list) kfd_release_topology_device(dev); } +#endif int kfd_topology_init(void) { @@ -1036,6 +1038,7 @@ int kfd_topology_init(void) * NOTE: The current implementation expects all AMD APUs to have * CRAT. If no CRAT is available, it is assumed to be a CPU */ +#ifdef CONFIG_ACPI ret = kfd_create_crat_image_acpi(&crat_image, &image_size); if (ret == 0) { ret = kfd_parse_crat_table(crat_image, @@ -1051,7 +1054,7 @@ int kfd_topology_init(void) crat_image = NULL; } } - +#endif if (!crat_image) { ret = kfd_create_crat_image_virtual(&crat_image, &image_size, COMPUTE_UNIT_CPU, NULL, -- 2.7.4