AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexander.deucher@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>
Subject: [PATCH 63/64] drm/amdkfd: convert kfd_device.c to use GC IP version
Date: Tue, 28 Sep 2021 12:42:36 -0400	[thread overview]
Message-ID: <20210928164237.833132-64-alexander.deucher@amd.com> (raw)
In-Reply-To: <20210928164237.833132-1-alexander.deucher@amd.com>

rather than asic type.

v2: fix up CZ case

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@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 82af344cbf10..76ab22755ca3 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 = &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;
 	}
 
-- 
2.31.1


  parent reply	other threads:[~2021-09-28 16:46 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 16:41 [PATCH V2 00/64] Move to IP driven device enumeration Alex Deucher
2021-09-28 16:41 ` [PATCH 01/64] drm/amdgpu: move headless sku check into harvest function Alex Deucher
2021-09-28 16:41 ` [PATCH 02/64] drm/amdgpu: add debugfs access to the IP discovery table Alex Deucher
2021-09-28 16:41 ` [PATCH 03/64] drm/amdgpu: store HW IP versions in the driver structure Alex Deucher
2021-09-28 16:41 ` [PATCH 04/64] drm/amdgpu: fill in IP versions from IP discovery table Alex Deucher
2021-09-28 16:41 ` [PATCH 05/64] drm/amdgpu: add XGMI HWIP Alex Deucher
2021-09-28 16:41 ` [PATCH 06/64] drm/amdgpu/nv: export common IP functions Alex Deucher
2021-09-28 16:41 ` [PATCH 07/64] drm/amdgpu: add initial IP enumeration via IP discovery table Alex Deucher
2021-09-28 16:41 ` [PATCH 08/64] drm/amdgpu/sdma5.0: convert to IP version checking Alex Deucher
2021-09-28 16:41 ` [PATCH 09/64] drm/amdgpu/sdma5.2: " Alex Deucher
2021-09-28 16:41 ` [PATCH 10/64] drm/amdgpu/gfx10: " Alex Deucher
2021-09-28 16:41 ` [PATCH 11/64] drm/amdgpu: filter out radeon PCI device IDs Alex Deucher
2021-09-28 16:41 ` [PATCH 12/64] drm/amdgpu: bind to any 0x1002 PCI diplay class device Alex Deucher
2021-09-28 16:41 ` [PATCH 13/64] drm/amdgpu/gmc10.0: convert to IP version checking Alex Deucher
2021-09-28 16:41 ` [PATCH 14/64] drm/amdgpu: Use IP discovery to drive setting IP blocks by default Alex Deucher
2021-09-28 16:41 ` [PATCH 15/64] drm/amdgpu: drive nav10 from the IP discovery table Alex Deucher
2021-09-28 16:41 ` [PATCH 16/64] drm/amdgpu/gfxhub2.1: convert to IP version checking Alex Deucher
2021-09-28 16:41 ` [PATCH 17/64] drm/amdgpu/mmhub2.0: " Alex Deucher
2021-09-28 16:41 ` [PATCH 18/64] drm/amdgpu/mmhub2.1: " Alex Deucher
2021-09-28 16:41 ` [PATCH 19/64] drm/amdgpu/vcn3.0: " Alex Deucher
2021-09-28 16:41 ` [PATCH 20/64] drm/amdgpu/athub2.0: " Alex Deucher
2021-09-28 16:41 ` [PATCH 21/64] drm/amdgpu/athub2.1: " Alex Deucher
2021-09-28 16:41 ` [PATCH 22/64] drm/amdgpu/navi10_ih: " Alex Deucher
2021-09-28 16:41 ` [PATCH 23/64] drm/amdgpu/amdgpu_smu: " Alex Deucher
2021-09-28 16:41 ` [PATCH 24/64] drm/amdgpu/smu11.0: " Alex Deucher
2021-09-28 16:41 ` [PATCH 25/64] drm/amdgpu/navi10_ppt: " Alex Deucher
2021-09-28 16:41 ` [PATCH 26/64] drm/amdgpu/sienna_cichlid_ppt: " Alex Deucher
2021-09-28 16:42 ` [PATCH 27/64] drm/amdgpu/nv: " Alex Deucher
2021-09-29  9:16   ` Christian König
2021-09-28 16:42 ` [PATCH 28/64] drm/amdgpu: drive all navi asics from the IP discovery table Alex Deucher
2021-10-11 17:20   ` Mike Lothian
2021-10-11 17:35     ` Alex Deucher
2021-10-11 23:16       ` Mike Lothian
2021-09-28 16:42 ` [PATCH 29/64] drm/amdgpu/display/dm: convert to IP version checking Alex Deucher
2021-09-28 16:42 ` [PATCH 30/64] drm/amdgpu: add DCI HWIP Alex Deucher
2021-09-28 16:42 ` [PATCH 31/64] drm/amdgpu/soc15: export common IP functions Alex Deucher
2021-09-29  9:16   ` Christian König
2021-09-28 16:42 ` [PATCH 32/64] drm/amdgpu: add initial IP discovery support for vega based parts Alex Deucher
2021-09-28 16:42 ` [PATCH 33/64] drm/amdgpu/soc15: get rev_id in soc15_common_early_init Alex Deucher
2021-09-28 16:42 ` [PATCH 34/64] drm/amdgpu: drive all vega asics from the IP discovery table Alex Deucher
2021-09-28 16:42 ` [PATCH 35/64] drm/amdgpu: default to true in amdgpu_device_asic_has_dc_support Alex Deucher
2021-09-28 16:42 ` [PATCH 36/64] drm/amdgpu/display/dm: convert RAVEN to IP version checking Alex Deucher
2021-09-28 16:42 ` [PATCH 37/64] drm/amdgpu/sdma4.0: convert " Alex Deucher
2021-09-28 16:42 ` [PATCH 38/64] drm/amdgpu/hdp4.0: " Alex Deucher
2021-09-28 16:42 ` [PATCH 39/64] drm/amdgpu/gfx9.0: " Alex Deucher
2021-09-28 16:42 ` [PATCH 40/64] drm/amdgpu/amdgpu_psp: " Alex Deucher
2021-09-28 16:42 ` [PATCH 41/64] drm/amdgpu/psp_v11.0: " Alex Deucher
2021-09-28 16:42 ` [PATCH 42/64] drm/amdgpu/psp_v13.0: " Alex Deucher
2021-09-28 16:42 ` [PATCH 43/64] drm/amdgpu/pm/smu_v11.0: update " Alex Deucher
2021-09-28 16:42 ` [PATCH 44/64] drm/amdgpu/pm/smu_v13.0: convert " Alex Deucher
2021-09-28 16:42 ` [PATCH 45/64] drm/amdgpu/pm/amdgpu_smu: convert more " Alex Deucher
2021-09-28 16:42 ` [PATCH 46/64] drm/amdgpu/amdgpu_vcn: convert to " Alex Deucher
2021-09-28 16:42 ` [PATCH 47/64] drm/amdgpu/vcn2.5: " Alex Deucher
2021-09-28 16:42 ` [PATCH 48/64] drm/amdgpu/soc15: " Alex Deucher
2021-09-28 16:42 ` [PATCH 49/64] drm/amd/display: fix error case handling Alex Deucher
2021-09-28 16:42 ` [PATCH 50/64] drm/amdgpu: add VCN1 hardware IP Alex Deucher
2021-09-29  9:17   ` Christian König
2021-09-28 16:42 ` [PATCH 51/64] drm/amdgpu: add HWID of SDMA instance 2 and 3 Alex Deucher
2021-09-28 16:42 ` [PATCH 52/64] drm/amdgpu: get VCN and SDMA instances from IP discovery table Alex Deucher
2021-09-29  9:18   ` Christian König
2021-09-28 16:42 ` [PATCH 53/64] drm/amdgpu/sdma: remove manual instance setting Alex Deucher
2021-09-28 16:42 ` [PATCH 54/64] drm/amdgpu/vcn: " Alex Deucher
2021-09-28 16:42 ` [PATCH 55/64] drm/amdgpu: get VCN harvest information from IP discovery table Alex Deucher
2021-09-28 16:42 ` [PATCH 56/64] drm/amdgpu/ucode: add default behavior Alex Deucher
2021-09-28 16:42 ` [PATCH 57/64] drm/amdgpu: add new asic_type for IP discovery Alex Deucher
2021-09-28 16:42 ` [PATCH 58/64] drm/amdgpu: set CHIP_IP_DISCOVERY as the asic type by default Alex Deucher
2021-09-28 16:42 ` [PATCH 59/64] drm/amdgpu: convert IP version array to include instances Alex Deucher
2021-09-29  9:22   ` Christian König
2021-09-28 16:42 ` [PATCH 60/64] drm/amdgpu: clean up set IP function Alex Deucher
2021-09-28 16:42 ` [PATCH 61/64] drm/amdgpu: add support for SRIOV in IP discovery path Alex Deucher
2021-09-29  9:23   ` Christian König
2021-09-28 16:42 ` [PATCH 62/64] drm/amdkfd: clean up parameters in kgd2kfd_probe Alex Deucher
2021-09-28 16:42 ` Alex Deucher [this message]
2021-09-28 16:42 ` [PATCH 64/64] drm/amdgpu: add an option to override IP discovery table from a file Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210928164237.833132-64-alexander.deucher@amd.com \
    --to=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox