diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdkfd/kfd_device.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_device.c | 267 |
1 files changed, 189 insertions, 78 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c index 4a416231b24c..0fffaf859c59 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c @@ -32,6 +32,7 @@ #include "amdgpu_amdkfd.h" #include "kfd_smi_events.h" #include "kfd_migrate.h" +#include "amdgpu.h" #define MQD_SIZE_ALIGNED 768 @@ -52,41 +53,6 @@ extern const struct kfd2kgd_calls aldebaran_kfd2kgd; extern const struct kfd2kgd_calls gfx_v10_kfd2kgd; extern const struct kfd2kgd_calls gfx_v10_3_kfd2kgd; -static const struct kfd2kgd_calls *kfd2kgd_funcs[] = { -#ifdef KFD_SUPPORT_IOMMU_V2 -#ifdef CONFIG_DRM_AMDGPU_CIK - [CHIP_KAVERI] = &gfx_v7_kfd2kgd, -#endif - [CHIP_CARRIZO] = &gfx_v8_kfd2kgd, - [CHIP_RAVEN] = &gfx_v9_kfd2kgd, -#endif -#ifdef CONFIG_DRM_AMDGPU_CIK - [CHIP_HAWAII] = &gfx_v7_kfd2kgd, -#endif - [CHIP_TONGA] = &gfx_v8_kfd2kgd, - [CHIP_FIJI] = &gfx_v8_kfd2kgd, - [CHIP_POLARIS10] = &gfx_v8_kfd2kgd, - [CHIP_POLARIS11] = &gfx_v8_kfd2kgd, - [CHIP_POLARIS12] = &gfx_v8_kfd2kgd, - [CHIP_VEGAM] = &gfx_v8_kfd2kgd, - [CHIP_VEGA10] = &gfx_v9_kfd2kgd, - [CHIP_VEGA12] = &gfx_v9_kfd2kgd, - [CHIP_VEGA20] = &gfx_v9_kfd2kgd, - [CHIP_RENOIR] = &gfx_v9_kfd2kgd, - [CHIP_ARCTURUS] = &arcturus_kfd2kgd, - [CHIP_ALDEBARAN] = &aldebaran_kfd2kgd, - [CHIP_NAVI10] = &gfx_v10_kfd2kgd, - [CHIP_NAVI12] = &gfx_v10_kfd2kgd, - [CHIP_NAVI14] = &gfx_v10_kfd2kgd, - [CHIP_SIENNA_CICHLID] = &gfx_v10_3_kfd2kgd, - [CHIP_NAVY_FLOUNDER] = &gfx_v10_3_kfd2kgd, - [CHIP_VANGOGH] = &gfx_v10_3_kfd2kgd, - [CHIP_DIMGREY_CAVEFISH] = &gfx_v10_3_kfd2kgd, - [CHIP_BEIGE_GOBY] = &gfx_v10_3_kfd2kgd, - [CHIP_YELLOW_CARP] = &gfx_v10_3_kfd2kgd, - [CHIP_CYAN_SKILLFISH] = &gfx_v10_kfd2kgd, -}; - #ifdef KFD_SUPPORT_IOMMU_V2 static const struct kfd_device_info kaveri_device_info = { .asic_family = CHIP_KAVERI, @@ -127,7 +93,6 @@ static const struct kfd_device_info carrizo_device_info = { .num_xgmi_sdma_engines = 0, .num_sdma_queues_per_engine = 2, }; -#endif static const struct kfd_device_info raven_device_info = { .asic_family = CHIP_RAVEN, @@ -147,7 +112,9 @@ static const struct kfd_device_info raven_device_info = { .num_xgmi_sdma_engines = 0, .num_sdma_queues_per_engine = 2, }; +#endif +#ifdef CONFIG_DRM_AMDGPU_CIK static const struct kfd_device_info hawaii_device_info = { .asic_family = CHIP_HAWAII, .asic_name = "hawaii", @@ -167,6 +134,7 @@ static const struct kfd_device_info hawaii_device_info = { .num_xgmi_sdma_engines = 0, .num_sdma_queues_per_engine = 2, }; +#endif static const struct kfd_device_info tonga_device_info = { .asic_family = CHIP_TONGA, @@ -653,63 +621,202 @@ static const struct kfd_device_info cyan_skillfish_device_info = { .num_sdma_queues_per_engine = 8, }; -/* For each entry, [0] is regular and [1] is virtualisation device. */ -static const struct kfd_device_info *kfd_supported_devices[][2] = { -#ifdef KFD_SUPPORT_IOMMU_V2 - [CHIP_KAVERI] = {&kaveri_device_info, NULL}, - [CHIP_CARRIZO] = {&carrizo_device_info, NULL}, -#endif - [CHIP_RAVEN] = {&raven_device_info, NULL}, - [CHIP_HAWAII] = {&hawaii_device_info, NULL}, - [CHIP_TONGA] = {&tonga_device_info, NULL}, - [CHIP_FIJI] = {&fiji_device_info, &fiji_vf_device_info}, - [CHIP_POLARIS10] = {&polaris10_device_info, &polaris10_vf_device_info}, - [CHIP_POLARIS11] = {&polaris11_device_info, NULL}, - [CHIP_POLARIS12] = {&polaris12_device_info, NULL}, - [CHIP_VEGAM] = {&vegam_device_info, NULL}, - [CHIP_VEGA10] = {&vega10_device_info, &vega10_vf_device_info}, - [CHIP_VEGA12] = {&vega12_device_info, NULL}, - [CHIP_VEGA20] = {&vega20_device_info, NULL}, - [CHIP_RENOIR] = {&renoir_device_info, NULL}, - [CHIP_ARCTURUS] = {&arcturus_device_info, &arcturus_device_info}, - [CHIP_ALDEBARAN] = {&aldebaran_device_info, &aldebaran_device_info}, - [CHIP_NAVI10] = {&navi10_device_info, NULL}, - [CHIP_NAVI12] = {&navi12_device_info, &navi12_device_info}, - [CHIP_NAVI14] = {&navi14_device_info, NULL}, - [CHIP_SIENNA_CICHLID] = {&sienna_cichlid_device_info, &sienna_cichlid_device_info}, - [CHIP_NAVY_FLOUNDER] = {&navy_flounder_device_info, &navy_flounder_device_info}, - [CHIP_VANGOGH] = {&vangogh_device_info, NULL}, - [CHIP_DIMGREY_CAVEFISH] = {&dimgrey_cavefish_device_info, &dimgrey_cavefish_device_info}, - [CHIP_BEIGE_GOBY] = {&beige_goby_device_info, &beige_goby_device_info}, - [CHIP_YELLOW_CARP] = {&yellow_carp_device_info, NULL}, - [CHIP_CYAN_SKILLFISH] = {&cyan_skillfish_device_info, NULL}, -}; - static int kfd_gtt_sa_init(struct kfd_dev *kfd, unsigned int buf_size, unsigned int chunk_size); static void kfd_gtt_sa_fini(struct kfd_dev *kfd); static int kfd_resume(struct kfd_dev *kfd); -struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, - struct pci_dev *pdev, unsigned int asic_type, bool vf) +struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, bool vf) { struct kfd_dev *kfd; const struct kfd_device_info *device_info; const struct kfd2kgd_calls *f2g; + struct amdgpu_device *adev = (struct amdgpu_device *)kgd; + struct pci_dev *pdev = adev->pdev; - if (asic_type >= sizeof(kfd_supported_devices) / (sizeof(void *) * 2) - || asic_type >= sizeof(kfd2kgd_funcs) / sizeof(void *)) { - dev_err(kfd_device, "asic_type %d out of range\n", asic_type); - return NULL; /* asic_type out of range */ + switch (adev->asic_type) { +#ifdef KFD_SUPPORT_IOMMU_V2 +#ifdef CONFIG_DRM_AMDGPU_CIK + case CHIP_KAVERI: + if (vf) + device_info = NULL; + else + device_info = &kaveri_device_info; + f2g = &gfx_v7_kfd2kgd; + break; +#endif + case CHIP_CARRIZO: + if (vf) + device_info = NULL; + else + device_info = &carrizo_device_info; + f2g = &gfx_v8_kfd2kgd; + break; +#endif +#ifdef CONFIG_DRM_AMDGPU_CIK + case CHIP_HAWAII: + if (vf) + device_info = NULL; + else + device_info = &hawaii_device_info; + f2g = &gfx_v7_kfd2kgd; + break; +#endif + case CHIP_TONGA: + if (vf) + device_info = NULL; + else + device_info = &tonga_device_info; + f2g = &gfx_v8_kfd2kgd; + break; + case CHIP_FIJI: + if (vf) + device_info = &fiji_vf_device_info; + else + device_info = &fiji_device_info; + f2g = &gfx_v8_kfd2kgd; + break; + case CHIP_POLARIS10: + if (vf) + device_info = &polaris10_vf_device_info; + else + device_info = &polaris10_device_info; + f2g = &gfx_v8_kfd2kgd; + break; + case CHIP_POLARIS11: + if (vf) + device_info = NULL; + else + device_info = &polaris11_device_info; + f2g = &gfx_v8_kfd2kgd; + break; + case CHIP_POLARIS12: + if (vf) + device_info = NULL; + else + device_info = &polaris12_device_info; + f2g = &gfx_v8_kfd2kgd; + break; + case CHIP_VEGAM: + if (vf) + device_info = NULL; + else + device_info = &vegam_device_info; + f2g = &gfx_v8_kfd2kgd; + break; + default: + switch (adev->ip_versions[GC_HWIP][0]) { + case IP_VERSION(9, 0, 1): + if (vf) + device_info = &vega10_vf_device_info; + else + device_info = &vega10_device_info; + f2g = &gfx_v9_kfd2kgd; + break; +#ifdef KFD_SUPPORT_IOMMU_V2 + case IP_VERSION(9, 1, 0): + case IP_VERSION(9, 2, 2): + if (vf) + device_info = NULL; + else + device_info = &raven_device_info; + f2g = &gfx_v9_kfd2kgd; + break; +#endif + case IP_VERSION(9, 2, 1): + if (vf) + device_info = NULL; + else + device_info = &vega12_device_info; + f2g = &gfx_v9_kfd2kgd; + break; + case IP_VERSION(9, 3, 0): + if (vf) + device_info = NULL; + else + device_info = &renoir_device_info; + f2g = &gfx_v9_kfd2kgd; + break; + case IP_VERSION(9, 4, 0): + if (vf) + device_info = NULL; + else + device_info = &vega20_device_info; + f2g = &gfx_v9_kfd2kgd; + break; + case IP_VERSION(9, 4, 1): + device_info = &arcturus_device_info; + f2g = &arcturus_kfd2kgd; + break; + case IP_VERSION(9, 4, 2): + device_info = &aldebaran_device_info; + f2g = &aldebaran_kfd2kgd; + break; + case IP_VERSION(10, 1, 10): + if (vf) + device_info = NULL; + else + device_info = &navi10_device_info; + f2g = &gfx_v10_kfd2kgd; + break; + case IP_VERSION(10, 1, 2): + device_info = &navi12_device_info; + f2g = &gfx_v10_kfd2kgd; + break; + case IP_VERSION(10, 1, 1): + if (vf) + device_info = NULL; + else + device_info = &navi14_device_info; + f2g = &gfx_v10_kfd2kgd; + break; + case IP_VERSION(10, 1, 3): + if (vf) + device_info = NULL; + else + device_info = &cyan_skillfish_device_info; + f2g = &gfx_v10_kfd2kgd; + break; + case IP_VERSION(10, 3, 0): + device_info = &sienna_cichlid_device_info; + f2g = &gfx_v10_3_kfd2kgd; + break; + case IP_VERSION(10, 3, 2): + device_info = &navy_flounder_device_info; + f2g = &gfx_v10_3_kfd2kgd; + break; + case IP_VERSION(10, 3, 1): + if (vf) + device_info = NULL; + else + device_info = &vangogh_device_info; + f2g = &gfx_v10_3_kfd2kgd; + break; + case IP_VERSION(10, 3, 4): + device_info = &dimgrey_cavefish_device_info; + f2g = &gfx_v10_3_kfd2kgd; + break; + case IP_VERSION(10, 3, 5): + device_info = &beige_goby_device_info; + f2g = &gfx_v10_3_kfd2kgd; + break; + case IP_VERSION(10, 3, 3): + if (vf) + device_info = NULL; + else + device_info = &yellow_carp_device_info; + f2g = &gfx_v10_3_kfd2kgd; + break; + default: + return NULL; + } + break; } - device_info = kfd_supported_devices[asic_type][vf]; - f2g = kfd2kgd_funcs[asic_type]; - if (!device_info || !f2g) { dev_err(kfd_device, "%s %s not supported in kfd\n", - amdgpu_asic_name[asic_type], vf ? "VF" : ""); + amdgpu_asic_name[adev->asic_type], vf ? "VF" : ""); return NULL; } @@ -916,6 +1023,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, kfd_double_confirm_iommu_support(kfd); if (kfd_iommu_device_init(kfd)) { + kfd->use_iommu_v2 = false; dev_err(kfd_device, "Error initializing iommuv2\n"); goto device_iommu_error; } @@ -924,6 +1032,9 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, svm_migrate_init((struct amdgpu_device *)kfd->kgd); + if(kgd2kfd_resume_iommu(kfd)) + goto device_iommu_error; + if (kfd_resume(kfd)) goto kfd_resume_error; |