[PATCH 65/66] drm/amdkfd: convert kfd_device.c to use GC IP version
Alex Deucher
alexdeucher at gmail.com
Wed Sep 22 01:44:36 UTC 2021
On Tue, Sep 21, 2021 at 5:00 PM <ernstp at gmail.com> wrote:
>
> tis 2021-09-21 klockan 14:07 -0400 skrev Alex Deucher:
> > rather than asic type.
> >
> > Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> > ---
> > drivers/gpu/drm/amd/amdkfd/kfd_device.c | 254 +++++++++++++++++-------
> > 1 file changed, 178 insertions(+), 76 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
> > index 9269b5e3aed1..25614a86b2c9 100644
> > --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
> > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
> > @@ -53,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,
> > @@ -654,38 +619,6 @@ 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);
> > @@ -698,21 +631,190 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, bool vf)
> > const struct kfd_device_info *device_info;
> > const struct kfd2kgd_calls *f2g;
> > struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
> > - unsigned int asic_type = adev->asic_type;
> > 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 = &kaveri_device_info;
>
> That should probably be carrizo. Found with W=1.
Thanks. Fixed locally.
Alex
>
> > + 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;
> > }
> >
> >
>
>
More information about the amd-gfx
mailing list