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"
36 #include "nbio_v6_1.h"
37 #include "nbio_v7_0.h"
38 #include "nbio_v7_4.h"
40 #include "vega10_ih.h"
41 #include "vega20_ih.h"
42 #include "sdma_v4_0.h"
47 #include "jpeg_v2_5.h"
48 #include "smuio_v9_0.h"
49 #include "gmc_v10_0.h"
50 #include "gmc_v11_0.h"
51 #include "gfxhub_v2_0.h"
52 #include "mmhub_v2_0.h"
53 #include "nbio_v2_3.h"
54 #include "nbio_v4_3.h"
55 #include "nbio_v7_2.h"
56 #include "nbio_v7_7.h"
62 #include "navi10_ih.h"
64 #include "gfx_v10_0.h"
65 #include "gfx_v11_0.h"
66 #include "sdma_v5_0.h"
67 #include "sdma_v5_2.h"
68 #include "sdma_v6_0.h"
69 #include "lsdma_v6_0.h"
71 #include "jpeg_v2_0.h"
73 #include "jpeg_v3_0.h"
75 #include "jpeg_v4_0.h"
76 #include "amdgpu_vkms.h"
77 #include "mes_v10_1.h"
78 #include "mes_v11_0.h"
79 #include "smuio_v11_0.h"
80 #include "smuio_v11_0_6.h"
81 #include "smuio_v13_0.h"
82 #include "smuio_v13_0_6.h"
84 #define FIRMWARE_IP_DISCOVERY "amdgpu/ip_discovery.bin"
85 MODULE_FIRMWARE(FIRMWARE_IP_DISCOVERY);
87 #define mmRCC_CONFIG_MEMSIZE 0xde3
88 #define mmMM_INDEX 0x0
89 #define mmMM_INDEX_HI 0x6
92 static const char *hw_id_names[HW_ID_MAX] = {
96 [SMUIO_HWID] = "SMUIO",
102 [AUDIO_AZ_HWID] = "AUDIO_AZ",
108 [XDMA_HWID] = "XDMA",
109 [DCEAZ_HWID] = "DCEAZ",
111 [SDPMUX_HWID] = "SDPMUX",
113 [IOHC_HWID] = "IOHC",
114 [L2IMU_HWID] = "L2IMU",
116 [MMHUB_HWID] = "MMHUB",
117 [ATHUB_HWID] = "ATHUB",
118 [DBGU_NBIO_HWID] = "DBGU_NBIO",
120 [DBGU0_HWID] = "DBGU0",
121 [DBGU1_HWID] = "DBGU1",
122 [OSSSYS_HWID] = "OSSSYS",
124 [SDMA0_HWID] = "SDMA0",
125 [SDMA1_HWID] = "SDMA1",
126 [SDMA2_HWID] = "SDMA2",
127 [SDMA3_HWID] = "SDMA3",
128 [LSDMA_HWID] = "LSDMA",
130 [DBGU_IO_HWID] = "DBGU_IO",
132 [CLKB_HWID] = "CLKB",
134 [DFX_DAP_HWID] = "DFX_DAP",
135 [L1IMU_PCIE_HWID] = "L1IMU_PCIE",
136 [L1IMU_NBIF_HWID] = "L1IMU_NBIF",
137 [L1IMU_IOAGR_HWID] = "L1IMU_IOAGR",
138 [L1IMU3_HWID] = "L1IMU3",
139 [L1IMU4_HWID] = "L1IMU4",
140 [L1IMU5_HWID] = "L1IMU5",
141 [L1IMU6_HWID] = "L1IMU6",
142 [L1IMU7_HWID] = "L1IMU7",
143 [L1IMU8_HWID] = "L1IMU8",
144 [L1IMU9_HWID] = "L1IMU9",
145 [L1IMU10_HWID] = "L1IMU10",
146 [L1IMU11_HWID] = "L1IMU11",
147 [L1IMU12_HWID] = "L1IMU12",
148 [L1IMU13_HWID] = "L1IMU13",
149 [L1IMU14_HWID] = "L1IMU14",
150 [L1IMU15_HWID] = "L1IMU15",
151 [WAFLC_HWID] = "WAFLC",
152 [FCH_USB_PD_HWID] = "FCH_USB_PD",
153 [PCIE_HWID] = "PCIE",
155 [DDCL_HWID] = "DDCL",
157 [IOAGR_HWID] = "IOAGR",
158 [NBIF_HWID] = "NBIF",
159 [IOAPIC_HWID] = "IOAPIC",
160 [SYSTEMHUB_HWID] = "SYSTEMHUB",
161 [NTBCCP_HWID] = "NTBCCP",
163 [SATA_HWID] = "SATA",
165 [CCXSEC_HWID] = "CCXSEC",
166 [XGMI_HWID] = "XGMI",
167 [XGBE_HWID] = "XGBE",
171 static int hw_id_map[MAX_HWIP] = {
173 [HDP_HWIP] = HDP_HWID,
174 [SDMA0_HWIP] = SDMA0_HWID,
175 [SDMA1_HWIP] = SDMA1_HWID,
176 [SDMA2_HWIP] = SDMA2_HWID,
177 [SDMA3_HWIP] = SDMA3_HWID,
178 [LSDMA_HWIP] = LSDMA_HWID,
179 [MMHUB_HWIP] = MMHUB_HWID,
180 [ATHUB_HWIP] = ATHUB_HWID,
181 [NBIO_HWIP] = NBIF_HWID,
182 [MP0_HWIP] = MP0_HWID,
183 [MP1_HWIP] = MP1_HWID,
184 [UVD_HWIP] = UVD_HWID,
185 [VCE_HWIP] = VCE_HWID,
187 [DCE_HWIP] = DMU_HWID,
188 [OSSSYS_HWIP] = OSSSYS_HWID,
189 [SMUIO_HWIP] = SMUIO_HWID,
190 [PWR_HWIP] = PWR_HWID,
191 [NBIF_HWIP] = NBIF_HWID,
192 [THM_HWIP] = THM_HWID,
193 [CLK_HWIP] = CLKA_HWID,
194 [UMC_HWIP] = UMC_HWID,
195 [XGMI_HWIP] = XGMI_HWID,
196 [DCI_HWIP] = DCI_HWID,
197 [PCIE_HWIP] = PCIE_HWID,
200 static int amdgpu_discovery_read_binary_from_vram(struct amdgpu_device *adev, uint8_t *binary)
202 uint64_t vram_size = (uint64_t)RREG32(mmRCC_CONFIG_MEMSIZE) << 20;
203 uint64_t pos = vram_size - DISCOVERY_TMR_OFFSET;
205 amdgpu_device_vram_access(adev, pos, (uint32_t *)binary,
206 adev->mman.discovery_tmr_size, false);
210 static int amdgpu_discovery_read_binary_from_file(struct amdgpu_device *adev, uint8_t *binary)
212 const struct firmware *fw;
216 switch (amdgpu_discovery) {
218 fw_name = FIRMWARE_IP_DISCOVERY;
221 dev_warn(adev->dev, "amdgpu_discovery is not set properly\n");
225 r = request_firmware(&fw, fw_name, adev->dev);
227 dev_err(adev->dev, "can't load firmware \"%s\"\n",
232 memcpy((u8 *)binary, (u8 *)fw->data, fw->size);
233 release_firmware(fw);
238 static uint16_t amdgpu_discovery_calculate_checksum(uint8_t *data, uint32_t size)
240 uint16_t checksum = 0;
243 for (i = 0; i < size; i++)
249 static inline bool amdgpu_discovery_verify_checksum(uint8_t *data, uint32_t size,
252 return !!(amdgpu_discovery_calculate_checksum(data, size) == expected);
255 static inline bool amdgpu_discovery_verify_binary_signature(uint8_t *binary)
257 struct binary_header *bhdr;
258 bhdr = (struct binary_header *)binary;
260 return (le32_to_cpu(bhdr->binary_signature) == BINARY_SIGNATURE);
263 static void amdgpu_discovery_harvest_config_quirk(struct amdgpu_device *adev)
266 * So far, apply this quirk only on those Navy Flounder boards which
267 * have a bad harvest table of VCN config.
269 if ((adev->ip_versions[UVD_HWIP][1] == IP_VERSION(3, 0, 1)) &&
270 (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 2))) {
271 switch (adev->pdev->revision) {
279 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
287 static int amdgpu_discovery_init(struct amdgpu_device *adev)
289 struct table_info *info;
290 struct binary_header *bhdr;
296 adev->mman.discovery_tmr_size = DISCOVERY_TMR_SIZE;
297 adev->mman.discovery_bin = kzalloc(adev->mman.discovery_tmr_size, GFP_KERNEL);
298 if (!adev->mman.discovery_bin)
301 r = amdgpu_discovery_read_binary_from_vram(adev, adev->mman.discovery_bin);
303 dev_err(adev->dev, "failed to read ip discovery binary from vram\n");
308 if (!amdgpu_discovery_verify_binary_signature(adev->mman.discovery_bin) || amdgpu_discovery == 2) {
309 /* ignore the discovery binary from vram if discovery=2 in kernel module parameter */
310 if (amdgpu_discovery == 2)
311 dev_info(adev->dev,"force read ip discovery binary from file");
313 dev_warn(adev->dev, "get invalid ip discovery binary signature from vram\n");
315 /* retry read ip discovery binary from file */
316 r = amdgpu_discovery_read_binary_from_file(adev, adev->mman.discovery_bin);
318 dev_err(adev->dev, "failed to read ip discovery binary from file\n");
322 /* check the ip discovery binary signature */
323 if(!amdgpu_discovery_verify_binary_signature(adev->mman.discovery_bin)) {
324 dev_warn(adev->dev, "get invalid ip discovery binary signature from file\n");
330 bhdr = (struct binary_header *)adev->mman.discovery_bin;
332 offset = offsetof(struct binary_header, binary_checksum) +
333 sizeof(bhdr->binary_checksum);
334 size = le16_to_cpu(bhdr->binary_size) - offset;
335 checksum = le16_to_cpu(bhdr->binary_checksum);
337 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
339 dev_err(adev->dev, "invalid ip discovery binary checksum\n");
344 info = &bhdr->table_list[IP_DISCOVERY];
345 offset = le16_to_cpu(info->offset);
346 checksum = le16_to_cpu(info->checksum);
349 struct ip_discovery_header *ihdr =
350 (struct ip_discovery_header *)(adev->mman.discovery_bin + offset);
351 if (le32_to_cpu(ihdr->signature) != DISCOVERY_TABLE_SIGNATURE) {
352 dev_err(adev->dev, "invalid ip discovery data table signature\n");
357 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
358 le16_to_cpu(ihdr->size), checksum)) {
359 dev_err(adev->dev, "invalid ip discovery data table checksum\n");
365 info = &bhdr->table_list[GC];
366 offset = le16_to_cpu(info->offset);
367 checksum = le16_to_cpu(info->checksum);
370 struct gpu_info_header *ghdr =
371 (struct gpu_info_header *)(adev->mman.discovery_bin + offset);
373 if (le32_to_cpu(ghdr->table_id) != GC_TABLE_ID) {
374 dev_err(adev->dev, "invalid ip discovery gc table id\n");
379 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
380 le32_to_cpu(ghdr->size), checksum)) {
381 dev_err(adev->dev, "invalid gc data table checksum\n");
387 info = &bhdr->table_list[HARVEST_INFO];
388 offset = le16_to_cpu(info->offset);
389 checksum = le16_to_cpu(info->checksum);
392 struct harvest_info_header *hhdr =
393 (struct harvest_info_header *)(adev->mman.discovery_bin + offset);
395 if (le32_to_cpu(hhdr->signature) != HARVEST_TABLE_SIGNATURE) {
396 dev_err(adev->dev, "invalid ip discovery harvest table signature\n");
401 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
402 sizeof(struct harvest_table), checksum)) {
403 dev_err(adev->dev, "invalid harvest data table checksum\n");
409 info = &bhdr->table_list[VCN_INFO];
410 offset = le16_to_cpu(info->offset);
411 checksum = le16_to_cpu(info->checksum);
414 struct vcn_info_header *vhdr =
415 (struct vcn_info_header *)(adev->mman.discovery_bin + offset);
417 if (le32_to_cpu(vhdr->table_id) != VCN_INFO_TABLE_ID) {
418 dev_err(adev->dev, "invalid ip discovery vcn table id\n");
423 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
424 le32_to_cpu(vhdr->size_bytes), checksum)) {
425 dev_err(adev->dev, "invalid vcn data table checksum\n");
431 info = &bhdr->table_list[MALL_INFO];
432 offset = le16_to_cpu(info->offset);
433 checksum = le16_to_cpu(info->checksum);
436 struct mall_info_header *mhdr =
437 (struct mall_info_header *)(adev->mman.discovery_bin + offset);
439 if (le32_to_cpu(mhdr->table_id) != MALL_INFO_TABLE_ID) {
440 dev_err(adev->dev, "invalid ip discovery mall table id\n");
445 if (!amdgpu_discovery_verify_checksum(adev->mman.discovery_bin + offset,
446 le32_to_cpu(mhdr->size_bytes), checksum)) {
447 dev_err(adev->dev, "invalid mall data table checksum\n");
456 kfree(adev->mman.discovery_bin);
457 adev->mman.discovery_bin = NULL;
462 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev);
464 void amdgpu_discovery_fini(struct amdgpu_device *adev)
466 amdgpu_discovery_sysfs_fini(adev);
467 kfree(adev->mman.discovery_bin);
468 adev->mman.discovery_bin = NULL;
471 static int amdgpu_discovery_validate_ip(const struct ip *ip)
473 if (ip->number_instance >= HWIP_MAX_INSTANCE) {
474 DRM_ERROR("Unexpected number_instance (%d) from ip discovery blob\n",
475 ip->number_instance);
478 if (le16_to_cpu(ip->hw_id) >= HW_ID_MAX) {
479 DRM_ERROR("Unexpected hw_id (%d) from ip discovery blob\n",
480 le16_to_cpu(ip->hw_id));
487 static void amdgpu_discovery_read_harvest_bit_per_ip(struct amdgpu_device *adev,
488 uint32_t *vcn_harvest_count)
490 struct binary_header *bhdr;
491 struct ip_discovery_header *ihdr;
492 struct die_header *dhdr;
494 uint16_t die_offset, ip_offset, num_dies, num_ips;
497 bhdr = (struct binary_header *)adev->mman.discovery_bin;
498 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
499 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
500 num_dies = le16_to_cpu(ihdr->num_dies);
502 /* scan harvest bit of all IP data structures */
503 for (i = 0; i < num_dies; i++) {
504 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
505 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
506 num_ips = le16_to_cpu(dhdr->num_ips);
507 ip_offset = die_offset + sizeof(*dhdr);
509 for (j = 0; j < num_ips; j++) {
510 ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
512 if (amdgpu_discovery_validate_ip(ip))
515 if (le16_to_cpu(ip->harvest) == 1) {
516 switch (le16_to_cpu(ip->hw_id)) {
518 (*vcn_harvest_count)++;
519 if (ip->number_instance == 0)
520 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN0;
522 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
525 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
532 ip_offset += struct_size(ip, base_address, ip->num_base_address);
537 static void amdgpu_discovery_read_from_harvest_table(struct amdgpu_device *adev,
538 uint32_t *vcn_harvest_count,
539 uint32_t *umc_harvest_count)
541 struct binary_header *bhdr;
542 struct harvest_table *harvest_info;
546 bhdr = (struct binary_header *)adev->mman.discovery_bin;
547 offset = le16_to_cpu(bhdr->table_list[HARVEST_INFO].offset);
550 dev_err(adev->dev, "invalid harvest table offset\n");
554 harvest_info = (struct harvest_table *)(adev->mman.discovery_bin + offset);
556 for (i = 0; i < 32; i++) {
557 if (le16_to_cpu(harvest_info->list[i].hw_id) == 0)
560 switch (le16_to_cpu(harvest_info->list[i].hw_id)) {
562 (*vcn_harvest_count)++;
563 if (harvest_info->list[i].number_instance == 0)
564 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN0;
566 adev->vcn.harvest_config |= AMDGPU_VCN_HARVEST_VCN1;
569 adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
572 (*umc_harvest_count)++;
580 /* ================================================== */
582 struct ip_hw_instance {
583 struct kobject kobj; /* ip_discovery/die/#die/#hw_id/#instance/<attrs...> */
587 u8 major, minor, revision;
590 int num_base_addresses;
595 struct kset hw_id_kset; /* ip_discovery/die/#die/#hw_id/, contains ip_hw_instance */
599 struct ip_die_entry {
600 struct kset ip_kset; /* ip_discovery/die/#die/, contains ip_hw_id */
604 /* -------------------------------------------------- */
606 struct ip_hw_instance_attr {
607 struct attribute attr;
608 ssize_t (*show)(struct ip_hw_instance *ip_hw_instance, char *buf);
611 static ssize_t hw_id_show(struct ip_hw_instance *ip_hw_instance, char *buf)
613 return sysfs_emit(buf, "%d\n", ip_hw_instance->hw_id);
616 static ssize_t num_instance_show(struct ip_hw_instance *ip_hw_instance, char *buf)
618 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_instance);
621 static ssize_t major_show(struct ip_hw_instance *ip_hw_instance, char *buf)
623 return sysfs_emit(buf, "%d\n", ip_hw_instance->major);
626 static ssize_t minor_show(struct ip_hw_instance *ip_hw_instance, char *buf)
628 return sysfs_emit(buf, "%d\n", ip_hw_instance->minor);
631 static ssize_t revision_show(struct ip_hw_instance *ip_hw_instance, char *buf)
633 return sysfs_emit(buf, "%d\n", ip_hw_instance->revision);
636 static ssize_t harvest_show(struct ip_hw_instance *ip_hw_instance, char *buf)
638 return sysfs_emit(buf, "0x%01X\n", ip_hw_instance->harvest);
641 static ssize_t num_base_addresses_show(struct ip_hw_instance *ip_hw_instance, char *buf)
643 return sysfs_emit(buf, "%d\n", ip_hw_instance->num_base_addresses);
646 static ssize_t base_addr_show(struct ip_hw_instance *ip_hw_instance, char *buf)
651 for (res = at = ii = 0; ii < ip_hw_instance->num_base_addresses; ii++) {
652 /* Here we satisfy the condition that, at + size <= PAGE_SIZE.
654 if (at + 12 > PAGE_SIZE)
656 res = sysfs_emit_at(buf, at, "0x%08X\n",
657 ip_hw_instance->base_addr[ii]);
663 return res < 0 ? res : at;
666 static struct ip_hw_instance_attr ip_hw_attr[] = {
668 __ATTR_RO(num_instance),
673 __ATTR_RO(num_base_addresses),
674 __ATTR_RO(base_addr),
677 static struct attribute *ip_hw_instance_attrs[ARRAY_SIZE(ip_hw_attr) + 1];
678 ATTRIBUTE_GROUPS(ip_hw_instance);
680 #define to_ip_hw_instance(x) container_of(x, struct ip_hw_instance, kobj)
681 #define to_ip_hw_instance_attr(x) container_of(x, struct ip_hw_instance_attr, attr)
683 static ssize_t ip_hw_instance_attr_show(struct kobject *kobj,
684 struct attribute *attr,
687 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
688 struct ip_hw_instance_attr *ip_hw_attr = to_ip_hw_instance_attr(attr);
690 if (!ip_hw_attr->show)
693 return ip_hw_attr->show(ip_hw_instance, buf);
696 static const struct sysfs_ops ip_hw_instance_sysfs_ops = {
697 .show = ip_hw_instance_attr_show,
700 static void ip_hw_instance_release(struct kobject *kobj)
702 struct ip_hw_instance *ip_hw_instance = to_ip_hw_instance(kobj);
704 kfree(ip_hw_instance);
707 static struct kobj_type ip_hw_instance_ktype = {
708 .release = ip_hw_instance_release,
709 .sysfs_ops = &ip_hw_instance_sysfs_ops,
710 .default_groups = ip_hw_instance_groups,
713 /* -------------------------------------------------- */
715 #define to_ip_hw_id(x) container_of(to_kset(x), struct ip_hw_id, hw_id_kset)
717 static void ip_hw_id_release(struct kobject *kobj)
719 struct ip_hw_id *ip_hw_id = to_ip_hw_id(kobj);
721 if (!list_empty(&ip_hw_id->hw_id_kset.list))
722 DRM_ERROR("ip_hw_id->hw_id_kset is not empty");
726 static struct kobj_type ip_hw_id_ktype = {
727 .release = ip_hw_id_release,
728 .sysfs_ops = &kobj_sysfs_ops,
731 /* -------------------------------------------------- */
733 static void die_kobj_release(struct kobject *kobj);
734 static void ip_disc_release(struct kobject *kobj);
736 struct ip_die_entry_attribute {
737 struct attribute attr;
738 ssize_t (*show)(struct ip_die_entry *ip_die_entry, char *buf);
741 #define to_ip_die_entry_attr(x) container_of(x, struct ip_die_entry_attribute, attr)
743 static ssize_t num_ips_show(struct ip_die_entry *ip_die_entry, char *buf)
745 return sysfs_emit(buf, "%d\n", ip_die_entry->num_ips);
748 /* If there are more ip_die_entry attrs, other than the number of IPs,
749 * we can make this intro an array of attrs, and then initialize
750 * ip_die_entry_attrs in a loop.
752 static struct ip_die_entry_attribute num_ips_attr =
755 static struct attribute *ip_die_entry_attrs[] = {
759 ATTRIBUTE_GROUPS(ip_die_entry); /* ip_die_entry_groups */
761 #define to_ip_die_entry(x) container_of(to_kset(x), struct ip_die_entry, ip_kset)
763 static ssize_t ip_die_entry_attr_show(struct kobject *kobj,
764 struct attribute *attr,
767 struct ip_die_entry_attribute *ip_die_entry_attr = to_ip_die_entry_attr(attr);
768 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
770 if (!ip_die_entry_attr->show)
773 return ip_die_entry_attr->show(ip_die_entry, buf);
776 static void ip_die_entry_release(struct kobject *kobj)
778 struct ip_die_entry *ip_die_entry = to_ip_die_entry(kobj);
780 if (!list_empty(&ip_die_entry->ip_kset.list))
781 DRM_ERROR("ip_die_entry->ip_kset is not empty");
785 static const struct sysfs_ops ip_die_entry_sysfs_ops = {
786 .show = ip_die_entry_attr_show,
789 static struct kobj_type ip_die_entry_ktype = {
790 .release = ip_die_entry_release,
791 .sysfs_ops = &ip_die_entry_sysfs_ops,
792 .default_groups = ip_die_entry_groups,
795 static struct kobj_type die_kobj_ktype = {
796 .release = die_kobj_release,
797 .sysfs_ops = &kobj_sysfs_ops,
800 static struct kobj_type ip_discovery_ktype = {
801 .release = ip_disc_release,
802 .sysfs_ops = &kobj_sysfs_ops,
805 struct ip_discovery_top {
806 struct kobject kobj; /* ip_discovery/ */
807 struct kset die_kset; /* ip_discovery/die/, contains ip_die_entry */
808 struct amdgpu_device *adev;
811 static void die_kobj_release(struct kobject *kobj)
813 struct ip_discovery_top *ip_top = container_of(to_kset(kobj),
814 struct ip_discovery_top,
816 if (!list_empty(&ip_top->die_kset.list))
817 DRM_ERROR("ip_top->die_kset is not empty");
820 static void ip_disc_release(struct kobject *kobj)
822 struct ip_discovery_top *ip_top = container_of(kobj, struct ip_discovery_top,
824 struct amdgpu_device *adev = ip_top->adev;
830 static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev,
831 struct ip_die_entry *ip_die_entry,
832 const size_t _ip_offset, const int num_ips)
836 DRM_DEBUG("num_ips:%d", num_ips);
838 /* Find all IPs of a given HW ID, and add their instance to
839 * #die/#hw_id/#instance/<attributes>
841 for (ii = 0; ii < HW_ID_MAX; ii++) {
842 struct ip_hw_id *ip_hw_id = NULL;
843 size_t ip_offset = _ip_offset;
845 for (jj = 0; jj < num_ips; jj++) {
847 struct ip_hw_instance *ip_hw_instance;
849 ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
850 if (amdgpu_discovery_validate_ip(ip) ||
851 le16_to_cpu(ip->hw_id) != ii)
854 DRM_DEBUG("match:%d @ ip_offset:%zu", ii, ip_offset);
856 /* We have a hw_id match; register the hw
857 * block if not yet registered.
860 ip_hw_id = kzalloc(sizeof(*ip_hw_id), GFP_KERNEL);
863 ip_hw_id->hw_id = ii;
865 kobject_set_name(&ip_hw_id->hw_id_kset.kobj, "%d", ii);
866 ip_hw_id->hw_id_kset.kobj.kset = &ip_die_entry->ip_kset;
867 ip_hw_id->hw_id_kset.kobj.ktype = &ip_hw_id_ktype;
868 res = kset_register(&ip_hw_id->hw_id_kset);
870 DRM_ERROR("Couldn't register ip_hw_id kset");
874 if (hw_id_names[ii]) {
875 res = sysfs_create_link(&ip_die_entry->ip_kset.kobj,
876 &ip_hw_id->hw_id_kset.kobj,
879 DRM_ERROR("Couldn't create IP link %s in IP Die:%s\n",
881 kobject_name(&ip_die_entry->ip_kset.kobj));
886 /* Now register its instance.
888 ip_hw_instance = kzalloc(struct_size(ip_hw_instance,
890 ip->num_base_address),
892 if (!ip_hw_instance) {
893 DRM_ERROR("no memory for ip_hw_instance");
896 ip_hw_instance->hw_id = le16_to_cpu(ip->hw_id); /* == ii */
897 ip_hw_instance->num_instance = ip->number_instance;
898 ip_hw_instance->major = ip->major;
899 ip_hw_instance->minor = ip->minor;
900 ip_hw_instance->revision = ip->revision;
901 ip_hw_instance->harvest = ip->harvest;
902 ip_hw_instance->num_base_addresses = ip->num_base_address;
904 for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++)
905 ip_hw_instance->base_addr[kk] = ip->base_address[kk];
907 kobject_init(&ip_hw_instance->kobj, &ip_hw_instance_ktype);
908 ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset;
909 res = kobject_add(&ip_hw_instance->kobj, NULL,
910 "%d", ip_hw_instance->num_instance);
912 ip_offset += struct_size(ip, base_address, ip->num_base_address);
919 static int amdgpu_discovery_sysfs_recurse(struct amdgpu_device *adev)
921 struct binary_header *bhdr;
922 struct ip_discovery_header *ihdr;
923 struct die_header *dhdr;
924 struct kset *die_kset = &adev->ip_top->die_kset;
925 u16 num_dies, die_offset, num_ips;
929 bhdr = (struct binary_header *)adev->mman.discovery_bin;
930 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
931 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
932 num_dies = le16_to_cpu(ihdr->num_dies);
934 DRM_DEBUG("number of dies: %d\n", num_dies);
936 for (ii = 0; ii < num_dies; ii++) {
937 struct ip_die_entry *ip_die_entry;
939 die_offset = le16_to_cpu(ihdr->die_info[ii].die_offset);
940 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
941 num_ips = le16_to_cpu(dhdr->num_ips);
942 ip_offset = die_offset + sizeof(*dhdr);
944 /* Add the die to the kset.
946 * dhdr->die_id == ii, which was checked in
947 * amdgpu_discovery_reg_base_init().
950 ip_die_entry = kzalloc(sizeof(*ip_die_entry), GFP_KERNEL);
954 ip_die_entry->num_ips = num_ips;
956 kobject_set_name(&ip_die_entry->ip_kset.kobj, "%d", le16_to_cpu(dhdr->die_id));
957 ip_die_entry->ip_kset.kobj.kset = die_kset;
958 ip_die_entry->ip_kset.kobj.ktype = &ip_die_entry_ktype;
959 res = kset_register(&ip_die_entry->ip_kset);
961 DRM_ERROR("Couldn't register ip_die_entry kset");
966 amdgpu_discovery_sysfs_ips(adev, ip_die_entry, ip_offset, num_ips);
972 static int amdgpu_discovery_sysfs_init(struct amdgpu_device *adev)
974 struct kset *die_kset;
977 adev->ip_top = kzalloc(sizeof(*adev->ip_top), GFP_KERNEL);
981 adev->ip_top->adev = adev;
983 res = kobject_init_and_add(&adev->ip_top->kobj, &ip_discovery_ktype,
984 &adev->dev->kobj, "ip_discovery");
986 DRM_ERROR("Couldn't init and add ip_discovery/");
990 die_kset = &adev->ip_top->die_kset;
991 kobject_set_name(&die_kset->kobj, "%s", "die");
992 die_kset->kobj.parent = &adev->ip_top->kobj;
993 die_kset->kobj.ktype = &die_kobj_ktype;
994 res = kset_register(&adev->ip_top->die_kset);
996 DRM_ERROR("Couldn't register die_kset");
1000 for (ii = 0; ii < ARRAY_SIZE(ip_hw_attr); ii++)
1001 ip_hw_instance_attrs[ii] = &ip_hw_attr[ii].attr;
1002 ip_hw_instance_attrs[ii] = NULL;
1004 res = amdgpu_discovery_sysfs_recurse(adev);
1008 kobject_put(&adev->ip_top->kobj);
1012 /* -------------------------------------------------- */
1014 #define list_to_kobj(el) container_of(el, struct kobject, entry)
1016 static void amdgpu_discovery_sysfs_ip_hw_free(struct ip_hw_id *ip_hw_id)
1018 struct list_head *el, *tmp;
1019 struct kset *hw_id_kset;
1021 hw_id_kset = &ip_hw_id->hw_id_kset;
1022 spin_lock(&hw_id_kset->list_lock);
1023 list_for_each_prev_safe(el, tmp, &hw_id_kset->list) {
1025 spin_unlock(&hw_id_kset->list_lock);
1026 /* kobject is embedded in ip_hw_instance */
1027 kobject_put(list_to_kobj(el));
1028 spin_lock(&hw_id_kset->list_lock);
1030 spin_unlock(&hw_id_kset->list_lock);
1031 kobject_put(&ip_hw_id->hw_id_kset.kobj);
1034 static void amdgpu_discovery_sysfs_die_free(struct ip_die_entry *ip_die_entry)
1036 struct list_head *el, *tmp;
1037 struct kset *ip_kset;
1039 ip_kset = &ip_die_entry->ip_kset;
1040 spin_lock(&ip_kset->list_lock);
1041 list_for_each_prev_safe(el, tmp, &ip_kset->list) {
1043 spin_unlock(&ip_kset->list_lock);
1044 amdgpu_discovery_sysfs_ip_hw_free(to_ip_hw_id(list_to_kobj(el)));
1045 spin_lock(&ip_kset->list_lock);
1047 spin_unlock(&ip_kset->list_lock);
1048 kobject_put(&ip_die_entry->ip_kset.kobj);
1051 static void amdgpu_discovery_sysfs_fini(struct amdgpu_device *adev)
1053 struct list_head *el, *tmp;
1054 struct kset *die_kset;
1056 die_kset = &adev->ip_top->die_kset;
1057 spin_lock(&die_kset->list_lock);
1058 list_for_each_prev_safe(el, tmp, &die_kset->list) {
1060 spin_unlock(&die_kset->list_lock);
1061 amdgpu_discovery_sysfs_die_free(to_ip_die_entry(list_to_kobj(el)));
1062 spin_lock(&die_kset->list_lock);
1064 spin_unlock(&die_kset->list_lock);
1065 kobject_put(&adev->ip_top->die_kset.kobj);
1066 kobject_put(&adev->ip_top->kobj);
1069 /* ================================================== */
1071 static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
1073 struct binary_header *bhdr;
1074 struct ip_discovery_header *ihdr;
1075 struct die_header *dhdr;
1077 uint16_t die_offset;
1081 uint8_t num_base_address;
1086 r = amdgpu_discovery_init(adev);
1088 DRM_ERROR("amdgpu_discovery_init failed\n");
1092 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1093 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1094 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1095 num_dies = le16_to_cpu(ihdr->num_dies);
1097 DRM_DEBUG("number of dies: %d\n", num_dies);
1099 for (i = 0; i < num_dies; i++) {
1100 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
1101 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1102 num_ips = le16_to_cpu(dhdr->num_ips);
1103 ip_offset = die_offset + sizeof(*dhdr);
1105 if (le16_to_cpu(dhdr->die_id) != i) {
1106 DRM_ERROR("invalid die id %d, expected %d\n",
1107 le16_to_cpu(dhdr->die_id), i);
1111 DRM_DEBUG("number of hardware IPs on die%d: %d\n",
1112 le16_to_cpu(dhdr->die_id), num_ips);
1114 for (j = 0; j < num_ips; j++) {
1115 ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
1117 if (amdgpu_discovery_validate_ip(ip))
1120 num_base_address = ip->num_base_address;
1122 DRM_DEBUG("%s(%d) #%d v%d.%d.%d:\n",
1123 hw_id_names[le16_to_cpu(ip->hw_id)],
1124 le16_to_cpu(ip->hw_id),
1125 ip->number_instance,
1126 ip->major, ip->minor,
1129 if (le16_to_cpu(ip->hw_id) == VCN_HWID) {
1130 /* Bit [5:0]: original revision value
1131 * Bit [7:6]: en/decode capability:
1132 * 0b00 : VCN function normally
1133 * 0b10 : encode is disabled
1134 * 0b01 : decode is disabled
1136 adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
1137 ip->revision & 0xc0;
1138 ip->revision &= ~0xc0;
1139 if (adev->vcn.num_vcn_inst < AMDGPU_MAX_VCN_INSTANCES)
1140 adev->vcn.num_vcn_inst++;
1142 dev_err(adev->dev, "Too many VCN instances: %d vs %d\n",
1143 adev->vcn.num_vcn_inst + 1,
1144 AMDGPU_MAX_VCN_INSTANCES);
1146 if (le16_to_cpu(ip->hw_id) == SDMA0_HWID ||
1147 le16_to_cpu(ip->hw_id) == SDMA1_HWID ||
1148 le16_to_cpu(ip->hw_id) == SDMA2_HWID ||
1149 le16_to_cpu(ip->hw_id) == SDMA3_HWID) {
1150 if (adev->sdma.num_instances < AMDGPU_MAX_SDMA_INSTANCES)
1151 adev->sdma.num_instances++;
1153 dev_err(adev->dev, "Too many SDMA instances: %d vs %d\n",
1154 adev->sdma.num_instances + 1,
1155 AMDGPU_MAX_SDMA_INSTANCES);
1158 if (le16_to_cpu(ip->hw_id) == UMC_HWID)
1159 adev->gmc.num_umc++;
1161 for (k = 0; k < num_base_address; k++) {
1163 * convert the endianness of base addresses in place,
1164 * so that we don't need to convert them when accessing adev->reg_offset.
1166 ip->base_address[k] = le32_to_cpu(ip->base_address[k]);
1167 DRM_DEBUG("\t0x%08x\n", ip->base_address[k]);
1170 for (hw_ip = 0; hw_ip < MAX_HWIP; hw_ip++) {
1171 if (hw_id_map[hw_ip] == le16_to_cpu(ip->hw_id)) {
1172 DRM_DEBUG("set register base offset for %s\n",
1173 hw_id_names[le16_to_cpu(ip->hw_id)]);
1174 adev->reg_offset[hw_ip][ip->number_instance] =
1176 /* Instance support is somewhat inconsistent.
1177 * SDMA is a good example. Sienna cichlid has 4 total
1178 * SDMA instances, each enumerated separately (HWIDs
1179 * 42, 43, 68, 69). Arcturus has 8 total SDMA instances,
1180 * but they are enumerated as multiple instances of the
1181 * same HWIDs (4x HWID 42, 4x HWID 43). UMC is another
1182 * example. On most chips there are multiple instances
1183 * with the same HWID.
1185 adev->ip_versions[hw_ip][ip->number_instance] =
1186 IP_VERSION(ip->major, ip->minor, ip->revision);
1191 ip_offset += struct_size(ip, base_address, ip->num_base_address);
1195 amdgpu_discovery_sysfs_init(adev);
1200 int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id, int number_instance,
1201 int *major, int *minor, int *revision)
1203 struct binary_header *bhdr;
1204 struct ip_discovery_header *ihdr;
1205 struct die_header *dhdr;
1207 uint16_t die_offset;
1213 if (!adev->mman.discovery_bin) {
1214 DRM_ERROR("ip discovery uninitialized\n");
1218 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1219 ihdr = (struct ip_discovery_header *)(adev->mman.discovery_bin +
1220 le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
1221 num_dies = le16_to_cpu(ihdr->num_dies);
1223 for (i = 0; i < num_dies; i++) {
1224 die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
1225 dhdr = (struct die_header *)(adev->mman.discovery_bin + die_offset);
1226 num_ips = le16_to_cpu(dhdr->num_ips);
1227 ip_offset = die_offset + sizeof(*dhdr);
1229 for (j = 0; j < num_ips; j++) {
1230 ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
1232 if ((le16_to_cpu(ip->hw_id) == hw_id) && (ip->number_instance == number_instance)) {
1238 *revision = ip->revision;
1241 ip_offset += struct_size(ip, base_address, ip->num_base_address);
1248 static void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
1250 int vcn_harvest_count = 0;
1251 int umc_harvest_count = 0;
1254 * Harvest table does not fit Navi1x and legacy GPUs,
1255 * so read harvest bit per IP data structure to set
1256 * harvest configuration.
1258 if (adev->ip_versions[GC_HWIP][0] < IP_VERSION(10, 2, 0)) {
1259 if ((adev->pdev->device == 0x731E &&
1260 (adev->pdev->revision == 0xC6 ||
1261 adev->pdev->revision == 0xC7)) ||
1262 (adev->pdev->device == 0x7340 &&
1263 adev->pdev->revision == 0xC9) ||
1264 (adev->pdev->device == 0x7360 &&
1265 adev->pdev->revision == 0xC7))
1266 amdgpu_discovery_read_harvest_bit_per_ip(adev,
1267 &vcn_harvest_count);
1269 amdgpu_discovery_read_from_harvest_table(adev,
1271 &umc_harvest_count);
1274 amdgpu_discovery_harvest_config_quirk(adev);
1276 if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
1277 adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
1278 adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
1281 if (umc_harvest_count < adev->gmc.num_umc) {
1282 adev->gmc.num_umc -= umc_harvest_count;
1287 struct gc_info_v1_0 v1;
1288 struct gc_info_v1_1 v1_1;
1289 struct gc_info_v1_2 v1_2;
1290 struct gc_info_v2_0 v2;
1293 static int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
1295 struct binary_header *bhdr;
1296 union gc_info *gc_info;
1299 if (!adev->mman.discovery_bin) {
1300 DRM_ERROR("ip discovery uninitialized\n");
1304 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1305 offset = le16_to_cpu(bhdr->table_list[GC].offset);
1310 gc_info = (union gc_info *)(adev->mman.discovery_bin + offset);
1312 switch (le16_to_cpu(gc_info->v1.header.version_major)) {
1314 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v1.gc_num_se);
1315 adev->gfx.config.max_cu_per_sh = 2 * (le32_to_cpu(gc_info->v1.gc_num_wgp0_per_sa) +
1316 le32_to_cpu(gc_info->v1.gc_num_wgp1_per_sa));
1317 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1318 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v1.gc_num_rb_per_se);
1319 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v1.gc_num_gl2c);
1320 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v1.gc_num_gprs);
1321 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v1.gc_num_max_gs_thds);
1322 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v1.gc_gs_table_depth);
1323 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v1.gc_gsprim_buff_depth);
1324 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v1.gc_double_offchip_lds_buffer);
1325 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v1.gc_wave_size);
1326 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v1.gc_max_waves_per_simd);
1327 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v1.gc_max_scratch_slots_per_cu);
1328 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v1.gc_lds_size);
1329 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v1.gc_num_sc_per_se) /
1330 le32_to_cpu(gc_info->v1.gc_num_sa_per_se);
1331 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v1.gc_num_packer_per_sc);
1332 if (gc_info->v1.header.version_minor >= 1) {
1333 adev->gfx.config.gc_num_tcp_per_sa = le32_to_cpu(gc_info->v1_1.gc_num_tcp_per_sa);
1334 adev->gfx.config.gc_num_sdp_interface = le32_to_cpu(gc_info->v1_1.gc_num_sdp_interface);
1335 adev->gfx.config.gc_num_tcps = le32_to_cpu(gc_info->v1_1.gc_num_tcps);
1337 if (gc_info->v1.header.version_minor >= 2) {
1338 adev->gfx.config.gc_num_tcp_per_wpg = le32_to_cpu(gc_info->v1_2.gc_num_tcp_per_wpg);
1339 adev->gfx.config.gc_tcp_l1_size = le32_to_cpu(gc_info->v1_2.gc_tcp_l1_size);
1340 adev->gfx.config.gc_num_sqc_per_wgp = le32_to_cpu(gc_info->v1_2.gc_num_sqc_per_wgp);
1341 adev->gfx.config.gc_l1_instruction_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_instruction_cache_size_per_sqc);
1342 adev->gfx.config.gc_l1_data_cache_size_per_sqc = le32_to_cpu(gc_info->v1_2.gc_l1_data_cache_size_per_sqc);
1343 adev->gfx.config.gc_gl1c_per_sa = le32_to_cpu(gc_info->v1_2.gc_gl1c_per_sa);
1344 adev->gfx.config.gc_gl1c_size_per_instance = le32_to_cpu(gc_info->v1_2.gc_gl1c_size_per_instance);
1345 adev->gfx.config.gc_gl2c_per_gpu = le32_to_cpu(gc_info->v1_2.gc_gl2c_per_gpu);
1349 adev->gfx.config.max_shader_engines = le32_to_cpu(gc_info->v2.gc_num_se);
1350 adev->gfx.config.max_cu_per_sh = le32_to_cpu(gc_info->v2.gc_num_cu_per_sh);
1351 adev->gfx.config.max_sh_per_se = le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1352 adev->gfx.config.max_backends_per_se = le32_to_cpu(gc_info->v2.gc_num_rb_per_se);
1353 adev->gfx.config.max_texture_channel_caches = le32_to_cpu(gc_info->v2.gc_num_tccs);
1354 adev->gfx.config.max_gprs = le32_to_cpu(gc_info->v2.gc_num_gprs);
1355 adev->gfx.config.max_gs_threads = le32_to_cpu(gc_info->v2.gc_num_max_gs_thds);
1356 adev->gfx.config.gs_vgt_table_depth = le32_to_cpu(gc_info->v2.gc_gs_table_depth);
1357 adev->gfx.config.gs_prim_buffer_depth = le32_to_cpu(gc_info->v2.gc_gsprim_buff_depth);
1358 adev->gfx.config.double_offchip_lds_buf = le32_to_cpu(gc_info->v2.gc_double_offchip_lds_buffer);
1359 adev->gfx.cu_info.wave_front_size = le32_to_cpu(gc_info->v2.gc_wave_size);
1360 adev->gfx.cu_info.max_waves_per_simd = le32_to_cpu(gc_info->v2.gc_max_waves_per_simd);
1361 adev->gfx.cu_info.max_scratch_slots_per_cu = le32_to_cpu(gc_info->v2.gc_max_scratch_slots_per_cu);
1362 adev->gfx.cu_info.lds_size = le32_to_cpu(gc_info->v2.gc_lds_size);
1363 adev->gfx.config.num_sc_per_sh = le32_to_cpu(gc_info->v2.gc_num_sc_per_se) /
1364 le32_to_cpu(gc_info->v2.gc_num_sh_per_se);
1365 adev->gfx.config.num_packer_per_sc = le32_to_cpu(gc_info->v2.gc_num_packer_per_sc);
1369 "Unhandled GC info table %d.%d\n",
1370 le16_to_cpu(gc_info->v1.header.version_major),
1371 le16_to_cpu(gc_info->v1.header.version_minor));
1378 struct mall_info_v1_0 v1;
1381 static int amdgpu_discovery_get_mall_info(struct amdgpu_device *adev)
1383 struct binary_header *bhdr;
1384 union mall_info *mall_info;
1385 u32 u, mall_size_per_umc, m_s_present, half_use;
1389 if (!adev->mman.discovery_bin) {
1390 DRM_ERROR("ip discovery uninitialized\n");
1394 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1395 offset = le16_to_cpu(bhdr->table_list[MALL_INFO].offset);
1400 mall_info = (union mall_info *)(adev->mman.discovery_bin + offset);
1402 switch (le16_to_cpu(mall_info->v1.header.version_major)) {
1405 mall_size_per_umc = le32_to_cpu(mall_info->v1.mall_size_per_m);
1406 m_s_present = le32_to_cpu(mall_info->v1.m_s_present);
1407 half_use = le32_to_cpu(mall_info->v1.m_half_use);
1408 for (u = 0; u < adev->gmc.num_umc; u++) {
1409 if (m_s_present & (1 << u))
1410 mall_size += mall_size_per_umc * 2;
1411 else if (half_use & (1 << u))
1412 mall_size += mall_size_per_umc / 2;
1414 mall_size += mall_size_per_umc;
1416 adev->gmc.mall_size = mall_size;
1420 "Unhandled MALL info table %d.%d\n",
1421 le16_to_cpu(mall_info->v1.header.version_major),
1422 le16_to_cpu(mall_info->v1.header.version_minor));
1429 struct vcn_info_v1_0 v1;
1432 static int amdgpu_discovery_get_vcn_info(struct amdgpu_device *adev)
1434 struct binary_header *bhdr;
1435 union vcn_info *vcn_info;
1439 if (!adev->mman.discovery_bin) {
1440 DRM_ERROR("ip discovery uninitialized\n");
1444 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1445 * which is smaller than VCN_INFO_TABLE_MAX_NUM_INSTANCES
1446 * but that may change in the future with new GPUs so keep this
1447 * check for defensive purposes.
1449 if (adev->vcn.num_vcn_inst > VCN_INFO_TABLE_MAX_NUM_INSTANCES) {
1450 dev_err(adev->dev, "invalid vcn instances\n");
1454 bhdr = (struct binary_header *)adev->mman.discovery_bin;
1455 offset = le16_to_cpu(bhdr->table_list[VCN_INFO].offset);
1460 vcn_info = (union vcn_info *)(adev->mman.discovery_bin + offset);
1462 switch (le16_to_cpu(vcn_info->v1.header.version_major)) {
1464 /* num_vcn_inst is currently limited to AMDGPU_MAX_VCN_INSTANCES
1465 * so this won't overflow.
1467 for (v = 0; v < adev->vcn.num_vcn_inst; v++) {
1468 adev->vcn.vcn_codec_disable_mask[v] =
1469 le32_to_cpu(vcn_info->v1.instance_info[v].fuse_data.all_bits);
1474 "Unhandled VCN info table %d.%d\n",
1475 le16_to_cpu(vcn_info->v1.header.version_major),
1476 le16_to_cpu(vcn_info->v1.header.version_minor));
1482 static int amdgpu_discovery_set_common_ip_blocks(struct amdgpu_device *adev)
1484 /* what IP to use for this? */
1485 switch (adev->ip_versions[GC_HWIP][0]) {
1486 case IP_VERSION(9, 0, 1):
1487 case IP_VERSION(9, 1, 0):
1488 case IP_VERSION(9, 2, 1):
1489 case IP_VERSION(9, 2, 2):
1490 case IP_VERSION(9, 3, 0):
1491 case IP_VERSION(9, 4, 0):
1492 case IP_VERSION(9, 4, 1):
1493 case IP_VERSION(9, 4, 2):
1494 amdgpu_device_ip_block_add(adev, &vega10_common_ip_block);
1496 case IP_VERSION(10, 1, 10):
1497 case IP_VERSION(10, 1, 1):
1498 case IP_VERSION(10, 1, 2):
1499 case IP_VERSION(10, 1, 3):
1500 case IP_VERSION(10, 1, 4):
1501 case IP_VERSION(10, 3, 0):
1502 case IP_VERSION(10, 3, 1):
1503 case IP_VERSION(10, 3, 2):
1504 case IP_VERSION(10, 3, 3):
1505 case IP_VERSION(10, 3, 4):
1506 case IP_VERSION(10, 3, 5):
1507 case IP_VERSION(10, 3, 6):
1508 case IP_VERSION(10, 3, 7):
1509 amdgpu_device_ip_block_add(adev, &nv_common_ip_block);
1511 case IP_VERSION(11, 0, 0):
1512 case IP_VERSION(11, 0, 1):
1513 case IP_VERSION(11, 0, 2):
1514 case IP_VERSION(11, 0, 3):
1515 case IP_VERSION(11, 0, 4):
1516 amdgpu_device_ip_block_add(adev, &soc21_common_ip_block);
1520 "Failed to add common ip block(GC_HWIP:0x%x)\n",
1521 adev->ip_versions[GC_HWIP][0]);
1527 static int amdgpu_discovery_set_gmc_ip_blocks(struct amdgpu_device *adev)
1529 /* use GC or MMHUB IP version */
1530 switch (adev->ip_versions[GC_HWIP][0]) {
1531 case IP_VERSION(9, 0, 1):
1532 case IP_VERSION(9, 1, 0):
1533 case IP_VERSION(9, 2, 1):
1534 case IP_VERSION(9, 2, 2):
1535 case IP_VERSION(9, 3, 0):
1536 case IP_VERSION(9, 4, 0):
1537 case IP_VERSION(9, 4, 1):
1538 case IP_VERSION(9, 4, 2):
1539 amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block);
1541 case IP_VERSION(10, 1, 10):
1542 case IP_VERSION(10, 1, 1):
1543 case IP_VERSION(10, 1, 2):
1544 case IP_VERSION(10, 1, 3):
1545 case IP_VERSION(10, 1, 4):
1546 case IP_VERSION(10, 3, 0):
1547 case IP_VERSION(10, 3, 1):
1548 case IP_VERSION(10, 3, 2):
1549 case IP_VERSION(10, 3, 3):
1550 case IP_VERSION(10, 3, 4):
1551 case IP_VERSION(10, 3, 5):
1552 case IP_VERSION(10, 3, 6):
1553 case IP_VERSION(10, 3, 7):
1554 amdgpu_device_ip_block_add(adev, &gmc_v10_0_ip_block);
1556 case IP_VERSION(11, 0, 0):
1557 case IP_VERSION(11, 0, 1):
1558 case IP_VERSION(11, 0, 2):
1559 case IP_VERSION(11, 0, 3):
1560 case IP_VERSION(11, 0, 4):
1561 amdgpu_device_ip_block_add(adev, &gmc_v11_0_ip_block);
1565 "Failed to add gmc ip block(GC_HWIP:0x%x)\n",
1566 adev->ip_versions[GC_HWIP][0]);
1572 static int amdgpu_discovery_set_ih_ip_blocks(struct amdgpu_device *adev)
1574 switch (adev->ip_versions[OSSSYS_HWIP][0]) {
1575 case IP_VERSION(4, 0, 0):
1576 case IP_VERSION(4, 0, 1):
1577 case IP_VERSION(4, 1, 0):
1578 case IP_VERSION(4, 1, 1):
1579 case IP_VERSION(4, 3, 0):
1580 amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block);
1582 case IP_VERSION(4, 2, 0):
1583 case IP_VERSION(4, 2, 1):
1584 case IP_VERSION(4, 4, 0):
1585 amdgpu_device_ip_block_add(adev, &vega20_ih_ip_block);
1587 case IP_VERSION(5, 0, 0):
1588 case IP_VERSION(5, 0, 1):
1589 case IP_VERSION(5, 0, 2):
1590 case IP_VERSION(5, 0, 3):
1591 case IP_VERSION(5, 2, 0):
1592 case IP_VERSION(5, 2, 1):
1593 amdgpu_device_ip_block_add(adev, &navi10_ih_ip_block);
1595 case IP_VERSION(6, 0, 0):
1596 case IP_VERSION(6, 0, 1):
1597 case IP_VERSION(6, 0, 2):
1598 amdgpu_device_ip_block_add(adev, &ih_v6_0_ip_block);
1602 "Failed to add ih ip block(OSSSYS_HWIP:0x%x)\n",
1603 adev->ip_versions[OSSSYS_HWIP][0]);
1609 static int amdgpu_discovery_set_psp_ip_blocks(struct amdgpu_device *adev)
1611 switch (adev->ip_versions[MP0_HWIP][0]) {
1612 case IP_VERSION(9, 0, 0):
1613 amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block);
1615 case IP_VERSION(10, 0, 0):
1616 case IP_VERSION(10, 0, 1):
1617 amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block);
1619 case IP_VERSION(11, 0, 0):
1620 case IP_VERSION(11, 0, 2):
1621 case IP_VERSION(11, 0, 4):
1622 case IP_VERSION(11, 0, 5):
1623 case IP_VERSION(11, 0, 9):
1624 case IP_VERSION(11, 0, 7):
1625 case IP_VERSION(11, 0, 11):
1626 case IP_VERSION(11, 0, 12):
1627 case IP_VERSION(11, 0, 13):
1628 case IP_VERSION(11, 5, 0):
1629 amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block);
1631 case IP_VERSION(11, 0, 8):
1632 amdgpu_device_ip_block_add(adev, &psp_v11_0_8_ip_block);
1634 case IP_VERSION(11, 0, 3):
1635 case IP_VERSION(12, 0, 1):
1636 amdgpu_device_ip_block_add(adev, &psp_v12_0_ip_block);
1638 case IP_VERSION(13, 0, 0):
1639 case IP_VERSION(13, 0, 1):
1640 case IP_VERSION(13, 0, 2):
1641 case IP_VERSION(13, 0, 3):
1642 case IP_VERSION(13, 0, 5):
1643 case IP_VERSION(13, 0, 7):
1644 case IP_VERSION(13, 0, 8):
1645 case IP_VERSION(13, 0, 10):
1646 amdgpu_device_ip_block_add(adev, &psp_v13_0_ip_block);
1648 case IP_VERSION(13, 0, 4):
1649 amdgpu_device_ip_block_add(adev, &psp_v13_0_4_ip_block);
1653 "Failed to add psp ip block(MP0_HWIP:0x%x)\n",
1654 adev->ip_versions[MP0_HWIP][0]);
1660 static int amdgpu_discovery_set_smu_ip_blocks(struct amdgpu_device *adev)
1662 switch (adev->ip_versions[MP1_HWIP][0]) {
1663 case IP_VERSION(9, 0, 0):
1664 case IP_VERSION(10, 0, 0):
1665 case IP_VERSION(10, 0, 1):
1666 case IP_VERSION(11, 0, 2):
1667 if (adev->asic_type == CHIP_ARCTURUS)
1668 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1670 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block);
1672 case IP_VERSION(11, 0, 0):
1673 case IP_VERSION(11, 0, 5):
1674 case IP_VERSION(11, 0, 9):
1675 case IP_VERSION(11, 0, 7):
1676 case IP_VERSION(11, 0, 8):
1677 case IP_VERSION(11, 0, 11):
1678 case IP_VERSION(11, 0, 12):
1679 case IP_VERSION(11, 0, 13):
1680 case IP_VERSION(11, 5, 0):
1681 amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
1683 case IP_VERSION(12, 0, 0):
1684 case IP_VERSION(12, 0, 1):
1685 amdgpu_device_ip_block_add(adev, &smu_v12_0_ip_block);
1687 case IP_VERSION(13, 0, 0):
1688 case IP_VERSION(13, 0, 1):
1689 case IP_VERSION(13, 0, 2):
1690 case IP_VERSION(13, 0, 3):
1691 case IP_VERSION(13, 0, 4):
1692 case IP_VERSION(13, 0, 5):
1693 case IP_VERSION(13, 0, 7):
1694 case IP_VERSION(13, 0, 8):
1695 case IP_VERSION(13, 0, 10):
1696 amdgpu_device_ip_block_add(adev, &smu_v13_0_ip_block);
1700 "Failed to add smu ip block(MP1_HWIP:0x%x)\n",
1701 adev->ip_versions[MP1_HWIP][0]);
1707 #if defined(CONFIG_DRM_AMD_DC)
1708 static void amdgpu_discovery_set_sriov_display(struct amdgpu_device *adev)
1710 amdgpu_device_set_sriov_virtual_display(adev);
1711 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1715 static int amdgpu_discovery_set_display_ip_blocks(struct amdgpu_device *adev)
1717 if (adev->enable_virtual_display) {
1718 amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
1722 if (!amdgpu_device_has_dc_support(adev))
1725 #if defined(CONFIG_DRM_AMD_DC)
1726 if (adev->ip_versions[DCE_HWIP][0]) {
1727 switch (adev->ip_versions[DCE_HWIP][0]) {
1728 case IP_VERSION(1, 0, 0):
1729 case IP_VERSION(1, 0, 1):
1730 case IP_VERSION(2, 0, 2):
1731 case IP_VERSION(2, 0, 0):
1732 case IP_VERSION(2, 0, 3):
1733 case IP_VERSION(2, 1, 0):
1734 case IP_VERSION(3, 0, 0):
1735 case IP_VERSION(3, 0, 2):
1736 case IP_VERSION(3, 0, 3):
1737 case IP_VERSION(3, 0, 1):
1738 case IP_VERSION(3, 1, 2):
1739 case IP_VERSION(3, 1, 3):
1740 case IP_VERSION(3, 1, 4):
1741 case IP_VERSION(3, 1, 5):
1742 case IP_VERSION(3, 1, 6):
1743 case IP_VERSION(3, 2, 0):
1744 case IP_VERSION(3, 2, 1):
1745 if (amdgpu_sriov_vf(adev))
1746 amdgpu_discovery_set_sriov_display(adev);
1748 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1752 "Failed to add dm ip block(DCE_HWIP:0x%x)\n",
1753 adev->ip_versions[DCE_HWIP][0]);
1756 } else if (adev->ip_versions[DCI_HWIP][0]) {
1757 switch (adev->ip_versions[DCI_HWIP][0]) {
1758 case IP_VERSION(12, 0, 0):
1759 case IP_VERSION(12, 0, 1):
1760 case IP_VERSION(12, 1, 0):
1761 if (amdgpu_sriov_vf(adev))
1762 amdgpu_discovery_set_sriov_display(adev);
1764 amdgpu_device_ip_block_add(adev, &dm_ip_block);
1768 "Failed to add dm ip block(DCI_HWIP:0x%x)\n",
1769 adev->ip_versions[DCI_HWIP][0]);
1777 static int amdgpu_discovery_set_gc_ip_blocks(struct amdgpu_device *adev)
1779 switch (adev->ip_versions[GC_HWIP][0]) {
1780 case IP_VERSION(9, 0, 1):
1781 case IP_VERSION(9, 1, 0):
1782 case IP_VERSION(9, 2, 1):
1783 case IP_VERSION(9, 2, 2):
1784 case IP_VERSION(9, 3, 0):
1785 case IP_VERSION(9, 4, 0):
1786 case IP_VERSION(9, 4, 1):
1787 case IP_VERSION(9, 4, 2):
1788 amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block);
1790 case IP_VERSION(10, 1, 10):
1791 case IP_VERSION(10, 1, 2):
1792 case IP_VERSION(10, 1, 1):
1793 case IP_VERSION(10, 1, 3):
1794 case IP_VERSION(10, 1, 4):
1795 case IP_VERSION(10, 3, 0):
1796 case IP_VERSION(10, 3, 2):
1797 case IP_VERSION(10, 3, 1):
1798 case IP_VERSION(10, 3, 4):
1799 case IP_VERSION(10, 3, 5):
1800 case IP_VERSION(10, 3, 6):
1801 case IP_VERSION(10, 3, 3):
1802 case IP_VERSION(10, 3, 7):
1803 amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block);
1805 case IP_VERSION(11, 0, 0):
1806 case IP_VERSION(11, 0, 1):
1807 case IP_VERSION(11, 0, 2):
1808 case IP_VERSION(11, 0, 3):
1809 case IP_VERSION(11, 0, 4):
1810 amdgpu_device_ip_block_add(adev, &gfx_v11_0_ip_block);
1814 "Failed to add gfx ip block(GC_HWIP:0x%x)\n",
1815 adev->ip_versions[GC_HWIP][0]);
1821 static int amdgpu_discovery_set_sdma_ip_blocks(struct amdgpu_device *adev)
1823 switch (adev->ip_versions[SDMA0_HWIP][0]) {
1824 case IP_VERSION(4, 0, 0):
1825 case IP_VERSION(4, 0, 1):
1826 case IP_VERSION(4, 1, 0):
1827 case IP_VERSION(4, 1, 1):
1828 case IP_VERSION(4, 1, 2):
1829 case IP_VERSION(4, 2, 0):
1830 case IP_VERSION(4, 2, 2):
1831 case IP_VERSION(4, 4, 0):
1832 amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block);
1834 case IP_VERSION(5, 0, 0):
1835 case IP_VERSION(5, 0, 1):
1836 case IP_VERSION(5, 0, 2):
1837 case IP_VERSION(5, 0, 5):
1838 amdgpu_device_ip_block_add(adev, &sdma_v5_0_ip_block);
1840 case IP_VERSION(5, 2, 0):
1841 case IP_VERSION(5, 2, 2):
1842 case IP_VERSION(5, 2, 4):
1843 case IP_VERSION(5, 2, 5):
1844 case IP_VERSION(5, 2, 6):
1845 case IP_VERSION(5, 2, 3):
1846 case IP_VERSION(5, 2, 1):
1847 case IP_VERSION(5, 2, 7):
1848 amdgpu_device_ip_block_add(adev, &sdma_v5_2_ip_block);
1850 case IP_VERSION(6, 0, 0):
1851 case IP_VERSION(6, 0, 1):
1852 case IP_VERSION(6, 0, 2):
1853 case IP_VERSION(6, 0, 3):
1854 amdgpu_device_ip_block_add(adev, &sdma_v6_0_ip_block);
1858 "Failed to add sdma ip block(SDMA0_HWIP:0x%x)\n",
1859 adev->ip_versions[SDMA0_HWIP][0]);
1865 static int amdgpu_discovery_set_mm_ip_blocks(struct amdgpu_device *adev)
1867 if (adev->ip_versions[VCE_HWIP][0]) {
1868 switch (adev->ip_versions[UVD_HWIP][0]) {
1869 case IP_VERSION(7, 0, 0):
1870 case IP_VERSION(7, 2, 0):
1871 /* UVD is not supported on vega20 SR-IOV */
1872 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
1873 amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block);
1877 "Failed to add uvd v7 ip block(UVD_HWIP:0x%x)\n",
1878 adev->ip_versions[UVD_HWIP][0]);
1881 switch (adev->ip_versions[VCE_HWIP][0]) {
1882 case IP_VERSION(4, 0, 0):
1883 case IP_VERSION(4, 1, 0):
1884 /* VCE is not supported on vega20 SR-IOV */
1885 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev)))
1886 amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block);
1890 "Failed to add VCE v4 ip block(VCE_HWIP:0x%x)\n",
1891 adev->ip_versions[VCE_HWIP][0]);
1895 switch (adev->ip_versions[UVD_HWIP][0]) {
1896 case IP_VERSION(1, 0, 0):
1897 case IP_VERSION(1, 0, 1):
1898 amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block);
1900 case IP_VERSION(2, 0, 0):
1901 case IP_VERSION(2, 0, 2):
1902 case IP_VERSION(2, 2, 0):
1903 amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
1904 if (!amdgpu_sriov_vf(adev))
1905 amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
1907 case IP_VERSION(2, 0, 3):
1909 case IP_VERSION(2, 5, 0):
1910 amdgpu_device_ip_block_add(adev, &vcn_v2_5_ip_block);
1911 amdgpu_device_ip_block_add(adev, &jpeg_v2_5_ip_block);
1913 case IP_VERSION(2, 6, 0):
1914 amdgpu_device_ip_block_add(adev, &vcn_v2_6_ip_block);
1915 amdgpu_device_ip_block_add(adev, &jpeg_v2_6_ip_block);
1917 case IP_VERSION(3, 0, 0):
1918 case IP_VERSION(3, 0, 16):
1919 case IP_VERSION(3, 1, 1):
1920 case IP_VERSION(3, 1, 2):
1921 case IP_VERSION(3, 0, 2):
1922 case IP_VERSION(3, 0, 192):
1923 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
1924 if (!amdgpu_sriov_vf(adev))
1925 amdgpu_device_ip_block_add(adev, &jpeg_v3_0_ip_block);
1927 case IP_VERSION(3, 0, 33):
1928 amdgpu_device_ip_block_add(adev, &vcn_v3_0_ip_block);
1930 case IP_VERSION(4, 0, 0):
1931 case IP_VERSION(4, 0, 2):
1932 case IP_VERSION(4, 0, 4):
1933 amdgpu_device_ip_block_add(adev, &vcn_v4_0_ip_block);
1934 if (!amdgpu_sriov_vf(adev))
1935 amdgpu_device_ip_block_add(adev, &jpeg_v4_0_ip_block);
1939 "Failed to add vcn/jpeg ip block(UVD_HWIP:0x%x)\n",
1940 adev->ip_versions[UVD_HWIP][0]);
1947 static int amdgpu_discovery_set_mes_ip_blocks(struct amdgpu_device *adev)
1949 switch (adev->ip_versions[GC_HWIP][0]) {
1950 case IP_VERSION(10, 1, 10):
1951 case IP_VERSION(10, 1, 1):
1952 case IP_VERSION(10, 1, 2):
1953 case IP_VERSION(10, 1, 3):
1954 case IP_VERSION(10, 1, 4):
1955 case IP_VERSION(10, 3, 0):
1956 case IP_VERSION(10, 3, 1):
1957 case IP_VERSION(10, 3, 2):
1958 case IP_VERSION(10, 3, 3):
1959 case IP_VERSION(10, 3, 4):
1960 case IP_VERSION(10, 3, 5):
1961 case IP_VERSION(10, 3, 6):
1963 amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block);
1964 adev->enable_mes = true;
1966 adev->enable_mes_kiq = true;
1969 case IP_VERSION(11, 0, 0):
1970 case IP_VERSION(11, 0, 1):
1971 case IP_VERSION(11, 0, 2):
1972 case IP_VERSION(11, 0, 3):
1973 case IP_VERSION(11, 0, 4):
1974 amdgpu_device_ip_block_add(adev, &mes_v11_0_ip_block);
1975 adev->enable_mes = true;
1976 adev->enable_mes_kiq = true;
1984 int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)
1988 switch (adev->asic_type) {
1990 vega10_reg_base_init(adev);
1991 adev->sdma.num_instances = 2;
1992 adev->gmc.num_umc = 4;
1993 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 0, 0);
1994 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 0, 0);
1995 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 0);
1996 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 0);
1997 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 0);
1998 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 0);
1999 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2000 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 1, 0);
2001 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 0, 0);
2002 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2003 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2004 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2005 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 0);
2006 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 0, 1);
2007 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2008 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2009 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 0);
2012 vega10_reg_base_init(adev);
2013 adev->sdma.num_instances = 2;
2014 adev->gmc.num_umc = 4;
2015 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2016 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 3, 0);
2017 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 0, 1);
2018 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 0, 1);
2019 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 0, 1);
2020 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 0, 1);
2021 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 5, 0);
2022 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(6, 2, 0);
2023 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 0);
2024 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(9, 0, 0);
2025 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(9, 0, 0);
2026 adev->ip_versions[THM_HWIP][0] = IP_VERSION(9, 0, 0);
2027 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(9, 0, 1);
2028 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 1);
2029 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 0, 0);
2030 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 0, 0);
2031 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 0, 1);
2034 vega10_reg_base_init(adev);
2035 adev->sdma.num_instances = 1;
2036 adev->vcn.num_vcn_inst = 1;
2037 adev->gmc.num_umc = 2;
2038 if (adev->apu_flags & AMD_APU_IS_RAVEN2) {
2039 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2040 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 2, 0);
2041 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 1);
2042 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 1);
2043 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 1);
2044 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 1);
2045 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 1);
2046 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 5, 0);
2047 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 1);
2048 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 1);
2049 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 1, 0);
2050 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 1);
2051 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 2, 2);
2052 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 1);
2053 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 1);
2055 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2056 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 1, 0);
2057 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 1, 0);
2058 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 1, 0);
2059 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 1, 0);
2060 adev->ip_versions[DF_HWIP][0] = IP_VERSION(2, 1, 0);
2061 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 0, 0);
2062 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(7, 0, 0);
2063 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(10, 0, 0);
2064 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(10, 0, 0);
2065 adev->ip_versions[THM_HWIP][0] = IP_VERSION(10, 0, 0);
2066 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(10, 0, 0);
2067 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 1, 0);
2068 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(1, 0, 0);
2069 adev->ip_versions[DCE_HWIP][0] = IP_VERSION(1, 0, 0);
2073 vega20_reg_base_init(adev);
2074 adev->sdma.num_instances = 2;
2075 adev->gmc.num_umc = 8;
2076 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2077 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 0);
2078 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 0);
2079 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 0);
2080 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 0);
2081 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 0);
2082 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 0);
2083 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 0);
2084 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 1);
2085 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 2);
2086 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2087 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 2);
2088 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 2);
2089 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 0);
2090 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(7, 2, 0);
2091 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(7, 2, 0);
2092 adev->ip_versions[VCE_HWIP][0] = IP_VERSION(4, 1, 0);
2093 adev->ip_versions[DCI_HWIP][0] = IP_VERSION(12, 1, 0);
2096 arct_reg_base_init(adev);
2097 adev->sdma.num_instances = 8;
2098 adev->vcn.num_vcn_inst = 2;
2099 adev->gmc.num_umc = 8;
2100 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2101 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 1);
2102 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 2, 1);
2103 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 2, 1);
2104 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 2, 2);
2105 adev->ip_versions[SDMA1_HWIP][0] = IP_VERSION(4, 2, 2);
2106 adev->ip_versions[SDMA1_HWIP][1] = IP_VERSION(4, 2, 2);
2107 adev->ip_versions[SDMA1_HWIP][2] = IP_VERSION(4, 2, 2);
2108 adev->ip_versions[SDMA1_HWIP][3] = IP_VERSION(4, 2, 2);
2109 adev->ip_versions[SDMA1_HWIP][4] = IP_VERSION(4, 2, 2);
2110 adev->ip_versions[SDMA1_HWIP][5] = IP_VERSION(4, 2, 2);
2111 adev->ip_versions[SDMA1_HWIP][6] = IP_VERSION(4, 2, 2);
2112 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 1);
2113 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 1);
2114 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 1, 2);
2115 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(11, 0, 4);
2116 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(11, 0, 2);
2117 adev->ip_versions[THM_HWIP][0] = IP_VERSION(11, 0, 3);
2118 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(11, 0, 3);
2119 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 1);
2120 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 5, 0);
2121 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 5, 0);
2123 case CHIP_ALDEBARAN:
2124 aldebaran_reg_base_init(adev);
2125 adev->sdma.num_instances = 5;
2126 adev->vcn.num_vcn_inst = 2;
2127 adev->gmc.num_umc = 4;
2128 adev->ip_versions[MMHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2129 adev->ip_versions[ATHUB_HWIP][0] = IP_VERSION(9, 4, 2);
2130 adev->ip_versions[OSSSYS_HWIP][0] = IP_VERSION(4, 4, 0);
2131 adev->ip_versions[HDP_HWIP][0] = IP_VERSION(4, 4, 0);
2132 adev->ip_versions[SDMA0_HWIP][0] = IP_VERSION(4, 4, 0);
2133 adev->ip_versions[SDMA0_HWIP][1] = IP_VERSION(4, 4, 0);
2134 adev->ip_versions[SDMA0_HWIP][2] = IP_VERSION(4, 4, 0);
2135 adev->ip_versions[SDMA0_HWIP][3] = IP_VERSION(4, 4, 0);
2136 adev->ip_versions[SDMA0_HWIP][4] = IP_VERSION(4, 4, 0);
2137 adev->ip_versions[DF_HWIP][0] = IP_VERSION(3, 6, 2);
2138 adev->ip_versions[NBIO_HWIP][0] = IP_VERSION(7, 4, 4);
2139 adev->ip_versions[UMC_HWIP][0] = IP_VERSION(6, 7, 0);
2140 adev->ip_versions[MP0_HWIP][0] = IP_VERSION(13, 0, 2);
2141 adev->ip_versions[MP1_HWIP][0] = IP_VERSION(13, 0, 2);
2142 adev->ip_versions[THM_HWIP][0] = IP_VERSION(13, 0, 2);
2143 adev->ip_versions[SMUIO_HWIP][0] = IP_VERSION(13, 0, 2);
2144 adev->ip_versions[GC_HWIP][0] = IP_VERSION(9, 4, 2);
2145 adev->ip_versions[UVD_HWIP][0] = IP_VERSION(2, 6, 0);
2146 adev->ip_versions[UVD_HWIP][1] = IP_VERSION(2, 6, 0);
2147 adev->ip_versions[XGMI_HWIP][0] = IP_VERSION(6, 1, 0);
2150 r = amdgpu_discovery_reg_base_init(adev);
2154 amdgpu_discovery_harvest_ip(adev);
2155 amdgpu_discovery_get_gfx_info(adev);
2156 amdgpu_discovery_get_mall_info(adev);
2157 amdgpu_discovery_get_vcn_info(adev);
2161 switch (adev->ip_versions[GC_HWIP][0]) {
2162 case IP_VERSION(9, 0, 1):
2163 case IP_VERSION(9, 2, 1):
2164 case IP_VERSION(9, 4, 0):
2165 case IP_VERSION(9, 4, 1):
2166 case IP_VERSION(9, 4, 2):
2167 adev->family = AMDGPU_FAMILY_AI;
2169 case IP_VERSION(9, 1, 0):
2170 case IP_VERSION(9, 2, 2):
2171 case IP_VERSION(9, 3, 0):
2172 adev->family = AMDGPU_FAMILY_RV;
2174 case IP_VERSION(10, 1, 10):
2175 case IP_VERSION(10, 1, 1):
2176 case IP_VERSION(10, 1, 2):
2177 case IP_VERSION(10, 1, 3):
2178 case IP_VERSION(10, 1, 4):
2179 case IP_VERSION(10, 3, 0):
2180 case IP_VERSION(10, 3, 2):
2181 case IP_VERSION(10, 3, 4):
2182 case IP_VERSION(10, 3, 5):
2183 adev->family = AMDGPU_FAMILY_NV;
2185 case IP_VERSION(10, 3, 1):
2186 adev->family = AMDGPU_FAMILY_VGH;
2187 adev->apu_flags |= AMD_APU_IS_VANGOGH;
2189 case IP_VERSION(10, 3, 3):
2190 adev->family = AMDGPU_FAMILY_YC;
2192 case IP_VERSION(10, 3, 6):
2193 adev->family = AMDGPU_FAMILY_GC_10_3_6;
2195 case IP_VERSION(10, 3, 7):
2196 adev->family = AMDGPU_FAMILY_GC_10_3_7;
2198 case IP_VERSION(11, 0, 0):
2199 case IP_VERSION(11, 0, 2):
2200 case IP_VERSION(11, 0, 3):
2201 adev->family = AMDGPU_FAMILY_GC_11_0_0;
2203 case IP_VERSION(11, 0, 1):
2204 adev->family = AMDGPU_FAMILY_GC_11_0_1;
2210 switch (adev->ip_versions[GC_HWIP][0]) {
2211 case IP_VERSION(9, 1, 0):
2212 case IP_VERSION(9, 2, 2):
2213 case IP_VERSION(9, 3, 0):
2214 case IP_VERSION(10, 1, 3):
2215 case IP_VERSION(10, 1, 4):
2216 case IP_VERSION(10, 3, 1):
2217 case IP_VERSION(10, 3, 3):
2218 case IP_VERSION(10, 3, 6):
2219 case IP_VERSION(10, 3, 7):
2220 case IP_VERSION(11, 0, 1):
2221 adev->flags |= AMD_IS_APU;
2227 if (adev->ip_versions[XGMI_HWIP][0] == IP_VERSION(4, 8, 0))
2228 adev->gmc.xgmi.supported = true;
2230 /* set NBIO version */
2231 switch (adev->ip_versions[NBIO_HWIP][0]) {
2232 case IP_VERSION(6, 1, 0):
2233 case IP_VERSION(6, 2, 0):
2234 adev->nbio.funcs = &nbio_v6_1_funcs;
2235 adev->nbio.hdp_flush_reg = &nbio_v6_1_hdp_flush_reg;
2237 case IP_VERSION(7, 0, 0):
2238 case IP_VERSION(7, 0, 1):
2239 case IP_VERSION(2, 5, 0):
2240 adev->nbio.funcs = &nbio_v7_0_funcs;
2241 adev->nbio.hdp_flush_reg = &nbio_v7_0_hdp_flush_reg;
2243 case IP_VERSION(7, 4, 0):
2244 case IP_VERSION(7, 4, 1):
2245 case IP_VERSION(7, 4, 4):
2246 adev->nbio.funcs = &nbio_v7_4_funcs;
2247 adev->nbio.hdp_flush_reg = &nbio_v7_4_hdp_flush_reg;
2249 case IP_VERSION(7, 2, 0):
2250 case IP_VERSION(7, 2, 1):
2251 case IP_VERSION(7, 3, 0):
2252 case IP_VERSION(7, 5, 0):
2253 case IP_VERSION(7, 5, 1):
2254 adev->nbio.funcs = &nbio_v7_2_funcs;
2255 adev->nbio.hdp_flush_reg = &nbio_v7_2_hdp_flush_reg;
2257 case IP_VERSION(2, 1, 1):
2258 case IP_VERSION(2, 3, 0):
2259 case IP_VERSION(2, 3, 1):
2260 case IP_VERSION(2, 3, 2):
2261 case IP_VERSION(3, 3, 0):
2262 case IP_VERSION(3, 3, 1):
2263 case IP_VERSION(3, 3, 2):
2264 case IP_VERSION(3, 3, 3):
2265 adev->nbio.funcs = &nbio_v2_3_funcs;
2266 adev->nbio.hdp_flush_reg = &nbio_v2_3_hdp_flush_reg;
2268 case IP_VERSION(4, 3, 0):
2269 case IP_VERSION(4, 3, 1):
2270 if (amdgpu_sriov_vf(adev))
2271 adev->nbio.funcs = &nbio_v4_3_sriov_funcs;
2273 adev->nbio.funcs = &nbio_v4_3_funcs;
2274 adev->nbio.hdp_flush_reg = &nbio_v4_3_hdp_flush_reg;
2276 case IP_VERSION(7, 7, 0):
2277 adev->nbio.funcs = &nbio_v7_7_funcs;
2278 adev->nbio.hdp_flush_reg = &nbio_v7_7_hdp_flush_reg;
2284 switch (adev->ip_versions[HDP_HWIP][0]) {
2285 case IP_VERSION(4, 0, 0):
2286 case IP_VERSION(4, 0, 1):
2287 case IP_VERSION(4, 1, 0):
2288 case IP_VERSION(4, 1, 1):
2289 case IP_VERSION(4, 1, 2):
2290 case IP_VERSION(4, 2, 0):
2291 case IP_VERSION(4, 2, 1):
2292 case IP_VERSION(4, 4, 0):
2293 adev->hdp.funcs = &hdp_v4_0_funcs;
2295 case IP_VERSION(5, 0, 0):
2296 case IP_VERSION(5, 0, 1):
2297 case IP_VERSION(5, 0, 2):
2298 case IP_VERSION(5, 0, 3):
2299 case IP_VERSION(5, 0, 4):
2300 case IP_VERSION(5, 2, 0):
2301 adev->hdp.funcs = &hdp_v5_0_funcs;
2303 case IP_VERSION(5, 2, 1):
2304 adev->hdp.funcs = &hdp_v5_2_funcs;
2306 case IP_VERSION(6, 0, 0):
2307 case IP_VERSION(6, 0, 1):
2308 adev->hdp.funcs = &hdp_v6_0_funcs;
2314 switch (adev->ip_versions[DF_HWIP][0]) {
2315 case IP_VERSION(3, 6, 0):
2316 case IP_VERSION(3, 6, 1):
2317 case IP_VERSION(3, 6, 2):
2318 adev->df.funcs = &df_v3_6_funcs;
2320 case IP_VERSION(2, 1, 0):
2321 case IP_VERSION(2, 1, 1):
2322 case IP_VERSION(2, 5, 0):
2323 case IP_VERSION(3, 5, 1):
2324 case IP_VERSION(3, 5, 2):
2325 adev->df.funcs = &df_v1_7_funcs;
2331 switch (adev->ip_versions[SMUIO_HWIP][0]) {
2332 case IP_VERSION(9, 0, 0):
2333 case IP_VERSION(9, 0, 1):
2334 case IP_VERSION(10, 0, 0):
2335 case IP_VERSION(10, 0, 1):
2336 case IP_VERSION(10, 0, 2):
2337 adev->smuio.funcs = &smuio_v9_0_funcs;
2339 case IP_VERSION(11, 0, 0):
2340 case IP_VERSION(11, 0, 2):
2341 case IP_VERSION(11, 0, 3):
2342 case IP_VERSION(11, 0, 4):
2343 case IP_VERSION(11, 0, 7):
2344 case IP_VERSION(11, 0, 8):
2345 adev->smuio.funcs = &smuio_v11_0_funcs;
2347 case IP_VERSION(11, 0, 6):
2348 case IP_VERSION(11, 0, 10):
2349 case IP_VERSION(11, 0, 11):
2350 case IP_VERSION(11, 5, 0):
2351 case IP_VERSION(13, 0, 1):
2352 case IP_VERSION(13, 0, 9):
2353 case IP_VERSION(13, 0, 10):
2354 adev->smuio.funcs = &smuio_v11_0_6_funcs;
2356 case IP_VERSION(13, 0, 2):
2357 adev->smuio.funcs = &smuio_v13_0_funcs;
2359 case IP_VERSION(13, 0, 6):
2360 case IP_VERSION(13, 0, 8):
2361 adev->smuio.funcs = &smuio_v13_0_6_funcs;
2367 switch (adev->ip_versions[LSDMA_HWIP][0]) {
2368 case IP_VERSION(6, 0, 0):
2369 case IP_VERSION(6, 0, 1):
2370 case IP_VERSION(6, 0, 2):
2371 case IP_VERSION(6, 0, 3):
2372 adev->lsdma.funcs = &lsdma_v6_0_funcs;
2378 r = amdgpu_discovery_set_common_ip_blocks(adev);
2382 r = amdgpu_discovery_set_gmc_ip_blocks(adev);
2386 /* For SR-IOV, PSP needs to be initialized before IH */
2387 if (amdgpu_sriov_vf(adev)) {
2388 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2391 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2395 r = amdgpu_discovery_set_ih_ip_blocks(adev);
2399 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2400 r = amdgpu_discovery_set_psp_ip_blocks(adev);
2406 if (likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
2407 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2412 r = amdgpu_discovery_set_display_ip_blocks(adev);
2416 r = amdgpu_discovery_set_gc_ip_blocks(adev);
2420 r = amdgpu_discovery_set_sdma_ip_blocks(adev);
2424 if ((adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
2425 !amdgpu_sriov_vf(adev)) ||
2426 (adev->firmware.load_type == AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO && amdgpu_dpm == 1)) {
2427 r = amdgpu_discovery_set_smu_ip_blocks(adev);
2432 r = amdgpu_discovery_set_mm_ip_blocks(adev);
2436 r = amdgpu_discovery_set_mes_ip_blocks(adev);