diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1680-drm-amdkfd-Remove-IOMMU_v2-dependency-AND-adaptions.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1680-drm-amdkfd-Remove-IOMMU_v2-dependency-AND-adaptions.patch | 378 |
1 files changed, 378 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1680-drm-amdkfd-Remove-IOMMU_v2-dependency-AND-adaptions.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1680-drm-amdkfd-Remove-IOMMU_v2-dependency-AND-adaptions.patch new file mode 100644 index 00000000..195d1978 --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1680-drm-amdkfd-Remove-IOMMU_v2-dependency-AND-adaptions.patch @@ -0,0 +1,378 @@ +From db2b4a3b1e90ebf4c1ef73aec66bc81e174f6625 Mon Sep 17 00:00:00 2001 +From: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com> +Date: Wed, 26 Apr 2017 12:28:21 -0500 +Subject: [PATCH 1680/4131] drm/amdkfd: Remove IOMMU_v2 dependency AND + adaptions + +Since some similar work has been done on hybrid dirver branch, this +commit introduced a lot of conflicts. We choose to discard the previous +adaptions and use the code from amd-kfd-staging branch. + +Change-Id: I47969d856db304d482fe640a26fdd1cb1257cb30 +Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com> +Signed-off-by: Yong Zhao <Yong.Zhao@amd.com> +--- + drivers/gpu/drm/amd/amdkfd/Kconfig | 2 +- + drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 12 +++++------- + drivers/gpu/drm/amd/amdkfd/kfd_device.c | 22 +++++++++++++++------- + drivers/gpu/drm/amd/amdkfd/kfd_events.c | 4 ++-- + drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 4 +++- + drivers/gpu/drm/amd/amdkfd/kfd_process.c | 16 ++++++++-------- + drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 ++ + drivers/gpu/drm/amd/amdkfd/kfd_topology.h | 2 +- + 8 files changed, 37 insertions(+), 27 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdkfd/Kconfig b/drivers/gpu/drm/amd/amdkfd/Kconfig +index ac49532..dc62fae 100644 +--- a/drivers/gpu/drm/amd/amdkfd/Kconfig ++++ b/drivers/gpu/drm/amd/amdkfd/Kconfig +@@ -4,7 +4,7 @@ + + config HSA_AMD + tristate "HSA kernel driver for AMD GPU devices" +- depends on (DRM_RADEON || DRM_AMDGPU) && AMD_IOMMU_V2 && X86_64 ++ depends on (DRM_RADEON || DRM_AMDGPU) && X86_64 + select DRM_AMDGPU_USERPTR + help + Enable this if you want to use HSA features on AMD GPU devices. +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +index e740ca6..ab35190 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +@@ -1,7 +1,7 @@ + #include <linux/kernel.h> + #include <linux/acpi.h> + #include <linux/mm.h> +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + #include <linux/amd-iommu.h> + #endif + #include <linux/pci.h> +@@ -121,7 +121,7 @@ static void kfd_populated_cu_info_cpu(struct kfd_topology_device *dev, + + dev->node_props.cpu_cores_count = cu->num_cpu_cores; + dev->node_props.cpu_core_id_base = cu->processor_id_low; +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + if (cu->hsa_capability & CRAT_CU_FLAGS_IOMMU_PRESENT) + dev->node_props.capability |= HSA_CAP_ATS_PRESENT; + #endif +@@ -1068,15 +1068,13 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image, + struct crat_subtype_generic *sub_type_hdr; + struct crat_subtype_computeunit *cu; + struct kfd_cu_info cu_info; +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) +- struct amd_iommu_device_info iommu_info; +-#endif + int avail_size = *size; + uint32_t total_num_of_cu; + int num_of_cache_entries = 0; + int cache_mem_filled = 0; + int ret = 0; +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) ++ struct amd_iommu_device_info iommu_info; + const u32 required_iommu_flags = AMD_IOMMU_DEVICE_FLAG_ATS_SUP | + AMD_IOMMU_DEVICE_FLAG_PRI_SUP | + AMD_IOMMU_DEVICE_FLAG_PASID_SUP; +@@ -1136,9 +1134,9 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image, + + cu->hsa_capability = 0; + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) + /* Check if this node supports IOMMU. During parsing this flag will + * translate to HSA_CAP_ATS_PRESENT */ ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + iommu_info.flags = 0; + if (0 == amd_iommu_device_info(kdev->pdev, &iommu_info)) { + if ((iommu_info.flags & required_iommu_flags) == required_iommu_flags) +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c +index b84dddb..5d657a9 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c +@@ -20,7 +20,7 @@ + * OTHER DEALINGS IN THE SOFTWARE. + */ + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + #include <linux/amd-iommu.h> + #endif + #include <linux/pci.h> +@@ -35,6 +35,7 @@ + + #define MQD_SIZE_ALIGNED 768 + ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + static const struct kfd_device_info kaveri_device_info = { + .asic_family = CHIP_KAVERI, + .max_pasid_bits = 16, +@@ -49,6 +50,7 @@ static const struct kfd_device_info kaveri_device_info = { + .supports_cwsr = false, + .needs_pci_atomics = false, + }; ++#endif + + static const struct kfd_device_info hawaii_device_info = { + .asic_family = CHIP_HAWAII, +@@ -65,6 +67,7 @@ static const struct kfd_device_info hawaii_device_info = { + .needs_pci_atomics = false, + }; + ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + static const struct kfd_device_info carrizo_device_info = { + .asic_family = CHIP_CARRIZO, + .max_pasid_bits = 16, +@@ -79,6 +82,7 @@ static const struct kfd_device_info carrizo_device_info = { + .supports_cwsr = true, + .needs_pci_atomics = false, + }; ++#endif + + static const struct kfd_device_info tonga_device_info = { + .asic_family = CHIP_TONGA, +@@ -170,6 +174,7 @@ struct kfd_deviceid { + */ + /* Please keep this sorted by increasing device id. */ + static const struct kfd_deviceid supported_devices[] = { ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + { 0x1304, &kaveri_device_info }, /* Kaveri */ + { 0x1305, &kaveri_device_info }, /* Kaveri */ + { 0x1306, &kaveri_device_info }, /* Kaveri */ +@@ -192,6 +197,7 @@ static const struct kfd_deviceid supported_devices[] = { + { 0x131B, &kaveri_device_info }, /* Kaveri */ + { 0x131C, &kaveri_device_info }, /* Kaveri */ + { 0x131D, &kaveri_device_info }, /* Kaveri */ ++#endif + { 0x67A0, &hawaii_device_info }, /* Hawaii */ + { 0x67A1, &hawaii_device_info }, /* Hawaii */ + { 0x67A2, &hawaii_device_info }, /* Hawaii */ +@@ -204,11 +210,13 @@ static const struct kfd_deviceid supported_devices[] = { + { 0x67B9, &hawaii_device_info }, /* Hawaii */ + { 0x67BA, &hawaii_device_info }, /* Hawaii */ + { 0x67BE, &hawaii_device_info }, /* Hawaii */ ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + { 0x9870, &carrizo_device_info }, /* Carrizo */ + { 0x9874, &carrizo_device_info }, /* Carrizo */ + { 0x9875, &carrizo_device_info }, /* Carrizo */ + { 0x9876, &carrizo_device_info }, /* Carrizo */ + { 0x9877, &carrizo_device_info }, /* Carrizo */ ++#endif + { 0x6920, &tonga_device_info }, /* Tonga */ + { 0x6921, &tonga_device_info }, /* Tonga */ + { 0x6928, &tonga_device_info }, /* Tonga */ +@@ -313,7 +321,7 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, + return kfd; + } + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + static bool device_iommu_pasid_init(struct kfd_dev *kfd) + { + const u32 required_iommu_flags = AMD_IOMMU_DEVICE_FLAG_ATS_SUP | +@@ -391,7 +399,7 @@ static int iommu_invalid_ppr_cb(struct pci_dev *pdev, int pasid, + + return AMD_IOMMU_INV_PRI_RSP_INVALID; + } +-#endif ++#endif /* CONFIG_AMD_IOMMU_V2 */ + + static int kfd_cwsr_init(struct kfd_dev *kfd) + { +@@ -549,7 +557,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, + goto device_queue_manager_error; + } + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + if (kfd->device_info->is_need_iommu_device) { + if (!device_iommu_pasid_init(kfd)) { + dev_err(kfd_device, +@@ -631,7 +639,7 @@ void kgd2kfd_suspend(struct kfd_dev *kfd) + + kfd->dqm->ops.stop(kfd->dqm); + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + if (!kfd->device_info->is_need_iommu_device) + return; + +@@ -658,7 +666,7 @@ static int kfd_resume(struct kfd_dev *kfd) + { + int err = 0; + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + if (kfd->device_info->is_need_iommu_device) { + unsigned int pasid_limit = kfd_get_pasid_limit(); + +@@ -689,7 +697,7 @@ static int kfd_resume(struct kfd_dev *kfd) + return err; + + dqm_start_error: +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + if (kfd->device_info->is_need_iommu_device) + amd_iommu_free_device(kfd->pdev); + #endif +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_events.c +index 2ff1a8e..be5abd5 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c +@@ -1031,7 +1031,7 @@ static void lookup_events_by_type_and_signal(struct kfd_process *p, + } + } + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + void kfd_signal_iommu_event(struct kfd_dev *dev, unsigned int pasid, + unsigned long address, bool is_write_requested, + bool is_execute_requested) +@@ -1101,7 +1101,7 @@ void kfd_signal_iommu_event(struct kfd_dev *dev, unsigned int pasid, + + kfd_unref_process(p); + } +-#endif ++#endif /* CONFIG_AMD_IOMMU_V2_MODULE */ + + void kfd_signal_hw_exception_event(unsigned int pasid) + { +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +index 798919b..a39c278 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +@@ -764,7 +764,7 @@ void kfd_unref_process(struct kfd_process *p); + + struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev, + struct kfd_process *p); +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + int kfd_bind_processes_to_device(struct kfd_dev *dev); + void kfd_unbind_processes_from_device(struct kfd_dev *dev); + #endif +@@ -1044,9 +1044,11 @@ int kfd_wait_on_events(struct kfd_process *p, + bool all, uint32_t user_timeout_ms, + enum kfd_event_wait_result *wait_result); + void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id, uint32_t valid_id_bits); ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + void kfd_signal_iommu_event(struct kfd_dev *dev, + unsigned int pasid, unsigned long address, + bool is_write_requested, bool is_execute_requested); ++#endif + void kfd_signal_hw_exception_event(unsigned int pasid); + int kfd_set_event(struct kfd_process *p, uint32_t event_id); + int kfd_reset_event(struct kfd_process *p, uint32_t event_id); +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c +index 3c0c40f..5343dad 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c +@@ -25,7 +25,7 @@ + #include <linux/sched.h> + #include <linux/sched/mm.h> + #include <linux/slab.h> +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + #include <linux/amd-iommu.h> + #endif + #include <linux/notifier.h> +@@ -368,6 +368,7 @@ static void kfd_process_wq_release(struct work_struct *work) + { + struct kfd_process *p = container_of(work, struct kfd_process, + release_work); ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + struct kfd_process_device *pdd; + + pr_debug("Releasing process (pasid %d)\n", +@@ -377,7 +378,6 @@ static void kfd_process_wq_release(struct work_struct *work) + pr_debug("Releasing pdd (topology id %d) for process (pasid %d)\n", + pdd->dev->id, p->pasid); + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) + if (pdd->dev->device_info->is_need_iommu_device) { + if (pdd->bound == PDD_BOUND) { + amd_iommu_unbind_pasid(pdd->dev->pdev, +@@ -385,8 +385,8 @@ static void kfd_process_wq_release(struct work_struct *work) + pdd->bound = PDD_UNBOUND; + } + } +-#endif + } ++#endif + + kfd_process_free_outstanding_kfd_bos(p); + +@@ -691,7 +691,6 @@ struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev, + struct kfd_process *p) + { + struct kfd_process_device *pdd; +- int err; + + pdd = kfd_get_process_device_data(dev, p); + if (!pdd) { +@@ -707,9 +706,10 @@ struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev, + return ERR_PTR(-EINVAL); + } + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + if (dev->device_info->is_need_iommu_device) { +- err = amd_iommu_bind_pasid(dev->pdev, p->pasid, p->lead_thread); ++ int err = amd_iommu_bind_pasid(dev->pdev, p->pasid, ++ p->lead_thread); + if (err < 0) + return ERR_PTR(err); + } +@@ -720,7 +720,7 @@ struct kfd_process_device *kfd_bind_process_to_device(struct kfd_dev *dev, + return pdd; + } + +-#if !defined(KFD_NO_IOMMU_V2_SUPPORT) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + int kfd_bind_processes_to_device(struct kfd_dev *dev) + { + struct kfd_process_device *pdd; +@@ -820,7 +820,7 @@ void kfd_process_iommu_unbind_callback(struct kfd_dev *dev, unsigned int pasid) + + kfd_unref_process(p); + } +-#endif ++#endif /* CONFIG_AMD_IOMMU_V2 */ + + struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p) + { +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +index c323782..1d1992f 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +@@ -942,6 +942,7 @@ static void find_system_memory(const struct dmi_header *dm, + */ + static int kfd_add_perf_to_topology(struct kfd_topology_device *kdev) + { ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + struct kfd_perf_properties *props; + + if (amd_iommu_pc_supported()) { +@@ -953,6 +954,7 @@ static int kfd_add_perf_to_topology(struct kfd_topology_device *kdev) + amd_iommu_pc_get_max_counters(0); /* assume one iommu */ + list_add_tail(&props->list, &kdev->perf_props); + } ++#endif + + return 0; + } +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.h b/drivers/gpu/drm/amd/amdkfd/kfd_topology.h +index 89d08c4..ae5edd9 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.h ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.h +@@ -193,7 +193,7 @@ struct kfd_topology_device *kfd_create_topology_device( + struct list_head *device_list); + void kfd_release_live_view(void); + +-#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 10, 0) ++#if defined(CONFIG_AMD_IOMMU_V2_MODULE) || defined(CONFIG_AMD_IOMMU_V2) + extern bool amd_iommu_pc_supported(void); + extern u8 amd_iommu_pc_get_max_banks(u16 devid); + extern u8 amd_iommu_pc_get_max_counters(u16 devid); +-- +2.7.4 + |