2 * Copyright 2018 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
24 #include <linux/firmware.h>
27 #include "amdgpu_discovery.h"
28 #include "soc15_hw_ip.h"
29 #include "discovery.h"
37 #include "nbio_v6_1.h"
38 #include "nbio_v7_0.h"
39 #include "nbio_v7_4.h"
41 #include "vega10_ih.h"
42 #include "vega20_ih.h"
43 #include "sdma_v4_0.h"
48 #include "jpeg_v2_5.h"
49 #include "smuio_v9_0.h"
50 #include "gmc_v10_0.h"
51 #include "gmc_v11_0.h"
52 #include "gfxhub_v2_0.h"
53 #include "mmhub_v2_0.h"
54 #include "nbio_v2_3.h"
55 #include "nbio_v4_3.h"
56 #include "nbio_v7_2.h"
57 #include "nbio_v7_7.h"
63 #include "navi10_ih.h"
65 #include "gfx_v10_0.h"
66 #include "gfx_v11_0.h"
67 #include "sdma_v5_0.h"
68 #include "sdma_v5_2.h"
69 #include "sdma_v6_0.h"
70 #include "lsdma_v6_0.h"
72 #include "jpeg_v2_0.h"
74 #include "jpeg_v3_0.h"
76 #include "jpeg_v4_0.h"
77 #include "amdgpu_vkms.h"
78 #include "mes_v10_1.h"
79 #include "mes_v11_0.h"
80 #include "smuio_v11_0.h"
81 #include "smuio_v11_0_6.h"
82 #include "smuio_v13_0.h"
83 #include "smuio_v13_0_6.h"
85 #define FIRMWARE_IP_DISCOVERY "amdgpu/ip_discovery.bin"
86 MODULE_FIRMWARE(FIRMWARE_IP_DISCOVERY);
88 #define mmRCC_CONFIG_MEMSIZE 0xde3
89 #define mmMM_INDEX 0x0
90 #define mmMM_INDEX_HI 0x6
93 static const char *hw_id_names[HW_ID_MAX] = {
97 [SMUIO_HWID] = "SMUIO",
103 [AUDIO_AZ_HWID] = "AUDIO_AZ",
109 [XDMA_HWID] = "XDMA",
110 [DCEAZ_HWID] = "DCEAZ",
112 [SDPMUX_HWID] = "SDPMUX",
114 [IOHC_HWID] = "IOHC",
115 [L2IMU_HWID] = "L2IMU",
117 [MMHUB_HWID] = "MMHUB",
118 [ATHUB_HWID] = "ATHUB",
119 [DBGU_NBIO_HWID] = "DBGU_NBIO",
121 [DBGU0_HWID] = "DBGU0",
122 [DBGU1_HWID] = "DBGU1",
123 [OSSSYS_HWID] = "OSSSYS",
125 [SDMA0_HWID] = "SDMA0",
126 [SDMA1_HWID] = "SDMA1",
127 [SDMA2_HWID] = "SDMA2",
128 [SDMA3_HWID] = "SDMA3",
129 [LSDMA_HWID] = "LSDMA",
131 [DBGU_IO_HWID] = "DBGU_IO",
133 [CLKB_HWID] = "CLKB",
135 [DFX_DAP_HWID] = "DFX_DAP",
136 [L1IMU_PCIE_HWID] = "L1IMU_PCIE",
137 [L1IMU_NBIF_HWID] = "L1IMU_NBIF",
138 [L1IMU_IOAGR_HWID] = "L1IMU_IOAGR",
139 [L1IMU3_HWID] = "L1IMU3",
140 [L1IMU4_HWID] = "L1IMU4",
141 [L1IMU5_HWID] = "L1IMU5",
142 [L1IMU6_HWID] = "L1IMU6",
143 [L1IMU7_HWID] = "L1IMU7",
144 [L1IMU8_HWID] = "L1IMU8",
145 [L1IMU9_HWID] = "L1IMU9",
146 [L1IMU10_HWID] = "L1IMU10",
147 [L1IMU11_HWID] = "L1IMU11",
148 [L1IMU12_HWID] = "L1IMU12",
149 [L1IMU13_HWID] = "L1IMU13",
150 [L1IMU14_HWID] = "L1IMU14",
151 [L1IMU15_HWID] = "L1IMU15",
152 [WAFLC_HWID] = "WAFLC",
153 [FCH_USB_PD_HWID] = "FCH_USB_PD",
154 [PCIE_HWID] = "PCIE",
156 [DDCL_HWID] = "DDCL",
158 [IOAGR_HWID] = "IOAGR",
159 [NBIF_HWID] = "NBIF",
160 [IOAPIC_HWID] = "IOAPIC",
161 [SYSTEMHUB_HWID] = "SYSTEMHUB",
162 [NTBCCP_HWID] = "NTBCCP",
164 [SATA_HWID] = "SATA",
166 [CCXSEC_HWID] = "CCXSEC",
167 [XGMI_HWID] = "XGMI",
168 [XGBE_HWID] = "XGBE",
172 static int hw_id_map[MAX_HWIP] = {
174 [HDP_HWIP] = HDP_HWID,
175 [SDMA0_HWIP] = SDMA0_HWID,
176 [SDMA1_HWIP] = SDMA1_HWID,
177 [SDMA2_HWIP] = SDMA2_HWID,
178 [SDMA3_HWIP] = SDMA3_HWID,
179 [LSDMA_HWIP] = LSDMA_HWID,
180 [MMHUB_HWIP] = MMHUB_HWID,
181 [ATHUB_HWIP] = ATHUB_HWID,
182 [NBIO_HWIP] = NBIF_HWID,
183 [MP0_HWIP] = MP0_HWID,
184 [MP1_HWIP] = MP1_HWID,
185 [UVD_HWIP] = UVD_HWID,
186 [VCE_HWIP] = VCE_HWID,
188 [DCE_HWIP] = DMU_HWID,
189 [OSSSYS_HWIP] = OSSSYS_HWID,
190 [SMUIO_HWIP] = SMUIO_HWID,
191 [PWR_HWIP] = PWR_HWID,
192 [NBIF_HWIP] = NBIF_HWID,
193 [THM_HWIP] = THM_HWID,
194 [CLK_HWIP] = CLKA_HWID,
195 [UMC_HWIP] = UMC_HWID,
196 [XGMI_HWIP] = XGMI_HWID,
197 [DCI_HWIP] = DCI_HWID,
198 [PCIE_HWIP] = PCIE_HWID,
201 static int amdgpu_discovery_read_binary_from_vram(struct amdgpu_device *adev, uint8_t *binary)
203 uint64_t vram_size = (uint64_t)RREG32(mmRCC_CONFIG_MEMSIZE) << 20;
204 uint64_t pos = vram_size - DISCOVERY_TMR_OFFSET;
206 amdgpu_device_vram_access(adev, pos, (uint32_t *)binary,
207 adev->mman.discovery_tmr_size, false);
211 static int amdgpu_discovery_read_binary_from_file(struct amdgpu_device *adev, uint8_t *binary)
213 const struct firmware *fw;
217 switch (amdgpu_discovery) {
219 fw_name = FIRMWARE_IP_DISCOVERY;
222 dev_warn(adev->dev, "amdgpu_discovery is not set properly\n");
226 r = request_firmware(&fw, fw_name, adev->dev);
228 dev_err(adev->dev, "can't load firmware \"%s\"\n",
233 memcpy((u8 *)binary, (u8 *)fw->data, fw->size);
234 release_firmware(fw);
239 static uint16_t amdgpu_discovery_calculate_checksum(uint8_t *data, uint32_t size)
241 uint16_t checksum = 0;
244 for (i = 0; i < size; i++)
250 static inline bool amdgpu_discovery_verify_checksum(uint8_t *data, uint32_t size,
253 return !!(amdgpu_discovery_calculate_checksum(data, size) == expected);
256 static inline bool amdgpu_discovery_verify_binary_signature(uint8_t *binary)
258 struct binary_header *bhdr;
259 bhdr = (struct binary_header *)binary;
261 return (le32_to_cpu(bhdr->binary_signature) == BINARY_SIGNATURE);
264 static void amdgpu_discovery_harvest_config_quirk(struct amdgpu_device *adev)
267 * So far, apply this quirk only on those Navy Flounder boards which
268 * have a bad harvest table of VCN config.
270 if ((adev->ip_versions[UVD_HWIP][1] == IP_VERSION(3, 0, 1)) &&
271 (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 2))) {
272 switch (adev->pdev->revision) {
280 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
288 static int amdgpu_discovery_init(struct amdgpu_device *adev)
290 struct table_info *info;
291 struct binary_header *bhdr;
297 adev->mman.discovery_tmr_size = DISCOVERY_TMR_SIZE;
298 adev->mman.discovery_bin = kzalloc(adev->mman.discovery_tmr_size, GFP_KERNEL);
299 if (!adev->mman.discovery_bin)
302 r = amdgpu_discovery_read_binary_from_vram(adev, adev->mman.discovery_bin);
304 dev_err(adev->dev, "failed to read ip discovery binary from vram\n");
309 if (!amdgpu_discovery_verify_binary_signature(adev->mman.discovery_bin) || amdgpu_discovery == 2) {
310 /* ignore the discovery binary from vram if discovery=2 in kernel module parameter */
311 if (amdgpu_discovery == 2)
312 dev_info(adev->dev,"force read ip discovery binary from file");
314 dev_warn(adev->dev, "get invalid ip discovery binary signature from vram\n");
316 /* retry read ip discovery binary from file */
317 r = amdgpu_discovery_read_binary_from_file(adev, adev->mman.discovery_bin);
319 dev_err(adev->dev, "failed to read ip discovery binary from file\n");
323 /* check the ip discovery binary signature */
324 if(!amdgpu_discovery_verify_binary_signature(adev->mman.discovery_bin)) {
325 dev_warn(adev->dev, "get invalid ip discovery binary signature from file\n");
331 bhdr = (struct binary_header *)adev->mman.discovery_bin;
333 offset = offsetof(struct binary_header, binary_checksum) +
334 sizeof(bhdr->binary_checksum);
335 size = le16_to_cpu(bhdr->binary_size) - offset;
336 checksum = le16_to_cpu(bhdr->binary_checksum);
338 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
340 dev_err(adev->dev, "invalid ip discovery binary checksum\n");
345 info = &bhdr->table_list[IP_DISCOVERY];
346 offset = le16_to_cpu(info->offset);
347 checksum = le16_to_cpu(info->checksum);
350 struct ip_discovery_header *ihdr =
351 (struct ip_discovery_header *)(adev->mman.discovery_bin + offset);
352 if (le32_to_cpu(ihdr->signature) != DISCOVERY_TABLE_SIGNATURE) {
353 dev_err(adev->dev, "invalid ip discovery data table signature\n");
358 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
359 le16_to_cpu(ihdr->size), checksum)) {
360 dev_err(adev->dev, "invalid ip discovery data table checksum\n");
366 info = &bhdr->table_list[GC];
367 offset = le16_to_cpu(info->offset);
368 checksum = le16_to_cpu(info->checksum);
371 struct gpu_info_header *ghdr =
372 (struct gpu_info_header *)(adev->mman.discovery_bin + offset);
374 if (le32_to_cpu(ghdr->table_id) != GC_TABLE_ID) {
375 dev_err(adev->dev, "invalid ip discovery gc table id\n");
380 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
381 le32_to_cpu(ghdr->size), checksum)) {
382 dev_err(adev->dev, "invalid gc data table checksum\n");
388 info = &bhdr->table_list[HARVEST_INFO];
389 offset = le16_to_cpu(info->offset);
390 checksum = le16_to_cpu(info->checksum);
393 struct harvest_info_header *hhdr =
394 (struct harvest_info_header *)(adev->mman.discovery_bin + offset);
396 if (le32_to_cpu(hhdr->signature) != HARVEST_TABLE_SIGNATURE) {
397 dev_err(adev->dev, "invalid ip discovery harvest table signature\n");
402 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
403 sizeof(struct harvest_table), checksum)) {
404 dev_err(adev->dev, "invalid harvest data table checksum\n");
410 info = &bhdr->table_list[VCN_INFO];
411 offset = le16_to_cpu(info->offset);
412 checksum = le16_to_cpu(info->checksum);
415 struct vcn_info_header *vhdr =
416 (struct vcn_info_header *)(adev->mman.discovery_bin + offset);
418 if (le32_to_cpu(vhdr->table_id) != VCN_INFO_TABLE_ID) {
419 dev_err(adev->dev, "invalid ip discovery vcn table id\n");
424 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
425 le32_to_cpu(vhdr->size_bytes), checksum)) {
426 dev_err(adev->dev, "invalid vcn data table checksum\n");
432 info = &bhdr->table_list[MALL_INFO];
433 offset = le16_to_cpu(info->offset);
434 checksum = le16_to_cpu(info->checksum);
437 struct mall_info_header *mhdr =
438 (struct mall_info_header *)(adev->mman.discovery_bin + offset);
440 if (le32_to_cpu(mhdr->table_id) != MALL_INFO_TABLE_ID) {
441 dev_err(adev->dev, "invalid ip discovery mall table id\n");
446 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
447 le32_to_cpu(mhdr->size_bytes), checksum)) {
448 dev_err(adev->dev, "invalid mall data table checksum\n");
457 kfree(adev->mman.discovery_bin);
458 adev->mman.discovery_bin = NULL;
463 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev);
465 void amdgpu_discovery_fini(struct amdgpu_device *adev)
467 amdgpu_discovery_sysfs_fini(adev);
468 kfree(adev->mman.discovery_bin);
469 adev->mman.discovery_bin = NULL;
472 static int amdgpu_discovery_validate_ip(const struct ip *ip)
474 if (ip->number_instance >= HWIP_MAX_INSTANCE) {
475 DRM_ERROR("Unexpected number_instance (%d) from ip discovery blob\n",
476 ip->number_instance);
479 if (le16_to_cpu(ip->hw_id) >= HW_ID_MAX) {
480 DRM_ERROR("Unexpected hw_id (%d) from ip discovery blob\n",
481 le16_to_cpu(ip->hw_id));
488 static void amdgpu_discovery_read_harvest_bit_per_ip(struct amdgpu_device *adev,
489 uint32_t *vcn_harvest_count)
491 struct binary_header *bhdr;
492 struct ip_discovery_header *ihdr;
493 struct die_header *dhdr;
495 uint16_t die_offset, ip_offset, num_dies, num_ips;
498 bhdr = (struct binary_header *)adev->mman.discovery_bin;
499 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
500 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
501 num_dies = le16_to_cpu(ihdr->num_dies);
503 /* scan harvest bit of all IP data structures */
504 for (i = 0; i < num_dies; i++) {
505 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
506 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
507 num_ips = le16_to_cpu(dhdr->num_ips);
508 ip_offset = die_offset + sizeof(*dhdr);
510 for (j = 0; j < num_ips; j++) {
511 ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
513 if (amdgpu_discovery_validate_ip(ip))
516 if (le16_to_cpu(ip->harvest) == 1) {
517 switch (le16_to_cpu(ip->hw_id)) {
519 (*vcn_harvest_count)++;
520 if (ip->number_instance == 0)
521 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN0;
523 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
526 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
533 ip_offset += struct_size(ip, base_address, ip->num_base_address);
538 static void amdgpu_discovery_read_from_harvest_table(struct amdgpu_device *adev,
539 uint32_t *vcn_harvest_count,
540 uint32_t *umc_harvest_count)
542 struct binary_header *bhdr;
543 struct harvest_table *harvest_info;
546 uint32_t umc_harvest_config = 0;
548 bhdr = (struct binary_header *)adev->mman.discovery_bin;
549 offset = le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset);
552 dev_err(adev->dev, "invalid harvest table offset\n");
556 harvest_info = (struct harvest_table *)(adev->mman.discovery_bin + offset);
558 for (i = 0; i < 32; i++) {
559 if (le16_to_cpu(harvest_info->list[i].hw_id) == 0)
562 switch (le16_to_cpu(harvest_info->list[i].hw_id)) {
564 (*vcn_harvest_count)++;
565 if (harvest_info->list[i].number_instance == 0)
566 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN0;
568 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
571 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
574 umc_harvest_config |=
575 1 << (le16_to_cpu(harvest_info->list[i].number_instance));
576 (*umc_harvest_count)++;
583 adev->umc.active_mask = ((1 << adev->umc.node_inst_num) - 1) &
587 /* ================================================== */
589 struct ip_hw_instance {
590 struct kobject kobj; /* ip_discovery/die/#die/#hw_id/#instance/<attrs...> */
594 u8 major, minor, revision;
597 int num_base_addresses;
602 struct kset hw_id_kset; /* ip_discovery/die/#die/#hw_id/, contains ip_hw_instance */
606 struct ip_die_entry {
607 struct kset ip_kset; /* ip_discovery/die/#die/, contains ip_hw_id */
611 /* -------------------------------------------------- */
613 struct ip_hw_instance_attr {
614 struct attribute attr;
615 ssize_t (*show)(struct ip_hw_instance *ip_hw_instance, char *buf);
618 static ssize_t hw_id_show(struct ip_hw_instance *ip_hw_instance, char *buf)
620 return sysfs_emit(buf, "%d\n", ip_hw_instance->hw_id);
623 static ssize_t num_instance_show(struct ip_hw_instance *ip_hw_instance, char *buf)
625 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_instance);
628 static ssize_t major_show(struct ip_hw_instance *ip_hw_instance, char *buf)
630 return sysfs_emit(buf, "%d\n", ip_hw_instance->major);
633 static ssize_t minor_show(struct ip_hw_instance *ip_hw_instance, char *buf)
635 return sysfs_emit(buf, "%d\n", ip_hw_instance->minor);
638 static ssize_t revision_show(struct ip_hw_instance *ip_hw_instance, char *buf)
640 return sysfs_emit(buf, "%d\n", ip_hw_instance->revision);
643 static ssize_t harvest_show(struct ip_hw_instance *ip_hw_instance, char *buf)
645 return sysfs_emit(buf, "0x%01X\n", ip_hw_instance->harvest);
648 static ssize_t num_base_addresses_show(struct ip_hw_instance *ip_hw_instance, char *buf)
650 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_base_addresses);
653 static ssize_t base_addr_show(struct ip_hw_instance *ip_hw_instance, char *buf)
658 for (res = at = ii = 0; ii < ip_hw_instance->num_base_addresses; ii++) {
659 /* Here we satisfy the condition that, at + size <= PAGE_SIZE.
661 if (at + 12 > PAGE_SIZE)
663 res = sysfs_emit_at(buf, at, "0x%08X\n",
664 ip_hw_instance->base_addr[ii]);
670 return res < 0 ? res : at;
673 static struct ip_hw_instance_attr ip_hw_attr[] = {
675 __ATTR_RO(num_instance),
680 __ATTR_RO(num_base_addresses),
681 __ATTR_RO(base_addr),
684 static struct attribute *ip_hw_instance_attrs[ARRAY_SIZE(ip_hw_attr) + 1];
685 ATTRIBUTE_GROUPS(ip_hw_instance);
687 #define to_ip_hw_instance(x) container_of(x, struct ip_hw_instance, kobj)
688 #define to_ip_hw_instance_attr(x) container_of(x, struct ip_hw_instance_attr, attr)
690 static ssize_t ip_hw_instance_attr_show(struct kobject *kobj,
691 struct attribute *attr,
694 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
695 struct ip_hw_instance_attr *ip_hw_attr = to_ip_hw_instance_attr(attr);
697 if (!ip_hw_attr->show)
700 return ip_hw_attr->show(ip_hw_instance, buf);
703 static const struct sysfs_ops ip_hw_instance_sysfs_ops = {
704 .show = ip_hw_instance_attr_show,
707 static void ip_hw_instance_release(struct kobject *kobj)
709 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
711 kfree(ip_hw_instance);
714 static struct kobj_type ip_hw_instance_ktype = {
715 .release = ip_hw_instance_release,
716 .sysfs_ops = &ip_hw_instance_sysfs_ops,
717 .default_groups = ip_hw_instance_groups,
720 /* -------------------------------------------------- */
722 #define to_ip_hw_id(x) container_of(to_kset(x), struct ip_hw_id, hw_id_kset)
724 static void ip_hw_id_release(struct kobject *kobj)
726 struct ip_hw_id *ip_hw_id = to_ip_hw_id(kobj);
728 if (!list_empty(&ip_hw_id->hw_id_kset.list))
729 DRM_ERROR("ip_hw_id->hw_id_kset is not empty");
733 static struct kobj_type ip_hw_id_ktype = {
734 .release = ip_hw_id_release,
735 .sysfs_ops = &kobj_sysfs_ops,
738 /* -------------------------------------------------- */
740 static void die_kobj_release(struct kobject *kobj);
741 static void ip_disc_release(struct kobject *kobj);
743 struct ip_die_entry_attribute {
744 struct attribute attr;
745 ssize_t (*show)(struct ip_die_entry *ip_die_entry, char *buf);
748 #define to_ip_die_entry_attr(x) container_of(x, struct ip_die_entry_attribute, attr)
750 static ssize_t num_ips_show(struct ip_die_entry *ip_die_entry, char *buf)
752 return sysfs_emit(buf, "%d\n", ip_die_entry->num_ips);
755 /* If there are more ip_die_entry attrs, other than the number of IPs,
756 * we can make this intro an array of attrs, and then initialize
757 * ip_die_entry_attrs in a loop.
759 static struct ip_die_entry_attribute num_ips_attr =
762 static struct attribute *ip_die_entry_attrs[] = {
766 ATTRIBUTE_GROUPS(ip_die_entry); /* ip_die_entry_groups */
768 #define to_ip_die_entry(x) container_of(to_kset(x), struct ip_die_entry, ip_kset)
770 static ssize_t ip_die_entry_attr_show(struct kobject *kobj,
771 struct attribute *attr,
774 struct ip_die_entry_attribute *ip_die_entry_attr = to_ip_die_entry_attr(attr);
775 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
777 if (!ip_die_entry_attr->show)
780 return ip_die_entry_attr->show(ip_die_entry, buf);
783 static void ip_die_entry_release(struct kobject *kobj)
785 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
787 if (!list_empty(&ip_die_entry->ip_kset.list))
788 DRM_ERROR("ip_die_entry->ip_kset is not empty");
792 static const struct sysfs_ops ip_die_entry_sysfs_ops = {
793 .show = ip_die_entry_attr_show,
796 static struct kobj_type ip_die_entry_ktype = {
797 .release = ip_die_entry_release,
798 .sysfs_ops = &ip_die_entry_sysfs_ops,
799 .default_groups = ip_die_entry_groups,
802 static struct kobj_type die_kobj_ktype = {
803 .release = die_kobj_release,
804 .sysfs_ops = &kobj_sysfs_ops,
807 static struct kobj_type ip_discovery_ktype = {
808 .release = ip_disc_release,
809 .sysfs_ops = &kobj_sysfs_ops,
812 struct ip_discovery_top {
813 struct kobject kobj; /* ip_discovery/ */
814 struct kset die_kset; /* ip_discovery/die/, contains ip_die_entry */
815 struct amdgpu_device *adev;
818 static void die_kobj_release(struct kobject *kobj)
820 struct ip_discovery_top *ip_top = container_of(to_kset(kobj),
821 struct ip_discovery_top,
823 if (!list_empty(&ip_top->die_kset.list))
824 DRM_ERROR("ip_top->die_kset is not empty");
827 static void ip_disc_release(struct kobject *kobj)
829 struct ip_discovery_top *ip_top = container_of(kobj, struct ip_discovery_top,
831 struct amdgpu_device *adev = ip_top->adev;
837 static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev,
838 struct ip_die_entry *ip_die_entry,
839 const size_t _ip_offset, const int num_ips)
843 DRM_DEBUG("num_ips:%d", num_ips);
845 /* Find all IPs of a given HW ID, and add their instance to
846 * #die/#hw_id/#instance/<attributes>
848 for (ii = 0; ii < HW_ID_MAX; ii++) {
849 struct ip_hw_id *ip_hw_id = NULL;
850 size_t ip_offset = _ip_offset;
852 for (jj = 0; jj < num_ips; jj++) {
854 struct ip_hw_instance *ip_hw_instance;
856 ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
857 if (amdgpu_discovery_validate_ip(ip) ||
858 le16_to_cpu(ip->hw_id) != ii)
861 DRM_DEBUG("match:%d @ ip_offset:%zu", ii, ip_offset);
863 /* We have a hw_id match; register the hw
864 * block if not yet registered.
867 ip_hw_id = kzalloc(sizeof(*ip_hw_id), GFP_KERNEL);
870 ip_hw_id->hw_id = ii;
872 kobject_set_name(&ip_hw_id->hw_id_kset.kobj, "%d", ii);
873 ip_hw_id->hw_id_kset.kobj.kset = &ip_die_entry->ip_kset;
874 ip_hw_id->hw_id_kset.kobj.ktype = &ip_hw_id_ktype;
875 res = kset_register(&ip_hw_id->hw_id_kset);
877 DRM_ERROR("Couldn't register ip_hw_id kset");
881 if (hw_id_names[ii]) {
882 res = sysfs_create_link(&ip_die_entry->ip_kset.kobj,
883 &ip_hw_id->hw_id_kset.kobj,
886 DRM_ERROR("Couldn't create IP link %s in IP Die:%s\n",
888 kobject_name(&ip_die_entry->ip_kset.kobj));
893 /* Now register its instance.
895 ip_hw_instance = kzalloc(struct_size(ip_hw_instance,
897 ip->num_base_address),
899 if (!ip_hw_instance) {
900 DRM_ERROR("no memory for ip_hw_instance");
903 ip_hw_instance->hw_id = le16_to_cpu(ip->hw_id); /* == ii */
904 ip_hw_instance->num_instance = ip->number_instance;
905 ip_hw_instance->major = ip->major;
906 ip_hw_instance->minor = ip->minor;
907 ip_hw_instance->revision = ip->revision;
908 ip_hw_instance->harvest = ip->harvest;
909 ip_hw_instance->num_base_addresses = ip->num_base_address;
911 for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++)
912 ip_hw_instance->base_addr[kk] = ip->base_address[kk];
914 kobject_init(&ip_hw_instance->kobj, &ip_hw_instance_ktype);
915 ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset;
916 res = kobject_add(&ip_hw_instance->kobj, NULL,
917 "%d", ip_hw_instance->num_instance);
919 ip_offset += struct_size(ip, base_address, ip->num_base_address);
926 static int amdgpu_discovery_sysfs_recurse(struct amdgpu_device *adev)
928 struct binary_header *bhdr;
929 struct ip_discovery_header *ihdr;
930 struct die_header *dhdr;
931 struct kset *die_kset = &adev->ip_top->die_kset;
932 u16 num_dies, die_offset, num_ips;
936 bhdr = (struct binary_header *)adev->mman.discovery_bin;
937 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
938 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
939 num_dies = le16_to_cpu(ihdr->num_dies);
941 DRM_DEBUG("number of dies: %d\n", num_dies);
943 for (ii = 0; ii < num_dies; ii++) {
944 struct ip_die_entry *ip_die_entry;
946 die_offset = le16_to_cpu(ihdr->die_info[ii].die_offset);
947 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
948 num_ips = le16_to_cpu(dhdr->num_ips);
949 ip_offset = die_offset + sizeof(*dhdr);
951 /* Add the die to the kset.
953 * dhdr->die_id == ii, which was checked in
954 * amdgpu_discovery_reg_base_init().
957 ip_die_entry = kzalloc(sizeof(*ip_die_entry), GFP_KERNEL);
961 ip_die_entry->num_ips = num_ips;
963 kobject_set_name(&ip_die_entry->ip_kset.kobj, "%d", le16_to_cpu(dhdr->die_id));
964 ip_die_entry->ip_kset.kobj.kset = die_kset;
965 ip_die_entry->ip_kset.kobj.ktype = &ip_die_entry_ktype;
966 res = kset_register(&ip_die_entry->ip_kset);
968 DRM_ERROR("Couldn't register ip_die_entry kset");
973 amdgpu_discovery_sysfs_ips(adev, ip_die_entry, ip_offset, num_ips);
979 static int amdgpu_discovery_sysfs_init(struct amdgpu_device *adev)
981 struct kset *die_kset;
984 adev->ip_top = kzalloc(sizeof(*adev->ip_top), GFP_KERNEL);
988 adev->ip_top->adev = adev;
990 res = kobject_init_and_add(&adev->ip_top->kobj, &ip_discovery_ktype,
991 &adev->dev->kobj, "ip_discovery");
993 DRM_ERROR("Couldn't init and add ip_discovery/");
997 die_kset = &adev->ip_top->die_kset;
998 kobject_set_name(&die_kset->kobj, "%s", "die");
999 die_kset->kobj.parent = &adev->ip_top->kobj;
1000 die_kset->kobj.ktype = &die_kobj_ktype;
1001 res = kset_register(&adev->ip_top->die_kset);
1003 DRM_ERROR("Couldn't register die_kset");
1007 for (ii = 0; ii < ARRAY_SIZE(ip_hw_attr); ii++)
1008 ip_hw_instance_attrs[ii] = &ip_hw_attr[ii].attr;
1009 ip_hw_instance_attrs[ii] = NULL;
1011 res = amdgpu_discovery_sysfs_recurse(adev);
1015 kobject_put(&adev->ip_top->kobj);
1019 /* -------------------------------------------------- */
1021 #define list_to_kobj(el) container_of(el, struct kobject, entry)
1023 static void amdgpu_discovery_sysfs_ip_hw_free(struct ip_hw_id *ip_hw_id)
1025 struct list_head *el, *tmp;
1026 struct kset *hw_id_kset;
1028 hw_id_kset = &ip_hw_id->hw_id_kset;
1029 spin_lock(&hw_id_kset->list_lock);
1030 list_for_each_prev_safe(el, tmp, &hw_id_kset->list) {
1032 spin_unlock(&hw_id_kset->list_lock);
1033 /* kobject is embedded in ip_hw_instance */
1034 kobject_put(list_to_kobj(el));
1035 spin_lock(&hw_id_kset->list_lock);
1037 spin_unlock(&hw_id_kset->list_lock);
1038 kobject_put(&ip_hw_id->hw_id_kset.kobj);
1041 static void amdgpu_discovery_sysfs_die_free(struct ip_die_entry *ip_die_entry)
1043 struct list_head *el, *tmp;
1044 struct kset *ip_kset;
1046 ip_kset = &ip_die_entry->ip_kset;
1047 spin_lock(&ip_kset->list_lock);
1048 list_for_each_prev_safe(el, tmp, &ip_kset->list) {
1050 spin_unlock(&ip_kset->list_lock);
1051 amdgpu_discovery_sysfs_ip_hw_free(to_ip_hw_id(list_to_kobj(el)));
1052 spin_lock(&ip_kset->list_lock);
1054 spin_unlock(&ip_kset->list_lock);
1055 kobject_put(&ip_die_entry->ip_kset.kobj);
1058 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev)
1060 struct list_head *el, *tmp;
1061 struct kset *die_kset;
1063 die_kset = &adev->ip_top->die_kset;
1064 spin_lock(&die_kset->list_lock);
1065 list_for_each_prev_safe(el, tmp, &die_kset->list) {
1067 spin_unlock(&die_kset->list_lock);
1068 amdgpu_discovery_sysfs_die_free(to_ip_die_entry(list_to_kobj(el)));
1069 spin_lock(&die_kset->list_lock);
1071 spin_unlock(&die_kset->list_lock);
1072 kobject_put(&adev->ip_top->die_kset.kobj);
1073 kobject_put(&adev->ip_top->kobj);
1076 /* ================================================== */
1078 static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
1080 struct binary_header *bhdr;
1081 struct ip_discovery_header *ihdr;
1082 struct die_header *dhdr;
1084 uint16_t die_offset;
1088 uint8_t num_base_address;
1093 r = amdgpu_discovery_init(adev);
1095 DRM_ERROR("amdgpu_discovery_init failed\n");
1099 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1100 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1101 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1102 num_dies = le16_to_cpu(ihdr->num_dies);
1104 DRM_DEBUG("number of dies: %d\n", num_dies);
1106 for (i = 0; i < num_dies; i++) {
1107 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
1108 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1109 num_ips = le16_to_cpu(dhdr->num_ips);
1110 ip_offset = die_offset + sizeof(*dhdr);
1112 if (le16_to_cpu(dhdr->die_id) != i) {
1113 DRM_ERROR("invalid die id %d, expected %d\n",
1114 le16_to_cpu(dhdr->die_id), i);
1118 DRM_DEBUG("number of hardware IPs on die%d: %d\n",
1119 le16_to_cpu(dhdr->die_id), num_ips);
1121 for (j = 0; j < num_ips; j++) {
1122 ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
1124 if (amdgpu_discovery_validate_ip(ip))
1127 num_base_address = ip->num_base_address;
1129 DRM_DEBUG("%s(%d) #%d v%d.%d.%d:\n",
1130 hw_id_names[le16_to_cpu(ip->hw_id)],
1131 le16_to_cpu(ip->hw_id),
1132 ip->number_instance,
1133 ip->major, ip->minor,
1136 if (le16_to_cpu(ip->hw_id) == VCN_HWID) {
1137 /* Bit [5:0]: original revision value
1138 * Bit [7:6]: en/decode capability:
1139 * 0b00 : VCN function normally
1140 * 0b10 : encode is disabled
1141 * 0b01 : decode is disabled
1143 adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
1144 ip->revision & 0xc0;
1145 ip->revision &= ~0xc0;
1146 if (adev->vcn.num_vcn_inst < AMDGPU_MAX_VCN_INSTANCES)
1147 adev->vcn.num_vcn_inst++;
1149 dev_err(adev->dev, "Too many VCN instances: %d vs %d\n",
1150 adev->vcn.num_vcn_inst + 1,
1151 AMDGPU_MAX_VCN_INSTANCES);
1153 if (le16_to_cpu(ip->hw_id) == SDMA0_HWID ||
1154 le16_to_cpu(ip->hw_id) == SDMA1_HWID ||
1155 le16_to_cpu(ip->hw_id) == SDMA2_HWID ||
1156 le16_to_cpu(ip->hw_id) == SDMA3_HWID) {
1157 if (adev->sdma.num_instances < AMDGPU_MAX_SDMA_INSTANCES)
1158 adev->sdma.num_instances++;
1160 dev_err(adev->dev, "Too many SDMA instances: %d vs %d\n",
1161 adev->sdma.num_instances + 1,
1162 AMDGPU_MAX_SDMA_INSTANCES);
1165 if (le16_to_cpu(ip->hw_id) == UMC_HWID) {
1166 adev->gmc.num_umc++;
1167 adev->umc.node_inst_num++;
1170 for (k = 0; k < num_base_address; k++) {
1172 * convert the endianness of base addresses in place,
1173 * so that we don't need to convert them when accessing adev->reg_offset.
1175 ip->base_address[k] = le32_to_cpu(ip->base_address[k]);
1176 DRM_DEBUG("\t0x%08x\n", ip->base_address[k]);
1179 for (hw_ip = 0; hw_ip < MAX_HWIP; hw_ip++) {
1180 if (hw_id_map[hw_ip] == le16_to_cpu(ip->hw_id)) {
1181 DRM_DEBUG("set register base offset for %s\n",
1182 hw_id_names[le16_to_cpu(ip->hw_id)]);
1183 adev->reg_offset[hw_ip][ip->number_instance] =
1185 /* Instance support is somewhat inconsistent.
1186 * SDMA is a good example. Sienna cichlid has 4 total
1187 * SDMA instances, each enumerated separately (HWIDs
1188 * 42, 43, 68, 69). Arcturus has 8 total SDMA instances,
1189 * but they are enumerated as multiple instances of the
1190 * same HWIDs (4x HWID 42, 4x HWID 43). UMC is another
1191 * example. On most chips there are multiple instances
1192 * with the same HWID.
1194 adev->ip_versions[hw_ip][ip->number_instance] =
1195 IP_VERSION(ip->major, ip->minor, ip->revision);
1200 ip_offset += struct_size(ip, base_address, ip->num_base_address);
1204 amdgpu_discovery_sysfs_init(adev);
1209 int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id, int number_instance,
1210 int *major, int *minor, int *revision)
1212 struct binary_header *bhdr;
1213 struct ip_discovery_header *ihdr;
1214 struct die_header *dhdr;
1216 uint16_t die_offset;
1222 if (!adev->mman.discovery_bin) {
1223 DRM_ERROR("ip discovery uninitialized\n");
1227 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1228 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1229 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1230 num_dies = le16_to_cpu(ihdr->num_dies);
1232 for (i = 0; i < num_dies; i++) {
1233 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
1234 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1235 num_ips = le16_to_cpu(dhdr->num_ips);
1236 ip_offset = die_offset + sizeof(*dhdr);
1238 for (j = 0; j < num_ips; j++) {
1239 ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
1241 if ((le16_to_cpu(ip->hw_id) == hw_id) && (ip->number_instance == number_instance)) {
1247 *revision = ip->revision;
1250 ip_offset += struct_size(ip, base_address, ip->num_base_address);
1257 static void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
1259 int vcn_harvest_count = 0;
1260 int umc_harvest_count = 0;
1263 * Harvest table does not fit Navi1x and legacy GPUs,
1264 * so read harvest bit per IP data structure to set
1265 * harvest configuration.
1267 if (adev->ip_versions[GC_HWIP][0] < IP_VERSION(10, 2, 0)) {
1268 if ((adev->pdev->device == 0x731E &&
1269 (adev->pdev->revision == 0xC6 ||
1270 adev->pdev->revision == 0xC7)) ||
1271 (adev->pdev->device == 0x7340 &&
1272 adev->pdev->revision == 0xC9) ||
1273 (adev->pdev->device == 0x7360 &&
1274 adev->pdev->revision == 0xC7))
1275 amdgpu_discovery_read_harvest_bit_per_ip(adev,
1276 &vcn_harvest_count);
1278 amdgpu_discovery_read_from_harvest_table(adev,
1280 &umc_harvest_count);
1283 amdgpu_discovery_harvest_config_quirk(adev);
1285 if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
1286 adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
1287 adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
1290 if (umc_harvest_count < adev->gmc.num_umc) {
1291 adev->gmc.num_umc -= umc_harvest_count;
1296 struct gc_info_v1_0 v1;
1297 struct gc_info_v1_1 v1_1;
1298 struct gc_info_v1_2 v1_2;
1299 struct gc_info_v2_0 v2;
1302 static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
1304 struct binary_header *bhdr;
1305 union gc_info *gc_info;
1308 if (!adev->mman.discovery_bin) {
1309 DRM_ERROR("ip discovery uninitialized\n");
1313 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1314 offset = le16_to_cpu(bhdr->table_list[GC].offset);
1319 gc_info = (union gc_info *)(adev->mman.discovery_bin + offset);
1321 switch (le16_to_cpu(gc_info->v1.header.version_major)) {
1323 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v1.gc_num_se);
1324 adev->gfx.config.max_cu_per_sh = 2 * (le32_to_cpu(gc_info->v1.gc_num_wgp0_per_sa) +
1325 le32_to_cpu(gc_info->v1.gc_num_wgp1_per_sa));
1326 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1327 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v1.gc_num_rb_per_se);
1328 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v1.gc_num_gl2c);
1329 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v1.gc_num_gprs);
1330 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v1.gc_num_max_gs_thds);
1331 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v1.gc_gs_table_depth);
1332 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v1.gc_gsprim_buff_depth);
1333 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v1.gc_double_offchip_lds_buffer);
1334 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v1.gc_wave_size);
1335 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v1.gc_max_waves_per_simd);
1336 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v1.gc_max_scratch_slots_per_cu);
1337 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v1.gc_lds_size);
1338 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v1.gc_num_sc_per_se) /
1339 le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1340 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v1.gc_num_packer_per_sc);
1341 if (gc_info->v1.header.version_minor >= 1) {
1342 adev->gfx.config.gc_num_tcp_per_sa = le32_to_cpu(gc_info->v1_1.gc_num_tcp_per_sa);
1343 adev->gfx.config.gc_num_sdp_interface = le32_to_cpu(gc_info->v1_1.gc_num_sdp_interface);
1344 adev->gfx.config.gc_num_tcps = le32_to_cpu(gc_info->v1_1.gc_num_tcps);
1346 if (gc_info->v1.header.version_minor >= 2) {
1347 adev->gfx.config.gc_num_tcp_per_wpg = le32_to_cpu(gc_info->v1_2.gc_num_tcp_per_wpg);
1348 adev->gfx.config.gc_tcp_l1_size = le32_to_cpu(gc_info->v1_2.gc_tcp_l1_size);
1349 adev->gfx.config.gc_num_sqc_per_wgp = le32_to_cpu(gc_info->v1_2.gc_num_sqc_per_wgp);
1350 adev->gfx.config.gc_l1_instruction_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_instruction_cache_size_per_sqc);
1351 adev->gfx.config.gc_l1_data_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_data_cache_size_per_sqc);
1352 adev->gfx.config.gc_gl1c_per_sa = le32_to_cpu(gc_info->v1_2.gc_gl1c_per_sa);
1353 adev->gfx.config.gc_gl1c_size_per_instance = le32_to_cpu(gc_info->v1_2.gc_gl1c_size_per_instance);
1354 adev->gfx.config.gc_gl2c_per_gpu = le32_to_cpu(gc_info->v1_2.gc_gl2c_per_gpu);
1358 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v2.gc_num_se);
1359 adev->gfx.config.max_cu_per_sh = le32_to_cpu(gc_info->v2.gc_num_cu_per_sh);
1360 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1361 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v2.gc_num_rb_per_se);
1362 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v2.gc_num_tccs);
1363 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v2.gc_num_gprs);
1364 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v2.gc_num_max_gs_thds);
1365 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v2.gc_gs_table_depth);
1366 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v2.gc_gsprim_buff_depth);
1367 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v2.gc_double_offchip_lds_buffer);
1368 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v2.gc_wave_size);
1369 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v2.gc_max_waves_per_simd);
1370 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v2.gc_max_scratch_slots_per_cu);
1371 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v2.gc_lds_size);
1372 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v2.gc_num_sc_per_se) /
1373 le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1374 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v2.gc_num_packer_per_sc);
1378 "Unhandled GC info table %d.%d\n",
1379 le16_to_cpu(gc_info->v1.header.version_major),
1380 le16_to_cpu(gc_info->v1.header.version_minor));
1387 struct mall_info_v1_0 v1;
1390 static int amdgpu_discovery_get_mall_info(struct amdgpu_device *adev)
1392 struct binary_header *bhdr;
1393 union mall_info *mall_info;
1394 u32 u, mall_size_per_umc, m_s_present, half_use;
1398 if (!adev->mman.discovery_bin) {
1399 DRM_ERROR("ip discovery uninitialized\n");
1403 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1404 offset = le16_to_cpu(bhdr->table_list[MALL_INFO].offset);
1409 mall_info = (union mall_info *)(adev->mman.discovery_bin + offset);
1411 switch (le16_to_cpu(mall_info->v1.header.version_major)) {
1414 mall_size_per_umc = le32_to_cpu(mall_info->v1.mall_size_per_m);
1415 m_s_present = le32_to_cpu(mall_info->v1.m_s_present);
1416 half_use = le32_to_cpu(mall_info->v1.m_half_use);
1417 for (u = 0; u < adev->gmc.num_umc; u++) {
1418 if (m_s_present & (1 << u))
1419 mall_size += mall_size_per_umc * 2;
1420 else if (half_use & (1 << u))
1421 mall_size += mall_size_per_umc / 2;
1423 mall_size += mall_size_per_umc;
1425 adev->gmc.mall_size = mall_size;
1429 "Unhandled MALL info table %d.%d\n",
1430 le16_to_cpu(mall_info->v1.header.version_major),
1431 le16_to_cpu(mall_info->v1.header.version_minor));
1438 struct vcn_info_v1_0 v1;
1441 static int amdgpu_discovery_get_vcn_info(struct amdgpu_device *adev)
1443 struct binary_header *bhdr;
1444 union vcn_info *vcn_info;
1448 if (!adev->mman.discovery_bin) {
1449 DRM_ERROR("ip discovery uninitialized\n");
1453 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1454 * which is smaller than VCN_INFO_TABLE_MAX_NUM_INSTANCES
1455 * but that may change in the future with new GPUs so keep this
1456 * check for defensive purposes.
1458 if (adev->vcn.num_vcn_inst > VCN_INFO_TABLE_MAX_NUM_INSTANCES) {
1459 dev_err(adev->dev, "invalid vcn instances\n");
1463 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1464 offset = le16_to_cpu(bhdr->table_list[VCN_INFO].offset);
1469 vcn_info = (union vcn_info *)(adev->mman.discovery_bin + offset);
1471 switch (le16_to_cpu(vcn_info->v1.header.version_major)) {
1473 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1474 * so this won't overflow.
1476 for (v = 0; v < adev->vcn.num_vcn_inst; v++) {
1477 adev->vcn.vcn_codec_disable_mask[v] =
1478 le32_to_cpu(vcn_info->v1.instance_info[v].fuse_data.all_bits);
1483 "Unhandled VCN info table %d.%d\n",
1484 le16_to_cpu(vcn_info->v1.header.version_major),
1485 le16_to_cpu(vcn_info->v1.header.version_minor));
1491 static int amdgpu_discovery_set_common_ip_blocks(struct amdgpu_device *adev)
1493 /* what IP to use for this? */
1494 switch (adev->ip_versions[GC_HWIP][0]) {
1495 case IP_VERSION(9, 0, 1):
1496 case IP_VERSION(9, 1, 0):
1497 case IP_VERSION(9, 2, 1):
1498 case IP_VERSION(9, 2, 2):
1499 case IP_VERSION(9, 3, 0):
1500 case IP_VERSION(9, 4, 0):
1501 case IP_VERSION(9, 4, 1):
1502 case IP_VERSION(9, 4, 2):
1503 amdgpu_device_ip_block_add(adev, &vega10_common_ip_block);
1505 case IP_VERSION(10, 1, 10):
1506 case IP_VERSION(10, 1, 1):
1507 case IP_VERSION(10, 1, 2):
1508 case IP_VERSION(10, 1, 3):
1509 case IP_VERSION(10, 1, 4):
1510 case IP_VERSION(10, 3, 0):
1511 case IP_VERSION(10, 3, 1):
1512 case IP_VERSION(10, 3, 2):
1513 case IP_VERSION(10, 3, 3):
1514 case IP_VERSION(10, 3, 4):
1515 case IP_VERSION(10, 3, 5):
1516 case IP_VERSION(10, 3, 6):
1517 case IP_VERSION(10, 3, 7):
1518 amdgpu_device_ip_block_add(adev, &nv_common_ip_block);
1520 case IP_VERSION(11, 0, 0):
1521 case IP_VERSION(11, 0, 1):
1522 case IP_VERSION(11, 0, 2):
1523 case IP_VERSION(11, 0, 3):
1524 case IP_VERSION(11, 0, 4):
1525 amdgpu_device_ip_block_add(adev, &soc21_common_ip_block);
1529 "Failed to add common ip block(GC_HWIP:0x%x)\n",
1530 adev->ip_versions[GC_HWIP][0]);
1536 static int amdgpu_discovery_set_gmc_ip_blocks(struct amdgpu_device *adev)
1538 /* use GC or MMHUB IP version */
1539 switch (adev->ip_versions[GC_HWIP][0]) {
1540 case IP_VERSION(9, 0, 1):
1541 case IP_VERSION(9, 1, 0):
1542 case IP_VERSION(9, 2, 1):
1543 case IP_VERSION(9, 2, 2):
1544 case IP_VERSION(9, 3, 0):
1545 case IP_VERSION(9, 4, 0):
1546 case IP_VERSION(9, 4, 1):
1547 case IP_VERSION(9, 4, 2):
1548 amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block);
1550 case IP_VERSION(10, 1, 10):
1551 case IP_VERSION(10, 1, 1):
1552 case IP_VERSION(10, 1, 2):
1553 case IP_VERSION(10, 1, 3):
1554 case IP_VERSION(10, 1, 4):
1555 case IP_VERSION(10, 3, 0):
1556 case IP_VERSION(10, 3, 1):
1557 case IP_VERSION(10, 3, 2):
1558 case IP_VERSION(10, 3, 3):
1559 case IP_VERSION(10, 3, 4):
1560 case IP_VERSION(10, 3, 5):
1561 case IP_VERSION(10, 3, 6):
1562 case IP_VERSION(10, 3, 7):
1563 amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block);
1565 case IP_VERSION(11, 0, 0):
1566 case IP_VERSION(11, 0, 1):
1567 case IP_VERSION(11, 0, 2):
1568 case IP_VERSION(11, 0, 3):
1569 case IP_VERSION(11, 0, 4):
1570 amdgpu_device_ip_block_add(adev, &gmc_v11_0_ip_block);
1574 "Failed to add gmc ip block(GC_HWIP:0x%x)\n",
1575 adev->ip_versions[GC_HWIP][0]);
1581 static int amdgpu_discovery_set_ih_ip_blocks(struct amdgpu_device *adev)
1583 switch (adev->ip_versions[OSSSYS_HWIP][0]) {
1584 case IP_VERSION(4, 0, 0):
1585 case IP_VERSION(4, 0, 1):
1586 case IP_VERSION(4, 1, 0):
1587 case IP_VERSION(4, 1, 1):
1588 case IP_VERSION(4, 3, 0):
1589 amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block);
1591 case IP_VERSION(4, 2, 0):
1592 case IP_VERSION(4, 2, 1):
1593 case IP_VERSION(4, 4, 0):
1594 amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block);
1596 case IP_VERSION(5, 0, 0):
1597 case IP_VERSION(5, 0, 1):
1598 case IP_VERSION(5, 0, 2):
1599 case IP_VERSION(5, 0, 3):
1600 case IP_VERSION(5, 2, 0):
1601 case IP_VERSION(5, 2, 1):
1602 amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);
1604 case IP_VERSION(6, 0, 0):
1605 case IP_VERSION(6, 0, 1):
1606 case IP_VERSION(6, 0, 2):
1607 amdgpu_device_ip_block_add(adev, &ih_v6_0_ip_block);
1611 "Failed to add ih ip block(OSSSYS_HWIP:0x%x)\n",
1612 adev->ip_versions[OSSSYS_HWIP][0]);
1618 static int amdgpu_discovery_set_psp_ip_blocks(struct amdgpu_device *adev)
1620 switch (adev->ip_versions[MP0_HWIP][0]) {
1621 case IP_VERSION(9, 0, 0):
1622 amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block);
1624 case IP_VERSION(10, 0, 0):
1625 case IP_VERSION(10, 0, 1):
1626 amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block);
1628 case IP_VERSION(11, 0, 0):
1629 case IP_VERSION(11, 0, 2):
1630 case IP_VERSION(11, 0, 4):
1631 case IP_VERSION(11, 0, 5):
1632 case IP_VERSION(11, 0, 9):
1633 case IP_VERSION(11, 0, 7):
1634 case IP_VERSION(11, 0, 11):
1635 case IP_VERSION(11, 0, 12):
1636 case IP_VERSION(11, 0, 13):
1637 case IP_VERSION(11, 5, 0):
1638 amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);
1640 case IP_VERSION(11, 0, 8):
1641 amdgpu_device_ip_block_add(adev, &psp_v11_0_8_ip_block);
1643 case IP_VERSION(11, 0, 3):
1644 case IP_VERSION(12, 0, 1):
1645 amdgpu_device_ip_block_add(adev, &psp_v12_0_ip_block);
1647 case IP_VERSION(13, 0, 0):
1648 case IP_VERSION(13, 0, 1):
1649 case IP_VERSION(13, 0, 2):
1650 case IP_VERSION(13, 0, 3):
1651 case IP_VERSION(13, 0, 5):
1652 case IP_VERSION(13, 0, 7):
1653 case IP_VERSION(13, 0, 8):
1654 case IP_VERSION(13, 0, 10):
1655 case IP_VERSION(13, 0, 11):
1656 amdgpu_device_ip_block_add(adev, &psp_v13_0_ip_block);
1658 case IP_VERSION(13, 0, 4):
1659 amdgpu_device_ip_block_add(adev, &psp_v13_0_4_ip_block);
1663 "Failed to add psp ip block(MP0_HWIP:0x%x)\n",
1664 adev->ip_versions[MP0_HWIP][0]);
1670 static int amdgpu_discovery_set_smu_ip_blocks(struct amdgpu_device *adev)
1672 switch (adev->ip_versions[MP1_HWIP][0]) {
1673 case IP_VERSION(9, 0, 0):
1674 case IP_VERSION(10, 0, 0):
1675 case IP_VERSION(10, 0, 1):
1676 case IP_VERSION(11, 0, 2):
1677 if (adev->asic_type == CHIP_ARCTURUS)
1678 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1680 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block);
1682 case IP_VERSION(11, 0, 0):
1683 case IP_VERSION(11, 0, 5):
1684 case IP_VERSION(11, 0, 9):
1685 case IP_VERSION(11, 0, 7):
1686 case IP_VERSION(11, 0, 8):
1687 case IP_VERSION(11, 0, 11):
1688 case IP_VERSION(11, 0, 12):
1689 case IP_VERSION(11, 0, 13):
1690 case IP_VERSION(11, 5, 0):
1691 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1693 case IP_VERSION(12, 0, 0):
1694 case IP_VERSION(12, 0, 1):
1695 amdgpu_device_ip_block_add(adev, &smu_v12_0_ip_block);
1697 case IP_VERSION(13, 0, 0):
1698 case IP_VERSION(13, 0, 1):
1699 case IP_VERSION(13, 0, 2):
1700 case IP_VERSION(13, 0, 3):
1701 case IP_VERSION(13, 0, 4):
1702 case IP_VERSION(13, 0, 5):
1703 case IP_VERSION(13, 0, 7):
1704 case IP_VERSION(13, 0, 8):
1705 case IP_VERSION(13, 0, 10):
1706 case IP_VERSION(13, 0, 11):
1707 amdgpu_device_ip_block_add(adev, &smu_v13_0_ip_block);
1711 "Failed to add smu ip block(MP1_HWIP:0x%x)\n",
1712 adev->ip_versions[MP1_HWIP][0]);
1718 #if defined(CONFIG_DRM_AMD_DC)
1719 static void amdgpu_discovery_set_sriov_display(struct amdgpu_device *adev)
1721 amdgpu_device_set_sriov_virtual_display(adev);
1722 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1726 static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)
1728 if (adev->enable_virtual_display) {
1729 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1733 if (!amdgpu_device_has_dc_support(adev))
1736 #if defined(CONFIG_DRM_AMD_DC)
1737 if (adev->ip_versions[DCE_HWIP][0]) {
1738 switch (adev->ip_versions[DCE_HWIP][0]) {
1739 case IP_VERSION(1, 0, 0):
1740 case IP_VERSION(1, 0, 1):
1741 case IP_VERSION(2, 0, 2):
1742 case IP_VERSION(2, 0, 0):
1743 case IP_VERSION(2, 0, 3):
1744 case IP_VERSION(2, 1, 0):
1745 case IP_VERSION(3, 0, 0):
1746 case IP_VERSION(3, 0, 2):
1747 case IP_VERSION(3, 0, 3):
1748 case IP_VERSION(3, 0, 1):
1749 case IP_VERSION(3, 1, 2):
1750 case IP_VERSION(3, 1, 3):
1751 case IP_VERSION(3, 1, 4):
1752 case IP_VERSION(3, 1, 5):
1753 case IP_VERSION(3, 1, 6):
1754 case IP_VERSION(3, 2, 0):
1755 case IP_VERSION(3, 2, 1):
1756 if (amdgpu_sriov_vf(adev))
1757 amdgpu_discovery_set_sriov_display(adev);
1759 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1763 "Failed to add dm ip block(DCE_HWIP:0x%x)\n",
1764 adev->ip_versions[DCE_HWIP][0]);
1767 } else if (adev->ip_versions[DCI_HWIP][0]) {
1768 switch (adev->ip_versions[DCI_HWIP][0]) {
1769 case IP_VERSION(12, 0, 0):
1770 case IP_VERSION(12, 0, 1):
1771 case IP_VERSION(12, 1, 0):
1772 if (amdgpu_sriov_vf(adev))
1773 amdgpu_discovery_set_sriov_display(adev);
1775 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1779 "Failed to add dm ip block(DCI_HWIP:0x%x)\n",
1780 adev->ip_versions[DCI_HWIP][0]);
1788 static int amdgpu_discovery_set_gc_ip_blocks(struct amdgpu_device *adev)
1790 switch (adev->ip_versions[GC_HWIP][0]) {
1791 case IP_VERSION(9, 0, 1):
1792 case IP_VERSION(9, 1, 0):
1793 case IP_VERSION(9, 2, 1):
1794 case IP_VERSION(9, 2, 2):
1795 case IP_VERSION(9, 3, 0):
1796 case IP_VERSION(9, 4, 0):
1797 case IP_VERSION(9, 4, 1):
1798 case IP_VERSION(9, 4, 2):
1799 amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
1801 case IP_VERSION(10, 1, 10):
1802 case IP_VERSION(10, 1, 2):
1803 case IP_VERSION(10, 1, 1):
1804 case IP_VERSION(10, 1, 3):
1805 case IP_VERSION(10, 1, 4):
1806 case IP_VERSION(10, 3, 0):
1807 case IP_VERSION(10, 3, 2):
1808 case IP_VERSION(10, 3, 1):
1809 case IP_VERSION(10, 3, 4):
1810 case IP_VERSION(10, 3, 5):
1811 case IP_VERSION(10, 3, 6):
1812 case IP_VERSION(10, 3, 3):
1813 case IP_VERSION(10, 3, 7):
1814 amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block);
1816 case IP_VERSION(11, 0, 0):
1817 case IP_VERSION(11, 0, 1):
1818 case IP_VERSION(11, 0, 2):
1819 case IP_VERSION(11, 0, 3):
1820 case IP_VERSION(11, 0, 4):
1821 amdgpu_device_ip_block_add(adev, &gfx_v11_0_ip_block);
1825 "Failed to add gfx ip block(GC_HWIP:0x%x)\n",
1826 adev->ip_versions[GC_HWIP][0]);
1832 static int amdgpu_discovery_set_sdma_ip_blocks(struct amdgpu_device *adev)
1834 switch (adev->ip_versions[SDMA0_HWIP][0]) {
1835 case IP_VERSION(4, 0, 0):
1836 case IP_VERSION(4, 0, 1):
1837 case IP_VERSION(4, 1, 0):
1838 case IP_VERSION(4, 1, 1):
1839 case IP_VERSION(4, 1, 2):
1840 case IP_VERSION(4, 2, 0):
1841 case IP_VERSION(4, 2, 2):
1842 case IP_VERSION(4, 4, 0):
1843 amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
1845 case IP_VERSION(5, 0, 0):
1846 case IP_VERSION(5, 0, 1):
1847 case IP_VERSION(5, 0, 2):
1848 case IP_VERSION(5, 0, 5):
1849 amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block);
1851 case IP_VERSION(5, 2, 0):
1852 case IP_VERSION(5, 2, 2):
1853 case IP_VERSION(5, 2, 4):
1854 case IP_VERSION(5, 2, 5):
1855 case IP_VERSION(5, 2, 6):
1856 case IP_VERSION(5, 2, 3):
1857 case IP_VERSION(5, 2, 1):
1858 case IP_VERSION(5, 2, 7):
1859 amdgpu_device_ip_block_add(adev, &sdma_v5_2_ip_block);
1861 case IP_VERSION(6, 0, 0):
1862 case IP_VERSION(6, 0, 1):
1863 case IP_VERSION(6, 0, 2):
1864 case IP_VERSION(6, 0, 3):
1865 amdgpu_device_ip_block_add(adev, &sdma_v6_0_ip_block);
1869 "Failed to add sdma ip block(SDMA0_HWIP:0x%x)\n",
1870 adev->ip_versions[SDMA0_HWIP][0]);
1876 static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
1878 if (adev->ip_versions[VCE_HWIP][0]) {
1879 switch (adev->ip_versions[UVD_HWIP][0]) {
1880 case IP_VERSION(7, 0, 0):
1881 case IP_VERSION(7, 2, 0):
1882 /* UVD is not supported on vega20 SR-IOV */
1883 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
1884 amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block);
1888 "Failed to add uvd v7 ip block(UVD_HWIP:0x%x)\n",
1889 adev->ip_versions[UVD_HWIP][0]);
1892 switch (adev->ip_versions[VCE_HWIP][0]) {
1893 case IP_VERSION(4, 0, 0):
1894 case IP_VERSION(4, 1, 0):
1895 /* VCE is not supported on vega20 SR-IOV */
1896 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
1897 amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block);
1901 "Failed to add VCE v4 ip block(VCE_HWIP:0x%x)\n",
1902 adev->ip_versions[VCE_HWIP][0]);
1906 switch (adev->ip_versions[UVD_HWIP][0]) {
1907 case IP_VERSION(1, 0, 0):
1908 case IP_VERSION(1, 0, 1):
1909 amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block);
1911 case IP_VERSION(2, 0, 0):
1912 case IP_VERSION(2, 0, 2):
1913 case IP_VERSION(2, 2, 0):
1914 amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
1915 if (!amdgpu_sriov_vf(adev))
1916 amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
1918 case IP_VERSION(2, 0, 3):
1920 case IP_VERSION(2, 5, 0):
1921 amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
1922 amdgpu_device_ip_block_add(adev, &jpeg_v2_5_ip_block);
1924 case IP_VERSION(2, 6, 0):
1925 amdgpu_device_ip_block_add(adev, &vcn_v2_6_ip_block);
1926 amdgpu_device_ip_block_add(adev, &jpeg_v2_6_ip_block);
1928 case IP_VERSION(3, 0, 0):
1929 case IP_VERSION(3, 0, 16):
1930 case IP_VERSION(3, 1, 1):
1931 case IP_VERSION(3, 1, 2):
1932 case IP_VERSION(3, 0, 2):
1933 case IP_VERSION(3, 0, 192):
1934 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
1935 if (!amdgpu_sriov_vf(adev))
1936 amdgpu_device_ip_block_add(adev, &jpeg_v3_0_ip_block);
1938 case IP_VERSION(3, 0, 33):
1939 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
1941 case IP_VERSION(4, 0, 0):
1942 case IP_VERSION(4, 0, 2):
1943 case IP_VERSION(4, 0, 4):
1944 amdgpu_device_ip_block_add(adev, &vcn_v4_0_ip_block);
1945 if (!amdgpu_sriov_vf(adev))
1946 amdgpu_device_ip_block_add(adev, &jpeg_v4_0_ip_block);
1950 "Failed to add vcn/jpeg ip block(UVD_HWIP:0x%x)\n",
1951 adev->ip_versions[UVD_HWIP][0]);
1958 static int amdgpu_discovery_set_mes_ip_blocks(struct amdgpu_device *adev)
1960 switch (adev->ip_versions[GC_HWIP][0]) {
1961 case IP_VERSION(10, 1, 10):
1962 case IP_VERSION(10, 1, 1):
1963 case IP_VERSION(10, 1, 2):
1964 case IP_VERSION(10, 1, 3):
1965 case IP_VERSION(10, 1, 4):
1966 case IP_VERSION(10, 3, 0):
1967 case IP_VERSION(10, 3, 1):
1968 case IP_VERSION(10, 3, 2):
1969 case IP_VERSION(10, 3, 3):
1970 case IP_VERSION(10, 3, 4):
1971 case IP_VERSION(10, 3, 5):
1972 case IP_VERSION(10, 3, 6):
1974 amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block);
1975 adev->enable_mes = true;
1977 adev->enable_mes_kiq = true;
1980 case IP_VERSION(11, 0, 0):
1981 case IP_VERSION(11, 0, 1):
1982 case IP_VERSION(11, 0, 2):
1983 case IP_VERSION(11, 0, 3):
1984 case IP_VERSION(11, 0, 4):
1985 amdgpu_device_ip_block_add(adev, &mes_v11_0_ip_block);
1986 adev->enable_mes = true;
1987 adev->enable_mes_kiq = true;
1995 int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)
1999 switch (adev->asic_type) {
2001 vega10_reg_base_init(adev);
2002 adev->sdma.num_instances = 2;
2003 adev->gmc.num_umc = 4;
2004 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 0, 0);
2005 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 0, 0);
2006 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 0);
2007 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 0);
2008 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 0);
2009 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 0);
2010 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2011 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 1, 0);
2012 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 0, 0);
2013 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2014 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2015 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2016 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 0);
2017 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 0, 1);
2018 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2019 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2020 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 0);
2023 vega10_reg_base_init(adev);
2024 adev->sdma.num_instances = 2;
2025 adev->gmc.num_umc = 4;
2026 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2027 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2028 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 1);
2029 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 1);
2030 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 1);
2031 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 1);
2032 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 5, 0);
2033 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 2, 0);
2034 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 0);
2035 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2036 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2037 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2038 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 1);
2039 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 1);
2040 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2041 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2042 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 1);
2045 vega10_reg_base_init(adev);
2046 adev->sdma.num_instances = 1;
2047 adev->vcn.num_vcn_inst = 1;
2048 adev->gmc.num_umc = 2;
2049 if (adev->apu_flags & AMD_APU_IS_RAVEN2) {
2050 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2051 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2052 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 1);
2053 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 1);
2054 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 1);
2055 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 1);
2056 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 1);
2057 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 5, 0);
2058 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 1);
2059 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 1);
2060 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 1, 0);
2061 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 1);
2062 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 2);
2063 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 1);
2064 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 1);
2066 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2067 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2068 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 0);
2069 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 0);
2070 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 0);
2071 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2072 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 0);
2073 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 0, 0);
2074 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 0);
2075 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 0);
2076 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 0, 0);
2077 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 0);
2078 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 1, 0);
2079 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 0);
2080 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 0);
2084 vega20_reg_base_init(adev);
2085 adev->sdma.num_instances = 2;
2086 adev->gmc.num_umc = 8;
2087 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2088 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2089 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 0);
2090 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 0);
2091 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 0);
2092 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 0);
2093 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 0);
2094 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 0);
2095 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 1);
2096 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 2);
2097 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2098 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 2);
2099 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 2);
2100 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 0);
2101 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 2, 0);
2102 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(7, 2, 0);
2103 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 1, 0);
2104 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 1, 0);
2107 arct_reg_base_init(adev);
2108 adev->sdma.num_instances = 8;
2109 adev->vcn.num_vcn_inst = 2;
2110 adev->gmc.num_umc = 8;
2111 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2112 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2113 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 1);
2114 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 1);
2115 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 2);
2116 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 2);
2117 adev->ip_versions[SDMA1_HWIP][1] = IP_VERSION(4, 2, 2);
2118 adev->ip_versions[SDMA1_HWIP][2] = IP_VERSION(4, 2, 2);
2119 adev->ip_versions[SDMA1_HWIP][3] = IP_VERSION(4, 2, 2);
2120 adev->ip_versions[SDMA1_HWIP][4] = IP_VERSION(4, 2, 2);
2121 adev->ip_versions[SDMA1_HWIP][5] = IP_VERSION(4, 2, 2);
2122 adev->ip_versions[SDMA1_HWIP][6] = IP_VERSION(4, 2, 2);
2123 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 1);
2124 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 1);
2125 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 2);
2126 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 4);
2127 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2128 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 3);
2129 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 3);
2130 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 1);
2131 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 5, 0);
2132 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 5, 0);
2134 case CHIP_ALDEBARAN:
2135 aldebaran_reg_base_init(adev);
2136 adev->sdma.num_instances = 5;
2137 adev->vcn.num_vcn_inst = 2;
2138 adev->gmc.num_umc = 4;
2139 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2140 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2141 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 4, 0);
2142 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 4, 0);
2143 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 4, 0);
2144 adev->ip_versions[SDMA0_HWIP][1] = IP_VERSION(4, 4, 0);
2145 adev->ip_versions[SDMA0_HWIP][2] = IP_VERSION(4, 4, 0);
2146 adev->ip_versions[SDMA0_HWIP][3] = IP_VERSION(4, 4, 0);
2147 adev->ip_versions[SDMA0_HWIP][4] = IP_VERSION(4, 4, 0);
2148 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 2);
2149 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 4);
2150 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 7, 0);
2151 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(13, 0, 2);
2152 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(13, 0, 2);
2153 adev->ip_versions[THM_HWIP][0] = IP_VERSION(13, 0, 2);
2154 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(13, 0, 2);
2155 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 2);
2156 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 6, 0);
2157 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 6, 0);
2158 adev->ip_versions[XGMI_HWIP][0] = IP_VERSION(6, 1, 0);
2161 r = amdgpu_discovery_reg_base_init(adev);
2165 amdgpu_discovery_harvest_ip(adev);
2166 amdgpu_discovery_get_gfx_info(adev);
2167 amdgpu_discovery_get_mall_info(adev);
2168 amdgpu_discovery_get_vcn_info(adev);
2172 switch (adev->ip_versions[GC_HWIP][0]) {
2173 case IP_VERSION(9, 0, 1):
2174 case IP_VERSION(9, 2, 1):
2175 case IP_VERSION(9, 4, 0):
2176 case IP_VERSION(9, 4, 1):
2177 case IP_VERSION(9, 4, 2):
2178 adev->family = AMDGPU_FAMILY_AI;
2180 case IP_VERSION(9, 1, 0):
2181 case IP_VERSION(9, 2, 2):
2182 case IP_VERSION(9, 3, 0):
2183 adev->family = AMDGPU_FAMILY_RV;
2185 case IP_VERSION(10, 1, 10):
2186 case IP_VERSION(10, 1, 1):
2187 case IP_VERSION(10, 1, 2):
2188 case IP_VERSION(10, 1, 3):
2189 case IP_VERSION(10, 1, 4):
2190 case IP_VERSION(10, 3, 0):
2191 case IP_VERSION(10, 3, 2):
2192 case IP_VERSION(10, 3, 4):
2193 case IP_VERSION(10, 3, 5):
2194 adev->family = AMDGPU_FAMILY_NV;
2196 case IP_VERSION(10, 3, 1):
2197 adev->family = AMDGPU_FAMILY_VGH;
2198 adev->apu_flags |= AMD_APU_IS_VANGOGH;
2200 case IP_VERSION(10, 3, 3):
2201 adev->family = AMDGPU_FAMILY_YC;
2203 case IP_VERSION(10, 3, 6):
2204 adev->family = AMDGPU_FAMILY_GC_10_3_6;
2206 case IP_VERSION(10, 3, 7):
2207 adev->family = AMDGPU_FAMILY_GC_10_3_7;
2209 case IP_VERSION(11, 0, 0):
2210 case IP_VERSION(11, 0, 2):
2211 case IP_VERSION(11, 0, 3):
2212 adev->family = AMDGPU_FAMILY_GC_11_0_0;
2214 case IP_VERSION(11, 0, 1):
2215 case IP_VERSION(11, 0, 4):
2216 adev->family = AMDGPU_FAMILY_GC_11_0_1;
2222 switch (adev->ip_versions[GC_HWIP][0]) {
2223 case IP_VERSION(9, 1, 0):
2224 case IP_VERSION(9, 2, 2):
2225 case IP_VERSION(9, 3, 0):
2226 case IP_VERSION(10, 1, 3):
2227 case IP_VERSION(10, 1, 4):
2228 case IP_VERSION(10, 3, 1):
2229 case IP_VERSION(10, 3, 3):
2230 case IP_VERSION(10, 3, 6):
2231 case IP_VERSION(10, 3, 7):
2232 case IP_VERSION(11, 0, 1):
2233 case IP_VERSION(11, 0, 4):
2234 adev->flags |= AMD_IS_APU;
2240 if (adev->ip_versions[XGMI_HWIP][0] == IP_VERSION(4, 8, 0))
2241 adev->gmc.xgmi.supported = true;
2243 /* set NBIO version */
2244 switch (adev->ip_versions[NBIO_HWIP][0]) {
2245 case IP_VERSION(6, 1, 0):
2246 case IP_VERSION(6, 2, 0):
2247 adev->nbio.funcs = &nbio_v6_1_funcs;
2248 adev->nbio.hdp_flush_reg = &nbio_v6_1_hdp_flush_reg;
2250 case IP_VERSION(7, 0, 0):
2251 case IP_VERSION(7, 0, 1):
2252 case IP_VERSION(2, 5, 0):
2253 adev->nbio.funcs = &nbio_v7_0_funcs;
2254 adev->nbio.hdp_flush_reg = &nbio_v7_0_hdp_flush_reg;
2256 case IP_VERSION(7, 4, 0):
2257 case IP_VERSION(7, 4, 1):
2258 case IP_VERSION(7, 4, 4):
2259 adev->nbio.funcs = &nbio_v7_4_funcs;
2260 adev->nbio.hdp_flush_reg = &nbio_v7_4_hdp_flush_reg;
2262 case IP_VERSION(7, 2, 0):
2263 case IP_VERSION(7, 2, 1):
2264 case IP_VERSION(7, 3, 0):
2265 case IP_VERSION(7, 5, 0):
2266 case IP_VERSION(7, 5, 1):
2267 adev->nbio.funcs = &nbio_v7_2_funcs;
2268 adev->nbio.hdp_flush_reg = &nbio_v7_2_hdp_flush_reg;
2270 case IP_VERSION(2, 1, 1):
2271 case IP_VERSION(2, 3, 0):
2272 case IP_VERSION(2, 3, 1):
2273 case IP_VERSION(2, 3, 2):
2274 case IP_VERSION(3, 3, 0):
2275 case IP_VERSION(3, 3, 1):
2276 case IP_VERSION(3, 3, 2):
2277 case IP_VERSION(3, 3, 3):
2278 adev->nbio.funcs = &nbio_v2_3_funcs;
2279 adev->nbio.hdp_flush_reg = &nbio_v2_3_hdp_flush_reg;
2281 case IP_VERSION(4, 3, 0):
2282 case IP_VERSION(4, 3, 1):
2283 if (amdgpu_sriov_vf(adev))
2284 adev->nbio.funcs = &nbio_v4_3_sriov_funcs;
2286 adev->nbio.funcs = &nbio_v4_3_funcs;
2287 adev->nbio.hdp_flush_reg = &nbio_v4_3_hdp_flush_reg;
2289 case IP_VERSION(7, 7, 0):
2290 case IP_VERSION(7, 7, 1):
2291 adev->nbio.funcs = &nbio_v7_7_funcs;
2292 adev->nbio.hdp_flush_reg = &nbio_v7_7_hdp_flush_reg;
2298 switch (adev->ip_versions[HDP_HWIP][0]) {
2299 case IP_VERSION(4, 0, 0):
2300 case IP_VERSION(4, 0, 1):
2301 case IP_VERSION(4, 1, 0):
2302 case IP_VERSION(4, 1, 1):
2303 case IP_VERSION(4, 1, 2):
2304 case IP_VERSION(4, 2, 0):
2305 case IP_VERSION(4, 2, 1):
2306 case IP_VERSION(4, 4, 0):
2307 adev->hdp.funcs = &hdp_v4_0_funcs;
2309 case IP_VERSION(5, 0, 0):
2310 case IP_VERSION(5, 0, 1):
2311 case IP_VERSION(5, 0, 2):
2312 case IP_VERSION(5, 0, 3):
2313 case IP_VERSION(5, 0, 4):
2314 case IP_VERSION(5, 2, 0):
2315 adev->hdp.funcs = &hdp_v5_0_funcs;
2317 case IP_VERSION(5, 2, 1):
2318 adev->hdp.funcs = &hdp_v5_2_funcs;
2320 case IP_VERSION(6, 0, 0):
2321 case IP_VERSION(6, 0, 1):
2322 adev->hdp.funcs = &hdp_v6_0_funcs;
2328 switch (adev->ip_versions[DF_HWIP][0]) {
2329 case IP_VERSION(3, 6, 0):
2330 case IP_VERSION(3, 6, 1):
2331 case IP_VERSION(3, 6, 2):
2332 adev->df.funcs = &df_v3_6_funcs;
2334 case IP_VERSION(2, 1, 0):
2335 case IP_VERSION(2, 1, 1):
2336 case IP_VERSION(2, 5, 0):
2337 case IP_VERSION(3, 5, 1):
2338 case IP_VERSION(3, 5, 2):
2339 adev->df.funcs = &df_v1_7_funcs;
2341 case IP_VERSION(4, 3, 0):
2342 adev->df.funcs = &df_v4_3_funcs;
2348 switch (adev->ip_versions[SMUIO_HWIP][0]) {
2349 case IP_VERSION(9, 0, 0):
2350 case IP_VERSION(9, 0, 1):
2351 case IP_VERSION(10, 0, 0):
2352 case IP_VERSION(10, 0, 1):
2353 case IP_VERSION(10, 0, 2):
2354 adev->smuio.funcs = &smuio_v9_0_funcs;
2356 case IP_VERSION(11, 0, 0):
2357 case IP_VERSION(11, 0, 2):
2358 case IP_VERSION(11, 0, 3):
2359 case IP_VERSION(11, 0, 4):
2360 case IP_VERSION(11, 0, 7):
2361 case IP_VERSION(11, 0, 8):
2362 adev->smuio.funcs = &smuio_v11_0_funcs;
2364 case IP_VERSION(11, 0, 6):
2365 case IP_VERSION(11, 0, 10):
2366 case IP_VERSION(11, 0, 11):
2367 case IP_VERSION(11, 5, 0):
2368 case IP_VERSION(13, 0, 1):
2369 case IP_VERSION(13, 0, 9):
2370 case IP_VERSION(13, 0, 10):
2371 adev->smuio.funcs = &smuio_v11_0_6_funcs;
2373 case IP_VERSION(13, 0, 2):
2374 adev->smuio.funcs = &smuio_v13_0_funcs;
2376 case IP_VERSION(13, 0, 6):
2377 case IP_VERSION(13, 0, 8):
2378 adev->smuio.funcs = &smuio_v13_0_6_funcs;
2384 switch (adev->ip_versions[LSDMA_HWIP][0]) {
2385 case IP_VERSION(6, 0, 0):
2386 case IP_VERSION(6, 0, 1):
2387 case IP_VERSION(6, 0, 2):
2388 case IP_VERSION(6, 0, 3):
2389 adev->lsdma.funcs = &lsdma_v6_0_funcs;
2395 r = amdgpu_discovery_set_common_ip_blocks(adev);
2399 r = amdgpu_discovery_set_gmc_ip_blocks(adev);
2403 /* For SR-IOV, PSP needs to be initialized before IH */
2404 if (amdgpu_sriov_vf(adev)) {
2405 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2408 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2412 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2416 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2417 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2423 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2424 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2429 r = amdgpu_discovery_set_display_ip_blocks(adev);
2433 r = amdgpu_discovery_set_gc_ip_blocks(adev);
2437 r = amdgpu_discovery_set_sdma_ip_blocks(adev);
2441 if ((adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
2442 !amdgpu_sriov_vf(adev)) ||
2443 (adev->firmware.load_type == AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO && amdgpu_dpm == 1)) {
2444 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2449 r = amdgpu_discovery_set_mm_ip_blocks(adev);
2453 r = amdgpu_discovery_set_mes_ip_blocks(adev);