This is the main feature pull for radeon and amdgpu for 4.11. Highlights: - Power and clockgating improvements - Preliminary SR-IOV support - ttm buffer priority support - ttm eviction fixes - Removal of the ttm lru callbacks - Remove SI DPM quirks due to MC firmware issues - Handle VFCT with multiple vbioses - Powerplay improvements - Lots of driver cleanups * 'drm-next-4.11' of git://people.freedesktop.org/~agd5f/linux: (120 commits) drm/amdgpu: fix amdgpu_bo_va_mapping flags drm/amdgpu: access stolen VRAM directly on CZ (v2) drm/amdgpu: access stolen VRAM directly on KV/KB (v2) drm/amdgpu: fix kernel panic when dpm disabled on Kv. drm/amdgpu: fix dpm bug on Kv. drm/amd/powerplay: fix regresstion issue can't set manual dpm mode. drm/amdgpu: handle vfct with multiple vbios images drm/radeon: handle vfct with multiple vbios images drm/amdgpu: move misc si headers into amdgpu drm/amdgpu: remove unused header si_reg.h drm/radeon: drop pitcairn dpm quirks drm/amdgpu: drop pitcairn dpm quirks drm: radeon: radeon_ttm: Handle return NULL error from ioremap_nocache drm/amd/amdgpu/amdgpu_ttm: Handle return NULL error from ioremap_nocache drm/amdgpu: add new virtual display ID drm/amd/amdgpu: remove the uncessary parameter for ib scheduler drm/amdgpu: Bring bo creation in line with radeon driver (v2) drm/amd/powerplay: fix misspelling in header guard drm/ttm: revert "add optional LRU removal callback v2" drm/ttm: revert "implement LRU add callbacks v2" ...
Unified · Split
| @@ -24,7 +24,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ · 23 unmodified lines | ||
| 24 | 24 | atombios_encoders.o amdgpu_sa.o atombios_i2c.o \ |
| 25 | 25 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ |
| 26 | 26 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ |
| 27 | − amdgpu_gtt_mgr.o amdgpu_vram_mgr.o | |
| 27 | + amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o | |
| 28 | 28 | |
| 29 | 29 | # add asic specific block |
| 30 | 30 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ |
| @@ -34,7 +34,7 @@ amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ · 3 unmodified lines | ||
| 34 | 34 | amdgpu-$(CONFIG_DRM_AMDGPU_SI)+= si.o gmc_v6_0.o gfx_v6_0.o si_ih.o si_dma.o dce_v6_0.o si_dpm.o si_smc.o |
| 35 | 35 | |
| 36 | 36 | amdgpu-y += \ |
| 37 | − vi.o | |
| 37 | + vi.o mxgpu_vi.o | |
| 38 | 38 | |
| 39 | 39 | # add GMC block |
| 40 | 40 | amdgpu-y += \ |
| @@ -52,8 +52,7 @@ amdgpu-y += \ · 11 unmodified lines | ||
| 52 | 52 | # add SMC block |
| 53 | 53 | amdgpu-y += \ |
| 54 | 54 | amdgpu_dpm.o \ |
| 55 | − amdgpu_powerplay.o \ | |
| 56 | − cz_smc.o cz_dpm.o | |
| 55 | + amdgpu_powerplay.o | |
| 57 | 56 | |
| 58 | 57 | # add DCE block |
| 59 | 58 | amdgpu-y += \ |
| @@ -91,7 +91,6 @@ extern int amdgpu_vm_fault_stop; · 90 unmodified lines | ||
| 91 | 91 | extern int amdgpu_vm_debug; |
| 92 | 92 | extern int amdgpu_sched_jobs; |
| 93 | 93 | extern int amdgpu_sched_hw_submission; |
| 94 | −extern int amdgpu_powerplay; | |
| 95 | 94 | extern int amdgpu_no_evict; |
| 96 | 95 | extern int amdgpu_direct_gma_size; |
| 97 | 96 | extern unsigned amdgpu_pcie_gen_cap; |
| @@ -184,12 +183,18 @@ enum amdgpu_thermal_irq { · 86 unmodified lines | ||
| 184 | 183 | AMDGPU_THERMAL_IRQ_LAST |
| 185 | 184 | }; |
| 186 | 185 | |
| 186 | +enum amdgpu_kiq_irq { | |
| 187 | + AMDGPU_CP_KIQ_IRQ_DRIVER0 = 0, | |
| 188 | + AMDGPU_CP_KIQ_IRQ_LAST | |
| 189 | +}; | |
| 190 | + | |
| 187 | 191 | int amdgpu_set_clockgating_state(struct amdgpu_device *adev, |
| 188 | 192 | enum amd_ip_block_type block_type, |
| 189 | 193 | enum amd_clockgating_state state); |
| 190 | 194 | int amdgpu_set_powergating_state(struct amdgpu_device *adev, |
| 191 | 195 | enum amd_ip_block_type block_type, |
| 192 | 196 | enum amd_powergating_state state); |
| 197 | +void amdgpu_get_clockgating_state(struct amdgpu_device *adev, u32 *flags); | |
| 193 | 198 | int amdgpu_wait_for_idle(struct amdgpu_device *adev, |
| 194 | 199 | enum amd_ip_block_type block_type); |
| 195 | 200 | bool amdgpu_is_idle(struct amdgpu_device *adev, |
| @@ -352,7 +357,7 @@ struct amdgpu_bo_va_mapping { · 156 unmodified lines | ||
| 352 | 357 | struct list_head list; |
| 353 | 358 | struct interval_tree_node it; |
| 354 | 359 | uint64_t offset; |
| 355 | − uint32_t flags; | |
| 360 | + uint64_t flags; | |
| 356 | 361 | }; |
| 357 | 362 | |
| 358 | 363 | /* bo virtual addresses in a specific vm */ |
| @@ -776,14 +781,20 @@ struct amdgpu_mec { · 417 unmodified lines | ||
| 776 | 781 | u32 num_queue; |
| 777 | 782 | }; |
| 778 | 783 | |
| 784 | +struct amdgpu_kiq { | |
| 785 | + u64 eop_gpu_addr; | |
| 786 | + struct amdgpu_bo *eop_obj; | |
| 787 | + struct amdgpu_ring ring; | |
| 788 | + struct amdgpu_irq_src irq; | |
| 789 | +}; | |
| 790 | + | |
| 779 | 791 | /* |
| 780 | 792 | * GPU scratch registers structures, functions & helpers |
| 781 | 793 | */ |
| 782 | 794 | struct amdgpu_scratch { |
| 783 | 795 | unsigned num_reg; |
| 784 | 796 | uint32_t reg_base; |
| 785 | − bool free[32]; | |
| 786 | − uint32_t reg[32]; | |
| 797 | + uint32_t free_mask; | |
| 787 | 798 | }; |
| 788 | 799 | |
| 789 | 800 | /* |
| @@ -851,6 +862,7 @@ struct amdgpu_gfx { · 61 unmodified lines | ||
| 851 | 862 | struct amdgpu_gca_config config; |
| 852 | 863 | struct amdgpu_rlc rlc; |
| 853 | 864 | struct amdgpu_mec mec; |
| 865 | + struct amdgpu_kiq kiq; | |
| 854 | 866 | struct amdgpu_scratch scratch; |
| 855 | 867 | const struct firmware *me_fw; /* ME firmware */ |
| 856 | 868 | uint32_t me_fw_version; |
| @@ -894,8 +906,8 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm, · 37 unmodified lines | ||
| 894 | 906 | void amdgpu_ib_free(struct amdgpu_device *adev, struct amdgpu_ib *ib, |
| 895 | 907 | struct dma_fence *f); |
| 896 | 908 | int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, |
| 897 | − struct amdgpu_ib *ib, struct dma_fence *last_vm_update, | |
| 898 | − struct amdgpu_job *job, struct dma_fence **f); | |
| 909 | + struct amdgpu_ib *ibs, struct amdgpu_job *job, | |
| 910 | + struct dma_fence **f); | |
| 899 | 911 | int amdgpu_ib_pool_init(struct amdgpu_device *adev); |
| 900 | 912 | void amdgpu_ib_pool_fini(struct amdgpu_device *adev); |
| 901 | 913 | int amdgpu_ib_ring_tests(struct amdgpu_device *adev); |
| @@ -938,6 +950,7 @@ struct amdgpu_cs_parser { · 36 unmodified lines | ||
| 938 | 950 | #define AMDGPU_PREAMBLE_IB_PRESENT (1 << 0) /* bit set means command submit involves a preamble IB */ |
| 939 | 951 | #define AMDGPU_PREAMBLE_IB_PRESENT_FIRST (1 << 1) /* bit set means preamble IB is first presented in belonging context */ |
| 940 | 952 | #define AMDGPU_HAVE_CTX_SWITCH (1 << 2) /* bit set means context switch occured */ |
| 953 | +#define AMDGPU_VM_DOMAIN (1 << 3) /* bit set means in virtual memory context */ | |
| 941 | 954 | |
| 942 | 955 | struct amdgpu_job { |
| 943 | 956 | struct amd_sched_job base; |
| @@ -1024,6 +1037,7 @@ struct amdgpu_uvd { · 80 unmodified lines | ||
| 1024 | 1037 | bool use_ctx_buf; |
| 1025 | 1038 | struct amd_sched_entity entity; |
| 1026 | 1039 | uint32_t srbm_soft_reset; |
| 1040 | + bool is_powergated; | |
| 1027 | 1041 | }; |
| 1028 | 1042 | |
| 1029 | 1043 | /* |
| @@ -1052,6 +1066,7 @@ struct amdgpu_vce { · 22 unmodified lines | ||
| 1052 | 1066 | struct amd_sched_entity entity; |
| 1053 | 1067 | uint32_t srbm_soft_reset; |
| 1054 | 1068 | unsigned num_rings; |
| 1069 | + bool is_powergated; | |
| 1055 | 1070 | }; |
| 1056 | 1071 | |
| 1057 | 1072 | /* |
| @@ -1177,7 +1192,6 @@ struct amdgpu_asic_funcs { · 119 unmodified lines | ||
| 1177 | 1192 | bool (*read_disabled_bios)(struct amdgpu_device *adev); |
| 1178 | 1193 | bool (*read_bios_from_rom)(struct amdgpu_device *adev, |
| 1179 | 1194 | u8 *bios, u32 length_bytes); |
| 1180 | − void (*detect_hw_virtualization) (struct amdgpu_device *adev); | |
| 1181 | 1195 | int (*read_register)(struct amdgpu_device *adev, u32 se_num, |
| 1182 | 1196 | u32 sh_num, u32 reg_offset, u32 *value); |
| 1183 | 1197 | void (*set_vga_state)(struct amdgpu_device *adev, bool state); |
| @@ -1332,7 +1346,6 @@ struct amdgpu_device { · 148 unmodified lines | ||
| 1332 | 1346 | /* BIOS */ |
| 1333 | 1347 | uint8_t *bios; |
| 1334 | 1348 | uint32_t bios_size; |
| 1335 | − bool is_atom_bios; | |
| 1336 | 1349 | struct amdgpu_bo *stollen_vga_memory; |
| 1337 | 1350 | uint32_t bios_scratch[AMDGPU_BIOS_NUM_SCRATCH]; |
| 1338 | 1351 | |
| @@ -1462,7 +1475,7 @@ struct amdgpu_device { · 123 unmodified lines | ||
| 1462 | 1475 | /* amdkfd interface */ |
| 1463 | 1476 | struct kfd_dev *kfd; |
| 1464 | 1477 | |
| 1465 | − struct amdgpu_virtualization virtualization; | |
| 1478 | + struct amdgpu_virt virt; | |
| 1466 | 1479 | |
| 1467 | 1480 | /* link all shadow bo */ |
| 1468 | 1481 | struct list_head shadow_list; |
| @@ -1575,6 +1588,37 @@ static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v) · 106 unmodified lines | ||
| 1575 | 1588 | ring->count_dw--; |
| 1576 | 1589 | } |
| 1577 | 1590 | |
| 1591 | +static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, void *src, int count_dw) | |
| 1592 | +{ | |
| 1593 | + unsigned occupied, chunk1, chunk2; | |
| 1594 | + void *dst; | |
| 1595 | + | |
| 1596 | + if (ring->count_dw < count_dw) { | |
| 1597 | + DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n"); | |
| 1598 | + } else { | |
| 1599 | + occupied = ring->wptr & ring->ptr_mask; | |
| 1600 | + dst = (void *)&ring->ring[occupied]; | |
| 1601 | + chunk1 = ring->ptr_mask + 1 - occupied; | |
| 1602 | + chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1; | |
| 1603 | + chunk2 = count_dw - chunk1; | |
| 1604 | + chunk1 <<= 2; | |
| 1605 | + chunk2 <<= 2; | |
| 1606 | + | |
| 1607 | + if (chunk1) | |
| 1608 | + memcpy(dst, src, chunk1); | |
| 1609 | + | |
| 1610 | + if (chunk2) { | |
| 1611 | + src += chunk1; | |
| 1612 | + dst = (void *)ring->ring; | |
| 1613 | + memcpy(dst, src, chunk2); | |
| 1614 | + } | |
| 1615 | + | |
| 1616 | + ring->wptr += count_dw; | |
| 1617 | + ring->wptr &= ring->ptr_mask; | |
| 1618 | + ring->count_dw -= count_dw; | |
| 1619 | + } | |
| 1620 | +} | |
| 1621 | + | |
| 1578 | 1622 | static inline struct amdgpu_sdma_instance * |
| 1579 | 1623 | amdgpu_get_sdma_instance(struct amdgpu_ring *ring) |
| 1580 | 1624 | { |
| @@ -1604,7 +1648,6 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) · 23 unmodified lines | ||
| 1604 | 1648 | #define amdgpu_asic_get_gpu_clock_counter(adev) (adev)->asic_funcs->get_gpu_clock_counter((adev)) |
| 1605 | 1649 | #define amdgpu_asic_read_disabled_bios(adev) (adev)->asic_funcs->read_disabled_bios((adev)) |
| 1606 | 1650 | #define amdgpu_asic_read_bios_from_rom(adev, b, l) (adev)->asic_funcs->read_bios_from_rom((adev), (b), (l)) |
| 1607 | −#define amdgpu_asic_detect_hw_virtualization(adev) (adev)->asic_funcs->detect_hw_virtualization((adev)) | |
| 1608 | 1651 | #define amdgpu_asic_read_register(adev, se, sh, offset, v)((adev)->asic_funcs->read_register((adev), (se), (sh), (offset), (v))) |
| 1609 | 1652 | #define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid)) |
| 1610 | 1653 | #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags)) |
| @@ -1626,6 +1669,8 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) · 15 unmodified lines | ||
| 1626 | 1669 | #define amdgpu_ring_emit_hdp_invalidate(r) (r)->funcs->emit_hdp_invalidate((r)) |
| 1627 | 1670 | #define amdgpu_ring_emit_switch_buffer(r) (r)->funcs->emit_switch_buffer((r)) |
| 1628 | 1671 | #define amdgpu_ring_emit_cntxcntl(r, d) (r)->funcs->emit_cntxcntl((r), (d)) |
| 1672 | +#define amdgpu_ring_emit_rreg(r, d) (r)->funcs->emit_rreg((r), (d)) | |
| 1673 | +#define amdgpu_ring_emit_wreg(r, d, v) (r)->funcs->emit_wreg((r), (d), (v)) | |
| 1629 | 1674 | #define amdgpu_ring_pad_ib(r, ib) ((r)->funcs->pad_ib((r), (ib))) |
| 1630 | 1675 | #define amdgpu_ring_init_cond_exec(r) (r)->funcs->init_cond_exec((r)) |
| 1631 | 1676 | #define amdgpu_ring_patch_cond_exec(r,o) (r)->funcs->patch_cond_exec((r),(o)) |
| @@ -672,12 +672,10 @@ int amdgpu_acpi_init(struct amdgpu_device *adev) · 671 unmodified lines | ||
| 672 | 672 | |
| 673 | 673 | if ((enc->devices & (ATOM_DEVICE_LCD_SUPPORT)) && |
| 674 | 674 | enc->enc_priv) { |
| 675 | − if (adev->is_atom_bios) { | |
| 676 | − struct amdgpu_encoder_atom_dig *dig = enc->enc_priv; | |
| 677 | − if (dig->bl_dev) { | |
| 678 | − atif->encoder_for_bl = enc; | |
| 679 | − break; | |
| 680 | − } | |
| 675 | + struct amdgpu_encoder_atom_dig *dig = enc->enc_priv; | |
| 676 | + if (dig->bl_dev) { | |
| 677 | + atif->encoder_for_bl = enc; | |
| 678 | + break; | |
| 681 | 679 | } |
| 682 | 680 | } |
| 683 | 681 | } |
| @@ -42,6 +42,51 @@ · 41 unmodified lines | ||
| 42 | 42 | #define AMD_IS_VALID_VBIOS(p) ((p)[0] == 0x55 && (p)[1] == 0xAA) |
| 43 | 43 | #define AMD_VBIOS_LENGTH(p) ((p)[2] << 9) |
| 44 | 44 | |
| 45 | +/* Check if current bios is an ATOM BIOS. | |
| 46 | + * Return true if it is ATOM BIOS. Otherwise, return false. | |
| 47 | + */ | |
| 48 | +static bool check_atom_bios(uint8_t *bios, size_t size) | |
| 49 | +{ | |
| 50 | + uint16_t tmp, bios_header_start; | |
| 51 | + | |
| 52 | + if (!bios || size < 0x49) { | |
| 53 | + DRM_INFO("vbios mem is null or mem size is wrong\n"); | |
| 54 | + return false; | |
| 55 | + } | |
| 56 | + | |
| 57 | + if (!AMD_IS_VALID_VBIOS(bios)) { | |
| 58 | + DRM_INFO("BIOS signature incorrect %x %x\n", bios[0], bios[1]); | |
| 59 | + return false; | |
| 60 | + } | |
| 61 | + | |
| 62 | + tmp = bios[0x18] | (bios[0x19] << 8); | |
| 63 | + if (bios[tmp + 0x14] != 0x0) { | |
| 64 | + DRM_INFO("Not an x86 BIOS ROM\n"); | |
| 65 | + return false; | |
| 66 | + } | |
| 67 | + | |
| 68 | + bios_header_start = bios[0x48] | (bios[0x49] << 8); | |
| 69 | + if (!bios_header_start) { | |
| 70 | + DRM_INFO("Can't locate bios header\n"); | |
| 71 | + return false; | |
| 72 | + } | |
| 73 | + | |
| 74 | + tmp = bios_header_start + 4; | |
| 75 | + if (size < tmp) { | |
| 76 | + DRM_INFO("BIOS header is broken\n"); | |
| 77 | + return false; | |
| 78 | + } | |
| 79 | + | |
| 80 | + if (!memcmp(bios + tmp, "ATOM", 4) || | |
| 81 | + !memcmp(bios + tmp, "MOTA", 4)) { | |
| 82 | + DRM_DEBUG("ATOMBIOS detected\n"); | |
| 83 | + return true; | |
| 84 | + } | |
| 85 | + | |
| 86 | + return false; | |
| 87 | +} | |
| 88 | + | |
| 89 | + | |
| 45 | 90 | /* If you boot an IGP board with a discrete card as the primary, |
| 46 | 91 | * the IGP rom is not accessible via the rom bar as the IGP rom is |
| 47 | 92 | * part of the system bios. On boot, the system bios puts a |
| @@ -65,10 +110,6 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev) · 17 unmodified lines | ||
| 65 | 110 | return false; |
| 66 | 111 | } |
| 67 | 112 | |
| 68 | − if (size == 0 || !AMD_IS_VALID_VBIOS(bios)) { | |
| 69 | − iounmap(bios); | |
| 70 | − return false; | |
| 71 | − } | |
| 72 | 113 | adev->bios = kmalloc(size, GFP_KERNEL); |
| 73 | 114 | if (!adev->bios) { |
| 74 | 115 | iounmap(bios); |
| @@ -77,12 +118,18 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev) · 2 unmodified lines | ||
| 77 | 118 | adev->bios_size = size; |
| 78 | 119 | memcpy_fromio(adev->bios, bios, size); |
| 79 | 120 | iounmap(bios); |
| 121 | + | |
| 122 | + if (!check_atom_bios(adev->bios, size)) { | |
| 123 | + kfree(adev->bios); | |
| 124 | + return false; | |
| 125 | + } | |
| 126 | + | |
| 80 | 127 | return true; |
| 81 | 128 | } |
| 82 | 129 | |
| 83 | 130 | bool amdgpu_read_bios(struct amdgpu_device *adev) |
| 84 | 131 | { |
| 85 | − uint8_t __iomem *bios, val[2]; | |
| 132 | + uint8_t __iomem *bios; | |
| 86 | 133 | size_t size; |
| 87 | 134 | |
| 88 | 135 | adev->bios = NULL; |
| @@ -92,13 +139,6 @@ bool amdgpu_read_bios(struct amdgpu_device *adev) · 3 unmodified lines | ||
| 92 | 139 | return false; |
| 93 | 140 | } |
| 94 | 141 | |
| 95 | − val[0] = readb(&bios[0]); | |
| 96 | − val[1] = readb(&bios[1]); | |
| 97 | − | |
| 98 | − if (size == 0 || !AMD_IS_VALID_VBIOS(val)) { | |
| 99 | − pci_unmap_rom(adev->pdev, bios); | |
| 100 | − return false; | |
| 101 | − } | |
| 102 | 142 | adev->bios = kzalloc(size, GFP_KERNEL); |
| 103 | 143 | if (adev->bios == NULL) { |
| 104 | 144 | pci_unmap_rom(adev->pdev, bios); |
| @@ -107,6 +147,12 @@ bool amdgpu_read_bios(struct amdgpu_device *adev) · 2 unmodified lines | ||
| 107 | 147 | adev->bios_size = size; |
| 108 | 148 | memcpy_fromio(adev->bios, bios, size); |
| 109 | 149 | pci_unmap_rom(adev->pdev, bios); |
| 150 | + | |
| 151 | + if (!check_atom_bios(adev->bios, size)) { | |
| 152 | + kfree(adev->bios); | |
| 153 | + return false; | |
| 154 | + } | |
| 155 | + | |
| 110 | 156 | return true; |
| 111 | 157 | } |
| 112 | 158 | |
| @@ -140,7 +186,14 @@ static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev) · 27 unmodified lines | ||
| 140 | 186 | adev->bios_size = len; |
| 141 | 187 | |
| 142 | 188 | /* read complete BIOS */ |
| 143 | − return amdgpu_asic_read_bios_from_rom(adev, adev->bios, len); | |
| 189 | + amdgpu_asic_read_bios_from_rom(adev, adev->bios, len); | |
| 190 | + | |
| 191 | + if (!check_atom_bios(adev->bios, len)) { | |
| 192 | + kfree(adev->bios); | |
| 193 | + return false; | |
| 194 | + } | |
| 195 | + | |
| 196 | + return true; | |
| 144 | 197 | } |
| 145 | 198 | |
| 146 | 199 | static bool amdgpu_read_platform_bios(struct amdgpu_device *adev) |
| @@ -155,13 +208,17 @@ static bool amdgpu_read_platform_bios(struct amdgpu_device *adev) · 8 unmodified lines | ||
| 155 | 208 | return false; |
| 156 | 209 | } |
| 157 | 210 | |
| 158 | − if (size == 0 || !AMD_IS_VALID_VBIOS(bios)) { | |
| 211 | + adev->bios = kzalloc(size, GFP_KERNEL); | |
| 212 | + if (adev->bios == NULL) | |
| 159 | 213 | return false; |
| 160 | − } | |
| 161 | − adev->bios = kmemdup(bios, size, GFP_KERNEL); | |
| 162 | − if (adev->bios == NULL) { | |
| 214 | + | |
| 215 | + memcpy_fromio(adev->bios, bios, size); | |
| 216 | + | |
| 217 | + if (!check_atom_bios(adev->bios, size)) { | |
| 218 | + kfree(adev->bios); | |
| 163 | 219 | return false; |
| 164 | 220 | } |
| 221 | + | |
| 165 | 222 | adev->bios_size = size; |
| 166 | 223 | |
| 167 | 224 | return true; |
| @@ -273,7 +330,7 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) · 105 unmodified lines | ||
| 273 | 330 | break; |
| 274 | 331 | } |
| 275 | 332 | |
| 276 | − if (i == 0 || !AMD_IS_VALID_VBIOS(adev->bios)) { | |
| 333 | + if (!check_atom_bios(adev->bios, size)) { | |
| 277 | 334 | kfree(adev->bios); |
| 278 | 335 | return false; |
| 279 | 336 | } |
| @@ -298,53 +355,59 @@ static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev) · 18 unmodified lines | ||
| 298 | 355 | #ifdef CONFIG_ACPI |
| 299 | 356 | static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) |
| 300 | 357 | { |
| 301 | − bool ret = false; | |
| 302 | 358 | struct acpi_table_header *hdr; |
| 303 | 359 | acpi_size tbl_size; |
| 304 | 360 | UEFI_ACPI_VFCT *vfct; |
| 305 | − GOP_VBIOS_CONTENT *vbios; | |
| 306 | − VFCT_IMAGE_HEADER *vhdr; | |
| 361 | + unsigned offset; | |
| 307 | 362 | |
| 308 | 363 | if (!ACPI_SUCCESS(acpi_get_table("VFCT", 1, &hdr))) |
| 309 | 364 | return false; |
| 310 | 365 | tbl_size = hdr->length; |
| 311 | 366 | if (tbl_size < sizeof(UEFI_ACPI_VFCT)) { |
| 312 | 367 | DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n"); |
| 313 | − goto out_unmap; | |
| 368 | + return false; | |
| 314 | 369 | } |
| 315 | 370 | |
| 316 | 371 | vfct = (UEFI_ACPI_VFCT *)hdr; |
| 317 | − if (vfct->VBIOSImageOffset + sizeof(VFCT_IMAGE_HEADER) > tbl_size) { | |
| 318 | − DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n"); | |
| 319 | − goto out_unmap; | |
| 320 | − } | |
| 372 | + offset = vfct->VBIOSImageOffset; | |
| 321 | 373 | |
| 322 | − vbios = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset); | |
| 323 | − vhdr = &vbios->VbiosHeader; | |
| 324 | − DRM_INFO("ACPI VFCT contains a BIOS for %02x:%02x.%d %04x:%04x, size %d\n", | |
| 325 | − vhdr->PCIBus, vhdr->PCIDevice, vhdr->PCIFunction, | |
| 326 | − vhdr->VendorID, vhdr->DeviceID, vhdr->ImageLength); | |
| 327 | − | |
| 328 | − if (vhdr->PCIBus != adev->pdev->bus->number || | |
| 329 | − vhdr->PCIDevice != PCI_SLOT(adev->pdev->devfn) || | |
| 330 | − vhdr->PCIFunction != PCI_FUNC(adev->pdev->devfn) || | |
| 331 | − vhdr->VendorID != adev->pdev->vendor || | |
| 332 | − vhdr->DeviceID != adev->pdev->device) { | |
| 333 | − DRM_INFO("ACPI VFCT table is not for this card\n"); | |
| 334 | − goto out_unmap; | |
| 335 | − } | |
| 374 | + while (offset < tbl_size) { | |
| 375 | + GOP_VBIOS_CONTENT *vbios = (GOP_VBIOS_CONTENT *)((char *)hdr + offset); | |
| 376 | + VFCT_IMAGE_HEADER *vhdr = &vbios->VbiosHeader; | |
| 336 | 377 | |
| 337 | − if (vfct->VBIOSImageOffset + sizeof(VFCT_IMAGE_HEADER) + vhdr->ImageLength > tbl_size) { | |
| 338 | − DRM_ERROR("ACPI VFCT image truncated\n"); | |
| 339 | − goto out_unmap; | |
| 340 | − } | |
| 378 | + offset += sizeof(VFCT_IMAGE_HEADER); | |
| 379 | + if (offset > tbl_size) { | |
| 380 | + DRM_ERROR("ACPI VFCT image header truncated\n"); | |
| 381 | + return false; | |
| 382 | + } | |
| 383 | + | |
| 384 | + offset += vhdr->ImageLength; | |
| 385 | + if (offset > tbl_size) { | |
| 386 | + DRM_ERROR("ACPI VFCT image truncated\n"); | |
| 387 | + return false; | |
| 388 | + } | |
| 341 | 389 | |
| 342 | − adev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL); | |
| 343 | − adev->bios_size = vhdr->ImageLength; | |
| 344 | − ret = !!adev->bios; | |
| 390 | + if (vhdr->ImageLength && | |
| 391 | + vhdr->PCIBus == adev->pdev->bus->number && | |
| 392 | + vhdr->PCIDevice == PCI_SLOT(adev->pdev->devfn) && | |
| 393 | + vhdr->PCIFunction == PCI_FUNC(adev->pdev->devfn) && | |
| 394 | + vhdr->VendorID == adev->pdev->vendor && | |
| 395 | + vhdr->DeviceID == adev->pdev->device) { | |
| 396 | + adev->bios = kmemdup(&vbios->VbiosContent, | |
| 397 | + vhdr->ImageLength, | |
| 398 | + GFP_KERNEL); | |
| 399 | + | |
| 400 | + if (!check_atom_bios(adev->bios, vhdr->ImageLength)) { | |
| 401 | + kfree(adev->bios); | |
| 402 | + return false; | |
| 403 | + } | |
| 404 | + adev->bios_size = vhdr->ImageLength; | |
| 405 | + return true; | |
| 406 | + } | |
| 407 | + } | |
| 345 | 408 | |
| 346 | −out_unmap: | |
| 347 | − return ret; | |
| 409 | + DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n"); | |
| 410 | + return false; | |
| 348 | 411 | } |
| 349 | 412 | #else |
| 350 | 413 | static inline bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) |
| @@ -355,57 +418,27 @@ static inline bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) · 4 unmodified lines | ||
| 355 | 418 | |
| 356 | 419 | bool amdgpu_get_bios(struct amdgpu_device *adev) |
| 357 | 420 | { |
| 358 | − bool r; | |
| 359 | − uint16_t tmp, bios_header_start; | |
| 421 | + if (amdgpu_atrm_get_bios(adev)) | |
| 422 | + return true; | |
| 360 | 423 | |
| 361 | − r = amdgpu_atrm_get_bios(adev); | |
| 362 | − if (!r) | |
| 363 | − r = amdgpu_acpi_vfct_bios(adev); | |
| 364 | − if (!r) | |
| 365 | − r = igp_read_bios_from_vram(adev); | |
| 366 | − if (!r) | |
| 367 | − r = amdgpu_read_bios(adev); | |
| 368 | − if (!r) { | |
| 369 | − r = amdgpu_read_bios_from_rom(adev); | |
| 370 | − } | |
| 371 | − if (!r) { | |
| 372 | − r = amdgpu_read_disabled_bios(adev); | |
| 373 | − } | |
| 374 | − if (!r) { | |
| 375 | − r = amdgpu_read_platform_bios(adev); | |
| 376 | − } | |
| 377 | − if (!r || adev->bios == NULL) { | |
| 378 | − DRM_ERROR("Unable to locate a BIOS ROM\n"); | |
| 379 | − adev->bios = NULL; | |
| 380 | − return false; | |
| 381 | − } | |
| 382 | − if (!AMD_IS_VALID_VBIOS(adev->bios)) { | |
| 383 | − printk("BIOS signature incorrect %x %x\n", adev->bios[0], adev->bios[1]); | |
| 384 | − goto free_bios; | |
| 385 | − } | |
| 424 | + if (amdgpu_acpi_vfct_bios(adev)) | |
| 425 | + return true; | |
| 386 | 426 | |
| 387 | − tmp = RBIOS16(0x18); | |
| 388 | − if (RBIOS8(tmp + 0x14) != 0x0) { | |
| 389 | − DRM_INFO("Not an x86 BIOS ROM, not using.\n"); | |
| 390 | − goto free_bios; | |
| 391 | − } | |
| 427 | + if (igp_read_bios_from_vram(adev)) | |
| 428 | + return true; | |
| 392 | 429 | |
| 393 | − bios_header_start = RBIOS16(0x48); | |
| 394 | − if (!bios_header_start) { | |
| 395 | − goto free_bios; | |
| 396 | − } | |
| 397 | − tmp = bios_header_start + 4; | |
| 398 | − if (!memcmp(adev->bios + tmp, "ATOM", 4) || | |
| 399 | − !memcmp(adev->bios + tmp, "MOTA", 4)) { | |
| 400 | − adev->is_atom_bios = true; | |
| 401 | − } else { | |
| 402 | − adev->is_atom_bios = false; | |
| 403 | − } | |
| 430 | + if (amdgpu_read_bios(adev)) | |
| 431 | + return true; | |
| 404 | 432 | |
| 405 | − DRM_DEBUG("%sBIOS detected\n", adev->is_atom_bios ? "ATOM" : "COM"); | |
| 406 | − return true; | |
| 407 | −free_bios: | |
| 408 | − kfree(adev->bios); | |
| 409 | − adev->bios = NULL; | |
| 433 | + if (amdgpu_read_bios_from_rom(adev)) | |
| 434 | + return true; | |
| 435 | + | |
| 436 | + if (amdgpu_read_disabled_bios(adev)) | |
| 437 | + return true; | |
| 438 | + | |
| 439 | + if (amdgpu_read_platform_bios(adev)) | |
| 440 | + return true; | |
| 441 | + | |
| 442 | + DRM_ERROR("Unable to locate a BIOS ROM\n"); | |
| 410 | 443 | return false; |
| 411 | 444 | } |
| @@ -713,6 +713,7 @@ static int amdgpu_cgs_rel_firmware(struct cgs_device *cgs_device, enum cgs_ucode · 712 unmodified lines | ||
| 713 | 713 | CGS_FUNC_ADEV; |
| 714 | 714 | if ((CGS_UCODE_ID_SMU == type) || (CGS_UCODE_ID_SMU_SK == type)) { |
| 715 | 715 | release_firmware(adev->pm.fw); |
| 716 | + adev->pm.fw = NULL; | |
| 716 | 717 | return 0; |
| 717 | 718 | } |
| 718 | 719 | /* cannot release other firmware because they are not created by cgs */ |
| @@ -762,6 +763,23 @@ static uint16_t amdgpu_get_firmware_version(struct cgs_device *cgs_device, · 43 unmodified lines | ||
| 762 | 763 | return fw_version; |
| 763 | 764 | } |
| 764 | 765 | |
| 766 | +static int amdgpu_cgs_enter_safe_mode(struct cgs_device *cgs_device, | |
| 767 | + bool en) | |
| 768 | +{ | |
| 769 | + CGS_FUNC_ADEV; | |
| 770 | + | |
| 771 | + if (adev->gfx.rlc.funcs->enter_safe_mode == NULL || | |
| 772 | + adev->gfx.rlc.funcs->exit_safe_mode == NULL) | |
| 773 | + return 0; | |
| 774 | + | |
| 775 | + if (en) | |
| 776 | + adev->gfx.rlc.funcs->enter_safe_mode(adev); | |
| 777 | + else | |
| 778 | + adev->gfx.rlc.funcs->exit_safe_mode(adev); | |
| 779 | + | |
| 780 | + return 0; | |
| 781 | +} | |
| 782 | + | |
| 765 | 783 | static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, |
| 766 | 784 | enum cgs_ucode_id type, |
| 767 | 785 | struct cgs_firmware_info *info) |
| @@ -808,6 +826,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, · 40 unmodified lines | ||
| 808 | 826 | const uint8_t *src; |
| 809 | 827 | const struct smc_firmware_header_v1_0 *hdr; |
| 810 | 828 | |
| 829 | + if (CGS_UCODE_ID_SMU_SK == type) | |
| 830 | + amdgpu_cgs_rel_firmware(cgs_device, CGS_UCODE_ID_SMU); | |
| 831 | + | |
| 811 | 832 | if (!adev->pm.fw) { |
| 812 | 833 | switch (adev->asic_type) { |
| 813 | 834 | case CHIP_TOPAZ: |
| @@ -1200,51 +1221,52 @@ static int amdgpu_cgs_call_acpi_method(struct cgs_device *cgs_device, · 386 unmodified lines | ||
| 1200 | 1221 | } |
| 1201 | 1222 | |
| 1202 | 1223 | static const struct cgs_ops amdgpu_cgs_ops = { |
| 1203 | − amdgpu_cgs_gpu_mem_info, | |
| 1204 | − amdgpu_cgs_gmap_kmem, | |
| 1205 | − amdgpu_cgs_gunmap_kmem, | |
| 1206 | − amdgpu_cgs_alloc_gpu_mem, | |
| 1207 | − amdgpu_cgs_free_gpu_mem, | |
| 1208 | − amdgpu_cgs_gmap_gpu_mem, | |
| 1209 | − amdgpu_cgs_gunmap_gpu_mem, | |
| 1210 | − amdgpu_cgs_kmap_gpu_mem, | |
| 1211 | − amdgpu_cgs_kunmap_gpu_mem, | |
| 1212 | − amdgpu_cgs_read_register, | |
| 1213 | − amdgpu_cgs_write_register, | |
| 1214 | − amdgpu_cgs_read_ind_register, | |
| 1215 | − amdgpu_cgs_write_ind_register, | |
| 1216 | − amdgpu_cgs_read_pci_config_byte, | |
| 1217 | − amdgpu_cgs_read_pci_config_word, | |
| 1218 | − amdgpu_cgs_read_pci_config_dword, | |
| 1219 | − amdgpu_cgs_write_pci_config_byte, | |
| 1220 | − amdgpu_cgs_write_pci_config_word, | |
| 1221 | − amdgpu_cgs_write_pci_config_dword, | |
| 1222 | − amdgpu_cgs_get_pci_resource, | |
| 1223 | − amdgpu_cgs_atom_get_data_table, | |
| 1224 | − amdgpu_cgs_atom_get_cmd_table_revs, | |
| 1225 | − amdgpu_cgs_atom_exec_cmd_table, | |
| 1226 | − amdgpu_cgs_create_pm_request, | |
| 1227 | − amdgpu_cgs_destroy_pm_request, | |
| 1228 | − amdgpu_cgs_set_pm_request, | |
| 1229 | − amdgpu_cgs_pm_request_clock, | |
| 1230 | − amdgpu_cgs_pm_request_engine, | |
| 1231 | − amdgpu_cgs_pm_query_clock_limits, | |
| 1232 | − amdgpu_cgs_set_camera_voltages, | |
| 1233 | − amdgpu_cgs_get_firmware_info, | |
| 1234 | − amdgpu_cgs_rel_firmware, | |
| 1235 | − amdgpu_cgs_set_powergating_state, | |
| 1236 | − amdgpu_cgs_set_clockgating_state, | |
| 1237 | − amdgpu_cgs_get_active_displays_info, | |
| 1238 | − amdgpu_cgs_notify_dpm_enabled, | |
| 1239 | − amdgpu_cgs_call_acpi_method, | |
| 1240 | − amdgpu_cgs_query_system_info, | |
| 1241 | − amdgpu_cgs_is_virtualization_enabled | |
| 1224 | + .gpu_mem_info = amdgpu_cgs_gpu_mem_info, | |
| 1225 | + .gmap_kmem = amdgpu_cgs_gmap_kmem, | |
| 1226 | + .gunmap_kmem = amdgpu_cgs_gunmap_kmem, | |
| 1227 | + .alloc_gpu_mem = amdgpu_cgs_alloc_gpu_mem, | |
| 1228 | + .free_gpu_mem = amdgpu_cgs_free_gpu_mem, | |
| 1229 | + .gmap_gpu_mem = amdgpu_cgs_gmap_gpu_mem, | |
| 1230 | + .gunmap_gpu_mem = amdgpu_cgs_gunmap_gpu_mem, | |
| 1231 | + .kmap_gpu_mem = amdgpu_cgs_kmap_gpu_mem, | |
| 1232 | + .kunmap_gpu_mem = amdgpu_cgs_kunmap_gpu_mem, | |
| 1233 | + .read_register = amdgpu_cgs_read_register, | |
| 1234 | + .write_register = amdgpu_cgs_write_register, | |
| 1235 | + .read_ind_register = amdgpu_cgs_read_ind_register, | |
| 1236 | + .write_ind_register = amdgpu_cgs_write_ind_register, | |
| 1237 | + .read_pci_config_byte = amdgpu_cgs_read_pci_config_byte, | |
| 1238 | + .read_pci_config_word = amdgpu_cgs_read_pci_config_word, | |
| 1239 | + .read_pci_config_dword = amdgpu_cgs_read_pci_config_dword, | |
| 1240 | + .write_pci_config_byte = amdgpu_cgs_write_pci_config_byte, | |
| 1241 | + .write_pci_config_word = amdgpu_cgs_write_pci_config_word, | |
| 1242 | + .write_pci_config_dword = amdgpu_cgs_write_pci_config_dword, | |
| 1243 | + .get_pci_resource = amdgpu_cgs_get_pci_resource, | |
| 1244 | + .atom_get_data_table = amdgpu_cgs_atom_get_data_table, | |
| 1245 | + .atom_get_cmd_table_revs = amdgpu_cgs_atom_get_cmd_table_revs, | |
| 1246 | + .atom_exec_cmd_table = amdgpu_cgs_atom_exec_cmd_table, | |
| 1247 | + .create_pm_request = amdgpu_cgs_create_pm_request, | |
| 1248 | + .destroy_pm_request = amdgpu_cgs_destroy_pm_request, | |
| 1249 | + .set_pm_request = amdgpu_cgs_set_pm_request, | |
| 1250 | + .pm_request_clock = amdgpu_cgs_pm_request_clock, | |
| 1251 | + .pm_request_engine = amdgpu_cgs_pm_request_engine, | |
| 1252 | + .pm_query_clock_limits = amdgpu_cgs_pm_query_clock_limits, | |
| 1253 | + .set_camera_voltages = amdgpu_cgs_set_camera_voltages, | |
| 1254 | + .get_firmware_info = amdgpu_cgs_get_firmware_info, | |
| 1255 | + .rel_firmware = amdgpu_cgs_rel_firmware, | |
| 1256 | + .set_powergating_state = amdgpu_cgs_set_powergating_state, | |
| 1257 | + .set_clockgating_state = amdgpu_cgs_set_clockgating_state, | |
| 1258 | + .get_active_displays_info = amdgpu_cgs_get_active_displays_info, | |
| 1259 | + .notify_dpm_enabled = amdgpu_cgs_notify_dpm_enabled, | |
| 1260 | + .call_acpi_method = amdgpu_cgs_call_acpi_method, | |
| 1261 | + .query_system_info = amdgpu_cgs_query_system_info, | |
| 1262 | + .is_virtualization_enabled = amdgpu_cgs_is_virtualization_enabled, | |
| 1263 | + .enter_safe_mode = amdgpu_cgs_enter_safe_mode, | |
| 1242 | 1264 | }; |
| 1243 | 1265 | |
| 1244 | 1266 | static const struct cgs_os_ops amdgpu_cgs_os_ops = { |
| 1245 | − amdgpu_cgs_add_irq_source, | |
| 1246 | − amdgpu_cgs_irq_get, | |
| 1247 | − amdgpu_cgs_irq_put | |
| 1267 | + .add_irq_source = amdgpu_cgs_add_irq_source, | |
| 1268 | + .irq_get = amdgpu_cgs_irq_get, | |
| 1269 | + .irq_put = amdgpu_cgs_irq_put | |
| 1248 | 1270 | }; |
| 1249 | 1271 | |
| 1250 | 1272 | struct cgs_device *amdgpu_cgs_create_device(struct amdgpu_device *adev) |
| @@ -75,10 +75,10 @@ int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, · 74 unmodified lines | ||
| 75 | 75 | *out_ring = &adev->uvd.ring; |
| 76 | 76 | break; |
| 77 | 77 | case AMDGPU_HW_IP_VCE: |
| 78 | − if (ring < 2){ | |
| 78 | + if (ring < adev->vce.num_rings){ | |
| 79 | 79 | *out_ring = &adev->vce.ring[ring]; |
| 80 | 80 | } else { |
| 81 | − DRM_ERROR("only two VCE rings are supported\n"); | |
| 81 | + DRM_ERROR("only %d VCE rings are supported\n", adev->vce.num_rings); | |
| 82 | 82 | return -EINVAL; |
| 83 | 83 | } |
| 84 | 84 | break; |
| @@ -771,6 +771,20 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p, · 686 unmodified lines | ||
| 771 | 771 | if (r) |
| 772 | 772 | return r; |
| 773 | 773 | |
| 774 | + if (amdgpu_sriov_vf(adev)) { | |
| 775 | + struct dma_fence *f; | |
| 776 | + bo_va = vm->csa_bo_va; | |
| 777 | + BUG_ON(!bo_va); | |
| 778 | + r = amdgpu_vm_bo_update(adev, bo_va, false); | |
| 779 | + if (r) | |
| 780 | + return r; | |
| 781 | + | |
| 782 | + f = bo_va->last_pt_update; | |
| 783 | + r = amdgpu_sync_fence(adev, &p->job->sync, f); | |
| 784 | + if (r) | |
| 785 | + return r; | |
| 786 | + } | |
| 787 | + | |
| 774 | 788 | if (p->bo_list) { |
| 775 | 789 | for (i = 0; i < p->bo_list->num_entries; i++) { |
| 776 | 790 | struct dma_fence *f; |
| @@ -94,6 +94,11 @@ uint32_t amdgpu_mm_rreg(struct amdgpu_device *adev, uint32_t reg, · 93 unmodified lines | ||
| 94 | 94 | { |
| 95 | 95 | uint32_t ret; |
| 96 | 96 | |
| 97 | + if (amdgpu_sriov_runtime(adev)) { | |
| 98 | + BUG_ON(in_interrupt()); | |
| 99 | + return amdgpu_virt_kiq_rreg(adev, reg); | |
| 100 | + } | |
| 101 | + | |
| 97 | 102 | if ((reg * 4) < adev->rmmio_size && !always_indirect) |
| 98 | 103 | ret = readl(((void __iomem *)adev->rmmio) + (reg * 4)); |
| 99 | 104 | else { |
| @@ -113,6 +118,11 @@ void amdgpu_mm_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, · 13 unmodified lines | ||
| 113 | 118 | { |
| 114 | 119 | trace_amdgpu_mm_wreg(adev->pdev->device, reg, v); |
| 115 | 120 | |
| 121 | + if (amdgpu_sriov_runtime(adev)) { | |
| 122 | + BUG_ON(in_interrupt()); | |
| 123 | + return amdgpu_virt_kiq_wreg(adev, reg, v); | |
| 124 | + } | |
| 125 | + | |
| 116 | 126 | if ((reg * 4) < adev->rmmio_size && !always_indirect) |
| 117 | 127 | writel(v, ((void __iomem *)adev->rmmio) + (reg * 4)); |
| 118 | 128 | else { |
| @@ -885,7 +895,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev) · 766 unmodified lines | ||
| 885 | 895 | atom_card_info->ioreg_read = cail_ioreg_read; |
| 886 | 896 | atom_card_info->ioreg_write = cail_ioreg_write; |
| 887 | 897 | } else { |
| 888 | − DRM_ERROR("Unable to find PCI I/O BAR; using MMIO for ATOM IIO\n"); | |
| 898 | + DRM_INFO("PCI I/O BAR is not found. Using MMIO to access ATOM BIOS\n"); | |
| 889 | 899 | atom_card_info->ioreg_read = cail_reg_read; |
| 890 | 900 | atom_card_info->ioreg_write = cail_reg_write; |
| 891 | 901 | } |
| @@ -1131,6 +1141,18 @@ int amdgpu_set_powergating_state(struct amdgpu_device *adev, · 239 unmodified lines | ||
| 1131 | 1141 | return r; |
| 1132 | 1142 | } |
| 1133 | 1143 | |
| 1144 | +void amdgpu_get_clockgating_state(struct amdgpu_device *adev, u32 *flags) | |
| 1145 | +{ | |
| 1146 | + int i; | |
| 1147 | + | |
| 1148 | + for (i = 0; i < adev->num_ip_blocks; i++) { | |
| 1149 | + if (!adev->ip_blocks[i].status.valid) | |
| 1150 | + continue; | |
| 1151 | + if (adev->ip_blocks[i].version->funcs->get_clockgating_state) | |
| 1152 | + adev->ip_blocks[i].version->funcs->get_clockgating_state((void *)adev, flags); | |
| 1153 | + } | |
| 1154 | +} | |
| 1155 | + | |
| 1134 | 1156 | int amdgpu_wait_for_idle(struct amdgpu_device *adev, |
| 1135 | 1157 | enum amd_ip_block_type block_type) |
| 1136 | 1158 | { |
| @@ -1235,7 +1257,8 @@ static void amdgpu_device_enable_virtual_display(struct amdgpu_device *adev) · 98 unmodified lines | ||
| 1235 | 1257 | pciaddstr_tmp = pciaddstr; |
| 1236 | 1258 | while ((pciaddname_tmp = strsep(&pciaddstr_tmp, ";"))) { |
| 1237 | 1259 | pciaddname = strsep(&pciaddname_tmp, ","); |
| 1238 | − if (!strcmp(pci_address_name, pciaddname)) { | |
| 1260 | + if (!strcmp("all", pciaddname) | |
| 1261 | + || !strcmp(pci_address_name, pciaddname)) { | |
| 1239 | 1262 | long num_crtc; |
| 1240 | 1263 | int res = -1; |
| 1241 | 1264 | |
| @@ -1323,6 +1346,12 @@ static int amdgpu_early_init(struct amdgpu_device *adev) · 81 unmodified lines | ||
| 1323 | 1346 | return -EINVAL; |
| 1324 | 1347 | } |
| 1325 | 1348 | |
| 1349 | + if (amdgpu_sriov_vf(adev)) { | |
| 1350 | + r = amdgpu_virt_request_full_gpu(adev, true); | |
| 1351 | + if (r) | |
| 1352 | + return r; | |
| 1353 | + } | |
| 1354 | + | |
| 1326 | 1355 | for (i = 0; i < adev->num_ip_blocks; i++) { |
| 1327 | 1356 | if ((amdgpu_ip_block_mask & (1 << i)) == 0) { |
| 1328 | 1357 | DRM_ERROR("disabled ip block: %d\n", i); |
| @@ -1383,6 +1412,15 @@ static int amdgpu_init(struct amdgpu_device *adev) · 54 unmodified lines | ||
| 1383 | 1412 | return r; |
| 1384 | 1413 | } |
| 1385 | 1414 | adev->ip_blocks[i].status.hw = true; |
| 1415 | + | |
| 1416 | + /* right after GMC hw init, we create CSA */ | |
| 1417 | + if (amdgpu_sriov_vf(adev)) { | |
| 1418 | + r = amdgpu_allocate_static_csa(adev); | |
| 1419 | + if (r) { | |
| 1420 | + DRM_ERROR("allocate CSA failed %d\n", r); | |
| 1421 | + return r; | |
| 1422 | + } | |
| 1423 | + } | |
| 1386 | 1424 | } |
| 1387 | 1425 | } |
| 1388 | 1426 | |
| @@ -1516,6 +1554,11 @@ static int amdgpu_fini(struct amdgpu_device *adev) · 127 unmodified lines | ||
| 1516 | 1554 | adev->ip_blocks[i].status.late_initialized = false; |
| 1517 | 1555 | } |
| 1518 | 1556 | |
| 1557 | + if (amdgpu_sriov_vf(adev)) { | |
| 1558 | + amdgpu_bo_free_kernel(&adev->virt.csa_obj, &adev->virt.csa_vmid0_addr, NULL); | |
| 1559 | + amdgpu_virt_release_full_gpu(adev, false); | |
| 1560 | + } | |
| 1561 | + | |
| 1519 | 1562 | return 0; |
| 1520 | 1563 | } |
| 1521 | 1564 | |
| @@ -1523,6 +1566,9 @@ int amdgpu_suspend(struct amdgpu_device *adev) · 1 unmodified line | ||
| 1523 | 1566 | { |
| 1524 | 1567 | int i, r; |
| 1525 | 1568 | |
| 1569 | + if (amdgpu_sriov_vf(adev)) | |
| 1570 | + amdgpu_virt_request_full_gpu(adev, false); | |
| 1571 | + | |
| 1526 | 1572 | /* ungate SMC block first */ |
| 1527 | 1573 | r = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_SMC, |
| 1528 | 1574 | AMD_CG_STATE_UNGATE); |
| @@ -1551,6 +1597,9 @@ int amdgpu_suspend(struct amdgpu_device *adev) · 22 unmodified lines | ||
| 1551 | 1597 | } |
| 1552 | 1598 | } |
| 1553 | 1599 | |
| 1600 | + if (amdgpu_sriov_vf(adev)) | |
| 1601 | + amdgpu_virt_release_full_gpu(adev, false); | |
| 1602 | + | |
| 1554 | 1603 | return 0; |
| 1555 | 1604 | } |
| 1556 | 1605 | |
| @@ -1575,7 +1624,7 @@ static int amdgpu_resume(struct amdgpu_device *adev) · 18 unmodified lines | ||
| 1575 | 1624 | static void amdgpu_device_detect_sriov_bios(struct amdgpu_device *adev) |
| 1576 | 1625 | { |
| 1577 | 1626 | if (amdgpu_atombios_has_gpu_virtualization_table(adev)) |
| 1578 | − adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; | |
| 1627 | + adev->virt.caps |= AMDGPU_SRIOV_CAPS_SRIOV_VBIOS; | |
| 1579 | 1628 | } |
| 1580 | 1629 | |
| 1581 | 1630 | /** |
| @@ -1605,7 +1654,6 @@ int amdgpu_device_init(struct amdgpu_device *adev, · 23 unmodified lines | ||
| 1605 | 1654 | adev->pdev = pdev; |
| 1606 | 1655 | adev->flags = flags; |
| 1607 | 1656 | adev->asic_type = flags & AMD_ASIC_MASK; |
| 1608 | − adev->is_atom_bios = false; | |
| 1609 | 1657 | adev->usec_timeout = AMDGPU_MAX_USEC_TIMEOUT; |
| 1610 | 1658 | adev->mc.gtt_size = 512 * 1024 * 1024; |
| 1611 | 1659 | adev->accel_working = false; |
| @@ -1695,7 +1743,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, · 83 unmodified lines | ||
| 1695 | 1743 | } |
| 1696 | 1744 | } |
| 1697 | 1745 | if (adev->rio_mem == NULL) |
| 1698 | − DRM_ERROR("Unable to find PCI I/O BAR\n"); | |
| 1746 | + DRM_INFO("PCI I/O BAR is not found.\n"); | |
| 1699 | 1747 | |
| 1700 | 1748 | /* early init functions */ |
| 1701 | 1749 | r = amdgpu_early_init(adev); |
| @@ -1720,12 +1768,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, · 18 unmodified lines | ||
| 1720 | 1768 | r = -EINVAL; |
| 1721 | 1769 | goto failed; |
| 1722 | 1770 | } |
| 1723 | − /* Must be an ATOMBIOS */ | |
| 1724 | − if (!adev->is_atom_bios) { | |
| 1725 | − dev_err(adev->dev, "Expecting atombios for GPU\n"); | |
| 1726 | − r = -EINVAL; | |
| 1727 | − goto failed; | |
| 1728 | − } | |
| 1771 | + | |
| 1729 | 1772 | r = amdgpu_atombios_init(adev); |
| 1730 | 1773 | if (r) { |
| 1731 | 1774 | dev_err(adev->dev, "amdgpu_atombios_init failed\n"); |
| @@ -2249,6 +2292,9 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) · 517 unmodified lines | ||
| 2249 | 2292 | int resched; |
| 2250 | 2293 | bool need_full_reset; |
| 2251 | 2294 | |
| 2295 | + if (amdgpu_sriov_vf(adev)) | |
| 2296 | + return 0; | |
| 2297 | + | |
| 2252 | 2298 | if (!amdgpu_check_soft_reset(adev)) { |
| 2253 | 2299 | DRM_INFO("No hardware hang detected. Did some blocks stall?\n"); |
| 2254 | 2300 | return 0; |
| @@ -2837,7 +2883,7 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf, · 582 unmodified lines | ||
| 2837 | 2883 | return -ENOMEM; |
| 2838 | 2884 | |
| 2839 | 2885 | /* version, increment each time something is added */ |
| 2840 | − config[no_regs++] = 2; | |
| 2886 | + config[no_regs++] = 3; | |
| 2841 | 2887 | config[no_regs++] = adev->gfx.config.max_shader_engines; |
| 2842 | 2888 | config[no_regs++] = adev->gfx.config.max_tile_pipes; |
| 2843 | 2889 | config[no_regs++] = adev->gfx.config.max_cu_per_sh; |
| @@ -2871,6 +2917,12 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf, · 27 unmodified lines | ||
| 2871 | 2917 | config[no_regs++] = adev->family; |
| 2872 | 2918 | config[no_regs++] = adev->external_rev_id; |
| 2873 | 2919 | |
| 2920 | + /* rev==3 */ | |
| 2921 | + config[no_regs++] = adev->pdev->device; | |
| 2922 | + config[no_regs++] = adev->pdev->revision; | |
| 2923 | + config[no_regs++] = adev->pdev->subsystem_device; | |
| 2924 | + config[no_regs++] = adev->pdev->subsystem_vendor; | |
| 2925 | + | |
| 2874 | 2926 | while (size && (*pos < no_regs * 4)) { |
| 2875 | 2927 | uint32_t value; |
| 2876 | 2928 | |
| @@ -138,10 +138,52 @@ static void amdgpu_unpin_work_func(struct work_struct *__work) · 137 unmodified lines | ||
| 138 | 138 | kfree(work); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | −int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, | |
| 142 | − struct drm_framebuffer *fb, | |
| 143 | − struct drm_pending_vblank_event *event, | |
| 144 | − uint32_t page_flip_flags, uint32_t target) | |
| 141 | + | |
| 142 | +static void amdgpu_flip_work_cleanup(struct amdgpu_flip_work *work) | |
| 143 | +{ | |
| 144 | + int i; | |
| 145 | + | |
| 146 | + amdgpu_bo_unref(&work->old_abo); | |
| 147 | + dma_fence_put(work->excl); | |
| 148 | + for (i = 0; i < work->shared_count; ++i) | |
| 149 | + dma_fence_put(work->shared[i]); | |
| 150 | + kfree(work->shared); | |
| 151 | + kfree(work); | |
| 152 | +} | |
| 153 | + | |
| 154 | +static void amdgpu_flip_cleanup_unreserve(struct amdgpu_flip_work *work, | |
| 155 | + struct amdgpu_bo *new_abo) | |
| 156 | +{ | |
| 157 | + amdgpu_bo_unreserve(new_abo); | |
| 158 | + amdgpu_flip_work_cleanup(work); | |
| 159 | +} | |
| 160 | + | |
| 161 | +static void amdgpu_flip_cleanup_unpin(struct amdgpu_flip_work *work, | |
| 162 | + struct amdgpu_bo *new_abo) | |
| 163 | +{ | |
| 164 | + if (unlikely(amdgpu_bo_unpin(new_abo) != 0)) | |
| 165 | + DRM_ERROR("failed to unpin new abo in error path\n"); | |
| 166 | + amdgpu_flip_cleanup_unreserve(work, new_abo); | |
| 167 | +} | |
| 168 | + | |
| 169 | +void amdgpu_crtc_cleanup_flip_ctx(struct amdgpu_flip_work *work, | |
| 170 | + struct amdgpu_bo *new_abo) | |
| 171 | +{ | |
| 172 | + if (unlikely(amdgpu_bo_reserve(new_abo, false) != 0)) { | |
| 173 | + DRM_ERROR("failed to reserve new abo in error path\n"); | |
| 174 | + amdgpu_flip_work_cleanup(work); | |
| 175 | + return; | |
| 176 | + } | |
| 177 | + amdgpu_flip_cleanup_unpin(work, new_abo); | |
| 178 | +} | |
| 179 | + | |
| 180 | +int amdgpu_crtc_prepare_flip(struct drm_crtc *crtc, | |
| 181 | + struct drm_framebuffer *fb, | |
| 182 | + struct drm_pending_vblank_event *event, | |
| 183 | + uint32_t page_flip_flags, | |
| 184 | + uint32_t target, | |
| 185 | + struct amdgpu_flip_work **work_p, | |
| 186 | + struct amdgpu_bo **new_abo_p) | |
| 145 | 187 | { |
| 146 | 188 | struct drm_device *dev = crtc->dev; |
| 147 | 189 | struct amdgpu_device *adev = dev->dev_private; |
| @@ -154,7 +196,7 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, · 6 unmodified lines | ||
| 154 | 196 | unsigned long flags; |
| 155 | 197 | u64 tiling_flags; |
| 156 | 198 | u64 base; |
| 157 | − int i, r; | |
| 199 | + int r; | |
| 158 | 200 | |
| 159 | 201 | work = kzalloc(sizeof *work, GFP_KERNEL); |
| 160 | 202 | if (work == NULL) |
| @@ -189,7 +231,6 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, · 28 unmodified lines | ||
| 189 | 231 | |
| 190 | 232 | r = amdgpu_bo_pin(new_abo, AMDGPU_GEM_DOMAIN_VRAM, &base); |
| 191 | 233 | if (unlikely(r != 0)) { |
| 192 | − r = -EINVAL; | |
| 193 | 234 | DRM_ERROR("failed to pin new abo buffer before flip\n"); |
| 194 | 235 | goto unreserve; |
| 195 | 236 | } |
| @@ -216,41 +257,79 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, · 20 unmodified lines | ||
| 216 | 257 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); |
| 217 | 258 | r = -EBUSY; |
| 218 | 259 | goto pflip_cleanup; |
| 260 | + | |
| 219 | 261 | } |
| 262 | + spin_unlock_irqrestore(&crtc->dev->event_lock, flags); | |
| 263 | + | |
| 264 | + *work_p = work; | |
| 265 | + *new_abo_p = new_abo; | |
| 266 | + | |
| 267 | + return 0; | |
| 268 | + | |
| 269 | +pflip_cleanup: | |
| 270 | + amdgpu_crtc_cleanup_flip_ctx(work, new_abo); | |
| 271 | + return r; | |
| 220 | 272 | |
| 273 | +unpin: | |
| 274 | + amdgpu_flip_cleanup_unpin(work, new_abo); | |
| 275 | + return r; | |
| 276 | + | |
| 277 | +unreserve: | |
| 278 | + amdgpu_flip_cleanup_unreserve(work, new_abo); | |
| 279 | + return r; | |
| 280 | + | |
| 281 | +cleanup: | |
| 282 | + amdgpu_flip_work_cleanup(work); | |
| 283 | + return r; | |
| 284 | + | |
| 285 | +} | |
| 286 | + | |
| 287 | +void amdgpu_crtc_submit_flip(struct drm_crtc *crtc, | |
| 288 | + struct drm_framebuffer *fb, | |
| 289 | + struct amdgpu_flip_work *work, | |
| 290 | + struct amdgpu_bo *new_abo) | |
| 291 | +{ | |
| 292 | + unsigned long flags; | |
| 293 | + struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | |
| 294 | + | |
| 295 | + spin_lock_irqsave(&crtc->dev->event_lock, flags); | |
| 221 | 296 | amdgpu_crtc->pflip_status = AMDGPU_FLIP_PENDING; |
| 222 | 297 | amdgpu_crtc->pflip_works = work; |
| 223 | 298 | |
| 224 | − | |
| 225 | − DRM_DEBUG_DRIVER("crtc:%d[%p], pflip_stat:AMDGPU_FLIP_PENDING, work: %p,\n", | |
| 226 | − amdgpu_crtc->crtc_id, amdgpu_crtc, work); | |
| 227 | 299 | /* update crtc fb */ |
| 228 | 300 | crtc->primary->fb = fb; |
| 229 | 301 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); |
| 302 | + | |
| 303 | + DRM_DEBUG_DRIVER( | |
| 304 | + "crtc:%d[%p], pflip_stat:AMDGPU_FLIP_PENDING, work: %p,\n", | |
| 305 | + amdgpu_crtc->crtc_id, amdgpu_crtc, work); | |
| 306 | + | |
| 230 | 307 | amdgpu_flip_work_func(&work->flip_work.work); |
| 231 | − return 0; | |
| 308 | +} | |
| 232 | 309 | |
| 233 | −pflip_cleanup: | |
| 234 | − if (unlikely(amdgpu_bo_reserve(new_abo, false) != 0)) { | |
| 235 | − DRM_ERROR("failed to reserve new abo in error path\n"); | |
| 236 | − goto cleanup; | |
| 237 | − } | |
| 238 | −unpin: | |
| 239 | − if (unlikely(amdgpu_bo_unpin(new_abo) != 0)) { | |
| 240 | − DRM_ERROR("failed to unpin new abo in error path\n"); | |
| 241 | − } | |
| 242 | −unreserve: | |
| 243 | − amdgpu_bo_unreserve(new_abo); | |
| 310 | +int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, | |
| 311 | + struct drm_framebuffer *fb, | |
| 312 | + struct drm_pending_vblank_event *event, | |
| 313 | + uint32_t page_flip_flags, | |
| 314 | + uint32_t target) | |
| 315 | +{ | |
| 316 | + struct amdgpu_bo *new_abo; | |
| 317 | + struct amdgpu_flip_work *work; | |
| 318 | + int r; | |
| 244 | 319 | |
| 245 | −cleanup: | |
| 246 | − amdgpu_bo_unref(&work->old_abo); | |
| 247 | − dma_fence_put(work->excl); | |
| 248 | − for (i = 0; i < work->shared_count; ++i) | |
| 249 | − dma_fence_put(work->shared[i]); | |
| 250 | − kfree(work->shared); | |
| 251 | − kfree(work); | |
| 320 | + r = amdgpu_crtc_prepare_flip(crtc, | |
| 321 | + fb, | |
| 322 | + event, | |
| 323 | + page_flip_flags, | |
| 324 | + target, | |
| 325 | + &work, | |
| 326 | + &new_abo); | |
| 327 | + if (r) | |
| 328 | + return r; | |
| 252 | 329 | |
| 253 | − return r; | |
| 330 | + amdgpu_crtc_submit_flip(crtc, fb, work, new_abo); | |
| 331 | + | |
| 332 | + return 0; | |
| 254 | 333 | } |
| 255 | 334 | |
| 256 | 335 | int amdgpu_crtc_set_config(struct drm_mode_set *set) |
| @@ -582,12 +661,10 @@ int amdgpu_modeset_create_props(struct amdgpu_device *adev) · 325 unmodified lines | ||
| 582 | 661 | { |
| 583 | 662 | int sz; |
| 584 | 663 | |
| 585 | − if (adev->is_atom_bios) { | |
| 586 | − adev->mode_info.coherent_mode_property = | |
| 587 | − drm_property_create_range(adev->ddev, 0 , "coherent", 0, 1); | |
| 588 | − if (!adev->mode_info.coherent_mode_property) | |
| 589 | − return -ENOMEM; | |
| 590 | − } | |
| 664 | + adev->mode_info.coherent_mode_property = | |
| 665 | + drm_property_create_range(adev->ddev, 0 , "coherent", 0, 1); | |
| 666 | + if (!adev->mode_info.coherent_mode_property) | |
| 667 | + return -ENOMEM; | |
| 591 | 668 | |
| 592 | 669 | adev->mode_info.load_detect_property = |
| 593 | 670 | drm_property_create_range(adev->ddev, 0, "load detection", 0, 1); |
| @@ -241,13 +241,6 @@ enum amdgpu_pcie_gen { · 240 unmodified lines | ||
| 241 | 241 | AMDGPU_PCIE_GEN_INVALID = 0xffff |
| 242 | 242 | }; |
| 243 | 243 | |
| 244 | −enum amdgpu_dpm_forced_level { | |
| 245 | − AMDGPU_DPM_FORCED_LEVEL_AUTO = 0, | |
| 246 | − AMDGPU_DPM_FORCED_LEVEL_LOW = 1, | |
| 247 | − AMDGPU_DPM_FORCED_LEVEL_HIGH = 2, | |
| 248 | − AMDGPU_DPM_FORCED_LEVEL_MANUAL = 3, | |
| 249 | −}; | |
| 250 | − | |
| 251 | 244 | struct amdgpu_dpm_funcs { |
| 252 | 245 | int (*get_temperature)(struct amdgpu_device *adev); |
| 253 | 246 | int (*pre_set_power_state)(struct amdgpu_device *adev); |
| @@ -258,7 +251,7 @@ struct amdgpu_dpm_funcs { · 4 unmodified lines | ||
| 258 | 251 | u32 (*get_mclk)(struct amdgpu_device *adev, bool low); |
| 259 | 252 | void (*print_power_state)(struct amdgpu_device *adev, struct amdgpu_ps *ps); |
| 260 | 253 | void (*debugfs_print_current_performance_level)(struct amdgpu_device *adev, struct seq_file *m); |
| 261 | − int (*force_performance_level)(struct amdgpu_device *adev, enum amdgpu_dpm_forced_level level); | |
| 254 | + int (*force_performance_level)(struct amdgpu_device *adev, enum amd_dpm_forced_level level); | |
| 262 | 255 | bool (*vblank_too_short)(struct amdgpu_device *adev); |
| 263 | 256 | void (*powergate_uvd)(struct amdgpu_device *adev, bool gate); |
| 264 | 257 | void (*powergate_vce)(struct amdgpu_device *adev, bool gate); |
| @@ -353,9 +346,6 @@ struct amdgpu_dpm_funcs { · 88 unmodified lines | ||
| 353 | 346 | #define amdgpu_dpm_get_current_power_state(adev) \ |
| 354 | 347 | (adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle) |
| 355 | 348 | |
| 356 | −#define amdgpu_dpm_get_performance_level(adev) \ | |
| 357 | − (adev)->powerplay.pp_funcs->get_performance_level((adev)->powerplay.pp_handle) | |
| 358 | − | |
| 359 | 349 | #define amdgpu_dpm_get_pp_num_states(adev, data) \ |
| 360 | 350 | (adev)->powerplay.pp_funcs->get_pp_num_states((adev)->powerplay.pp_handle, data) |
| 361 | 351 | |
| @@ -393,6 +383,11 @@ struct amdgpu_dpm_funcs { · 31 unmodified lines | ||
| 393 | 383 | (adev)->powerplay.pp_funcs->get_vce_clock_state((adev)->powerplay.pp_handle, (i)) : \ |
| 394 | 384 | (adev)->pm.funcs->get_vce_clock_state((adev), (i))) |
| 395 | 385 | |
| 386 | +#define amdgpu_dpm_get_performance_level(adev) \ | |
| 387 | + ((adev)->pp_enabled ? \ | |
| 388 | + (adev)->powerplay.pp_funcs->get_performance_level((adev)->powerplay.pp_handle) : \ | |
| 389 | + (adev)->pm.dpm.forced_level) | |
| 390 | + | |
| 396 | 391 | struct amdgpu_dpm { |
| 397 | 392 | struct amdgpu_ps *ps; |
| 398 | 393 | /* number of valid power states */ |
| @@ -440,7 +435,7 @@ struct amdgpu_dpm { · 41 unmodified lines | ||
| 440 | 435 | /* thermal handling */ |
| 441 | 436 | struct amdgpu_dpm_thermal thermal; |
| 442 | 437 | /* forced levels */ |
| 443 | − enum amdgpu_dpm_forced_level forced_level; | |
| 438 | + enum amd_dpm_forced_level forced_level; | |
| 444 | 439 | }; |
| 445 | 440 | |
| 446 | 441 | struct amdgpu_pm { |
| @@ -90,7 +90,6 @@ int amdgpu_vram_page_split = 1024; · 89 unmodified lines | ||
| 90 | 90 | int amdgpu_exp_hw_support = 0; |
| 91 | 91 | int amdgpu_sched_jobs = 32; |
| 92 | 92 | int amdgpu_sched_hw_submission = 2; |
| 93 | −int amdgpu_powerplay = -1; | |
| 94 | 93 | int amdgpu_no_evict = 0; |
| 95 | 94 | int amdgpu_direct_gma_size = 0; |
| 96 | 95 | unsigned amdgpu_pcie_gen_cap = 0; |
| @@ -179,9 +178,6 @@ module_param_named(sched_jobs, amdgpu_sched_jobs, int, 0444); · 82 unmodified lines | ||
| 179 | 178 | MODULE_PARM_DESC(sched_hw_submission, "the max number of HW submissions (default 2)"); |
| 180 | 179 | module_param_named(sched_hw_submission, amdgpu_sched_hw_submission, int, 0444); |
| 181 | 180 | |
| 182 | −MODULE_PARM_DESC(powerplay, "Powerplay component (1 = enable, 0 = disable, -1 = auto (default))"); | |
| 183 | −module_param_named(powerplay, amdgpu_powerplay, int, 0444); | |
| 184 | − | |
| 185 | 181 | MODULE_PARM_DESC(ppfeaturemask, "all power features enabled (default))"); |
| 186 | 182 | module_param_named(ppfeaturemask, amdgpu_pp_feature_mask, int, 0444); |
| 187 | 183 | |
| @@ -471,12 +471,15 @@ out: · 470 unmodified lines | ||
| 471 | 471 | |
| 472 | 472 | static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo) |
| 473 | 473 | { |
| 474 | − unsigned domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); | |
| 475 | − | |
| 476 | 474 | /* if anything is swapped out don't swap it in here, |
| 477 | 475 | just abort and wait for the next CS */ |
| 476 | + if (!amdgpu_bo_gpu_accessible(bo)) | |
| 477 | + return -ERESTARTSYS; | |
| 478 | + | |
| 479 | + if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow)) | |
| 480 | + return -ERESTARTSYS; | |
| 478 | 481 | |
| 479 | − return domain == AMDGPU_GEM_DOMAIN_CPU ? -ERESTARTSYS : 0; | |
| 482 | + return 0; | |
| 480 | 483 | } |
| 481 | 484 | |
| 482 | 485 | /** |
| @@ -496,7 +499,6 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, · 13 unmodified lines | ||
| 496 | 499 | struct amdgpu_bo_list_entry vm_pd; |
| 497 | 500 | struct ww_acquire_ctx ticket; |
| 498 | 501 | struct list_head list, duplicates; |
| 499 | − unsigned domain; | |
| 500 | 502 | int r; |
| 501 | 503 | |
| 502 | 504 | INIT_LIST_HEAD(&list); |
| @@ -514,12 +516,18 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, · 11 unmodified lines | ||
| 514 | 516 | goto error_print; |
| 515 | 517 | |
| 516 | 518 | list_for_each_entry(entry, &list, head) { |
| 517 | − domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); | |
| 519 | + struct amdgpu_bo *bo = | |
| 520 | + container_of(entry->bo, struct amdgpu_bo, tbo); | |
| 521 | + | |
| 518 | 522 | /* if anything is swapped out don't swap it in here, |
| 519 | 523 | just abort and wait for the next CS */ |
| 520 | − if (domain == AMDGPU_GEM_DOMAIN_CPU) | |
| 524 | + if (!amdgpu_bo_gpu_accessible(bo)) | |
| 525 | + goto error_unreserve; | |
| 526 | + | |
| 527 | + if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow)) | |
| 521 | 528 | goto error_unreserve; |
| 522 | 529 | } |
| 530 | + | |
| 523 | 531 | r = amdgpu_vm_validate_pt_bos(adev, bo_va->vm, amdgpu_gem_va_check, |
| 524 | 532 | NULL); |
| 525 | 533 | if (r) |
| @@ -42,12 +42,12 @@ int amdgpu_gfx_scratch_get(struct amdgpu_device *adev, uint32_t *reg) · 41 unmodified lines | ||
| 42 | 42 | { |
| 43 | 43 | int i; |
| 44 | 44 | |
| 45 | − for (i = 0; i < adev->gfx.scratch.num_reg; i++) { | |
| 46 | − if (adev->gfx.scratch.free[i]) { | |
| 47 | − adev->gfx.scratch.free[i] = false; | |
| 48 | − *reg = adev->gfx.scratch.reg[i]; | |
| 49 | − return 0; | |
| 50 | − } | |
| 45 | + i = ffs(adev->gfx.scratch.free_mask); | |
| 46 | + if (i != 0 && i <= adev->gfx.scratch.num_reg) { | |
| 47 | + i--; | |
| 48 | + adev->gfx.scratch.free_mask &= ~(1u << i); | |
| 49 | + *reg = adev->gfx.scratch.reg_base + i; | |
| 50 | + return 0; | |
| 51 | 51 | } |
| 52 | 52 | return -EINVAL; |
| 53 | 53 | } |
| @@ -62,14 +62,7 @@ int amdgpu_gfx_scratch_get(struct amdgpu_device *adev, uint32_t *reg) · 8 unmodified lines | ||
| 62 | 62 | */ |
| 63 | 63 | void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg) |
| 64 | 64 | { |
| 65 | − int i; | |
| 66 | − | |
| 67 | − for (i = 0; i < adev->gfx.scratch.num_reg; i++) { | |
| 68 | − if (adev->gfx.scratch.reg[i] == reg) { | |
| 69 | − adev->gfx.scratch.free[i] = true; | |
| 70 | − return; | |
| 71 | − } | |
| 72 | − } | |
| 65 | + adev->gfx.scratch.free_mask |= 1u << (reg - adev->gfx.scratch.reg_base); | |
| 73 | 66 | } |
| 74 | 67 | |
| 75 | 68 | /** |
| @@ -243,9 +243,9 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man, · 242 unmodified lines | ||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = { |
| 246 | − amdgpu_gtt_mgr_init, | |
| 247 | − amdgpu_gtt_mgr_fini, | |
| 248 | − amdgpu_gtt_mgr_new, | |
| 249 | − amdgpu_gtt_mgr_del, | |
| 250 | − amdgpu_gtt_mgr_debug | |
| 246 | + .init = amdgpu_gtt_mgr_init, | |
| 247 | + .takedown = amdgpu_gtt_mgr_fini, | |
| 248 | + .get_node = amdgpu_gtt_mgr_new, | |
| 249 | + .put_node = amdgpu_gtt_mgr_del, | |
| 250 | + .debug = amdgpu_gtt_mgr_debug | |
| 251 | 251 | }; |
| @@ -231,8 +231,7 @@ void amdgpu_i2c_init(struct amdgpu_device *adev) · 230 unmodified lines | ||
| 231 | 231 | if (amdgpu_hw_i2c) |
| 232 | 232 | DRM_INFO("hw_i2c forced on, you may experience display detection problems!\n"); |
| 233 | 233 | |
| 234 | − if (adev->is_atom_bios) | |
| 235 | − amdgpu_atombios_i2c_init(adev); | |
| 234 | + amdgpu_atombios_i2c_init(adev); | |
| 236 | 235 | } |
| 237 | 236 | |
| 238 | 237 | /* remove all the buses */ |
| @@ -116,8 +116,8 @@ void amdgpu_ib_free(struct amdgpu_device *adev, struct amdgpu_ib *ib, · 115 unmodified lines | ||
| 116 | 116 | * to SI there was just a DE IB. |
| 117 | 117 | */ |
| 118 | 118 | int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, |
| 119 | − struct amdgpu_ib *ibs, struct dma_fence *last_vm_update, | |
| 120 | − struct amdgpu_job *job, struct dma_fence **f) | |
| 119 | + struct amdgpu_ib *ibs, struct amdgpu_job *job, | |
| 120 | + struct dma_fence **f) | |
| 121 | 121 | { |
| 122 | 122 | struct amdgpu_device *adev = ring->adev; |
| 123 | 123 | struct amdgpu_ib *ib = &ibs[0]; |
| @@ -175,15 +175,15 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, · 51 unmodified lines | ||
| 175 | 175 | if (ring->funcs->emit_hdp_flush) |
| 176 | 176 | amdgpu_ring_emit_hdp_flush(ring); |
| 177 | 177 | |
| 178 | − /* always set cond_exec_polling to CONTINUE */ | |
| 179 | − *ring->cond_exe_cpu_addr = 1; | |
| 180 | − | |
| 181 | 178 | skip_preamble = ring->current_ctx == fence_ctx; |
| 182 | 179 | need_ctx_switch = ring->current_ctx != fence_ctx; |
| 183 | 180 | if (job && ring->funcs->emit_cntxcntl) { |
| 184 | 181 | if (need_ctx_switch) |
| 185 | 182 | status |= AMDGPU_HAVE_CTX_SWITCH; |
| 186 | 183 | status |= job->preamble_status; |
| 184 | + | |
| 185 | + if (vm) | |
| 186 | + status |= AMDGPU_VM_DOMAIN; | |
| 187 | 187 | amdgpu_ring_emit_cntxcntl(ring, status); |
| 188 | 188 | } |
| 189 | 189 | |
| @@ -193,7 +193,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, · 3 unmodified lines | ||
| 193 | 193 | /* drop preamble IBs if we don't have a context switch */ |
| 194 | 194 | if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && |
| 195 | 195 | skip_preamble && |
| 196 | − !(status & AMDGPU_PREAMBLE_IB_PRESENT_FIRST)) | |
| 196 | + !(status & AMDGPU_PREAMBLE_IB_PRESENT_FIRST) && | |
| 197 | + !amdgpu_sriov_vf(adev)) /* for SRIOV preemption, Preamble CE ib must be inserted anyway */ | |
| 197 | 198 | continue; |
| 198 | 199 | |
| 199 | 200 | amdgpu_ring_emit_ib(ring, ib, job ? job->vm_id : 0, |
| @@ -223,7 +224,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, · 23 unmodified lines | ||
| 223 | 224 | amdgpu_ring_patch_cond_exec(ring, patch_offset); |
| 224 | 225 | |
| 225 | 226 | ring->current_ctx = fence_ctx; |
| 226 | − if (ring->funcs->emit_switch_buffer) | |
| 227 | + if (vm && ring->funcs->emit_switch_buffer) | |
| 227 | 228 | amdgpu_ring_emit_switch_buffer(ring); |
| 228 | 229 | amdgpu_ring_commit(ring); |
| 229 | 230 | return 0; |
| @@ -170,8 +170,7 @@ static struct dma_fence *amdgpu_job_run(struct amd_sched_job *sched_job) · 169 unmodified lines | ||
| 170 | 170 | BUG_ON(amdgpu_sync_peek_fence(&job->sync, NULL)); |
| 171 | 171 | |
| 172 | 172 | trace_amdgpu_sched_run_job(job); |
| 173 | − r = amdgpu_ib_schedule(job->ring, job->num_ibs, job->ibs, | |
| 174 | − job->sync.last_vm_update, job, &fence); | |
| 173 | + r = amdgpu_ib_schedule(job->ring, job->num_ibs, job->ibs, job, &fence); | |
| 175 | 174 | if (r) |
| 176 | 175 | DRM_ERROR("Error scheduling IBs (%d)\n", r); |
| 177 | 176 | |
| @@ -60,6 +60,9 @@ void amdgpu_driver_unload_kms(struct drm_device *dev) · 59 unmodified lines | ||
| 60 | 60 | if (adev->rmmio == NULL) |
| 61 | 61 | goto done_free; |
| 62 | 62 | |
| 63 | + if (amdgpu_sriov_vf(adev)) | |
| 64 | + amdgpu_virt_request_full_gpu(adev, false); | |
| 65 | + | |
| 63 | 66 | if (amdgpu_device_is_px(dev)) { |
| 64 | 67 | pm_runtime_get_sync(dev->dev); |
| 65 | 68 | pm_runtime_forbid(dev->dev); |
| @@ -138,6 +141,9 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · 72 unmodified lines | ||
| 138 | 141 | pm_runtime_put_autosuspend(dev->dev); |
| 139 | 142 | } |
| 140 | 143 | |
| 144 | + if (amdgpu_sriov_vf(adev)) | |
| 145 | + amdgpu_virt_release_full_gpu(adev, true); | |
| 146 | + | |
| 141 | 147 | out: |
| 142 | 148 | if (r) { |
| 143 | 149 | /* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */ |
| @@ -569,6 +575,27 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · 425 unmodified lines | ||
| 569 | 575 | return -EINVAL; |
| 570 | 576 | } |
| 571 | 577 | } |
| 578 | + case AMDGPU_INFO_NUM_HANDLES: { | |
| 579 | + struct drm_amdgpu_info_num_handles handle; | |
| 580 | + | |
| 581 | + switch (info->query_hw_ip.type) { | |
| 582 | + case AMDGPU_HW_IP_UVD: | |
| 583 | + /* Starting Polaris, we support unlimited UVD handles */ | |
| 584 | + if (adev->asic_type < CHIP_POLARIS10) { | |
| 585 | + handle.uvd_max_handles = adev->uvd.max_handles; | |
| 586 | + handle.uvd_used_handles = amdgpu_uvd_used_handles(adev); | |
| 587 | + | |
| 588 | + return copy_to_user(out, &handle, | |
| 589 | + min((size_t)size, sizeof(handle))) ? -EFAULT : 0; | |
| 590 | + } else { | |
| 591 | + return -ENODATA; | |
| 592 | + } | |
| 593 | + | |
| 594 | + break; | |
| 595 | + default: | |
| 596 | + return -EINVAL; | |
| 597 | + } | |
| 598 | + } | |
| 572 | 599 | default: |
| 573 | 600 | DRM_DEBUG_KMS("Invalid request %d\n", info->query); |
| 574 | 601 | return -EINVAL; |
| @@ -628,6 +655,12 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) · 53 unmodified lines | ||
| 628 | 655 | goto out_suspend; |
| 629 | 656 | } |
| 630 | 657 | |
| 658 | + if (amdgpu_sriov_vf(adev)) { | |
| 659 | + r = amdgpu_map_static_csa(adev, &fpriv->vm); | |
| 660 | + if (r) | |
| 661 | + goto out_suspend; | |
| 662 | + } | |
| 663 | + | |
| 631 | 664 | mutex_init(&fpriv->bo_list_lock); |
| 632 | 665 | idr_init(&fpriv->bo_list_handles); |
| 633 | 666 | |
| @@ -666,6 +699,14 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, · 32 unmodified lines | ||
| 666 | 699 | amdgpu_uvd_free_handles(adev, file_priv); |
| 667 | 700 | amdgpu_vce_free_handles(adev, file_priv); |
| 668 | 701 | |
| 702 | + if (amdgpu_sriov_vf(adev)) { | |
| 703 | + /* TODO: how to handle reserve failure */ | |
| 704 | + BUG_ON(amdgpu_bo_reserve(adev->virt.csa_obj, false)); | |
| 705 | + amdgpu_vm_bo_rmv(adev, fpriv->vm.csa_bo_va); | |
| 706 | + fpriv->vm.csa_bo_va = NULL; | |
| 707 | + amdgpu_bo_unreserve(adev->virt.csa_obj); | |
| 708 | + } | |
| 709 | + | |
| 669 | 710 | amdgpu_vm_fini(adev, &fpriv->vm); |
| 670 | 711 | |
| 671 | 712 | idr_for_each_entry(&fpriv->bo_list_handles, list, handle) |
| @@ -595,6 +595,21 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, · 594 unmodified lines | ||
| 595 | 595 | struct drm_framebuffer *fb, |
| 596 | 596 | struct drm_pending_vblank_event *event, |
| 597 | 597 | uint32_t page_flip_flags, uint32_t target); |
| 598 | +void amdgpu_crtc_cleanup_flip_ctx(struct amdgpu_flip_work *work, | |
| 599 | + struct amdgpu_bo *new_abo); | |
| 600 | +int amdgpu_crtc_prepare_flip(struct drm_crtc *crtc, | |
| 601 | + struct drm_framebuffer *fb, | |
| 602 | + struct drm_pending_vblank_event *event, | |
| 603 | + uint32_t page_flip_flags, | |
| 604 | + uint32_t target, | |
| 605 | + struct amdgpu_flip_work **work, | |
| 606 | + struct amdgpu_bo **new_abo); | |
| 607 | + | |
| 608 | +void amdgpu_crtc_submit_flip(struct drm_crtc *crtc, | |
| 609 | + struct drm_framebuffer *fb, | |
| 610 | + struct amdgpu_flip_work *work, | |
| 611 | + struct amdgpu_bo *new_abo); | |
| 612 | + | |
| 598 | 613 | extern const struct drm_mode_config_funcs amdgpu_mode_funcs; |
| 599 | 614 | |
| 600 | 615 | #endif |
| @@ -363,11 +363,31 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, · 362 unmodified lines | ||
| 363 | 363 | |
| 364 | 364 | bo->flags = flags; |
| 365 | 365 | |
| 366 | +#ifdef CONFIG_X86_32 | |
| 367 | + /* XXX: Write-combined CPU mappings of GTT seem broken on 32-bit | |
| 368 | + * See https://bugs.freedesktop.org/show_bug.cgi?id=84627 | |
| 369 | + */ | |
| 370 | + bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; | |
| 371 | +#elif defined(CONFIG_X86) && !defined(CONFIG_X86_PAT) | |
| 372 | + /* Don't try to enable write-combining when it can't work, or things | |
| 373 | + * may be slow | |
| 374 | + * See https://bugs.freedesktop.org/show_bug.cgi?id=88758 | |
| 375 | + */ | |
| 376 | + | |
| 377 | +#warning Please enable CONFIG_MTRR and CONFIG_X86_PAT for better performance \ | |
| 378 | + thanks to write-combining | |
| 379 | + | |
| 380 | + if (bo->flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) | |
| 381 | + DRM_INFO_ONCE("Please enable CONFIG_MTRR and CONFIG_X86_PAT for " | |
| 382 | + "better performance thanks to write-combining\n"); | |
| 383 | + bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; | |
| 384 | +#else | |
| 366 | 385 | /* For architectures that don't support WC memory, |
| 367 | 386 | * mask out the WC flag from the BO |
| 368 | 387 | */ |
| 369 | 388 | if (!drm_arch_can_wc_memory()) |
| 370 | 389 | bo->flags &= ~AMDGPU_GEM_CREATE_CPU_GTT_USWC; |
| 390 | +#endif | |
| 371 | 391 | |
| 372 | 392 | amdgpu_fill_placement_to_bo(bo, placement); |
| 373 | 393 | /* Kernel allocation are uninterruptible */ |
| @@ -386,6 +406,11 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, · 12 unmodified lines | ||
| 386 | 406 | if (unlikely(r != 0)) |
| 387 | 407 | return r; |
| 388 | 408 | |
| 409 | + bo->tbo.priority = ilog2(bo->tbo.num_pages); | |
| 410 | + if (kernel) | |
| 411 | + bo->tbo.priority *= 2; | |
| 412 | + bo->tbo.priority = min(bo->tbo.priority, (unsigned)(TTM_MAX_BO_PRIORITY - 1)); | |
| 413 | + | |
| 389 | 414 | if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && |
| 390 | 415 | bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { |
| 391 | 416 | struct dma_fence *fence; |
| @@ -408,7 +433,8 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, · 16 unmodified lines | ||
| 408 | 433 | return 0; |
| 409 | 434 | |
| 410 | 435 | fail_unreserve: |
| 411 | − ww_mutex_unlock(&bo->tbo.resv->lock); | |
| 436 | + if (!resv) | |
| 437 | + ww_mutex_unlock(&bo->tbo.resv->lock); | |
| 412 | 438 | amdgpu_bo_unref(&bo); |
| 413 | 439 | return r; |
| 414 | 440 | } |
| @@ -472,7 +498,16 @@ int amdgpu_bo_create(struct amdgpu_device *adev, · 57 unmodified lines | ||
| 472 | 498 | return r; |
| 473 | 499 | |
| 474 | 500 | if (amdgpu_need_backup(adev) && (flags & AMDGPU_GEM_CREATE_SHADOW)) { |
| 501 | + if (!resv) { | |
| 502 | + r = ww_mutex_lock(&(*bo_ptr)->tbo.resv->lock, NULL); | |
| 503 | + WARN_ON(r != 0); | |
| 504 | + } | |
| 505 | + | |
| 475 | 506 | r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr)); |
| 507 | + | |
| 508 | + if (!resv) | |
| 509 | + ww_mutex_unlock(&(*bo_ptr)->tbo.resv->lock); | |
| 510 | + | |
| 476 | 511 | if (r) |
| 477 | 512 | amdgpu_bo_unref(bo_ptr); |
| 478 | 513 | } |
| @@ -849,6 +884,7 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer, · 370 unmodified lines | ||
| 849 | 884 | } |
| 850 | 885 | |
| 851 | 886 | void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, |
| 887 | + bool evict, | |
| 852 | 888 | struct ttm_mem_reg *new_mem) |
| 853 | 889 | { |
| 854 | 890 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); |
| @@ -861,6 +897,10 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, · 6 unmodified lines | ||
| 861 | 897 | abo = container_of(bo, struct amdgpu_bo, tbo); |
| 862 | 898 | amdgpu_vm_bo_invalidate(adev, abo); |
| 863 | 899 | |
| 900 | + /* remember the eviction */ | |
| 901 | + if (evict) | |
| 902 | + atomic64_inc(&adev->num_evictions); | |
| 903 | + | |
| 864 | 904 | /* update statistics */ |
| 865 | 905 | if (!new_mem) |
| 866 | 906 | return; |
| @@ -114,6 +114,15 @@ static inline u64 amdgpu_bo_mmap_offset(struct amdgpu_bo *bo) · 113 unmodified lines | ||
| 114 | 114 | return drm_vma_node_offset_addr(&bo->tbo.vma_node); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | +/** | |
| 118 | + * amdgpu_bo_gpu_accessible - return whether the bo is currently in memory that | |
| 119 | + * is accessible to the GPU. | |
| 120 | + */ | |
| 121 | +static inline bool amdgpu_bo_gpu_accessible(struct amdgpu_bo *bo) | |
| 122 | +{ | |
| 123 | + return bo->tbo.mem.mem_type != TTM_PL_SYSTEM; | |
| 124 | +} | |
| 125 | + | |
| 117 | 126 | int amdgpu_bo_create(struct amdgpu_device *adev, |
| 118 | 127 | unsigned long size, int byte_align, |
| 119 | 128 | bool kernel, u32 domain, u64 flags, |
| @@ -155,7 +164,8 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer, · 35 unmodified lines | ||
| 155 | 164 | size_t buffer_size, uint32_t *metadata_size, |
| 156 | 165 | uint64_t *flags); |
| 157 | 166 | void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, |
| 158 | − struct ttm_mem_reg *new_mem); | |
| 167 | + bool evict, | |
| 168 | + struct ttm_mem_reg *new_mem); | |
| 159 | 169 | int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo); |
| 160 | 170 | void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence, |
| 161 | 171 | bool shared); |
| @@ -34,6 +34,28 @@ · 33 unmodified lines | ||
| 34 | 34 | |
| 35 | 35 | static int amdgpu_debugfs_pm_init(struct amdgpu_device *adev); |
| 36 | 36 | |
| 37 | +static const struct cg_flag_name clocks[] = { | |
| 38 | + {AMD_CG_SUPPORT_GFX_MGCG, "Graphics Medium Grain Clock Gating"}, | |
| 39 | + {AMD_CG_SUPPORT_GFX_MGLS, "Graphics Medium Grain memory Light Sleep"}, | |
| 40 | + {AMD_CG_SUPPORT_GFX_CGCG, "Graphics Coarse Grain Clock Gating"}, | |
| 41 | + {AMD_CG_SUPPORT_GFX_CGLS, "Graphics Coarse Grain memory Light Sleep"}, | |
| 42 | + {AMD_CG_SUPPORT_GFX_CGTS, "Graphics Coarse Grain Tree Shader Clock Gating"}, | |
| 43 | + {AMD_CG_SUPPORT_GFX_CGTS_LS, "Graphics Coarse Grain Tree Shader Light Sleep"}, | |
| 44 | + {AMD_CG_SUPPORT_GFX_CP_LS, "Graphics Command Processor Light Sleep"}, | |
| 45 | + {AMD_CG_SUPPORT_GFX_RLC_LS, "Graphics Run List Controller Light Sleep"}, | |
| 46 | + {AMD_CG_SUPPORT_MC_LS, "Memory Controller Light Sleep"}, | |
| 47 | + {AMD_CG_SUPPORT_MC_MGCG, "Memory Controller Medium Grain Clock Gating"}, | |
| 48 | + {AMD_CG_SUPPORT_SDMA_LS, "System Direct Memory Access Light Sleep"}, | |
| 49 | + {AMD_CG_SUPPORT_SDMA_MGCG, "System Direct Memory Access Medium Grain Clock Gating"}, | |
| 50 | + {AMD_CG_SUPPORT_BIF_LS, "Bus Interface Light Sleep"}, | |
| 51 | + {AMD_CG_SUPPORT_UVD_MGCG, "Unified Video Decoder Medium Grain Clock Gating"}, | |
| 52 | + {AMD_CG_SUPPORT_VCE_MGCG, "Video Compression Engine Medium Grain Clock Gating"}, | |
| 53 | + {AMD_CG_SUPPORT_HDP_LS, "Host Data Path Light Sleep"}, | |
| 54 | + {AMD_CG_SUPPORT_HDP_MGCG, "Host Data Path Medium Grain Clock Gating"}, | |
| 55 | + {AMD_CG_SUPPORT_ROM_MGCG, "Rom Medium Grain Clock Gating"}, | |
| 56 | + {0, NULL}, | |
| 57 | +}; | |
| 58 | + | |
| 37 | 59 | void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev) |
| 38 | 60 | { |
| 39 | 61 | if (adev->pp_enabled) |
| @@ -112,28 +134,23 @@ static ssize_t amdgpu_get_dpm_forced_performance_level(struct device *dev, · 72 unmodified lines | ||
| 112 | 134 | { |
| 113 | 135 | struct drm_device *ddev = dev_get_drvdata(dev); |
| 114 | 136 | struct amdgpu_device *adev = ddev->dev_private; |
| 137 | + enum amd_dpm_forced_level level; | |
| 115 | 138 | |
| 116 | 139 | if ((adev->flags & AMD_IS_PX) && |
| 117 | 140 | (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) |
| 118 | 141 | return snprintf(buf, PAGE_SIZE, "off\n"); |
| 119 | 142 | |
| 120 | − if (adev->pp_enabled) { | |
| 121 | − enum amd_dpm_forced_level level; | |
| 122 | − | |
| 123 | − level = amdgpu_dpm_get_performance_level(adev); | |
| 124 | − return snprintf(buf, PAGE_SIZE, "%s\n", | |
| 125 | − (level == AMD_DPM_FORCED_LEVEL_AUTO) ? "auto" : | |
| 126 | − (level == AMD_DPM_FORCED_LEVEL_LOW) ? "low" : | |
| 127 | − (level == AMD_DPM_FORCED_LEVEL_HIGH) ? "high" : | |
| 128 | − (level == AMD_DPM_FORCED_LEVEL_MANUAL) ? "manual" : "unknown"); | |
| 129 | − } else { | |
| 130 | − enum amdgpu_dpm_forced_level level; | |
| 131 | − | |
| 132 | − level = adev->pm.dpm.forced_level; | |
| 133 | − return snprintf(buf, PAGE_SIZE, "%s\n", | |
| 134 | − (level == AMDGPU_DPM_FORCED_LEVEL_AUTO) ? "auto" : | |
| 135 | − (level == AMDGPU_DPM_FORCED_LEVEL_LOW) ? "low" : "high"); | |
| 136 | − } | |
| 143 | + level = amdgpu_dpm_get_performance_level(adev); | |
| 144 | + return snprintf(buf, PAGE_SIZE, "%s\n", | |
| 145 | + (level == AMD_DPM_FORCED_LEVEL_AUTO) ? "auto" : | |
| 146 | + (level == AMD_DPM_FORCED_LEVEL_LOW) ? "low" : | |
| 147 | + (level == AMD_DPM_FORCED_LEVEL_HIGH) ? "high" : | |
| 148 | + (level == AMD_DPM_FORCED_LEVEL_MANUAL) ? "manual" : | |
| 149 | + (level == AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD) ? "profile_standard" : | |
| 150 | + (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) ? "profile_min_sclk" : | |
| 151 | + (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK) ? "profile_min_mclk" : | |
| 152 | + (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) ? "profile_peak" : | |
| 153 | + "unknown"); | |
| 137 | 154 | } |
| 138 | 155 | |
| 139 | 156 | static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev, |
| @@ -143,7 +160,8 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev, · 3 unmodified lines | ||
| 143 | 160 | { |
| 144 | 161 | struct drm_device *ddev = dev_get_drvdata(dev); |
| 145 | 162 | struct amdgpu_device *adev = ddev->dev_private; |
| 146 | − enum amdgpu_dpm_forced_level level; | |
| 163 | + enum amd_dpm_forced_level level; | |
| 164 | + enum amd_dpm_forced_level current_level; | |
| 147 | 165 | int ret = 0; |
| 148 | 166 | |
| 149 | 167 | /* Can't force performance level when the card is off */ |
| @@ -151,19 +169,34 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev, · 1 unmodified line | ||
| 151 | 169 | (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) |
| 152 | 170 | return -EINVAL; |
| 153 | 171 | |
| 172 | + current_level = amdgpu_dpm_get_performance_level(adev); | |
| 173 | + | |
| 154 | 174 | if (strncmp("low", buf, strlen("low")) == 0) { |
| 155 | − level = AMDGPU_DPM_FORCED_LEVEL_LOW; | |
| 175 | + level = AMD_DPM_FORCED_LEVEL_LOW; | |
| 156 | 176 | } else if (strncmp("high", buf, strlen("high")) == 0) { |
| 157 | − level = AMDGPU_DPM_FORCED_LEVEL_HIGH; | |
| 177 | + level = AMD_DPM_FORCED_LEVEL_HIGH; | |
| 158 | 178 | } else if (strncmp("auto", buf, strlen("auto")) == 0) { |
| 159 | − level = AMDGPU_DPM_FORCED_LEVEL_AUTO; | |
| 179 | + level = AMD_DPM_FORCED_LEVEL_AUTO; | |
| 160 | 180 | } else if (strncmp("manual", buf, strlen("manual")) == 0) { |
| 161 | − level = AMDGPU_DPM_FORCED_LEVEL_MANUAL; | |
| 162 | − } else { | |
| 181 | + level = AMD_DPM_FORCED_LEVEL_MANUAL; | |
| 182 | + } else if (strncmp("profile_exit", buf, strlen("profile_exit")) == 0) { | |
| 183 | + level = AMD_DPM_FORCED_LEVEL_PROFILE_EXIT; | |
| 184 | + } else if (strncmp("profile_standard", buf, strlen("profile_standard")) == 0) { | |
| 185 | + level = AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD; | |
| 186 | + } else if (strncmp("profile_min_sclk", buf, strlen("profile_min_sclk")) == 0) { | |
| 187 | + level = AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK; | |
| 188 | + } else if (strncmp("profile_min_mclk", buf, strlen("profile_min_mclk")) == 0) { | |
| 189 | + level = AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK; | |
| 190 | + } else if (strncmp("profile_peak", buf, strlen("profile_peak")) == 0) { | |
| 191 | + level = AMD_DPM_FORCED_LEVEL_PROFILE_PEAK; | |
| 192 | + } else { | |
| 163 | 193 | count = -EINVAL; |
| 164 | 194 | goto fail; |
| 165 | 195 | } |
| 166 | 196 | |
| 197 | + if (current_level == level) | |
| 198 | + return count; | |
| 199 | + | |
| 167 | 200 | if (adev->pp_enabled) |
| 168 | 201 | amdgpu_dpm_force_performance_level(adev, level); |
| 169 | 202 | else { |
| @@ -180,6 +213,7 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev, · 10 unmodified lines | ||
| 180 | 213 | adev->pm.dpm.forced_level = level; |
| 181 | 214 | mutex_unlock(&adev->pm.mutex); |
| 182 | 215 | } |
| 216 | + | |
| 183 | 217 | fail: |
| 184 | 218 | return count; |
| 185 | 219 | } |
| @@ -1060,9 +1094,9 @@ static void amdgpu_dpm_change_power_state_locked(struct amdgpu_device *adev) · 874 unmodified lines | ||
| 1060 | 1094 | |
| 1061 | 1095 | if (adev->pm.funcs->force_performance_level) { |
| 1062 | 1096 | if (adev->pm.dpm.thermal_active) { |
| 1063 | − enum amdgpu_dpm_forced_level level = adev->pm.dpm.forced_level; | |
| 1097 | + enum amd_dpm_forced_level level = adev->pm.dpm.forced_level; | |
| 1064 | 1098 | /* force low perf level for thermal */ |
| 1065 | − amdgpu_dpm_force_performance_level(adev, AMDGPU_DPM_FORCED_LEVEL_LOW); | |
| 1099 | + amdgpu_dpm_force_performance_level(adev, AMD_DPM_FORCED_LEVEL_LOW); | |
| 1066 | 1100 | /* save the user's level */ |
| 1067 | 1101 | adev->pm.dpm.forced_level = level; |
| 1068 | 1102 | } else { |
| @@ -1351,12 +1385,27 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *a · 282 unmodified lines | ||
| 1351 | 1385 | return 0; |
| 1352 | 1386 | } |
| 1353 | 1387 | |
| 1388 | +static void amdgpu_parse_cg_state(struct seq_file *m, u32 flags) | |
| 1389 | +{ | |
| 1390 | + int i; | |
| 1391 | + | |
| 1392 | + for (i = 0; clocks[i].flag; i++) | |
| 1393 | + seq_printf(m, "\t%s: %s\n", clocks[i].name, | |
| 1394 | + (flags & clocks[i].flag) ? "On" : "Off"); | |
| 1395 | +} | |
| 1396 | + | |
| 1354 | 1397 | static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data) |
| 1355 | 1398 | { |
| 1356 | 1399 | struct drm_info_node *node = (struct drm_info_node *) m->private; |
| 1357 | 1400 | struct drm_device *dev = node->minor->dev; |
| 1358 | 1401 | struct amdgpu_device *adev = dev->dev_private; |
| 1359 | 1402 | struct drm_device *ddev = adev->ddev; |
| 1403 | + u32 flags = 0; | |
| 1404 | + | |
| 1405 | + amdgpu_get_clockgating_state(adev, &flags); | |
| 1406 | + seq_printf(m, "Clock Gating Flags Mask: 0x%x\n", flags); | |
| 1407 | + amdgpu_parse_cg_state(m, flags); | |
| 1408 | + seq_printf(m, "\n"); | |
| 1360 | 1409 | |
| 1361 | 1410 | if (!adev->pm.dpm_enabled) { |
| 1362 | 1411 | seq_printf(m, "dpm not enabled\n"); |
| @@ -24,6 +24,12 @@ · 23 unmodified lines | ||
| 24 | 24 | #ifndef __AMDGPU_PM_H__ |
| 25 | 25 | #define __AMDGPU_PM_H__ |
| 26 | 26 | |
| 27 | +struct cg_flag_name | |
| 28 | +{ | |
| 29 | + u32 flag; | |
| 30 | + const char *name; | |
| 31 | +}; | |
| 32 | + | |
| 27 | 33 | int amdgpu_pm_sysfs_init(struct amdgpu_device *adev); |
| 28 | 34 | void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev); |
| 29 | 35 | void amdgpu_pm_print_power_states(struct amdgpu_device *adev); |
| @@ -34,67 +34,34 @@ · 33 unmodified lines | ||
| 34 | 34 | #include "cik_dpm.h" |
| 35 | 35 | #include "vi_dpm.h" |
| 36 | 36 | |
| 37 | −static int amdgpu_powerplay_init(struct amdgpu_device *adev) | |
| 37 | +static int amdgpu_create_pp_handle(struct amdgpu_device *adev) | |
| 38 | 38 | { |
| 39 | − int ret = 0; | |
| 39 | + struct amd_pp_init pp_init; | |
| 40 | 40 | struct amd_powerplay *amd_pp; |
| 41 | + int ret; | |
| 41 | 42 | |
| 42 | 43 | amd_pp = &(adev->powerplay); |
| 43 | − | |
| 44 | − if (adev->pp_enabled) { | |
| 45 | − struct amd_pp_init *pp_init; | |
| 46 | − | |
| 47 | − pp_init = kzalloc(sizeof(struct amd_pp_init), GFP_KERNEL); | |
| 48 | − | |
| 49 | − if (pp_init == NULL) | |
| 50 | − return -ENOMEM; | |
| 51 | − | |
| 52 | − pp_init->chip_family = adev->family; | |
| 53 | − pp_init->chip_id = adev->asic_type; | |
| 54 | − pp_init->device = amdgpu_cgs_create_device(adev); | |
| 55 | − ret = amd_powerplay_init(pp_init, amd_pp); | |
| 56 | − kfree(pp_init); | |
| 57 | − } else { | |
| 58 | − amd_pp->pp_handle = (void *)adev; | |
| 59 | − | |
| 60 | − switch (adev->asic_type) { | |
| 61 | −#ifdef CONFIG_DRM_AMDGPU_SI | |
| 62 | − case CHIP_TAHITI: | |
| 63 | − case CHIP_PITCAIRN: | |
| 64 | − case CHIP_VERDE: | |
| 65 | − case CHIP_OLAND: | |
| 66 | − case CHIP_HAINAN: | |
| 67 | − amd_pp->ip_funcs = &si_dpm_ip_funcs; | |
| 68 | − break; | |
| 69 | −#endif | |
| 70 | −#ifdef CONFIG_DRM_AMDGPU_CIK | |
| 71 | − case CHIP_BONAIRE: | |
| 72 | − case CHIP_HAWAII: | |
| 73 | − amd_pp->ip_funcs = &ci_dpm_ip_funcs; | |
| 74 | − break; | |
| 75 | − case CHIP_KABINI: | |
| 76 | − case CHIP_MULLINS: | |
| 77 | − case CHIP_KAVERI: | |
| 78 | − amd_pp->ip_funcs = &kv_dpm_ip_funcs; | |
| 79 | − break; | |
| 80 | −#endif | |
| 81 | − case CHIP_CARRIZO: | |
| 82 | − case CHIP_STONEY: | |
| 83 | − amd_pp->ip_funcs = &cz_dpm_ip_funcs; | |
| 84 | − break; | |
| 85 | − default: | |
| 86 | − ret = -EINVAL; | |
| 87 | − break; | |
| 88 | − } | |
| 89 | − } | |
| 90 | − return ret; | |
| 44 | + pp_init.chip_family = adev->family; | |
| 45 | + pp_init.chip_id = adev->asic_type; | |
| 46 | + pp_init.pm_en = amdgpu_dpm != 0 ? true : false; | |
| 47 | + pp_init.feature_mask = amdgpu_pp_feature_mask; | |
| 48 | + pp_init.device = amdgpu_cgs_create_device(adev); | |
| 49 | + ret = amd_powerplay_create(&pp_init, &(amd_pp->pp_handle)); | |
| 50 | + if (ret) | |
| 51 | + return -EINVAL; | |
| 52 | + return 0; | |
| 91 | 53 | } |
| 92 | 54 | |
| 93 | 55 | static int amdgpu_pp_early_init(void *handle) |
| 94 | 56 | { |
| 95 | 57 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 58 | + struct amd_powerplay *amd_pp; | |
| 96 | 59 | int ret = 0; |
| 97 | 60 | |
| 61 | + amd_pp = &(adev->powerplay); | |
| 62 | + adev->pp_enabled = false; | |
| 63 | + amd_pp->pp_handle = (void *)adev; | |
| 64 | + | |
| 98 | 65 | switch (adev->asic_type) { |
| 99 | 66 | case CHIP_POLARIS11: |
| 100 | 67 | case CHIP_POLARIS10: |
| @@ -102,30 +69,48 @@ static int amdgpu_pp_early_init(void *handle) · 1 unmodified line | ||
| 102 | 69 | case CHIP_TONGA: |
| 103 | 70 | case CHIP_FIJI: |
| 104 | 71 | case CHIP_TOPAZ: |
| 105 | − adev->pp_enabled = true; | |
| 106 | − break; | |
| 107 | 72 | case CHIP_CARRIZO: |
| 108 | 73 | case CHIP_STONEY: |
| 109 | − adev->pp_enabled = (amdgpu_powerplay == 0) ? false : true; | |
| 74 | + adev->pp_enabled = true; | |
| 75 | + if (amdgpu_create_pp_handle(adev)) | |
| 76 | + return -EINVAL; | |
| 77 | + amd_pp->ip_funcs = &pp_ip_funcs; | |
| 78 | + amd_pp->pp_funcs = &pp_dpm_funcs; | |
| 110 | 79 | break; |
| 111 | 80 | /* These chips don't have powerplay implemenations */ |
| 81 | +#ifdef CONFIG_DRM_AMDGPU_SI | |
| 82 | + case CHIP_TAHITI: | |
| 83 | + case CHIP_PITCAIRN: | |
| 84 | + case CHIP_VERDE: | |
| 85 | + case CHIP_OLAND: | |
| 86 | + case CHIP_HAINAN: | |
| 87 | + amd_pp->ip_funcs = &si_dpm_ip_funcs; | |
| 88 | + break; | |
| 89 | +#endif | |
| 90 | +#ifdef CONFIG_DRM_AMDGPU_CIK | |
| 112 | 91 | case CHIP_BONAIRE: |
| 113 | 92 | case CHIP_HAWAII: |
| 93 | + amd_pp->ip_funcs = &ci_dpm_ip_funcs; | |
| 94 | + break; | |
| 114 | 95 | case CHIP_KABINI: |
| 115 | 96 | case CHIP_MULLINS: |
| 116 | 97 | case CHIP_KAVERI: |
| 98 | + amd_pp->ip_funcs = &kv_dpm_ip_funcs; | |
| 99 | + break; | |
| 100 | +#endif | |
| 117 | 101 | default: |
| 118 | − adev->pp_enabled = false; | |
| 102 | + ret = -EINVAL; | |
| 119 | 103 | break; |
| 120 | 104 | } |
| 121 | 105 | |
| 122 | − ret = amdgpu_powerplay_init(adev); | |
| 123 | − if (ret) | |
| 124 | − return ret; | |
| 125 | − | |
| 126 | 106 | if (adev->powerplay.ip_funcs->early_init) |
| 127 | 107 | ret = adev->powerplay.ip_funcs->early_init( |
| 128 | 108 | adev->powerplay.pp_handle); |
| 109 | + | |
| 110 | + if (ret == PP_DPM_DISABLED) { | |
| 111 | + adev->pm.dpm_enabled = false; | |
| 112 | + return 0; | |
| 113 | + } | |
| 129 | 114 | return ret; |
| 130 | 115 | } |
| 131 | 116 | |
| @@ -185,6 +170,11 @@ static int amdgpu_pp_hw_init(void *handle) · 53 unmodified lines | ||
| 185 | 170 | ret = adev->powerplay.ip_funcs->hw_init( |
| 186 | 171 | adev->powerplay.pp_handle); |
| 187 | 172 | |
| 173 | + if (ret == PP_DPM_DISABLED) { | |
| 174 | + adev->pm.dpm_enabled = false; | |
| 175 | + return 0; | |
| 176 | + } | |
| 177 | + | |
| 188 | 178 | if ((amdgpu_dpm != 0) && !amdgpu_sriov_vf(adev)) |
| 189 | 179 | adev->pm.dpm_enabled = true; |
| 190 | 180 | |
| @@ -210,14 +200,14 @@ static void amdgpu_pp_late_fini(void *handle) · 19 unmodified lines | ||
| 210 | 200 | { |
| 211 | 201 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 212 | 202 | |
| 213 | − if (adev->pp_enabled) { | |
| 214 | − amdgpu_pm_sysfs_fini(adev); | |
| 215 | − amd_powerplay_fini(adev->powerplay.pp_handle); | |
| 216 | − } | |
| 217 | − | |
| 218 | 203 | if (adev->powerplay.ip_funcs->late_fini) |
| 219 | 204 | adev->powerplay.ip_funcs->late_fini( |
| 220 | 205 | adev->powerplay.pp_handle); |
| 206 | + | |
| 207 | + if (adev->pp_enabled && adev->pm.dpm_enabled) | |
| 208 | + amdgpu_pm_sysfs_fini(adev); | |
| 209 | + | |
| 210 | + amd_powerplay_destroy(adev->powerplay.pp_handle); | |
| 221 | 211 | } |
| 222 | 212 | |
| 223 | 213 | static int amdgpu_pp_suspend(void *handle) |
| @@ -207,6 +207,8 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, · 206 unmodified lines | ||
| 207 | 207 | } |
| 208 | 208 | ring->cond_exe_gpu_addr = adev->wb.gpu_addr + (ring->cond_exe_offs * 4); |
| 209 | 209 | ring->cond_exe_cpu_addr = &adev->wb.wb[ring->cond_exe_offs]; |
| 210 | + /* always set cond_exec_polling to CONTINUE */ | |
| 211 | + *ring->cond_exe_cpu_addr = 1; | |
| 210 | 212 | |
| 211 | 213 | r = amdgpu_fence_driver_start_ring(ring, irq_src, irq_type); |
| 212 | 214 | if (r) { |
| @@ -307,7 +309,7 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf, · 94 unmodified lines | ||
| 307 | 309 | while (size) { |
| 308 | 310 | if (*pos >= (ring->ring_size + 12)) |
| 309 | 311 | return result; |
| 310 | − | |
| 312 | + | |
| 311 | 313 | value = ring->ring[(*pos - 12)/4]; |
| 312 | 314 | r = put_user(value, (uint32_t*)buf); |
| 313 | 315 | if (r) |
| @@ -135,6 +135,8 @@ struct amdgpu_ring_funcs { · 134 unmodified lines | ||
| 135 | 135 | void (*end_use)(struct amdgpu_ring *ring); |
| 136 | 136 | void (*emit_switch_buffer) (struct amdgpu_ring *ring); |
| 137 | 137 | void (*emit_cntxcntl) (struct amdgpu_ring *ring, uint32_t flags); |
| 138 | + void (*emit_rreg)(struct amdgpu_ring *ring, uint32_t reg); | |
| 139 | + void (*emit_wreg)(struct amdgpu_ring *ring, uint32_t reg, uint32_t val); | |
| 138 | 140 | }; |
| 139 | 141 | |
| 140 | 142 | struct amdgpu_ring { |
| @@ -24,7 +24,7 @@ TRACE_EVENT(amdgpu_mm_rreg, · 23 unmodified lines | ||
| 24 | 24 | __entry->reg = reg; |
| 25 | 25 | __entry->value = value; |
| 26 | 26 | ), |
| 27 | − TP_printk("0x%04lx, 0x%04lx, 0x%08lx", | |
| 27 | + TP_printk("0x%04lx, 0x%08lx, 0x%08lx", | |
| 28 | 28 | (unsigned long)__entry->did, |
| 29 | 29 | (unsigned long)__entry->reg, |
| 30 | 30 | (unsigned long)__entry->value) |
| @@ -43,7 +43,7 @@ TRACE_EVENT(amdgpu_mm_wreg, · 12 unmodified lines | ||
| 43 | 43 | __entry->reg = reg; |
| 44 | 44 | __entry->value = value; |
| 45 | 45 | ), |
| 46 | − TP_printk("0x%04lx, 0x%04lx, 0x%08lx", | |
| 46 | + TP_printk("0x%04lx, 0x%08lx, 0x%08lx", | |
| 47 | 47 | (unsigned long)__entry->did, |
| 48 | 48 | (unsigned long)__entry->reg, |
| 49 | 49 | (unsigned long)__entry->value) |
| @@ -466,10 +466,6 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, · 465 unmodified lines | ||
| 466 | 466 | |
| 467 | 467 | adev = amdgpu_ttm_adev(bo->bdev); |
| 468 | 468 | |
| 469 | − /* remember the eviction */ | |
| 470 | − if (evict) | |
| 471 | − atomic64_inc(&adev->num_evictions); | |
| 472 | − | |
| 473 | 469 | if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) { |
| 474 | 470 | amdgpu_move_null(bo, new_mem); |
| 475 | 471 | return 0; |
| @@ -552,6 +548,8 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_ · 76 unmodified lines | ||
| 552 | 548 | mem->bus.addr = |
| 553 | 549 | ioremap_nocache(mem->bus.base + mem->bus.offset, |
| 554 | 550 | mem->bus.size); |
| 551 | + if (!mem->bus.addr) | |
| 552 | + return -ENOMEM; | |
| 555 | 553 | |
| 556 | 554 | /* |
| 557 | 555 | * Alpha: Use just the bus offset plus |
| @@ -1052,56 +1050,6 @@ uint32_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, · 494 unmodified lines | ||
| 1052 | 1050 | return flags; |
| 1053 | 1051 | } |
| 1054 | 1052 | |
| 1055 | −static void amdgpu_ttm_lru_removal(struct ttm_buffer_object *tbo) | |
| 1056 | −{ | |
| 1057 | − struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); | |
| 1058 | − unsigned i, j; | |
| 1059 | − | |
| 1060 | − for (i = 0; i < AMDGPU_TTM_LRU_SIZE; ++i) { | |
| 1061 | − struct amdgpu_mman_lru *lru = &adev->mman.log2_size[i]; | |
| 1062 | − | |
| 1063 | − for (j = 0; j < TTM_NUM_MEM_TYPES; ++j) | |
| 1064 | − if (&tbo->lru == lru->lru[j]) | |
| 1065 | − lru->lru[j] = tbo->lru.prev; | |
| 1066 | − | |
| 1067 | − if (&tbo->swap == lru->swap_lru) | |
| 1068 | − lru->swap_lru = tbo->swap.prev; | |
| 1069 | − } | |
| 1070 | −} | |
| 1071 | − | |
| 1072 | −static struct amdgpu_mman_lru *amdgpu_ttm_lru(struct ttm_buffer_object *tbo) | |
| 1073 | −{ | |
| 1074 | − struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); | |
| 1075 | − unsigned log2_size = min(ilog2(tbo->num_pages), | |
| 1076 | − AMDGPU_TTM_LRU_SIZE - 1); | |
| 1077 | − | |
| 1078 | − return &adev->mman.log2_size[log2_size]; | |
| 1079 | −} | |
| 1080 | − | |
| 1081 | −static struct list_head *amdgpu_ttm_lru_tail(struct ttm_buffer_object *tbo) | |
| 1082 | −{ | |
| 1083 | − struct amdgpu_mman_lru *lru = amdgpu_ttm_lru(tbo); | |
| 1084 | − struct list_head *res = lru->lru[tbo->mem.mem_type]; | |
| 1085 | − | |
| 1086 | − lru->lru[tbo->mem.mem_type] = &tbo->lru; | |
| 1087 | − while ((++lru)->lru[tbo->mem.mem_type] == res) | |
| 1088 | − lru->lru[tbo->mem.mem_type] = &tbo->lru; | |
| 1089 | − | |
| 1090 | − return res; | |
| 1091 | −} | |
| 1092 | − | |
| 1093 | −static struct list_head *amdgpu_ttm_swap_lru_tail(struct ttm_buffer_object *tbo) | |
| 1094 | −{ | |
| 1095 | − struct amdgpu_mman_lru *lru = amdgpu_ttm_lru(tbo); | |
| 1096 | − struct list_head *res = lru->swap_lru; | |
| 1097 | − | |
| 1098 | − lru->swap_lru = &tbo->swap; | |
| 1099 | − while ((++lru)->swap_lru == res) | |
| 1100 | − lru->swap_lru = &tbo->swap; | |
| 1101 | − | |
| 1102 | − return res; | |
| 1103 | −} | |
| 1104 | − | |
| 1105 | 1053 | static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, |
| 1106 | 1054 | const struct ttm_place *place) |
| 1107 | 1055 | { |
| @@ -1140,14 +1088,10 @@ static struct ttm_bo_driver amdgpu_bo_driver = { · 32 unmodified lines | ||
| 1140 | 1088 | .fault_reserve_notify = &amdgpu_bo_fault_reserve_notify, |
| 1141 | 1089 | .io_mem_reserve = &amdgpu_ttm_io_mem_reserve, |
| 1142 | 1090 | .io_mem_free = &amdgpu_ttm_io_mem_free, |
| 1143 | − .lru_removal = &amdgpu_ttm_lru_removal, | |
| 1144 | − .lru_tail = &amdgpu_ttm_lru_tail, | |
| 1145 | − .swap_lru_tail = &amdgpu_ttm_swap_lru_tail, | |
| 1146 | 1091 | }; |
| 1147 | 1092 | |
| 1148 | 1093 | int amdgpu_ttm_init(struct amdgpu_device *adev) |
| 1149 | 1094 | { |
| 1150 | − unsigned i, j; | |
| 1151 | 1095 | int r; |
| 1152 | 1096 | |
| 1153 | 1097 | r = amdgpu_ttm_global_init(adev); |
| @@ -1165,19 +1109,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) · 11 unmodified lines | ||
| 1165 | 1109 | DRM_ERROR("failed initializing buffer object driver(%d).\n", r); |
| 1166 | 1110 | return r; |
| 1167 | 1111 | } |
| 1168 | − | |
| 1169 | − for (i = 0; i < AMDGPU_TTM_LRU_SIZE; ++i) { | |
| 1170 | − struct amdgpu_mman_lru *lru = &adev->mman.log2_size[i]; | |
| 1171 | − | |
| 1172 | − for (j = 0; j < TTM_NUM_MEM_TYPES; ++j) | |
| 1173 | − lru->lru[j] = &adev->mman.bdev.man[j].lru; | |
| 1174 | − lru->swap_lru = &adev->mman.bdev.glob->swap_lru; | |
| 1175 | − } | |
| 1176 | − | |
| 1177 | − for (j = 0; j < TTM_NUM_MEM_TYPES; ++j) | |
| 1178 | − adev->mman.guard.lru[j] = NULL; | |
| 1179 | − adev->mman.guard.swap_lru = NULL; | |
| 1180 | − | |
| 1181 | 1112 | adev->mman.initialized = true; |
| 1182 | 1113 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM, |
| 1183 | 1114 | adev->mc.real_vram_size >> PAGE_SHIFT); |
| @@ -1365,7 +1296,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, · 181 unmodified lines | ||
| 1365 | 1296 | WARN_ON(job->ibs[0].length_dw > num_dw); |
| 1366 | 1297 | if (direct_submit) { |
| 1367 | 1298 | r = amdgpu_ib_schedule(ring, job->num_ibs, job->ibs, |
| 1368 | − NULL, NULL, fence); | |
| 1299 | + NULL, fence); | |
| 1369 | 1300 | job->fence = dma_fence_get(*fence); |
| 1370 | 1301 | if (r) |
| 1371 | 1302 | DRM_ERROR("Error scheduling IBs (%d)\n", r); |
| @@ -34,13 +34,6 @@ · 33 unmodified lines | ||
| 34 | 34 | #define AMDGPU_PL_FLAG_GWS (TTM_PL_FLAG_PRIV << 1) |
| 35 | 35 | #define AMDGPU_PL_FLAG_OA (TTM_PL_FLAG_PRIV << 2) |
| 36 | 36 | |
| 37 | −#define AMDGPU_TTM_LRU_SIZE 20 | |
| 38 | − | |
| 39 | −struct amdgpu_mman_lru { | |
| 40 | − struct list_head *lru[TTM_NUM_MEM_TYPES]; | |
| 41 | − struct list_head *swap_lru; | |
| 42 | −}; | |
| 43 | − | |
| 44 | 37 | struct amdgpu_mman { |
| 45 | 38 | struct ttm_bo_global_ref bo_global_ref; |
| 46 | 39 | struct drm_global_reference mem_global_ref; |
| @@ -58,11 +51,6 @@ struct amdgpu_mman { · 11 unmodified lines | ||
| 58 | 51 | struct amdgpu_ring *buffer_funcs_ring; |
| 59 | 52 | /* Scheduler entity for buffer moves */ |
| 60 | 53 | struct amd_sched_entity entity; |
| 61 | − | |
| 62 | − /* custom LRU management */ | |
| 63 | − struct amdgpu_mman_lru log2_size[AMDGPU_TTM_LRU_SIZE]; | |
| 64 | − /* guard for log2_size array, don't add anything in between */ | |
| 65 | − struct amdgpu_mman_lru guard; | |
| 66 | 54 | }; |
| 67 | 55 | |
| 68 | 56 | extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; |
| @@ -976,7 +976,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring, struct amdgpu_bo *bo, · 975 unmodified lines | ||
| 976 | 976 | ib->length_dw = 16; |
| 977 | 977 | |
| 978 | 978 | if (direct) { |
| 979 | − r = amdgpu_ib_schedule(ring, 1, ib, NULL, NULL, &f); | |
| 979 | + r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f); | |
| 980 | 980 | job->fence = dma_fence_get(f); |
| 981 | 981 | if (r) |
| 982 | 982 | goto err_free; |
| @@ -1178,3 +1178,28 @@ int amdgpu_uvd_ring_test_ib(struct amdgpu_ring *ring, long timeout) · 195 unmodified lines | ||
| 1178 | 1178 | error: |
| 1179 | 1179 | return r; |
| 1180 | 1180 | } |
| 1181 | + | |
| 1182 | +/** | |
| 1183 | + * amdgpu_uvd_used_handles - returns used UVD handles | |
| 1184 | + * | |
| 1185 | + * @adev: amdgpu_device pointer | |
| 1186 | + * | |
| 1187 | + * Returns the number of UVD handles in use | |
| 1188 | + */ | |
| 1189 | +uint32_t amdgpu_uvd_used_handles(struct amdgpu_device *adev) | |
| 1190 | +{ | |
| 1191 | + unsigned i; | |
| 1192 | + uint32_t used_handles = 0; | |
| 1193 | + | |
| 1194 | + for (i = 0; i < adev->uvd.max_handles; ++i) { | |
| 1195 | + /* | |
| 1196 | + * Handles can be freed in any order, and not | |
| 1197 | + * necessarily linear. So we need to count | |
| 1198 | + * all non-zero handles. | |
| 1199 | + */ | |
| 1200 | + if (atomic_read(&adev->uvd.handles[i])) | |
| 1201 | + used_handles++; | |
| 1202 | + } | |
| 1203 | + | |
| 1204 | + return used_handles; | |
| 1205 | +} | |
| @@ -38,5 +38,6 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx); · 37 unmodified lines | ||
| 38 | 38 | void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring); |
| 39 | 39 | void amdgpu_uvd_ring_end_use(struct amdgpu_ring *ring); |
| 40 | 40 | int amdgpu_uvd_ring_test_ib(struct amdgpu_ring *ring, long timeout); |
| 41 | +uint32_t amdgpu_uvd_used_handles(struct amdgpu_device *adev); | |
| 41 | 42 | |
| 42 | 43 | #endif |
| @@ -455,7 +455,7 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, · 454 unmodified lines | ||
| 455 | 455 | for (i = ib->length_dw; i < ib_size_dw; ++i) |
| 456 | 456 | ib->ptr[i] = 0x0; |
| 457 | 457 | |
| 458 | − r = amdgpu_ib_schedule(ring, 1, ib, NULL, NULL, &f); | |
| 458 | + r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f); | |
| 459 | 459 | job->fence = dma_fence_get(f); |
| 460 | 460 | if (r) |
| 461 | 461 | goto err; |
| @@ -518,7 +518,7 @@ int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, · 56 unmodified lines | ||
| 518 | 518 | ib->ptr[i] = 0x0; |
| 519 | 519 | |
| 520 | 520 | if (direct) { |
| 521 | − r = amdgpu_ib_schedule(ring, 1, ib, NULL, NULL, &f); | |
| 521 | + r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f); | |
| 522 | 522 | job->fence = dma_fence_get(f); |
| 523 | 523 | if (r) |
| 524 | 524 | goto err; |
| @@ -0,0 +1,222 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright 2016 Advanced Micro Devices, Inc. | |
| 3 | + * | |
| 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: | |
| 10 | + * | |
| 11 | + * The above copyright notice and this permission notice shall be included in | |
| 12 | + * all copies or substantial portions of the Software. | |
| 13 | + * | |
| 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. | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + | |
| 24 | +#include "amdgpu.h" | |
| 25 | + | |
| 26 | +int amdgpu_allocate_static_csa(struct amdgpu_device *adev) | |
| 27 | +{ | |
| 28 | + int r; | |
| 29 | + void *ptr; | |
| 30 | + | |
| 31 | + r = amdgpu_bo_create_kernel(adev, AMDGPU_CSA_SIZE, PAGE_SIZE, | |
| 32 | + AMDGPU_GEM_DOMAIN_VRAM, &adev->virt.csa_obj, | |
| 33 | + &adev->virt.csa_vmid0_addr, &ptr); | |
| 34 | + if (r) | |
| 35 | + return r; | |
| 36 | + | |
| 37 | + memset(ptr, 0, AMDGPU_CSA_SIZE); | |
| 38 | + return 0; | |
| 39 | +} | |
| 40 | + | |
| 41 | +/* | |
| 42 | + * amdgpu_map_static_csa should be called during amdgpu_vm_init | |
| 43 | + * it maps virtual address "AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE" | |
| 44 | + * to this VM, and each command submission of GFX should use this virtual | |
| 45 | + * address within META_DATA init package to support SRIOV gfx preemption. | |
| 46 | + */ | |
| 47 | + | |
| 48 | +int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm) | |
| 49 | +{ | |
| 50 | + int r; | |
| 51 | + struct amdgpu_bo_va *bo_va; | |
| 52 | + struct ww_acquire_ctx ticket; | |
| 53 | + struct list_head list; | |
| 54 | + struct amdgpu_bo_list_entry pd; | |
| 55 | + struct ttm_validate_buffer csa_tv; | |
| 56 | + | |
| 57 | + INIT_LIST_HEAD(&list); | |
| 58 | + INIT_LIST_HEAD(&csa_tv.head); | |
| 59 | + csa_tv.bo = &adev->virt.csa_obj->tbo; | |
| 60 | + csa_tv.shared = true; | |
| 61 | + | |
| 62 | + list_add(&csa_tv.head, &list); | |
| 63 | + amdgpu_vm_get_pd_bo(vm, &list, &pd); | |
| 64 | + | |
| 65 | + r = ttm_eu_reserve_buffers(&ticket, &list, true, NULL); | |
| 66 | + if (r) { | |
| 67 | + DRM_ERROR("failed to reserve CSA,PD BOs: err=%d\n", r); | |
| 68 | + return r; | |
| 69 | + } | |
| 70 | + | |
| 71 | + bo_va = amdgpu_vm_bo_add(adev, vm, adev->virt.csa_obj); | |
| 72 | + if (!bo_va) { | |
| 73 | + ttm_eu_backoff_reservation(&ticket, &list); | |
| 74 | + DRM_ERROR("failed to create bo_va for static CSA\n"); | |
| 75 | + return -ENOMEM; | |
| 76 | + } | |
| 77 | + | |
| 78 | + r = amdgpu_vm_bo_map(adev, bo_va, AMDGPU_CSA_VADDR, 0,AMDGPU_CSA_SIZE, | |
| 79 | + AMDGPU_PTE_READABLE | AMDGPU_PTE_WRITEABLE | | |
| 80 | + AMDGPU_PTE_EXECUTABLE); | |
| 81 | + | |
| 82 | + if (r) { | |
| 83 | + DRM_ERROR("failed to do bo_map on static CSA, err=%d\n", r); | |
| 84 | + amdgpu_vm_bo_rmv(adev, bo_va); | |
| 85 | + ttm_eu_backoff_reservation(&ticket, &list); | |
| 86 | + kfree(bo_va); | |
| 87 | + return r; | |
| 88 | + } | |
| 89 | + | |
| 90 | + vm->csa_bo_va = bo_va; | |
| 91 | + ttm_eu_backoff_reservation(&ticket, &list); | |
| 92 | + return 0; | |
| 93 | +} | |
| 94 | + | |
| 95 | +void amdgpu_virt_init_setting(struct amdgpu_device *adev) | |
| 96 | +{ | |
| 97 | + /* enable virtual display */ | |
| 98 | + adev->mode_info.num_crtc = 1; | |
| 99 | + adev->enable_virtual_display = true; | |
| 100 | + | |
| 101 | + mutex_init(&adev->virt.lock); | |
| 102 | +} | |
| 103 | + | |
| 104 | +uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg) | |
| 105 | +{ | |
| 106 | + signed long r; | |
| 107 | + uint32_t val; | |
| 108 | + struct dma_fence *f; | |
| 109 | + struct amdgpu_kiq *kiq = &adev->gfx.kiq; | |
| 110 | + struct amdgpu_ring *ring = &kiq->ring; | |
| 111 | + | |
| 112 | + BUG_ON(!ring->funcs->emit_rreg); | |
| 113 | + | |
| 114 | + mutex_lock(&adev->virt.lock); | |
| 115 | + amdgpu_ring_alloc(ring, 32); | |
| 116 | + amdgpu_ring_emit_hdp_flush(ring); | |
| 117 | + amdgpu_ring_emit_rreg(ring, reg); | |
| 118 | + amdgpu_ring_emit_hdp_invalidate(ring); | |
| 119 | + amdgpu_fence_emit(ring, &f); | |
| 120 | + amdgpu_ring_commit(ring); | |
| 121 | + mutex_unlock(&adev->virt.lock); | |
| 122 | + | |
| 123 | + r = dma_fence_wait(f, false); | |
| 124 | + if (r) | |
| 125 | + DRM_ERROR("wait for kiq fence error: %ld.\n", r); | |
| 126 | + dma_fence_put(f); | |
| 127 | + | |
| 128 | + val = adev->wb.wb[adev->virt.reg_val_offs]; | |
| 129 | + | |
| 130 | + return val; | |
| 131 | +} | |
| 132 | + | |
| 133 | +void amdgpu_virt_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v) | |
| 134 | +{ | |
| 135 | + signed long r; | |
| 136 | + struct dma_fence *f; | |
| 137 | + struct amdgpu_kiq *kiq = &adev->gfx.kiq; | |
| 138 | + struct amdgpu_ring *ring = &kiq->ring; | |
| 139 | + | |
| 140 | + BUG_ON(!ring->funcs->emit_wreg); | |
| 141 | + | |
| 142 | + mutex_lock(&adev->virt.lock); | |
| 143 | + amdgpu_ring_alloc(ring, 32); | |
| 144 | + amdgpu_ring_emit_hdp_flush(ring); | |
| 145 | + amdgpu_ring_emit_wreg(ring, reg, v); | |
| 146 | + amdgpu_ring_emit_hdp_invalidate(ring); | |
| 147 | + amdgpu_fence_emit(ring, &f); | |
| 148 | + amdgpu_ring_commit(ring); | |
| 149 | + mutex_unlock(&adev->virt.lock); | |
| 150 | + | |
| 151 | + r = dma_fence_wait(f, false); | |
| 152 | + if (r) | |
| 153 | + DRM_ERROR("wait for kiq fence error: %ld.\n", r); | |
| 154 | + dma_fence_put(f); | |
| 155 | +} | |
| 156 | + | |
| 157 | +/** | |
| 158 | + * amdgpu_virt_request_full_gpu() - request full gpu access | |
| 159 | + * @amdgpu: amdgpu device. | |
| 160 | + * @init: is driver init time. | |
| 161 | + * When start to init/fini driver, first need to request full gpu access. | |
| 162 | + * Return: Zero if request success, otherwise will return error. | |
| 163 | + */ | |
| 164 | +int amdgpu_virt_request_full_gpu(struct amdgpu_device *adev, bool init) | |
| 165 | +{ | |
| 166 | + struct amdgpu_virt *virt = &adev->virt; | |
| 167 | + int r; | |
| 168 | + | |
| 169 | + if (virt->ops && virt->ops->req_full_gpu) { | |
| 170 | + r = virt->ops->req_full_gpu(adev, init); | |
| 171 | + if (r) | |
| 172 | + return r; | |
| 173 | + | |
| 174 | + adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME; | |
| 175 | + } | |
| 176 | + | |
| 177 | + return 0; | |
| 178 | +} | |
| 179 | + | |
| 180 | +/** | |
| 181 | + * amdgpu_virt_release_full_gpu() - release full gpu access | |
| 182 | + * @amdgpu: amdgpu device. | |
| 183 | + * @init: is driver init time. | |
| 184 | + * When finishing driver init/fini, need to release full gpu access. | |
| 185 | + * Return: Zero if release success, otherwise will returen error. | |
| 186 | + */ | |
| 187 | +int amdgpu_virt_release_full_gpu(struct amdgpu_device *adev, bool init) | |
| 188 | +{ | |
| 189 | + struct amdgpu_virt *virt = &adev->virt; | |
| 190 | + int r; | |
| 191 | + | |
| 192 | + if (virt->ops && virt->ops->rel_full_gpu) { | |
| 193 | + r = virt->ops->rel_full_gpu(adev, init); | |
| 194 | + if (r) | |
| 195 | + return r; | |
| 196 | + | |
| 197 | + adev->virt.caps |= AMDGPU_SRIOV_CAPS_RUNTIME; | |
| 198 | + } | |
| 199 | + return 0; | |
| 200 | +} | |
| 201 | + | |
| 202 | +/** | |
| 203 | + * amdgpu_virt_reset_gpu() - reset gpu | |
| 204 | + * @amdgpu: amdgpu device. | |
| 205 | + * Send reset command to GPU hypervisor to reset GPU that VM is using | |
| 206 | + * Return: Zero if reset success, otherwise will return error. | |
| 207 | + */ | |
| 208 | +int amdgpu_virt_reset_gpu(struct amdgpu_device *adev) | |
| 209 | +{ | |
| 210 | + struct amdgpu_virt *virt = &adev->virt; | |
| 211 | + int r; | |
| 212 | + | |
| 213 | + if (virt->ops && virt->ops->reset_gpu) { | |
| 214 | + r = virt->ops->reset_gpu(adev); | |
| 215 | + if (r) | |
| 216 | + return r; | |
| 217 | + | |
| 218 | + adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME; | |
| 219 | + } | |
| 220 | + | |
| 221 | + return 0; | |
| 222 | +} | |
| @@ -28,22 +28,48 @@ · 27 unmodified lines | ||
| 28 | 28 | #define AMDGPU_SRIOV_CAPS_ENABLE_IOV (1 << 1) /* sr-iov is enabled on this GPU */ |
| 29 | 29 | #define AMDGPU_SRIOV_CAPS_IS_VF (1 << 2) /* this GPU is a virtual function */ |
| 30 | 30 | #define AMDGPU_PASSTHROUGH_MODE (1 << 3) /* thw whole GPU is pass through for VM */ |
| 31 | +#define AMDGPU_SRIOV_CAPS_RUNTIME (1 << 4) /* is out of full access mode */ | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * struct amdgpu_virt_ops - amdgpu device virt operations | |
| 35 | + */ | |
| 36 | +struct amdgpu_virt_ops { | |
| 37 | + int (*req_full_gpu)(struct amdgpu_device *adev, bool init); | |
| 38 | + int (*rel_full_gpu)(struct amdgpu_device *adev, bool init); | |
| 39 | + int (*reset_gpu)(struct amdgpu_device *adev); | |
| 40 | +}; | |
| 41 | + | |
| 31 | 42 | /* GPU virtualization */ |
| 32 | −struct amdgpu_virtualization { | |
| 33 | − uint32_t virtual_caps; | |
| 43 | +struct amdgpu_virt { | |
| 44 | + uint32_t caps; | |
| 45 | + struct amdgpu_bo *csa_obj; | |
| 46 | + uint64_t csa_vmid0_addr; | |
| 47 | + bool chained_ib_support; | |
| 48 | + uint32_t reg_val_offs; | |
| 49 | + struct mutex lock; | |
| 50 | + struct amdgpu_irq_src ack_irq; | |
| 51 | + struct amdgpu_irq_src rcv_irq; | |
| 52 | + struct delayed_work flr_work; | |
| 53 | + const struct amdgpu_virt_ops *ops; | |
| 34 | 54 | }; |
| 35 | 55 | |
| 56 | +#define AMDGPU_CSA_SIZE (8 * 1024) | |
| 57 | +#define AMDGPU_CSA_VADDR (AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE) | |
| 58 | + | |
| 36 | 59 | #define amdgpu_sriov_enabled(adev) \ |
| 37 | −((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV) | |
| 60 | +((adev)->virt.caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV) | |
| 38 | 61 | |
| 39 | 62 | #define amdgpu_sriov_vf(adev) \ |
| 40 | −((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_IS_VF) | |
| 63 | +((adev)->virt.caps & AMDGPU_SRIOV_CAPS_IS_VF) | |
| 41 | 64 | |
| 42 | 65 | #define amdgpu_sriov_bios(adev) \ |
| 43 | −((adev)->virtualization.virtual_caps & AMDGPU_SRIOV_CAPS_SRIOV_VBIOS) | |
| 66 | +((adev)->virt.caps & AMDGPU_SRIOV_CAPS_SRIOV_VBIOS) | |
| 67 | + | |
| 68 | +#define amdgpu_sriov_runtime(adev) \ | |
| 69 | +((adev)->virt.caps & AMDGPU_SRIOV_CAPS_RUNTIME) | |
| 44 | 70 | |
| 45 | 71 | #define amdgpu_passthrough(adev) \ |
| 46 | −((adev)->virtualization.virtual_caps & AMDGPU_PASSTHROUGH_MODE) | |
| 72 | +((adev)->virt.caps & AMDGPU_PASSTHROUGH_MODE) | |
| 47 | 73 | |
| 48 | 74 | static inline bool is_virtual_machine(void) |
| 49 | 75 | { |
| @@ -54,4 +80,14 @@ static inline bool is_virtual_machine(void) · 4 unmodified lines | ||
| 54 | 80 | #endif |
| 55 | 81 | } |
| 56 | 82 | |
| 57 | −#endif | |
| 83 | +struct amdgpu_vm; | |
| 84 | +int amdgpu_allocate_static_csa(struct amdgpu_device *adev); | |
| 85 | +int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm); | |
| 86 | +void amdgpu_virt_init_setting(struct amdgpu_device *adev); | |
| 87 | +uint32_t amdgpu_virt_kiq_rreg(struct amdgpu_device *adev, uint32_t reg); | |
| 88 | +void amdgpu_virt_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v); | |
| 89 | +int amdgpu_virt_request_full_gpu(struct amdgpu_device *adev, bool init); | |
| 90 | +int amdgpu_virt_release_full_gpu(struct amdgpu_device *adev, bool init); | |
| 91 | +int amdgpu_virt_reset_gpu(struct amdgpu_device *adev); | |
| 92 | + | |
| 93 | +#endif | |
| @@ -1293,7 +1293,7 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev, · 1292 unmodified lines | ||
| 1293 | 1293 | int amdgpu_vm_bo_map(struct amdgpu_device *adev, |
| 1294 | 1294 | struct amdgpu_bo_va *bo_va, |
| 1295 | 1295 | uint64_t saddr, uint64_t offset, |
| 1296 | − uint64_t size, uint32_t flags) | |
| 1296 | + uint64_t size, uint64_t flags) | |
| 1297 | 1297 | { |
| 1298 | 1298 | struct amdgpu_bo_va_mapping *mapping; |
| 1299 | 1299 | struct amdgpu_vm *vm = bo_va->vm; |
| @@ -111,6 +111,8 @@ struct amdgpu_vm { · 110 unmodified lines | ||
| 111 | 111 | |
| 112 | 112 | /* client id */ |
| 113 | 113 | u64 client_id; |
| 114 | + /* each VM will map on CSA */ | |
| 115 | + struct amdgpu_bo_va *csa_bo_va; | |
| 114 | 116 | }; |
| 115 | 117 | |
| 116 | 118 | struct amdgpu_vm_id { |
| @@ -195,7 +197,7 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev, · 78 unmodified lines | ||
| 195 | 197 | int amdgpu_vm_bo_map(struct amdgpu_device *adev, |
| 196 | 198 | struct amdgpu_bo_va *bo_va, |
| 197 | 199 | uint64_t addr, uint64_t offset, |
| 198 | − uint64_t size, uint32_t flags); | |
| 200 | + uint64_t size, uint64_t flags); | |
| 199 | 201 | int amdgpu_vm_bo_unmap(struct amdgpu_device *adev, |
| 200 | 202 | struct amdgpu_bo_va *bo_va, |
| 201 | 203 | uint64_t addr); |
| @@ -181,9 +181,6 @@ void amdgpu_atombios_encoder_init_backlight(struct amdgpu_encoder *amdgpu_encode · 180 unmodified lines | ||
| 181 | 181 | if (!amdgpu_encoder->enc_priv) |
| 182 | 182 | return; |
| 183 | 183 | |
| 184 | − if (!adev->is_atom_bios) | |
| 185 | − return; | |
| 186 | − | |
| 187 | 184 | if (!(adev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU)) |
| 188 | 185 | return; |
| 189 | 186 | |
| @@ -236,9 +233,6 @@ amdgpu_atombios_encoder_fini_backlight(struct amdgpu_encoder *amdgpu_encoder) · 46 unmodified lines | ||
| 236 | 233 | if (!amdgpu_encoder->enc_priv) |
| 237 | 234 | return; |
| 238 | 235 | |
| 239 | − if (!adev->is_atom_bios) | |
| 240 | − return; | |
| 241 | − | |
| 242 | 236 | if (!(adev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU)) |
| 243 | 237 | return; |
| 244 | 238 | |
| @@ -889,7 +889,16 @@ static void ci_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate) · 888 unmodified lines | ||
| 889 | 889 | |
| 890 | 890 | pi->uvd_power_gated = gate; |
| 891 | 891 | |
| 892 | − ci_update_uvd_dpm(adev, gate); | |
| 892 | + if (gate) { | |
| 893 | + /* stop the UVD block */ | |
| 894 | + amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | |
| 895 | + AMD_PG_STATE_GATE); | |
| 896 | + ci_update_uvd_dpm(adev, gate); | |
| 897 | + } else { | |
| 898 | + amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | |
| 899 | + AMD_PG_STATE_UNGATE); | |
| 900 | + ci_update_uvd_dpm(adev, gate); | |
| 901 | + } | |
| 893 | 902 | } |
| 894 | 903 | |
| 895 | 904 | static bool ci_dpm_vblank_too_short(struct amdgpu_device *adev) |
| @@ -4336,13 +4345,13 @@ static u32 ci_get_lowest_enabled_level(struct amdgpu_device *adev, · 3440 unmodified lines | ||
| 4336 | 4345 | |
| 4337 | 4346 | |
| 4338 | 4347 | static int ci_dpm_force_performance_level(struct amdgpu_device *adev, |
| 4339 | − enum amdgpu_dpm_forced_level level) | |
| 4348 | + enum amd_dpm_forced_level level) | |
| 4340 | 4349 | { |
| 4341 | 4350 | struct ci_power_info *pi = ci_get_pi(adev); |
| 4342 | 4351 | u32 tmp, levels, i; |
| 4343 | 4352 | int ret; |
| 4344 | 4353 | |
| 4345 | − if (level == AMDGPU_DPM_FORCED_LEVEL_HIGH) { | |
| 4354 | + if (level == AMD_DPM_FORCED_LEVEL_HIGH) { | |
| 4346 | 4355 | if ((!pi->pcie_dpm_key_disabled) && |
| 4347 | 4356 | pi->dpm_level_enable_mask.pcie_dpm_enable_mask) { |
| 4348 | 4357 | levels = 0; |
| @@ -4403,7 +4412,7 @@ static int ci_dpm_force_performance_level(struct amdgpu_device *adev, · 54 unmodified lines | ||
| 4403 | 4412 | } |
| 4404 | 4413 | } |
| 4405 | 4414 | } |
| 4406 | − } else if (level == AMDGPU_DPM_FORCED_LEVEL_LOW) { | |
| 4415 | + } else if (level == AMD_DPM_FORCED_LEVEL_LOW) { | |
| 4407 | 4416 | if ((!pi->sclk_dpm_key_disabled) && |
| 4408 | 4417 | pi->dpm_level_enable_mask.sclk_dpm_enable_mask) { |
| 4409 | 4418 | levels = ci_get_lowest_enabled_level(adev, |
| @@ -4452,7 +4461,7 @@ static int ci_dpm_force_performance_level(struct amdgpu_device *adev, · 42 unmodified lines | ||
| 4452 | 4461 | udelay(1); |
| 4453 | 4462 | } |
| 4454 | 4463 | } |
| 4455 | − } else if (level == AMDGPU_DPM_FORCED_LEVEL_AUTO) { | |
| 4464 | + } else if (level == AMD_DPM_FORCED_LEVEL_AUTO) { | |
| 4456 | 4465 | if (!pi->pcie_dpm_key_disabled) { |
| 4457 | 4466 | PPSMC_Result smc_result; |
| 4458 | 4467 | |
| @@ -6262,7 +6271,7 @@ static int ci_dpm_sw_init(void *handle) · 1803 unmodified lines | ||
| 6262 | 6271 | /* default to balanced state */ |
| 6263 | 6272 | adev->pm.dpm.state = POWER_STATE_TYPE_BALANCED; |
| 6264 | 6273 | adev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; |
| 6265 | − adev->pm.dpm.forced_level = AMDGPU_DPM_FORCED_LEVEL_AUTO; | |
| 6274 | + adev->pm.dpm.forced_level = AMD_DPM_FORCED_LEVEL_AUTO; | |
| 6266 | 6275 | adev->pm.default_sclk = adev->clock.default_sclk; |
| 6267 | 6276 | adev->pm.default_mclk = adev->clock.default_mclk; |
| 6268 | 6277 | adev->pm.current_sclk = adev->clock.default_sclk; |
| @@ -6571,8 +6580,9 @@ static int ci_dpm_force_clock_level(struct amdgpu_device *adev, · 302 unmodified lines | ||
| 6571 | 6580 | { |
| 6572 | 6581 | struct ci_power_info *pi = ci_get_pi(adev); |
| 6573 | 6582 | |
| 6574 | − if (adev->pm.dpm.forced_level | |
| 6575 | − != AMDGPU_DPM_FORCED_LEVEL_MANUAL) | |
| 6583 | + if (adev->pm.dpm.forced_level & (AMD_DPM_FORCED_LEVEL_AUTO | | |
| 6584 | + AMD_DPM_FORCED_LEVEL_LOW | | |
| 6585 | + AMD_DPM_FORCED_LEVEL_HIGH)) | |
| 6576 | 6586 | return -EINVAL; |
| 6577 | 6587 | |
| 6578 | 6588 | switch (type) { |
| @@ -6739,12 +6749,3 @@ static void ci_dpm_set_irq_funcs(struct amdgpu_device *adev) · 160 unmodified lines | ||
| 6739 | 6749 | adev->pm.dpm.thermal.irq.num_types = AMDGPU_THERMAL_IRQ_LAST; |
| 6740 | 6750 | adev->pm.dpm.thermal.irq.funcs = &ci_dpm_irq_funcs; |
| 6741 | 6751 | } |
| 6742 | − | |
| 6743 | −const struct amdgpu_ip_block_version ci_dpm_ip_block = | |
| 6744 | −{ | |
| 6745 | − .type = AMD_IP_BLOCK_TYPE_SMC, | |
| 6746 | − .major = 7, | |
| 6747 | − .minor = 0, | |
| 6748 | − .rev = 0, | |
| 6749 | − .funcs = &ci_dpm_ip_funcs, | |
| 6750 | −}; | |
| @@ -1627,14 +1627,13 @@ static uint32_t cik_get_rev_id(struct amdgpu_device *adev) · 1626 unmodified lines | ||
| 1627 | 1627 | static void cik_detect_hw_virtualization(struct amdgpu_device *adev) |
| 1628 | 1628 | { |
| 1629 | 1629 | if (is_virtual_machine()) /* passthrough mode */ |
| 1630 | − adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE; | |
| 1630 | + adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE; | |
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | static const struct amdgpu_asic_funcs cik_asic_funcs = |
| 1634 | 1634 | { |
| 1635 | 1635 | .read_disabled_bios = &cik_read_disabled_bios, |
| 1636 | 1636 | .read_bios_from_rom = &cik_read_bios_from_rom, |
| 1637 | − .detect_hw_virtualization = cik_detect_hw_virtualization, | |
| 1638 | 1637 | .read_register = &cik_read_register, |
| 1639 | 1638 | .reset = &cik_asic_reset, |
| 1640 | 1639 | .set_vga_state = &cik_vga_set_state, |
| @@ -1890,6 +1889,8 @@ static const struct amdgpu_ip_block_version cik_common_ip_block = · 249 unmodified lines | ||
| 1890 | 1889 | |
| 1891 | 1890 | int cik_set_ip_blocks(struct amdgpu_device *adev) |
| 1892 | 1891 | { |
| 1892 | + cik_detect_hw_virtualization(adev); | |
| 1893 | + | |
| 1893 | 1894 | switch (adev->asic_type) { |
| 1894 | 1895 | case CHIP_BONAIRE: |
| 1895 | 1896 | amdgpu_ip_block_add(adev, &cik_common_ip_block); |
| @@ -651,7 +651,7 @@ static int cik_sdma_ring_test_ib(struct amdgpu_ring *ring, long timeout) · 650 unmodified lines | ||
| 651 | 651 | ib.ptr[3] = 1; |
| 652 | 652 | ib.ptr[4] = 0xDEADBEEF; |
| 653 | 653 | ib.length_dw = 5; |
| 654 | − r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | |
| 654 | + r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f); | |
| 655 | 655 | if (r) |
| 656 | 656 | goto err1; |
| 657 | 657 | |
File renamed without changes.
| @@ -1,2320 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright 2014 Advanced Micro Devices, Inc. | |
| 3 | − * | |
| 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: | |
| 10 | − * | |
| 11 | − * The above copyright notice and this permission notice shall be included in | |
| 12 | − * all copies or substantial portions of the Software. | |
| 13 | − * | |
| 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. | |
| 21 | − * | |
| 22 | − */ | |
| 23 | − | |
| 24 | −#include <linux/firmware.h> | |
| 25 | −#include <linux/seq_file.h> | |
| 26 | −#include "drmP.h" | |
| 27 | −#include "amdgpu.h" | |
| 28 | −#include "amdgpu_pm.h" | |
| 29 | −#include "amdgpu_atombios.h" | |
| 30 | −#include "vid.h" | |
| 31 | −#include "vi_dpm.h" | |
| 32 | −#include "amdgpu_dpm.h" | |
| 33 | −#include "cz_dpm.h" | |
| 34 | −#include "cz_ppsmc.h" | |
| 35 | −#include "atom.h" | |
| 36 | − | |
| 37 | −#include "smu/smu_8_0_d.h" | |
| 38 | −#include "smu/smu_8_0_sh_mask.h" | |
| 39 | −#include "gca/gfx_8_0_d.h" | |
| 40 | −#include "gca/gfx_8_0_sh_mask.h" | |
| 41 | −#include "gmc/gmc_8_1_d.h" | |
| 42 | −#include "bif/bif_5_1_d.h" | |
| 43 | −#include "gfx_v8_0.h" | |
| 44 | − | |
| 45 | −static void cz_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate); | |
| 46 | −static void cz_dpm_powergate_vce(struct amdgpu_device *adev, bool gate); | |
| 47 | −static void cz_dpm_fini(struct amdgpu_device *adev); | |
| 48 | − | |
| 49 | −static struct cz_ps *cz_get_ps(struct amdgpu_ps *rps) | |
| 50 | −{ | |
| 51 | − struct cz_ps *ps = rps->ps_priv; | |
| 52 | − | |
| 53 | − return ps; | |
| 54 | −} | |
| 55 | − | |
| 56 | −static struct cz_power_info *cz_get_pi(struct amdgpu_device *adev) | |
| 57 | −{ | |
| 58 | − struct cz_power_info *pi = adev->pm.dpm.priv; | |
| 59 | − | |
| 60 | − return pi; | |
| 61 | −} | |
| 62 | − | |
| 63 | −static uint16_t cz_convert_8bit_index_to_voltage(struct amdgpu_device *adev, | |
| 64 | − uint16_t voltage) | |
| 65 | −{ | |
| 66 | − uint16_t tmp = 6200 - voltage * 25; | |
| 67 | − | |
| 68 | − return tmp; | |
| 69 | −} | |
| 70 | − | |
| 71 | −static void cz_construct_max_power_limits_table(struct amdgpu_device *adev, | |
| 72 | − struct amdgpu_clock_and_voltage_limits *table) | |
| 73 | −{ | |
| 74 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 75 | − struct amdgpu_clock_voltage_dependency_table *dep_table = | |
| 76 | − &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk; | |
| 77 | − | |
| 78 | − if (dep_table->count > 0) { | |
| 79 | − table->sclk = dep_table->entries[dep_table->count - 1].clk; | |
| 80 | − table->vddc = cz_convert_8bit_index_to_voltage(adev, | |
| 81 | − dep_table->entries[dep_table->count - 1].v); | |
| 82 | − } | |
| 83 | − | |
| 84 | − table->mclk = pi->sys_info.nbp_memory_clock[0]; | |
| 85 | − | |
| 86 | −} | |
| 87 | − | |
| 88 | −union igp_info { | |
| 89 | − struct _ATOM_INTEGRATED_SYSTEM_INFO info; | |
| 90 | − struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 info_7; | |
| 91 | − struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_8 info_8; | |
| 92 | − struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_9 info_9; | |
| 93 | −}; | |
| 94 | − | |
| 95 | −static int cz_parse_sys_info_table(struct amdgpu_device *adev) | |
| 96 | −{ | |
| 97 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 98 | − struct amdgpu_mode_info *mode_info = &adev->mode_info; | |
| 99 | − int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo); | |
| 100 | − union igp_info *igp_info; | |
| 101 | − u8 frev, crev; | |
| 102 | − u16 data_offset; | |
| 103 | − int i = 0; | |
| 104 | − | |
| 105 | − if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | |
| 106 | − &frev, &crev, &data_offset)) { | |
| 107 | − igp_info = (union igp_info *)(mode_info->atom_context->bios + | |
| 108 | − data_offset); | |
| 109 | − | |
| 110 | − if (crev != 9) { | |
| 111 | − DRM_ERROR("Unsupported IGP table: %d %d\n", frev, crev); | |
| 112 | − return -EINVAL; | |
| 113 | − } | |
| 114 | − pi->sys_info.bootup_sclk = | |
| 115 | − le32_to_cpu(igp_info->info_9.ulBootUpEngineClock); | |
| 116 | − pi->sys_info.bootup_uma_clk = | |
| 117 | − le32_to_cpu(igp_info->info_9.ulBootUpUMAClock); | |
| 118 | − pi->sys_info.dentist_vco_freq = | |
| 119 | − le32_to_cpu(igp_info->info_9.ulDentistVCOFreq); | |
| 120 | − pi->sys_info.bootup_nb_voltage_index = | |
| 121 | − le16_to_cpu(igp_info->info_9.usBootUpNBVoltage); | |
| 122 | − | |
| 123 | − if (igp_info->info_9.ucHtcTmpLmt == 0) | |
| 124 | − pi->sys_info.htc_tmp_lmt = 203; | |
| 125 | − else | |
| 126 | − pi->sys_info.htc_tmp_lmt = igp_info->info_9.ucHtcTmpLmt; | |
| 127 | − | |
| 128 | − if (igp_info->info_9.ucHtcHystLmt == 0) | |
| 129 | − pi->sys_info.htc_hyst_lmt = 5; | |
| 130 | − else | |
| 131 | − pi->sys_info.htc_hyst_lmt = igp_info->info_9.ucHtcHystLmt; | |
| 132 | − | |
| 133 | − if (pi->sys_info.htc_tmp_lmt <= pi->sys_info.htc_hyst_lmt) { | |
| 134 | − DRM_ERROR("The htcTmpLmt should be larger than htcHystLmt.\n"); | |
| 135 | − return -EINVAL; | |
| 136 | − } | |
| 137 | − | |
| 138 | − if (le32_to_cpu(igp_info->info_9.ulSystemConfig) & (1 << 3) && | |
| 139 | − pi->enable_nb_ps_policy) | |
| 140 | − pi->sys_info.nb_dpm_enable = true; | |
| 141 | − else | |
| 142 | − pi->sys_info.nb_dpm_enable = false; | |
| 143 | − | |
| 144 | − for (i = 0; i < CZ_NUM_NBPSTATES; i++) { | |
| 145 | − if (i < CZ_NUM_NBPMEMORY_CLOCK) | |
| 146 | − pi->sys_info.nbp_memory_clock[i] = | |
| 147 | − le32_to_cpu(igp_info->info_9.ulNbpStateMemclkFreq[i]); | |
| 148 | − pi->sys_info.nbp_n_clock[i] = | |
| 149 | − le32_to_cpu(igp_info->info_9.ulNbpStateNClkFreq[i]); | |
| 150 | − } | |
| 151 | − | |
| 152 | − for (i = 0; i < CZ_MAX_DISPLAY_CLOCK_LEVEL; i++) | |
| 153 | − pi->sys_info.display_clock[i] = | |
| 154 | − le32_to_cpu(igp_info->info_9.sDispClkVoltageMapping[i].ulMaximumSupportedCLK); | |
| 155 | − | |
| 156 | − for (i = 0; i < CZ_NUM_NBPSTATES; i++) | |
| 157 | − pi->sys_info.nbp_voltage_index[i] = | |
| 158 | − le32_to_cpu(igp_info->info_9.usNBPStateVoltage[i]); | |
| 159 | − | |
| 160 | − if (le32_to_cpu(igp_info->info_9.ulGPUCapInfo) & | |
| 161 | − SYS_INFO_GPUCAPS__ENABEL_DFS_BYPASS) | |
| 162 | − pi->caps_enable_dfs_bypass = true; | |
| 163 | − | |
| 164 | − pi->sys_info.uma_channel_number = | |
| 165 | − igp_info->info_9.ucUMAChannelNumber; | |
| 166 | − | |
| 167 | − cz_construct_max_power_limits_table(adev, | |
| 168 | − &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac); | |
| 169 | − } | |
| 170 | − | |
| 171 | − return 0; | |
| 172 | −} | |
| 173 | − | |
| 174 | −static void cz_patch_voltage_values(struct amdgpu_device *adev) | |
| 175 | −{ | |
| 176 | − int i; | |
| 177 | − struct amdgpu_uvd_clock_voltage_dependency_table *uvd_table = | |
| 178 | − &adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table; | |
| 179 | − struct amdgpu_vce_clock_voltage_dependency_table *vce_table = | |
| 180 | − &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table; | |
| 181 | − struct amdgpu_clock_voltage_dependency_table *acp_table = | |
| 182 | − &adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table; | |
| 183 | − | |
| 184 | − if (uvd_table->count) { | |
| 185 | − for (i = 0; i < uvd_table->count; i++) | |
| 186 | − uvd_table->entries[i].v = | |
| 187 | − cz_convert_8bit_index_to_voltage(adev, | |
| 188 | − uvd_table->entries[i].v); | |
| 189 | − } | |
| 190 | − | |
| 191 | − if (vce_table->count) { | |
| 192 | − for (i = 0; i < vce_table->count; i++) | |
| 193 | − vce_table->entries[i].v = | |
| 194 | − cz_convert_8bit_index_to_voltage(adev, | |
| 195 | − vce_table->entries[i].v); | |
| 196 | − } | |
| 197 | − | |
| 198 | − if (acp_table->count) { | |
| 199 | − for (i = 0; i < acp_table->count; i++) | |
| 200 | − acp_table->entries[i].v = | |
| 201 | − cz_convert_8bit_index_to_voltage(adev, | |
| 202 | − acp_table->entries[i].v); | |
| 203 | − } | |
| 204 | − | |
| 205 | −} | |
| 206 | − | |
| 207 | −static void cz_construct_boot_state(struct amdgpu_device *adev) | |
| 208 | −{ | |
| 209 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 210 | − | |
| 211 | − pi->boot_pl.sclk = pi->sys_info.bootup_sclk; | |
| 212 | − pi->boot_pl.vddc_index = pi->sys_info.bootup_nb_voltage_index; | |
| 213 | − pi->boot_pl.ds_divider_index = 0; | |
| 214 | − pi->boot_pl.ss_divider_index = 0; | |
| 215 | − pi->boot_pl.allow_gnb_slow = 1; | |
| 216 | − pi->boot_pl.force_nbp_state = 0; | |
| 217 | − pi->boot_pl.display_wm = 0; | |
| 218 | − pi->boot_pl.vce_wm = 0; | |
| 219 | − | |
| 220 | −} | |
| 221 | − | |
| 222 | −static void cz_patch_boot_state(struct amdgpu_device *adev, | |
| 223 | − struct cz_ps *ps) | |
| 224 | −{ | |
| 225 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 226 | − | |
| 227 | − ps->num_levels = 1; | |
| 228 | − ps->levels[0] = pi->boot_pl; | |
| 229 | −} | |
| 230 | − | |
| 231 | −union pplib_clock_info { | |
| 232 | − struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO evergreen; | |
| 233 | − struct _ATOM_PPLIB_SUMO_CLOCK_INFO sumo; | |
| 234 | − struct _ATOM_PPLIB_CZ_CLOCK_INFO carrizo; | |
| 235 | −}; | |
| 236 | − | |
| 237 | −static void cz_parse_pplib_clock_info(struct amdgpu_device *adev, | |
| 238 | − struct amdgpu_ps *rps, int index, | |
| 239 | − union pplib_clock_info *clock_info) | |
| 240 | −{ | |
| 241 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 242 | − struct cz_ps *ps = cz_get_ps(rps); | |
| 243 | − struct cz_pl *pl = &ps->levels[index]; | |
| 244 | − struct amdgpu_clock_voltage_dependency_table *table = | |
| 245 | − &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk; | |
| 246 | − | |
| 247 | − pl->sclk = table->entries[clock_info->carrizo.index].clk; | |
| 248 | − pl->vddc_index = table->entries[clock_info->carrizo.index].v; | |
| 249 | − | |
| 250 | − ps->num_levels = index + 1; | |
| 251 | − | |
| 252 | − if (pi->caps_sclk_ds) { | |
| 253 | − pl->ds_divider_index = 5; | |
| 254 | − pl->ss_divider_index = 5; | |
| 255 | − } | |
| 256 | − | |
| 257 | −} | |
| 258 | − | |
| 259 | −static void cz_parse_pplib_non_clock_info(struct amdgpu_device *adev, | |
| 260 | − struct amdgpu_ps *rps, | |
| 261 | − struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info, | |
| 262 | − u8 table_rev) | |
| 263 | −{ | |
| 264 | − struct cz_ps *ps = cz_get_ps(rps); | |
| 265 | − | |
| 266 | − rps->caps = le32_to_cpu(non_clock_info->ulCapsAndSettings); | |
| 267 | − rps->class = le16_to_cpu(non_clock_info->usClassification); | |
| 268 | − rps->class2 = le16_to_cpu(non_clock_info->usClassification2); | |
| 269 | − | |
| 270 | − if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) { | |
| 271 | − rps->vclk = le32_to_cpu(non_clock_info->ulVCLK); | |
| 272 | − rps->dclk = le32_to_cpu(non_clock_info->ulDCLK); | |
| 273 | − } else { | |
| 274 | − rps->vclk = 0; | |
| 275 | − rps->dclk = 0; | |
| 276 | − } | |
| 277 | − | |
| 278 | − if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) { | |
| 279 | − adev->pm.dpm.boot_ps = rps; | |
| 280 | − cz_patch_boot_state(adev, ps); | |
| 281 | − } | |
| 282 | − if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE) | |
| 283 | − adev->pm.dpm.uvd_ps = rps; | |
| 284 | − | |
| 285 | −} | |
| 286 | − | |
| 287 | −union power_info { | |
| 288 | − struct _ATOM_PPLIB_POWERPLAYTABLE pplib; | |
| 289 | − struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2; | |
| 290 | − struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3; | |
| 291 | − struct _ATOM_PPLIB_POWERPLAYTABLE4 pplib4; | |
| 292 | − struct _ATOM_PPLIB_POWERPLAYTABLE5 pplib5; | |
| 293 | −}; | |
| 294 | − | |
| 295 | −union pplib_power_state { | |
| 296 | − struct _ATOM_PPLIB_STATE v1; | |
| 297 | − struct _ATOM_PPLIB_STATE_V2 v2; | |
| 298 | −}; | |
| 299 | − | |
| 300 | −static int cz_parse_power_table(struct amdgpu_device *adev) | |
| 301 | −{ | |
| 302 | − struct amdgpu_mode_info *mode_info = &adev->mode_info; | |
| 303 | − struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info; | |
| 304 | − union pplib_power_state *power_state; | |
| 305 | − int i, j, k, non_clock_array_index, clock_array_index; | |
| 306 | − union pplib_clock_info *clock_info; | |
| 307 | − struct _StateArray *state_array; | |
| 308 | − struct _ClockInfoArray *clock_info_array; | |
| 309 | − struct _NonClockInfoArray *non_clock_info_array; | |
| 310 | − union power_info *power_info; | |
| 311 | − int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo); | |
| 312 | − u16 data_offset; | |
| 313 | − u8 frev, crev; | |
| 314 | − u8 *power_state_offset; | |
| 315 | − struct cz_ps *ps; | |
| 316 | − | |
| 317 | − if (!amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL, | |
| 318 | − &frev, &crev, &data_offset)) | |
| 319 | − return -EINVAL; | |
| 320 | − power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); | |
| 321 | − | |
| 322 | − state_array = (struct _StateArray *) | |
| 323 | − (mode_info->atom_context->bios + data_offset + | |
| 324 | − le16_to_cpu(power_info->pplib.usStateArrayOffset)); | |
| 325 | − clock_info_array = (struct _ClockInfoArray *) | |
| 326 | − (mode_info->atom_context->bios + data_offset + | |
| 327 | − le16_to_cpu(power_info->pplib.usClockInfoArrayOffset)); | |
| 328 | − non_clock_info_array = (struct _NonClockInfoArray *) | |
| 329 | − (mode_info->atom_context->bios + data_offset + | |
| 330 | − le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | |
| 331 | − | |
| 332 | − adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) * | |
| 333 | − state_array->ucNumEntries, GFP_KERNEL); | |
| 334 | − | |
| 335 | − if (!adev->pm.dpm.ps) | |
| 336 | − return -ENOMEM; | |
| 337 | − | |
| 338 | − power_state_offset = (u8 *)state_array->states; | |
| 339 | − adev->pm.dpm.platform_caps = | |
| 340 | − le32_to_cpu(power_info->pplib.ulPlatformCaps); | |
| 341 | − adev->pm.dpm.backbias_response_time = | |
| 342 | − le16_to_cpu(power_info->pplib.usBackbiasTime); | |
| 343 | − adev->pm.dpm.voltage_response_time = | |
| 344 | − le16_to_cpu(power_info->pplib.usVoltageTime); | |
| 345 | − | |
| 346 | − for (i = 0; i < state_array->ucNumEntries; i++) { | |
| 347 | − power_state = (union pplib_power_state *)power_state_offset; | |
| 348 | − non_clock_array_index = power_state->v2.nonClockInfoIndex; | |
| 349 | − non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) | |
| 350 | − &non_clock_info_array->nonClockInfo[non_clock_array_index]; | |
| 351 | − | |
| 352 | − ps = kzalloc(sizeof(struct cz_ps), GFP_KERNEL); | |
| 353 | − if (ps == NULL) { | |
| 354 | − for (j = 0; j < i; j++) | |
| 355 | − kfree(adev->pm.dpm.ps[j].ps_priv); | |
| 356 | − kfree(adev->pm.dpm.ps); | |
| 357 | − return -ENOMEM; | |
| 358 | − } | |
| 359 | − | |
| 360 | − adev->pm.dpm.ps[i].ps_priv = ps; | |
| 361 | − k = 0; | |
| 362 | − for (j = 0; j < power_state->v2.ucNumDPMLevels; j++) { | |
| 363 | − clock_array_index = power_state->v2.clockInfoIndex[j]; | |
| 364 | − if (clock_array_index >= clock_info_array->ucNumEntries) | |
| 365 | − continue; | |
| 366 | − if (k >= CZ_MAX_HARDWARE_POWERLEVELS) | |
| 367 | − break; | |
| 368 | − clock_info = (union pplib_clock_info *) | |
| 369 | − &clock_info_array->clockInfo[clock_array_index * | |
| 370 | − clock_info_array->ucEntrySize]; | |
| 371 | − cz_parse_pplib_clock_info(adev, &adev->pm.dpm.ps[i], | |
| 372 | − k, clock_info); | |
| 373 | − k++; | |
| 374 | − } | |
| 375 | − cz_parse_pplib_non_clock_info(adev, &adev->pm.dpm.ps[i], | |
| 376 | − non_clock_info, | |
| 377 | − non_clock_info_array->ucEntrySize); | |
| 378 | − power_state_offset += 2 + power_state->v2.ucNumDPMLevels; | |
| 379 | − } | |
| 380 | − adev->pm.dpm.num_ps = state_array->ucNumEntries; | |
| 381 | − | |
| 382 | − return 0; | |
| 383 | −} | |
| 384 | − | |
| 385 | −static int cz_process_firmware_header(struct amdgpu_device *adev) | |
| 386 | −{ | |
| 387 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 388 | − u32 tmp; | |
| 389 | − int ret; | |
| 390 | − | |
| 391 | − ret = cz_read_smc_sram_dword(adev, SMU8_FIRMWARE_HEADER_LOCATION + | |
| 392 | − offsetof(struct SMU8_Firmware_Header, | |
| 393 | − DpmTable), | |
| 394 | − &tmp, pi->sram_end); | |
| 395 | − | |
| 396 | − if (ret == 0) | |
| 397 | − pi->dpm_table_start = tmp; | |
| 398 | − | |
| 399 | − return ret; | |
| 400 | −} | |
| 401 | − | |
| 402 | −static int cz_dpm_init(struct amdgpu_device *adev) | |
| 403 | −{ | |
| 404 | − struct cz_power_info *pi; | |
| 405 | − int ret, i; | |
| 406 | − | |
| 407 | − pi = kzalloc(sizeof(struct cz_power_info), GFP_KERNEL); | |
| 408 | − if (NULL == pi) | |
| 409 | − return -ENOMEM; | |
| 410 | − | |
| 411 | − adev->pm.dpm.priv = pi; | |
| 412 | − | |
| 413 | − ret = amdgpu_get_platform_caps(adev); | |
| 414 | − if (ret) | |
| 415 | − goto err; | |
| 416 | − | |
| 417 | − ret = amdgpu_parse_extended_power_table(adev); | |
| 418 | − if (ret) | |
| 419 | − goto err; | |
| 420 | − | |
| 421 | − pi->sram_end = SMC_RAM_END; | |
| 422 | − | |
| 423 | − /* set up DPM defaults */ | |
| 424 | − for (i = 0; i < CZ_MAX_HARDWARE_POWERLEVELS; i++) | |
| 425 | − pi->active_target[i] = CZ_AT_DFLT; | |
| 426 | − | |
| 427 | − pi->mgcg_cgtt_local0 = 0x0; | |
| 428 | − pi->mgcg_cgtt_local1 = 0x0; | |
| 429 | − pi->clock_slow_down_step = 25000; | |
| 430 | − pi->skip_clock_slow_down = 1; | |
| 431 | − pi->enable_nb_ps_policy = false; | |
| 432 | − pi->caps_power_containment = true; | |
| 433 | − pi->caps_cac = true; | |
| 434 | − pi->didt_enabled = false; | |
| 435 | − if (pi->didt_enabled) { | |
| 436 | − pi->caps_sq_ramping = true; | |
| 437 | − pi->caps_db_ramping = true; | |
| 438 | − pi->caps_td_ramping = true; | |
| 439 | − pi->caps_tcp_ramping = true; | |
| 440 | − } | |
| 441 | − if (amdgpu_pp_feature_mask & SCLK_DEEP_SLEEP_MASK) | |
| 442 | − pi->caps_sclk_ds = true; | |
| 443 | − else | |
| 444 | − pi->caps_sclk_ds = false; | |
| 445 | − | |
| 446 | − pi->voting_clients = 0x00c00033; | |
| 447 | − pi->auto_thermal_throttling_enabled = true; | |
| 448 | − pi->bapm_enabled = false; | |
| 449 | − pi->disable_nb_ps3_in_battery = false; | |
| 450 | − pi->voltage_drop_threshold = 0; | |
| 451 | − pi->caps_sclk_throttle_low_notification = false; | |
| 452 | − pi->gfx_pg_threshold = 500; | |
| 453 | − pi->caps_fps = true; | |
| 454 | − /* uvd */ | |
| 455 | − pi->caps_uvd_pg = (adev->pg_flags & AMD_PG_SUPPORT_UVD) ? true : false; | |
| 456 | − pi->caps_uvd_dpm = true; | |
| 457 | − /* vce */ | |
| 458 | − pi->caps_vce_pg = (adev->pg_flags & AMD_PG_SUPPORT_VCE) ? true : false; | |
| 459 | − pi->caps_vce_dpm = true; | |
| 460 | − /* acp */ | |
| 461 | − pi->caps_acp_pg = (adev->pg_flags & AMD_PG_SUPPORT_ACP) ? true : false; | |
| 462 | − pi->caps_acp_dpm = true; | |
| 463 | − | |
| 464 | − pi->caps_stable_power_state = false; | |
| 465 | − pi->nb_dpm_enabled_by_driver = true; | |
| 466 | − pi->nb_dpm_enabled = false; | |
| 467 | − pi->caps_voltage_island = false; | |
| 468 | − /* flags which indicate need to upload pptable */ | |
| 469 | − pi->need_pptable_upload = true; | |
| 470 | − | |
| 471 | − ret = cz_parse_sys_info_table(adev); | |
| 472 | − if (ret) | |
| 473 | − goto err; | |
| 474 | − | |
| 475 | − cz_patch_voltage_values(adev); | |
| 476 | − cz_construct_boot_state(adev); | |
| 477 | − | |
| 478 | − ret = cz_parse_power_table(adev); | |
| 479 | − if (ret) | |
| 480 | − goto err; | |
| 481 | − | |
| 482 | − ret = cz_process_firmware_header(adev); | |
| 483 | − if (ret) | |
| 484 | − goto err; | |
| 485 | − | |
| 486 | − pi->dpm_enabled = true; | |
| 487 | − pi->uvd_dynamic_pg = false; | |
| 488 | − | |
| 489 | − return 0; | |
| 490 | −err: | |
| 491 | − cz_dpm_fini(adev); | |
| 492 | − return ret; | |
| 493 | −} | |
| 494 | − | |
| 495 | −static void cz_dpm_fini(struct amdgpu_device *adev) | |
| 496 | −{ | |
| 497 | − int i; | |
| 498 | − | |
| 499 | − for (i = 0; i < adev->pm.dpm.num_ps; i++) | |
| 500 | − kfree(adev->pm.dpm.ps[i].ps_priv); | |
| 501 | − | |
| 502 | − kfree(adev->pm.dpm.ps); | |
| 503 | − kfree(adev->pm.dpm.priv); | |
| 504 | − amdgpu_free_extended_power_table(adev); | |
| 505 | −} | |
| 506 | − | |
| 507 | −#define ixSMUSVI_NB_CURRENTVID 0xD8230044 | |
| 508 | −#define CURRENT_NB_VID_MASK 0xff000000 | |
| 509 | −#define CURRENT_NB_VID__SHIFT 24 | |
| 510 | −#define ixSMUSVI_GFX_CURRENTVID 0xD8230048 | |
| 511 | −#define CURRENT_GFX_VID_MASK 0xff000000 | |
| 512 | −#define CURRENT_GFX_VID__SHIFT 24 | |
| 513 | − | |
| 514 | −static void | |
| 515 | −cz_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev, | |
| 516 | − struct seq_file *m) | |
| 517 | −{ | |
| 518 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 519 | − struct amdgpu_clock_voltage_dependency_table *table = | |
| 520 | − &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk; | |
| 521 | − struct amdgpu_uvd_clock_voltage_dependency_table *uvd_table = | |
| 522 | − &adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table; | |
| 523 | − struct amdgpu_vce_clock_voltage_dependency_table *vce_table = | |
| 524 | − &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table; | |
| 525 | − u32 sclk_index = REG_GET_FIELD(RREG32_SMC(ixTARGET_AND_CURRENT_PROFILE_INDEX), | |
| 526 | − TARGET_AND_CURRENT_PROFILE_INDEX, CURR_SCLK_INDEX); | |
| 527 | − u32 uvd_index = REG_GET_FIELD(RREG32_SMC(ixTARGET_AND_CURRENT_PROFILE_INDEX_2), | |
| 528 | − TARGET_AND_CURRENT_PROFILE_INDEX_2, CURR_UVD_INDEX); | |
| 529 | − u32 vce_index = REG_GET_FIELD(RREG32_SMC(ixTARGET_AND_CURRENT_PROFILE_INDEX_2), | |
| 530 | − TARGET_AND_CURRENT_PROFILE_INDEX_2, CURR_VCE_INDEX); | |
| 531 | − u32 sclk, vclk, dclk, ecclk, tmp; | |
| 532 | − u16 vddnb, vddgfx; | |
| 533 | − | |
| 534 | − if (sclk_index >= NUM_SCLK_LEVELS) { | |
| 535 | − seq_printf(m, "invalid sclk dpm profile %d\n", sclk_index); | |
| 536 | − } else { | |
| 537 | − sclk = table->entries[sclk_index].clk; | |
| 538 | − seq_printf(m, "%u sclk: %u\n", sclk_index, sclk); | |
| 539 | − } | |
| 540 | − | |
| 541 | − tmp = (RREG32_SMC(ixSMUSVI_NB_CURRENTVID) & | |
| 542 | − CURRENT_NB_VID_MASK) >> CURRENT_NB_VID__SHIFT; | |
| 543 | − vddnb = cz_convert_8bit_index_to_voltage(adev, (u16)tmp); | |
| 544 | − tmp = (RREG32_SMC(ixSMUSVI_GFX_CURRENTVID) & | |
| 545 | − CURRENT_GFX_VID_MASK) >> CURRENT_GFX_VID__SHIFT; | |
| 546 | − vddgfx = cz_convert_8bit_index_to_voltage(adev, (u16)tmp); | |
| 547 | − seq_printf(m, "vddnb: %u vddgfx: %u\n", vddnb, vddgfx); | |
| 548 | − | |
| 549 | − seq_printf(m, "uvd %sabled\n", pi->uvd_power_gated ? "dis" : "en"); | |
| 550 | − if (!pi->uvd_power_gated) { | |
| 551 | − if (uvd_index >= CZ_MAX_HARDWARE_POWERLEVELS) { | |
| 552 | − seq_printf(m, "invalid uvd dpm level %d\n", uvd_index); | |
| 553 | − } else { | |
| 554 | − vclk = uvd_table->entries[uvd_index].vclk; | |
| 555 | − dclk = uvd_table->entries[uvd_index].dclk; | |
| 556 | − seq_printf(m, "%u uvd vclk: %u dclk: %u\n", uvd_index, vclk, dclk); | |
| 557 | − } | |
| 558 | − } | |
| 559 | − | |
| 560 | − seq_printf(m, "vce %sabled\n", pi->vce_power_gated ? "dis" : "en"); | |
| 561 | − if (!pi->vce_power_gated) { | |
| 562 | − if (vce_index >= CZ_MAX_HARDWARE_POWERLEVELS) { | |
| 563 | − seq_printf(m, "invalid vce dpm level %d\n", vce_index); | |
| 564 | − } else { | |
| 565 | − ecclk = vce_table->entries[vce_index].ecclk; | |
| 566 | − seq_printf(m, "%u vce ecclk: %u\n", vce_index, ecclk); | |
| 567 | − } | |
| 568 | − } | |
| 569 | −} | |
| 570 | − | |
| 571 | −static void cz_dpm_print_power_state(struct amdgpu_device *adev, | |
| 572 | − struct amdgpu_ps *rps) | |
| 573 | −{ | |
| 574 | − int i; | |
| 575 | − struct cz_ps *ps = cz_get_ps(rps); | |
| 576 | − | |
| 577 | − amdgpu_dpm_print_class_info(rps->class, rps->class2); | |
| 578 | − amdgpu_dpm_print_cap_info(rps->caps); | |
| 579 | − | |
| 580 | − DRM_INFO("\tuvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk); | |
| 581 | − for (i = 0; i < ps->num_levels; i++) { | |
| 582 | − struct cz_pl *pl = &ps->levels[i]; | |
| 583 | − | |
| 584 | − DRM_INFO("\t\tpower level %d sclk: %u vddc: %u\n", | |
| 585 | − i, pl->sclk, | |
| 586 | − cz_convert_8bit_index_to_voltage(adev, pl->vddc_index)); | |
| 587 | − } | |
| 588 | − | |
| 589 | − amdgpu_dpm_print_ps_status(adev, rps); | |
| 590 | −} | |
| 591 | − | |
| 592 | −static void cz_dpm_set_funcs(struct amdgpu_device *adev); | |
| 593 | − | |
| 594 | −static int cz_dpm_early_init(void *handle) | |
| 595 | −{ | |
| 596 | − struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 597 | − | |
| 598 | − cz_dpm_set_funcs(adev); | |
| 599 | − | |
| 600 | − return 0; | |
| 601 | −} | |
| 602 | − | |
| 603 | − | |
| 604 | −static int cz_dpm_late_init(void *handle) | |
| 605 | −{ | |
| 606 | − struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 607 | − | |
| 608 | − if (amdgpu_dpm) { | |
| 609 | − int ret; | |
| 610 | − /* init the sysfs and debugfs files late */ | |
| 611 | − ret = amdgpu_pm_sysfs_init(adev); | |
| 612 | − if (ret) | |
| 613 | − return ret; | |
| 614 | − | |
| 615 | − /* powerdown unused blocks for now */ | |
| 616 | − cz_dpm_powergate_uvd(adev, true); | |
| 617 | − cz_dpm_powergate_vce(adev, true); | |
| 618 | − } | |
| 619 | − | |
| 620 | − return 0; | |
| 621 | −} | |
| 622 | − | |
| 623 | −static int cz_dpm_sw_init(void *handle) | |
| 624 | −{ | |
| 625 | − struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 626 | − int ret = 0; | |
| 627 | − /* fix me to add thermal support TODO */ | |
| 628 | − | |
| 629 | − /* default to balanced state */ | |
| 630 | − adev->pm.dpm.state = POWER_STATE_TYPE_BALANCED; | |
| 631 | − adev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; | |
| 632 | − adev->pm.dpm.forced_level = AMDGPU_DPM_FORCED_LEVEL_AUTO; | |
| 633 | − adev->pm.default_sclk = adev->clock.default_sclk; | |
| 634 | − adev->pm.default_mclk = adev->clock.default_mclk; | |
| 635 | − adev->pm.current_sclk = adev->clock.default_sclk; | |
| 636 | − adev->pm.current_mclk = adev->clock.default_mclk; | |
| 637 | − adev->pm.int_thermal_type = THERMAL_TYPE_NONE; | |
| 638 | − | |
| 639 | − if (amdgpu_dpm == 0) | |
| 640 | − return 0; | |
| 641 | − | |
| 642 | − mutex_lock(&adev->pm.mutex); | |
| 643 | − ret = cz_dpm_init(adev); | |
| 644 | − if (ret) | |
| 645 | − goto dpm_init_failed; | |
| 646 | − | |
| 647 | − adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps; | |
| 648 | − if (amdgpu_dpm == 1) | |
| 649 | − amdgpu_pm_print_power_states(adev); | |
| 650 | − | |
| 651 | − mutex_unlock(&adev->pm.mutex); | |
| 652 | − DRM_INFO("amdgpu: dpm initialized\n"); | |
| 653 | − | |
| 654 | − return 0; | |
| 655 | − | |
| 656 | −dpm_init_failed: | |
| 657 | − cz_dpm_fini(adev); | |
| 658 | − mutex_unlock(&adev->pm.mutex); | |
| 659 | − DRM_ERROR("amdgpu: dpm initialization failed\n"); | |
| 660 | − | |
| 661 | − return ret; | |
| 662 | −} | |
| 663 | − | |
| 664 | −static int cz_dpm_sw_fini(void *handle) | |
| 665 | −{ | |
| 666 | − struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 667 | − | |
| 668 | − mutex_lock(&adev->pm.mutex); | |
| 669 | − amdgpu_pm_sysfs_fini(adev); | |
| 670 | − cz_dpm_fini(adev); | |
| 671 | − mutex_unlock(&adev->pm.mutex); | |
| 672 | − | |
| 673 | − return 0; | |
| 674 | −} | |
| 675 | − | |
| 676 | −static void cz_reset_ap_mask(struct amdgpu_device *adev) | |
| 677 | −{ | |
| 678 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 679 | − | |
| 680 | − pi->active_process_mask = 0; | |
| 681 | −} | |
| 682 | − | |
| 683 | −static int cz_dpm_download_pptable_from_smu(struct amdgpu_device *adev, | |
| 684 | − void **table) | |
| 685 | −{ | |
| 686 | − return cz_smu_download_pptable(adev, table); | |
| 687 | −} | |
| 688 | − | |
| 689 | −static int cz_dpm_upload_pptable_to_smu(struct amdgpu_device *adev) | |
| 690 | −{ | |
| 691 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 692 | − struct SMU8_Fusion_ClkTable *clock_table; | |
| 693 | − struct atom_clock_dividers dividers; | |
| 694 | − void *table = NULL; | |
| 695 | − uint8_t i = 0; | |
| 696 | − int ret = 0; | |
| 697 | − | |
| 698 | − struct amdgpu_clock_voltage_dependency_table *vddc_table = | |
| 699 | − &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk; | |
| 700 | − struct amdgpu_clock_voltage_dependency_table *vddgfx_table = | |
| 701 | − &adev->pm.dpm.dyn_state.vddgfx_dependency_on_sclk; | |
| 702 | − struct amdgpu_uvd_clock_voltage_dependency_table *uvd_table = | |
| 703 | − &adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table; | |
| 704 | − struct amdgpu_vce_clock_voltage_dependency_table *vce_table = | |
| 705 | − &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table; | |
| 706 | − struct amdgpu_clock_voltage_dependency_table *acp_table = | |
| 707 | − &adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table; | |
| 708 | − | |
| 709 | − if (!pi->need_pptable_upload) | |
| 710 | − return 0; | |
| 711 | − | |
| 712 | − ret = cz_dpm_download_pptable_from_smu(adev, &table); | |
| 713 | − if (ret) { | |
| 714 | − DRM_ERROR("amdgpu: Failed to get power play table from SMU!\n"); | |
| 715 | − return -EINVAL; | |
| 716 | − } | |
| 717 | − | |
| 718 | − clock_table = (struct SMU8_Fusion_ClkTable *)table; | |
| 719 | − /* patch clock table */ | |
| 720 | − if (vddc_table->count > CZ_MAX_HARDWARE_POWERLEVELS || | |
| 721 | − vddgfx_table->count > CZ_MAX_HARDWARE_POWERLEVELS || | |
| 722 | − uvd_table->count > CZ_MAX_HARDWARE_POWERLEVELS || | |
| 723 | − vce_table->count > CZ_MAX_HARDWARE_POWERLEVELS || | |
| 724 | − acp_table->count > CZ_MAX_HARDWARE_POWERLEVELS) { | |
| 725 | − DRM_ERROR("amdgpu: Invalid Clock Voltage Dependency Table!\n"); | |
| 726 | − return -EINVAL; | |
| 727 | − } | |
| 728 | − | |
| 729 | − for (i = 0; i < CZ_MAX_HARDWARE_POWERLEVELS; i++) { | |
| 730 | − | |
| 731 | − /* vddc sclk */ | |
| 732 | − clock_table->SclkBreakdownTable.ClkLevel[i].GnbVid = | |
| 733 | − (i < vddc_table->count) ? (uint8_t)vddc_table->entries[i].v : 0; | |
| 734 | − clock_table->SclkBreakdownTable.ClkLevel[i].Frequency = | |
| 735 | − (i < vddc_table->count) ? vddc_table->entries[i].clk : 0; | |
| 736 | − ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK, | |
| 737 | − clock_table->SclkBreakdownTable.ClkLevel[i].Frequency, | |
| 738 | − false, ÷rs); | |
| 739 | − if (ret) | |
| 740 | − return ret; | |
| 741 | − clock_table->SclkBreakdownTable.ClkLevel[i].DfsDid = | |
| 742 | − (uint8_t)dividers.post_divider; | |
| 743 | − | |
| 744 | − /* vddgfx sclk */ | |
| 745 | − clock_table->SclkBreakdownTable.ClkLevel[i].GfxVid = | |
| 746 | − (i < vddgfx_table->count) ? (uint8_t)vddgfx_table->entries[i].v : 0; | |
| 747 | − | |
| 748 | − /* acp breakdown */ | |
| 749 | − clock_table->AclkBreakdownTable.ClkLevel[i].GfxVid = | |
| 750 | − (i < acp_table->count) ? (uint8_t)acp_table->entries[i].v : 0; | |
| 751 | − clock_table->AclkBreakdownTable.ClkLevel[i].Frequency = | |
| 752 | − (i < acp_table->count) ? acp_table->entries[i].clk : 0; | |
| 753 | − ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK, | |
| 754 | − clock_table->SclkBreakdownTable.ClkLevel[i].Frequency, | |
| 755 | − false, ÷rs); | |
| 756 | − if (ret) | |
| 757 | − return ret; | |
| 758 | − clock_table->AclkBreakdownTable.ClkLevel[i].DfsDid = | |
| 759 | − (uint8_t)dividers.post_divider; | |
| 760 | − | |
| 761 | − /* uvd breakdown */ | |
| 762 | − clock_table->VclkBreakdownTable.ClkLevel[i].GfxVid = | |
| 763 | − (i < uvd_table->count) ? (uint8_t)uvd_table->entries[i].v : 0; | |
| 764 | − clock_table->VclkBreakdownTable.ClkLevel[i].Frequency = | |
| 765 | − (i < uvd_table->count) ? uvd_table->entries[i].vclk : 0; | |
| 766 | − ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK, | |
| 767 | − clock_table->VclkBreakdownTable.ClkLevel[i].Frequency, | |
| 768 | − false, ÷rs); | |
| 769 | − if (ret) | |
| 770 | − return ret; | |
| 771 | − clock_table->VclkBreakdownTable.ClkLevel[i].DfsDid = | |
| 772 | − (uint8_t)dividers.post_divider; | |
| 773 | − | |
| 774 | − clock_table->DclkBreakdownTable.ClkLevel[i].GfxVid = | |
| 775 | − (i < uvd_table->count) ? (uint8_t)uvd_table->entries[i].v : 0; | |
| 776 | − clock_table->DclkBreakdownTable.ClkLevel[i].Frequency = | |
| 777 | − (i < uvd_table->count) ? uvd_table->entries[i].dclk : 0; | |
| 778 | − ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK, | |
| 779 | − clock_table->DclkBreakdownTable.ClkLevel[i].Frequency, | |
| 780 | − false, ÷rs); | |
| 781 | − if (ret) | |
| 782 | − return ret; | |
| 783 | − clock_table->DclkBreakdownTable.ClkLevel[i].DfsDid = | |
| 784 | − (uint8_t)dividers.post_divider; | |
| 785 | − | |
| 786 | − /* vce breakdown */ | |
| 787 | − clock_table->EclkBreakdownTable.ClkLevel[i].GfxVid = | |
| 788 | − (i < vce_table->count) ? (uint8_t)vce_table->entries[i].v : 0; | |
| 789 | − clock_table->EclkBreakdownTable.ClkLevel[i].Frequency = | |
| 790 | − (i < vce_table->count) ? vce_table->entries[i].ecclk : 0; | |
| 791 | − ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK, | |
| 792 | − clock_table->EclkBreakdownTable.ClkLevel[i].Frequency, | |
| 793 | − false, ÷rs); | |
| 794 | − if (ret) | |
| 795 | − return ret; | |
| 796 | − clock_table->EclkBreakdownTable.ClkLevel[i].DfsDid = | |
| 797 | − (uint8_t)dividers.post_divider; | |
| 798 | − } | |
| 799 | − | |
| 800 | − /* its time to upload to SMU */ | |
| 801 | − ret = cz_smu_upload_pptable(adev); | |
| 802 | − if (ret) { | |
| 803 | − DRM_ERROR("amdgpu: Failed to put power play table to SMU!\n"); | |
| 804 | − return ret; | |
| 805 | − } | |
| 806 | − | |
| 807 | − return 0; | |
| 808 | −} | |
| 809 | − | |
| 810 | −static void cz_init_sclk_limit(struct amdgpu_device *adev) | |
| 811 | −{ | |
| 812 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 813 | − struct amdgpu_clock_voltage_dependency_table *table = | |
| 814 | − &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk; | |
| 815 | − uint32_t clock = 0, level; | |
| 816 | − | |
| 817 | − if (!table || !table->count) { | |
| 818 | − DRM_ERROR("Invalid Voltage Dependency table.\n"); | |
| 819 | − return; | |
| 820 | − } | |
| 821 | − | |
| 822 | − pi->sclk_dpm.soft_min_clk = 0; | |
| 823 | − pi->sclk_dpm.hard_min_clk = 0; | |
| 824 | − cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxSclkLevel); | |
| 825 | − level = cz_get_argument(adev); | |
| 826 | − if (level < table->count) { | |
| 827 | − clock = table->entries[level].clk; | |
| 828 | − } else { | |
| 829 | − DRM_ERROR("Invalid SLCK Voltage Dependency table entry.\n"); | |
| 830 | − clock = table->entries[table->count - 1].clk; | |
| 831 | − } | |
| 832 | − | |
| 833 | − pi->sclk_dpm.soft_max_clk = clock; | |
| 834 | − pi->sclk_dpm.hard_max_clk = clock; | |
| 835 | − | |
| 836 | −} | |
| 837 | − | |
| 838 | −static void cz_init_uvd_limit(struct amdgpu_device *adev) | |
| 839 | −{ | |
| 840 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 841 | − struct amdgpu_uvd_clock_voltage_dependency_table *table = | |
| 842 | − &adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table; | |
| 843 | − uint32_t clock = 0, level; | |
| 844 | − | |
| 845 | − if (!table || !table->count) { | |
| 846 | − DRM_ERROR("Invalid Voltage Dependency table.\n"); | |
| 847 | − return; | |
| 848 | − } | |
| 849 | − | |
| 850 | − pi->uvd_dpm.soft_min_clk = 0; | |
| 851 | − pi->uvd_dpm.hard_min_clk = 0; | |
| 852 | − cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxUvdLevel); | |
| 853 | − level = cz_get_argument(adev); | |
| 854 | − if (level < table->count) { | |
| 855 | − clock = table->entries[level].vclk; | |
| 856 | − } else { | |
| 857 | − DRM_ERROR("Invalid UVD Voltage Dependency table entry.\n"); | |
| 858 | − clock = table->entries[table->count - 1].vclk; | |
| 859 | − } | |
| 860 | − | |
| 861 | − pi->uvd_dpm.soft_max_clk = clock; | |
| 862 | − pi->uvd_dpm.hard_max_clk = clock; | |
| 863 | − | |
| 864 | −} | |
| 865 | − | |
| 866 | −static void cz_init_vce_limit(struct amdgpu_device *adev) | |
| 867 | −{ | |
| 868 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 869 | − struct amdgpu_vce_clock_voltage_dependency_table *table = | |
| 870 | − &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table; | |
| 871 | − uint32_t clock = 0, level; | |
| 872 | − | |
| 873 | − if (!table || !table->count) { | |
| 874 | − DRM_ERROR("Invalid Voltage Dependency table.\n"); | |
| 875 | − return; | |
| 876 | − } | |
| 877 | − | |
| 878 | − pi->vce_dpm.soft_min_clk = table->entries[0].ecclk; | |
| 879 | − pi->vce_dpm.hard_min_clk = table->entries[0].ecclk; | |
| 880 | − cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxEclkLevel); | |
| 881 | − level = cz_get_argument(adev); | |
| 882 | − if (level < table->count) { | |
| 883 | − clock = table->entries[level].ecclk; | |
| 884 | − } else { | |
| 885 | − /* future BIOS would fix this error */ | |
| 886 | − DRM_ERROR("Invalid VCE Voltage Dependency table entry.\n"); | |
| 887 | − clock = table->entries[table->count - 1].ecclk; | |
| 888 | − } | |
| 889 | − | |
| 890 | − pi->vce_dpm.soft_max_clk = clock; | |
| 891 | − pi->vce_dpm.hard_max_clk = clock; | |
| 892 | − | |
| 893 | −} | |
| 894 | − | |
| 895 | −static void cz_init_acp_limit(struct amdgpu_device *adev) | |
| 896 | −{ | |
| 897 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 898 | − struct amdgpu_clock_voltage_dependency_table *table = | |
| 899 | − &adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table; | |
| 900 | − uint32_t clock = 0, level; | |
| 901 | − | |
| 902 | − if (!table || !table->count) { | |
| 903 | − DRM_ERROR("Invalid Voltage Dependency table.\n"); | |
| 904 | − return; | |
| 905 | − } | |
| 906 | − | |
| 907 | − pi->acp_dpm.soft_min_clk = 0; | |
| 908 | − pi->acp_dpm.hard_min_clk = 0; | |
| 909 | − cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxAclkLevel); | |
| 910 | − level = cz_get_argument(adev); | |
| 911 | − if (level < table->count) { | |
| 912 | − clock = table->entries[level].clk; | |
| 913 | − } else { | |
| 914 | − DRM_ERROR("Invalid ACP Voltage Dependency table entry.\n"); | |
| 915 | − clock = table->entries[table->count - 1].clk; | |
| 916 | − } | |
| 917 | − | |
| 918 | − pi->acp_dpm.soft_max_clk = clock; | |
| 919 | − pi->acp_dpm.hard_max_clk = clock; | |
| 920 | − | |
| 921 | −} | |
| 922 | − | |
| 923 | −static void cz_init_pg_state(struct amdgpu_device *adev) | |
| 924 | −{ | |
| 925 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 926 | − | |
| 927 | − pi->uvd_power_gated = false; | |
| 928 | − pi->vce_power_gated = false; | |
| 929 | − pi->acp_power_gated = false; | |
| 930 | − | |
| 931 | −} | |
| 932 | − | |
| 933 | −static void cz_init_sclk_threshold(struct amdgpu_device *adev) | |
| 934 | −{ | |
| 935 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 936 | − | |
| 937 | − pi->low_sclk_interrupt_threshold = 0; | |
| 938 | −} | |
| 939 | − | |
| 940 | −static void cz_dpm_setup_asic(struct amdgpu_device *adev) | |
| 941 | −{ | |
| 942 | − cz_reset_ap_mask(adev); | |
| 943 | − cz_dpm_upload_pptable_to_smu(adev); | |
| 944 | − cz_init_sclk_limit(adev); | |
| 945 | − cz_init_uvd_limit(adev); | |
| 946 | − cz_init_vce_limit(adev); | |
| 947 | − cz_init_acp_limit(adev); | |
| 948 | − cz_init_pg_state(adev); | |
| 949 | − cz_init_sclk_threshold(adev); | |
| 950 | − | |
| 951 | −} | |
| 952 | − | |
| 953 | −static bool cz_check_smu_feature(struct amdgpu_device *adev, | |
| 954 | − uint32_t feature) | |
| 955 | −{ | |
| 956 | − uint32_t smu_feature = 0; | |
| 957 | − int ret; | |
| 958 | − | |
| 959 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 960 | − PPSMC_MSG_GetFeatureStatus, 0); | |
| 961 | − if (ret) { | |
| 962 | − DRM_ERROR("Failed to get SMU features from SMC.\n"); | |
| 963 | − return false; | |
| 964 | − } else { | |
| 965 | − smu_feature = cz_get_argument(adev); | |
| 966 | − if (feature & smu_feature) | |
| 967 | − return true; | |
| 968 | − } | |
| 969 | − | |
| 970 | − return false; | |
| 971 | −} | |
| 972 | − | |
| 973 | −static bool cz_check_for_dpm_enabled(struct amdgpu_device *adev) | |
| 974 | −{ | |
| 975 | − if (cz_check_smu_feature(adev, | |
| 976 | − SMU_EnabledFeatureScoreboard_SclkDpmOn)) | |
| 977 | − return true; | |
| 978 | − | |
| 979 | − return false; | |
| 980 | −} | |
| 981 | − | |
| 982 | −static void cz_program_voting_clients(struct amdgpu_device *adev) | |
| 983 | −{ | |
| 984 | − WREG32_SMC(ixCG_FREQ_TRAN_VOTING_0, PPCZ_VOTINGRIGHTSCLIENTS_DFLT0); | |
| 985 | −} | |
| 986 | − | |
| 987 | −static void cz_clear_voting_clients(struct amdgpu_device *adev) | |
| 988 | −{ | |
| 989 | − WREG32_SMC(ixCG_FREQ_TRAN_VOTING_0, 0); | |
| 990 | −} | |
| 991 | − | |
| 992 | −static int cz_start_dpm(struct amdgpu_device *adev) | |
| 993 | −{ | |
| 994 | − int ret = 0; | |
| 995 | − | |
| 996 | − if (amdgpu_dpm) { | |
| 997 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 998 | − PPSMC_MSG_EnableAllSmuFeatures, SCLK_DPM_MASK); | |
| 999 | − if (ret) { | |
| 1000 | − DRM_ERROR("SMU feature: SCLK_DPM enable failed\n"); | |
| 1001 | − return -EINVAL; | |
| 1002 | − } | |
| 1003 | − } | |
| 1004 | − | |
| 1005 | − return 0; | |
| 1006 | −} | |
| 1007 | − | |
| 1008 | −static int cz_stop_dpm(struct amdgpu_device *adev) | |
| 1009 | −{ | |
| 1010 | − int ret = 0; | |
| 1011 | − | |
| 1012 | − if (amdgpu_dpm && adev->pm.dpm_enabled) { | |
| 1013 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1014 | − PPSMC_MSG_DisableAllSmuFeatures, SCLK_DPM_MASK); | |
| 1015 | − if (ret) { | |
| 1016 | − DRM_ERROR("SMU feature: SCLK_DPM disable failed\n"); | |
| 1017 | − return -EINVAL; | |
| 1018 | − } | |
| 1019 | − } | |
| 1020 | − | |
| 1021 | − return 0; | |
| 1022 | −} | |
| 1023 | − | |
| 1024 | −static uint32_t cz_get_sclk_level(struct amdgpu_device *adev, | |
| 1025 | − uint32_t clock, uint16_t msg) | |
| 1026 | −{ | |
| 1027 | − int i = 0; | |
| 1028 | − struct amdgpu_clock_voltage_dependency_table *table = | |
| 1029 | − &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk; | |
| 1030 | − | |
| 1031 | − switch (msg) { | |
| 1032 | − case PPSMC_MSG_SetSclkSoftMin: | |
| 1033 | − case PPSMC_MSG_SetSclkHardMin: | |
| 1034 | − for (i = 0; i < table->count; i++) | |
| 1035 | − if (clock <= table->entries[i].clk) | |
| 1036 | − break; | |
| 1037 | − if (i == table->count) | |
| 1038 | − i = table->count - 1; | |
| 1039 | − break; | |
| 1040 | − case PPSMC_MSG_SetSclkSoftMax: | |
| 1041 | − case PPSMC_MSG_SetSclkHardMax: | |
| 1042 | − for (i = table->count - 1; i >= 0; i--) | |
| 1043 | − if (clock >= table->entries[i].clk) | |
| 1044 | − break; | |
| 1045 | − if (i < 0) | |
| 1046 | − i = 0; | |
| 1047 | − break; | |
| 1048 | − default: | |
| 1049 | − break; | |
| 1050 | − } | |
| 1051 | − | |
| 1052 | − return i; | |
| 1053 | −} | |
| 1054 | − | |
| 1055 | −static uint32_t cz_get_eclk_level(struct amdgpu_device *adev, | |
| 1056 | − uint32_t clock, uint16_t msg) | |
| 1057 | −{ | |
| 1058 | − int i = 0; | |
| 1059 | − struct amdgpu_vce_clock_voltage_dependency_table *table = | |
| 1060 | − &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table; | |
| 1061 | − | |
| 1062 | − if (table->count == 0) | |
| 1063 | − return 0; | |
| 1064 | − | |
| 1065 | − switch (msg) { | |
| 1066 | − case PPSMC_MSG_SetEclkSoftMin: | |
| 1067 | − case PPSMC_MSG_SetEclkHardMin: | |
| 1068 | − for (i = 0; i < table->count-1; i++) | |
| 1069 | − if (clock <= table->entries[i].ecclk) | |
| 1070 | − break; | |
| 1071 | − break; | |
| 1072 | − case PPSMC_MSG_SetEclkSoftMax: | |
| 1073 | − case PPSMC_MSG_SetEclkHardMax: | |
| 1074 | − for (i = table->count - 1; i > 0; i--) | |
| 1075 | − if (clock >= table->entries[i].ecclk) | |
| 1076 | − break; | |
| 1077 | − break; | |
| 1078 | − default: | |
| 1079 | − break; | |
| 1080 | − } | |
| 1081 | − | |
| 1082 | − return i; | |
| 1083 | −} | |
| 1084 | − | |
| 1085 | −static uint32_t cz_get_uvd_level(struct amdgpu_device *adev, | |
| 1086 | − uint32_t clock, uint16_t msg) | |
| 1087 | −{ | |
| 1088 | − int i = 0; | |
| 1089 | − struct amdgpu_uvd_clock_voltage_dependency_table *table = | |
| 1090 | − &adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table; | |
| 1091 | − | |
| 1092 | − switch (msg) { | |
| 1093 | − case PPSMC_MSG_SetUvdSoftMin: | |
| 1094 | − case PPSMC_MSG_SetUvdHardMin: | |
| 1095 | − for (i = 0; i < table->count; i++) | |
| 1096 | − if (clock <= table->entries[i].vclk) | |
| 1097 | − break; | |
| 1098 | − if (i == table->count) | |
| 1099 | − i = table->count - 1; | |
| 1100 | − break; | |
| 1101 | − case PPSMC_MSG_SetUvdSoftMax: | |
| 1102 | − case PPSMC_MSG_SetUvdHardMax: | |
| 1103 | − for (i = table->count - 1; i >= 0; i--) | |
| 1104 | − if (clock >= table->entries[i].vclk) | |
| 1105 | − break; | |
| 1106 | − if (i < 0) | |
| 1107 | − i = 0; | |
| 1108 | − break; | |
| 1109 | − default: | |
| 1110 | − break; | |
| 1111 | − } | |
| 1112 | − | |
| 1113 | − return i; | |
| 1114 | −} | |
| 1115 | − | |
| 1116 | −static int cz_program_bootup_state(struct amdgpu_device *adev) | |
| 1117 | −{ | |
| 1118 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1119 | − uint32_t soft_min_clk = 0; | |
| 1120 | − uint32_t soft_max_clk = 0; | |
| 1121 | − int ret = 0; | |
| 1122 | − | |
| 1123 | − pi->sclk_dpm.soft_min_clk = pi->sys_info.bootup_sclk; | |
| 1124 | − pi->sclk_dpm.soft_max_clk = pi->sys_info.bootup_sclk; | |
| 1125 | − | |
| 1126 | − soft_min_clk = cz_get_sclk_level(adev, | |
| 1127 | − pi->sclk_dpm.soft_min_clk, | |
| 1128 | − PPSMC_MSG_SetSclkSoftMin); | |
| 1129 | − soft_max_clk = cz_get_sclk_level(adev, | |
| 1130 | − pi->sclk_dpm.soft_max_clk, | |
| 1131 | − PPSMC_MSG_SetSclkSoftMax); | |
| 1132 | − | |
| 1133 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1134 | − PPSMC_MSG_SetSclkSoftMin, soft_min_clk); | |
| 1135 | − if (ret) | |
| 1136 | − return -EINVAL; | |
| 1137 | − | |
| 1138 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1139 | − PPSMC_MSG_SetSclkSoftMax, soft_max_clk); | |
| 1140 | − if (ret) | |
| 1141 | − return -EINVAL; | |
| 1142 | − | |
| 1143 | − return 0; | |
| 1144 | −} | |
| 1145 | − | |
| 1146 | −/* TODO */ | |
| 1147 | −static int cz_disable_cgpg(struct amdgpu_device *adev) | |
| 1148 | −{ | |
| 1149 | − return 0; | |
| 1150 | −} | |
| 1151 | − | |
| 1152 | −/* TODO */ | |
| 1153 | −static int cz_enable_cgpg(struct amdgpu_device *adev) | |
| 1154 | −{ | |
| 1155 | − return 0; | |
| 1156 | −} | |
| 1157 | − | |
| 1158 | −/* TODO */ | |
| 1159 | −static int cz_program_pt_config_registers(struct amdgpu_device *adev) | |
| 1160 | −{ | |
| 1161 | − return 0; | |
| 1162 | −} | |
| 1163 | − | |
| 1164 | −static void cz_do_enable_didt(struct amdgpu_device *adev, bool enable) | |
| 1165 | −{ | |
| 1166 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1167 | − uint32_t reg = 0; | |
| 1168 | − | |
| 1169 | − if (pi->caps_sq_ramping) { | |
| 1170 | − reg = RREG32_DIDT(ixDIDT_SQ_CTRL0); | |
| 1171 | − if (enable) | |
| 1172 | − reg = REG_SET_FIELD(reg, DIDT_SQ_CTRL0, DIDT_CTRL_EN, 1); | |
| 1173 | − else | |
| 1174 | − reg = REG_SET_FIELD(reg, DIDT_SQ_CTRL0, DIDT_CTRL_EN, 0); | |
| 1175 | − WREG32_DIDT(ixDIDT_SQ_CTRL0, reg); | |
| 1176 | − } | |
| 1177 | − if (pi->caps_db_ramping) { | |
| 1178 | − reg = RREG32_DIDT(ixDIDT_DB_CTRL0); | |
| 1179 | − if (enable) | |
| 1180 | − reg = REG_SET_FIELD(reg, DIDT_DB_CTRL0, DIDT_CTRL_EN, 1); | |
| 1181 | − else | |
| 1182 | − reg = REG_SET_FIELD(reg, DIDT_DB_CTRL0, DIDT_CTRL_EN, 0); | |
| 1183 | − WREG32_DIDT(ixDIDT_DB_CTRL0, reg); | |
| 1184 | − } | |
| 1185 | − if (pi->caps_td_ramping) { | |
| 1186 | − reg = RREG32_DIDT(ixDIDT_TD_CTRL0); | |
| 1187 | − if (enable) | |
| 1188 | − reg = REG_SET_FIELD(reg, DIDT_TD_CTRL0, DIDT_CTRL_EN, 1); | |
| 1189 | − else | |
| 1190 | − reg = REG_SET_FIELD(reg, DIDT_TD_CTRL0, DIDT_CTRL_EN, 0); | |
| 1191 | − WREG32_DIDT(ixDIDT_TD_CTRL0, reg); | |
| 1192 | − } | |
| 1193 | − if (pi->caps_tcp_ramping) { | |
| 1194 | − reg = RREG32_DIDT(ixDIDT_TCP_CTRL0); | |
| 1195 | − if (enable) | |
| 1196 | − reg = REG_SET_FIELD(reg, DIDT_SQ_CTRL0, DIDT_CTRL_EN, 1); | |
| 1197 | − else | |
| 1198 | − reg = REG_SET_FIELD(reg, DIDT_SQ_CTRL0, DIDT_CTRL_EN, 0); | |
| 1199 | − WREG32_DIDT(ixDIDT_TCP_CTRL0, reg); | |
| 1200 | − } | |
| 1201 | − | |
| 1202 | −} | |
| 1203 | − | |
| 1204 | −static int cz_enable_didt(struct amdgpu_device *adev, bool enable) | |
| 1205 | −{ | |
| 1206 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1207 | − int ret; | |
| 1208 | − | |
| 1209 | − if (pi->caps_sq_ramping || pi->caps_db_ramping || | |
| 1210 | − pi->caps_td_ramping || pi->caps_tcp_ramping) { | |
| 1211 | − if (adev->gfx.gfx_current_status != AMDGPU_GFX_SAFE_MODE) { | |
| 1212 | − ret = cz_disable_cgpg(adev); | |
| 1213 | − if (ret) { | |
| 1214 | − DRM_ERROR("Pre Di/Dt disable cg/pg failed\n"); | |
| 1215 | − return -EINVAL; | |
| 1216 | − } | |
| 1217 | − adev->gfx.gfx_current_status = AMDGPU_GFX_SAFE_MODE; | |
| 1218 | − } | |
| 1219 | − | |
| 1220 | − ret = cz_program_pt_config_registers(adev); | |
| 1221 | − if (ret) { | |
| 1222 | − DRM_ERROR("Di/Dt config failed\n"); | |
| 1223 | − return -EINVAL; | |
| 1224 | − } | |
| 1225 | − cz_do_enable_didt(adev, enable); | |
| 1226 | − | |
| 1227 | − if (adev->gfx.gfx_current_status == AMDGPU_GFX_SAFE_MODE) { | |
| 1228 | − ret = cz_enable_cgpg(adev); | |
| 1229 | − if (ret) { | |
| 1230 | − DRM_ERROR("Post Di/Dt enable cg/pg failed\n"); | |
| 1231 | − return -EINVAL; | |
| 1232 | − } | |
| 1233 | − adev->gfx.gfx_current_status = AMDGPU_GFX_NORMAL_MODE; | |
| 1234 | − } | |
| 1235 | − } | |
| 1236 | − | |
| 1237 | − return 0; | |
| 1238 | −} | |
| 1239 | − | |
| 1240 | −/* TODO */ | |
| 1241 | −static void cz_reset_acp_boot_level(struct amdgpu_device *adev) | |
| 1242 | −{ | |
| 1243 | −} | |
| 1244 | − | |
| 1245 | −static void cz_update_current_ps(struct amdgpu_device *adev, | |
| 1246 | − struct amdgpu_ps *rps) | |
| 1247 | −{ | |
| 1248 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1249 | − struct cz_ps *ps = cz_get_ps(rps); | |
| 1250 | − | |
| 1251 | − pi->current_ps = *ps; | |
| 1252 | − pi->current_rps = *rps; | |
| 1253 | − pi->current_rps.ps_priv = &pi->current_ps; | |
| 1254 | − adev->pm.dpm.current_ps = &pi->current_rps; | |
| 1255 | − | |
| 1256 | −} | |
| 1257 | − | |
| 1258 | −static void cz_update_requested_ps(struct amdgpu_device *adev, | |
| 1259 | − struct amdgpu_ps *rps) | |
| 1260 | −{ | |
| 1261 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1262 | − struct cz_ps *ps = cz_get_ps(rps); | |
| 1263 | − | |
| 1264 | − pi->requested_ps = *ps; | |
| 1265 | − pi->requested_rps = *rps; | |
| 1266 | − pi->requested_rps.ps_priv = &pi->requested_ps; | |
| 1267 | − adev->pm.dpm.requested_ps = &pi->requested_rps; | |
| 1268 | − | |
| 1269 | −} | |
| 1270 | − | |
| 1271 | −/* PP arbiter support needed TODO */ | |
| 1272 | −static void cz_apply_state_adjust_rules(struct amdgpu_device *adev, | |
| 1273 | − struct amdgpu_ps *new_rps, | |
| 1274 | − struct amdgpu_ps *old_rps) | |
| 1275 | −{ | |
| 1276 | − struct cz_ps *ps = cz_get_ps(new_rps); | |
| 1277 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1278 | − struct amdgpu_clock_and_voltage_limits *limits = | |
| 1279 | − &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | |
| 1280 | − /* 10kHz memory clock */ | |
| 1281 | − uint32_t mclk = 0; | |
| 1282 | − | |
| 1283 | − ps->force_high = false; | |
| 1284 | − ps->need_dfs_bypass = true; | |
| 1285 | − pi->video_start = new_rps->dclk || new_rps->vclk || | |
| 1286 | − new_rps->evclk || new_rps->ecclk; | |
| 1287 | − | |
| 1288 | − if ((new_rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) == | |
| 1289 | − ATOM_PPLIB_CLASSIFICATION_UI_BATTERY) | |
| 1290 | − pi->battery_state = true; | |
| 1291 | − else | |
| 1292 | − pi->battery_state = false; | |
| 1293 | − | |
| 1294 | − if (pi->caps_stable_power_state) | |
| 1295 | − mclk = limits->mclk; | |
| 1296 | − | |
| 1297 | − if (mclk > pi->sys_info.nbp_memory_clock[CZ_NUM_NBPMEMORY_CLOCK - 1]) | |
| 1298 | − ps->force_high = true; | |
| 1299 | − | |
| 1300 | −} | |
| 1301 | − | |
| 1302 | −static int cz_dpm_enable(struct amdgpu_device *adev) | |
| 1303 | −{ | |
| 1304 | − const char *chip_name; | |
| 1305 | − int ret = 0; | |
| 1306 | − | |
| 1307 | − /* renable will hang up SMU, so check first */ | |
| 1308 | − if (cz_check_for_dpm_enabled(adev)) | |
| 1309 | − return -EINVAL; | |
| 1310 | − | |
| 1311 | − cz_program_voting_clients(adev); | |
| 1312 | − | |
| 1313 | − switch (adev->asic_type) { | |
| 1314 | − case CHIP_CARRIZO: | |
| 1315 | − chip_name = "carrizo"; | |
| 1316 | − break; | |
| 1317 | − case CHIP_STONEY: | |
| 1318 | − chip_name = "stoney"; | |
| 1319 | − break; | |
| 1320 | − default: | |
| 1321 | − BUG(); | |
| 1322 | − } | |
| 1323 | − | |
| 1324 | − | |
| 1325 | − ret = cz_start_dpm(adev); | |
| 1326 | − if (ret) { | |
| 1327 | − DRM_ERROR("%s DPM enable failed\n", chip_name); | |
| 1328 | − return -EINVAL; | |
| 1329 | − } | |
| 1330 | − | |
| 1331 | − ret = cz_program_bootup_state(adev); | |
| 1332 | − if (ret) { | |
| 1333 | − DRM_ERROR("%s bootup state program failed\n", chip_name); | |
| 1334 | − return -EINVAL; | |
| 1335 | − } | |
| 1336 | − | |
| 1337 | − ret = cz_enable_didt(adev, true); | |
| 1338 | − if (ret) { | |
| 1339 | − DRM_ERROR("%s enable di/dt failed\n", chip_name); | |
| 1340 | − return -EINVAL; | |
| 1341 | − } | |
| 1342 | − | |
| 1343 | − cz_reset_acp_boot_level(adev); | |
| 1344 | − cz_update_current_ps(adev, adev->pm.dpm.boot_ps); | |
| 1345 | − | |
| 1346 | − return 0; | |
| 1347 | −} | |
| 1348 | − | |
| 1349 | −static int cz_dpm_hw_init(void *handle) | |
| 1350 | −{ | |
| 1351 | − struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1352 | − int ret = 0; | |
| 1353 | − | |
| 1354 | − mutex_lock(&adev->pm.mutex); | |
| 1355 | − | |
| 1356 | − /* smu init only needs to be called at startup, not resume. | |
| 1357 | − * It should be in sw_init, but requires the fw info gathered | |
| 1358 | − * in sw_init from other IP modules. | |
| 1359 | − */ | |
| 1360 | − ret = cz_smu_init(adev); | |
| 1361 | − if (ret) { | |
| 1362 | − DRM_ERROR("amdgpu: smc initialization failed\n"); | |
| 1363 | − mutex_unlock(&adev->pm.mutex); | |
| 1364 | − return ret; | |
| 1365 | − } | |
| 1366 | − | |
| 1367 | − /* do the actual fw loading */ | |
| 1368 | − ret = cz_smu_start(adev); | |
| 1369 | − if (ret) { | |
| 1370 | − DRM_ERROR("amdgpu: smc start failed\n"); | |
| 1371 | − mutex_unlock(&adev->pm.mutex); | |
| 1372 | − return ret; | |
| 1373 | − } | |
| 1374 | − | |
| 1375 | − if (!amdgpu_dpm) { | |
| 1376 | − adev->pm.dpm_enabled = false; | |
| 1377 | − mutex_unlock(&adev->pm.mutex); | |
| 1378 | − return ret; | |
| 1379 | − } | |
| 1380 | − | |
| 1381 | − /* cz dpm setup asic */ | |
| 1382 | − cz_dpm_setup_asic(adev); | |
| 1383 | − | |
| 1384 | − /* cz dpm enable */ | |
| 1385 | − ret = cz_dpm_enable(adev); | |
| 1386 | − if (ret) | |
| 1387 | − adev->pm.dpm_enabled = false; | |
| 1388 | − else | |
| 1389 | − adev->pm.dpm_enabled = true; | |
| 1390 | − | |
| 1391 | − mutex_unlock(&adev->pm.mutex); | |
| 1392 | − | |
| 1393 | − return 0; | |
| 1394 | −} | |
| 1395 | − | |
| 1396 | −static int cz_dpm_disable(struct amdgpu_device *adev) | |
| 1397 | −{ | |
| 1398 | − int ret = 0; | |
| 1399 | − | |
| 1400 | − if (!cz_check_for_dpm_enabled(adev)) | |
| 1401 | − return -EINVAL; | |
| 1402 | − | |
| 1403 | − ret = cz_enable_didt(adev, false); | |
| 1404 | − if (ret) { | |
| 1405 | − DRM_ERROR("disable di/dt failed\n"); | |
| 1406 | − return -EINVAL; | |
| 1407 | − } | |
| 1408 | − | |
| 1409 | − /* powerup blocks */ | |
| 1410 | − cz_dpm_powergate_uvd(adev, false); | |
| 1411 | − cz_dpm_powergate_vce(adev, false); | |
| 1412 | − | |
| 1413 | − cz_clear_voting_clients(adev); | |
| 1414 | − cz_stop_dpm(adev); | |
| 1415 | − cz_update_current_ps(adev, adev->pm.dpm.boot_ps); | |
| 1416 | − | |
| 1417 | − return 0; | |
| 1418 | −} | |
| 1419 | − | |
| 1420 | −static int cz_dpm_hw_fini(void *handle) | |
| 1421 | −{ | |
| 1422 | − int ret = 0; | |
| 1423 | − struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1424 | − | |
| 1425 | − mutex_lock(&adev->pm.mutex); | |
| 1426 | − | |
| 1427 | − /* smu fini only needs to be called at teardown, not suspend. | |
| 1428 | − * It should be in sw_fini, but we put it here for symmetry | |
| 1429 | − * with smu init. | |
| 1430 | − */ | |
| 1431 | − cz_smu_fini(adev); | |
| 1432 | − | |
| 1433 | − if (adev->pm.dpm_enabled) { | |
| 1434 | − ret = cz_dpm_disable(adev); | |
| 1435 | − | |
| 1436 | − adev->pm.dpm.current_ps = | |
| 1437 | − adev->pm.dpm.requested_ps = | |
| 1438 | − adev->pm.dpm.boot_ps; | |
| 1439 | − } | |
| 1440 | − | |
| 1441 | − adev->pm.dpm_enabled = false; | |
| 1442 | − | |
| 1443 | − mutex_unlock(&adev->pm.mutex); | |
| 1444 | − | |
| 1445 | − return ret; | |
| 1446 | −} | |
| 1447 | − | |
| 1448 | −static int cz_dpm_suspend(void *handle) | |
| 1449 | −{ | |
| 1450 | − int ret = 0; | |
| 1451 | − struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1452 | − | |
| 1453 | − if (adev->pm.dpm_enabled) { | |
| 1454 | − mutex_lock(&adev->pm.mutex); | |
| 1455 | − | |
| 1456 | − ret = cz_dpm_disable(adev); | |
| 1457 | − | |
| 1458 | − adev->pm.dpm.current_ps = | |
| 1459 | − adev->pm.dpm.requested_ps = | |
| 1460 | − adev->pm.dpm.boot_ps; | |
| 1461 | − | |
| 1462 | − mutex_unlock(&adev->pm.mutex); | |
| 1463 | − } | |
| 1464 | − | |
| 1465 | − return ret; | |
| 1466 | −} | |
| 1467 | − | |
| 1468 | −static int cz_dpm_resume(void *handle) | |
| 1469 | −{ | |
| 1470 | − int ret = 0; | |
| 1471 | − struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1472 | − | |
| 1473 | − mutex_lock(&adev->pm.mutex); | |
| 1474 | − | |
| 1475 | − /* do the actual fw loading */ | |
| 1476 | − ret = cz_smu_start(adev); | |
| 1477 | − if (ret) { | |
| 1478 | − DRM_ERROR("amdgpu: smc start failed\n"); | |
| 1479 | − mutex_unlock(&adev->pm.mutex); | |
| 1480 | − return ret; | |
| 1481 | − } | |
| 1482 | − | |
| 1483 | − if (!amdgpu_dpm) { | |
| 1484 | − adev->pm.dpm_enabled = false; | |
| 1485 | − mutex_unlock(&adev->pm.mutex); | |
| 1486 | − return ret; | |
| 1487 | − } | |
| 1488 | − | |
| 1489 | − /* cz dpm setup asic */ | |
| 1490 | − cz_dpm_setup_asic(adev); | |
| 1491 | − | |
| 1492 | − /* cz dpm enable */ | |
| 1493 | − ret = cz_dpm_enable(adev); | |
| 1494 | − if (ret) | |
| 1495 | − adev->pm.dpm_enabled = false; | |
| 1496 | − else | |
| 1497 | − adev->pm.dpm_enabled = true; | |
| 1498 | − | |
| 1499 | − mutex_unlock(&adev->pm.mutex); | |
| 1500 | − /* upon resume, re-compute the clocks */ | |
| 1501 | − if (adev->pm.dpm_enabled) | |
| 1502 | − amdgpu_pm_compute_clocks(adev); | |
| 1503 | − | |
| 1504 | − return 0; | |
| 1505 | −} | |
| 1506 | − | |
| 1507 | −static int cz_dpm_set_clockgating_state(void *handle, | |
| 1508 | − enum amd_clockgating_state state) | |
| 1509 | −{ | |
| 1510 | − return 0; | |
| 1511 | −} | |
| 1512 | − | |
| 1513 | −static int cz_dpm_set_powergating_state(void *handle, | |
| 1514 | − enum amd_powergating_state state) | |
| 1515 | −{ | |
| 1516 | − return 0; | |
| 1517 | −} | |
| 1518 | − | |
| 1519 | −static int cz_dpm_get_temperature(struct amdgpu_device *adev) | |
| 1520 | −{ | |
| 1521 | − int actual_temp = 0; | |
| 1522 | − uint32_t val = RREG32_SMC(ixTHM_TCON_CUR_TMP); | |
| 1523 | − uint32_t temp = REG_GET_FIELD(val, THM_TCON_CUR_TMP, CUR_TEMP); | |
| 1524 | − | |
| 1525 | − if (REG_GET_FIELD(val, THM_TCON_CUR_TMP, CUR_TEMP_RANGE_SEL)) | |
| 1526 | − actual_temp = 1000 * ((temp / 8) - 49); | |
| 1527 | − else | |
| 1528 | − actual_temp = 1000 * (temp / 8); | |
| 1529 | − | |
| 1530 | − return actual_temp; | |
| 1531 | −} | |
| 1532 | − | |
| 1533 | −static int cz_dpm_pre_set_power_state(struct amdgpu_device *adev) | |
| 1534 | −{ | |
| 1535 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1536 | − struct amdgpu_ps requested_ps = *adev->pm.dpm.requested_ps; | |
| 1537 | − struct amdgpu_ps *new_ps = &requested_ps; | |
| 1538 | − | |
| 1539 | − cz_update_requested_ps(adev, new_ps); | |
| 1540 | − cz_apply_state_adjust_rules(adev, &pi->requested_rps, | |
| 1541 | − &pi->current_rps); | |
| 1542 | − | |
| 1543 | − return 0; | |
| 1544 | −} | |
| 1545 | − | |
| 1546 | −static int cz_dpm_update_sclk_limit(struct amdgpu_device *adev) | |
| 1547 | −{ | |
| 1548 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1549 | − struct amdgpu_clock_and_voltage_limits *limits = | |
| 1550 | − &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | |
| 1551 | − uint32_t clock, stable_ps_clock = 0; | |
| 1552 | − | |
| 1553 | − clock = pi->sclk_dpm.soft_min_clk; | |
| 1554 | − | |
| 1555 | − if (pi->caps_stable_power_state) { | |
| 1556 | − stable_ps_clock = limits->sclk * 75 / 100; | |
| 1557 | − if (clock < stable_ps_clock) | |
| 1558 | − clock = stable_ps_clock; | |
| 1559 | − } | |
| 1560 | − | |
| 1561 | − if (clock != pi->sclk_dpm.soft_min_clk) { | |
| 1562 | − pi->sclk_dpm.soft_min_clk = clock; | |
| 1563 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 1564 | − PPSMC_MSG_SetSclkSoftMin, | |
| 1565 | − cz_get_sclk_level(adev, clock, | |
| 1566 | − PPSMC_MSG_SetSclkSoftMin)); | |
| 1567 | − } | |
| 1568 | − | |
| 1569 | − if (pi->caps_stable_power_state && | |
| 1570 | − pi->sclk_dpm.soft_max_clk != clock) { | |
| 1571 | − pi->sclk_dpm.soft_max_clk = clock; | |
| 1572 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 1573 | − PPSMC_MSG_SetSclkSoftMax, | |
| 1574 | − cz_get_sclk_level(adev, clock, | |
| 1575 | − PPSMC_MSG_SetSclkSoftMax)); | |
| 1576 | − } else { | |
| 1577 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 1578 | − PPSMC_MSG_SetSclkSoftMax, | |
| 1579 | − cz_get_sclk_level(adev, | |
| 1580 | − pi->sclk_dpm.soft_max_clk, | |
| 1581 | − PPSMC_MSG_SetSclkSoftMax)); | |
| 1582 | − } | |
| 1583 | − | |
| 1584 | − return 0; | |
| 1585 | −} | |
| 1586 | − | |
| 1587 | −static int cz_dpm_set_deep_sleep_sclk_threshold(struct amdgpu_device *adev) | |
| 1588 | −{ | |
| 1589 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1590 | − | |
| 1591 | − if (pi->caps_sclk_ds) { | |
| 1592 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 1593 | − PPSMC_MSG_SetMinDeepSleepSclk, | |
| 1594 | − CZ_MIN_DEEP_SLEEP_SCLK); | |
| 1595 | − } | |
| 1596 | − | |
| 1597 | − return 0; | |
| 1598 | −} | |
| 1599 | − | |
| 1600 | −/* ?? without dal support, is this still needed in setpowerstate list*/ | |
| 1601 | −static int cz_dpm_set_watermark_threshold(struct amdgpu_device *adev) | |
| 1602 | −{ | |
| 1603 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1604 | − | |
| 1605 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 1606 | − PPSMC_MSG_SetWatermarkFrequency, | |
| 1607 | − pi->sclk_dpm.soft_max_clk); | |
| 1608 | − | |
| 1609 | − return 0; | |
| 1610 | −} | |
| 1611 | − | |
| 1612 | −static int cz_dpm_enable_nbdpm(struct amdgpu_device *adev) | |
| 1613 | −{ | |
| 1614 | − int ret = 0; | |
| 1615 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1616 | − | |
| 1617 | − /* also depend on dal NBPStateDisableRequired */ | |
| 1618 | − if (pi->nb_dpm_enabled_by_driver && !pi->nb_dpm_enabled) { | |
| 1619 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1620 | − PPSMC_MSG_EnableAllSmuFeatures, | |
| 1621 | − NB_DPM_MASK); | |
| 1622 | − if (ret) { | |
| 1623 | − DRM_ERROR("amdgpu: nb dpm enable failed\n"); | |
| 1624 | − return ret; | |
| 1625 | − } | |
| 1626 | − pi->nb_dpm_enabled = true; | |
| 1627 | − } | |
| 1628 | − | |
| 1629 | − return ret; | |
| 1630 | −} | |
| 1631 | − | |
| 1632 | −static void cz_dpm_nbdpm_lm_pstate_enable(struct amdgpu_device *adev, | |
| 1633 | − bool enable) | |
| 1634 | −{ | |
| 1635 | − if (enable) | |
| 1636 | − cz_send_msg_to_smc(adev, PPSMC_MSG_EnableLowMemoryPstate); | |
| 1637 | − else | |
| 1638 | − cz_send_msg_to_smc(adev, PPSMC_MSG_DisableLowMemoryPstate); | |
| 1639 | − | |
| 1640 | −} | |
| 1641 | − | |
| 1642 | −static int cz_dpm_update_low_memory_pstate(struct amdgpu_device *adev) | |
| 1643 | −{ | |
| 1644 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1645 | − struct cz_ps *ps = &pi->requested_ps; | |
| 1646 | − | |
| 1647 | − if (pi->sys_info.nb_dpm_enable) { | |
| 1648 | − if (ps->force_high) | |
| 1649 | − cz_dpm_nbdpm_lm_pstate_enable(adev, false); | |
| 1650 | − else | |
| 1651 | − cz_dpm_nbdpm_lm_pstate_enable(adev, true); | |
| 1652 | − } | |
| 1653 | − | |
| 1654 | − return 0; | |
| 1655 | −} | |
| 1656 | − | |
| 1657 | −/* with dpm enabled */ | |
| 1658 | −static int cz_dpm_set_power_state(struct amdgpu_device *adev) | |
| 1659 | −{ | |
| 1660 | − cz_dpm_update_sclk_limit(adev); | |
| 1661 | − cz_dpm_set_deep_sleep_sclk_threshold(adev); | |
| 1662 | − cz_dpm_set_watermark_threshold(adev); | |
| 1663 | − cz_dpm_enable_nbdpm(adev); | |
| 1664 | − cz_dpm_update_low_memory_pstate(adev); | |
| 1665 | − | |
| 1666 | − return 0; | |
| 1667 | −} | |
| 1668 | − | |
| 1669 | −static void cz_dpm_post_set_power_state(struct amdgpu_device *adev) | |
| 1670 | −{ | |
| 1671 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1672 | − struct amdgpu_ps *ps = &pi->requested_rps; | |
| 1673 | − | |
| 1674 | − cz_update_current_ps(adev, ps); | |
| 1675 | −} | |
| 1676 | − | |
| 1677 | −static int cz_dpm_force_highest(struct amdgpu_device *adev) | |
| 1678 | −{ | |
| 1679 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1680 | − int ret = 0; | |
| 1681 | − | |
| 1682 | − if (pi->sclk_dpm.soft_min_clk != pi->sclk_dpm.soft_max_clk) { | |
| 1683 | − pi->sclk_dpm.soft_min_clk = | |
| 1684 | − pi->sclk_dpm.soft_max_clk; | |
| 1685 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1686 | − PPSMC_MSG_SetSclkSoftMin, | |
| 1687 | − cz_get_sclk_level(adev, | |
| 1688 | − pi->sclk_dpm.soft_min_clk, | |
| 1689 | − PPSMC_MSG_SetSclkSoftMin)); | |
| 1690 | − if (ret) | |
| 1691 | − return ret; | |
| 1692 | − } | |
| 1693 | − | |
| 1694 | − return ret; | |
| 1695 | −} | |
| 1696 | − | |
| 1697 | −static int cz_dpm_force_lowest(struct amdgpu_device *adev) | |
| 1698 | −{ | |
| 1699 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1700 | − int ret = 0; | |
| 1701 | − | |
| 1702 | − if (pi->sclk_dpm.soft_max_clk != pi->sclk_dpm.soft_min_clk) { | |
| 1703 | − pi->sclk_dpm.soft_max_clk = pi->sclk_dpm.soft_min_clk; | |
| 1704 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1705 | − PPSMC_MSG_SetSclkSoftMax, | |
| 1706 | − cz_get_sclk_level(adev, | |
| 1707 | − pi->sclk_dpm.soft_max_clk, | |
| 1708 | − PPSMC_MSG_SetSclkSoftMax)); | |
| 1709 | − if (ret) | |
| 1710 | − return ret; | |
| 1711 | − } | |
| 1712 | − | |
| 1713 | − return ret; | |
| 1714 | −} | |
| 1715 | − | |
| 1716 | −static uint32_t cz_dpm_get_max_sclk_level(struct amdgpu_device *adev) | |
| 1717 | −{ | |
| 1718 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1719 | − | |
| 1720 | − if (!pi->max_sclk_level) { | |
| 1721 | − cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxSclkLevel); | |
| 1722 | − pi->max_sclk_level = cz_get_argument(adev) + 1; | |
| 1723 | − } | |
| 1724 | − | |
| 1725 | − if (pi->max_sclk_level > CZ_MAX_HARDWARE_POWERLEVELS) { | |
| 1726 | − DRM_ERROR("Invalid max sclk level!\n"); | |
| 1727 | − return -EINVAL; | |
| 1728 | − } | |
| 1729 | − | |
| 1730 | − return pi->max_sclk_level; | |
| 1731 | −} | |
| 1732 | − | |
| 1733 | −static int cz_dpm_unforce_dpm_levels(struct amdgpu_device *adev) | |
| 1734 | −{ | |
| 1735 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1736 | − struct amdgpu_clock_voltage_dependency_table *dep_table = | |
| 1737 | − &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk; | |
| 1738 | − uint32_t level = 0; | |
| 1739 | − int ret = 0; | |
| 1740 | − | |
| 1741 | − pi->sclk_dpm.soft_min_clk = dep_table->entries[0].clk; | |
| 1742 | − level = cz_dpm_get_max_sclk_level(adev) - 1; | |
| 1743 | − if (level < dep_table->count) | |
| 1744 | − pi->sclk_dpm.soft_max_clk = dep_table->entries[level].clk; | |
| 1745 | − else | |
| 1746 | − pi->sclk_dpm.soft_max_clk = | |
| 1747 | − dep_table->entries[dep_table->count - 1].clk; | |
| 1748 | − | |
| 1749 | − /* get min/max sclk soft value | |
| 1750 | − * notify SMU to execute */ | |
| 1751 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1752 | − PPSMC_MSG_SetSclkSoftMin, | |
| 1753 | − cz_get_sclk_level(adev, | |
| 1754 | − pi->sclk_dpm.soft_min_clk, | |
| 1755 | − PPSMC_MSG_SetSclkSoftMin)); | |
| 1756 | − if (ret) | |
| 1757 | − return ret; | |
| 1758 | − | |
| 1759 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1760 | − PPSMC_MSG_SetSclkSoftMax, | |
| 1761 | − cz_get_sclk_level(adev, | |
| 1762 | − pi->sclk_dpm.soft_max_clk, | |
| 1763 | − PPSMC_MSG_SetSclkSoftMax)); | |
| 1764 | − if (ret) | |
| 1765 | − return ret; | |
| 1766 | − | |
| 1767 | − DRM_DEBUG("DPM unforce state min=%d, max=%d.\n", | |
| 1768 | − pi->sclk_dpm.soft_min_clk, | |
| 1769 | − pi->sclk_dpm.soft_max_clk); | |
| 1770 | − | |
| 1771 | − return 0; | |
| 1772 | −} | |
| 1773 | − | |
| 1774 | −static int cz_dpm_uvd_force_highest(struct amdgpu_device *adev) | |
| 1775 | −{ | |
| 1776 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1777 | − int ret = 0; | |
| 1778 | − | |
| 1779 | − if (pi->uvd_dpm.soft_min_clk != pi->uvd_dpm.soft_max_clk) { | |
| 1780 | − pi->uvd_dpm.soft_min_clk = | |
| 1781 | − pi->uvd_dpm.soft_max_clk; | |
| 1782 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1783 | − PPSMC_MSG_SetUvdSoftMin, | |
| 1784 | − cz_get_uvd_level(adev, | |
| 1785 | − pi->uvd_dpm.soft_min_clk, | |
| 1786 | − PPSMC_MSG_SetUvdSoftMin)); | |
| 1787 | − if (ret) | |
| 1788 | − return ret; | |
| 1789 | − } | |
| 1790 | − | |
| 1791 | − return ret; | |
| 1792 | −} | |
| 1793 | − | |
| 1794 | −static int cz_dpm_uvd_force_lowest(struct amdgpu_device *adev) | |
| 1795 | −{ | |
| 1796 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1797 | − int ret = 0; | |
| 1798 | − | |
| 1799 | − if (pi->uvd_dpm.soft_max_clk != pi->uvd_dpm.soft_min_clk) { | |
| 1800 | − pi->uvd_dpm.soft_max_clk = pi->uvd_dpm.soft_min_clk; | |
| 1801 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1802 | − PPSMC_MSG_SetUvdSoftMax, | |
| 1803 | − cz_get_uvd_level(adev, | |
| 1804 | − pi->uvd_dpm.soft_max_clk, | |
| 1805 | − PPSMC_MSG_SetUvdSoftMax)); | |
| 1806 | − if (ret) | |
| 1807 | − return ret; | |
| 1808 | − } | |
| 1809 | − | |
| 1810 | − return ret; | |
| 1811 | −} | |
| 1812 | − | |
| 1813 | −static uint32_t cz_dpm_get_max_uvd_level(struct amdgpu_device *adev) | |
| 1814 | −{ | |
| 1815 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1816 | − | |
| 1817 | − if (!pi->max_uvd_level) { | |
| 1818 | − cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxUvdLevel); | |
| 1819 | − pi->max_uvd_level = cz_get_argument(adev) + 1; | |
| 1820 | − } | |
| 1821 | − | |
| 1822 | − if (pi->max_uvd_level > CZ_MAX_HARDWARE_POWERLEVELS) { | |
| 1823 | − DRM_ERROR("Invalid max uvd level!\n"); | |
| 1824 | − return -EINVAL; | |
| 1825 | − } | |
| 1826 | − | |
| 1827 | − return pi->max_uvd_level; | |
| 1828 | −} | |
| 1829 | − | |
| 1830 | −static int cz_dpm_unforce_uvd_dpm_levels(struct amdgpu_device *adev) | |
| 1831 | −{ | |
| 1832 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1833 | − struct amdgpu_uvd_clock_voltage_dependency_table *dep_table = | |
| 1834 | − &adev->pm.dpm.dyn_state.uvd_clock_voltage_dependency_table; | |
| 1835 | − uint32_t level = 0; | |
| 1836 | − int ret = 0; | |
| 1837 | − | |
| 1838 | − pi->uvd_dpm.soft_min_clk = dep_table->entries[0].vclk; | |
| 1839 | − level = cz_dpm_get_max_uvd_level(adev) - 1; | |
| 1840 | − if (level < dep_table->count) | |
| 1841 | − pi->uvd_dpm.soft_max_clk = dep_table->entries[level].vclk; | |
| 1842 | − else | |
| 1843 | − pi->uvd_dpm.soft_max_clk = | |
| 1844 | − dep_table->entries[dep_table->count - 1].vclk; | |
| 1845 | − | |
| 1846 | − /* get min/max sclk soft value | |
| 1847 | − * notify SMU to execute */ | |
| 1848 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1849 | − PPSMC_MSG_SetUvdSoftMin, | |
| 1850 | − cz_get_uvd_level(adev, | |
| 1851 | − pi->uvd_dpm.soft_min_clk, | |
| 1852 | − PPSMC_MSG_SetUvdSoftMin)); | |
| 1853 | − if (ret) | |
| 1854 | − return ret; | |
| 1855 | − | |
| 1856 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1857 | − PPSMC_MSG_SetUvdSoftMax, | |
| 1858 | − cz_get_uvd_level(adev, | |
| 1859 | − pi->uvd_dpm.soft_max_clk, | |
| 1860 | − PPSMC_MSG_SetUvdSoftMax)); | |
| 1861 | − if (ret) | |
| 1862 | − return ret; | |
| 1863 | − | |
| 1864 | − DRM_DEBUG("DPM uvd unforce state min=%d, max=%d.\n", | |
| 1865 | − pi->uvd_dpm.soft_min_clk, | |
| 1866 | − pi->uvd_dpm.soft_max_clk); | |
| 1867 | − | |
| 1868 | − return 0; | |
| 1869 | −} | |
| 1870 | − | |
| 1871 | −static int cz_dpm_vce_force_highest(struct amdgpu_device *adev) | |
| 1872 | −{ | |
| 1873 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1874 | − int ret = 0; | |
| 1875 | − | |
| 1876 | − if (pi->vce_dpm.soft_min_clk != pi->vce_dpm.soft_max_clk) { | |
| 1877 | − pi->vce_dpm.soft_min_clk = | |
| 1878 | − pi->vce_dpm.soft_max_clk; | |
| 1879 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1880 | − PPSMC_MSG_SetEclkSoftMin, | |
| 1881 | − cz_get_eclk_level(adev, | |
| 1882 | − pi->vce_dpm.soft_min_clk, | |
| 1883 | − PPSMC_MSG_SetEclkSoftMin)); | |
| 1884 | − if (ret) | |
| 1885 | − return ret; | |
| 1886 | − } | |
| 1887 | − | |
| 1888 | − return ret; | |
| 1889 | −} | |
| 1890 | − | |
| 1891 | −static int cz_dpm_vce_force_lowest(struct amdgpu_device *adev) | |
| 1892 | −{ | |
| 1893 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1894 | − int ret = 0; | |
| 1895 | − | |
| 1896 | − if (pi->vce_dpm.soft_max_clk != pi->vce_dpm.soft_min_clk) { | |
| 1897 | − pi->vce_dpm.soft_max_clk = pi->vce_dpm.soft_min_clk; | |
| 1898 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1899 | − PPSMC_MSG_SetEclkSoftMax, | |
| 1900 | − cz_get_uvd_level(adev, | |
| 1901 | − pi->vce_dpm.soft_max_clk, | |
| 1902 | − PPSMC_MSG_SetEclkSoftMax)); | |
| 1903 | − if (ret) | |
| 1904 | − return ret; | |
| 1905 | − } | |
| 1906 | − | |
| 1907 | − return ret; | |
| 1908 | −} | |
| 1909 | − | |
| 1910 | −static uint32_t cz_dpm_get_max_vce_level(struct amdgpu_device *adev) | |
| 1911 | −{ | |
| 1912 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1913 | − | |
| 1914 | − if (!pi->max_vce_level) { | |
| 1915 | − cz_send_msg_to_smc(adev, PPSMC_MSG_GetMaxEclkLevel); | |
| 1916 | − pi->max_vce_level = cz_get_argument(adev) + 1; | |
| 1917 | − } | |
| 1918 | − | |
| 1919 | − if (pi->max_vce_level > CZ_MAX_HARDWARE_POWERLEVELS) { | |
| 1920 | − DRM_ERROR("Invalid max vce level!\n"); | |
| 1921 | − return -EINVAL; | |
| 1922 | − } | |
| 1923 | − | |
| 1924 | − return pi->max_vce_level; | |
| 1925 | −} | |
| 1926 | − | |
| 1927 | −static int cz_dpm_unforce_vce_dpm_levels(struct amdgpu_device *adev) | |
| 1928 | −{ | |
| 1929 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 1930 | − struct amdgpu_vce_clock_voltage_dependency_table *dep_table = | |
| 1931 | − &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table; | |
| 1932 | − uint32_t level = 0; | |
| 1933 | − int ret = 0; | |
| 1934 | − | |
| 1935 | − pi->vce_dpm.soft_min_clk = dep_table->entries[0].ecclk; | |
| 1936 | − level = cz_dpm_get_max_vce_level(adev) - 1; | |
| 1937 | − if (level < dep_table->count) | |
| 1938 | − pi->vce_dpm.soft_max_clk = dep_table->entries[level].ecclk; | |
| 1939 | − else | |
| 1940 | − pi->vce_dpm.soft_max_clk = | |
| 1941 | − dep_table->entries[dep_table->count - 1].ecclk; | |
| 1942 | − | |
| 1943 | − /* get min/max sclk soft value | |
| 1944 | − * notify SMU to execute */ | |
| 1945 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1946 | − PPSMC_MSG_SetEclkSoftMin, | |
| 1947 | − cz_get_eclk_level(adev, | |
| 1948 | − pi->vce_dpm.soft_min_clk, | |
| 1949 | − PPSMC_MSG_SetEclkSoftMin)); | |
| 1950 | − if (ret) | |
| 1951 | − return ret; | |
| 1952 | − | |
| 1953 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 1954 | − PPSMC_MSG_SetEclkSoftMax, | |
| 1955 | − cz_get_eclk_level(adev, | |
| 1956 | − pi->vce_dpm.soft_max_clk, | |
| 1957 | − PPSMC_MSG_SetEclkSoftMax)); | |
| 1958 | − if (ret) | |
| 1959 | − return ret; | |
| 1960 | − | |
| 1961 | − DRM_DEBUG("DPM vce unforce state min=%d, max=%d.\n", | |
| 1962 | − pi->vce_dpm.soft_min_clk, | |
| 1963 | − pi->vce_dpm.soft_max_clk); | |
| 1964 | − | |
| 1965 | − return 0; | |
| 1966 | −} | |
| 1967 | − | |
| 1968 | −static int cz_dpm_force_dpm_level(struct amdgpu_device *adev, | |
| 1969 | − enum amdgpu_dpm_forced_level level) | |
| 1970 | −{ | |
| 1971 | − int ret = 0; | |
| 1972 | − | |
| 1973 | − switch (level) { | |
| 1974 | − case AMDGPU_DPM_FORCED_LEVEL_HIGH: | |
| 1975 | − /* sclk */ | |
| 1976 | − ret = cz_dpm_unforce_dpm_levels(adev); | |
| 1977 | − if (ret) | |
| 1978 | − return ret; | |
| 1979 | − ret = cz_dpm_force_highest(adev); | |
| 1980 | − if (ret) | |
| 1981 | − return ret; | |
| 1982 | − | |
| 1983 | − /* uvd */ | |
| 1984 | − ret = cz_dpm_unforce_uvd_dpm_levels(adev); | |
| 1985 | − if (ret) | |
| 1986 | − return ret; | |
| 1987 | − ret = cz_dpm_uvd_force_highest(adev); | |
| 1988 | − if (ret) | |
| 1989 | − return ret; | |
| 1990 | − | |
| 1991 | − /* vce */ | |
| 1992 | − ret = cz_dpm_unforce_vce_dpm_levels(adev); | |
| 1993 | − if (ret) | |
| 1994 | − return ret; | |
| 1995 | − ret = cz_dpm_vce_force_highest(adev); | |
| 1996 | − if (ret) | |
| 1997 | − return ret; | |
| 1998 | − break; | |
| 1999 | − case AMDGPU_DPM_FORCED_LEVEL_LOW: | |
| 2000 | − /* sclk */ | |
| 2001 | − ret = cz_dpm_unforce_dpm_levels(adev); | |
| 2002 | − if (ret) | |
| 2003 | − return ret; | |
| 2004 | − ret = cz_dpm_force_lowest(adev); | |
| 2005 | − if (ret) | |
| 2006 | − return ret; | |
| 2007 | − | |
| 2008 | − /* uvd */ | |
| 2009 | − ret = cz_dpm_unforce_uvd_dpm_levels(adev); | |
| 2010 | − if (ret) | |
| 2011 | − return ret; | |
| 2012 | − ret = cz_dpm_uvd_force_lowest(adev); | |
| 2013 | − if (ret) | |
| 2014 | − return ret; | |
| 2015 | − | |
| 2016 | − /* vce */ | |
| 2017 | − ret = cz_dpm_unforce_vce_dpm_levels(adev); | |
| 2018 | − if (ret) | |
| 2019 | − return ret; | |
| 2020 | − ret = cz_dpm_vce_force_lowest(adev); | |
| 2021 | − if (ret) | |
| 2022 | − return ret; | |
| 2023 | − break; | |
| 2024 | − case AMDGPU_DPM_FORCED_LEVEL_AUTO: | |
| 2025 | − /* sclk */ | |
| 2026 | − ret = cz_dpm_unforce_dpm_levels(adev); | |
| 2027 | − if (ret) | |
| 2028 | − return ret; | |
| 2029 | − | |
| 2030 | − /* uvd */ | |
| 2031 | − ret = cz_dpm_unforce_uvd_dpm_levels(adev); | |
| 2032 | − if (ret) | |
| 2033 | − return ret; | |
| 2034 | − | |
| 2035 | − /* vce */ | |
| 2036 | − ret = cz_dpm_unforce_vce_dpm_levels(adev); | |
| 2037 | − if (ret) | |
| 2038 | − return ret; | |
| 2039 | − break; | |
| 2040 | − default: | |
| 2041 | − break; | |
| 2042 | − } | |
| 2043 | − | |
| 2044 | − adev->pm.dpm.forced_level = level; | |
| 2045 | − | |
| 2046 | − return ret; | |
| 2047 | −} | |
| 2048 | − | |
| 2049 | −/* fix me, display configuration change lists here | |
| 2050 | − * mostly dal related*/ | |
| 2051 | −static void cz_dpm_display_configuration_changed(struct amdgpu_device *adev) | |
| 2052 | −{ | |
| 2053 | −} | |
| 2054 | − | |
| 2055 | −static uint32_t cz_dpm_get_sclk(struct amdgpu_device *adev, bool low) | |
| 2056 | −{ | |
| 2057 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 2058 | − struct cz_ps *requested_state = cz_get_ps(&pi->requested_rps); | |
| 2059 | − | |
| 2060 | − if (low) | |
| 2061 | − return requested_state->levels[0].sclk; | |
| 2062 | − else | |
| 2063 | − return requested_state->levels[requested_state->num_levels - 1].sclk; | |
| 2064 | − | |
| 2065 | −} | |
| 2066 | − | |
| 2067 | −static uint32_t cz_dpm_get_mclk(struct amdgpu_device *adev, bool low) | |
| 2068 | −{ | |
| 2069 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 2070 | − | |
| 2071 | − return pi->sys_info.bootup_uma_clk; | |
| 2072 | −} | |
| 2073 | − | |
| 2074 | −static int cz_enable_uvd_dpm(struct amdgpu_device *adev, bool enable) | |
| 2075 | −{ | |
| 2076 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 2077 | − int ret = 0; | |
| 2078 | − | |
| 2079 | − if (enable && pi->caps_uvd_dpm ) { | |
| 2080 | − pi->dpm_flags |= DPMFlags_UVD_Enabled; | |
| 2081 | − DRM_DEBUG("UVD DPM Enabled.\n"); | |
| 2082 | − | |
| 2083 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 2084 | − PPSMC_MSG_EnableAllSmuFeatures, UVD_DPM_MASK); | |
| 2085 | − } else { | |
| 2086 | − pi->dpm_flags &= ~DPMFlags_UVD_Enabled; | |
| 2087 | − DRM_DEBUG("UVD DPM Stopped\n"); | |
| 2088 | − | |
| 2089 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 2090 | − PPSMC_MSG_DisableAllSmuFeatures, UVD_DPM_MASK); | |
| 2091 | − } | |
| 2092 | − | |
| 2093 | − return ret; | |
| 2094 | −} | |
| 2095 | − | |
| 2096 | −static int cz_update_uvd_dpm(struct amdgpu_device *adev, bool gate) | |
| 2097 | −{ | |
| 2098 | − return cz_enable_uvd_dpm(adev, !gate); | |
| 2099 | −} | |
| 2100 | − | |
| 2101 | − | |
| 2102 | −static void cz_dpm_powergate_uvd(struct amdgpu_device *adev, bool gate) | |
| 2103 | −{ | |
| 2104 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 2105 | − int ret; | |
| 2106 | − | |
| 2107 | − if (pi->uvd_power_gated == gate) | |
| 2108 | − return; | |
| 2109 | − | |
| 2110 | − pi->uvd_power_gated = gate; | |
| 2111 | − | |
| 2112 | − if (gate) { | |
| 2113 | − if (pi->caps_uvd_pg) { | |
| 2114 | − ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | |
| 2115 | − AMD_CG_STATE_GATE); | |
| 2116 | − if (ret) { | |
| 2117 | − DRM_ERROR("UVD DPM Power Gating failed to set clockgating state\n"); | |
| 2118 | − return; | |
| 2119 | − } | |
| 2120 | − | |
| 2121 | − /* shutdown the UVD block */ | |
| 2122 | − ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | |
| 2123 | − AMD_PG_STATE_GATE); | |
| 2124 | − | |
| 2125 | − if (ret) { | |
| 2126 | − DRM_ERROR("UVD DPM Power Gating failed to set powergating state\n"); | |
| 2127 | − return; | |
| 2128 | − } | |
| 2129 | − } | |
| 2130 | − cz_update_uvd_dpm(adev, gate); | |
| 2131 | − if (pi->caps_uvd_pg) { | |
| 2132 | − /* power off the UVD block */ | |
| 2133 | − ret = cz_send_msg_to_smc(adev, PPSMC_MSG_UVDPowerOFF); | |
| 2134 | − if (ret) { | |
| 2135 | − DRM_ERROR("UVD DPM Power Gating failed to send SMU PowerOFF message\n"); | |
| 2136 | − return; | |
| 2137 | − } | |
| 2138 | − } | |
| 2139 | − } else { | |
| 2140 | − if (pi->caps_uvd_pg) { | |
| 2141 | − /* power on the UVD block */ | |
| 2142 | − if (pi->uvd_dynamic_pg) | |
| 2143 | − ret = cz_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_UVDPowerON, 1); | |
| 2144 | − else | |
| 2145 | − ret = cz_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_UVDPowerON, 0); | |
| 2146 | − | |
| 2147 | − if (ret) { | |
| 2148 | − DRM_ERROR("UVD DPM Power Gating Failed to send SMU PowerON message\n"); | |
| 2149 | − return; | |
| 2150 | − } | |
| 2151 | − | |
| 2152 | − /* re-init the UVD block */ | |
| 2153 | − ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | |
| 2154 | − AMD_PG_STATE_UNGATE); | |
| 2155 | − | |
| 2156 | − if (ret) { | |
| 2157 | − DRM_ERROR("UVD DPM Power Gating Failed to set powergating state\n"); | |
| 2158 | − return; | |
| 2159 | − } | |
| 2160 | − | |
| 2161 | − ret = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | |
| 2162 | − AMD_CG_STATE_UNGATE); | |
| 2163 | − if (ret) { | |
| 2164 | − DRM_ERROR("UVD DPM Power Gating Failed to set clockgating state\n"); | |
| 2165 | − return; | |
| 2166 | − } | |
| 2167 | − } | |
| 2168 | − cz_update_uvd_dpm(adev, gate); | |
| 2169 | − } | |
| 2170 | −} | |
| 2171 | − | |
| 2172 | −static int cz_enable_vce_dpm(struct amdgpu_device *adev, bool enable) | |
| 2173 | −{ | |
| 2174 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 2175 | − int ret = 0; | |
| 2176 | − | |
| 2177 | − if (enable && pi->caps_vce_dpm) { | |
| 2178 | − pi->dpm_flags |= DPMFlags_VCE_Enabled; | |
| 2179 | − DRM_DEBUG("VCE DPM Enabled.\n"); | |
| 2180 | − | |
| 2181 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 2182 | − PPSMC_MSG_EnableAllSmuFeatures, VCE_DPM_MASK); | |
| 2183 | − | |
| 2184 | − } else { | |
| 2185 | − pi->dpm_flags &= ~DPMFlags_VCE_Enabled; | |
| 2186 | − DRM_DEBUG("VCE DPM Stopped\n"); | |
| 2187 | − | |
| 2188 | − ret = cz_send_msg_to_smc_with_parameter(adev, | |
| 2189 | − PPSMC_MSG_DisableAllSmuFeatures, VCE_DPM_MASK); | |
| 2190 | − } | |
| 2191 | − | |
| 2192 | − return ret; | |
| 2193 | −} | |
| 2194 | − | |
| 2195 | −static int cz_update_vce_dpm(struct amdgpu_device *adev) | |
| 2196 | −{ | |
| 2197 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 2198 | − struct amdgpu_vce_clock_voltage_dependency_table *table = | |
| 2199 | − &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table; | |
| 2200 | − | |
| 2201 | − /* Stable Pstate is enabled and we need to set the VCE DPM to highest level */ | |
| 2202 | − if (pi->caps_stable_power_state) { | |
| 2203 | − pi->vce_dpm.hard_min_clk = table->entries[table->count-1].ecclk; | |
| 2204 | − } else { /* non-stable p-state cases. without vce.Arbiter.EcclkHardMin */ | |
| 2205 | − /* leave it as set by user */ | |
| 2206 | − /*pi->vce_dpm.hard_min_clk = table->entries[0].ecclk;*/ | |
| 2207 | − } | |
| 2208 | − | |
| 2209 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 2210 | − PPSMC_MSG_SetEclkHardMin, | |
| 2211 | − cz_get_eclk_level(adev, | |
| 2212 | − pi->vce_dpm.hard_min_clk, | |
| 2213 | − PPSMC_MSG_SetEclkHardMin)); | |
| 2214 | − return 0; | |
| 2215 | −} | |
| 2216 | − | |
| 2217 | −static void cz_dpm_powergate_vce(struct amdgpu_device *adev, bool gate) | |
| 2218 | −{ | |
| 2219 | − struct cz_power_info *pi = cz_get_pi(adev); | |
| 2220 | − | |
| 2221 | − if (pi->caps_vce_pg) { | |
| 2222 | − if (pi->vce_power_gated != gate) { | |
| 2223 | − if (gate) { | |
| 2224 | − /* disable clockgating so we can properly shut down the block */ | |
| 2225 | − amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | |
| 2226 | − AMD_CG_STATE_UNGATE); | |
| 2227 | − /* shutdown the VCE block */ | |
| 2228 | − amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | |
| 2229 | − AMD_PG_STATE_GATE); | |
| 2230 | − | |
| 2231 | − cz_enable_vce_dpm(adev, false); | |
| 2232 | − cz_send_msg_to_smc(adev, PPSMC_MSG_VCEPowerOFF); | |
| 2233 | − pi->vce_power_gated = true; | |
| 2234 | − } else { | |
| 2235 | − cz_send_msg_to_smc(adev, PPSMC_MSG_VCEPowerON); | |
| 2236 | − pi->vce_power_gated = false; | |
| 2237 | − | |
| 2238 | − /* re-init the VCE block */ | |
| 2239 | − amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | |
| 2240 | − AMD_PG_STATE_UNGATE); | |
| 2241 | − /* enable clockgating. hw will dynamically gate/ungate clocks on the fly */ | |
| 2242 | − amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | |
| 2243 | − AMD_CG_STATE_GATE); | |
| 2244 | − | |
| 2245 | − cz_update_vce_dpm(adev); | |
| 2246 | − cz_enable_vce_dpm(adev, true); | |
| 2247 | − } | |
| 2248 | − } else { | |
| 2249 | − if (! pi->vce_power_gated) { | |
| 2250 | − cz_update_vce_dpm(adev); | |
| 2251 | − } | |
| 2252 | − } | |
| 2253 | − } else { /*pi->caps_vce_pg*/ | |
| 2254 | − pi->vce_power_gated = gate; | |
| 2255 | − cz_update_vce_dpm(adev); | |
| 2256 | − cz_enable_vce_dpm(adev, !gate); | |
| 2257 | − } | |
| 2258 | −} | |
| 2259 | − | |
| 2260 | −static int cz_check_state_equal(struct amdgpu_device *adev, | |
| 2261 | − struct amdgpu_ps *cps, | |
| 2262 | − struct amdgpu_ps *rps, | |
| 2263 | − bool *equal) | |
| 2264 | −{ | |
| 2265 | − if (equal == NULL) | |
| 2266 | − return -EINVAL; | |
| 2267 | − | |
| 2268 | − *equal = false; | |
| 2269 | − return 0; | |
| 2270 | −} | |
| 2271 | − | |
| 2272 | −const struct amd_ip_funcs cz_dpm_ip_funcs = { | |
| 2273 | − .name = "cz_dpm", | |
| 2274 | − .early_init = cz_dpm_early_init, | |
| 2275 | − .late_init = cz_dpm_late_init, | |
| 2276 | − .sw_init = cz_dpm_sw_init, | |
| 2277 | − .sw_fini = cz_dpm_sw_fini, | |
| 2278 | − .hw_init = cz_dpm_hw_init, | |
| 2279 | − .hw_fini = cz_dpm_hw_fini, | |
| 2280 | − .suspend = cz_dpm_suspend, | |
| 2281 | − .resume = cz_dpm_resume, | |
| 2282 | − .is_idle = NULL, | |
| 2283 | − .wait_for_idle = NULL, | |
| 2284 | − .soft_reset = NULL, | |
| 2285 | − .set_clockgating_state = cz_dpm_set_clockgating_state, | |
| 2286 | − .set_powergating_state = cz_dpm_set_powergating_state, | |
| 2287 | −}; | |
| 2288 | − | |
| 2289 | −static const struct amdgpu_dpm_funcs cz_dpm_funcs = { | |
| 2290 | − .get_temperature = cz_dpm_get_temperature, | |
| 2291 | − .pre_set_power_state = cz_dpm_pre_set_power_state, | |
| 2292 | − .set_power_state = cz_dpm_set_power_state, | |
| 2293 | − .post_set_power_state = cz_dpm_post_set_power_state, | |
| 2294 | − .display_configuration_changed = cz_dpm_display_configuration_changed, | |
| 2295 | − .get_sclk = cz_dpm_get_sclk, | |
| 2296 | − .get_mclk = cz_dpm_get_mclk, | |
| 2297 | − .print_power_state = cz_dpm_print_power_state, | |
| 2298 | − .debugfs_print_current_performance_level = | |
| 2299 | − cz_dpm_debugfs_print_current_performance_level, | |
| 2300 | − .force_performance_level = cz_dpm_force_dpm_level, | |
| 2301 | − .vblank_too_short = NULL, | |
| 2302 | − .powergate_uvd = cz_dpm_powergate_uvd, | |
| 2303 | − .powergate_vce = cz_dpm_powergate_vce, | |
| 2304 | − .check_state_equal = cz_check_state_equal, | |
| 2305 | −}; | |
| 2306 | − | |
| 2307 | −static void cz_dpm_set_funcs(struct amdgpu_device *adev) | |
| 2308 | −{ | |
| 2309 | − if (NULL == adev->pm.funcs) | |
| 2310 | − adev->pm.funcs = &cz_dpm_funcs; | |
| 2311 | −} | |
| 2312 | − | |
| 2313 | −const struct amdgpu_ip_block_version cz_dpm_ip_block = | |
| 2314 | −{ | |
| 2315 | − .type = AMD_IP_BLOCK_TYPE_SMC, | |
| 2316 | − .major = 8, | |
| 2317 | − .minor = 0, | |
| 2318 | − .rev = 0, | |
| 2319 | − .funcs = &cz_dpm_ip_funcs, | |
| 2320 | −}; | |
| @@ -1,239 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright 2014 Advanced Micro Devices, Inc. | |
| 3 | − * | |
| 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: | |
| 10 | − * | |
| 11 | − * The above copyright notice and this permission notice shall be included in | |
| 12 | − * all copies or substantial portions of the Software. | |
| 13 | − * | |
| 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. | |
| 21 | − * | |
| 22 | − */ | |
| 23 | − | |
| 24 | −#ifndef __CZ_DPM_H__ | |
| 25 | −#define __CZ_DPM_H__ | |
| 26 | − | |
| 27 | −#include "smu8_fusion.h" | |
| 28 | − | |
| 29 | −#define CZ_AT_DFLT 30 | |
| 30 | −#define CZ_NUM_NBPSTATES 4 | |
| 31 | −#define CZ_NUM_NBPMEMORY_CLOCK 2 | |
| 32 | −#define CZ_MAX_HARDWARE_POWERLEVELS 8 | |
| 33 | −#define CZ_MAX_DISPLAY_CLOCK_LEVEL 8 | |
| 34 | −#define CZ_MAX_DISPLAYPHY_IDS 10 | |
| 35 | − | |
| 36 | −#define PPCZ_VOTINGRIGHTSCLIENTS_DFLT0 0x3FFFC102 | |
| 37 | − | |
| 38 | −#define SMC_RAM_END 0x40000 | |
| 39 | − | |
| 40 | −#define DPMFlags_SCLK_Enabled 0x00000001 | |
| 41 | −#define DPMFlags_UVD_Enabled 0x00000002 | |
| 42 | −#define DPMFlags_VCE_Enabled 0x00000004 | |
| 43 | −#define DPMFlags_ACP_Enabled 0x00000008 | |
| 44 | −#define DPMFlags_ForceHighestValid 0x40000000 | |
| 45 | −#define DPMFlags_Debug 0x80000000 | |
| 46 | − | |
| 47 | −/* Do not change the following, it is also defined in SMU8.h */ | |
| 48 | −#define SMU_EnabledFeatureScoreboard_AcpDpmOn 0x00000001 | |
| 49 | −#define SMU_EnabledFeatureScoreboard_SclkDpmOn 0x00200000 | |
| 50 | −#define SMU_EnabledFeatureScoreboard_UvdDpmOn 0x00800000 | |
| 51 | −#define SMU_EnabledFeatureScoreboard_VceDpmOn 0x01000000 | |
| 52 | − | |
| 53 | −/* temporary solution to SetMinDeepSleepSclk | |
| 54 | − * should indicate by display adaptor | |
| 55 | − * 10k Hz unit*/ | |
| 56 | −#define CZ_MIN_DEEP_SLEEP_SCLK 800 | |
| 57 | − | |
| 58 | −enum cz_pt_config_reg_type { | |
| 59 | − CZ_CONFIGREG_MMR = 0, | |
| 60 | − CZ_CONFIGREG_SMC_IND, | |
| 61 | − CZ_CONFIGREG_DIDT_IND, | |
| 62 | − CZ_CONFIGREG_CACHE, | |
| 63 | − CZ_CONFIGREG_MAX | |
| 64 | −}; | |
| 65 | − | |
| 66 | −struct cz_pt_config_reg { | |
| 67 | − uint32_t offset; | |
| 68 | − uint32_t mask; | |
| 69 | − uint32_t shift; | |
| 70 | − uint32_t value; | |
| 71 | − enum cz_pt_config_reg_type type; | |
| 72 | −}; | |
| 73 | − | |
| 74 | −struct cz_dpm_entry { | |
| 75 | − uint32_t soft_min_clk; | |
| 76 | − uint32_t hard_min_clk; | |
| 77 | − uint32_t soft_max_clk; | |
| 78 | − uint32_t hard_max_clk; | |
| 79 | −}; | |
| 80 | − | |
| 81 | −struct cz_pl { | |
| 82 | − uint32_t sclk; | |
| 83 | − uint8_t vddc_index; | |
| 84 | − uint8_t ds_divider_index; | |
| 85 | − uint8_t ss_divider_index; | |
| 86 | − uint8_t allow_gnb_slow; | |
| 87 | − uint8_t force_nbp_state; | |
| 88 | − uint8_t display_wm; | |
| 89 | − uint8_t vce_wm; | |
| 90 | −}; | |
| 91 | − | |
| 92 | −struct cz_ps { | |
| 93 | − struct cz_pl levels[CZ_MAX_HARDWARE_POWERLEVELS]; | |
| 94 | − uint32_t num_levels; | |
| 95 | − bool need_dfs_bypass; | |
| 96 | − uint8_t dpm0_pg_nb_ps_lo; | |
| 97 | − uint8_t dpm0_pg_nb_ps_hi; | |
| 98 | − uint8_t dpmx_nb_ps_lo; | |
| 99 | − uint8_t dpmx_nb_ps_hi; | |
| 100 | − bool force_high; | |
| 101 | −}; | |
| 102 | − | |
| 103 | −struct cz_displayphy_entry { | |
| 104 | − uint8_t phy_present; | |
| 105 | − uint8_t active_lane_mapping; | |
| 106 | − uint8_t display_conf_type; | |
| 107 | − uint8_t num_active_lanes; | |
| 108 | −}; | |
| 109 | − | |
| 110 | −struct cz_displayphy_info { | |
| 111 | − bool phy_access_initialized; | |
| 112 | − struct cz_displayphy_entry entries[CZ_MAX_DISPLAYPHY_IDS]; | |
| 113 | −}; | |
| 114 | − | |
| 115 | −struct cz_sys_info { | |
| 116 | − uint32_t bootup_uma_clk; | |
| 117 | − uint32_t bootup_sclk; | |
| 118 | − uint32_t dentist_vco_freq; | |
| 119 | − uint32_t nb_dpm_enable; | |
| 120 | − uint32_t nbp_memory_clock[CZ_NUM_NBPMEMORY_CLOCK]; | |
| 121 | − uint32_t nbp_n_clock[CZ_NUM_NBPSTATES]; | |
| 122 | − uint8_t nbp_voltage_index[CZ_NUM_NBPSTATES]; | |
| 123 | − uint32_t display_clock[CZ_MAX_DISPLAY_CLOCK_LEVEL]; | |
| 124 | − uint16_t bootup_nb_voltage_index; | |
| 125 | − uint8_t htc_tmp_lmt; | |
| 126 | − uint8_t htc_hyst_lmt; | |
| 127 | − uint32_t uma_channel_number; | |
| 128 | −}; | |
| 129 | − | |
| 130 | −struct cz_power_info { | |
| 131 | − uint32_t active_target[CZ_MAX_HARDWARE_POWERLEVELS]; | |
| 132 | − struct cz_sys_info sys_info; | |
| 133 | − struct cz_pl boot_pl; | |
| 134 | − bool disable_nb_ps3_in_battery; | |
| 135 | − bool battery_state; | |
| 136 | − uint32_t lowest_valid; | |
| 137 | − uint32_t highest_valid; | |
| 138 | − uint16_t high_voltage_threshold; | |
| 139 | − /* smc offsets */ | |
| 140 | − uint32_t sram_end; | |
| 141 | − uint32_t dpm_table_start; | |
| 142 | − uint32_t soft_regs_start; | |
| 143 | − /* dpm SMU tables */ | |
| 144 | − uint8_t uvd_level_count; | |
| 145 | − uint8_t vce_level_count; | |
| 146 | − uint8_t acp_level_count; | |
| 147 | − uint32_t fps_high_threshold; | |
| 148 | − uint32_t fps_low_threshold; | |
| 149 | − /* dpm table */ | |
| 150 | − uint32_t dpm_flags; | |
| 151 | − struct cz_dpm_entry sclk_dpm; | |
| 152 | − struct cz_dpm_entry uvd_dpm; | |
| 153 | − struct cz_dpm_entry vce_dpm; | |
| 154 | − struct cz_dpm_entry acp_dpm; | |
| 155 | − | |
| 156 | − uint8_t uvd_boot_level; | |
| 157 | − uint8_t uvd_interval; | |
| 158 | − uint8_t vce_boot_level; | |
| 159 | − uint8_t vce_interval; | |
| 160 | − uint8_t acp_boot_level; | |
| 161 | − uint8_t acp_interval; | |
| 162 | − | |
| 163 | − uint8_t graphics_boot_level; | |
| 164 | − uint8_t graphics_interval; | |
| 165 | − uint8_t graphics_therm_throttle_enable; | |
| 166 | − uint8_t graphics_voltage_change_enable; | |
| 167 | − uint8_t graphics_clk_slow_enable; | |
| 168 | − uint8_t graphics_clk_slow_divider; | |
| 169 | − | |
| 170 | − uint32_t low_sclk_interrupt_threshold; | |
| 171 | − bool uvd_power_gated; | |
| 172 | − bool vce_power_gated; | |
| 173 | − bool acp_power_gated; | |
| 174 | − | |
| 175 | − uint32_t active_process_mask; | |
| 176 | − | |
| 177 | − uint32_t mgcg_cgtt_local0; | |
| 178 | − uint32_t mgcg_cgtt_local1; | |
| 179 | − uint32_t clock_slow_down_step; | |
| 180 | − uint32_t skip_clock_slow_down; | |
| 181 | − bool enable_nb_ps_policy; | |
| 182 | − uint32_t voting_clients; | |
| 183 | − uint32_t voltage_drop_threshold; | |
| 184 | − uint32_t gfx_pg_threshold; | |
| 185 | − uint32_t max_sclk_level; | |
| 186 | − uint32_t max_uvd_level; | |
| 187 | − uint32_t max_vce_level; | |
| 188 | − /* flags */ | |
| 189 | − bool didt_enabled; | |
| 190 | − bool video_start; | |
| 191 | − bool cac_enabled; | |
| 192 | − bool bapm_enabled; | |
| 193 | − bool nb_dpm_enabled_by_driver; | |
| 194 | − bool nb_dpm_enabled; | |
| 195 | − bool auto_thermal_throttling_enabled; | |
| 196 | − bool dpm_enabled; | |
| 197 | − bool need_pptable_upload; | |
| 198 | − /* caps */ | |
| 199 | − bool caps_cac; | |
| 200 | − bool caps_power_containment; | |
| 201 | − bool caps_sq_ramping; | |
| 202 | − bool caps_db_ramping; | |
| 203 | − bool caps_td_ramping; | |
| 204 | − bool caps_tcp_ramping; | |
| 205 | − bool caps_sclk_throttle_low_notification; | |
| 206 | − bool caps_fps; | |
| 207 | − bool caps_uvd_dpm; | |
| 208 | − bool caps_uvd_pg; | |
| 209 | − bool caps_vce_dpm; | |
| 210 | − bool caps_vce_pg; | |
| 211 | − bool caps_acp_dpm; | |
| 212 | − bool caps_acp_pg; | |
| 213 | − bool caps_stable_power_state; | |
| 214 | − bool caps_enable_dfs_bypass; | |
| 215 | − bool caps_sclk_ds; | |
| 216 | − bool caps_voltage_island; | |
| 217 | − /* power state */ | |
| 218 | − struct amdgpu_ps current_rps; | |
| 219 | − struct cz_ps current_ps; | |
| 220 | − struct amdgpu_ps requested_rps; | |
| 221 | − struct cz_ps requested_ps; | |
| 222 | − | |
| 223 | − bool uvd_power_down; | |
| 224 | − bool vce_power_down; | |
| 225 | − bool acp_power_down; | |
| 226 | − | |
| 227 | − bool uvd_dynamic_pg; | |
| 228 | −}; | |
| 229 | − | |
| 230 | −/* cz_smc.c */ | |
| 231 | −uint32_t cz_get_argument(struct amdgpu_device *adev); | |
| 232 | −int cz_send_msg_to_smc(struct amdgpu_device *adev, uint16_t msg); | |
| 233 | −int cz_send_msg_to_smc_with_parameter(struct amdgpu_device *adev, | |
| 234 | − uint16_t msg, uint32_t parameter); | |
| 235 | −int cz_read_smc_sram_dword(struct amdgpu_device *adev, | |
| 236 | − uint32_t smc_address, uint32_t *value, uint32_t limit); | |
| 237 | −int cz_smu_upload_pptable(struct amdgpu_device *adev); | |
| 238 | −int cz_smu_download_pptable(struct amdgpu_device *adev, void **table); | |
| 239 | −#endif | |
| @@ -1,995 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright 2014 Advanced Micro Devices, Inc. | |
| 3 | − * | |
| 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: | |
| 10 | − * | |
| 11 | − * The above copyright notice and this permission notice shall be included in | |
| 12 | − * all copies or substantial portions of the Software. | |
| 13 | − * | |
| 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. | |
| 21 | − * | |
| 22 | − */ | |
| 23 | −#include <linux/firmware.h> | |
| 24 | −#include "drmP.h" | |
| 25 | −#include "amdgpu.h" | |
| 26 | −#include "smu8.h" | |
| 27 | −#include "smu8_fusion.h" | |
| 28 | −#include "cz_ppsmc.h" | |
| 29 | −#include "cz_smumgr.h" | |
| 30 | −#include "smu_ucode_xfer_cz.h" | |
| 31 | −#include "amdgpu_ucode.h" | |
| 32 | −#include "cz_dpm.h" | |
| 33 | −#include "vi_dpm.h" | |
| 34 | − | |
| 35 | −#include "smu/smu_8_0_d.h" | |
| 36 | −#include "smu/smu_8_0_sh_mask.h" | |
| 37 | −#include "gca/gfx_8_0_d.h" | |
| 38 | −#include "gca/gfx_8_0_sh_mask.h" | |
| 39 | − | |
| 40 | −uint32_t cz_get_argument(struct amdgpu_device *adev) | |
| 41 | −{ | |
| 42 | − return RREG32(mmSMU_MP1_SRBM2P_ARG_0); | |
| 43 | −} | |
| 44 | − | |
| 45 | −static struct cz_smu_private_data *cz_smu_get_priv(struct amdgpu_device *adev) | |
| 46 | −{ | |
| 47 | − struct cz_smu_private_data *priv = | |
| 48 | − (struct cz_smu_private_data *)(adev->smu.priv); | |
| 49 | − | |
| 50 | − return priv; | |
| 51 | −} | |
| 52 | − | |
| 53 | −static int cz_send_msg_to_smc_async(struct amdgpu_device *adev, u16 msg) | |
| 54 | −{ | |
| 55 | − int i; | |
| 56 | − u32 content = 0, tmp; | |
| 57 | − | |
| 58 | − for (i = 0; i < adev->usec_timeout; i++) { | |
| 59 | − tmp = REG_GET_FIELD(RREG32(mmSMU_MP1_SRBM2P_RESP_0), | |
| 60 | − SMU_MP1_SRBM2P_RESP_0, CONTENT); | |
| 61 | − if (content != tmp) | |
| 62 | − break; | |
| 63 | − udelay(1); | |
| 64 | − } | |
| 65 | − | |
| 66 | − /* timeout means wrong logic*/ | |
| 67 | − if (i == adev->usec_timeout) | |
| 68 | − return -EINVAL; | |
| 69 | − | |
| 70 | − WREG32(mmSMU_MP1_SRBM2P_RESP_0, 0); | |
| 71 | − WREG32(mmSMU_MP1_SRBM2P_MSG_0, msg); | |
| 72 | − | |
| 73 | − return 0; | |
| 74 | −} | |
| 75 | − | |
| 76 | −int cz_send_msg_to_smc(struct amdgpu_device *adev, u16 msg) | |
| 77 | −{ | |
| 78 | − int i; | |
| 79 | − u32 content = 0, tmp = 0; | |
| 80 | − | |
| 81 | − if (cz_send_msg_to_smc_async(adev, msg)) | |
| 82 | − return -EINVAL; | |
| 83 | − | |
| 84 | − for (i = 0; i < adev->usec_timeout; i++) { | |
| 85 | − tmp = REG_GET_FIELD(RREG32(mmSMU_MP1_SRBM2P_RESP_0), | |
| 86 | − SMU_MP1_SRBM2P_RESP_0, CONTENT); | |
| 87 | − if (content != tmp) | |
| 88 | − break; | |
| 89 | − udelay(1); | |
| 90 | − } | |
| 91 | − | |
| 92 | − /* timeout means wrong logic*/ | |
| 93 | − if (i == adev->usec_timeout) | |
| 94 | − return -EINVAL; | |
| 95 | − | |
| 96 | − if (PPSMC_Result_OK != tmp) { | |
| 97 | − dev_err(adev->dev, "SMC Failed to send Message.\n"); | |
| 98 | − return -EINVAL; | |
| 99 | − } | |
| 100 | − | |
| 101 | − return 0; | |
| 102 | −} | |
| 103 | − | |
| 104 | −int cz_send_msg_to_smc_with_parameter(struct amdgpu_device *adev, | |
| 105 | − u16 msg, u32 parameter) | |
| 106 | −{ | |
| 107 | − WREG32(mmSMU_MP1_SRBM2P_ARG_0, parameter); | |
| 108 | − return cz_send_msg_to_smc(adev, msg); | |
| 109 | −} | |
| 110 | − | |
| 111 | −static int cz_set_smc_sram_address(struct amdgpu_device *adev, | |
| 112 | − u32 smc_address, u32 limit) | |
| 113 | −{ | |
| 114 | − if (smc_address & 3) | |
| 115 | − return -EINVAL; | |
| 116 | − if ((smc_address + 3) > limit) | |
| 117 | − return -EINVAL; | |
| 118 | − | |
| 119 | − WREG32(mmMP0PUB_IND_INDEX_0, SMN_MP1_SRAM_START_ADDR + smc_address); | |
| 120 | − | |
| 121 | − return 0; | |
| 122 | −} | |
| 123 | − | |
| 124 | −int cz_read_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address, | |
| 125 | − u32 *value, u32 limit) | |
| 126 | −{ | |
| 127 | − int ret; | |
| 128 | − | |
| 129 | − ret = cz_set_smc_sram_address(adev, smc_address, limit); | |
| 130 | − if (ret) | |
| 131 | − return ret; | |
| 132 | − | |
| 133 | − *value = RREG32(mmMP0PUB_IND_DATA_0); | |
| 134 | − | |
| 135 | − return 0; | |
| 136 | −} | |
| 137 | − | |
| 138 | −static int cz_write_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address, | |
| 139 | − u32 value, u32 limit) | |
| 140 | −{ | |
| 141 | − int ret; | |
| 142 | − | |
| 143 | − ret = cz_set_smc_sram_address(adev, smc_address, limit); | |
| 144 | − if (ret) | |
| 145 | − return ret; | |
| 146 | − | |
| 147 | − WREG32(mmMP0PUB_IND_DATA_0, value); | |
| 148 | − | |
| 149 | − return 0; | |
| 150 | −} | |
| 151 | − | |
| 152 | −static int cz_smu_request_load_fw(struct amdgpu_device *adev) | |
| 153 | −{ | |
| 154 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 155 | − | |
| 156 | − uint32_t smc_addr = SMU8_FIRMWARE_HEADER_LOCATION + | |
| 157 | − offsetof(struct SMU8_Firmware_Header, UcodeLoadStatus); | |
| 158 | − | |
| 159 | − cz_write_smc_sram_dword(adev, smc_addr, 0, smc_addr + 4); | |
| 160 | − | |
| 161 | − /*prepare toc buffers*/ | |
| 162 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 163 | − PPSMC_MSG_DriverDramAddrHi, | |
| 164 | − priv->toc_buffer.mc_addr_high); | |
| 165 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 166 | − PPSMC_MSG_DriverDramAddrLo, | |
| 167 | − priv->toc_buffer.mc_addr_low); | |
| 168 | − cz_send_msg_to_smc(adev, PPSMC_MSG_InitJobs); | |
| 169 | − | |
| 170 | − /*execute jobs*/ | |
| 171 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 172 | − PPSMC_MSG_ExecuteJob, | |
| 173 | − priv->toc_entry_aram); | |
| 174 | − | |
| 175 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 176 | − PPSMC_MSG_ExecuteJob, | |
| 177 | − priv->toc_entry_power_profiling_index); | |
| 178 | − | |
| 179 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 180 | − PPSMC_MSG_ExecuteJob, | |
| 181 | − priv->toc_entry_initialize_index); | |
| 182 | − | |
| 183 | − return 0; | |
| 184 | −} | |
| 185 | − | |
| 186 | −/* | |
| 187 | − *Check if the FW has been loaded, SMU will not return if loading | |
| 188 | − *has not finished. | |
| 189 | − */ | |
| 190 | −static int cz_smu_check_fw_load_finish(struct amdgpu_device *adev, | |
| 191 | − uint32_t fw_mask) | |
| 192 | −{ | |
| 193 | − int i; | |
| 194 | − uint32_t index = SMN_MP1_SRAM_START_ADDR + | |
| 195 | − SMU8_FIRMWARE_HEADER_LOCATION + | |
| 196 | − offsetof(struct SMU8_Firmware_Header, UcodeLoadStatus); | |
| 197 | − | |
| 198 | − WREG32(mmMP0PUB_IND_INDEX, index); | |
| 199 | − | |
| 200 | − for (i = 0; i < adev->usec_timeout; i++) { | |
| 201 | − if (fw_mask == (RREG32(mmMP0PUB_IND_DATA) & fw_mask)) | |
| 202 | − break; | |
| 203 | − udelay(1); | |
| 204 | − } | |
| 205 | − | |
| 206 | − if (i >= adev->usec_timeout) { | |
| 207 | − dev_err(adev->dev, | |
| 208 | − "SMU check loaded firmware failed, expecting 0x%x, getting 0x%x", | |
| 209 | − fw_mask, RREG32(mmMP0PUB_IND_DATA)); | |
| 210 | − return -EINVAL; | |
| 211 | − } | |
| 212 | − | |
| 213 | − return 0; | |
| 214 | −} | |
| 215 | − | |
| 216 | −/* | |
| 217 | − * interfaces for different ip blocks to check firmware loading status | |
| 218 | − * 0 for success otherwise failed | |
| 219 | − */ | |
| 220 | −static int cz_smu_check_finished(struct amdgpu_device *adev, | |
| 221 | − enum AMDGPU_UCODE_ID id) | |
| 222 | −{ | |
| 223 | − switch (id) { | |
| 224 | − case AMDGPU_UCODE_ID_SDMA0: | |
| 225 | − if (adev->smu.fw_flags & AMDGPU_SDMA0_UCODE_LOADED) | |
| 226 | − return 0; | |
| 227 | − break; | |
| 228 | − case AMDGPU_UCODE_ID_SDMA1: | |
| 229 | − if (adev->smu.fw_flags & AMDGPU_SDMA1_UCODE_LOADED) | |
| 230 | − return 0; | |
| 231 | − break; | |
| 232 | − case AMDGPU_UCODE_ID_CP_CE: | |
| 233 | − if (adev->smu.fw_flags & AMDGPU_CPCE_UCODE_LOADED) | |
| 234 | − return 0; | |
| 235 | − break; | |
| 236 | − case AMDGPU_UCODE_ID_CP_PFP: | |
| 237 | − if (adev->smu.fw_flags & AMDGPU_CPPFP_UCODE_LOADED) | |
| 238 | − return 0; | |
| 239 | − case AMDGPU_UCODE_ID_CP_ME: | |
| 240 | − if (adev->smu.fw_flags & AMDGPU_CPME_UCODE_LOADED) | |
| 241 | − return 0; | |
| 242 | − break; | |
| 243 | − case AMDGPU_UCODE_ID_CP_MEC1: | |
| 244 | − if (adev->smu.fw_flags & AMDGPU_CPMEC1_UCODE_LOADED) | |
| 245 | − return 0; | |
| 246 | − break; | |
| 247 | − case AMDGPU_UCODE_ID_CP_MEC2: | |
| 248 | − if (adev->smu.fw_flags & AMDGPU_CPMEC2_UCODE_LOADED) | |
| 249 | − return 0; | |
| 250 | − break; | |
| 251 | − case AMDGPU_UCODE_ID_RLC_G: | |
| 252 | − if (adev->smu.fw_flags & AMDGPU_CPRLC_UCODE_LOADED) | |
| 253 | − return 0; | |
| 254 | − break; | |
| 255 | − case AMDGPU_UCODE_ID_MAXIMUM: | |
| 256 | − default: | |
| 257 | − break; | |
| 258 | − } | |
| 259 | − | |
| 260 | − return 1; | |
| 261 | −} | |
| 262 | − | |
| 263 | −static int cz_load_mec_firmware(struct amdgpu_device *adev) | |
| 264 | −{ | |
| 265 | − struct amdgpu_firmware_info *ucode = | |
| 266 | − &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1]; | |
| 267 | − uint32_t reg_data; | |
| 268 | − uint32_t tmp; | |
| 269 | − | |
| 270 | − if (ucode->fw == NULL) | |
| 271 | − return -EINVAL; | |
| 272 | − | |
| 273 | − /* Disable MEC parsing/prefetching */ | |
| 274 | − tmp = RREG32(mmCP_MEC_CNTL); | |
| 275 | − tmp = REG_SET_FIELD(tmp, CP_MEC_CNTL, MEC_ME1_HALT, 1); | |
| 276 | − tmp = REG_SET_FIELD(tmp, CP_MEC_CNTL, MEC_ME2_HALT, 1); | |
| 277 | − WREG32(mmCP_MEC_CNTL, tmp); | |
| 278 | − | |
| 279 | − tmp = RREG32(mmCP_CPC_IC_BASE_CNTL); | |
| 280 | − tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, VMID, 0); | |
| 281 | − tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, ATC, 0); | |
| 282 | − tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, CACHE_POLICY, 0); | |
| 283 | − tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, MTYPE, 1); | |
| 284 | − WREG32(mmCP_CPC_IC_BASE_CNTL, tmp); | |
| 285 | − | |
| 286 | − reg_data = lower_32_bits(ucode->mc_addr) & | |
| 287 | − REG_FIELD_MASK(CP_CPC_IC_BASE_LO, IC_BASE_LO); | |
| 288 | − WREG32(mmCP_CPC_IC_BASE_LO, reg_data); | |
| 289 | − | |
| 290 | − reg_data = upper_32_bits(ucode->mc_addr) & | |
| 291 | − REG_FIELD_MASK(CP_CPC_IC_BASE_HI, IC_BASE_HI); | |
| 292 | − WREG32(mmCP_CPC_IC_BASE_HI, reg_data); | |
| 293 | − | |
| 294 | − return 0; | |
| 295 | −} | |
| 296 | − | |
| 297 | −int cz_smu_start(struct amdgpu_device *adev) | |
| 298 | −{ | |
| 299 | − int ret = 0; | |
| 300 | − | |
| 301 | − uint32_t fw_to_check = UCODE_ID_RLC_G_MASK | | |
| 302 | − UCODE_ID_SDMA0_MASK | | |
| 303 | − UCODE_ID_SDMA1_MASK | | |
| 304 | − UCODE_ID_CP_CE_MASK | | |
| 305 | − UCODE_ID_CP_ME_MASK | | |
| 306 | − UCODE_ID_CP_PFP_MASK | | |
| 307 | − UCODE_ID_CP_MEC_JT1_MASK | | |
| 308 | − UCODE_ID_CP_MEC_JT2_MASK; | |
| 309 | − | |
| 310 | − if (adev->asic_type == CHIP_STONEY) | |
| 311 | − fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); | |
| 312 | − | |
| 313 | − cz_smu_request_load_fw(adev); | |
| 314 | − ret = cz_smu_check_fw_load_finish(adev, fw_to_check); | |
| 315 | − if (ret) | |
| 316 | − return ret; | |
| 317 | − | |
| 318 | − /* manually load MEC firmware for CZ */ | |
| 319 | − if (adev->asic_type == CHIP_CARRIZO || adev->asic_type == CHIP_STONEY) { | |
| 320 | − ret = cz_load_mec_firmware(adev); | |
| 321 | − if (ret) { | |
| 322 | − dev_err(adev->dev, "(%d) Mec Firmware load failed\n", ret); | |
| 323 | − return ret; | |
| 324 | − } | |
| 325 | − } | |
| 326 | − | |
| 327 | − /* setup fw load flag */ | |
| 328 | − adev->smu.fw_flags = AMDGPU_SDMA0_UCODE_LOADED | | |
| 329 | − AMDGPU_SDMA1_UCODE_LOADED | | |
| 330 | − AMDGPU_CPCE_UCODE_LOADED | | |
| 331 | − AMDGPU_CPPFP_UCODE_LOADED | | |
| 332 | − AMDGPU_CPME_UCODE_LOADED | | |
| 333 | − AMDGPU_CPMEC1_UCODE_LOADED | | |
| 334 | − AMDGPU_CPMEC2_UCODE_LOADED | | |
| 335 | − AMDGPU_CPRLC_UCODE_LOADED; | |
| 336 | − | |
| 337 | − if (adev->asic_type == CHIP_STONEY) | |
| 338 | − adev->smu.fw_flags &= ~(AMDGPU_SDMA1_UCODE_LOADED | AMDGPU_CPMEC2_UCODE_LOADED); | |
| 339 | − | |
| 340 | − return ret; | |
| 341 | −} | |
| 342 | − | |
| 343 | −static uint32_t cz_convert_fw_type(uint32_t fw_type) | |
| 344 | −{ | |
| 345 | − enum AMDGPU_UCODE_ID result = AMDGPU_UCODE_ID_MAXIMUM; | |
| 346 | − | |
| 347 | − switch (fw_type) { | |
| 348 | − case UCODE_ID_SDMA0: | |
| 349 | − result = AMDGPU_UCODE_ID_SDMA0; | |
| 350 | − break; | |
| 351 | − case UCODE_ID_SDMA1: | |
| 352 | − result = AMDGPU_UCODE_ID_SDMA1; | |
| 353 | − break; | |
| 354 | − case UCODE_ID_CP_CE: | |
| 355 | − result = AMDGPU_UCODE_ID_CP_CE; | |
| 356 | − break; | |
| 357 | − case UCODE_ID_CP_PFP: | |
| 358 | − result = AMDGPU_UCODE_ID_CP_PFP; | |
| 359 | − break; | |
| 360 | − case UCODE_ID_CP_ME: | |
| 361 | − result = AMDGPU_UCODE_ID_CP_ME; | |
| 362 | − break; | |
| 363 | − case UCODE_ID_CP_MEC_JT1: | |
| 364 | − case UCODE_ID_CP_MEC_JT2: | |
| 365 | − result = AMDGPU_UCODE_ID_CP_MEC1; | |
| 366 | − break; | |
| 367 | − case UCODE_ID_RLC_G: | |
| 368 | − result = AMDGPU_UCODE_ID_RLC_G; | |
| 369 | − break; | |
| 370 | − default: | |
| 371 | − DRM_ERROR("UCode type is out of range!"); | |
| 372 | − } | |
| 373 | − | |
| 374 | − return result; | |
| 375 | −} | |
| 376 | − | |
| 377 | −static uint8_t cz_smu_translate_firmware_enum_to_arg( | |
| 378 | − enum cz_scratch_entry firmware_enum) | |
| 379 | −{ | |
| 380 | − uint8_t ret = 0; | |
| 381 | − | |
| 382 | − switch (firmware_enum) { | |
| 383 | − case CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0: | |
| 384 | − ret = UCODE_ID_SDMA0; | |
| 385 | − break; | |
| 386 | − case CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1: | |
| 387 | − ret = UCODE_ID_SDMA1; | |
| 388 | − break; | |
| 389 | − case CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE: | |
| 390 | − ret = UCODE_ID_CP_CE; | |
| 391 | − break; | |
| 392 | − case CZ_SCRATCH_ENTRY_UCODE_ID_CP_PFP: | |
| 393 | − ret = UCODE_ID_CP_PFP; | |
| 394 | − break; | |
| 395 | − case CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME: | |
| 396 | − ret = UCODE_ID_CP_ME; | |
| 397 | − break; | |
| 398 | − case CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1: | |
| 399 | − ret = UCODE_ID_CP_MEC_JT1; | |
| 400 | − break; | |
| 401 | − case CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2: | |
| 402 | − ret = UCODE_ID_CP_MEC_JT2; | |
| 403 | − break; | |
| 404 | − case CZ_SCRATCH_ENTRY_UCODE_ID_GMCON_RENG: | |
| 405 | − ret = UCODE_ID_GMCON_RENG; | |
| 406 | − break; | |
| 407 | − case CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G: | |
| 408 | − ret = UCODE_ID_RLC_G; | |
| 409 | − break; | |
| 410 | − case CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SCRATCH: | |
| 411 | − ret = UCODE_ID_RLC_SCRATCH; | |
| 412 | − break; | |
| 413 | − case CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_ARAM: | |
| 414 | − ret = UCODE_ID_RLC_SRM_ARAM; | |
| 415 | − break; | |
| 416 | − case CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_DRAM: | |
| 417 | − ret = UCODE_ID_RLC_SRM_DRAM; | |
| 418 | − break; | |
| 419 | − case CZ_SCRATCH_ENTRY_UCODE_ID_DMCU_ERAM: | |
| 420 | − ret = UCODE_ID_DMCU_ERAM; | |
| 421 | − break; | |
| 422 | − case CZ_SCRATCH_ENTRY_UCODE_ID_DMCU_IRAM: | |
| 423 | − ret = UCODE_ID_DMCU_IRAM; | |
| 424 | − break; | |
| 425 | − case CZ_SCRATCH_ENTRY_UCODE_ID_POWER_PROFILING: | |
| 426 | − ret = TASK_ARG_INIT_MM_PWR_LOG; | |
| 427 | − break; | |
| 428 | − case CZ_SCRATCH_ENTRY_DATA_ID_SDMA_HALT: | |
| 429 | − case CZ_SCRATCH_ENTRY_DATA_ID_SYS_CLOCKGATING: | |
| 430 | − case CZ_SCRATCH_ENTRY_DATA_ID_SDMA_RING_REGS: | |
| 431 | − case CZ_SCRATCH_ENTRY_DATA_ID_NONGFX_REINIT: | |
| 432 | − case CZ_SCRATCH_ENTRY_DATA_ID_SDMA_START: | |
| 433 | − case CZ_SCRATCH_ENTRY_DATA_ID_IH_REGISTERS: | |
| 434 | − ret = TASK_ARG_REG_MMIO; | |
| 435 | − break; | |
| 436 | − case CZ_SCRATCH_ENTRY_SMU8_FUSION_CLKTABLE: | |
| 437 | − ret = TASK_ARG_INIT_CLK_TABLE; | |
| 438 | − break; | |
| 439 | − } | |
| 440 | − | |
| 441 | − return ret; | |
| 442 | −} | |
| 443 | − | |
| 444 | −static int cz_smu_populate_single_firmware_entry(struct amdgpu_device *adev, | |
| 445 | − enum cz_scratch_entry firmware_enum, | |
| 446 | − struct cz_buffer_entry *entry) | |
| 447 | −{ | |
| 448 | − uint64_t gpu_addr; | |
| 449 | − uint32_t data_size; | |
| 450 | − uint8_t ucode_id = cz_smu_translate_firmware_enum_to_arg(firmware_enum); | |
| 451 | − enum AMDGPU_UCODE_ID id = cz_convert_fw_type(ucode_id); | |
| 452 | − struct amdgpu_firmware_info *ucode = &adev->firmware.ucode[id]; | |
| 453 | − const struct gfx_firmware_header_v1_0 *header; | |
| 454 | − | |
| 455 | − if (ucode->fw == NULL) | |
| 456 | − return -EINVAL; | |
| 457 | − | |
| 458 | − gpu_addr = ucode->mc_addr; | |
| 459 | − header = (const struct gfx_firmware_header_v1_0 *)ucode->fw->data; | |
| 460 | − data_size = le32_to_cpu(header->header.ucode_size_bytes); | |
| 461 | − | |
| 462 | − if ((firmware_enum == CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1) || | |
| 463 | − (firmware_enum == CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2)) { | |
| 464 | − gpu_addr += le32_to_cpu(header->jt_offset) << 2; | |
| 465 | − data_size = le32_to_cpu(header->jt_size) << 2; | |
| 466 | − } | |
| 467 | − | |
| 468 | − entry->mc_addr_low = lower_32_bits(gpu_addr); | |
| 469 | − entry->mc_addr_high = upper_32_bits(gpu_addr); | |
| 470 | − entry->data_size = data_size; | |
| 471 | − entry->firmware_ID = firmware_enum; | |
| 472 | − | |
| 473 | − return 0; | |
| 474 | −} | |
| 475 | − | |
| 476 | −static int cz_smu_populate_single_scratch_entry(struct amdgpu_device *adev, | |
| 477 | − enum cz_scratch_entry scratch_type, | |
| 478 | − uint32_t size_in_byte, | |
| 479 | − struct cz_buffer_entry *entry) | |
| 480 | −{ | |
| 481 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 482 | − uint64_t mc_addr = (((uint64_t) priv->smu_buffer.mc_addr_high) << 32) | | |
| 483 | − priv->smu_buffer.mc_addr_low; | |
| 484 | − mc_addr += size_in_byte; | |
| 485 | − | |
| 486 | − priv->smu_buffer_used_bytes += size_in_byte; | |
| 487 | − entry->data_size = size_in_byte; | |
| 488 | − entry->kaddr = priv->smu_buffer.kaddr + priv->smu_buffer_used_bytes; | |
| 489 | − entry->mc_addr_low = lower_32_bits(mc_addr); | |
| 490 | − entry->mc_addr_high = upper_32_bits(mc_addr); | |
| 491 | − entry->firmware_ID = scratch_type; | |
| 492 | − | |
| 493 | − return 0; | |
| 494 | −} | |
| 495 | − | |
| 496 | −static int cz_smu_populate_single_ucode_load_task(struct amdgpu_device *adev, | |
| 497 | − enum cz_scratch_entry firmware_enum, | |
| 498 | − bool is_last) | |
| 499 | −{ | |
| 500 | − uint8_t i; | |
| 501 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 502 | − struct TOC *toc = (struct TOC *)priv->toc_buffer.kaddr; | |
| 503 | − struct SMU_Task *task = &toc->tasks[priv->toc_entry_used_count++]; | |
| 504 | − | |
| 505 | − task->type = TASK_TYPE_UCODE_LOAD; | |
| 506 | − task->arg = cz_smu_translate_firmware_enum_to_arg(firmware_enum); | |
| 507 | − task->next = is_last ? END_OF_TASK_LIST : priv->toc_entry_used_count; | |
| 508 | − | |
| 509 | − for (i = 0; i < priv->driver_buffer_length; i++) | |
| 510 | − if (priv->driver_buffer[i].firmware_ID == firmware_enum) | |
| 511 | − break; | |
| 512 | − | |
| 513 | − if (i >= priv->driver_buffer_length) { | |
| 514 | − dev_err(adev->dev, "Invalid Firmware Type\n"); | |
| 515 | − return -EINVAL; | |
| 516 | − } | |
| 517 | − | |
| 518 | − task->addr.low = priv->driver_buffer[i].mc_addr_low; | |
| 519 | − task->addr.high = priv->driver_buffer[i].mc_addr_high; | |
| 520 | − task->size_bytes = priv->driver_buffer[i].data_size; | |
| 521 | − | |
| 522 | − return 0; | |
| 523 | −} | |
| 524 | − | |
| 525 | −static int cz_smu_populate_single_scratch_task(struct amdgpu_device *adev, | |
| 526 | − enum cz_scratch_entry firmware_enum, | |
| 527 | − uint8_t type, bool is_last) | |
| 528 | −{ | |
| 529 | − uint8_t i; | |
| 530 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 531 | − struct TOC *toc = (struct TOC *)priv->toc_buffer.kaddr; | |
| 532 | − struct SMU_Task *task = &toc->tasks[priv->toc_entry_used_count++]; | |
| 533 | − | |
| 534 | − task->type = type; | |
| 535 | − task->arg = cz_smu_translate_firmware_enum_to_arg(firmware_enum); | |
| 536 | − task->next = is_last ? END_OF_TASK_LIST : priv->toc_entry_used_count; | |
| 537 | − | |
| 538 | − for (i = 0; i < priv->scratch_buffer_length; i++) | |
| 539 | − if (priv->scratch_buffer[i].firmware_ID == firmware_enum) | |
| 540 | − break; | |
| 541 | − | |
| 542 | − if (i >= priv->scratch_buffer_length) { | |
| 543 | − dev_err(adev->dev, "Invalid Firmware Type\n"); | |
| 544 | − return -EINVAL; | |
| 545 | − } | |
| 546 | − | |
| 547 | − task->addr.low = priv->scratch_buffer[i].mc_addr_low; | |
| 548 | − task->addr.high = priv->scratch_buffer[i].mc_addr_high; | |
| 549 | − task->size_bytes = priv->scratch_buffer[i].data_size; | |
| 550 | − | |
| 551 | − if (CZ_SCRATCH_ENTRY_DATA_ID_IH_REGISTERS == firmware_enum) { | |
| 552 | − struct cz_ih_meta_data *pIHReg_restore = | |
| 553 | − (struct cz_ih_meta_data *)priv->scratch_buffer[i].kaddr; | |
| 554 | − pIHReg_restore->command = | |
| 555 | − METADATA_CMD_MODE0 | METADATA_PERFORM_ON_LOAD; | |
| 556 | − } | |
| 557 | − | |
| 558 | − return 0; | |
| 559 | −} | |
| 560 | − | |
| 561 | −static int cz_smu_construct_toc_for_rlc_aram_save(struct amdgpu_device *adev) | |
| 562 | −{ | |
| 563 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 564 | − priv->toc_entry_aram = priv->toc_entry_used_count; | |
| 565 | − cz_smu_populate_single_scratch_task(adev, | |
| 566 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_ARAM, | |
| 567 | − TASK_TYPE_UCODE_SAVE, true); | |
| 568 | − | |
| 569 | − return 0; | |
| 570 | −} | |
| 571 | − | |
| 572 | −static int cz_smu_construct_toc_for_vddgfx_enter(struct amdgpu_device *adev) | |
| 573 | −{ | |
| 574 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 575 | − struct TOC *toc = (struct TOC *)priv->toc_buffer.kaddr; | |
| 576 | − | |
| 577 | − toc->JobList[JOB_GFX_SAVE] = (uint8_t)priv->toc_entry_used_count; | |
| 578 | − cz_smu_populate_single_scratch_task(adev, | |
| 579 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SCRATCH, | |
| 580 | − TASK_TYPE_UCODE_SAVE, false); | |
| 581 | − cz_smu_populate_single_scratch_task(adev, | |
| 582 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_DRAM, | |
| 583 | − TASK_TYPE_UCODE_SAVE, true); | |
| 584 | − | |
| 585 | − return 0; | |
| 586 | −} | |
| 587 | − | |
| 588 | −static int cz_smu_construct_toc_for_vddgfx_exit(struct amdgpu_device *adev) | |
| 589 | −{ | |
| 590 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 591 | − struct TOC *toc = (struct TOC *)priv->toc_buffer.kaddr; | |
| 592 | − | |
| 593 | − toc->JobList[JOB_GFX_RESTORE] = (uint8_t)priv->toc_entry_used_count; | |
| 594 | − | |
| 595 | − /* populate ucode */ | |
| 596 | − if (adev->firmware.smu_load) { | |
| 597 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 598 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE, false); | |
| 599 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 600 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_PFP, false); | |
| 601 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 602 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false); | |
| 603 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 604 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | |
| 605 | − if (adev->asic_type == CHIP_STONEY) { | |
| 606 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 607 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | |
| 608 | − } else { | |
| 609 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 610 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false); | |
| 611 | − } | |
| 612 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 613 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, false); | |
| 614 | − } | |
| 615 | − | |
| 616 | − /* populate scratch */ | |
| 617 | − cz_smu_populate_single_scratch_task(adev, | |
| 618 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SCRATCH, | |
| 619 | − TASK_TYPE_UCODE_LOAD, false); | |
| 620 | − cz_smu_populate_single_scratch_task(adev, | |
| 621 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_ARAM, | |
| 622 | − TASK_TYPE_UCODE_LOAD, false); | |
| 623 | − cz_smu_populate_single_scratch_task(adev, | |
| 624 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_DRAM, | |
| 625 | − TASK_TYPE_UCODE_LOAD, true); | |
| 626 | − | |
| 627 | − return 0; | |
| 628 | −} | |
| 629 | − | |
| 630 | −static int cz_smu_construct_toc_for_power_profiling(struct amdgpu_device *adev) | |
| 631 | −{ | |
| 632 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 633 | − | |
| 634 | − priv->toc_entry_power_profiling_index = priv->toc_entry_used_count; | |
| 635 | − | |
| 636 | − cz_smu_populate_single_scratch_task(adev, | |
| 637 | − CZ_SCRATCH_ENTRY_UCODE_ID_POWER_PROFILING, | |
| 638 | − TASK_TYPE_INITIALIZE, true); | |
| 639 | − return 0; | |
| 640 | −} | |
| 641 | − | |
| 642 | −static int cz_smu_construct_toc_for_bootup(struct amdgpu_device *adev) | |
| 643 | −{ | |
| 644 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 645 | − | |
| 646 | − priv->toc_entry_initialize_index = priv->toc_entry_used_count; | |
| 647 | − | |
| 648 | − if (adev->firmware.smu_load) { | |
| 649 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 650 | − CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false); | |
| 651 | − if (adev->asic_type == CHIP_STONEY) { | |
| 652 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 653 | − CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false); | |
| 654 | − } else { | |
| 655 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 656 | − CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1, false); | |
| 657 | − } | |
| 658 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 659 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE, false); | |
| 660 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 661 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_PFP, false); | |
| 662 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 663 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false); | |
| 664 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 665 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | |
| 666 | − if (adev->asic_type == CHIP_STONEY) { | |
| 667 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 668 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | |
| 669 | − } else { | |
| 670 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 671 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false); | |
| 672 | − } | |
| 673 | − cz_smu_populate_single_ucode_load_task(adev, | |
| 674 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, true); | |
| 675 | − } | |
| 676 | − | |
| 677 | − return 0; | |
| 678 | −} | |
| 679 | − | |
| 680 | −static int cz_smu_construct_toc_for_clock_table(struct amdgpu_device *adev) | |
| 681 | −{ | |
| 682 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 683 | − | |
| 684 | − priv->toc_entry_clock_table = priv->toc_entry_used_count; | |
| 685 | − | |
| 686 | − cz_smu_populate_single_scratch_task(adev, | |
| 687 | − CZ_SCRATCH_ENTRY_SMU8_FUSION_CLKTABLE, | |
| 688 | − TASK_TYPE_INITIALIZE, true); | |
| 689 | − | |
| 690 | − return 0; | |
| 691 | −} | |
| 692 | − | |
| 693 | −static int cz_smu_initialize_toc_empty_job_list(struct amdgpu_device *adev) | |
| 694 | −{ | |
| 695 | − int i; | |
| 696 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 697 | − struct TOC *toc = (struct TOC *)priv->toc_buffer.kaddr; | |
| 698 | − | |
| 699 | − for (i = 0; i < NUM_JOBLIST_ENTRIES; i++) | |
| 700 | − toc->JobList[i] = (uint8_t)IGNORE_JOB; | |
| 701 | − | |
| 702 | − return 0; | |
| 703 | −} | |
| 704 | − | |
| 705 | −/* | |
| 706 | − * cz smu uninitialization | |
| 707 | − */ | |
| 708 | −int cz_smu_fini(struct amdgpu_device *adev) | |
| 709 | −{ | |
| 710 | − amdgpu_bo_unref(&adev->smu.toc_buf); | |
| 711 | − amdgpu_bo_unref(&adev->smu.smu_buf); | |
| 712 | − kfree(adev->smu.priv); | |
| 713 | − adev->smu.priv = NULL; | |
| 714 | − if (adev->firmware.smu_load) | |
| 715 | − amdgpu_ucode_fini_bo(adev); | |
| 716 | − | |
| 717 | − return 0; | |
| 718 | −} | |
| 719 | − | |
| 720 | −int cz_smu_download_pptable(struct amdgpu_device *adev, void **table) | |
| 721 | −{ | |
| 722 | − uint8_t i; | |
| 723 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 724 | − | |
| 725 | − for (i = 0; i < priv->scratch_buffer_length; i++) | |
| 726 | − if (priv->scratch_buffer[i].firmware_ID == | |
| 727 | − CZ_SCRATCH_ENTRY_SMU8_FUSION_CLKTABLE) | |
| 728 | − break; | |
| 729 | − | |
| 730 | − if (i >= priv->scratch_buffer_length) { | |
| 731 | − dev_err(adev->dev, "Invalid Scratch Type\n"); | |
| 732 | − return -EINVAL; | |
| 733 | − } | |
| 734 | − | |
| 735 | − *table = (struct SMU8_Fusion_ClkTable *)priv->scratch_buffer[i].kaddr; | |
| 736 | − | |
| 737 | − /* prepare buffer for pptable */ | |
| 738 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 739 | − PPSMC_MSG_SetClkTableAddrHi, | |
| 740 | − priv->scratch_buffer[i].mc_addr_high); | |
| 741 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 742 | − PPSMC_MSG_SetClkTableAddrLo, | |
| 743 | − priv->scratch_buffer[i].mc_addr_low); | |
| 744 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 745 | − PPSMC_MSG_ExecuteJob, | |
| 746 | − priv->toc_entry_clock_table); | |
| 747 | − | |
| 748 | − /* actual downloading */ | |
| 749 | − cz_send_msg_to_smc(adev, PPSMC_MSG_ClkTableXferToDram); | |
| 750 | − | |
| 751 | − return 0; | |
| 752 | −} | |
| 753 | − | |
| 754 | −int cz_smu_upload_pptable(struct amdgpu_device *adev) | |
| 755 | −{ | |
| 756 | − uint8_t i; | |
| 757 | − struct cz_smu_private_data *priv = cz_smu_get_priv(adev); | |
| 758 | − | |
| 759 | − for (i = 0; i < priv->scratch_buffer_length; i++) | |
| 760 | − if (priv->scratch_buffer[i].firmware_ID == | |
| 761 | − CZ_SCRATCH_ENTRY_SMU8_FUSION_CLKTABLE) | |
| 762 | − break; | |
| 763 | − | |
| 764 | − if (i >= priv->scratch_buffer_length) { | |
| 765 | − dev_err(adev->dev, "Invalid Scratch Type\n"); | |
| 766 | − return -EINVAL; | |
| 767 | − } | |
| 768 | − | |
| 769 | − /* prepare SMU */ | |
| 770 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 771 | − PPSMC_MSG_SetClkTableAddrHi, | |
| 772 | − priv->scratch_buffer[i].mc_addr_high); | |
| 773 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 774 | − PPSMC_MSG_SetClkTableAddrLo, | |
| 775 | − priv->scratch_buffer[i].mc_addr_low); | |
| 776 | − cz_send_msg_to_smc_with_parameter(adev, | |
| 777 | − PPSMC_MSG_ExecuteJob, | |
| 778 | − priv->toc_entry_clock_table); | |
| 779 | − | |
| 780 | − /* actual uploading */ | |
| 781 | − cz_send_msg_to_smc(adev, PPSMC_MSG_ClkTableXferToSmu); | |
| 782 | − | |
| 783 | − return 0; | |
| 784 | −} | |
| 785 | − | |
| 786 | −/* | |
| 787 | − * cz smumgr functions initialization | |
| 788 | − */ | |
| 789 | −static const struct amdgpu_smumgr_funcs cz_smumgr_funcs = { | |
| 790 | − .check_fw_load_finish = cz_smu_check_finished, | |
| 791 | − .request_smu_load_fw = NULL, | |
| 792 | − .request_smu_specific_fw = NULL, | |
| 793 | −}; | |
| 794 | − | |
| 795 | −/* | |
| 796 | − * cz smu initialization | |
| 797 | − */ | |
| 798 | −int cz_smu_init(struct amdgpu_device *adev) | |
| 799 | −{ | |
| 800 | − int ret = -EINVAL; | |
| 801 | − uint64_t mc_addr = 0; | |
| 802 | − struct amdgpu_bo **toc_buf = &adev->smu.toc_buf; | |
| 803 | − struct amdgpu_bo **smu_buf = &adev->smu.smu_buf; | |
| 804 | − void *toc_buf_ptr = NULL; | |
| 805 | − void *smu_buf_ptr = NULL; | |
| 806 | − | |
| 807 | − struct cz_smu_private_data *priv = | |
| 808 | − kzalloc(sizeof(struct cz_smu_private_data), GFP_KERNEL); | |
| 809 | − if (priv == NULL) | |
| 810 | − return -ENOMEM; | |
| 811 | − | |
| 812 | − /* allocate firmware buffers */ | |
| 813 | − if (adev->firmware.smu_load) | |
| 814 | − amdgpu_ucode_init_bo(adev); | |
| 815 | − | |
| 816 | − adev->smu.priv = priv; | |
| 817 | − adev->smu.fw_flags = 0; | |
| 818 | − priv->toc_buffer.data_size = 4096; | |
| 819 | − | |
| 820 | − priv->smu_buffer.data_size = | |
| 821 | − ALIGN(UCODE_ID_RLC_SCRATCH_SIZE_BYTE, 32) + | |
| 822 | − ALIGN(UCODE_ID_RLC_SRM_ARAM_SIZE_BYTE, 32) + | |
| 823 | − ALIGN(UCODE_ID_RLC_SRM_DRAM_SIZE_BYTE, 32) + | |
| 824 | − ALIGN(sizeof(struct SMU8_MultimediaPowerLogData), 32) + | |
| 825 | − ALIGN(sizeof(struct SMU8_Fusion_ClkTable), 32); | |
| 826 | − | |
| 827 | − /* prepare toc buffer and smu buffer: | |
| 828 | − * 1. create amdgpu_bo for toc buffer and smu buffer | |
| 829 | − * 2. pin mc address | |
| 830 | − * 3. map kernel virtual address | |
| 831 | − */ | |
| 832 | − ret = amdgpu_bo_create(adev, priv->toc_buffer.data_size, PAGE_SIZE, | |
| 833 | − true, AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, | |
| 834 | − toc_buf); | |
| 835 | − | |
| 836 | − if (ret) { | |
| 837 | − dev_err(adev->dev, "(%d) SMC TOC buffer allocation failed\n", ret); | |
| 838 | − return ret; | |
| 839 | − } | |
| 840 | − | |
| 841 | − ret = amdgpu_bo_create(adev, priv->smu_buffer.data_size, PAGE_SIZE, | |
| 842 | − true, AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, | |
| 843 | − smu_buf); | |
| 844 | − | |
| 845 | − if (ret) { | |
| 846 | − dev_err(adev->dev, "(%d) SMC Internal buffer allocation failed\n", ret); | |
| 847 | − return ret; | |
| 848 | − } | |
| 849 | − | |
| 850 | − /* toc buffer reserve/pin/map */ | |
| 851 | − ret = amdgpu_bo_reserve(adev->smu.toc_buf, false); | |
| 852 | − if (ret) { | |
| 853 | − amdgpu_bo_unref(&adev->smu.toc_buf); | |
| 854 | − dev_err(adev->dev, "(%d) SMC TOC buffer reserve failed\n", ret); | |
| 855 | − return ret; | |
| 856 | − } | |
| 857 | − | |
| 858 | − ret = amdgpu_bo_pin(adev->smu.toc_buf, AMDGPU_GEM_DOMAIN_GTT, &mc_addr); | |
| 859 | − if (ret) { | |
| 860 | − amdgpu_bo_unreserve(adev->smu.toc_buf); | |
| 861 | − amdgpu_bo_unref(&adev->smu.toc_buf); | |
| 862 | − dev_err(adev->dev, "(%d) SMC TOC buffer pin failed\n", ret); | |
| 863 | − return ret; | |
| 864 | − } | |
| 865 | − | |
| 866 | − ret = amdgpu_bo_kmap(*toc_buf, &toc_buf_ptr); | |
| 867 | − if (ret) | |
| 868 | − goto smu_init_failed; | |
| 869 | − | |
| 870 | − amdgpu_bo_unreserve(adev->smu.toc_buf); | |
| 871 | − | |
| 872 | − priv->toc_buffer.mc_addr_low = lower_32_bits(mc_addr); | |
| 873 | − priv->toc_buffer.mc_addr_high = upper_32_bits(mc_addr); | |
| 874 | − priv->toc_buffer.kaddr = toc_buf_ptr; | |
| 875 | − | |
| 876 | − /* smu buffer reserve/pin/map */ | |
| 877 | − ret = amdgpu_bo_reserve(adev->smu.smu_buf, false); | |
| 878 | − if (ret) { | |
| 879 | − amdgpu_bo_unref(&adev->smu.smu_buf); | |
| 880 | − dev_err(adev->dev, "(%d) SMC Internal buffer reserve failed\n", ret); | |
| 881 | − return ret; | |
| 882 | − } | |
| 883 | − | |
| 884 | − ret = amdgpu_bo_pin(adev->smu.smu_buf, AMDGPU_GEM_DOMAIN_GTT, &mc_addr); | |
| 885 | − if (ret) { | |
| 886 | − amdgpu_bo_unreserve(adev->smu.smu_buf); | |
| 887 | − amdgpu_bo_unref(&adev->smu.smu_buf); | |
| 888 | − dev_err(adev->dev, "(%d) SMC Internal buffer pin failed\n", ret); | |
| 889 | − return ret; | |
| 890 | − } | |
| 891 | − | |
| 892 | − ret = amdgpu_bo_kmap(*smu_buf, &smu_buf_ptr); | |
| 893 | − if (ret) | |
| 894 | − goto smu_init_failed; | |
| 895 | − | |
| 896 | − amdgpu_bo_unreserve(adev->smu.smu_buf); | |
| 897 | − | |
| 898 | − priv->smu_buffer.mc_addr_low = lower_32_bits(mc_addr); | |
| 899 | − priv->smu_buffer.mc_addr_high = upper_32_bits(mc_addr); | |
| 900 | − priv->smu_buffer.kaddr = smu_buf_ptr; | |
| 901 | − | |
| 902 | − if (adev->firmware.smu_load) { | |
| 903 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 904 | − CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, | |
| 905 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 906 | − goto smu_init_failed; | |
| 907 | − | |
| 908 | − if (adev->asic_type == CHIP_STONEY) { | |
| 909 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 910 | − CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, | |
| 911 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 912 | − goto smu_init_failed; | |
| 913 | − } else { | |
| 914 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 915 | − CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1, | |
| 916 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 917 | − goto smu_init_failed; | |
| 918 | − } | |
| 919 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 920 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE, | |
| 921 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 922 | − goto smu_init_failed; | |
| 923 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 924 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_PFP, | |
| 925 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 926 | − goto smu_init_failed; | |
| 927 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 928 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, | |
| 929 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 930 | − goto smu_init_failed; | |
| 931 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 932 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, | |
| 933 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 934 | − goto smu_init_failed; | |
| 935 | − if (adev->asic_type == CHIP_STONEY) { | |
| 936 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 937 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, | |
| 938 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 939 | − goto smu_init_failed; | |
| 940 | − } else { | |
| 941 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 942 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, | |
| 943 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 944 | − goto smu_init_failed; | |
| 945 | − } | |
| 946 | − if (cz_smu_populate_single_firmware_entry(adev, | |
| 947 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, | |
| 948 | − &priv->driver_buffer[priv->driver_buffer_length++])) | |
| 949 | − goto smu_init_failed; | |
| 950 | − } | |
| 951 | − | |
| 952 | − if (cz_smu_populate_single_scratch_entry(adev, | |
| 953 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SCRATCH, | |
| 954 | − UCODE_ID_RLC_SCRATCH_SIZE_BYTE, | |
| 955 | − &priv->scratch_buffer[priv->scratch_buffer_length++])) | |
| 956 | − goto smu_init_failed; | |
| 957 | − if (cz_smu_populate_single_scratch_entry(adev, | |
| 958 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_ARAM, | |
| 959 | − UCODE_ID_RLC_SRM_ARAM_SIZE_BYTE, | |
| 960 | − &priv->scratch_buffer[priv->scratch_buffer_length++])) | |
| 961 | − goto smu_init_failed; | |
| 962 | − if (cz_smu_populate_single_scratch_entry(adev, | |
| 963 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_DRAM, | |
| 964 | − UCODE_ID_RLC_SRM_DRAM_SIZE_BYTE, | |
| 965 | − &priv->scratch_buffer[priv->scratch_buffer_length++])) | |
| 966 | − goto smu_init_failed; | |
| 967 | − if (cz_smu_populate_single_scratch_entry(adev, | |
| 968 | − CZ_SCRATCH_ENTRY_UCODE_ID_POWER_PROFILING, | |
| 969 | − sizeof(struct SMU8_MultimediaPowerLogData), | |
| 970 | − &priv->scratch_buffer[priv->scratch_buffer_length++])) | |
| 971 | − goto smu_init_failed; | |
| 972 | − if (cz_smu_populate_single_scratch_entry(adev, | |
| 973 | − CZ_SCRATCH_ENTRY_SMU8_FUSION_CLKTABLE, | |
| 974 | − sizeof(struct SMU8_Fusion_ClkTable), | |
| 975 | − &priv->scratch_buffer[priv->scratch_buffer_length++])) | |
| 976 | − goto smu_init_failed; | |
| 977 | − | |
| 978 | − cz_smu_initialize_toc_empty_job_list(adev); | |
| 979 | − cz_smu_construct_toc_for_rlc_aram_save(adev); | |
| 980 | − cz_smu_construct_toc_for_vddgfx_enter(adev); | |
| 981 | − cz_smu_construct_toc_for_vddgfx_exit(adev); | |
| 982 | − cz_smu_construct_toc_for_power_profiling(adev); | |
| 983 | − cz_smu_construct_toc_for_bootup(adev); | |
| 984 | − cz_smu_construct_toc_for_clock_table(adev); | |
| 985 | − /* init the smumgr functions */ | |
| 986 | − adev->smu.smumgr_funcs = &cz_smumgr_funcs; | |
| 987 | − | |
| 988 | − return 0; | |
| 989 | − | |
| 990 | −smu_init_failed: | |
| 991 | − amdgpu_bo_unref(toc_buf); | |
| 992 | − amdgpu_bo_unref(smu_buf); | |
| 993 | − | |
| 994 | − return ret; | |
| 995 | −} | |
| @@ -1,94 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright 2014 Advanced Micro Devices, Inc. | |
| 3 | − * | |
| 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: | |
| 10 | − * | |
| 11 | − * The above copyright notice and this permission notice shall be included in | |
| 12 | − * all copies or substantial portions of the Software. | |
| 13 | − * | |
| 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. | |
| 21 | − * | |
| 22 | − */ | |
| 23 | −#ifndef __CZ_SMC_H__ | |
| 24 | −#define __CZ_SMC_H__ | |
| 25 | − | |
| 26 | −#define MAX_NUM_FIRMWARE 8 | |
| 27 | −#define MAX_NUM_SCRATCH 11 | |
| 28 | −#define CZ_SCRATCH_SIZE_NONGFX_CLOCKGATING 1024 | |
| 29 | −#define CZ_SCRATCH_SIZE_NONGFX_GOLDENSETTING 2048 | |
| 30 | −#define CZ_SCRATCH_SIZE_SDMA_METADATA 1024 | |
| 31 | −#define CZ_SCRATCH_SIZE_IH ((2*256+1)*4) | |
| 32 | − | |
| 33 | −enum cz_scratch_entry { | |
| 34 | − CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0 = 0, | |
| 35 | − CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1, | |
| 36 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE, | |
| 37 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_PFP, | |
| 38 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, | |
| 39 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, | |
| 40 | − CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, | |
| 41 | − CZ_SCRATCH_ENTRY_UCODE_ID_GMCON_RENG, | |
| 42 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, | |
| 43 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SCRATCH, | |
| 44 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_ARAM, | |
| 45 | − CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_DRAM, | |
| 46 | − CZ_SCRATCH_ENTRY_UCODE_ID_DMCU_ERAM, | |
| 47 | − CZ_SCRATCH_ENTRY_UCODE_ID_DMCU_IRAM, | |
| 48 | − CZ_SCRATCH_ENTRY_UCODE_ID_POWER_PROFILING, | |
| 49 | − CZ_SCRATCH_ENTRY_DATA_ID_SDMA_HALT, | |
| 50 | − CZ_SCRATCH_ENTRY_DATA_ID_SYS_CLOCKGATING, | |
| 51 | − CZ_SCRATCH_ENTRY_DATA_ID_SDMA_RING_REGS, | |
| 52 | − CZ_SCRATCH_ENTRY_DATA_ID_NONGFX_REINIT, | |
| 53 | − CZ_SCRATCH_ENTRY_DATA_ID_SDMA_START, | |
| 54 | − CZ_SCRATCH_ENTRY_DATA_ID_IH_REGISTERS, | |
| 55 | − CZ_SCRATCH_ENTRY_SMU8_FUSION_CLKTABLE | |
| 56 | −}; | |
| 57 | − | |
| 58 | −struct cz_buffer_entry { | |
| 59 | − uint32_t data_size; | |
| 60 | − uint32_t mc_addr_low; | |
| 61 | − uint32_t mc_addr_high; | |
| 62 | − void *kaddr; | |
| 63 | − enum cz_scratch_entry firmware_ID; | |
| 64 | −}; | |
| 65 | − | |
| 66 | −struct cz_register_index_data_pair { | |
| 67 | − uint32_t offset; | |
| 68 | − uint32_t value; | |
| 69 | −}; | |
| 70 | − | |
| 71 | −struct cz_ih_meta_data { | |
| 72 | − uint32_t command; | |
| 73 | − struct cz_register_index_data_pair register_index_value_pair[1]; | |
| 74 | −}; | |
| 75 | − | |
| 76 | −struct cz_smu_private_data { | |
| 77 | − uint8_t driver_buffer_length; | |
| 78 | − uint8_t scratch_buffer_length; | |
| 79 | − uint16_t toc_entry_used_count; | |
| 80 | − uint16_t toc_entry_initialize_index; | |
| 81 | − uint16_t toc_entry_power_profiling_index; | |
| 82 | − uint16_t toc_entry_aram; | |
| 83 | − uint16_t toc_entry_ih_register_restore_task_index; | |
| 84 | − uint16_t toc_entry_clock_table; | |
| 85 | − uint16_t ih_register_restore_task_size; | |
| 86 | − uint16_t smu_buffer_used_bytes; | |
| 87 | − | |
| 88 | − struct cz_buffer_entry toc_buffer; | |
| 89 | − struct cz_buffer_entry smu_buffer; | |
| 90 | − struct cz_buffer_entry driver_buffer[MAX_NUM_FIRMWARE]; | |
| 91 | − struct cz_buffer_entry scratch_buffer[MAX_NUM_SCRATCH]; | |
| 92 | −}; | |
| 93 | − | |
| 94 | −#endif | |
| @@ -25,7 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "amdgpu_ih.h" |
| 26 | 26 | #include "amdgpu_gfx.h" |
| 27 | 27 | #include "amdgpu_ucode.h" |
| 28 | −#include "si/clearstate_si.h" | |
| 28 | +#include "clearstate_si.h" | |
| 29 | 29 | #include "bif/bif_3_0_d.h" |
| 30 | 30 | #include "bif/bif_3_0_sh_mask.h" |
| 31 | 31 | #include "oss/oss_1_0_d.h" |
| @@ -1794,14 +1794,9 @@ static void gfx_v6_0_gpu_init(struct amdgpu_device *adev) · 1762 unmodified lines | ||
| 1794 | 1794 | |
| 1795 | 1795 | static void gfx_v6_0_scratch_init(struct amdgpu_device *adev) |
| 1796 | 1796 | { |
| 1797 | − int i; | |
| 1798 | − | |
| 1799 | 1797 | adev->gfx.scratch.num_reg = 7; |
| 1800 | 1798 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; |
| 1801 | − for (i = 0; i < adev->gfx.scratch.num_reg; i++) { | |
| 1802 | − adev->gfx.scratch.free[i] = true; | |
| 1803 | − adev->gfx.scratch.reg[i] = adev->gfx.scratch.reg_base + i; | |
| 1804 | − } | |
| 1799 | + adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; | |
| 1805 | 1800 | } |
| 1806 | 1801 | |
| 1807 | 1802 | static int gfx_v6_0_ring_test_ring(struct amdgpu_ring *ring) |
| @@ -1975,7 +1970,7 @@ static int gfx_v6_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) · 167 unmodified lines | ||
| 1975 | 1970 | ib.ptr[2] = 0xDEADBEEF; |
| 1976 | 1971 | ib.length_dw = 3; |
| 1977 | 1972 | |
| 1978 | − r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | |
| 1973 | + r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f); | |
| 1979 | 1974 | if (r) |
| 1980 | 1975 | goto err2; |
| 1981 | 1976 | |
| @@ -2003,14 +2003,9 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev) · 2002 unmodified lines | ||
| 2003 | 2003 | */ |
| 2004 | 2004 | static void gfx_v7_0_scratch_init(struct amdgpu_device *adev) |
| 2005 | 2005 | { |
| 2006 | − int i; | |
| 2007 | − | |
| 2008 | 2006 | adev->gfx.scratch.num_reg = 7; |
| 2009 | 2007 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; |
| 2010 | − for (i = 0; i < adev->gfx.scratch.num_reg; i++) { | |
| 2011 | − adev->gfx.scratch.free[i] = true; | |
| 2012 | − adev->gfx.scratch.reg[i] = adev->gfx.scratch.reg_base + i; | |
| 2013 | − } | |
| 2008 | + adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; | |
| 2014 | 2009 | } |
| 2015 | 2010 | |
| 2016 | 2011 | /** |
| @@ -2321,7 +2316,7 @@ static int gfx_v7_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) · 304 unmodified lines | ||
| 2321 | 2316 | ib.ptr[2] = 0xDEADBEEF; |
| 2322 | 2317 | ib.length_dw = 3; |
| 2323 | 2318 | |
| 2324 | − r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | |
| 2319 | + r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f); | |
| 2325 | 2320 | if (r) |
| 2326 | 2321 | goto err2; |
| 2327 | 2322 | |
| @@ -657,6 +657,8 @@ static void gfx_v8_0_set_gds_init(struct amdgpu_device *adev); · 656 unmodified lines | ||
| 657 | 657 | static void gfx_v8_0_set_rlc_funcs(struct amdgpu_device *adev); |
| 658 | 658 | static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev); |
| 659 | 659 | static void gfx_v8_0_get_cu_info(struct amdgpu_device *adev); |
| 660 | +static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t addr); | |
| 661 | +static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t addr); | |
| 660 | 662 | |
| 661 | 663 | static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev) |
| 662 | 664 | { |
| @@ -749,14 +751,9 @@ static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev) · 86 unmodified lines | ||
| 749 | 751 | |
| 750 | 752 | static void gfx_v8_0_scratch_init(struct amdgpu_device *adev) |
| 751 | 753 | { |
| 752 | − int i; | |
| 753 | − | |
| 754 | 754 | adev->gfx.scratch.num_reg = 7; |
| 755 | 755 | adev->gfx.scratch.reg_base = mmSCRATCH_REG0; |
| 756 | − for (i = 0; i < adev->gfx.scratch.num_reg; i++) { | |
| 757 | − adev->gfx.scratch.free[i] = true; | |
| 758 | − adev->gfx.scratch.reg[i] = adev->gfx.scratch.reg_base + i; | |
| 759 | − } | |
| 756 | + adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1; | |
| 760 | 757 | } |
| 761 | 758 | |
| 762 | 759 | static int gfx_v8_0_ring_test_ring(struct amdgpu_ring *ring) |
| @@ -829,7 +826,7 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) · 66 unmodified lines | ||
| 829 | 826 | ib.ptr[2] = 0xDEADBEEF; |
| 830 | 827 | ib.length_dw = 3; |
| 831 | 828 | |
| 832 | − r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | |
| 829 | + r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f); | |
| 833 | 830 | if (r) |
| 834 | 831 | goto err2; |
| 835 | 832 | |
| @@ -941,6 +938,13 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 105 unmodified lines | ||
| 941 | 938 | goto out; |
| 942 | 939 | cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data; |
| 943 | 940 | adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); |
| 941 | + | |
| 942 | + /* chain ib ucode isn't formal released, just disable it by far | |
| 943 | + * TODO: when ucod ready we should use ucode version to judge if | |
| 944 | + * chain-ib support or not. | |
| 945 | + */ | |
| 946 | + adev->virt.chained_ib_support = false; | |
| 947 | + | |
| 944 | 948 | adev->gfx.me_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); |
| 945 | 949 | |
| 946 | 950 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name); |
| @@ -1367,6 +1371,51 @@ static void gfx_v8_0_mec_fini(struct amdgpu_device *adev) · 420 unmodified lines | ||
| 1367 | 1371 | } |
| 1368 | 1372 | } |
| 1369 | 1373 | |
| 1374 | +static int gfx_v8_0_kiq_init_ring(struct amdgpu_device *adev, | |
| 1375 | + struct amdgpu_ring *ring, | |
| 1376 | + struct amdgpu_irq_src *irq) | |
| 1377 | +{ | |
| 1378 | + int r = 0; | |
| 1379 | + | |
| 1380 | + if (amdgpu_sriov_vf(adev)) { | |
| 1381 | + r = amdgpu_wb_get(adev, &adev->virt.reg_val_offs); | |
| 1382 | + if (r) | |
| 1383 | + return r; | |
| 1384 | + } | |
| 1385 | + | |
| 1386 | + ring->adev = NULL; | |
| 1387 | + ring->ring_obj = NULL; | |
| 1388 | + ring->use_doorbell = true; | |
| 1389 | + ring->doorbell_index = AMDGPU_DOORBELL_KIQ; | |
| 1390 | + if (adev->gfx.mec2_fw) { | |
| 1391 | + ring->me = 2; | |
| 1392 | + ring->pipe = 0; | |
| 1393 | + } else { | |
| 1394 | + ring->me = 1; | |
| 1395 | + ring->pipe = 1; | |
| 1396 | + } | |
| 1397 | + | |
| 1398 | + irq->data = ring; | |
| 1399 | + ring->queue = 0; | |
| 1400 | + sprintf(ring->name, "kiq %d.%d.%d", ring->me, ring->pipe, ring->queue); | |
| 1401 | + r = amdgpu_ring_init(adev, ring, 1024, | |
| 1402 | + irq, AMDGPU_CP_KIQ_IRQ_DRIVER0); | |
| 1403 | + if (r) | |
| 1404 | + dev_warn(adev->dev, "(%d) failed to init kiq ring\n", r); | |
| 1405 | + | |
| 1406 | + return r; | |
| 1407 | +} | |
| 1408 | + | |
| 1409 | +static void gfx_v8_0_kiq_free_ring(struct amdgpu_ring *ring, | |
| 1410 | + struct amdgpu_irq_src *irq) | |
| 1411 | +{ | |
| 1412 | + if (amdgpu_sriov_vf(ring->adev)) | |
| 1413 | + amdgpu_wb_free(ring->adev, ring->adev->virt.reg_val_offs); | |
| 1414 | + | |
| 1415 | + amdgpu_ring_fini(ring); | |
| 1416 | + irq->data = NULL; | |
| 1417 | +} | |
| 1418 | + | |
| 1370 | 1419 | #define MEC_HPD_SIZE 2048 |
| 1371 | 1420 | |
| 1372 | 1421 | static int gfx_v8_0_mec_init(struct amdgpu_device *adev) |
| @@ -1421,6 +1470,35 @@ static int gfx_v8_0_mec_init(struct amdgpu_device *adev) · 48 unmodified lines | ||
| 1421 | 1470 | return 0; |
| 1422 | 1471 | } |
| 1423 | 1472 | |
| 1473 | +static void gfx_v8_0_kiq_fini(struct amdgpu_device *adev) | |
| 1474 | +{ | |
| 1475 | + struct amdgpu_kiq *kiq = &adev->gfx.kiq; | |
| 1476 | + | |
| 1477 | + amdgpu_bo_free_kernel(&kiq->eop_obj, &kiq->eop_gpu_addr, NULL); | |
| 1478 | + kiq->eop_obj = NULL; | |
| 1479 | +} | |
| 1480 | + | |
| 1481 | +static int gfx_v8_0_kiq_init(struct amdgpu_device *adev) | |
| 1482 | +{ | |
| 1483 | + int r; | |
| 1484 | + u32 *hpd; | |
| 1485 | + struct amdgpu_kiq *kiq = &adev->gfx.kiq; | |
| 1486 | + | |
| 1487 | + r = amdgpu_bo_create_kernel(adev, MEC_HPD_SIZE, PAGE_SIZE, | |
| 1488 | + AMDGPU_GEM_DOMAIN_GTT, &kiq->eop_obj, | |
| 1489 | + &kiq->eop_gpu_addr, (void **)&hpd); | |
| 1490 | + if (r) { | |
| 1491 | + dev_warn(adev->dev, "failed to create KIQ bo (%d).\n", r); | |
| 1492 | + return r; | |
| 1493 | + } | |
| 1494 | + | |
| 1495 | + memset(hpd, 0, MEC_HPD_SIZE); | |
| 1496 | + | |
| 1497 | + amdgpu_bo_kunmap(kiq->eop_obj); | |
| 1498 | + | |
| 1499 | + return 0; | |
| 1500 | +} | |
| 1501 | + | |
| 1424 | 1502 | static const u32 vgpr_init_compute_shader[] = |
| 1425 | 1503 | { |
| 1426 | 1504 | 0x7e000209, 0x7e020208, |
| @@ -1702,7 +1780,7 @@ static int gfx_v8_0_do_edc_gpr_workarounds(struct amdgpu_device *adev) · 275 unmodified lines | ||
| 1702 | 1780 | ib.ptr[ib.length_dw++] = EVENT_TYPE(7) | EVENT_INDEX(4); |
| 1703 | 1781 | |
| 1704 | 1782 | /* shedule the ib on the ring */ |
| 1705 | − r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | |
| 1783 | + r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f); | |
| 1706 | 1784 | if (r) { |
| 1707 | 1785 | DRM_ERROR("amdgpu: ib submit failed (%d).\n", r); |
| 1708 | 1786 | goto fail; |
| @@ -1997,8 +2075,14 @@ static int gfx_v8_0_sw_init(void *handle) · 288 unmodified lines | ||
| 1997 | 2075 | { |
| 1998 | 2076 | int i, r; |
| 1999 | 2077 | struct amdgpu_ring *ring; |
| 2078 | + struct amdgpu_kiq *kiq; | |
| 2000 | 2079 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 2001 | 2080 | |
| 2081 | + /* KIQ event */ | |
| 2082 | + r = amdgpu_irq_add_id(adev, 178, &adev->gfx.kiq.irq); | |
| 2083 | + if (r) | |
| 2084 | + return r; | |
| 2085 | + | |
| 2002 | 2086 | /* EOP Event */ |
| 2003 | 2087 | r = amdgpu_irq_add_id(adev, 181, &adev->gfx.eop_irq); |
| 2004 | 2088 | if (r) |
| @@ -2036,6 +2120,17 @@ static int gfx_v8_0_sw_init(void *handle) · 31 unmodified lines | ||
| 2036 | 2120 | return r; |
| 2037 | 2121 | } |
| 2038 | 2122 | |
| 2123 | + r = gfx_v8_0_kiq_init(adev); | |
| 2124 | + if (r) { | |
| 2125 | + DRM_ERROR("Failed to init KIQ BOs!\n"); | |
| 2126 | + return r; | |
| 2127 | + } | |
| 2128 | + | |
| 2129 | + kiq = &adev->gfx.kiq; | |
| 2130 | + r = gfx_v8_0_kiq_init_ring(adev, &kiq->ring, &kiq->irq); | |
| 2131 | + if (r) | |
| 2132 | + return r; | |
| 2133 | + | |
| 2039 | 2134 | /* set up the gfx ring */ |
| 2040 | 2135 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) { |
| 2041 | 2136 | ring = &adev->gfx.gfx_ring[i]; |
| @@ -2119,7 +2214,9 @@ static int gfx_v8_0_sw_fini(void *handle) · 77 unmodified lines | ||
| 2119 | 2214 | amdgpu_ring_fini(&adev->gfx.gfx_ring[i]); |
| 2120 | 2215 | for (i = 0; i < adev->gfx.num_compute_rings; i++) |
| 2121 | 2216 | amdgpu_ring_fini(&adev->gfx.compute_ring[i]); |
| 2217 | + gfx_v8_0_kiq_free_ring(&adev->gfx.kiq.ring, &adev->gfx.kiq.irq); | |
| 2122 | 2218 | |
| 2219 | + gfx_v8_0_kiq_fini(adev); | |
| 2123 | 2220 | gfx_v8_0_mec_fini(adev); |
| 2124 | 2221 | gfx_v8_0_rlc_fini(adev); |
| 2125 | 2222 | gfx_v8_0_free_microcode(adev); |
| @@ -4024,17 +4121,6 @@ static void gfx_v8_0_init_pg(struct amdgpu_device *adev) · 1898 unmodified lines | ||
| 4024 | 4121 | WREG32(mmRLC_JUMP_TABLE_RESTORE, adev->gfx.rlc.cp_table_gpu_addr >> 8); |
| 4025 | 4122 | gfx_v8_0_init_power_gating(adev); |
| 4026 | 4123 | WREG32(mmRLC_PG_ALWAYS_ON_CU_MASK, adev->gfx.cu_info.ao_cu_mask); |
| 4027 | − if (adev->pg_flags & AMD_PG_SUPPORT_RLC_SMU_HS) { | |
| 4028 | − cz_enable_sck_slow_down_on_power_up(adev, true); | |
| 4029 | − cz_enable_sck_slow_down_on_power_down(adev, true); | |
| 4030 | − } else { | |
| 4031 | − cz_enable_sck_slow_down_on_power_up(adev, false); | |
| 4032 | − cz_enable_sck_slow_down_on_power_down(adev, false); | |
| 4033 | − } | |
| 4034 | − if (adev->pg_flags & AMD_PG_SUPPORT_CP) | |
| 4035 | − cz_enable_cp_power_gating(adev, true); | |
| 4036 | − else | |
| 4037 | − cz_enable_cp_power_gating(adev, false); | |
| 4038 | 4124 | } else if ((adev->asic_type == CHIP_POLARIS11) || |
| 4039 | 4125 | (adev->asic_type == CHIP_POLARIS12)) { |
| 4040 | 4126 | gfx_v8_0_init_csb(adev); |
| @@ -4506,6 +4592,393 @@ static void gfx_v8_0_cp_compute_fini(struct amdgpu_device *adev) · 465 unmodified lines | ||
| 4506 | 4592 | } |
| 4507 | 4593 | } |
| 4508 | 4594 | |
| 4595 | +/* KIQ functions */ | |
| 4596 | +static void gfx_v8_0_kiq_setting(struct amdgpu_ring *ring) | |
| 4597 | +{ | |
| 4598 | + uint32_t tmp; | |
| 4599 | + struct amdgpu_device *adev = ring->adev; | |
| 4600 | + | |
| 4601 | + /* tell RLC which is KIQ queue */ | |
| 4602 | + tmp = RREG32(mmRLC_CP_SCHEDULERS); | |
| 4603 | + tmp &= 0xffffff00; | |
| 4604 | + tmp |= (ring->me << 5) | (ring->pipe << 3) | (ring->queue); | |
| 4605 | + WREG32(mmRLC_CP_SCHEDULERS, tmp); | |
| 4606 | + tmp |= 0x80; | |
| 4607 | + WREG32(mmRLC_CP_SCHEDULERS, tmp); | |
| 4608 | +} | |
| 4609 | + | |
| 4610 | +static void gfx_v8_0_kiq_enable(struct amdgpu_ring *ring) | |
| 4611 | +{ | |
| 4612 | + amdgpu_ring_alloc(ring, 8); | |
| 4613 | + /* set resources */ | |
| 4614 | + amdgpu_ring_write(ring, PACKET3(PACKET3_SET_RESOURCES, 6)); | |
| 4615 | + amdgpu_ring_write(ring, 0); /* vmid_mask:0 queue_type:0 (KIQ) */ | |
| 4616 | + amdgpu_ring_write(ring, 0x000000FF); /* queue mask lo */ | |
| 4617 | + amdgpu_ring_write(ring, 0); /* queue mask hi */ | |
| 4618 | + amdgpu_ring_write(ring, 0); /* gws mask lo */ | |
| 4619 | + amdgpu_ring_write(ring, 0); /* gws mask hi */ | |
| 4620 | + amdgpu_ring_write(ring, 0); /* oac mask */ | |
| 4621 | + amdgpu_ring_write(ring, 0); /* gds heap base:0, gds heap size:0 */ | |
| 4622 | + amdgpu_ring_commit(ring); | |
| 4623 | + udelay(50); | |
| 4624 | +} | |
| 4625 | + | |
| 4626 | +static void gfx_v8_0_map_queue_enable(struct amdgpu_ring *kiq_ring, | |
| 4627 | + struct amdgpu_ring *ring) | |
| 4628 | +{ | |
| 4629 | + struct amdgpu_device *adev = kiq_ring->adev; | |
| 4630 | + uint64_t mqd_addr, wptr_addr; | |
| 4631 | + | |
| 4632 | + mqd_addr = amdgpu_bo_gpu_offset(ring->mqd_obj); | |
| 4633 | + wptr_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4); | |
| 4634 | + amdgpu_ring_alloc(kiq_ring, 8); | |
| 4635 | + | |
| 4636 | + amdgpu_ring_write(kiq_ring, PACKET3(PACKET3_MAP_QUEUES, 5)); | |
| 4637 | + /* Q_sel:0, vmid:0, vidmem: 1, engine:0, num_Q:1*/ | |
| 4638 | + amdgpu_ring_write(kiq_ring, 0x21010000); | |
| 4639 | + amdgpu_ring_write(kiq_ring, (ring->doorbell_index << 2) | | |
| 4640 | + (ring->queue << 26) | | |
| 4641 | + (ring->pipe << 29) | | |
| 4642 | + ((ring->me == 1 ? 0 : 1) << 31)); /* doorbell */ | |
| 4643 | + amdgpu_ring_write(kiq_ring, lower_32_bits(mqd_addr)); | |
| 4644 | + amdgpu_ring_write(kiq_ring, upper_32_bits(mqd_addr)); | |
| 4645 | + amdgpu_ring_write(kiq_ring, lower_32_bits(wptr_addr)); | |
| 4646 | + amdgpu_ring_write(kiq_ring, upper_32_bits(wptr_addr)); | |
| 4647 | + amdgpu_ring_commit(kiq_ring); | |
| 4648 | + udelay(50); | |
| 4649 | +} | |
| 4650 | + | |
| 4651 | +static int gfx_v8_0_mqd_init(struct amdgpu_device *adev, | |
| 4652 | + struct vi_mqd *mqd, | |
| 4653 | + uint64_t mqd_gpu_addr, | |
| 4654 | + uint64_t eop_gpu_addr, | |
| 4655 | + struct amdgpu_ring *ring) | |
| 4656 | +{ | |
| 4657 | + uint64_t hqd_gpu_addr, wb_gpu_addr, eop_base_addr; | |
| 4658 | + uint32_t tmp; | |
| 4659 | + | |
| 4660 | + mqd->header = 0xC0310800; | |
| 4661 | + mqd->compute_pipelinestat_enable = 0x00000001; | |
| 4662 | + mqd->compute_static_thread_mgmt_se0 = 0xffffffff; | |
| 4663 | + mqd->compute_static_thread_mgmt_se1 = 0xffffffff; | |
| 4664 | + mqd->compute_static_thread_mgmt_se2 = 0xffffffff; | |
| 4665 | + mqd->compute_static_thread_mgmt_se3 = 0xffffffff; | |
| 4666 | + mqd->compute_misc_reserved = 0x00000003; | |
| 4667 | + | |
| 4668 | + eop_base_addr = eop_gpu_addr >> 8; | |
| 4669 | + mqd->cp_hqd_eop_base_addr_lo = eop_base_addr; | |
| 4670 | + mqd->cp_hqd_eop_base_addr_hi = upper_32_bits(eop_base_addr); | |
| 4671 | + | |
| 4672 | + /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ | |
| 4673 | + tmp = RREG32(mmCP_HQD_EOP_CONTROL); | |
| 4674 | + tmp = REG_SET_FIELD(tmp, CP_HQD_EOP_CONTROL, EOP_SIZE, | |
| 4675 | + (order_base_2(MEC_HPD_SIZE / 4) - 1)); | |
| 4676 | + | |
| 4677 | + mqd->cp_hqd_eop_control = tmp; | |
| 4678 | + | |
| 4679 | + /* enable doorbell? */ | |
| 4680 | + tmp = RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL); | |
| 4681 | + | |
| 4682 | + if (ring->use_doorbell) | |
| 4683 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, | |
| 4684 | + DOORBELL_EN, 1); | |
| 4685 | + else | |
| 4686 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, | |
| 4687 | + DOORBELL_EN, 0); | |
| 4688 | + | |
| 4689 | + mqd->cp_hqd_pq_doorbell_control = tmp; | |
| 4690 | + | |
| 4691 | + /* disable the queue if it's active */ | |
| 4692 | + mqd->cp_hqd_dequeue_request = 0; | |
| 4693 | + mqd->cp_hqd_pq_rptr = 0; | |
| 4694 | + mqd->cp_hqd_pq_wptr = 0; | |
| 4695 | + | |
| 4696 | + /* set the pointer to the MQD */ | |
| 4697 | + mqd->cp_mqd_base_addr_lo = mqd_gpu_addr & 0xfffffffc; | |
| 4698 | + mqd->cp_mqd_base_addr_hi = upper_32_bits(mqd_gpu_addr); | |
| 4699 | + | |
| 4700 | + /* set MQD vmid to 0 */ | |
| 4701 | + tmp = RREG32(mmCP_MQD_CONTROL); | |
| 4702 | + tmp = REG_SET_FIELD(tmp, CP_MQD_CONTROL, VMID, 0); | |
| 4703 | + mqd->cp_mqd_control = tmp; | |
| 4704 | + | |
| 4705 | + /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ | |
| 4706 | + hqd_gpu_addr = ring->gpu_addr >> 8; | |
| 4707 | + mqd->cp_hqd_pq_base_lo = hqd_gpu_addr; | |
| 4708 | + mqd->cp_hqd_pq_base_hi = upper_32_bits(hqd_gpu_addr); | |
| 4709 | + | |
| 4710 | + /* set up the HQD, this is similar to CP_RB0_CNTL */ | |
| 4711 | + tmp = RREG32(mmCP_HQD_PQ_CONTROL); | |
| 4712 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, QUEUE_SIZE, | |
| 4713 | + (order_base_2(ring->ring_size / 4) - 1)); | |
| 4714 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE, | |
| 4715 | + ((order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1) << 8)); | |
| 4716 | +#ifdef __BIG_ENDIAN | |
| 4717 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ENDIAN_SWAP, 1); | |
| 4718 | +#endif | |
| 4719 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0); | |
| 4720 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ROQ_PQ_IB_FLIP, 0); | |
| 4721 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1); | |
| 4722 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1); | |
| 4723 | + mqd->cp_hqd_pq_control = tmp; | |
| 4724 | + | |
| 4725 | + /* set the wb address whether it's enabled or not */ | |
| 4726 | + wb_gpu_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4); | |
| 4727 | + mqd->cp_hqd_pq_rptr_report_addr_lo = wb_gpu_addr & 0xfffffffc; | |
| 4728 | + mqd->cp_hqd_pq_rptr_report_addr_hi = | |
| 4729 | + upper_32_bits(wb_gpu_addr) & 0xffff; | |
| 4730 | + | |
| 4731 | + /* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */ | |
| 4732 | + wb_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4); | |
| 4733 | + mqd->cp_hqd_pq_wptr_poll_addr_lo = wb_gpu_addr & 0xfffffffc; | |
| 4734 | + mqd->cp_hqd_pq_wptr_poll_addr_hi = upper_32_bits(wb_gpu_addr) & 0xffff; | |
| 4735 | + | |
| 4736 | + tmp = 0; | |
| 4737 | + /* enable the doorbell if requested */ | |
| 4738 | + if (ring->use_doorbell) { | |
| 4739 | + tmp = RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL); | |
| 4740 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, | |
| 4741 | + DOORBELL_OFFSET, ring->doorbell_index); | |
| 4742 | + | |
| 4743 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, | |
| 4744 | + DOORBELL_EN, 1); | |
| 4745 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, | |
| 4746 | + DOORBELL_SOURCE, 0); | |
| 4747 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, | |
| 4748 | + DOORBELL_HIT, 0); | |
| 4749 | + } | |
| 4750 | + | |
| 4751 | + mqd->cp_hqd_pq_doorbell_control = tmp; | |
| 4752 | + | |
| 4753 | + /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */ | |
| 4754 | + ring->wptr = 0; | |
| 4755 | + mqd->cp_hqd_pq_wptr = ring->wptr; | |
| 4756 | + mqd->cp_hqd_pq_rptr = RREG32(mmCP_HQD_PQ_RPTR); | |
| 4757 | + | |
| 4758 | + /* set the vmid for the queue */ | |
| 4759 | + mqd->cp_hqd_vmid = 0; | |
| 4760 | + | |
| 4761 | + tmp = RREG32(mmCP_HQD_PERSISTENT_STATE); | |
| 4762 | + tmp = REG_SET_FIELD(tmp, CP_HQD_PERSISTENT_STATE, PRELOAD_SIZE, 0x53); | |
| 4763 | + mqd->cp_hqd_persistent_state = tmp; | |
| 4764 | + | |
| 4765 | + /* activate the queue */ | |
| 4766 | + mqd->cp_hqd_active = 1; | |
| 4767 | + | |
| 4768 | + return 0; | |
| 4769 | +} | |
| 4770 | + | |
| 4771 | +static int gfx_v8_0_kiq_init_register(struct amdgpu_device *adev, | |
| 4772 | + struct vi_mqd *mqd, | |
| 4773 | + struct amdgpu_ring *ring) | |
| 4774 | +{ | |
| 4775 | + uint32_t tmp; | |
| 4776 | + int j; | |
| 4777 | + | |
| 4778 | + /* disable wptr polling */ | |
| 4779 | + tmp = RREG32(mmCP_PQ_WPTR_POLL_CNTL); | |
| 4780 | + tmp = REG_SET_FIELD(tmp, CP_PQ_WPTR_POLL_CNTL, EN, 0); | |
| 4781 | + WREG32(mmCP_PQ_WPTR_POLL_CNTL, tmp); | |
| 4782 | + | |
| 4783 | + WREG32(mmCP_HQD_EOP_BASE_ADDR, mqd->cp_hqd_eop_base_addr_lo); | |
| 4784 | + WREG32(mmCP_HQD_EOP_BASE_ADDR_HI, mqd->cp_hqd_eop_base_addr_hi); | |
| 4785 | + | |
| 4786 | + /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ | |
| 4787 | + WREG32(mmCP_HQD_EOP_CONTROL, mqd->cp_hqd_eop_control); | |
| 4788 | + | |
| 4789 | + /* enable doorbell? */ | |
| 4790 | + WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL, mqd->cp_hqd_pq_doorbell_control); | |
| 4791 | + | |
| 4792 | + /* disable the queue if it's active */ | |
| 4793 | + if (RREG32(mmCP_HQD_ACTIVE) & 1) { | |
| 4794 | + WREG32(mmCP_HQD_DEQUEUE_REQUEST, 1); | |
| 4795 | + for (j = 0; j < adev->usec_timeout; j++) { | |
| 4796 | + if (!(RREG32(mmCP_HQD_ACTIVE) & 1)) | |
| 4797 | + break; | |
| 4798 | + udelay(1); | |
| 4799 | + } | |
| 4800 | + WREG32(mmCP_HQD_DEQUEUE_REQUEST, mqd->cp_hqd_dequeue_request); | |
| 4801 | + WREG32(mmCP_HQD_PQ_RPTR, mqd->cp_hqd_pq_rptr); | |
| 4802 | + WREG32(mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr); | |
| 4803 | + } | |
| 4804 | + | |
| 4805 | + /* set the pointer to the MQD */ | |
| 4806 | + WREG32(mmCP_MQD_BASE_ADDR, mqd->cp_mqd_base_addr_lo); | |
| 4807 | + WREG32(mmCP_MQD_BASE_ADDR_HI, mqd->cp_mqd_base_addr_hi); | |
| 4808 | + | |
| 4809 | + /* set MQD vmid to 0 */ | |
| 4810 | + WREG32(mmCP_MQD_CONTROL, mqd->cp_mqd_control); | |
| 4811 | + | |
| 4812 | + /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ | |
| 4813 | + WREG32(mmCP_HQD_PQ_BASE, mqd->cp_hqd_pq_base_lo); | |
| 4814 | + WREG32(mmCP_HQD_PQ_BASE_HI, mqd->cp_hqd_pq_base_hi); | |
| 4815 | + | |
| 4816 | + /* set up the HQD, this is similar to CP_RB0_CNTL */ | |
| 4817 | + WREG32(mmCP_HQD_PQ_CONTROL, mqd->cp_hqd_pq_control); | |
| 4818 | + | |
| 4819 | + /* set the wb address whether it's enabled or not */ | |
| 4820 | + WREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR, | |
| 4821 | + mqd->cp_hqd_pq_rptr_report_addr_lo); | |
| 4822 | + WREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI, | |
| 4823 | + mqd->cp_hqd_pq_rptr_report_addr_hi); | |
| 4824 | + | |
| 4825 | + /* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */ | |
| 4826 | + WREG32(mmCP_HQD_PQ_WPTR_POLL_ADDR, mqd->cp_hqd_pq_wptr_poll_addr_lo); | |
| 4827 | + WREG32(mmCP_HQD_PQ_WPTR_POLL_ADDR_HI, mqd->cp_hqd_pq_wptr_poll_addr_hi); | |
| 4828 | + | |
| 4829 | + /* enable the doorbell if requested */ | |
| 4830 | + if (ring->use_doorbell) { | |
| 4831 | + if ((adev->asic_type == CHIP_CARRIZO) || | |
| 4832 | + (adev->asic_type == CHIP_FIJI) || | |
| 4833 | + (adev->asic_type == CHIP_STONEY)) { | |
| 4834 | + WREG32(mmCP_MEC_DOORBELL_RANGE_LOWER, | |
| 4835 | + AMDGPU_DOORBELL_KIQ << 2); | |
| 4836 | + WREG32(mmCP_MEC_DOORBELL_RANGE_UPPER, | |
| 4837 | + AMDGPU_DOORBELL_MEC_RING7 << 2); | |
| 4838 | + } | |
| 4839 | + } | |
| 4840 | + WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL, mqd->cp_hqd_pq_doorbell_control); | |
| 4841 | + | |
| 4842 | + /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */ | |
| 4843 | + WREG32(mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr); | |
| 4844 | + | |
| 4845 | + /* set the vmid for the queue */ | |
| 4846 | + WREG32(mmCP_HQD_VMID, mqd->cp_hqd_vmid); | |
| 4847 | + | |
| 4848 | + WREG32(mmCP_HQD_PERSISTENT_STATE, mqd->cp_hqd_persistent_state); | |
| 4849 | + | |
| 4850 | + /* activate the queue */ | |
| 4851 | + WREG32(mmCP_HQD_ACTIVE, mqd->cp_hqd_active); | |
| 4852 | + | |
| 4853 | + if (ring->use_doorbell) { | |
| 4854 | + tmp = RREG32(mmCP_PQ_STATUS); | |
| 4855 | + tmp = REG_SET_FIELD(tmp, CP_PQ_STATUS, DOORBELL_ENABLE, 1); | |
| 4856 | + WREG32(mmCP_PQ_STATUS, tmp); | |
| 4857 | + } | |
| 4858 | + | |
| 4859 | + return 0; | |
| 4860 | +} | |
| 4861 | + | |
| 4862 | +static int gfx_v8_0_kiq_init_queue(struct amdgpu_ring *ring, | |
| 4863 | + struct vi_mqd *mqd, | |
| 4864 | + u64 mqd_gpu_addr) | |
| 4865 | +{ | |
| 4866 | + struct amdgpu_device *adev = ring->adev; | |
| 4867 | + struct amdgpu_kiq *kiq = &adev->gfx.kiq; | |
| 4868 | + uint64_t eop_gpu_addr; | |
| 4869 | + bool is_kiq = false; | |
| 4870 | + | |
| 4871 | + if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ) | |
| 4872 | + is_kiq = true; | |
| 4873 | + | |
| 4874 | + if (is_kiq) { | |
| 4875 | + eop_gpu_addr = kiq->eop_gpu_addr; | |
| 4876 | + gfx_v8_0_kiq_setting(&kiq->ring); | |
| 4877 | + } else | |
| 4878 | + eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr + | |
| 4879 | + ring->queue * MEC_HPD_SIZE; | |
| 4880 | + | |
| 4881 | + mutex_lock(&adev->srbm_mutex); | |
| 4882 | + vi_srbm_select(adev, ring->me, ring->pipe, ring->queue, 0); | |
| 4883 | + | |
| 4884 | + gfx_v8_0_mqd_init(adev, mqd, mqd_gpu_addr, eop_gpu_addr, ring); | |
| 4885 | + | |
| 4886 | + if (is_kiq) | |
| 4887 | + gfx_v8_0_kiq_init_register(adev, mqd, ring); | |
| 4888 | + | |
| 4889 | + vi_srbm_select(adev, 0, 0, 0, 0); | |
| 4890 | + mutex_unlock(&adev->srbm_mutex); | |
| 4891 | + | |
| 4892 | + if (is_kiq) | |
| 4893 | + gfx_v8_0_kiq_enable(ring); | |
| 4894 | + else | |
| 4895 | + gfx_v8_0_map_queue_enable(&kiq->ring, ring); | |
| 4896 | + | |
| 4897 | + return 0; | |
| 4898 | +} | |
| 4899 | + | |
| 4900 | +static void gfx_v8_0_kiq_free_queue(struct amdgpu_device *adev) | |
| 4901 | +{ | |
| 4902 | + struct amdgpu_ring *ring = NULL; | |
| 4903 | + int i; | |
| 4904 | + | |
| 4905 | + for (i = 0; i < adev->gfx.num_compute_rings; i++) { | |
| 4906 | + ring = &adev->gfx.compute_ring[i]; | |
| 4907 | + amdgpu_bo_free_kernel(&ring->mqd_obj, NULL, NULL); | |
| 4908 | + ring->mqd_obj = NULL; | |
| 4909 | + } | |
| 4910 | + | |
| 4911 | + ring = &adev->gfx.kiq.ring; | |
| 4912 | + amdgpu_bo_free_kernel(&ring->mqd_obj, NULL, NULL); | |
| 4913 | + ring->mqd_obj = NULL; | |
| 4914 | +} | |
| 4915 | + | |
| 4916 | +static int gfx_v8_0_kiq_setup_queue(struct amdgpu_device *adev, | |
| 4917 | + struct amdgpu_ring *ring) | |
| 4918 | +{ | |
| 4919 | + struct vi_mqd *mqd; | |
| 4920 | + u64 mqd_gpu_addr; | |
| 4921 | + u32 *buf; | |
| 4922 | + int r = 0; | |
| 4923 | + | |
| 4924 | + r = amdgpu_bo_create_kernel(adev, sizeof(struct vi_mqd), PAGE_SIZE, | |
| 4925 | + AMDGPU_GEM_DOMAIN_GTT, &ring->mqd_obj, | |
| 4926 | + &mqd_gpu_addr, (void **)&buf); | |
| 4927 | + if (r) { | |
| 4928 | + dev_warn(adev->dev, "failed to create ring mqd ob (%d)", r); | |
| 4929 | + return r; | |
| 4930 | + } | |
| 4931 | + | |
| 4932 | + /* init the mqd struct */ | |
| 4933 | + memset(buf, 0, sizeof(struct vi_mqd)); | |
| 4934 | + mqd = (struct vi_mqd *)buf; | |
| 4935 | + | |
| 4936 | + r = gfx_v8_0_kiq_init_queue(ring, mqd, mqd_gpu_addr); | |
| 4937 | + if (r) | |
| 4938 | + return r; | |
| 4939 | + | |
| 4940 | + amdgpu_bo_kunmap(ring->mqd_obj); | |
| 4941 | + | |
| 4942 | + return 0; | |
| 4943 | +} | |
| 4944 | + | |
| 4945 | +static int gfx_v8_0_kiq_resume(struct amdgpu_device *adev) | |
| 4946 | +{ | |
| 4947 | + struct amdgpu_ring *ring = NULL; | |
| 4948 | + int r, i; | |
| 4949 | + | |
| 4950 | + ring = &adev->gfx.kiq.ring; | |
| 4951 | + r = gfx_v8_0_kiq_setup_queue(adev, ring); | |
| 4952 | + if (r) | |
| 4953 | + return r; | |
| 4954 | + | |
| 4955 | + for (i = 0; i < adev->gfx.num_compute_rings; i++) { | |
| 4956 | + ring = &adev->gfx.compute_ring[i]; | |
| 4957 | + r = gfx_v8_0_kiq_setup_queue(adev, ring); | |
| 4958 | + if (r) | |
| 4959 | + return r; | |
| 4960 | + } | |
| 4961 | + | |
| 4962 | + gfx_v8_0_cp_compute_enable(adev, true); | |
| 4963 | + | |
| 4964 | + for (i = 0; i < adev->gfx.num_compute_rings; i++) { | |
| 4965 | + ring = &adev->gfx.compute_ring[i]; | |
| 4966 | + | |
| 4967 | + ring->ready = true; | |
| 4968 | + r = amdgpu_ring_test_ring(ring); | |
| 4969 | + if (r) | |
| 4970 | + ring->ready = false; | |
| 4971 | + } | |
| 4972 | + | |
| 4973 | + ring = &adev->gfx.kiq.ring; | |
| 4974 | + ring->ready = true; | |
| 4975 | + r = amdgpu_ring_test_ring(ring); | |
| 4976 | + if (r) | |
| 4977 | + ring->ready = false; | |
| 4978 | + | |
| 4979 | + return 0; | |
| 4980 | +} | |
| 4981 | + | |
| 4509 | 4982 | static int gfx_v8_0_cp_compute_resume(struct amdgpu_device *adev) |
| 4510 | 4983 | { |
| 4511 | 4984 | int r, i, j; |
| @@ -4806,7 +5279,10 @@ static int gfx_v8_0_cp_resume(struct amdgpu_device *adev) · 294 unmodified lines | ||
| 4806 | 5279 | if (r) |
| 4807 | 5280 | return r; |
| 4808 | 5281 | |
| 4809 | − r = gfx_v8_0_cp_compute_resume(adev); | |
| 5282 | + if (amdgpu_sriov_vf(adev)) | |
| 5283 | + r = gfx_v8_0_kiq_resume(adev); | |
| 5284 | + else | |
| 5285 | + r = gfx_v8_0_cp_compute_resume(adev); | |
| 4810 | 5286 | if (r) |
| 4811 | 5287 | return r; |
| 4812 | 5288 | |
| @@ -4845,6 +5321,7 @@ static int gfx_v8_0_hw_fini(void *handle) · 32 unmodified lines | ||
| 4845 | 5321 | amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0); |
| 4846 | 5322 | amdgpu_irq_put(adev, &adev->gfx.priv_inst_irq, 0); |
| 4847 | 5323 | if (amdgpu_sriov_vf(adev)) { |
| 5324 | + gfx_v8_0_kiq_free_queue(adev); | |
| 4848 | 5325 | pr_debug("For SRIOV client, shouldn't do anything.\n"); |
| 4849 | 5326 | return 0; |
| 4850 | 5327 | } |
| @@ -5360,6 +5837,18 @@ static int gfx_v8_0_set_powergating_state(void *handle, · 509 unmodified lines | ||
| 5360 | 5837 | case CHIP_CARRIZO: |
| 5361 | 5838 | case CHIP_STONEY: |
| 5362 | 5839 | |
| 5840 | + if (adev->pg_flags & AMD_PG_SUPPORT_RLC_SMU_HS) { | |
| 5841 | + cz_enable_sck_slow_down_on_power_up(adev, true); | |
| 5842 | + cz_enable_sck_slow_down_on_power_down(adev, true); | |
| 5843 | + } else { | |
| 5844 | + cz_enable_sck_slow_down_on_power_up(adev, false); | |
| 5845 | + cz_enable_sck_slow_down_on_power_down(adev, false); | |
| 5846 | + } | |
| 5847 | + if (adev->pg_flags & AMD_PG_SUPPORT_CP) | |
| 5848 | + cz_enable_cp_power_gating(adev, true); | |
| 5849 | + else | |
| 5850 | + cz_enable_cp_power_gating(adev, false); | |
| 5851 | + | |
| 5363 | 5852 | cz_update_gfx_cg_power_gating(adev, enable); |
| 5364 | 5853 | |
| 5365 | 5854 | if ((adev->pg_flags & AMD_PG_SUPPORT_GFX_SMG) && enable) |
| @@ -5396,6 +5885,45 @@ static int gfx_v8_0_set_powergating_state(void *handle, · 30 unmodified lines | ||
| 5396 | 5885 | return 0; |
| 5397 | 5886 | } |
| 5398 | 5887 | |
| 5888 | +static void gfx_v8_0_get_clockgating_state(void *handle, u32 *flags) | |
| 5889 | +{ | |
| 5890 | + struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 5891 | + int data; | |
| 5892 | + | |
| 5893 | + /* AMD_CG_SUPPORT_GFX_MGCG */ | |
| 5894 | + data = RREG32(mmRLC_CGTT_MGCG_OVERRIDE); | |
| 5895 | + if (!(data & RLC_CGTT_MGCG_OVERRIDE__CPF_MASK)) | |
| 5896 | + *flags |= AMD_CG_SUPPORT_GFX_MGCG; | |
| 5897 | + | |
| 5898 | + /* AMD_CG_SUPPORT_GFX_CGLG */ | |
| 5899 | + data = RREG32(mmRLC_CGCG_CGLS_CTRL); | |
| 5900 | + if (data & RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK) | |
| 5901 | + *flags |= AMD_CG_SUPPORT_GFX_CGCG; | |
| 5902 | + | |
| 5903 | + /* AMD_CG_SUPPORT_GFX_CGLS */ | |
| 5904 | + if (data & RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK) | |
| 5905 | + *flags |= AMD_CG_SUPPORT_GFX_CGLS; | |
| 5906 | + | |
| 5907 | + /* AMD_CG_SUPPORT_GFX_CGTS */ | |
| 5908 | + data = RREG32(mmCGTS_SM_CTRL_REG); | |
| 5909 | + if (!(data & CGTS_SM_CTRL_REG__OVERRIDE_MASK)) | |
| 5910 | + *flags |= AMD_CG_SUPPORT_GFX_CGTS; | |
| 5911 | + | |
| 5912 | + /* AMD_CG_SUPPORT_GFX_CGTS_LS */ | |
| 5913 | + if (!(data & CGTS_SM_CTRL_REG__LS_OVERRIDE_MASK)) | |
| 5914 | + *flags |= AMD_CG_SUPPORT_GFX_CGTS_LS; | |
| 5915 | + | |
| 5916 | + /* AMD_CG_SUPPORT_GFX_RLC_LS */ | |
| 5917 | + data = RREG32(mmRLC_MEM_SLP_CNTL); | |
| 5918 | + if (data & RLC_MEM_SLP_CNTL__RLC_MEM_LS_EN_MASK) | |
| 5919 | + *flags |= AMD_CG_SUPPORT_GFX_RLC_LS | AMD_CG_SUPPORT_GFX_MGLS; | |
| 5920 | + | |
| 5921 | + /* AMD_CG_SUPPORT_GFX_CP_LS */ | |
| 5922 | + data = RREG32(mmCP_MEM_SLP_CNTL); | |
| 5923 | + if (data & CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK) | |
| 5924 | + *flags |= AMD_CG_SUPPORT_GFX_CP_LS | AMD_CG_SUPPORT_GFX_MGLS; | |
| 5925 | +} | |
| 5926 | + | |
| 5399 | 5927 | static void gfx_v8_0_send_serdes_cmd(struct amdgpu_device *adev, |
| 5400 | 5928 | uint32_t reg_addr, uint32_t cmd) |
| 5401 | 5929 | { |
| @@ -5444,68 +5972,6 @@ static void gfx_v8_0_send_serdes_cmd(struct amdgpu_device *adev, · 42 unmodified lines | ||
| 5444 | 5972 | #define RLC_GPR_REG2__MESSAGE__SHIFT 0x00000001 |
| 5445 | 5973 | #define RLC_GPR_REG2__MESSAGE_MASK 0x0000001e |
| 5446 | 5974 | |
| 5447 | −static void cz_enter_rlc_safe_mode(struct amdgpu_device *adev) | |
| 5448 | −{ | |
| 5449 | − u32 data = 0; | |
| 5450 | − unsigned i; | |
| 5451 | − | |
| 5452 | − data = RREG32(mmRLC_CNTL); | |
| 5453 | − if ((data & RLC_CNTL__RLC_ENABLE_F32_MASK) == 0) | |
| 5454 | − return; | |
| 5455 | − | |
| 5456 | − if ((adev->cg_flags & (AMD_CG_SUPPORT_GFX_CGCG | AMD_CG_SUPPORT_GFX_MGCG)) || | |
| 5457 | − (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG | AMD_PG_SUPPORT_GFX_SMG | | |
| 5458 | − AMD_PG_SUPPORT_GFX_DMG))) { | |
| 5459 | − data |= RLC_GPR_REG2__REQ_MASK; | |
| 5460 | − data &= ~RLC_GPR_REG2__MESSAGE_MASK; | |
| 5461 | − data |= (MSG_ENTER_RLC_SAFE_MODE << RLC_GPR_REG2__MESSAGE__SHIFT); | |
| 5462 | − WREG32(mmRLC_GPR_REG2, data); | |
| 5463 | − | |
| 5464 | − for (i = 0; i < adev->usec_timeout; i++) { | |
| 5465 | − if ((RREG32(mmRLC_GPM_STAT) & | |
| 5466 | − (RLC_GPM_STAT__GFX_CLOCK_STATUS_MASK | | |
| 5467 | − RLC_GPM_STAT__GFX_POWER_STATUS_MASK)) == | |
| 5468 | − (RLC_GPM_STAT__GFX_CLOCK_STATUS_MASK | | |
| 5469 | − RLC_GPM_STAT__GFX_POWER_STATUS_MASK)) | |
| 5470 | − break; | |
| 5471 | − udelay(1); | |
| 5472 | − } | |
| 5473 | − | |
| 5474 | − for (i = 0; i < adev->usec_timeout; i++) { | |
| 5475 | − if (!REG_GET_FIELD(RREG32(mmRLC_GPR_REG2), RLC_GPR_REG2, REQ)) | |
| 5476 | − break; | |
| 5477 | − udelay(1); | |
| 5478 | − } | |
| 5479 | − adev->gfx.rlc.in_safe_mode = true; | |
| 5480 | − } | |
| 5481 | −} | |
| 5482 | − | |
| 5483 | −static void cz_exit_rlc_safe_mode(struct amdgpu_device *adev) | |
| 5484 | −{ | |
| 5485 | − u32 data; | |
| 5486 | − unsigned i; | |
| 5487 | − | |
| 5488 | − data = RREG32(mmRLC_CNTL); | |
| 5489 | − if ((data & RLC_CNTL__RLC_ENABLE_F32_MASK) == 0) | |
| 5490 | − return; | |
| 5491 | − | |
| 5492 | − if ((adev->cg_flags & (AMD_CG_SUPPORT_GFX_CGCG | AMD_CG_SUPPORT_GFX_MGCG)) || | |
| 5493 | − (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG | AMD_PG_SUPPORT_GFX_SMG | | |
| 5494 | − AMD_PG_SUPPORT_GFX_DMG))) { | |
| 5495 | − data |= RLC_GPR_REG2__REQ_MASK; | |
| 5496 | − data &= ~RLC_GPR_REG2__MESSAGE_MASK; | |
| 5497 | − data |= (MSG_EXIT_RLC_SAFE_MODE << RLC_GPR_REG2__MESSAGE__SHIFT); | |
| 5498 | − WREG32(mmRLC_GPR_REG2, data); | |
| 5499 | − adev->gfx.rlc.in_safe_mode = false; | |
| 5500 | − } | |
| 5501 | − | |
| 5502 | − for (i = 0; i < adev->usec_timeout; i++) { | |
| 5503 | − if (!REG_GET_FIELD(RREG32(mmRLC_GPR_REG2), RLC_GPR_REG2, REQ)) | |
| 5504 | − break; | |
| 5505 | − udelay(1); | |
| 5506 | − } | |
| 5507 | −} | |
| 5508 | − | |
| 5509 | 5975 | static void iceland_enter_rlc_safe_mode(struct amdgpu_device *adev) |
| 5510 | 5976 | { |
| 5511 | 5977 | u32 data; |
| @@ -5565,31 +6031,11 @@ static void iceland_exit_rlc_safe_mode(struct amdgpu_device *adev) · 53 unmodified lines | ||
| 5565 | 6031 | } |
| 5566 | 6032 | } |
| 5567 | 6033 | |
| 5568 | −static void gfx_v8_0_nop_enter_rlc_safe_mode(struct amdgpu_device *adev) | |
| 5569 | −{ | |
| 5570 | − adev->gfx.rlc.in_safe_mode = true; | |
| 5571 | −} | |
| 5572 | − | |
| 5573 | −static void gfx_v8_0_nop_exit_rlc_safe_mode(struct amdgpu_device *adev) | |
| 5574 | −{ | |
| 5575 | − adev->gfx.rlc.in_safe_mode = false; | |
| 5576 | −} | |
| 5577 | − | |
| 5578 | −static const struct amdgpu_rlc_funcs cz_rlc_funcs = { | |
| 5579 | − .enter_safe_mode = cz_enter_rlc_safe_mode, | |
| 5580 | − .exit_safe_mode = cz_exit_rlc_safe_mode | |
| 5581 | −}; | |
| 5582 | − | |
| 5583 | 6034 | static const struct amdgpu_rlc_funcs iceland_rlc_funcs = { |
| 5584 | 6035 | .enter_safe_mode = iceland_enter_rlc_safe_mode, |
| 5585 | 6036 | .exit_safe_mode = iceland_exit_rlc_safe_mode |
| 5586 | 6037 | }; |
| 5587 | 6038 | |
| 5588 | −static const struct amdgpu_rlc_funcs gfx_v8_0_nop_rlc_funcs = { | |
| 5589 | − .enter_safe_mode = gfx_v8_0_nop_enter_rlc_safe_mode, | |
| 5590 | − .exit_safe_mode = gfx_v8_0_nop_exit_rlc_safe_mode | |
| 5591 | −}; | |
| 5592 | − | |
| 5593 | 6039 | static void gfx_v8_0_update_medium_grain_clock_gating(struct amdgpu_device *adev, |
| 5594 | 6040 | bool enable) |
| 5595 | 6041 | { |
| @@ -6011,7 +6457,8 @@ static void gfx_v8_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) · 415 unmodified lines | ||
| 6011 | 6457 | { |
| 6012 | 6458 | u32 ref_and_mask, reg_mem_engine; |
| 6013 | 6459 | |
| 6014 | − if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) { | |
| 6460 | + if ((ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) || | |
| 6461 | + (ring->funcs->type == AMDGPU_RING_TYPE_KIQ)) { | |
| 6015 | 6462 | switch (ring->me) { |
| 6016 | 6463 | case 1: |
| 6017 | 6464 | ref_and_mask = GPU_HDP_FLUSH_DONE__CP2_MASK << ring->pipe; |
| @@ -6224,6 +6671,31 @@ static void gfx_v8_0_ring_emit_fence_compute(struct amdgpu_ring *ring, · 206 unmodified lines | ||
| 6224 | 6671 | amdgpu_ring_write(ring, upper_32_bits(seq)); |
| 6225 | 6672 | } |
| 6226 | 6673 | |
| 6674 | +static void gfx_v8_0_ring_emit_fence_kiq(struct amdgpu_ring *ring, u64 addr, | |
| 6675 | + u64 seq, unsigned int flags) | |
| 6676 | +{ | |
| 6677 | + /* we only allocate 32bit for each seq wb address */ | |
| 6678 | + BUG_ON(flags & AMDGPU_FENCE_FLAG_64BIT); | |
| 6679 | + | |
| 6680 | + /* write fence seq to the "addr" */ | |
| 6681 | + amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | |
| 6682 | + amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | | |
| 6683 | + WRITE_DATA_DST_SEL(5) | WR_CONFIRM)); | |
| 6684 | + amdgpu_ring_write(ring, lower_32_bits(addr)); | |
| 6685 | + amdgpu_ring_write(ring, upper_32_bits(addr)); | |
| 6686 | + amdgpu_ring_write(ring, lower_32_bits(seq)); | |
| 6687 | + | |
| 6688 | + if (flags & AMDGPU_FENCE_FLAG_INT) { | |
| 6689 | + /* set register to trigger INT */ | |
| 6690 | + amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | |
| 6691 | + amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | | |
| 6692 | + WRITE_DATA_DST_SEL(0) | WR_CONFIRM)); | |
| 6693 | + amdgpu_ring_write(ring, mmCPC_INT_STATUS); | |
| 6694 | + amdgpu_ring_write(ring, 0); | |
| 6695 | + amdgpu_ring_write(ring, 0x20000000); /* src_id is 178 */ | |
| 6696 | + } | |
| 6697 | +} | |
| 6698 | + | |
| 6227 | 6699 | static void gfx_v8_ring_emit_sb(struct amdgpu_ring *ring) |
| 6228 | 6700 | { |
| 6229 | 6701 | amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); |
| @@ -6234,6 +6706,10 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags) · 4 unmodified lines | ||
| 6234 | 6706 | { |
| 6235 | 6707 | uint32_t dw2 = 0; |
| 6236 | 6708 | |
| 6709 | + if (amdgpu_sriov_vf(ring->adev)) | |
| 6710 | + gfx_v8_0_ring_emit_ce_meta_init(ring, | |
| 6711 | + (flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr); | |
| 6712 | + | |
| 6237 | 6713 | dw2 |= 0x80000000; /* set load_enable otherwise this package is just NOPs */ |
| 6238 | 6714 | if (flags & AMDGPU_HAVE_CTX_SWITCH) { |
| 6239 | 6715 | gfx_v8_0_ring_emit_vgt_flush(ring); |
| @@ -6258,6 +6734,36 @@ static void gfx_v8_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags) · 18 unmodified lines | ||
| 6258 | 6734 | amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1)); |
| 6259 | 6735 | amdgpu_ring_write(ring, dw2); |
| 6260 | 6736 | amdgpu_ring_write(ring, 0); |
| 6737 | + | |
| 6738 | + if (amdgpu_sriov_vf(ring->adev)) | |
| 6739 | + gfx_v8_0_ring_emit_de_meta_init(ring, | |
| 6740 | + (flags & AMDGPU_VM_DOMAIN) ? AMDGPU_CSA_VADDR : ring->adev->virt.csa_vmid0_addr); | |
| 6741 | +} | |
| 6742 | + | |
| 6743 | +static void gfx_v8_0_ring_emit_rreg(struct amdgpu_ring *ring, uint32_t reg) | |
| 6744 | +{ | |
| 6745 | + struct amdgpu_device *adev = ring->adev; | |
| 6746 | + | |
| 6747 | + amdgpu_ring_write(ring, PACKET3(PACKET3_COPY_DATA, 4)); | |
| 6748 | + amdgpu_ring_write(ring, 0 | /* src: register*/ | |
| 6749 | + (5 << 8) | /* dst: memory */ | |
| 6750 | + (1 << 20)); /* write confirm */ | |
| 6751 | + amdgpu_ring_write(ring, reg); | |
| 6752 | + amdgpu_ring_write(ring, 0); | |
| 6753 | + amdgpu_ring_write(ring, lower_32_bits(adev->wb.gpu_addr + | |
| 6754 | + adev->virt.reg_val_offs * 4)); | |
| 6755 | + amdgpu_ring_write(ring, upper_32_bits(adev->wb.gpu_addr + | |
| 6756 | + adev->virt.reg_val_offs * 4)); | |
| 6757 | +} | |
| 6758 | + | |
| 6759 | +static void gfx_v8_0_ring_emit_wreg(struct amdgpu_ring *ring, uint32_t reg, | |
| 6760 | + uint32_t val) | |
| 6761 | +{ | |
| 6762 | + amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); | |
| 6763 | + amdgpu_ring_write(ring, (1 << 16)); /* no inc addr */ | |
| 6764 | + amdgpu_ring_write(ring, reg); | |
| 6765 | + amdgpu_ring_write(ring, 0); | |
| 6766 | + amdgpu_ring_write(ring, val); | |
| 6261 | 6767 | } |
| 6262 | 6768 | |
| 6263 | 6769 | static void gfx_v8_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, |
| @@ -6405,6 +6911,72 @@ static int gfx_v8_0_priv_inst_irq(struct amdgpu_device *adev, · 141 unmodified lines | ||
| 6405 | 6911 | return 0; |
| 6406 | 6912 | } |
| 6407 | 6913 | |
| 6914 | +static int gfx_v8_0_kiq_set_interrupt_state(struct amdgpu_device *adev, | |
| 6915 | + struct amdgpu_irq_src *src, | |
| 6916 | + unsigned int type, | |
| 6917 | + enum amdgpu_interrupt_state state) | |
| 6918 | +{ | |
| 6919 | + uint32_t tmp, target; | |
| 6920 | + struct amdgpu_ring *ring = (struct amdgpu_ring *)src->data; | |
| 6921 | + | |
| 6922 | + BUG_ON(!ring || (ring->funcs->type != AMDGPU_RING_TYPE_KIQ)); | |
| 6923 | + | |
| 6924 | + if (ring->me == 1) | |
| 6925 | + target = mmCP_ME1_PIPE0_INT_CNTL; | |
| 6926 | + else | |
| 6927 | + target = mmCP_ME2_PIPE0_INT_CNTL; | |
| 6928 | + target += ring->pipe; | |
| 6929 | + | |
| 6930 | + switch (type) { | |
| 6931 | + case AMDGPU_CP_KIQ_IRQ_DRIVER0: | |
| 6932 | + if (state == AMDGPU_IRQ_STATE_DISABLE) { | |
| 6933 | + tmp = RREG32(mmCPC_INT_CNTL); | |
| 6934 | + tmp = REG_SET_FIELD(tmp, CPC_INT_CNTL, | |
| 6935 | + GENERIC2_INT_ENABLE, 0); | |
| 6936 | + WREG32(mmCPC_INT_CNTL, tmp); | |
| 6937 | + | |
| 6938 | + tmp = RREG32(target); | |
| 6939 | + tmp = REG_SET_FIELD(tmp, CP_ME2_PIPE0_INT_CNTL, | |
| 6940 | + GENERIC2_INT_ENABLE, 0); | |
| 6941 | + WREG32(target, tmp); | |
| 6942 | + } else { | |
| 6943 | + tmp = RREG32(mmCPC_INT_CNTL); | |
| 6944 | + tmp = REG_SET_FIELD(tmp, CPC_INT_CNTL, | |
| 6945 | + GENERIC2_INT_ENABLE, 1); | |
| 6946 | + WREG32(mmCPC_INT_CNTL, tmp); | |
| 6947 | + | |
| 6948 | + tmp = RREG32(target); | |
| 6949 | + tmp = REG_SET_FIELD(tmp, CP_ME2_PIPE0_INT_CNTL, | |
| 6950 | + GENERIC2_INT_ENABLE, 1); | |
| 6951 | + WREG32(target, tmp); | |
| 6952 | + } | |
| 6953 | + break; | |
| 6954 | + default: | |
| 6955 | + BUG(); /* kiq only support GENERIC2_INT now */ | |
| 6956 | + break; | |
| 6957 | + } | |
| 6958 | + return 0; | |
| 6959 | +} | |
| 6960 | + | |
| 6961 | +static int gfx_v8_0_kiq_irq(struct amdgpu_device *adev, | |
| 6962 | + struct amdgpu_irq_src *source, | |
| 6963 | + struct amdgpu_iv_entry *entry) | |
| 6964 | +{ | |
| 6965 | + u8 me_id, pipe_id, queue_id; | |
| 6966 | + struct amdgpu_ring *ring = (struct amdgpu_ring *)source->data; | |
| 6967 | + | |
| 6968 | + BUG_ON(!ring || (ring->funcs->type != AMDGPU_RING_TYPE_KIQ)); | |
| 6969 | + | |
| 6970 | + me_id = (entry->ring_id & 0x0c) >> 2; | |
| 6971 | + pipe_id = (entry->ring_id & 0x03) >> 0; | |
| 6972 | + queue_id = (entry->ring_id & 0x70) >> 4; | |
| 6973 | + DRM_DEBUG("IH: CPC GENERIC2_INT, me:%d, pipe:%d, queue:%d\n", | |
| 6974 | + me_id, pipe_id, queue_id); | |
| 6975 | + | |
| 6976 | + amdgpu_fence_process(ring); | |
| 6977 | + return 0; | |
| 6978 | +} | |
| 6979 | + | |
| 6408 | 6980 | static const struct amd_ip_funcs gfx_v8_0_ip_funcs = { |
| 6409 | 6981 | .name = "gfx_v8_0", |
| 6410 | 6982 | .early_init = gfx_v8_0_early_init, |
| @@ -6423,6 +6995,7 @@ static const struct amd_ip_funcs gfx_v8_0_ip_funcs = { · 12 unmodified lines | ||
| 6423 | 6995 | .post_soft_reset = gfx_v8_0_post_soft_reset, |
| 6424 | 6996 | .set_clockgating_state = gfx_v8_0_set_clockgating_state, |
| 6425 | 6997 | .set_powergating_state = gfx_v8_0_set_powergating_state, |
| 6998 | + .get_clockgating_state = gfx_v8_0_get_clockgating_state, | |
| 6426 | 6999 | }; |
| 6427 | 7000 | |
| 6428 | 7001 | static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { |
| @@ -6440,7 +7013,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { · 11 unmodified lines | ||
| 6440 | 7013 | 7 + /* gfx_v8_0_ring_emit_pipeline_sync */ |
| 6441 | 7014 | 128 + 19 + /* gfx_v8_0_ring_emit_vm_flush */ |
| 6442 | 7015 | 2 + /* gfx_v8_ring_emit_sb */ |
| 6443 | − 3 + 4, /* gfx_v8_ring_emit_cntxcntl including vgt flush */ | |
| 7016 | + 3 + 4 + 29, /* gfx_v8_ring_emit_cntxcntl including vgt flush/meta-data */ | |
| 6444 | 7017 | .emit_ib_size = 4, /* gfx_v8_0_ring_emit_ib_gfx */ |
| 6445 | 7018 | .emit_ib = gfx_v8_0_ring_emit_ib_gfx, |
| 6446 | 7019 | .emit_fence = gfx_v8_0_ring_emit_fence_gfx, |
| @@ -6485,10 +7058,39 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = { · 38 unmodified lines | ||
| 6485 | 7058 | .pad_ib = amdgpu_ring_generic_pad_ib, |
| 6486 | 7059 | }; |
| 6487 | 7060 | |
| 7061 | +static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_kiq = { | |
| 7062 | + .type = AMDGPU_RING_TYPE_KIQ, | |
| 7063 | + .align_mask = 0xff, | |
| 7064 | + .nop = PACKET3(PACKET3_NOP, 0x3FFF), | |
| 7065 | + .get_rptr = gfx_v8_0_ring_get_rptr, | |
| 7066 | + .get_wptr = gfx_v8_0_ring_get_wptr_compute, | |
| 7067 | + .set_wptr = gfx_v8_0_ring_set_wptr_compute, | |
| 7068 | + .emit_frame_size = | |
| 7069 | + 20 + /* gfx_v8_0_ring_emit_gds_switch */ | |
| 7070 | + 7 + /* gfx_v8_0_ring_emit_hdp_flush */ | |
| 7071 | + 5 + /* gfx_v8_0_ring_emit_hdp_invalidate */ | |
| 7072 | + 7 + /* gfx_v8_0_ring_emit_pipeline_sync */ | |
| 7073 | + 17 + /* gfx_v8_0_ring_emit_vm_flush */ | |
| 7074 | + 7 + 7 + 7, /* gfx_v8_0_ring_emit_fence_kiq x3 for user fence, vm fence */ | |
| 7075 | + .emit_ib_size = 4, /* gfx_v8_0_ring_emit_ib_compute */ | |
| 7076 | + .emit_ib = gfx_v8_0_ring_emit_ib_compute, | |
| 7077 | + .emit_fence = gfx_v8_0_ring_emit_fence_kiq, | |
| 7078 | + .emit_hdp_flush = gfx_v8_0_ring_emit_hdp_flush, | |
| 7079 | + .emit_hdp_invalidate = gfx_v8_0_ring_emit_hdp_invalidate, | |
| 7080 | + .test_ring = gfx_v8_0_ring_test_ring, | |
| 7081 | + .test_ib = gfx_v8_0_ring_test_ib, | |
| 7082 | + .insert_nop = amdgpu_ring_insert_nop, | |
| 7083 | + .pad_ib = amdgpu_ring_generic_pad_ib, | |
| 7084 | + .emit_rreg = gfx_v8_0_ring_emit_rreg, | |
| 7085 | + .emit_wreg = gfx_v8_0_ring_emit_wreg, | |
| 7086 | +}; | |
| 7087 | + | |
| 6488 | 7088 | static void gfx_v8_0_set_ring_funcs(struct amdgpu_device *adev) |
| 6489 | 7089 | { |
| 6490 | 7090 | int i; |
| 6491 | 7091 | |
| 7092 | + adev->gfx.kiq.ring.funcs = &gfx_v8_0_ring_funcs_kiq; | |
| 7093 | + | |
| 6492 | 7094 | for (i = 0; i < adev->gfx.num_gfx_rings; i++) |
| 6493 | 7095 | adev->gfx.gfx_ring[i].funcs = &gfx_v8_0_ring_funcs_gfx; |
| 6494 | 7096 | |
| @@ -6511,6 +7113,11 @@ static const struct amdgpu_irq_src_funcs gfx_v8_0_priv_inst_irq_funcs = { · 16 unmodified lines | ||
| 6511 | 7113 | .process = gfx_v8_0_priv_inst_irq, |
| 6512 | 7114 | }; |
| 6513 | 7115 | |
| 7116 | +static const struct amdgpu_irq_src_funcs gfx_v8_0_kiq_irq_funcs = { | |
| 7117 | + .set = gfx_v8_0_kiq_set_interrupt_state, | |
| 7118 | + .process = gfx_v8_0_kiq_irq, | |
| 7119 | +}; | |
| 7120 | + | |
| 6514 | 7121 | static void gfx_v8_0_set_irq_funcs(struct amdgpu_device *adev) |
| 6515 | 7122 | { |
| 6516 | 7123 | adev->gfx.eop_irq.num_types = AMDGPU_CP_IRQ_LAST; |
| @@ -6521,22 +7128,14 @@ static void gfx_v8_0_set_irq_funcs(struct amdgpu_device *adev) · 4 unmodified lines | ||
| 6521 | 7128 | |
| 6522 | 7129 | adev->gfx.priv_inst_irq.num_types = 1; |
| 6523 | 7130 | adev->gfx.priv_inst_irq.funcs = &gfx_v8_0_priv_inst_irq_funcs; |
| 7131 | + | |
| 7132 | + adev->gfx.kiq.irq.num_types = AMDGPU_CP_KIQ_IRQ_LAST; | |
| 7133 | + adev->gfx.kiq.irq.funcs = &gfx_v8_0_kiq_irq_funcs; | |
| 6524 | 7134 | } |
| 6525 | 7135 | |
| 6526 | 7136 | static void gfx_v8_0_set_rlc_funcs(struct amdgpu_device *adev) |
| 6527 | 7137 | { |
| 6528 | − switch (adev->asic_type) { | |
| 6529 | − case CHIP_TOPAZ: | |
| 6530 | − adev->gfx.rlc.funcs = &iceland_rlc_funcs; | |
| 6531 | − break; | |
| 6532 | − case CHIP_STONEY: | |
| 6533 | − case CHIP_CARRIZO: | |
| 6534 | − adev->gfx.rlc.funcs = &cz_rlc_funcs; | |
| 6535 | − break; | |
| 6536 | − default: | |
| 6537 | − adev->gfx.rlc.funcs = &gfx_v8_0_nop_rlc_funcs; | |
| 6538 | − break; | |
| 6539 | − } | |
| 7138 | + adev->gfx.rlc.funcs = &iceland_rlc_funcs; | |
| 6540 | 7139 | } |
| 6541 | 7140 | |
| 6542 | 7141 | static void gfx_v8_0_set_gds_init(struct amdgpu_device *adev) |
| @@ -6653,3 +7252,62 @@ const struct amdgpu_ip_block_version gfx_v8_1_ip_block = · 110 unmodified lines | ||
| 6653 | 7252 | .rev = 0, |
| 6654 | 7253 | .funcs = &gfx_v8_0_ip_funcs, |
| 6655 | 7254 | }; |
| 7255 | + | |
| 7256 | +static void gfx_v8_0_ring_emit_ce_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr) | |
| 7257 | +{ | |
| 7258 | + uint64_t ce_payload_addr; | |
| 7259 | + int cnt_ce; | |
| 7260 | + static union { | |
| 7261 | + struct amdgpu_ce_ib_state regular; | |
| 7262 | + struct amdgpu_ce_ib_state_chained_ib chained; | |
| 7263 | + } ce_payload = {0}; | |
| 7264 | + | |
| 7265 | + if (ring->adev->virt.chained_ib_support) { | |
| 7266 | + ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, ce_payload); | |
| 7267 | + cnt_ce = (sizeof(ce_payload.chained) >> 2) + 4 - 2; | |
| 7268 | + } else { | |
| 7269 | + ce_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, ce_payload); | |
| 7270 | + cnt_ce = (sizeof(ce_payload.regular) >> 2) + 4 - 2; | |
| 7271 | + } | |
| 7272 | + | |
| 7273 | + amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_ce)); | |
| 7274 | + amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) | | |
| 7275 | + WRITE_DATA_DST_SEL(8) | | |
| 7276 | + WR_CONFIRM) | | |
| 7277 | + WRITE_DATA_CACHE_POLICY(0)); | |
| 7278 | + amdgpu_ring_write(ring, lower_32_bits(ce_payload_addr)); | |
| 7279 | + amdgpu_ring_write(ring, upper_32_bits(ce_payload_addr)); | |
| 7280 | + amdgpu_ring_write_multiple(ring, (void *)&ce_payload, cnt_ce - 2); | |
| 7281 | +} | |
| 7282 | + | |
| 7283 | +static void gfx_v8_0_ring_emit_de_meta_init(struct amdgpu_ring *ring, uint64_t csa_addr) | |
| 7284 | +{ | |
| 7285 | + uint64_t de_payload_addr, gds_addr; | |
| 7286 | + int cnt_de; | |
| 7287 | + static union { | |
| 7288 | + struct amdgpu_de_ib_state regular; | |
| 7289 | + struct amdgpu_de_ib_state_chained_ib chained; | |
| 7290 | + } de_payload = {0}; | |
| 7291 | + | |
| 7292 | + gds_addr = csa_addr + 4096; | |
| 7293 | + if (ring->adev->virt.chained_ib_support) { | |
| 7294 | + de_payload.chained.gds_backup_addrlo = lower_32_bits(gds_addr); | |
| 7295 | + de_payload.chained.gds_backup_addrhi = upper_32_bits(gds_addr); | |
| 7296 | + de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data_chained_ib, de_payload); | |
| 7297 | + cnt_de = (sizeof(de_payload.chained) >> 2) + 4 - 2; | |
| 7298 | + } else { | |
| 7299 | + de_payload.regular.gds_backup_addrlo = lower_32_bits(gds_addr); | |
| 7300 | + de_payload.regular.gds_backup_addrhi = upper_32_bits(gds_addr); | |
| 7301 | + de_payload_addr = csa_addr + offsetof(struct amdgpu_gfx_meta_data, de_payload); | |
| 7302 | + cnt_de = (sizeof(de_payload.regular) >> 2) + 4 - 2; | |
| 7303 | + } | |
| 7304 | + | |
| 7305 | + amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt_de)); | |
| 7306 | + amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) | | |
| 7307 | + WRITE_DATA_DST_SEL(8) | | |
| 7308 | + WR_CONFIRM) | | |
| 7309 | + WRITE_DATA_CACHE_POLICY(0)); | |
| 7310 | + amdgpu_ring_write(ring, lower_32_bits(de_payload_addr)); | |
| 7311 | + amdgpu_ring_write(ring, upper_32_bits(de_payload_addr)); | |
| 7312 | + amdgpu_ring_write_multiple(ring, (void *)&de_payload, cnt_de - 2); | |
| 7313 | +} | |
| @@ -375,9 +375,16 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) · 374 unmodified lines | ||
| 375 | 375 | /* size in MB on si */ |
| 376 | 376 | adev->mc.mc_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; |
| 377 | 377 | adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; |
| 378 | − adev->mc.visible_vram_size = adev->mc.aper_size; | |
| 378 | + | |
| 379 | +#ifdef CONFIG_X86_64 | |
| 380 | + if (adev->flags & AMD_IS_APU) { | |
| 381 | + adev->mc.aper_base = ((u64)RREG32(mmMC_VM_FB_OFFSET)) << 22; | |
| 382 | + adev->mc.aper_size = adev->mc.real_vram_size; | |
| 383 | + } | |
| 384 | +#endif | |
| 379 | 385 | |
| 380 | 386 | /* In case the PCI BAR is larger than the actual amount of vram */ |
| 387 | + adev->mc.visible_vram_size = adev->mc.aper_size; | |
| 381 | 388 | if (adev->mc.visible_vram_size > adev->mc.real_vram_size) |
| 382 | 389 | adev->mc.visible_vram_size = adev->mc.real_vram_size; |
| 383 | 390 | |
| @@ -467,9 +467,16 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev) · 466 unmodified lines | ||
| 467 | 467 | /* size in MB on si */ |
| 468 | 468 | adev->mc.mc_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; |
| 469 | 469 | adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; |
| 470 | − adev->mc.visible_vram_size = adev->mc.aper_size; | |
| 470 | + | |
| 471 | +#ifdef CONFIG_X86_64 | |
| 472 | + if (adev->flags & AMD_IS_APU) { | |
| 473 | + adev->mc.aper_base = ((u64)RREG32(mmMC_VM_FB_OFFSET)) << 22; | |
| 474 | + adev->mc.aper_size = adev->mc.real_vram_size; | |
| 475 | + } | |
| 476 | +#endif | |
| 471 | 477 | |
| 472 | 478 | /* In case the PCI BAR is larger than the actual amount of vram */ |
| 479 | + adev->mc.visible_vram_size = adev->mc.aper_size; | |
| 473 | 480 | if (adev->mc.visible_vram_size > adev->mc.real_vram_size) |
| 474 | 481 | adev->mc.visible_vram_size = adev->mc.real_vram_size; |
| 475 | 482 | |
| @@ -1439,6 +1446,21 @@ static int gmc_v8_0_set_powergating_state(void *handle, · 963 unmodified lines | ||
| 1439 | 1446 | return 0; |
| 1440 | 1447 | } |
| 1441 | 1448 | |
| 1449 | +static void gmc_v8_0_get_clockgating_state(void *handle, u32 *flags) | |
| 1450 | +{ | |
| 1451 | + struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1452 | + int data; | |
| 1453 | + | |
| 1454 | + /* AMD_CG_SUPPORT_MC_MGCG */ | |
| 1455 | + data = RREG32(mmMC_HUB_MISC_HUB_CG); | |
| 1456 | + if (data & MC_HUB_MISC_HUB_CG__ENABLE_MASK) | |
| 1457 | + *flags |= AMD_CG_SUPPORT_MC_MGCG; | |
| 1458 | + | |
| 1459 | + /* AMD_CG_SUPPORT_MC_LS */ | |
| 1460 | + if (data & MC_HUB_MISC_HUB_CG__MEM_LS_ENABLE_MASK) | |
| 1461 | + *flags |= AMD_CG_SUPPORT_MC_LS; | |
| 1462 | +} | |
| 1463 | + | |
| 1442 | 1464 | static const struct amd_ip_funcs gmc_v8_0_ip_funcs = { |
| 1443 | 1465 | .name = "gmc_v8_0", |
| 1444 | 1466 | .early_init = gmc_v8_0_early_init, |
| @@ -1457,6 +1479,7 @@ static const struct amd_ip_funcs gmc_v8_0_ip_funcs = { · 12 unmodified lines | ||
| 1457 | 1479 | .post_soft_reset = gmc_v8_0_post_soft_reset, |
| 1458 | 1480 | .set_clockgating_state = gmc_v8_0_set_clockgating_state, |
| 1459 | 1481 | .set_powergating_state = gmc_v8_0_set_powergating_state, |
| 1482 | + .get_clockgating_state = gmc_v8_0_get_clockgating_state, | |
| 1460 | 1483 | }; |
| 1461 | 1484 | |
| 1462 | 1485 | static const struct amdgpu_gart_funcs gmc_v8_0_gart_funcs = { |
| @@ -1230,6 +1230,7 @@ static void kv_update_current_ps(struct amdgpu_device *adev, · 1229 unmodified lines | ||
| 1230 | 1230 | pi->current_rps = *rps; |
| 1231 | 1231 | pi->current_ps = *new_ps; |
| 1232 | 1232 | pi->current_rps.ps_priv = &pi->current_ps; |
| 1233 | + adev->pm.dpm.current_ps = &pi->current_rps; | |
| 1233 | 1234 | } |
| 1234 | 1235 | |
| 1235 | 1236 | static void kv_update_requested_ps(struct amdgpu_device *adev, |
| @@ -1241,6 +1242,7 @@ static void kv_update_requested_ps(struct amdgpu_device *adev, · 5 unmodified lines | ||
| 1241 | 1242 | pi->requested_rps = *rps; |
| 1242 | 1243 | pi->requested_ps = *new_ps; |
| 1243 | 1244 | pi->requested_rps.ps_priv = &pi->requested_ps; |
| 1245 | + adev->pm.dpm.requested_ps = &pi->requested_rps; | |
| 1244 | 1246 | } |
| 1245 | 1247 | |
| 1246 | 1248 | static void kv_dpm_enable_bapm(struct amdgpu_device *adev, bool enable) |
| @@ -1904,19 +1906,19 @@ static int kv_enable_nb_dpm(struct amdgpu_device *adev, · 657 unmodified lines | ||
| 1904 | 1906 | } |
| 1905 | 1907 | |
| 1906 | 1908 | static int kv_dpm_force_performance_level(struct amdgpu_device *adev, |
| 1907 | − enum amdgpu_dpm_forced_level level) | |
| 1909 | + enum amd_dpm_forced_level level) | |
| 1908 | 1910 | { |
| 1909 | 1911 | int ret; |
| 1910 | 1912 | |
| 1911 | − if (level == AMDGPU_DPM_FORCED_LEVEL_HIGH) { | |
| 1913 | + if (level == AMD_DPM_FORCED_LEVEL_HIGH) { | |
| 1912 | 1914 | ret = kv_force_dpm_highest(adev); |
| 1913 | 1915 | if (ret) |
| 1914 | 1916 | return ret; |
| 1915 | − } else if (level == AMDGPU_DPM_FORCED_LEVEL_LOW) { | |
| 1917 | + } else if (level == AMD_DPM_FORCED_LEVEL_LOW) { | |
| 1916 | 1918 | ret = kv_force_dpm_lowest(adev); |
| 1917 | 1919 | if (ret) |
| 1918 | 1920 | return ret; |
| 1919 | − } else if (level == AMDGPU_DPM_FORCED_LEVEL_AUTO) { | |
| 1921 | + } else if (level == AMD_DPM_FORCED_LEVEL_AUTO) { | |
| 1920 | 1922 | ret = kv_unforce_levels(adev); |
| 1921 | 1923 | if (ret) |
| 1922 | 1924 | return ret; |
| @@ -3009,7 +3011,6 @@ static int kv_dpm_late_init(void *handle) · 1086 unmodified lines | ||
| 3009 | 3011 | kv_dpm_powergate_samu(adev, true); |
| 3010 | 3012 | kv_dpm_powergate_vce(adev, true); |
| 3011 | 3013 | kv_dpm_powergate_uvd(adev, true); |
| 3012 | − | |
| 3013 | 3014 | return 0; |
| 3014 | 3015 | } |
| 3015 | 3016 | |
| @@ -3029,7 +3030,7 @@ static int kv_dpm_sw_init(void *handle) · 13 unmodified lines | ||
| 3029 | 3030 | /* default to balanced state */ |
| 3030 | 3031 | adev->pm.dpm.state = POWER_STATE_TYPE_BALANCED; |
| 3031 | 3032 | adev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; |
| 3032 | − adev->pm.dpm.forced_level = AMDGPU_DPM_FORCED_LEVEL_AUTO; | |
| 3033 | + adev->pm.dpm.forced_level = AMD_DPM_FORCED_LEVEL_AUTO; | |
| 3033 | 3034 | adev->pm.default_sclk = adev->clock.default_sclk; |
| 3034 | 3035 | adev->pm.default_mclk = adev->clock.default_mclk; |
| 3035 | 3036 | adev->pm.current_sclk = adev->clock.default_sclk; |
| @@ -3078,6 +3079,9 @@ static int kv_dpm_hw_init(void *handle) · 42 unmodified lines | ||
| 3078 | 3079 | int ret; |
| 3079 | 3080 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 3080 | 3081 | |
| 3082 | + if (!amdgpu_dpm) | |
| 3083 | + return 0; | |
| 3084 | + | |
| 3081 | 3085 | mutex_lock(&adev->pm.mutex); |
| 3082 | 3086 | kv_dpm_setup_asic(adev); |
| 3083 | 3087 | ret = kv_dpm_enable(adev); |
| @@ -3245,15 +3249,52 @@ static int kv_dpm_set_powergating_state(void *handle, · 161 unmodified lines | ||
| 3245 | 3249 | return 0; |
| 3246 | 3250 | } |
| 3247 | 3251 | |
| 3252 | +static inline bool kv_are_power_levels_equal(const struct kv_pl *kv_cpl1, | |
| 3253 | + const struct kv_pl *kv_cpl2) | |
| 3254 | +{ | |
| 3255 | + return ((kv_cpl1->sclk == kv_cpl2->sclk) && | |
| 3256 | + (kv_cpl1->vddc_index == kv_cpl2->vddc_index) && | |
| 3257 | + (kv_cpl1->ds_divider_index == kv_cpl2->ds_divider_index) && | |
| 3258 | + (kv_cpl1->force_nbp_state == kv_cpl2->force_nbp_state)); | |
| 3259 | +} | |
| 3260 | + | |
| 3248 | 3261 | static int kv_check_state_equal(struct amdgpu_device *adev, |
| 3249 | 3262 | struct amdgpu_ps *cps, |
| 3250 | 3263 | struct amdgpu_ps *rps, |
| 3251 | 3264 | bool *equal) |
| 3252 | 3265 | { |
| 3253 | − if (equal == NULL) | |
| 3266 | + struct kv_ps *kv_cps; | |
| 3267 | + struct kv_ps *kv_rps; | |
| 3268 | + int i; | |
| 3269 | + | |
| 3270 | + if (adev == NULL || cps == NULL || rps == NULL || equal == NULL) | |
| 3254 | 3271 | return -EINVAL; |
| 3255 | 3272 | |
| 3256 | − *equal = false; | |
| 3273 | + kv_cps = kv_get_ps(cps); | |
| 3274 | + kv_rps = kv_get_ps(rps); | |
| 3275 | + | |
| 3276 | + if (kv_cps == NULL) { | |
| 3277 | + *equal = false; | |
| 3278 | + return 0; | |
| 3279 | + } | |
| 3280 | + | |
| 3281 | + if (kv_cps->num_levels != kv_rps->num_levels) { | |
| 3282 | + *equal = false; | |
| 3283 | + return 0; | |
| 3284 | + } | |
| 3285 | + | |
| 3286 | + for (i = 0; i < kv_cps->num_levels; i++) { | |
| 3287 | + if (!kv_are_power_levels_equal(&(kv_cps->levels[i]), | |
| 3288 | + &(kv_rps->levels[i]))) { | |
| 3289 | + *equal = false; | |
| 3290 | + return 0; | |
| 3291 | + } | |
| 3292 | + } | |
| 3293 | + | |
| 3294 | + /* If all performance levels are the same try to use the UVD clocks to break the tie.*/ | |
| 3295 | + *equal = ((cps->vclk == rps->vclk) && (cps->dclk == rps->dclk)); | |
| 3296 | + *equal &= ((cps->evclk == rps->evclk) && (cps->ecclk == rps->ecclk)); | |
| 3297 | + | |
| 3257 | 3298 | return 0; |
| 3258 | 3299 | } |
| 3259 | 3300 | |
| @@ -3307,12 +3348,3 @@ static void kv_dpm_set_irq_funcs(struct amdgpu_device *adev) · 47 unmodified lines | ||
| 3307 | 3348 | adev->pm.dpm.thermal.irq.num_types = AMDGPU_THERMAL_IRQ_LAST; |
| 3308 | 3349 | adev->pm.dpm.thermal.irq.funcs = &kv_dpm_irq_funcs; |
| 3309 | 3350 | } |
| 3310 | − | |
| 3311 | −const struct amdgpu_ip_block_version kv_dpm_ip_block = | |
| 3312 | −{ | |
| 3313 | − .type = AMD_IP_BLOCK_TYPE_SMC, | |
| 3314 | − .major = 7, | |
| 3315 | − .minor = 0, | |
| 3316 | − .rev = 0, | |
| 3317 | − .funcs = &kv_dpm_ip_funcs, | |
| 3318 | −}; | |
| @@ -0,0 +1,592 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright 2017 Advanced Micro Devices, Inc. | |
| 3 | + * | |
| 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: | |
| 10 | + * | |
| 11 | + * The above copyright notice and this permission notice shall be included in | |
| 12 | + * all copies or substantial portions of the Software. | |
| 13 | + * | |
| 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. | |
| 21 | + * | |
| 22 | + * Authors: Xiangliang.Yu@amd.com | |
| 23 | + */ | |
| 24 | + | |
| 25 | +#include "amdgpu.h" | |
| 26 | +#include "vi.h" | |
| 27 | +#include "bif/bif_5_0_d.h" | |
| 28 | +#include "bif/bif_5_0_sh_mask.h" | |
| 29 | +#include "vid.h" | |
| 30 | +#include "gca/gfx_8_0_d.h" | |
| 31 | +#include "gca/gfx_8_0_sh_mask.h" | |
| 32 | +#include "gmc_v8_0.h" | |
| 33 | +#include "gfx_v8_0.h" | |
| 34 | +#include "sdma_v3_0.h" | |
| 35 | +#include "tonga_ih.h" | |
| 36 | +#include "gmc/gmc_8_2_d.h" | |
| 37 | +#include "gmc/gmc_8_2_sh_mask.h" | |
| 38 | +#include "oss/oss_3_0_d.h" | |
| 39 | +#include "oss/oss_3_0_sh_mask.h" | |
| 40 | +#include "gca/gfx_8_0_sh_mask.h" | |
| 41 | +#include "dce/dce_10_0_d.h" | |
| 42 | +#include "dce/dce_10_0_sh_mask.h" | |
| 43 | +#include "smu/smu_7_1_3_d.h" | |
| 44 | +#include "mxgpu_vi.h" | |
| 45 | + | |
| 46 | +/* VI golden setting */ | |
| 47 | +static const u32 xgpu_fiji_mgcg_cgcg_init[] = { | |
| 48 | + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, | |
| 49 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 50 | + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 51 | + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 52 | + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 53 | + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 54 | + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, | |
| 55 | + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, | |
| 56 | + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 57 | + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 58 | + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 59 | + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 60 | + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 61 | + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 62 | + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 63 | + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 64 | + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 65 | + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 66 | + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, | |
| 67 | + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, | |
| 68 | + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, | |
| 69 | + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, | |
| 70 | + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, | |
| 71 | + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 72 | + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 73 | + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 74 | + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, | |
| 75 | + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 76 | + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 77 | + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 78 | + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 79 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 80 | + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, | |
| 81 | + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, | |
| 82 | + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, | |
| 83 | + mmPCIE_INDEX, 0xffffffff, 0x0140001c, | |
| 84 | + mmPCIE_DATA, 0x000f0000, 0x00000000, | |
| 85 | + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, | |
| 86 | + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, | |
| 87 | + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, | |
| 88 | + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, | |
| 89 | + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, | |
| 90 | + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, | |
| 91 | + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, | |
| 92 | + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, | |
| 93 | + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, | |
| 94 | + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, | |
| 95 | +}; | |
| 96 | + | |
| 97 | +static const u32 xgpu_fiji_golden_settings_a10[] = { | |
| 98 | + mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040, | |
| 99 | + mmDB_DEBUG2, 0xf00fffff, 0x00000400, | |
| 100 | + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, | |
| 101 | + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, | |
| 102 | + mmFBC_MISC, 0x1f311fff, 0x12300000, | |
| 103 | + mmHDMI_CONTROL, 0x31000111, 0x00000011, | |
| 104 | + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, | |
| 105 | + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, | |
| 106 | + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, | |
| 107 | + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, | |
| 108 | + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, | |
| 109 | + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, | |
| 110 | + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, | |
| 111 | + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, | |
| 112 | + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, | |
| 113 | + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, | |
| 114 | + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, | |
| 115 | + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, | |
| 116 | + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, | |
| 117 | + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000ff, | |
| 118 | + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, | |
| 119 | + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 120 | + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 121 | + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 122 | + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 123 | +}; | |
| 124 | + | |
| 125 | +static const u32 xgpu_fiji_golden_common_all[] = { | |
| 126 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 127 | + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x3a00161a, | |
| 128 | + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002e, | |
| 129 | + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003, | |
| 130 | + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, | |
| 131 | + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, | |
| 132 | + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, | |
| 133 | + mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF, | |
| 134 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 135 | + mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x00000009, | |
| 136 | +}; | |
| 137 | + | |
| 138 | +static const u32 xgpu_tonga_mgcg_cgcg_init[] = { | |
| 139 | + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff, | |
| 140 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 141 | + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 142 | + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 143 | + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 144 | + mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 145 | + mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100, | |
| 146 | + mmCGTT_DRM_CLK_CTRL0, 0xffffffff, 0x00600100, | |
| 147 | + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 148 | + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 149 | + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 150 | + mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 151 | + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 152 | + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 153 | + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 154 | + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 155 | + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 156 | + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 157 | + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, | |
| 158 | + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, | |
| 159 | + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, | |
| 160 | + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, | |
| 161 | + mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100, | |
| 162 | + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 163 | + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 164 | + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 165 | + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, | |
| 166 | + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 167 | + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 168 | + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 169 | + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 170 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 171 | + mmCGTS_CU0_SP0_CTRL_REG, 0xffffffff, 0x00010000, | |
| 172 | + mmCGTS_CU0_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, | |
| 173 | + mmCGTS_CU0_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, | |
| 174 | + mmCGTS_CU0_SP1_CTRL_REG, 0xffffffff, 0x00060005, | |
| 175 | + mmCGTS_CU0_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, | |
| 176 | + mmCGTS_CU1_SP0_CTRL_REG, 0xffffffff, 0x00010000, | |
| 177 | + mmCGTS_CU1_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, | |
| 178 | + mmCGTS_CU1_TA_CTRL_REG, 0xffffffff, 0x00040007, | |
| 179 | + mmCGTS_CU1_SP1_CTRL_REG, 0xffffffff, 0x00060005, | |
| 180 | + mmCGTS_CU1_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, | |
| 181 | + mmCGTS_CU2_SP0_CTRL_REG, 0xffffffff, 0x00010000, | |
| 182 | + mmCGTS_CU2_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, | |
| 183 | + mmCGTS_CU2_TA_CTRL_REG, 0xffffffff, 0x00040007, | |
| 184 | + mmCGTS_CU2_SP1_CTRL_REG, 0xffffffff, 0x00060005, | |
| 185 | + mmCGTS_CU2_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, | |
| 186 | + mmCGTS_CU3_SP0_CTRL_REG, 0xffffffff, 0x00010000, | |
| 187 | + mmCGTS_CU3_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, | |
| 188 | + mmCGTS_CU3_TA_CTRL_REG, 0xffffffff, 0x00040007, | |
| 189 | + mmCGTS_CU3_SP1_CTRL_REG, 0xffffffff, 0x00060005, | |
| 190 | + mmCGTS_CU3_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, | |
| 191 | + mmCGTS_CU4_SP0_CTRL_REG, 0xffffffff, 0x00010000, | |
| 192 | + mmCGTS_CU4_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, | |
| 193 | + mmCGTS_CU4_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007, | |
| 194 | + mmCGTS_CU4_SP1_CTRL_REG, 0xffffffff, 0x00060005, | |
| 195 | + mmCGTS_CU4_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, | |
| 196 | + mmCGTS_CU5_SP0_CTRL_REG, 0xffffffff, 0x00010000, | |
| 197 | + mmCGTS_CU5_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, | |
| 198 | + mmCGTS_CU5_TA_CTRL_REG, 0xffffffff, 0x00040007, | |
| 199 | + mmCGTS_CU5_SP1_CTRL_REG, 0xffffffff, 0x00060005, | |
| 200 | + mmCGTS_CU5_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, | |
| 201 | + mmCGTS_CU6_SP0_CTRL_REG, 0xffffffff, 0x00010000, | |
| 202 | + mmCGTS_CU6_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, | |
| 203 | + mmCGTS_CU6_TA_CTRL_REG, 0xffffffff, 0x00040007, | |
| 204 | + mmCGTS_CU6_SP1_CTRL_REG, 0xffffffff, 0x00060005, | |
| 205 | + mmCGTS_CU6_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, | |
| 206 | + mmCGTS_CU7_SP0_CTRL_REG, 0xffffffff, 0x00010000, | |
| 207 | + mmCGTS_CU7_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002, | |
| 208 | + mmCGTS_CU7_TA_CTRL_REG, 0xffffffff, 0x00040007, | |
| 209 | + mmCGTS_CU7_SP1_CTRL_REG, 0xffffffff, 0x00060005, | |
| 210 | + mmCGTS_CU7_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008, | |
| 211 | + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200, | |
| 212 | + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, | |
| 213 | + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c, | |
| 214 | + mmPCIE_INDEX, 0xffffffff, 0x0140001c, | |
| 215 | + mmPCIE_DATA, 0x000f0000, 0x00000000, | |
| 216 | + mmSMC_IND_INDEX_4, 0xffffffff, 0xC060000C, | |
| 217 | + mmSMC_IND_DATA_4, 0xc0000fff, 0x00000100, | |
| 218 | + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, | |
| 219 | + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, | |
| 220 | + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, | |
| 221 | + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, | |
| 222 | + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, | |
| 223 | + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, | |
| 224 | + mmSDMA0_CLK_CTRL, 0xff000ff0, 0x00000100, | |
| 225 | + mmSDMA1_CLK_CTRL, 0xff000ff0, 0x00000100, | |
| 226 | +}; | |
| 227 | + | |
| 228 | +static const u32 xgpu_tonga_golden_settings_a11[] = { | |
| 229 | + mmCB_HW_CONTROL, 0xfffdf3cf, 0x00007208, | |
| 230 | + mmCB_HW_CONTROL_3, 0x00000040, 0x00000040, | |
| 231 | + mmDB_DEBUG2, 0xf00fffff, 0x00000400, | |
| 232 | + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, | |
| 233 | + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, | |
| 234 | + mmFBC_MISC, 0x1f311fff, 0x12300000, | |
| 235 | + mmGB_GPU_ID, 0x0000000f, 0x00000000, | |
| 236 | + mmHDMI_CONTROL, 0x31000111, 0x00000011, | |
| 237 | + mmMC_ARB_WTM_GRPWT_RD, 0x00000003, 0x00000000, | |
| 238 | + mmMC_HUB_RDREQ_DMIF_LIMIT, 0x0000007f, 0x00000028, | |
| 239 | + mmMC_HUB_WDP_UMC, 0x00007fb6, 0x00000991, | |
| 240 | + mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, | |
| 241 | + mmPA_SC_FIFO_DEPTH_CNTL, 0x000003ff, 0x000000fc, | |
| 242 | + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, | |
| 243 | + mmRLC_CGCG_CGLS_CTRL, 0x00000003, 0x0000003c, | |
| 244 | + mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, | |
| 245 | + mmSDMA0_CLK_CTRL, 0xff000fff, 0x00000000, | |
| 246 | + mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, | |
| 247 | + mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, | |
| 248 | + mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, | |
| 249 | + mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, | |
| 250 | + mmSDMA1_CLK_CTRL, 0xff000fff, 0x00000000, | |
| 251 | + mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, | |
| 252 | + mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, | |
| 253 | + mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, | |
| 254 | + mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd, | |
| 255 | + mmTA_CNTL_AUX, 0x000f000f, 0x000b0000, | |
| 256 | + mmTCC_CTRL, 0x00100000, 0xf31fff7f, | |
| 257 | + mmTCC_EXE_DISABLE, 0x00000002, 0x00000002, | |
| 258 | + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000002fb, | |
| 259 | + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b, | |
| 260 | + mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876, | |
| 261 | + mmVGT_RESET_DEBUG, 0x00000004, 0x00000004, | |
| 262 | + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 263 | + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 264 | + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 265 | + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 266 | +}; | |
| 267 | + | |
| 268 | +static const u32 xgpu_tonga_golden_common_all[] = { | |
| 269 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 270 | + mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x16000012, | |
| 271 | + mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002A, | |
| 272 | + mmGB_ADDR_CONFIG, 0xffffffff, 0x22011002, | |
| 273 | + mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, | |
| 274 | + mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, | |
| 275 | + mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF, | |
| 276 | +}; | |
| 277 | + | |
| 278 | +void xgpu_vi_init_golden_registers(struct amdgpu_device *adev) | |
| 279 | +{ | |
| 280 | + switch (adev->asic_type) { | |
| 281 | + case CHIP_FIJI: | |
| 282 | + amdgpu_program_register_sequence(adev, | |
| 283 | + xgpu_fiji_mgcg_cgcg_init, | |
| 284 | + (const u32)ARRAY_SIZE( | |
| 285 | + xgpu_fiji_mgcg_cgcg_init)); | |
| 286 | + amdgpu_program_register_sequence(adev, | |
| 287 | + xgpu_fiji_golden_settings_a10, | |
| 288 | + (const u32)ARRAY_SIZE( | |
| 289 | + xgpu_fiji_golden_settings_a10)); | |
| 290 | + amdgpu_program_register_sequence(adev, | |
| 291 | + xgpu_fiji_golden_common_all, | |
| 292 | + (const u32)ARRAY_SIZE( | |
| 293 | + xgpu_fiji_golden_common_all)); | |
| 294 | + break; | |
| 295 | + case CHIP_TONGA: | |
| 296 | + amdgpu_program_register_sequence(adev, | |
| 297 | + xgpu_tonga_mgcg_cgcg_init, | |
| 298 | + (const u32)ARRAY_SIZE( | |
| 299 | + xgpu_tonga_mgcg_cgcg_init)); | |
| 300 | + amdgpu_program_register_sequence(adev, | |
| 301 | + xgpu_tonga_golden_settings_a11, | |
| 302 | + (const u32)ARRAY_SIZE( | |
| 303 | + xgpu_tonga_golden_settings_a11)); | |
| 304 | + amdgpu_program_register_sequence(adev, | |
| 305 | + xgpu_tonga_golden_common_all, | |
| 306 | + (const u32)ARRAY_SIZE( | |
| 307 | + xgpu_tonga_golden_common_all)); | |
| 308 | + break; | |
| 309 | + default: | |
| 310 | + BUG_ON("Doesn't support chip type.\n"); | |
| 311 | + break; | |
| 312 | + } | |
| 313 | +} | |
| 314 | + | |
| 315 | +/* | |
| 316 | + * Mailbox communication between GPU hypervisor and VFs | |
| 317 | + */ | |
| 318 | +static void xgpu_vi_mailbox_send_ack(struct amdgpu_device *adev) | |
| 319 | +{ | |
| 320 | + u32 reg; | |
| 321 | + | |
| 322 | + reg = RREG32(mmMAILBOX_CONTROL); | |
| 323 | + reg = REG_SET_FIELD(reg, MAILBOX_CONTROL, RCV_MSG_ACK, 1); | |
| 324 | + WREG32(mmMAILBOX_CONTROL, reg); | |
| 325 | +} | |
| 326 | + | |
| 327 | +static void xgpu_vi_mailbox_set_valid(struct amdgpu_device *adev, bool val) | |
| 328 | +{ | |
| 329 | + u32 reg; | |
| 330 | + | |
| 331 | + reg = RREG32(mmMAILBOX_CONTROL); | |
| 332 | + reg = REG_SET_FIELD(reg, MAILBOX_CONTROL, | |
| 333 | + TRN_MSG_VALID, val ? 1 : 0); | |
| 334 | + WREG32(mmMAILBOX_CONTROL, reg); | |
| 335 | +} | |
| 336 | + | |
| 337 | +static void xgpu_vi_mailbox_trans_msg(struct amdgpu_device *adev, | |
| 338 | + enum idh_event event) | |
| 339 | +{ | |
| 340 | + u32 reg; | |
| 341 | + | |
| 342 | + reg = RREG32(mmMAILBOX_MSGBUF_TRN_DW0); | |
| 343 | + reg = REG_SET_FIELD(reg, MAILBOX_MSGBUF_TRN_DW0, | |
| 344 | + MSGBUF_DATA, event); | |
| 345 | + WREG32(mmMAILBOX_MSGBUF_TRN_DW0, reg); | |
| 346 | + | |
| 347 | + xgpu_vi_mailbox_set_valid(adev, true); | |
| 348 | +} | |
| 349 | + | |
| 350 | +static int xgpu_vi_mailbox_rcv_msg(struct amdgpu_device *adev, | |
| 351 | + enum idh_event event) | |
| 352 | +{ | |
| 353 | + u32 reg; | |
| 354 | + | |
| 355 | + reg = RREG32(mmMAILBOX_MSGBUF_RCV_DW0); | |
| 356 | + if (reg != event) | |
| 357 | + return -ENOENT; | |
| 358 | + | |
| 359 | + /* send ack to PF */ | |
| 360 | + xgpu_vi_mailbox_send_ack(adev); | |
| 361 | + | |
| 362 | + return 0; | |
| 363 | +} | |
| 364 | + | |
| 365 | +static int xgpu_vi_poll_ack(struct amdgpu_device *adev) | |
| 366 | +{ | |
| 367 | + int r = 0, timeout = VI_MAILBOX_TIMEDOUT; | |
| 368 | + u32 mask = REG_FIELD_MASK(MAILBOX_CONTROL, TRN_MSG_ACK); | |
| 369 | + u32 reg; | |
| 370 | + | |
| 371 | + reg = RREG32(mmMAILBOX_CONTROL); | |
| 372 | + while (!(reg & mask)) { | |
| 373 | + if (timeout <= 0) { | |
| 374 | + pr_err("Doesn't get ack from pf.\n"); | |
| 375 | + r = -ETIME; | |
| 376 | + break; | |
| 377 | + } | |
| 378 | + msleep(1); | |
| 379 | + timeout -= 1; | |
| 380 | + | |
| 381 | + reg = RREG32(mmMAILBOX_CONTROL); | |
| 382 | + } | |
| 383 | + | |
| 384 | + return r; | |
| 385 | +} | |
| 386 | + | |
| 387 | +static int xgpu_vi_poll_msg(struct amdgpu_device *adev, enum idh_event event) | |
| 388 | +{ | |
| 389 | + int r = 0, timeout = VI_MAILBOX_TIMEDOUT; | |
| 390 | + | |
| 391 | + r = xgpu_vi_mailbox_rcv_msg(adev, event); | |
| 392 | + while (r) { | |
| 393 | + if (timeout <= 0) { | |
| 394 | + pr_err("Doesn't get ack from pf.\n"); | |
| 395 | + r = -ETIME; | |
| 396 | + break; | |
| 397 | + } | |
| 398 | + msleep(1); | |
| 399 | + timeout -= 1; | |
| 400 | + | |
| 401 | + r = xgpu_vi_mailbox_rcv_msg(adev, event); | |
| 402 | + } | |
| 403 | + | |
| 404 | + return r; | |
| 405 | +} | |
| 406 | + | |
| 407 | +static int xgpu_vi_send_access_requests(struct amdgpu_device *adev, | |
| 408 | + enum idh_request request) | |
| 409 | +{ | |
| 410 | + int r; | |
| 411 | + | |
| 412 | + xgpu_vi_mailbox_trans_msg(adev, request); | |
| 413 | + | |
| 414 | + /* start to poll ack */ | |
| 415 | + r = xgpu_vi_poll_ack(adev); | |
| 416 | + if (r) | |
| 417 | + return r; | |
| 418 | + | |
| 419 | + xgpu_vi_mailbox_set_valid(adev, false); | |
| 420 | + | |
| 421 | + /* start to check msg if request is idh_req_gpu_init_access */ | |
| 422 | + if (request == IDH_REQ_GPU_INIT_ACCESS) { | |
| 423 | + r = xgpu_vi_poll_msg(adev, IDH_READY_TO_ACCESS_GPU); | |
| 424 | + if (r) | |
| 425 | + return r; | |
| 426 | + } | |
| 427 | + | |
| 428 | + return 0; | |
| 429 | +} | |
| 430 | + | |
| 431 | +static int xgpu_vi_request_reset(struct amdgpu_device *adev) | |
| 432 | +{ | |
| 433 | + return xgpu_vi_send_access_requests(adev, IDH_REQ_GPU_RESET_ACCESS); | |
| 434 | +} | |
| 435 | + | |
| 436 | +static int xgpu_vi_request_full_gpu_access(struct amdgpu_device *adev, | |
| 437 | + bool init) | |
| 438 | +{ | |
| 439 | + enum idh_event event; | |
| 440 | + | |
| 441 | + event = init ? IDH_REQ_GPU_INIT_ACCESS : IDH_REQ_GPU_FINI_ACCESS; | |
| 442 | + return xgpu_vi_send_access_requests(adev, event); | |
| 443 | +} | |
| 444 | + | |
| 445 | +static int xgpu_vi_release_full_gpu_access(struct amdgpu_device *adev, | |
| 446 | + bool init) | |
| 447 | +{ | |
| 448 | + enum idh_event event; | |
| 449 | + int r = 0; | |
| 450 | + | |
| 451 | + event = init ? IDH_REL_GPU_INIT_ACCESS : IDH_REL_GPU_FINI_ACCESS; | |
| 452 | + r = xgpu_vi_send_access_requests(adev, event); | |
| 453 | + | |
| 454 | + return r; | |
| 455 | +} | |
| 456 | + | |
| 457 | +/* add support mailbox interrupts */ | |
| 458 | +static int xgpu_vi_mailbox_ack_irq(struct amdgpu_device *adev, | |
| 459 | + struct amdgpu_irq_src *source, | |
| 460 | + struct amdgpu_iv_entry *entry) | |
| 461 | +{ | |
| 462 | + DRM_DEBUG("get ack intr and do nothing.\n"); | |
| 463 | + return 0; | |
| 464 | +} | |
| 465 | + | |
| 466 | +static int xgpu_vi_set_mailbox_ack_irq(struct amdgpu_device *adev, | |
| 467 | + struct amdgpu_irq_src *src, | |
| 468 | + unsigned type, | |
| 469 | + enum amdgpu_interrupt_state state) | |
| 470 | +{ | |
| 471 | + u32 tmp = RREG32(mmMAILBOX_INT_CNTL); | |
| 472 | + | |
| 473 | + tmp = REG_SET_FIELD(tmp, MAILBOX_INT_CNTL, ACK_INT_EN, | |
| 474 | + (state == AMDGPU_IRQ_STATE_ENABLE) ? 1 : 0); | |
| 475 | + WREG32(mmMAILBOX_INT_CNTL, tmp); | |
| 476 | + | |
| 477 | + return 0; | |
| 478 | +} | |
| 479 | + | |
| 480 | +static void xgpu_vi_mailbox_flr_work(struct work_struct *work) | |
| 481 | +{ | |
| 482 | + struct amdgpu_virt *virt = container_of(work, | |
| 483 | + struct amdgpu_virt, flr_work.work); | |
| 484 | + struct amdgpu_device *adev = container_of(virt, | |
| 485 | + struct amdgpu_device, virt); | |
| 486 | + int r = 0; | |
| 487 | + | |
| 488 | + r = xgpu_vi_poll_msg(adev, IDH_FLR_NOTIFICATION_CMPL); | |
| 489 | + if (r) | |
| 490 | + DRM_ERROR("failed to get flr cmpl msg from hypervior.\n"); | |
| 491 | + | |
| 492 | + /* TODO: need to restore gfx states */ | |
| 493 | +} | |
| 494 | + | |
| 495 | +static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev, | |
| 496 | + struct amdgpu_irq_src *src, | |
| 497 | + unsigned type, | |
| 498 | + enum amdgpu_interrupt_state state) | |
| 499 | +{ | |
| 500 | + u32 tmp = RREG32(mmMAILBOX_INT_CNTL); | |
| 501 | + | |
| 502 | + tmp = REG_SET_FIELD(tmp, MAILBOX_INT_CNTL, VALID_INT_EN, | |
| 503 | + (state == AMDGPU_IRQ_STATE_ENABLE) ? 1 : 0); | |
| 504 | + WREG32(mmMAILBOX_INT_CNTL, tmp); | |
| 505 | + | |
| 506 | + return 0; | |
| 507 | +} | |
| 508 | + | |
| 509 | +static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev, | |
| 510 | + struct amdgpu_irq_src *source, | |
| 511 | + struct amdgpu_iv_entry *entry) | |
| 512 | +{ | |
| 513 | + int r; | |
| 514 | + | |
| 515 | + adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME; | |
| 516 | + r = xgpu_vi_mailbox_rcv_msg(adev, IDH_FLR_NOTIFICATION); | |
| 517 | + /* do nothing for other msg */ | |
| 518 | + if (r) | |
| 519 | + return 0; | |
| 520 | + | |
| 521 | + /* TODO: need to save gfx states */ | |
| 522 | + schedule_delayed_work(&adev->virt.flr_work, | |
| 523 | + msecs_to_jiffies(VI_MAILBOX_RESET_TIME)); | |
| 524 | + | |
| 525 | + return 0; | |
| 526 | +} | |
| 527 | + | |
| 528 | +static const struct amdgpu_irq_src_funcs xgpu_vi_mailbox_ack_irq_funcs = { | |
| 529 | + .set = xgpu_vi_set_mailbox_ack_irq, | |
| 530 | + .process = xgpu_vi_mailbox_ack_irq, | |
| 531 | +}; | |
| 532 | + | |
| 533 | +static const struct amdgpu_irq_src_funcs xgpu_vi_mailbox_rcv_irq_funcs = { | |
| 534 | + .set = xgpu_vi_set_mailbox_rcv_irq, | |
| 535 | + .process = xgpu_vi_mailbox_rcv_irq, | |
| 536 | +}; | |
| 537 | + | |
| 538 | +void xgpu_vi_mailbox_set_irq_funcs(struct amdgpu_device *adev) | |
| 539 | +{ | |
| 540 | + adev->virt.ack_irq.num_types = 1; | |
| 541 | + adev->virt.ack_irq.funcs = &xgpu_vi_mailbox_ack_irq_funcs; | |
| 542 | + adev->virt.rcv_irq.num_types = 1; | |
| 543 | + adev->virt.rcv_irq.funcs = &xgpu_vi_mailbox_rcv_irq_funcs; | |
| 544 | +} | |
| 545 | + | |
| 546 | +int xgpu_vi_mailbox_add_irq_id(struct amdgpu_device *adev) | |
| 547 | +{ | |
| 548 | + int r; | |
| 549 | + | |
| 550 | + r = amdgpu_irq_add_id(adev, 135, &adev->virt.rcv_irq); | |
| 551 | + if (r) | |
| 552 | + return r; | |
| 553 | + | |
| 554 | + r = amdgpu_irq_add_id(adev, 138, &adev->virt.ack_irq); | |
| 555 | + if (r) { | |
| 556 | + amdgpu_irq_put(adev, &adev->virt.rcv_irq, 0); | |
| 557 | + return r; | |
| 558 | + } | |
| 559 | + | |
| 560 | + return 0; | |
| 561 | +} | |
| 562 | + | |
| 563 | +int xgpu_vi_mailbox_get_irq(struct amdgpu_device *adev) | |
| 564 | +{ | |
| 565 | + int r; | |
| 566 | + | |
| 567 | + r = amdgpu_irq_get(adev, &adev->virt.rcv_irq, 0); | |
| 568 | + if (r) | |
| 569 | + return r; | |
| 570 | + r = amdgpu_irq_get(adev, &adev->virt.ack_irq, 0); | |
| 571 | + if (r) { | |
| 572 | + amdgpu_irq_put(adev, &adev->virt.rcv_irq, 0); | |
| 573 | + return r; | |
| 574 | + } | |
| 575 | + | |
| 576 | + INIT_DELAYED_WORK(&adev->virt.flr_work, xgpu_vi_mailbox_flr_work); | |
| 577 | + | |
| 578 | + return 0; | |
| 579 | +} | |
| 580 | + | |
| 581 | +void xgpu_vi_mailbox_put_irq(struct amdgpu_device *adev) | |
| 582 | +{ | |
| 583 | + cancel_delayed_work_sync(&adev->virt.flr_work); | |
| 584 | + amdgpu_irq_put(adev, &adev->virt.ack_irq, 0); | |
| 585 | + amdgpu_irq_put(adev, &adev->virt.rcv_irq, 0); | |
| 586 | +} | |
| 587 | + | |
| 588 | +const struct amdgpu_virt_ops xgpu_vi_virt_ops = { | |
| 589 | + .req_full_gpu = xgpu_vi_request_full_gpu_access, | |
| 590 | + .rel_full_gpu = xgpu_vi_release_full_gpu_access, | |
| 591 | + .reset_gpu = xgpu_vi_request_reset, | |
| 592 | +}; | |
| @@ -0,0 +1,55 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright 2017 Advanced Micro Devices, Inc. | |
| 3 | + * | |
| 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: | |
| 10 | + * | |
| 11 | + * The above copyright notice and this permission notice shall be included in | |
| 12 | + * all copies or substantial portions of the Software. | |
| 13 | + * | |
| 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. | |
| 21 | + */ | |
| 22 | + | |
| 23 | +#ifndef __MXGPU_VI_H__ | |
| 24 | +#define __MXGPU_VI_H__ | |
| 25 | + | |
| 26 | +#define VI_MAILBOX_TIMEDOUT 150 | |
| 27 | +#define VI_MAILBOX_RESET_TIME 12 | |
| 28 | + | |
| 29 | +/* VI mailbox messages request */ | |
| 30 | +enum idh_request { | |
| 31 | + IDH_REQ_GPU_INIT_ACCESS = 1, | |
| 32 | + IDH_REL_GPU_INIT_ACCESS, | |
| 33 | + IDH_REQ_GPU_FINI_ACCESS, | |
| 34 | + IDH_REL_GPU_FINI_ACCESS, | |
| 35 | + IDH_REQ_GPU_RESET_ACCESS | |
| 36 | +}; | |
| 37 | + | |
| 38 | +/* VI mailbox messages data */ | |
| 39 | +enum idh_event { | |
| 40 | + IDH_CLR_MSG_BUF = 0, | |
| 41 | + IDH_READY_TO_ACCESS_GPU, | |
| 42 | + IDH_FLR_NOTIFICATION, | |
| 43 | + IDH_FLR_NOTIFICATION_CMPL, | |
| 44 | + IDH_EVENT_MAX | |
| 45 | +}; | |
| 46 | + | |
| 47 | +extern const struct amdgpu_virt_ops xgpu_vi_virt_ops; | |
| 48 | + | |
| 49 | +void xgpu_vi_init_golden_registers(struct amdgpu_device *adev); | |
| 50 | +void xgpu_vi_mailbox_set_irq_funcs(struct amdgpu_device *adev); | |
| 51 | +int xgpu_vi_mailbox_add_irq_id(struct amdgpu_device *adev); | |
| 52 | +int xgpu_vi_mailbox_get_irq(struct amdgpu_device *adev); | |
| 53 | +void xgpu_vi_mailbox_put_irq(struct amdgpu_device *adev); | |
| 54 | + | |
| 55 | +#endif | |
| @@ -701,7 +701,7 @@ static int sdma_v2_4_ring_test_ib(struct amdgpu_ring *ring, long timeout) · 700 unmodified lines | ||
| 701 | 701 | ib.ptr[7] = SDMA_PKT_HEADER_OP(SDMA_OP_NOP); |
| 702 | 702 | ib.length_dw = 8; |
| 703 | 703 | |
| 704 | − r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | |
| 704 | + r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f); | |
| 705 | 705 | if (r) |
| 706 | 706 | goto err1; |
| 707 | 707 | |
| @@ -910,7 +910,7 @@ static int sdma_v3_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) · 909 unmodified lines | ||
| 910 | 910 | ib.ptr[7] = SDMA_PKT_NOP_HEADER_OP(SDMA_OP_NOP); |
| 911 | 911 | ib.length_dw = 8; |
| 912 | 912 | |
| 913 | − r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | |
| 913 | + r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f); | |
| 914 | 914 | if (r) |
| 915 | 915 | goto err1; |
| 916 | 916 | |
| @@ -1533,6 +1533,22 @@ static int sdma_v3_0_set_powergating_state(void *handle, · 616 unmodified lines | ||
| 1533 | 1533 | return 0; |
| 1534 | 1534 | } |
| 1535 | 1535 | |
| 1536 | +static void sdma_v3_0_get_clockgating_state(void *handle, u32 *flags) | |
| 1537 | +{ | |
| 1538 | + struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1539 | + int data; | |
| 1540 | + | |
| 1541 | + /* AMD_CG_SUPPORT_SDMA_MGCG */ | |
| 1542 | + data = RREG32(mmSDMA0_CLK_CTRL + sdma_offsets[0]); | |
| 1543 | + if (!(data & SDMA0_CLK_CTRL__SOFT_OVERRIDE0_MASK)) | |
| 1544 | + *flags |= AMD_CG_SUPPORT_SDMA_MGCG; | |
| 1545 | + | |
| 1546 | + /* AMD_CG_SUPPORT_SDMA_LS */ | |
| 1547 | + data = RREG32(mmSDMA0_POWER_CNTL + sdma_offsets[0]); | |
| 1548 | + if (data & SDMA0_POWER_CNTL__MEM_POWER_OVERRIDE_MASK) | |
| 1549 | + *flags |= AMD_CG_SUPPORT_SDMA_LS; | |
| 1550 | +} | |
| 1551 | + | |
| 1536 | 1552 | static const struct amd_ip_funcs sdma_v3_0_ip_funcs = { |
| 1537 | 1553 | .name = "sdma_v3_0", |
| 1538 | 1554 | .early_init = sdma_v3_0_early_init, |
| @@ -1551,6 +1567,7 @@ static const struct amd_ip_funcs sdma_v3_0_ip_funcs = { · 12 unmodified lines | ||
| 1551 | 1567 | .soft_reset = sdma_v3_0_soft_reset, |
| 1552 | 1568 | .set_clockgating_state = sdma_v3_0_set_clockgating_state, |
| 1553 | 1569 | .set_powergating_state = sdma_v3_0_set_powergating_state, |
| 1570 | + .get_clockgating_state = sdma_v3_0_get_clockgating_state, | |
| 1554 | 1571 | }; |
| 1555 | 1572 | |
| 1556 | 1573 | static const struct amdgpu_ring_funcs sdma_v3_0_ring_funcs = { |
| @@ -32,7 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "amdgpu_vce.h" |
| 33 | 33 | #include "atom.h" |
| 34 | 34 | #include "amdgpu_powerplay.h" |
| 35 | −#include "si/sid.h" | |
| 35 | +#include "sid.h" | |
| 36 | 36 | #include "si_ih.h" |
| 37 | 37 | #include "gfx_v6_0.h" |
| 38 | 38 | #include "gmc_v6_0.h" |
| @@ -40,337 +40,343 @@ · 1 unmodified line | ||
| 40 | 40 | #include "dce_v6_0.h" |
| 41 | 41 | #include "si.h" |
| 42 | 42 | #include "dce_virtual.h" |
| 43 | +#include "gca/gfx_6_0_d.h" | |
| 44 | +#include "oss/oss_1_0_d.h" | |
| 45 | +#include "gmc/gmc_6_0_d.h" | |
| 46 | +#include "dce/dce_6_0_d.h" | |
| 47 | +#include "uvd/uvd_4_0_d.h" | |
| 43 | 48 | |
| 44 | 49 | static const u32 tahiti_golden_registers[] = |
| 45 | 50 | { |
| 46 | − 0x17bc, 0x00000030, 0x00000011, | |
| 47 | − 0x2684, 0x00010000, 0x00018208, | |
| 48 | − 0x260c, 0xffffffff, 0x00000000, | |
| 49 | − 0x260d, 0xf00fffff, 0x00000400, | |
| 50 | − 0x260e, 0x0002021c, 0x00020200, | |
| 51 | − 0x031e, 0x00000080, 0x00000000, | |
| 51 | + mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, | |
| 52 | + mmCB_HW_CONTROL, 0x00010000, 0x00018208, | |
| 53 | + mmDB_DEBUG, 0xffffffff, 0x00000000, | |
| 54 | + mmDB_DEBUG2, 0xf00fffff, 0x00000400, | |
| 55 | + mmDB_DEBUG3, 0x0002021c, 0x00020200, | |
| 56 | + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, | |
| 52 | 57 | 0x340c, 0x000000c0, 0x00800040, |
| 53 | 58 | 0x360c, 0x000000c0, 0x00800040, |
| 54 | − 0x16ec, 0x000000f0, 0x00000070, | |
| 55 | − 0x16f0, 0x00200000, 0x50100000, | |
| 56 | − 0x1c0c, 0x31000311, 0x00000011, | |
| 57 | − 0x09df, 0x00000003, 0x000007ff, | |
| 58 | − 0x0903, 0x000007ff, 0x00000000, | |
| 59 | − 0x2285, 0xf000001f, 0x00000007, | |
| 60 | − 0x22c9, 0xffffffff, 0x00ffffff, | |
| 61 | − 0x22c4, 0x0000ff0f, 0x00000000, | |
| 62 | − 0xa293, 0x07ffffff, 0x4e000000, | |
| 63 | − 0xa0d4, 0x3f3f3fff, 0x2a00126a, | |
| 59 | + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, | |
| 60 | + mmFBC_MISC, 0x00200000, 0x50100000, | |
| 61 | + mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, | |
| 62 | + mmMC_ARB_WTM_CNTL_RD, 0x00000003, 0x000007ff, | |
| 63 | + mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, | |
| 64 | + mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, | |
| 65 | + mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, | |
| 66 | + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, | |
| 67 | + mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, | |
| 68 | + mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x2a00126a, | |
| 64 | 69 | 0x000c, 0xffffffff, 0x0040, |
| 65 | 70 | 0x000d, 0x00000040, 0x00004040, |
| 66 | − 0x2440, 0x07ffffff, 0x03000000, | |
| 67 | − 0x23a2, 0x01ff1f3f, 0x00000000, | |
| 68 | − 0x23a1, 0x01ff1f3f, 0x00000000, | |
| 69 | − 0x2418, 0x0000007f, 0x00000020, | |
| 70 | − 0x2542, 0x00010000, 0x00010000, | |
| 71 | − 0x2b05, 0x00000200, 0x000002fb, | |
| 72 | − 0x2b04, 0xffffffff, 0x0000543b, | |
| 73 | − 0x2b03, 0xffffffff, 0xa9210876, | |
| 74 | − 0x2234, 0xffffffff, 0x000fff40, | |
| 75 | − 0x2235, 0x0000001f, 0x00000010, | |
| 76 | − 0x0504, 0x20000000, 0x20fffed8, | |
| 77 | − 0x0570, 0x000c0fc0, 0x000c0400, | |
| 78 | − 0x052c, 0x0fffffff, 0xffffffff, | |
| 79 | − 0x052d, 0x0fffffff, 0x0fffffff, | |
| 80 | − 0x052e, 0x0fffffff, 0x0fffffff, | |
| 81 | − 0x052f, 0x0fffffff, 0x0fffffff | |
| 71 | + mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, | |
| 72 | + mmSQ_DED_CNT, 0x01ff1f3f, 0x00000000, | |
| 73 | + mmSQ_SEC_CNT, 0x01ff1f3f, 0x00000000, | |
| 74 | + mmSX_DEBUG_1, 0x0000007f, 0x00000020, | |
| 75 | + mmTA_CNTL_AUX, 0x00010000, 0x00010000, | |
| 76 | + mmTCP_ADDR_CONFIG, 0x00000200, 0x000002fb, | |
| 77 | + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b, | |
| 78 | + mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876, | |
| 79 | + mmVGT_FIFO_DEPTHS, 0xffffffff, 0x000fff40, | |
| 80 | + mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, | |
| 81 | + mmVM_CONTEXT0_CNTL, 0x20000000, 0x20fffed8, | |
| 82 | + mmVM_L2_CG, 0x000c0fc0, 0x000c0400, | |
| 83 | + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, | |
| 84 | + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 85 | + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 86 | + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 82 | 87 | }; |
| 83 | 88 | |
| 84 | 89 | static const u32 tahiti_golden_registers2[] = |
| 85 | 90 | { |
| 86 | − 0x0319, 0x00000001, 0x00000001 | |
| 91 | + mmMCIF_MEM_CONTROL, 0x00000001, 0x00000001, | |
| 87 | 92 | }; |
| 88 | 93 | |
| 89 | 94 | static const u32 tahiti_golden_rlc_registers[] = |
| 90 | 95 | { |
| 91 | − 0x263e, 0xffffffff, 0x12011003, | |
| 92 | − 0x3109, 0xffffffff, 0x00601005, | |
| 96 | + mmGB_ADDR_CONFIG, 0xffffffff, 0x12011003, | |
| 97 | + mmRLC_LB_PARAMS, 0xffffffff, 0x00601005, | |
| 93 | 98 | 0x311f, 0xffffffff, 0x10104040, |
| 94 | 99 | 0x3122, 0xffffffff, 0x0100000a, |
| 95 | − 0x30c5, 0xffffffff, 0x00000800, | |
| 96 | − 0x30c3, 0xffffffff, 0x800000f4, | |
| 97 | − 0x3d2a, 0x00000008, 0x00000000 | |
| 100 | + mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, | |
| 101 | + mmRLC_LB_CNTL, 0xffffffff, 0x800000f4, | |
| 102 | + mmUVD_CGC_GATE, 0x00000008, 0x00000000, | |
| 98 | 103 | }; |
| 99 | 104 | |
| 100 | 105 | static const u32 pitcairn_golden_registers[] = |
| 101 | 106 | { |
| 102 | − 0x17bc, 0x00000030, 0x00000011, | |
| 103 | − 0x2684, 0x00010000, 0x00018208, | |
| 104 | − 0x260c, 0xffffffff, 0x00000000, | |
| 105 | − 0x260d, 0xf00fffff, 0x00000400, | |
| 106 | − 0x260e, 0x0002021c, 0x00020200, | |
| 107 | − 0x031e, 0x00000080, 0x00000000, | |
| 107 | + mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, | |
| 108 | + mmCB_HW_CONTROL, 0x00010000, 0x00018208, | |
| 109 | + mmDB_DEBUG, 0xffffffff, 0x00000000, | |
| 110 | + mmDB_DEBUG2, 0xf00fffff, 0x00000400, | |
| 111 | + mmDB_DEBUG3, 0x0002021c, 0x00020200, | |
| 112 | + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, | |
| 108 | 113 | 0x340c, 0x000300c0, 0x00800040, |
| 109 | 114 | 0x360c, 0x000300c0, 0x00800040, |
| 110 | − 0x16ec, 0x000000f0, 0x00000070, | |
| 111 | − 0x16f0, 0x00200000, 0x50100000, | |
| 112 | − 0x1c0c, 0x31000311, 0x00000011, | |
| 113 | − 0x0ab9, 0x00073ffe, 0x000022a2, | |
| 114 | − 0x0903, 0x000007ff, 0x00000000, | |
| 115 | − 0x2285, 0xf000001f, 0x00000007, | |
| 116 | − 0x22c9, 0xffffffff, 0x00ffffff, | |
| 117 | − 0x22c4, 0x0000ff0f, 0x00000000, | |
| 118 | − 0xa293, 0x07ffffff, 0x4e000000, | |
| 119 | − 0xa0d4, 0x3f3f3fff, 0x2a00126a, | |
| 115 | + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, | |
| 116 | + mmFBC_MISC, 0x00200000, 0x50100000, | |
| 117 | + mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, | |
| 118 | + mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, | |
| 119 | + mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, | |
| 120 | + mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, | |
| 121 | + mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, | |
| 122 | + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, | |
| 123 | + mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, | |
| 124 | + mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x2a00126a, | |
| 120 | 125 | 0x000c, 0xffffffff, 0x0040, |
| 121 | 126 | 0x000d, 0x00000040, 0x00004040, |
| 122 | − 0x2440, 0x07ffffff, 0x03000000, | |
| 123 | − 0x2418, 0x0000007f, 0x00000020, | |
| 124 | − 0x2542, 0x00010000, 0x00010000, | |
| 125 | − 0x2b05, 0x000003ff, 0x000000f7, | |
| 126 | − 0x2b04, 0xffffffff, 0x00000000, | |
| 127 | − 0x2b03, 0xffffffff, 0x32761054, | |
| 128 | − 0x2235, 0x0000001f, 0x00000010, | |
| 129 | − 0x0570, 0x000c0fc0, 0x000c0400, | |
| 130 | − 0x052c, 0x0fffffff, 0xffffffff, | |
| 131 | − 0x052d, 0x0fffffff, 0x0fffffff, | |
| 132 | − 0x052e, 0x0fffffff, 0x0fffffff, | |
| 133 | − 0x052f, 0x0fffffff, 0x0fffffff | |
| 127 | + mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, | |
| 128 | + mmSX_DEBUG_1, 0x0000007f, 0x00000020, | |
| 129 | + mmTA_CNTL_AUX, 0x00010000, 0x00010000, | |
| 130 | + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f7, | |
| 131 | + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, | |
| 132 | + mmTCP_CHAN_STEER_LO, 0xffffffff, 0x32761054, | |
| 133 | + mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, | |
| 134 | + mmVM_L2_CG, 0x000c0fc0, 0x000c0400, | |
| 135 | + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, | |
| 136 | + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 137 | + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 138 | + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 134 | 139 | }; |
| 135 | 140 | |
| 136 | 141 | static const u32 pitcairn_golden_rlc_registers[] = |
| 137 | 142 | { |
| 138 | − 0x263e, 0xffffffff, 0x12011003, | |
| 139 | − 0x3109, 0xffffffff, 0x00601004, | |
| 143 | + mmGB_ADDR_CONFIG, 0xffffffff, 0x12011003, | |
| 144 | + mmRLC_LB_PARAMS, 0xffffffff, 0x00601004, | |
| 140 | 145 | 0x311f, 0xffffffff, 0x10102020, |
| 141 | 146 | 0x3122, 0xffffffff, 0x01000020, |
| 142 | − 0x30c5, 0xffffffff, 0x00000800, | |
| 143 | − 0x30c3, 0xffffffff, 0x800000a4 | |
| 147 | + mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, | |
| 148 | + mmRLC_LB_CNTL, 0xffffffff, 0x800000a4, | |
| 144 | 149 | }; |
| 145 | 150 | |
| 146 | 151 | static const u32 verde_pg_init[] = |
| 147 | 152 | { |
| 148 | − 0x0d4f, 0xffffffff, 0x40000, | |
| 149 | − 0x0d4e, 0xffffffff, 0x200010ff, | |
| 150 | − 0x0d4f, 0xffffffff, 0x0, | |
| 151 | − 0x0d4f, 0xffffffff, 0x0, | |
| 152 | − 0x0d4f, 0xffffffff, 0x0, | |
| 153 | − 0x0d4f, 0xffffffff, 0x0, | |
| 154 | − 0x0d4f, 0xffffffff, 0x0, | |
| 155 | − 0x0d4f, 0xffffffff, 0x7007, | |
| 156 | − 0x0d4e, 0xffffffff, 0x300010ff, | |
| 157 | − 0x0d4f, 0xffffffff, 0x0, | |
| 158 | − 0x0d4f, 0xffffffff, 0x0, | |
| 159 | − 0x0d4f, 0xffffffff, 0x0, | |
| 160 | − 0x0d4f, 0xffffffff, 0x0, | |
| 161 | − 0x0d4f, 0xffffffff, 0x0, | |
| 162 | − 0x0d4f, 0xffffffff, 0x400000, | |
| 163 | − 0x0d4e, 0xffffffff, 0x100010ff, | |
| 164 | − 0x0d4f, 0xffffffff, 0x0, | |
| 165 | − 0x0d4f, 0xffffffff, 0x0, | |
| 166 | − 0x0d4f, 0xffffffff, 0x0, | |
| 167 | − 0x0d4f, 0xffffffff, 0x0, | |
| 168 | − 0x0d4f, 0xffffffff, 0x0, | |
| 169 | − 0x0d4f, 0xffffffff, 0x120200, | |
| 170 | − 0x0d4e, 0xffffffff, 0x500010ff, | |
| 171 | − 0x0d4f, 0xffffffff, 0x0, | |
| 172 | − 0x0d4f, 0xffffffff, 0x0, | |
| 173 | − 0x0d4f, 0xffffffff, 0x0, | |
| 174 | − 0x0d4f, 0xffffffff, 0x0, | |
| 175 | − 0x0d4f, 0xffffffff, 0x0, | |
| 176 | − 0x0d4f, 0xffffffff, 0x1e1e16, | |
| 177 | − 0x0d4e, 0xffffffff, 0x600010ff, | |
| 178 | − 0x0d4f, 0xffffffff, 0x0, | |
| 179 | − 0x0d4f, 0xffffffff, 0x0, | |
| 180 | − 0x0d4f, 0xffffffff, 0x0, | |
| 181 | − 0x0d4f, 0xffffffff, 0x0, | |
| 182 | − 0x0d4f, 0xffffffff, 0x0, | |
| 183 | − 0x0d4f, 0xffffffff, 0x171f1e, | |
| 184 | − 0x0d4e, 0xffffffff, 0x700010ff, | |
| 185 | − 0x0d4f, 0xffffffff, 0x0, | |
| 186 | − 0x0d4f, 0xffffffff, 0x0, | |
| 187 | − 0x0d4f, 0xffffffff, 0x0, | |
| 188 | − 0x0d4f, 0xffffffff, 0x0, | |
| 189 | − 0x0d4f, 0xffffffff, 0x0, | |
| 190 | − 0x0d4f, 0xffffffff, 0x0, | |
| 191 | − 0x0d4e, 0xffffffff, 0x9ff, | |
| 192 | − 0x0d40, 0xffffffff, 0x0, | |
| 193 | − 0x0d41, 0xffffffff, 0x10000800, | |
| 194 | − 0x0d41, 0xffffffff, 0xf, | |
| 195 | − 0x0d41, 0xffffffff, 0xf, | |
| 196 | − 0x0d40, 0xffffffff, 0x4, | |
| 197 | − 0x0d41, 0xffffffff, 0x1000051e, | |
| 198 | − 0x0d41, 0xffffffff, 0xffff, | |
| 199 | − 0x0d41, 0xffffffff, 0xffff, | |
| 200 | − 0x0d40, 0xffffffff, 0x8, | |
| 201 | − 0x0d41, 0xffffffff, 0x80500, | |
| 202 | − 0x0d40, 0xffffffff, 0x12, | |
| 203 | − 0x0d41, 0xffffffff, 0x9050c, | |
| 204 | − 0x0d40, 0xffffffff, 0x1d, | |
| 205 | − 0x0d41, 0xffffffff, 0xb052c, | |
| 206 | − 0x0d40, 0xffffffff, 0x2a, | |
| 207 | − 0x0d41, 0xffffffff, 0x1053e, | |
| 208 | − 0x0d40, 0xffffffff, 0x2d, | |
| 209 | − 0x0d41, 0xffffffff, 0x10546, | |
| 210 | − 0x0d40, 0xffffffff, 0x30, | |
| 211 | − 0x0d41, 0xffffffff, 0xa054e, | |
| 212 | − 0x0d40, 0xffffffff, 0x3c, | |
| 213 | − 0x0d41, 0xffffffff, 0x1055f, | |
| 214 | − 0x0d40, 0xffffffff, 0x3f, | |
| 215 | − 0x0d41, 0xffffffff, 0x10567, | |
| 216 | − 0x0d40, 0xffffffff, 0x42, | |
| 217 | − 0x0d41, 0xffffffff, 0x1056f, | |
| 218 | − 0x0d40, 0xffffffff, 0x45, | |
| 219 | − 0x0d41, 0xffffffff, 0x10572, | |
| 220 | − 0x0d40, 0xffffffff, 0x48, | |
| 221 | − 0x0d41, 0xffffffff, 0x20575, | |
| 222 | − 0x0d40, 0xffffffff, 0x4c, | |
| 223 | − 0x0d41, 0xffffffff, 0x190801, | |
| 224 | − 0x0d40, 0xffffffff, 0x67, | |
| 225 | − 0x0d41, 0xffffffff, 0x1082a, | |
| 226 | − 0x0d40, 0xffffffff, 0x6a, | |
| 227 | − 0x0d41, 0xffffffff, 0x1b082d, | |
| 228 | − 0x0d40, 0xffffffff, 0x87, | |
| 229 | − 0x0d41, 0xffffffff, 0x310851, | |
| 230 | − 0x0d40, 0xffffffff, 0xba, | |
| 231 | − 0x0d41, 0xffffffff, 0x891, | |
| 232 | − 0x0d40, 0xffffffff, 0xbc, | |
| 233 | − 0x0d41, 0xffffffff, 0x893, | |
| 234 | − 0x0d40, 0xffffffff, 0xbe, | |
| 235 | − 0x0d41, 0xffffffff, 0x20895, | |
| 236 | − 0x0d40, 0xffffffff, 0xc2, | |
| 237 | − 0x0d41, 0xffffffff, 0x20899, | |
| 238 | − 0x0d40, 0xffffffff, 0xc6, | |
| 239 | − 0x0d41, 0xffffffff, 0x2089d, | |
| 240 | − 0x0d40, 0xffffffff, 0xca, | |
| 241 | − 0x0d41, 0xffffffff, 0x8a1, | |
| 242 | − 0x0d40, 0xffffffff, 0xcc, | |
| 243 | − 0x0d41, 0xffffffff, 0x8a3, | |
| 244 | − 0x0d40, 0xffffffff, 0xce, | |
| 245 | − 0x0d41, 0xffffffff, 0x308a5, | |
| 246 | − 0x0d40, 0xffffffff, 0xd3, | |
| 247 | − 0x0d41, 0xffffffff, 0x6d08cd, | |
| 248 | − 0x0d40, 0xffffffff, 0x142, | |
| 249 | − 0x0d41, 0xffffffff, 0x2000095a, | |
| 250 | − 0x0d41, 0xffffffff, 0x1, | |
| 251 | − 0x0d40, 0xffffffff, 0x144, | |
| 252 | − 0x0d41, 0xffffffff, 0x301f095b, | |
| 253 | − 0x0d40, 0xffffffff, 0x165, | |
| 254 | − 0x0d41, 0xffffffff, 0xc094d, | |
| 255 | − 0x0d40, 0xffffffff, 0x173, | |
| 256 | − 0x0d41, 0xffffffff, 0xf096d, | |
| 257 | − 0x0d40, 0xffffffff, 0x184, | |
| 258 | − 0x0d41, 0xffffffff, 0x15097f, | |
| 259 | − 0x0d40, 0xffffffff, 0x19b, | |
| 260 | − 0x0d41, 0xffffffff, 0xc0998, | |
| 261 | − 0x0d40, 0xffffffff, 0x1a9, | |
| 262 | − 0x0d41, 0xffffffff, 0x409a7, | |
| 263 | − 0x0d40, 0xffffffff, 0x1af, | |
| 264 | − 0x0d41, 0xffffffff, 0xcdc, | |
| 265 | − 0x0d40, 0xffffffff, 0x1b1, | |
| 266 | − 0x0d41, 0xffffffff, 0x800, | |
| 267 | − 0x0d42, 0xffffffff, 0x6c9b2000, | |
| 268 | − 0x0d44, 0xfc00, 0x2000, | |
| 269 | − 0x0d51, 0xffffffff, 0xfc0, | |
| 270 | − 0x0a35, 0x00000100, 0x100 | |
| 153 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x40000, | |
| 154 | + mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x200010ff, | |
| 155 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 156 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 157 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 158 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 159 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 160 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x7007, | |
| 161 | + mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x300010ff, | |
| 162 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 163 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 164 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 165 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 166 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 167 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x400000, | |
| 168 | + mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x100010ff, | |
| 169 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 170 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 171 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 172 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 173 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 174 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x120200, | |
| 175 | + mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x500010ff, | |
| 176 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 177 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 178 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 179 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 180 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 181 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x1e1e16, | |
| 182 | + mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x600010ff, | |
| 183 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 184 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 185 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 186 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 187 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 188 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x171f1e, | |
| 189 | + mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x700010ff, | |
| 190 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 191 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 192 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 193 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 194 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 195 | + mmGMCON_PGFSM_WRITE, 0xffffffff, 0x0, | |
| 196 | + mmGMCON_PGFSM_CONFIG, 0xffffffff, 0x9ff, | |
| 197 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x0, | |
| 198 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10000800, | |
| 199 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf, | |
| 200 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf, | |
| 201 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x4, | |
| 202 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1000051e, | |
| 203 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xffff, | |
| 204 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xffff, | |
| 205 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x8, | |
| 206 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x80500, | |
| 207 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x12, | |
| 208 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x9050c, | |
| 209 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1d, | |
| 210 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xb052c, | |
| 211 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x2a, | |
| 212 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1053e, | |
| 213 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x2d, | |
| 214 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10546, | |
| 215 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x30, | |
| 216 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xa054e, | |
| 217 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x3c, | |
| 218 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1055f, | |
| 219 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x3f, | |
| 220 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10567, | |
| 221 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x42, | |
| 222 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1056f, | |
| 223 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x45, | |
| 224 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x10572, | |
| 225 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x48, | |
| 226 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20575, | |
| 227 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x4c, | |
| 228 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x190801, | |
| 229 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x67, | |
| 230 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1082a, | |
| 231 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x6a, | |
| 232 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1b082d, | |
| 233 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x87, | |
| 234 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x310851, | |
| 235 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xba, | |
| 236 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x891, | |
| 237 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xbc, | |
| 238 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x893, | |
| 239 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xbe, | |
| 240 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20895, | |
| 241 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xc2, | |
| 242 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x20899, | |
| 243 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xc6, | |
| 244 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x2089d, | |
| 245 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xca, | |
| 246 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x8a1, | |
| 247 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xcc, | |
| 248 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x8a3, | |
| 249 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xce, | |
| 250 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x308a5, | |
| 251 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0xd3, | |
| 252 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x6d08cd, | |
| 253 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x142, | |
| 254 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x2000095a, | |
| 255 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x1, | |
| 256 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x144, | |
| 257 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x301f095b, | |
| 258 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x165, | |
| 259 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xc094d, | |
| 260 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x173, | |
| 261 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xf096d, | |
| 262 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x184, | |
| 263 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x15097f, | |
| 264 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x19b, | |
| 265 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xc0998, | |
| 266 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1a9, | |
| 267 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x409a7, | |
| 268 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1af, | |
| 269 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0xcdc, | |
| 270 | + mmGMCON_RENG_RAM_INDEX, 0xffffffff, 0x1b1, | |
| 271 | + mmGMCON_RENG_RAM_DATA, 0xffffffff, 0x800, | |
| 272 | + mmGMCON_RENG_EXECUTE, 0xffffffff, 0x6c9b2000, | |
| 273 | + mmGMCON_MISC2, 0xfc00, 0x2000, | |
| 274 | + mmGMCON_MISC3, 0xffffffff, 0xfc0, | |
| 275 | + mmMC_PMG_AUTO_CFG, 0x00000100, 0x100, | |
| 271 | 276 | }; |
| 272 | 277 | |
| 273 | 278 | static const u32 verde_golden_rlc_registers[] = |
| 274 | 279 | { |
| 275 | − 0x263e, 0xffffffff, 0x02010002, | |
| 276 | − 0x3109, 0xffffffff, 0x033f1005, | |
| 280 | + mmGB_ADDR_CONFIG, 0xffffffff, 0x02010002, | |
| 281 | + mmRLC_LB_PARAMS, 0xffffffff, 0x033f1005, | |
| 277 | 282 | 0x311f, 0xffffffff, 0x10808020, |
| 278 | 283 | 0x3122, 0xffffffff, 0x00800008, |
| 279 | − 0x30c5, 0xffffffff, 0x00001000, | |
| 280 | − 0x30c3, 0xffffffff, 0x80010014 | |
| 284 | + mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00001000, | |
| 285 | + mmRLC_LB_CNTL, 0xffffffff, 0x80010014, | |
| 281 | 286 | }; |
| 282 | 287 | |
| 283 | 288 | static const u32 verde_golden_registers[] = |
| 284 | 289 | { |
| 285 | − 0x17bc, 0x00000030, 0x00000011, | |
| 286 | − 0x2684, 0x00010000, 0x00018208, | |
| 287 | − 0x260c, 0xffffffff, 0x00000000, | |
| 288 | − 0x260d, 0xf00fffff, 0x00000400, | |
| 289 | − 0x260e, 0x0002021c, 0x00020200, | |
| 290 | − 0x031e, 0x00000080, 0x00000000, | |
| 290 | + mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, | |
| 291 | + mmCB_HW_CONTROL, 0x00010000, 0x00018208, | |
| 292 | + mmDB_DEBUG, 0xffffffff, 0x00000000, | |
| 293 | + mmDB_DEBUG2, 0xf00fffff, 0x00000400, | |
| 294 | + mmDB_DEBUG3, 0x0002021c, 0x00020200, | |
| 295 | + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, | |
| 291 | 296 | 0x340c, 0x000300c0, 0x00800040, |
| 292 | 297 | 0x360c, 0x000300c0, 0x00800040, |
| 293 | − 0x16ec, 0x000000f0, 0x00000070, | |
| 294 | − 0x16f0, 0x00200000, 0x50100000, | |
| 295 | − 0x1c0c, 0x31000311, 0x00000011, | |
| 296 | − 0x0ab9, 0x00073ffe, 0x000022a2, | |
| 297 | − 0x0903, 0x000007ff, 0x00000000, | |
| 298 | − 0x2285, 0xf000001f, 0x00000007, | |
| 299 | − 0x22c9, 0xffffffff, 0x00ffffff, | |
| 300 | − 0x22c4, 0x0000ff0f, 0x00000000, | |
| 301 | − 0xa293, 0x07ffffff, 0x4e000000, | |
| 302 | − 0xa0d4, 0x3f3f3fff, 0x0000124a, | |
| 298 | + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, | |
| 299 | + mmFBC_MISC, 0x00200000, 0x50100000, | |
| 300 | + mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, | |
| 301 | + mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, | |
| 302 | + mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, | |
| 303 | + mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, | |
| 304 | + mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, | |
| 305 | + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, | |
| 306 | + mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, | |
| 307 | + mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x0000124a, | |
| 303 | 308 | 0x000c, 0xffffffff, 0x0040, |
| 304 | 309 | 0x000d, 0x00000040, 0x00004040, |
| 305 | − 0x2440, 0x07ffffff, 0x03000000, | |
| 306 | − 0x23a2, 0x01ff1f3f, 0x00000000, | |
| 307 | − 0x23a1, 0x01ff1f3f, 0x00000000, | |
| 308 | − 0x2418, 0x0000007f, 0x00000020, | |
| 309 | − 0x2542, 0x00010000, 0x00010000, | |
| 310 | − 0x2b05, 0x000003ff, 0x00000003, | |
| 311 | − 0x2b04, 0xffffffff, 0x00000000, | |
| 312 | − 0x2b03, 0xffffffff, 0x00001032, | |
| 313 | − 0x2235, 0x0000001f, 0x00000010, | |
| 314 | − 0x0570, 0x000c0fc0, 0x000c0400, | |
| 315 | − 0x052c, 0x0fffffff, 0xffffffff, | |
| 316 | − 0x052d, 0x0fffffff, 0x0fffffff, | |
| 317 | − 0x052e, 0x0fffffff, 0x0fffffff, | |
| 318 | − 0x052f, 0x0fffffff, 0x0fffffff | |
| 310 | + mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, | |
| 311 | + mmSQ_DED_CNT, 0x01ff1f3f, 0x00000000, | |
| 312 | + mmSQ_SEC_CNT, 0x01ff1f3f, 0x00000000, | |
| 313 | + mmSX_DEBUG_1, 0x0000007f, 0x00000020, | |
| 314 | + mmTA_CNTL_AUX, 0x00010000, 0x00010000, | |
| 315 | + mmTCP_ADDR_CONFIG, 0x000003ff, 0x00000003, | |
| 316 | + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, | |
| 317 | + mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00001032, | |
| 318 | + mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, | |
| 319 | + mmVM_L2_CG, 0x000c0fc0, 0x000c0400, | |
| 320 | + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, | |
| 321 | + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 322 | + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 323 | + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 319 | 324 | }; |
| 320 | 325 | |
| 321 | 326 | static const u32 oland_golden_registers[] = |
| 322 | 327 | { |
| 323 | − 0x17bc, 0x00000030, 0x00000011, | |
| 324 | − 0x2684, 0x00010000, 0x00018208, | |
| 325 | − 0x260c, 0xffffffff, 0x00000000, | |
| 326 | − 0x260d, 0xf00fffff, 0x00000400, | |
| 327 | − 0x260e, 0x0002021c, 0x00020200, | |
| 328 | − 0x031e, 0x00000080, 0x00000000, | |
| 328 | + mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011, | |
| 329 | + mmCB_HW_CONTROL, 0x00010000, 0x00018208, | |
| 330 | + mmDB_DEBUG, 0xffffffff, 0x00000000, | |
| 331 | + mmDB_DEBUG2, 0xf00fffff, 0x00000400, | |
| 332 | + mmDB_DEBUG3, 0x0002021c, 0x00020200, | |
| 333 | + mmDCI_CLK_CNTL, 0x00000080, 0x00000000, | |
| 329 | 334 | 0x340c, 0x000300c0, 0x00800040, |
| 330 | 335 | 0x360c, 0x000300c0, 0x00800040, |
| 331 | − 0x16ec, 0x000000f0, 0x00000070, | |
| 332 | − 0x16f0, 0x00200000, 0x50100000, | |
| 333 | − 0x1c0c, 0x31000311, 0x00000011, | |
| 334 | − 0x0ab9, 0x00073ffe, 0x000022a2, | |
| 335 | − 0x0903, 0x000007ff, 0x00000000, | |
| 336 | − 0x2285, 0xf000001f, 0x00000007, | |
| 337 | − 0x22c9, 0xffffffff, 0x00ffffff, | |
| 338 | − 0x22c4, 0x0000ff0f, 0x00000000, | |
| 339 | − 0xa293, 0x07ffffff, 0x4e000000, | |
| 340 | − 0xa0d4, 0x3f3f3fff, 0x00000082, | |
| 336 | + mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, | |
| 337 | + mmFBC_MISC, 0x00200000, 0x50100000, | |
| 338 | + mmDIG0_HDMI_CONTROL, 0x31000311, 0x00000011, | |
| 339 | + mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, | |
| 340 | + mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, | |
| 341 | + mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, | |
| 342 | + mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, | |
| 343 | + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, | |
| 344 | + mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, | |
| 345 | + mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x00000082, | |
| 341 | 346 | 0x000c, 0xffffffff, 0x0040, |
| 342 | 347 | 0x000d, 0x00000040, 0x00004040, |
| 343 | − 0x2440, 0x07ffffff, 0x03000000, | |
| 344 | − 0x2418, 0x0000007f, 0x00000020, | |
| 345 | − 0x2542, 0x00010000, 0x00010000, | |
| 346 | − 0x2b05, 0x000003ff, 0x000000f3, | |
| 347 | − 0x2b04, 0xffffffff, 0x00000000, | |
| 348 | − 0x2b03, 0xffffffff, 0x00003210, | |
| 349 | − 0x2235, 0x0000001f, 0x00000010, | |
| 350 | − 0x0570, 0x000c0fc0, 0x000c0400, | |
| 351 | − 0x052c, 0x0fffffff, 0xffffffff, | |
| 352 | − 0x052d, 0x0fffffff, 0x0fffffff, | |
| 353 | − 0x052e, 0x0fffffff, 0x0fffffff, | |
| 354 | − 0x052f, 0x0fffffff, 0x0fffffff | |
| 348 | + mmSPI_CONFIG_CNTL, 0x07ffffff, 0x03000000, | |
| 349 | + mmSX_DEBUG_1, 0x0000007f, 0x00000020, | |
| 350 | + mmTA_CNTL_AUX, 0x00010000, 0x00010000, | |
| 351 | + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f3, | |
| 352 | + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, | |
| 353 | + mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003210, | |
| 354 | + mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, | |
| 355 | + mmVM_L2_CG, 0x000c0fc0, 0x000c0400, | |
| 356 | + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, | |
| 357 | + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 358 | + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 359 | + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 360 | + | |
| 355 | 361 | }; |
| 356 | 362 | |
| 357 | 363 | static const u32 oland_golden_rlc_registers[] = |
| 358 | 364 | { |
| 359 | − 0x263e, 0xffffffff, 0x02010002, | |
| 360 | − 0x3109, 0xffffffff, 0x00601005, | |
| 365 | + mmGB_ADDR_CONFIG, 0xffffffff, 0x02010002, | |
| 366 | + mmRLC_LB_PARAMS, 0xffffffff, 0x00601005, | |
| 361 | 367 | 0x311f, 0xffffffff, 0x10104040, |
| 362 | 368 | 0x3122, 0xffffffff, 0x0100000a, |
| 363 | − 0x30c5, 0xffffffff, 0x00000800, | |
| 364 | − 0x30c3, 0xffffffff, 0x800000f4 | |
| 369 | + mmRLC_LB_CNTR_MAX, 0xffffffff, 0x00000800, | |
| 370 | + mmRLC_LB_CNTL, 0xffffffff, 0x800000f4, | |
| 365 | 371 | }; |
| 366 | 372 | |
| 367 | 373 | static const u32 hainan_golden_registers[] = |
| 368 | 374 | { |
| 369 | 375 | 0x17bc, 0x00000030, 0x00000011, |
| 370 | − 0x2684, 0x00010000, 0x00018208, | |
| 371 | − 0x260c, 0xffffffff, 0x00000000, | |
| 372 | − 0x260d, 0xf00fffff, 0x00000400, | |
| 373 | − 0x260e, 0x0002021c, 0x00020200, | |
| 376 | + mmCB_HW_CONTROL, 0x00010000, 0x00018208, | |
| 377 | + mmDB_DEBUG, 0xffffffff, 0x00000000, | |
| 378 | + mmDB_DEBUG2, 0xf00fffff, 0x00000400, | |
| 379 | + mmDB_DEBUG3, 0x0002021c, 0x00020200, | |
| 374 | 380 | 0x031e, 0x00000080, 0x00000000, |
| 375 | 381 | 0x3430, 0xff000fff, 0x00000100, |
| 376 | 382 | 0x340c, 0x000300c0, 0x00800040, |
| @@ -379,63 +385,63 @@ static const u32 hainan_golden_registers[] = · 2 unmodified lines | ||
| 379 | 385 | 0x16ec, 0x000000f0, 0x00000070, |
| 380 | 386 | 0x16f0, 0x00200000, 0x50100000, |
| 381 | 387 | 0x1c0c, 0x31000311, 0x00000011, |
| 382 | − 0x0ab9, 0x00073ffe, 0x000022a2, | |
| 383 | − 0x0903, 0x000007ff, 0x00000000, | |
| 384 | − 0x2285, 0xf000001f, 0x00000007, | |
| 385 | − 0x22c9, 0xffffffff, 0x00ffffff, | |
| 386 | − 0x22c4, 0x0000ff0f, 0x00000000, | |
| 387 | − 0xa293, 0x07ffffff, 0x4e000000, | |
| 388 | − 0xa0d4, 0x3f3f3fff, 0x00000000, | |
| 388 | + mmMC_SEQ_PMG_PG_HWCNTL, 0x00073ffe, 0x000022a2, | |
| 389 | + mmMC_XPB_P2P_BAR_CFG, 0x000007ff, 0x00000000, | |
| 390 | + mmPA_CL_ENHANCE, 0xf000001f, 0x00000007, | |
| 391 | + mmPA_SC_FORCE_EOV_MAX_CNTS, 0xffffffff, 0x00ffffff, | |
| 392 | + mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, | |
| 393 | + mmPA_SC_MODE_CNTL_1, 0x07ffffff, 0x4e000000, | |
| 394 | + mmPA_SC_RASTER_CONFIG, 0x3f3f3fff, 0x00000000, | |
| 389 | 395 | 0x000c, 0xffffffff, 0x0040, |
| 390 | 396 | 0x000d, 0x00000040, 0x00004040, |
| 391 | − 0x2440, 0x03e00000, 0x03600000, | |
| 392 | − 0x2418, 0x0000007f, 0x00000020, | |
| 393 | − 0x2542, 0x00010000, 0x00010000, | |
| 394 | − 0x2b05, 0x000003ff, 0x000000f1, | |
| 395 | − 0x2b04, 0xffffffff, 0x00000000, | |
| 396 | − 0x2b03, 0xffffffff, 0x00003210, | |
| 397 | − 0x2235, 0x0000001f, 0x00000010, | |
| 398 | − 0x0570, 0x000c0fc0, 0x000c0400, | |
| 399 | − 0x052c, 0x0fffffff, 0xffffffff, | |
| 400 | − 0x052d, 0x0fffffff, 0x0fffffff, | |
| 401 | − 0x052e, 0x0fffffff, 0x0fffffff, | |
| 402 | − 0x052f, 0x0fffffff, 0x0fffffff | |
| 397 | + mmSPI_CONFIG_CNTL, 0x03e00000, 0x03600000, | |
| 398 | + mmSX_DEBUG_1, 0x0000007f, 0x00000020, | |
| 399 | + mmTA_CNTL_AUX, 0x00010000, 0x00010000, | |
| 400 | + mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f1, | |
| 401 | + mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000, | |
| 402 | + mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003210, | |
| 403 | + mmVGT_GS_VERTEX_REUSE, 0x0000001f, 0x00000010, | |
| 404 | + mmVM_L2_CG, 0x000c0fc0, 0x000c0400, | |
| 405 | + mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0xffffffff, | |
| 406 | + mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 407 | + mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 408 | + mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff, | |
| 403 | 409 | }; |
| 404 | 410 | |
| 405 | 411 | static const u32 hainan_golden_registers2[] = |
| 406 | 412 | { |
| 407 | − 0x263e, 0xffffffff, 0x2011003 | |
| 413 | + mmGB_ADDR_CONFIG, 0xffffffff, 0x2011003, | |
| 408 | 414 | }; |
| 409 | 415 | |
| 410 | 416 | static const u32 tahiti_mgcg_cgcg_init[] = |
| 411 | 417 | { |
| 412 | − 0x3100, 0xffffffff, 0xfffffffc, | |
| 413 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 414 | − 0x2698, 0xffffffff, 0x00000100, | |
| 415 | − 0x24a9, 0xffffffff, 0x00000100, | |
| 416 | − 0x3059, 0xffffffff, 0x00000100, | |
| 417 | − 0x25dd, 0xffffffff, 0x00000100, | |
| 418 | − 0x2261, 0xffffffff, 0x06000100, | |
| 419 | − 0x2286, 0xffffffff, 0x00000100, | |
| 420 | − 0x24a8, 0xffffffff, 0x00000100, | |
| 421 | − 0x30e0, 0xffffffff, 0x00000100, | |
| 422 | − 0x22ca, 0xffffffff, 0x00000100, | |
| 423 | − 0x2451, 0xffffffff, 0x00000100, | |
| 424 | − 0x2362, 0xffffffff, 0x00000100, | |
| 425 | − 0x2363, 0xffffffff, 0x00000100, | |
| 426 | − 0x240c, 0xffffffff, 0x00000100, | |
| 427 | − 0x240d, 0xffffffff, 0x00000100, | |
| 428 | − 0x240e, 0xffffffff, 0x00000100, | |
| 429 | − 0x240f, 0xffffffff, 0x00000100, | |
| 430 | − 0x2b60, 0xffffffff, 0x00000100, | |
| 431 | − 0x2b15, 0xffffffff, 0x00000100, | |
| 432 | − 0x225f, 0xffffffff, 0x06000100, | |
| 433 | − 0x261a, 0xffffffff, 0x00000100, | |
| 434 | − 0x2544, 0xffffffff, 0x00000100, | |
| 435 | − 0x2bc1, 0xffffffff, 0x00000100, | |
| 436 | − 0x2b81, 0xffffffff, 0x00000100, | |
| 437 | − 0x2527, 0xffffffff, 0x00000100, | |
| 438 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 418 | + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, | |
| 419 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 420 | + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 421 | + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 422 | + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 423 | + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 424 | + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 425 | + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 426 | + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 427 | + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 428 | + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 429 | + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 430 | + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 431 | + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 432 | + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, | |
| 433 | + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, | |
| 434 | + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, | |
| 435 | + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, | |
| 436 | + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 437 | + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 438 | + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 439 | + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, | |
| 440 | + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 441 | + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 442 | + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 443 | + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 444 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 439 | 445 | 0x2458, 0xffffffff, 0x00010000, |
| 440 | 446 | 0x2459, 0xffffffff, 0x00030002, |
| 441 | 447 | 0x245a, 0xffffffff, 0x00040007, |
| @@ -516,55 +522,55 @@ static const u32 tahiti_mgcg_cgcg_init[] = · 74 unmodified lines | ||
| 516 | 522 | 0x24a5, 0xffffffff, 0x00000015, |
| 517 | 523 | 0x24a6, 0xffffffff, 0x00140013, |
| 518 | 524 | 0x24a7, 0xffffffff, 0x00170016, |
| 519 | − 0x2454, 0xffffffff, 0x96940200, | |
| 520 | − 0x21c2, 0xffffffff, 0x00900100, | |
| 521 | − 0x311e, 0xffffffff, 0x00000080, | |
| 522 | − 0x3101, 0xffffffff, 0x0020003f, | |
| 525 | + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, | |
| 526 | + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, | |
| 527 | + mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, | |
| 528 | + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, | |
| 523 | 529 | 0x000c, 0xffffffff, 0x0000001c, |
| 524 | 530 | 0x000d, 0x000f0000, 0x000f0000, |
| 525 | 531 | 0x0583, 0xffffffff, 0x00000100, |
| 526 | − 0x0409, 0xffffffff, 0x00000100, | |
| 527 | − 0x040b, 0x00000101, 0x00000000, | |
| 528 | − 0x082a, 0xffffffff, 0x00000104, | |
| 529 | − 0x0993, 0x000c0000, 0x000c0000, | |
| 530 | − 0x0992, 0x000c0000, 0x000c0000, | |
| 531 | − 0x1579, 0xff000fff, 0x00000100, | |
| 532 | + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, | |
| 533 | + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, | |
| 534 | + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, | |
| 535 | + mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, | |
| 536 | + mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, | |
| 537 | + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, | |
| 532 | 538 | 0x157a, 0x00000001, 0x00000001, |
| 533 | − 0x0bd4, 0x00000001, 0x00000001, | |
| 534 | − 0x0c33, 0xc0000fff, 0x00000104, | |
| 535 | − 0x3079, 0x00000001, 0x00000001, | |
| 539 | + mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, | |
| 540 | + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, | |
| 541 | + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, | |
| 536 | 542 | 0x3430, 0xfffffff0, 0x00000100, |
| 537 | − 0x3630, 0xfffffff0, 0x00000100 | |
| 543 | + 0x3630, 0xfffffff0, 0x00000100, | |
| 538 | 544 | }; |
| 539 | 545 | static const u32 pitcairn_mgcg_cgcg_init[] = |
| 540 | 546 | { |
| 541 | − 0x3100, 0xffffffff, 0xfffffffc, | |
| 542 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 543 | − 0x2698, 0xffffffff, 0x00000100, | |
| 544 | − 0x24a9, 0xffffffff, 0x00000100, | |
| 545 | − 0x3059, 0xffffffff, 0x00000100, | |
| 546 | − 0x25dd, 0xffffffff, 0x00000100, | |
| 547 | − 0x2261, 0xffffffff, 0x06000100, | |
| 548 | − 0x2286, 0xffffffff, 0x00000100, | |
| 549 | − 0x24a8, 0xffffffff, 0x00000100, | |
| 550 | − 0x30e0, 0xffffffff, 0x00000100, | |
| 551 | − 0x22ca, 0xffffffff, 0x00000100, | |
| 552 | − 0x2451, 0xffffffff, 0x00000100, | |
| 553 | − 0x2362, 0xffffffff, 0x00000100, | |
| 554 | − 0x2363, 0xffffffff, 0x00000100, | |
| 555 | − 0x240c, 0xffffffff, 0x00000100, | |
| 556 | − 0x240d, 0xffffffff, 0x00000100, | |
| 557 | − 0x240e, 0xffffffff, 0x00000100, | |
| 558 | − 0x240f, 0xffffffff, 0x00000100, | |
| 559 | − 0x2b60, 0xffffffff, 0x00000100, | |
| 560 | − 0x2b15, 0xffffffff, 0x00000100, | |
| 561 | − 0x225f, 0xffffffff, 0x06000100, | |
| 562 | − 0x261a, 0xffffffff, 0x00000100, | |
| 563 | − 0x2544, 0xffffffff, 0x00000100, | |
| 564 | − 0x2bc1, 0xffffffff, 0x00000100, | |
| 565 | − 0x2b81, 0xffffffff, 0x00000100, | |
| 566 | − 0x2527, 0xffffffff, 0x00000100, | |
| 567 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 547 | + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, | |
| 548 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 549 | + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 550 | + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 551 | + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 552 | + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 553 | + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 554 | + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 555 | + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 556 | + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 557 | + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 558 | + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 559 | + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 560 | + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 561 | + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, | |
| 562 | + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, | |
| 563 | + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, | |
| 564 | + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, | |
| 565 | + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 566 | + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 567 | + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 568 | + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, | |
| 569 | + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 570 | + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 571 | + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 572 | + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 573 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 568 | 574 | 0x2458, 0xffffffff, 0x00010000, |
| 569 | 575 | 0x2459, 0xffffffff, 0x00030002, |
| 570 | 576 | 0x245a, 0xffffffff, 0x00040007, |
| @@ -615,53 +621,54 @@ static const u32 pitcairn_mgcg_cgcg_init[] = · 44 unmodified lines | ||
| 615 | 621 | 0x2496, 0xffffffff, 0x00100013, |
| 616 | 622 | 0x2497, 0xffffffff, 0x00120011, |
| 617 | 623 | 0x2498, 0xffffffff, 0x00150014, |
| 618 | − 0x2454, 0xffffffff, 0x96940200, | |
| 619 | − 0x21c2, 0xffffffff, 0x00900100, | |
| 620 | − 0x311e, 0xffffffff, 0x00000080, | |
| 621 | − 0x3101, 0xffffffff, 0x0020003f, | |
| 624 | + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, | |
| 625 | + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, | |
| 626 | + mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, | |
| 627 | + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, | |
| 622 | 628 | 0x000c, 0xffffffff, 0x0000001c, |
| 623 | 629 | 0x000d, 0x000f0000, 0x000f0000, |
| 624 | 630 | 0x0583, 0xffffffff, 0x00000100, |
| 625 | − 0x0409, 0xffffffff, 0x00000100, | |
| 626 | − 0x040b, 0x00000101, 0x00000000, | |
| 627 | − 0x082a, 0xffffffff, 0x00000104, | |
| 628 | − 0x1579, 0xff000fff, 0x00000100, | |
| 631 | + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, | |
| 632 | + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, | |
| 633 | + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, | |
| 634 | + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, | |
| 629 | 635 | 0x157a, 0x00000001, 0x00000001, |
| 630 | − 0x0bd4, 0x00000001, 0x00000001, | |
| 631 | − 0x0c33, 0xc0000fff, 0x00000104, | |
| 632 | − 0x3079, 0x00000001, 0x00000001, | |
| 636 | + mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, | |
| 637 | + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, | |
| 638 | + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, | |
| 633 | 639 | 0x3430, 0xfffffff0, 0x00000100, |
| 634 | − 0x3630, 0xfffffff0, 0x00000100 | |
| 640 | + 0x3630, 0xfffffff0, 0x00000100, | |
| 635 | 641 | }; |
| 642 | + | |
| 636 | 643 | static const u32 verde_mgcg_cgcg_init[] = |
| 637 | 644 | { |
| 638 | − 0x3100, 0xffffffff, 0xfffffffc, | |
| 639 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 640 | − 0x2698, 0xffffffff, 0x00000100, | |
| 641 | − 0x24a9, 0xffffffff, 0x00000100, | |
| 642 | − 0x3059, 0xffffffff, 0x00000100, | |
| 643 | − 0x25dd, 0xffffffff, 0x00000100, | |
| 644 | − 0x2261, 0xffffffff, 0x06000100, | |
| 645 | − 0x2286, 0xffffffff, 0x00000100, | |
| 646 | − 0x24a8, 0xffffffff, 0x00000100, | |
| 647 | − 0x30e0, 0xffffffff, 0x00000100, | |
| 648 | − 0x22ca, 0xffffffff, 0x00000100, | |
| 649 | − 0x2451, 0xffffffff, 0x00000100, | |
| 650 | − 0x2362, 0xffffffff, 0x00000100, | |
| 651 | − 0x2363, 0xffffffff, 0x00000100, | |
| 652 | − 0x240c, 0xffffffff, 0x00000100, | |
| 653 | − 0x240d, 0xffffffff, 0x00000100, | |
| 654 | − 0x240e, 0xffffffff, 0x00000100, | |
| 655 | − 0x240f, 0xffffffff, 0x00000100, | |
| 656 | − 0x2b60, 0xffffffff, 0x00000100, | |
| 657 | − 0x2b15, 0xffffffff, 0x00000100, | |
| 658 | − 0x225f, 0xffffffff, 0x06000100, | |
| 659 | − 0x261a, 0xffffffff, 0x00000100, | |
| 660 | − 0x2544, 0xffffffff, 0x00000100, | |
| 661 | − 0x2bc1, 0xffffffff, 0x00000100, | |
| 662 | − 0x2b81, 0xffffffff, 0x00000100, | |
| 663 | − 0x2527, 0xffffffff, 0x00000100, | |
| 664 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 645 | + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, | |
| 646 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 647 | + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 648 | + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 649 | + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 650 | + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 651 | + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 652 | + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 653 | + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 654 | + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 655 | + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 656 | + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 657 | + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 658 | + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 659 | + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, | |
| 660 | + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, | |
| 661 | + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, | |
| 662 | + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, | |
| 663 | + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 664 | + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 665 | + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 666 | + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, | |
| 667 | + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 668 | + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 669 | + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 670 | + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 671 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 665 | 672 | 0x2458, 0xffffffff, 0x00010000, |
| 666 | 673 | 0x2459, 0xffffffff, 0x00030002, |
| 667 | 674 | 0x245a, 0xffffffff, 0x00040007, |
| @@ -712,55 +719,56 @@ static const u32 verde_mgcg_cgcg_init[] = · 44 unmodified lines | ||
| 712 | 719 | 0x2496, 0xffffffff, 0x00100013, |
| 713 | 720 | 0x2497, 0xffffffff, 0x00120011, |
| 714 | 721 | 0x2498, 0xffffffff, 0x00150014, |
| 715 | − 0x2454, 0xffffffff, 0x96940200, | |
| 716 | − 0x21c2, 0xffffffff, 0x00900100, | |
| 717 | − 0x311e, 0xffffffff, 0x00000080, | |
| 718 | − 0x3101, 0xffffffff, 0x0020003f, | |
| 722 | + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, | |
| 723 | + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, | |
| 724 | + mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, | |
| 725 | + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, | |
| 719 | 726 | 0x000c, 0xffffffff, 0x0000001c, |
| 720 | 727 | 0x000d, 0x000f0000, 0x000f0000, |
| 721 | 728 | 0x0583, 0xffffffff, 0x00000100, |
| 722 | − 0x0409, 0xffffffff, 0x00000100, | |
| 723 | − 0x040b, 0x00000101, 0x00000000, | |
| 724 | − 0x082a, 0xffffffff, 0x00000104, | |
| 725 | − 0x0993, 0x000c0000, 0x000c0000, | |
| 726 | − 0x0992, 0x000c0000, 0x000c0000, | |
| 727 | − 0x1579, 0xff000fff, 0x00000100, | |
| 729 | + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, | |
| 730 | + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, | |
| 731 | + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, | |
| 732 | + mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, | |
| 733 | + mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, | |
| 734 | + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, | |
| 728 | 735 | 0x157a, 0x00000001, 0x00000001, |
| 729 | − 0x0bd4, 0x00000001, 0x00000001, | |
| 730 | − 0x0c33, 0xc0000fff, 0x00000104, | |
| 731 | − 0x3079, 0x00000001, 0x00000001, | |
| 736 | + mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, | |
| 737 | + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, | |
| 738 | + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, | |
| 732 | 739 | 0x3430, 0xfffffff0, 0x00000100, |
| 733 | − 0x3630, 0xfffffff0, 0x00000100 | |
| 740 | + 0x3630, 0xfffffff0, 0x00000100, | |
| 734 | 741 | }; |
| 742 | + | |
| 735 | 743 | static const u32 oland_mgcg_cgcg_init[] = |
| 736 | 744 | { |
| 737 | − 0x3100, 0xffffffff, 0xfffffffc, | |
| 738 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 739 | − 0x2698, 0xffffffff, 0x00000100, | |
| 740 | − 0x24a9, 0xffffffff, 0x00000100, | |
| 741 | − 0x3059, 0xffffffff, 0x00000100, | |
| 742 | − 0x25dd, 0xffffffff, 0x00000100, | |
| 743 | − 0x2261, 0xffffffff, 0x06000100, | |
| 744 | − 0x2286, 0xffffffff, 0x00000100, | |
| 745 | − 0x24a8, 0xffffffff, 0x00000100, | |
| 746 | − 0x30e0, 0xffffffff, 0x00000100, | |
| 747 | − 0x22ca, 0xffffffff, 0x00000100, | |
| 748 | − 0x2451, 0xffffffff, 0x00000100, | |
| 749 | − 0x2362, 0xffffffff, 0x00000100, | |
| 750 | − 0x2363, 0xffffffff, 0x00000100, | |
| 751 | − 0x240c, 0xffffffff, 0x00000100, | |
| 752 | − 0x240d, 0xffffffff, 0x00000100, | |
| 753 | − 0x240e, 0xffffffff, 0x00000100, | |
| 754 | − 0x240f, 0xffffffff, 0x00000100, | |
| 755 | − 0x2b60, 0xffffffff, 0x00000100, | |
| 756 | − 0x2b15, 0xffffffff, 0x00000100, | |
| 757 | − 0x225f, 0xffffffff, 0x06000100, | |
| 758 | − 0x261a, 0xffffffff, 0x00000100, | |
| 759 | − 0x2544, 0xffffffff, 0x00000100, | |
| 760 | − 0x2bc1, 0xffffffff, 0x00000100, | |
| 761 | − 0x2b81, 0xffffffff, 0x00000100, | |
| 762 | − 0x2527, 0xffffffff, 0x00000100, | |
| 763 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 745 | + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, | |
| 746 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 747 | + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 748 | + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 749 | + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 750 | + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 751 | + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 752 | + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 753 | + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 754 | + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 755 | + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 756 | + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 757 | + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 758 | + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 759 | + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, | |
| 760 | + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, | |
| 761 | + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, | |
| 762 | + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, | |
| 763 | + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 764 | + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 765 | + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 766 | + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, | |
| 767 | + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 768 | + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 769 | + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 770 | + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 771 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 764 | 772 | 0x2458, 0xffffffff, 0x00010000, |
| 765 | 773 | 0x2459, 0xffffffff, 0x00030002, |
| 766 | 774 | 0x245a, 0xffffffff, 0x00040007, |
| @@ -791,55 +799,56 @@ static const u32 oland_mgcg_cgcg_init[] = · 24 unmodified lines | ||
| 791 | 799 | 0x2473, 0xffffffff, 0x0000000b, |
| 792 | 800 | 0x2474, 0xffffffff, 0x000a0009, |
| 793 | 801 | 0x2475, 0xffffffff, 0x000d000c, |
| 794 | − 0x2454, 0xffffffff, 0x96940200, | |
| 795 | − 0x21c2, 0xffffffff, 0x00900100, | |
| 796 | − 0x311e, 0xffffffff, 0x00000080, | |
| 797 | − 0x3101, 0xffffffff, 0x0020003f, | |
| 802 | + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, | |
| 803 | + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, | |
| 804 | + mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, | |
| 805 | + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, | |
| 798 | 806 | 0x000c, 0xffffffff, 0x0000001c, |
| 799 | 807 | 0x000d, 0x000f0000, 0x000f0000, |
| 800 | 808 | 0x0583, 0xffffffff, 0x00000100, |
| 801 | − 0x0409, 0xffffffff, 0x00000100, | |
| 802 | − 0x040b, 0x00000101, 0x00000000, | |
| 803 | − 0x082a, 0xffffffff, 0x00000104, | |
| 804 | − 0x0993, 0x000c0000, 0x000c0000, | |
| 805 | − 0x0992, 0x000c0000, 0x000c0000, | |
| 806 | − 0x1579, 0xff000fff, 0x00000100, | |
| 809 | + mmXDMA_CLOCK_GATING_CNTL, 0xffffffff, 0x00000100, | |
| 810 | + mmXDMA_MEM_POWER_CNTL, 0x00000101, 0x00000000, | |
| 811 | + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, | |
| 812 | + mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, | |
| 813 | + mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, | |
| 814 | + mmCGTT_DRM_CLK_CTRL0, 0xff000fff, 0x00000100, | |
| 807 | 815 | 0x157a, 0x00000001, 0x00000001, |
| 808 | − 0x0bd4, 0x00000001, 0x00000001, | |
| 809 | − 0x0c33, 0xc0000fff, 0x00000104, | |
| 810 | − 0x3079, 0x00000001, 0x00000001, | |
| 816 | + mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, | |
| 817 | + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, | |
| 818 | + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, | |
| 811 | 819 | 0x3430, 0xfffffff0, 0x00000100, |
| 812 | − 0x3630, 0xfffffff0, 0x00000100 | |
| 820 | + 0x3630, 0xfffffff0, 0x00000100, | |
| 813 | 821 | }; |
| 822 | + | |
| 814 | 823 | static const u32 hainan_mgcg_cgcg_init[] = |
| 815 | 824 | { |
| 816 | − 0x3100, 0xffffffff, 0xfffffffc, | |
| 817 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 818 | − 0x2698, 0xffffffff, 0x00000100, | |
| 819 | − 0x24a9, 0xffffffff, 0x00000100, | |
| 820 | − 0x3059, 0xffffffff, 0x00000100, | |
| 821 | − 0x25dd, 0xffffffff, 0x00000100, | |
| 822 | − 0x2261, 0xffffffff, 0x06000100, | |
| 823 | − 0x2286, 0xffffffff, 0x00000100, | |
| 824 | − 0x24a8, 0xffffffff, 0x00000100, | |
| 825 | − 0x30e0, 0xffffffff, 0x00000100, | |
| 826 | − 0x22ca, 0xffffffff, 0x00000100, | |
| 827 | − 0x2451, 0xffffffff, 0x00000100, | |
| 828 | − 0x2362, 0xffffffff, 0x00000100, | |
| 829 | − 0x2363, 0xffffffff, 0x00000100, | |
| 830 | − 0x240c, 0xffffffff, 0x00000100, | |
| 831 | − 0x240d, 0xffffffff, 0x00000100, | |
| 832 | − 0x240e, 0xffffffff, 0x00000100, | |
| 833 | − 0x240f, 0xffffffff, 0x00000100, | |
| 834 | − 0x2b60, 0xffffffff, 0x00000100, | |
| 835 | − 0x2b15, 0xffffffff, 0x00000100, | |
| 836 | − 0x225f, 0xffffffff, 0x06000100, | |
| 837 | − 0x261a, 0xffffffff, 0x00000100, | |
| 838 | − 0x2544, 0xffffffff, 0x00000100, | |
| 839 | − 0x2bc1, 0xffffffff, 0x00000100, | |
| 840 | − 0x2b81, 0xffffffff, 0x00000100, | |
| 841 | − 0x2527, 0xffffffff, 0x00000100, | |
| 842 | − 0x200b, 0xffffffff, 0xe0000000, | |
| 825 | + mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xfffffffc, | |
| 826 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 827 | + mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 828 | + mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 829 | + mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 830 | + mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 831 | + mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 832 | + mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 833 | + mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 834 | + mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 835 | + mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 836 | + mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 837 | + mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 838 | + mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 839 | + mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100, | |
| 840 | + mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100, | |
| 841 | + mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100, | |
| 842 | + mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100, | |
| 843 | + mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 844 | + mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100, | |
| 845 | + mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100, | |
| 846 | + mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100, | |
| 847 | + mmTA_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 848 | + mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 849 | + mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100, | |
| 850 | + mmTD_CGTT_CTRL, 0xffffffff, 0x00000100, | |
| 851 | + mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, | |
| 843 | 852 | 0x2458, 0xffffffff, 0x00010000, |
| 844 | 853 | 0x2459, 0xffffffff, 0x00030002, |
| 845 | 854 | 0x245a, 0xffffffff, 0x00040007, |
| @@ -870,22 +879,22 @@ static const u32 hainan_mgcg_cgcg_init[] = · 24 unmodified lines | ||
| 870 | 879 | 0x2473, 0xffffffff, 0x0000000b, |
| 871 | 880 | 0x2474, 0xffffffff, 0x000a0009, |
| 872 | 881 | 0x2475, 0xffffffff, 0x000d000c, |
| 873 | − 0x2454, 0xffffffff, 0x96940200, | |
| 874 | − 0x21c2, 0xffffffff, 0x00900100, | |
| 875 | − 0x311e, 0xffffffff, 0x00000080, | |
| 876 | − 0x3101, 0xffffffff, 0x0020003f, | |
| 882 | + mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200, | |
| 883 | + mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100, | |
| 884 | + mmRLC_GCPM_GENERAL_3, 0xffffffff, 0x00000080, | |
| 885 | + mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f, | |
| 877 | 886 | 0x000c, 0xffffffff, 0x0000001c, |
| 878 | 887 | 0x000d, 0x000f0000, 0x000f0000, |
| 879 | 888 | 0x0583, 0xffffffff, 0x00000100, |
| 880 | 889 | 0x0409, 0xffffffff, 0x00000100, |
| 881 | − 0x082a, 0xffffffff, 0x00000104, | |
| 882 | − 0x0993, 0x000c0000, 0x000c0000, | |
| 883 | − 0x0992, 0x000c0000, 0x000c0000, | |
| 884 | − 0x0bd4, 0x00000001, 0x00000001, | |
| 885 | − 0x0c33, 0xc0000fff, 0x00000104, | |
| 886 | − 0x3079, 0x00000001, 0x00000001, | |
| 890 | + mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104, | |
| 891 | + mmMC_CITF_MISC_WR_CG, 0x000c0000, 0x000c0000, | |
| 892 | + mmMC_CITF_MISC_RD_CG, 0x000c0000, 0x000c0000, | |
| 893 | + mmHDP_MEM_POWER_LS, 0x00000001, 0x00000001, | |
| 894 | + mmHDP_XDP_CGTT_BLK_CTRL, 0xc0000fff, 0x00000104, | |
| 895 | + mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001, | |
| 887 | 896 | 0x3430, 0xfffffff0, 0x00000100, |
| 888 | − 0x3630, 0xfffffff0, 0x00000100 | |
| 897 | + 0x3630, 0xfffffff0, 0x00000100, | |
| 889 | 898 | }; |
| 890 | 899 | |
| 891 | 900 | static u32 si_pcie_rreg(struct amdgpu_device *adev, u32 reg) |
| @@ -1129,13 +1138,12 @@ static int si_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) · 237 unmodified lines | ||
| 1129 | 1138 | static void si_detect_hw_virtualization(struct amdgpu_device *adev) |
| 1130 | 1139 | { |
| 1131 | 1140 | if (is_virtual_machine()) /* passthrough mode */ |
| 1132 | − adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE; | |
| 1141 | + adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE; | |
| 1133 | 1142 | } |
| 1134 | 1143 | |
| 1135 | 1144 | static const struct amdgpu_asic_funcs si_asic_funcs = |
| 1136 | 1145 | { |
| 1137 | 1146 | .read_disabled_bios = &si_read_disabled_bios, |
| 1138 | − .detect_hw_virtualization = si_detect_hw_virtualization, | |
| 1139 | 1147 | .read_register = &si_read_register, |
| 1140 | 1148 | .reset = &si_asic_reset, |
| 1141 | 1149 | .set_vga_state = &si_vga_set_state, |
| @@ -1852,6 +1860,8 @@ static const struct amdgpu_ip_block_version si_common_ip_block = · 710 unmodified lines | ||
| 1852 | 1860 | |
| 1853 | 1861 | int si_set_ip_blocks(struct amdgpu_device *adev) |
| 1854 | 1862 | { |
| 1863 | + si_detect_hw_virtualization(adev); | |
| 1864 | + | |
| 1855 | 1865 | switch (adev->asic_type) { |
| 1856 | 1866 | case CHIP_VERDE: |
| 1857 | 1867 | case CHIP_TAHITI: |
| @@ -24,7 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include <drm/drmP.h> |
| 25 | 25 | #include "amdgpu.h" |
| 26 | 26 | #include "amdgpu_trace.h" |
| 27 | −#include "si/sid.h" | |
| 27 | +#include "sid.h" | |
| 28 | 28 | |
| 29 | 29 | const u32 sdma_offsets[SDMA_MAX_INSTANCE] = |
| 30 | 30 | { |
| @@ -301,7 +301,7 @@ static int si_dma_ring_test_ib(struct amdgpu_ring *ring, long timeout) · 270 unmodified lines | ||
| 301 | 301 | ib.ptr[2] = upper_32_bits(gpu_addr) & 0xff; |
| 302 | 302 | ib.ptr[3] = 0xDEADBEEF; |
| 303 | 303 | ib.length_dw = 4; |
| 304 | − r = amdgpu_ib_schedule(ring, 1, &ib, NULL, NULL, &f); | |
| 304 | + r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f); | |
| 305 | 305 | if (r) |
| 306 | 306 | goto err1; |
| 307 | 307 | |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include "amdgpu_pm.h" |
| 27 | 27 | #include "amdgpu_dpm.h" |
| 28 | 28 | #include "amdgpu_atombios.h" |
| 29 | −#include "si/sid.h" | |
| 29 | +#include "sid.h" | |
| 30 | 30 | #include "r600_dpm.h" |
| 31 | 31 | #include "si_dpm.h" |
| 32 | 32 | #include "atom.h" |
| @@ -3009,29 +3009,6 @@ static int si_init_smc_spll_table(struct amdgpu_device *adev) · 2976 unmodified lines | ||
| 3009 | 3009 | return ret; |
| 3010 | 3010 | } |
| 3011 | 3011 | |
| 3012 | −struct si_dpm_quirk { | |
| 3013 | − u32 chip_vendor; | |
| 3014 | − u32 chip_device; | |
| 3015 | − u32 subsys_vendor; | |
| 3016 | − u32 subsys_device; | |
| 3017 | − u32 max_sclk; | |
| 3018 | − u32 max_mclk; | |
| 3019 | −}; | |
| 3020 | − | |
| 3021 | −/* cards with dpm stability problems */ | |
| 3022 | −static struct si_dpm_quirk si_dpm_quirk_list[] = { | |
| 3023 | − /* PITCAIRN - https://bugs.freedesktop.org/show_bug.cgi?id=76490 */ | |
| 3024 | − { PCI_VENDOR_ID_ATI, 0x6810, 0x1462, 0x3036, 0, 120000 }, | |
| 3025 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0xe271, 0, 120000 }, | |
| 3026 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0x2015, 0, 120000 }, | |
| 3027 | − { PCI_VENDOR_ID_ATI, 0x6810, 0x174b, 0xe271, 85000, 90000 }, | |
| 3028 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x1462, 0x2015, 0, 120000 }, | |
| 3029 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x1043, 0x2015, 0, 120000 }, | |
| 3030 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x148c, 0x2015, 0, 120000 }, | |
| 3031 | − { PCI_VENDOR_ID_ATI, 0x6810, 0x1682, 0x9275, 0, 120000 }, | |
| 3032 | − { 0, 0, 0, 0 }, | |
| 3033 | −}; | |
| 3034 | − | |
| 3035 | 3012 | static u16 si_get_lower_of_leakage_and_vce_voltage(struct amdgpu_device *adev, |
| 3036 | 3013 | u16 vce_voltage) |
| 3037 | 3014 | { |
| @@ -3477,18 +3454,8 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, · 439 unmodified lines | ||
| 3477 | 3454 | u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc; |
| 3478 | 3455 | u32 max_sclk = 0, max_mclk = 0; |
| 3479 | 3456 | int i; |
| 3480 | − struct si_dpm_quirk *p = si_dpm_quirk_list; | |
| 3481 | 3457 | |
| 3482 | − /* limit all SI kickers */ | |
| 3483 | − if (adev->asic_type == CHIP_PITCAIRN) { | |
| 3484 | − if ((adev->pdev->revision == 0x81) || | |
| 3485 | − (adev->pdev->device == 0x6810) || | |
| 3486 | − (adev->pdev->device == 0x6811) || | |
| 3487 | − (adev->pdev->device == 0x6816) || | |
| 3488 | − (adev->pdev->device == 0x6817) || | |
| 3489 | − (adev->pdev->device == 0x6806)) | |
| 3490 | − max_mclk = 120000; | |
| 3491 | − } else if (adev->asic_type == CHIP_HAINAN) { | |
| 3458 | + if (adev->asic_type == CHIP_HAINAN) { | |
| 3492 | 3459 | if ((adev->pdev->revision == 0x81) || |
| 3493 | 3460 | (adev->pdev->revision == 0x83) || |
| 3494 | 3461 | (adev->pdev->revision == 0xC3) || |
| @@ -3498,18 +3465,6 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, · 3 unmodified lines | ||
| 3498 | 3465 | max_sclk = 75000; |
| 3499 | 3466 | } |
| 3500 | 3467 | } |
| 3501 | − /* Apply dpm quirks */ | |
| 3502 | − while (p && p->chip_device != 0) { | |
| 3503 | − if (adev->pdev->vendor == p->chip_vendor && | |
| 3504 | − adev->pdev->device == p->chip_device && | |
| 3505 | − adev->pdev->subsystem_vendor == p->subsys_vendor && | |
| 3506 | − adev->pdev->subsystem_device == p->subsys_device) { | |
| 3507 | − max_sclk = p->max_sclk; | |
| 3508 | − max_mclk = p->max_mclk; | |
| 3509 | − break; | |
| 3510 | − } | |
| 3511 | − ++p; | |
| 3512 | − } | |
| 3513 | 3468 | |
| 3514 | 3469 | if (rps->vce_active) { |
| 3515 | 3470 | rps->evclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].evclk; |
| @@ -3906,25 +3861,25 @@ static int si_restrict_performance_levels_before_switch(struct amdgpu_device *ad · 390 unmodified lines | ||
| 3906 | 3861 | } |
| 3907 | 3862 | |
| 3908 | 3863 | static int si_dpm_force_performance_level(struct amdgpu_device *adev, |
| 3909 | − enum amdgpu_dpm_forced_level level) | |
| 3864 | + enum amd_dpm_forced_level level) | |
| 3910 | 3865 | { |
| 3911 | 3866 | struct amdgpu_ps *rps = adev->pm.dpm.current_ps; |
| 3912 | 3867 | struct si_ps *ps = si_get_ps(rps); |
| 3913 | 3868 | u32 levels = ps->performance_level_count; |
| 3914 | 3869 | |
| 3915 | − if (level == AMDGPU_DPM_FORCED_LEVEL_HIGH) { | |
| 3870 | + if (level == AMD_DPM_FORCED_LEVEL_HIGH) { | |
| 3916 | 3871 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK) |
| 3917 | 3872 | return -EINVAL; |
| 3918 | 3873 | |
| 3919 | 3874 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 1) != PPSMC_Result_OK) |
| 3920 | 3875 | return -EINVAL; |
| 3921 | − } else if (level == AMDGPU_DPM_FORCED_LEVEL_LOW) { | |
| 3876 | + } else if (level == AMD_DPM_FORCED_LEVEL_LOW) { | |
| 3922 | 3877 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK) |
| 3923 | 3878 | return -EINVAL; |
| 3924 | 3879 | |
| 3925 | 3880 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, 1) != PPSMC_Result_OK) |
| 3926 | 3881 | return -EINVAL; |
| 3927 | − } else if (level == AMDGPU_DPM_FORCED_LEVEL_AUTO) { | |
| 3882 | + } else if (level == AMD_DPM_FORCED_LEVEL_AUTO) { | |
| 3928 | 3883 | if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK) |
| 3929 | 3884 | return -EINVAL; |
| 3930 | 3885 | |
| @@ -7746,7 +7701,7 @@ static int si_dpm_sw_init(void *handle) · 3815 unmodified lines | ||
| 7746 | 7701 | /* default to balanced state */ |
| 7747 | 7702 | adev->pm.dpm.state = POWER_STATE_TYPE_BALANCED; |
| 7748 | 7703 | adev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED; |
| 7749 | − adev->pm.dpm.forced_level = AMDGPU_DPM_FORCED_LEVEL_AUTO; | |
| 7704 | + adev->pm.dpm.forced_level = AMD_DPM_FORCED_LEVEL_AUTO; | |
| 7750 | 7705 | adev->pm.default_sclk = adev->clock.default_sclk; |
| 7751 | 7706 | adev->pm.default_mclk = adev->clock.default_mclk; |
| 7752 | 7707 | adev->pm.current_sclk = adev->clock.default_sclk; |
| @@ -8072,11 +8027,3 @@ static void si_dpm_set_irq_funcs(struct amdgpu_device *adev) · 319 unmodified lines | ||
| 8072 | 8027 | adev->pm.dpm.thermal.irq.funcs = &si_dpm_irq_funcs; |
| 8073 | 8028 | } |
| 8074 | 8029 | |
| 8075 | −const struct amdgpu_ip_block_version si_dpm_ip_block = | |
| 8076 | −{ | |
| 8077 | − .type = AMD_IP_BLOCK_TYPE_SMC, | |
| 8078 | − .major = 6, | |
| 8079 | − .minor = 0, | |
| 8080 | − .rev = 0, | |
| 8081 | − .funcs = &si_dpm_ip_funcs, | |
| 8082 | −}; | |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | #include "drmP.h" |
| 24 | 24 | #include "amdgpu.h" |
| 25 | 25 | #include "amdgpu_ih.h" |
| 26 | −#include "si/sid.h" | |
| 26 | +#include "sid.h" | |
| 27 | 27 | #include "si_ih.h" |
| 28 | 28 | |
| 29 | 29 | static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev); |
| @@ -25,7 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include <linux/firmware.h> |
| 26 | 26 | #include "drmP.h" |
| 27 | 27 | #include "amdgpu.h" |
| 28 | −#include "si/sid.h" | |
| 28 | +#include "sid.h" | |
| 29 | 29 | #include "ppsmc.h" |
| 30 | 30 | #include "amdgpu_ucode.h" |
| 31 | 31 | #include "sislands_smc.h" |
File renamed without changes.
| @@ -1,101 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright 2014 Advanced Micro Devices, Inc. | |
| 3 | − * | |
| 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: | |
| 10 | − * | |
| 11 | − * The above copyright notice and this permission notice shall be included in | |
| 12 | − * all copies or substantial portions of the Software. | |
| 13 | − * | |
| 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. | |
| 21 | − * | |
| 22 | − */ | |
| 23 | − | |
| 24 | −#ifndef SMU_UCODE_XFER_VI_H | |
| 25 | −#define SMU_UCODE_XFER_VI_H | |
| 26 | − | |
| 27 | −#define SMU_DRAMData_TOC_VERSION 1 | |
| 28 | −#define MAX_IH_REGISTER_COUNT 65535 | |
| 29 | −#define SMU_DIGEST_SIZE_BYTES 20 | |
| 30 | −#define SMU_FB_SIZE_BYTES 1048576 | |
| 31 | −#define SMU_MAX_ENTRIES 12 | |
| 32 | − | |
| 33 | −#define UCODE_ID_SMU 0 | |
| 34 | −#define UCODE_ID_SDMA0 1 | |
| 35 | −#define UCODE_ID_SDMA1 2 | |
| 36 | −#define UCODE_ID_CP_CE 3 | |
| 37 | −#define UCODE_ID_CP_PFP 4 | |
| 38 | −#define UCODE_ID_CP_ME 5 | |
| 39 | −#define UCODE_ID_CP_MEC 6 | |
| 40 | −#define UCODE_ID_CP_MEC_JT1 7 | |
| 41 | −#define UCODE_ID_CP_MEC_JT2 8 | |
| 42 | −#define UCODE_ID_GMCON_RENG 9 | |
| 43 | −#define UCODE_ID_RLC_G 10 | |
| 44 | −#define UCODE_ID_IH_REG_RESTORE 11 | |
| 45 | −#define UCODE_ID_VBIOS 12 | |
| 46 | −#define UCODE_ID_MISC_METADATA 13 | |
| 47 | −#define UCODE_ID_SMU_SK 14 | |
| 48 | −#define UCODE_ID_RLC_SCRATCH 32 | |
| 49 | −#define UCODE_ID_RLC_SRM_ARAM 33 | |
| 50 | −#define UCODE_ID_RLC_SRM_DRAM 34 | |
| 51 | −#define UCODE_ID_MEC_STORAGE 35 | |
| 52 | −#define UCODE_ID_VBIOS_PARAMETERS 36 | |
| 53 | −#define UCODE_META_DATA 0xFF | |
| 54 | − | |
| 55 | −#define UCODE_ID_SMU_MASK 0x00000001 | |
| 56 | −#define UCODE_ID_SDMA0_MASK 0x00000002 | |
| 57 | −#define UCODE_ID_SDMA1_MASK 0x00000004 | |
| 58 | −#define UCODE_ID_CP_CE_MASK 0x00000008 | |
| 59 | −#define UCODE_ID_CP_PFP_MASK 0x00000010 | |
| 60 | −#define UCODE_ID_CP_ME_MASK 0x00000020 | |
| 61 | −#define UCODE_ID_CP_MEC_MASK 0x00000040 | |
| 62 | −#define UCODE_ID_CP_MEC_JT1_MASK 0x00000080 | |
| 63 | −#define UCODE_ID_CP_MEC_JT2_MASK 0x00000100 | |
| 64 | −#define UCODE_ID_GMCON_RENG_MASK 0x00000200 | |
| 65 | −#define UCODE_ID_RLC_G_MASK 0x00000400 | |
| 66 | −#define UCODE_ID_IH_REG_RESTORE_MASK 0x00000800 | |
| 67 | −#define UCODE_ID_VBIOS_MASK 0x00001000 | |
| 68 | − | |
| 69 | −#define UCODE_FLAG_UNHALT_MASK 0x1 | |
| 70 | − | |
| 71 | −struct SMU_Entry { | |
| 72 | −#ifndef __BIG_ENDIAN | |
| 73 | − uint16_t id; | |
| 74 | − uint16_t version; | |
| 75 | − uint32_t image_addr_high; | |
| 76 | − uint32_t image_addr_low; | |
| 77 | − uint32_t meta_data_addr_high; | |
| 78 | − uint32_t meta_data_addr_low; | |
| 79 | − uint32_t data_size_byte; | |
| 80 | − uint16_t flags; | |
| 81 | − uint16_t num_register_entries; | |
| 82 | −#else | |
| 83 | − uint16_t version; | |
| 84 | − uint16_t id; | |
| 85 | − uint32_t image_addr_high; | |
| 86 | − uint32_t image_addr_low; | |
| 87 | − uint32_t meta_data_addr_high; | |
| 88 | − uint32_t meta_data_addr_low; | |
| 89 | − uint32_t data_size_byte; | |
| 90 | − uint16_t num_register_entries; | |
| 91 | − uint16_t flags; | |
| 92 | −#endif | |
| 93 | −}; | |
| 94 | − | |
| 95 | −struct SMU_DRAMData_TOC { | |
| 96 | − uint32_t structure_version; | |
| 97 | − uint32_t num_entries; | |
| 98 | − struct SMU_Entry entry[SMU_MAX_ENTRIES]; | |
| 99 | −}; | |
| 100 | − | |
| 101 | −#endif | |
| @@ -822,16 +822,44 @@ static int uvd_v5_0_set_powergating_state(void *handle, · 821 unmodified lines | ||
| 822 | 822 | * the smc and the hw blocks |
| 823 | 823 | */ |
| 824 | 824 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 825 | + int ret = 0; | |
| 825 | 826 | |
| 826 | 827 | if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD)) |
| 827 | 828 | return 0; |
| 828 | 829 | |
| 829 | 830 | if (state == AMD_PG_STATE_GATE) { |
| 830 | 831 | uvd_v5_0_stop(adev); |
| 831 | − return 0; | |
| 832 | + adev->uvd.is_powergated = true; | |
| 832 | 833 | } else { |
| 833 | − return uvd_v5_0_start(adev); | |
| 834 | + ret = uvd_v5_0_start(adev); | |
| 835 | + if (ret) | |
| 836 | + goto out; | |
| 837 | + adev->uvd.is_powergated = false; | |
| 838 | + } | |
| 839 | + | |
| 840 | +out: | |
| 841 | + return ret; | |
| 842 | +} | |
| 843 | + | |
| 844 | +static void uvd_v5_0_get_clockgating_state(void *handle, u32 *flags) | |
| 845 | +{ | |
| 846 | + struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 847 | + int data; | |
| 848 | + | |
| 849 | + mutex_lock(&adev->pm.mutex); | |
| 850 | + | |
| 851 | + if (adev->uvd.is_powergated) { | |
| 852 | + DRM_INFO("Cannot get clockgating state when UVD is powergated.\n"); | |
| 853 | + goto out; | |
| 834 | 854 | } |
| 855 | + | |
| 856 | + /* AMD_CG_SUPPORT_UVD_MGCG */ | |
| 857 | + data = RREG32(mmUVD_CGC_CTRL); | |
| 858 | + if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK) | |
| 859 | + *flags |= AMD_CG_SUPPORT_UVD_MGCG; | |
| 860 | + | |
| 861 | +out: | |
| 862 | + mutex_unlock(&adev->pm.mutex); | |
| 835 | 863 | } |
| 836 | 864 | |
| 837 | 865 | static const struct amd_ip_funcs uvd_v5_0_ip_funcs = { |
| @@ -849,6 +877,7 @@ static const struct amd_ip_funcs uvd_v5_0_ip_funcs = { · 11 unmodified lines | ||
| 849 | 877 | .soft_reset = uvd_v5_0_soft_reset, |
| 850 | 878 | .set_clockgating_state = uvd_v5_0_set_clockgating_state, |
| 851 | 879 | .set_powergating_state = uvd_v5_0_set_powergating_state, |
| 880 | + .get_clockgating_state = uvd_v5_0_get_clockgating_state, | |
| 852 | 881 | }; |
| 853 | 882 | |
| 854 | 883 | static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { |
| @@ -1047,6 +1047,7 @@ static int uvd_v6_0_set_powergating_state(void *handle, · 1046 unmodified lines | ||
| 1047 | 1047 | * the smc and the hw blocks |
| 1048 | 1048 | */ |
| 1049 | 1049 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 1050 | + int ret = 0; | |
| 1050 | 1051 | |
| 1051 | 1052 | if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD)) |
| 1052 | 1053 | return 0; |
| @@ -1055,10 +1056,37 @@ static int uvd_v6_0_set_powergating_state(void *handle, · 2 unmodified lines | ||
| 1055 | 1056 | |
| 1056 | 1057 | if (state == AMD_PG_STATE_GATE) { |
| 1057 | 1058 | uvd_v6_0_stop(adev); |
| 1058 | − return 0; | |
| 1059 | + adev->uvd.is_powergated = true; | |
| 1059 | 1060 | } else { |
| 1060 | − return uvd_v6_0_start(adev); | |
| 1061 | + ret = uvd_v6_0_start(adev); | |
| 1062 | + if (ret) | |
| 1063 | + goto out; | |
| 1064 | + adev->uvd.is_powergated = false; | |
| 1065 | + } | |
| 1066 | + | |
| 1067 | +out: | |
| 1068 | + return ret; | |
| 1069 | +} | |
| 1070 | + | |
| 1071 | +static void uvd_v6_0_get_clockgating_state(void *handle, u32 *flags) | |
| 1072 | +{ | |
| 1073 | + struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1074 | + int data; | |
| 1075 | + | |
| 1076 | + mutex_lock(&adev->pm.mutex); | |
| 1077 | + | |
| 1078 | + if (adev->uvd.is_powergated) { | |
| 1079 | + DRM_INFO("Cannot get clockgating state when UVD is powergated.\n"); | |
| 1080 | + goto out; | |
| 1061 | 1081 | } |
| 1082 | + | |
| 1083 | + /* AMD_CG_SUPPORT_UVD_MGCG */ | |
| 1084 | + data = RREG32(mmUVD_CGC_CTRL); | |
| 1085 | + if (data & UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK) | |
| 1086 | + *flags |= AMD_CG_SUPPORT_UVD_MGCG; | |
| 1087 | + | |
| 1088 | +out: | |
| 1089 | + mutex_unlock(&adev->pm.mutex); | |
| 1062 | 1090 | } |
| 1063 | 1091 | |
| 1064 | 1092 | static const struct amd_ip_funcs uvd_v6_0_ip_funcs = { |
| @@ -1079,6 +1107,7 @@ static const struct amd_ip_funcs uvd_v6_0_ip_funcs = { · 14 unmodified lines | ||
| 1079 | 1107 | .post_soft_reset = uvd_v6_0_post_soft_reset, |
| 1080 | 1108 | .set_clockgating_state = uvd_v6_0_set_clockgating_state, |
| 1081 | 1109 | .set_powergating_state = uvd_v6_0_set_powergating_state, |
| 1110 | + .get_clockgating_state = uvd_v6_0_get_clockgating_state, | |
| 1082 | 1111 | }; |
| 1083 | 1112 | |
| 1084 | 1113 | static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = { |
| @@ -230,6 +230,10 @@ static int vce_v3_0_start(struct amdgpu_device *adev) · 229 unmodified lines | ||
| 230 | 230 | struct amdgpu_ring *ring; |
| 231 | 231 | int idx, r; |
| 232 | 232 | |
| 233 | + vce_v3_0_override_vce_clock_gating(adev, true); | |
| 234 | + if (!(adev->flags & AMD_IS_APU)) | |
| 235 | + amdgpu_asic_set_vce_clocks(adev, 10000, 10000); | |
| 236 | + | |
| 233 | 237 | ring = &adev->vce.ring[0]; |
| 234 | 238 | WREG32(mmVCE_RB_RPTR, ring->wptr); |
| 235 | 239 | WREG32(mmVCE_RB_WPTR, ring->wptr); |
| @@ -708,18 +712,6 @@ static int vce_v3_0_process_interrupt(struct amdgpu_device *adev, · 472 unmodified lines | ||
| 708 | 712 | return 0; |
| 709 | 713 | } |
| 710 | 714 | |
| 711 | −static void vce_v3_0_set_bypass_mode(struct amdgpu_device *adev, bool enable) | |
| 712 | −{ | |
| 713 | − u32 tmp = RREG32_SMC(ixGCK_DFS_BYPASS_CNTL); | |
| 714 | − | |
| 715 | − if (enable) | |
| 716 | − tmp |= GCK_DFS_BYPASS_CNTL__BYPASSECLK_MASK; | |
| 717 | − else | |
| 718 | − tmp &= ~GCK_DFS_BYPASS_CNTL__BYPASSECLK_MASK; | |
| 719 | − | |
| 720 | − WREG32_SMC(ixGCK_DFS_BYPASS_CNTL, tmp); | |
| 721 | −} | |
| 722 | − | |
| 723 | 715 | static int vce_v3_0_set_clockgating_state(void *handle, |
| 724 | 716 | enum amd_clockgating_state state) |
| 725 | 717 | { |
| @@ -727,11 +719,6 @@ static int vce_v3_0_set_clockgating_state(void *handle, · 1 unmodified line | ||
| 727 | 719 | bool enable = (state == AMD_CG_STATE_GATE) ? true : false; |
| 728 | 720 | int i; |
| 729 | 721 | |
| 730 | − if ((adev->asic_type == CHIP_POLARIS10) || | |
| 731 | − (adev->asic_type == CHIP_TONGA) || | |
| 732 | − (adev->asic_type == CHIP_FIJI)) | |
| 733 | − vce_v3_0_set_bypass_mode(adev, enable); | |
| 734 | − | |
| 735 | 722 | if (!(adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)) |
| 736 | 723 | return 0; |
| 737 | 724 | |
| @@ -777,15 +764,46 @@ static int vce_v3_0_set_powergating_state(void *handle, · 39 unmodified lines | ||
| 777 | 764 | * the smc and the hw blocks |
| 778 | 765 | */ |
| 779 | 766 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
| 767 | + int ret = 0; | |
| 780 | 768 | |
| 781 | 769 | if (!(adev->pg_flags & AMD_PG_SUPPORT_VCE)) |
| 782 | 770 | return 0; |
| 783 | 771 | |
| 784 | − if (state == AMD_PG_STATE_GATE) | |
| 772 | + if (state == AMD_PG_STATE_GATE) { | |
| 773 | + adev->vce.is_powergated = true; | |
| 785 | 774 | /* XXX do we need a vce_v3_0_stop()? */ |
| 786 | − return 0; | |
| 787 | − else | |
| 788 | − return vce_v3_0_start(adev); | |
| 775 | + } else { | |
| 776 | + ret = vce_v3_0_start(adev); | |
| 777 | + if (ret) | |
| 778 | + goto out; | |
| 779 | + adev->vce.is_powergated = false; | |
| 780 | + } | |
| 781 | + | |
| 782 | +out: | |
| 783 | + return ret; | |
| 784 | +} | |
| 785 | + | |
| 786 | +static void vce_v3_0_get_clockgating_state(void *handle, u32 *flags) | |
| 787 | +{ | |
| 788 | + struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 789 | + int data; | |
| 790 | + | |
| 791 | + mutex_lock(&adev->pm.mutex); | |
| 792 | + | |
| 793 | + if (adev->vce.is_powergated) { | |
| 794 | + DRM_INFO("Cannot get clockgating state when VCE is powergated.\n"); | |
| 795 | + goto out; | |
| 796 | + } | |
| 797 | + | |
| 798 | + WREG32_FIELD(GRBM_GFX_INDEX, VCE_INSTANCE, 0); | |
| 799 | + | |
| 800 | + /* AMD_CG_SUPPORT_VCE_MGCG */ | |
| 801 | + data = RREG32(mmVCE_CLOCK_GATING_A); | |
| 802 | + if (data & (0x04 << 4)) | |
| 803 | + *flags |= AMD_CG_SUPPORT_VCE_MGCG; | |
| 804 | + | |
| 805 | +out: | |
| 806 | + mutex_unlock(&adev->pm.mutex); | |
| 789 | 807 | } |
| 790 | 808 | |
| 791 | 809 | static void vce_v3_0_ring_emit_ib(struct amdgpu_ring *ring, |
| @@ -839,6 +857,7 @@ static const struct amd_ip_funcs vce_v3_0_ip_funcs = { · 47 unmodified lines | ||
| 839 | 857 | .post_soft_reset = vce_v3_0_post_soft_reset, |
| 840 | 858 | .set_clockgating_state = vce_v3_0_set_clockgating_state, |
| 841 | 859 | .set_powergating_state = vce_v3_0_set_powergating_state, |
| 860 | + .get_clockgating_state = vce_v3_0_get_clockgating_state, | |
| 842 | 861 | }; |
| 843 | 862 | |
| 844 | 863 | static const struct amdgpu_ring_funcs vce_v3_0_ring_phys_funcs = { |
| @@ -20,9 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | −#include <linux/firmware.h> | |
| 24 | 23 | #include <linux/slab.h> |
| 25 | −#include <linux/module.h> | |
| 26 | 24 | #include "drmP.h" |
| 27 | 25 | #include "amdgpu.h" |
| 28 | 26 | #include "amdgpu_atombios.h" |
| @@ -78,17 +76,7 @@ · 49 unmodified lines | ||
| 78 | 76 | #include "amdgpu_acp.h" |
| 79 | 77 | #endif |
| 80 | 78 | #include "dce_virtual.h" |
| 81 | − | |
| 82 | −MODULE_FIRMWARE("amdgpu/topaz_smc.bin"); | |
| 83 | −MODULE_FIRMWARE("amdgpu/topaz_k_smc.bin"); | |
| 84 | −MODULE_FIRMWARE("amdgpu/tonga_smc.bin"); | |
| 85 | −MODULE_FIRMWARE("amdgpu/tonga_k_smc.bin"); | |
| 86 | −MODULE_FIRMWARE("amdgpu/fiji_smc.bin"); | |
| 87 | −MODULE_FIRMWARE("amdgpu/polaris10_smc.bin"); | |
| 88 | −MODULE_FIRMWARE("amdgpu/polaris10_smc_sk.bin"); | |
| 89 | −MODULE_FIRMWARE("amdgpu/polaris11_smc.bin"); | |
| 90 | −MODULE_FIRMWARE("amdgpu/polaris11_smc_sk.bin"); | |
| 91 | −MODULE_FIRMWARE("amdgpu/polaris12_smc.bin"); | |
| 79 | +#include "mxgpu_vi.h" | |
| 92 | 80 | |
| 93 | 81 | /* |
| 94 | 82 | * Indirect registers accessor |
| @@ -285,6 +273,12 @@ static void vi_init_golden_registers(struct amdgpu_device *adev) · 190 unmodified lines | ||
| 285 | 273 | /* Some of the registers might be dependent on GRBM_GFX_INDEX */ |
| 286 | 274 | mutex_lock(&adev->grbm_idx_mutex); |
| 287 | 275 | |
| 276 | + if (amdgpu_sriov_vf(adev)) { | |
| 277 | + xgpu_vi_init_golden_registers(adev); | |
| 278 | + mutex_unlock(&adev->grbm_idx_mutex); | |
| 279 | + return; | |
| 280 | + } | |
| 281 | + | |
| 288 | 282 | switch (adev->asic_type) { |
| 289 | 283 | case CHIP_TOPAZ: |
| 290 | 284 | amdgpu_program_register_sequence(adev, |
| @@ -458,14 +452,14 @@ static void vi_detect_hw_virtualization(struct amdgpu_device *adev) · 167 unmodified lines | ||
| 458 | 452 | /* bit0: 0 means pf and 1 means vf */ |
| 459 | 453 | /* bit31: 0 means disable IOV and 1 means enable */ |
| 460 | 454 | if (reg & 1) |
| 461 | − adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_IS_VF; | |
| 455 | + adev->virt.caps |= AMDGPU_SRIOV_CAPS_IS_VF; | |
| 462 | 456 | |
| 463 | 457 | if (reg & 0x80000000) |
| 464 | − adev->virtualization.virtual_caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV; | |
| 458 | + adev->virt.caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV; | |
| 465 | 459 | |
| 466 | 460 | if (reg == 0) { |
| 467 | 461 | if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */ |
| 468 | − adev->virtualization.virtual_caps |= AMDGPU_PASSTHROUGH_MODE; | |
| 462 | + adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE; | |
| 469 | 463 | } |
| 470 | 464 | } |
| 471 | 465 | |
| @@ -801,7 +795,37 @@ static int vi_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk) · 329 unmodified lines | ||
| 801 | 795 | |
| 802 | 796 | static int vi_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk) |
| 803 | 797 | { |
| 804 | − /* todo */ | |
| 798 | + int r, i; | |
| 799 | + struct atom_clock_dividers dividers; | |
| 800 | + u32 tmp; | |
| 801 | + | |
| 802 | + r = amdgpu_atombios_get_clock_dividers(adev, | |
| 803 | + COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK, | |
| 804 | + ecclk, false, ÷rs); | |
| 805 | + if (r) | |
| 806 | + return r; | |
| 807 | + | |
| 808 | + for (i = 0; i < 100; i++) { | |
| 809 | + if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK) | |
| 810 | + break; | |
| 811 | + mdelay(10); | |
| 812 | + } | |
| 813 | + if (i == 100) | |
| 814 | + return -ETIMEDOUT; | |
| 815 | + | |
| 816 | + tmp = RREG32_SMC(ixCG_ECLK_CNTL); | |
| 817 | + tmp &= ~(CG_ECLK_CNTL__ECLK_DIR_CNTL_EN_MASK | | |
| 818 | + CG_ECLK_CNTL__ECLK_DIVIDER_MASK); | |
| 819 | + tmp |= dividers.post_divider; | |
| 820 | + WREG32_SMC(ixCG_ECLK_CNTL, tmp); | |
| 821 | + | |
| 822 | + for (i = 0; i < 100; i++) { | |
| 823 | + if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK) | |
| 824 | + break; | |
| 825 | + mdelay(10); | |
| 826 | + } | |
| 827 | + if (i == 100) | |
| 828 | + return -ETIMEDOUT; | |
| 805 | 829 | |
| 806 | 830 | return 0; |
| 807 | 831 | } |
| @@ -869,7 +893,6 @@ static const struct amdgpu_asic_funcs vi_asic_funcs = · 61 unmodified lines | ||
| 869 | 893 | { |
| 870 | 894 | .read_disabled_bios = &vi_read_disabled_bios, |
| 871 | 895 | .read_bios_from_rom = &vi_read_bios_from_rom, |
| 872 | − .detect_hw_virtualization = vi_detect_hw_virtualization, | |
| 873 | 896 | .read_register = &vi_read_register, |
| 874 | 897 | .reset = &vi_asic_reset, |
| 875 | 898 | .set_vga_state = &vi_vga_set_state, |
| @@ -905,6 +928,11 @@ static int vi_common_early_init(void *handle) · 29 unmodified lines | ||
| 905 | 928 | (amdgpu_ip_block_mask & (1 << AMD_IP_BLOCK_TYPE_SMC))) |
| 906 | 929 | smc_enabled = true; |
| 907 | 930 | |
| 931 | + if (amdgpu_sriov_vf(adev)) { | |
| 932 | + amdgpu_virt_init_setting(adev); | |
| 933 | + xgpu_vi_mailbox_set_irq_funcs(adev); | |
| 934 | + } | |
| 935 | + | |
| 908 | 936 | adev->rev_id = vi_get_rev_id(adev); |
| 909 | 937 | adev->external_rev_id = 0xFF; |
| 910 | 938 | switch (adev->asic_type) { |
| @@ -1061,10 +1089,6 @@ static int vi_common_early_init(void *handle) · 150 unmodified lines | ||
| 1061 | 1089 | return -EINVAL; |
| 1062 | 1090 | } |
| 1063 | 1091 | |
| 1064 | − /* in early init stage, vbios code won't work */ | |
| 1065 | − if (adev->asic_funcs->detect_hw_virtualization) | |
| 1066 | − amdgpu_asic_detect_hw_virtualization(adev); | |
| 1067 | − | |
| 1068 | 1092 | if (amdgpu_smc_load_fw && smc_enabled) |
| 1069 | 1093 | adev->firmware.smu_load = true; |
| 1070 | 1094 | |
| @@ -1073,8 +1097,23 @@ static int vi_common_early_init(void *handle) · 2 unmodified lines | ||
| 1073 | 1097 | return 0; |
| 1074 | 1098 | } |
| 1075 | 1099 | |
| 1100 | +static int vi_common_late_init(void *handle) | |
| 1101 | +{ | |
| 1102 | + struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1103 | + | |
| 1104 | + if (amdgpu_sriov_vf(adev)) | |
| 1105 | + xgpu_vi_mailbox_get_irq(adev); | |
| 1106 | + | |
| 1107 | + return 0; | |
| 1108 | +} | |
| 1109 | + | |
| 1076 | 1110 | static int vi_common_sw_init(void *handle) |
| 1077 | 1111 | { |
| 1112 | + struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1113 | + | |
| 1114 | + if (amdgpu_sriov_vf(adev)) | |
| 1115 | + xgpu_vi_mailbox_add_irq_id(adev); | |
| 1116 | + | |
| 1078 | 1117 | return 0; |
| 1079 | 1118 | } |
| 1080 | 1119 | |
| @@ -1106,6 +1145,9 @@ static int vi_common_hw_fini(void *handle) · 25 unmodified lines | ||
| 1106 | 1145 | /* enable the doorbell aperture */ |
| 1107 | 1146 | vi_enable_doorbell_aperture(adev, false); |
| 1108 | 1147 | |
| 1148 | + if (amdgpu_sriov_vf(adev)) | |
| 1149 | + xgpu_vi_mailbox_put_irq(adev); | |
| 1150 | + | |
| 1109 | 1151 | return 0; |
| 1110 | 1152 | } |
| 1111 | 1153 | |
| @@ -1190,6 +1232,23 @@ static void vi_update_hdp_light_sleep(struct amdgpu_device *adev, · 78 unmodified lines | ||
| 1190 | 1232 | WREG32(mmHDP_MEM_POWER_LS, data); |
| 1191 | 1233 | } |
| 1192 | 1234 | |
| 1235 | +static void vi_update_drm_light_sleep(struct amdgpu_device *adev, | |
| 1236 | + bool enable) | |
| 1237 | +{ | |
| 1238 | + uint32_t temp, data; | |
| 1239 | + | |
| 1240 | + temp = data = RREG32(0x157a); | |
| 1241 | + | |
| 1242 | + if (enable && (adev->cg_flags & AMD_CG_SUPPORT_DRM_LS)) | |
| 1243 | + data |= 1; | |
| 1244 | + else | |
| 1245 | + data &= ~1; | |
| 1246 | + | |
| 1247 | + if (temp != data) | |
| 1248 | + WREG32(0x157a, data); | |
| 1249 | +} | |
| 1250 | + | |
| 1251 | + | |
| 1193 | 1252 | static void vi_update_rom_medium_grain_clock_gating(struct amdgpu_device *adev, |
| 1194 | 1253 | bool enable) |
| 1195 | 1254 | { |
| @@ -1350,6 +1409,8 @@ static int vi_common_set_clockgating_state(void *handle, · 154 unmodified lines | ||
| 1350 | 1409 | state == AMD_CG_STATE_GATE ? true : false); |
| 1351 | 1410 | vi_update_hdp_light_sleep(adev, |
| 1352 | 1411 | state == AMD_CG_STATE_GATE ? true : false); |
| 1412 | + vi_update_drm_light_sleep(adev, | |
| 1413 | + state == AMD_CG_STATE_GATE ? true : false); | |
| 1353 | 1414 | break; |
| 1354 | 1415 | case CHIP_TONGA: |
| 1355 | 1416 | case CHIP_POLARIS10: |
| @@ -1368,10 +1429,36 @@ static int vi_common_set_powergating_state(void *handle, · 12 unmodified lines | ||
| 1368 | 1429 | return 0; |
| 1369 | 1430 | } |
| 1370 | 1431 | |
| 1432 | +static void vi_common_get_clockgating_state(void *handle, u32 *flags) | |
| 1433 | +{ | |
| 1434 | + struct amdgpu_device *adev = (struct amdgpu_device *)handle; | |
| 1435 | + int data; | |
| 1436 | + | |
| 1437 | + /* AMD_CG_SUPPORT_BIF_LS */ | |
| 1438 | + data = RREG32_PCIE(ixPCIE_CNTL2); | |
| 1439 | + if (data & PCIE_CNTL2__SLV_MEM_LS_EN_MASK) | |
| 1440 | + *flags |= AMD_CG_SUPPORT_BIF_LS; | |
| 1441 | + | |
| 1442 | + /* AMD_CG_SUPPORT_HDP_LS */ | |
| 1443 | + data = RREG32(mmHDP_MEM_POWER_LS); | |
| 1444 | + if (data & HDP_MEM_POWER_LS__LS_ENABLE_MASK) | |
| 1445 | + *flags |= AMD_CG_SUPPORT_HDP_LS; | |
| 1446 | + | |
| 1447 | + /* AMD_CG_SUPPORT_HDP_MGCG */ | |
| 1448 | + data = RREG32(mmHDP_HOST_PATH_CNTL); | |
| 1449 | + if (!(data & HDP_HOST_PATH_CNTL__CLOCK_GATING_DIS_MASK)) | |
| 1450 | + *flags |= AMD_CG_SUPPORT_HDP_MGCG; | |
| 1451 | + | |
| 1452 | + /* AMD_CG_SUPPORT_ROM_MGCG */ | |
| 1453 | + data = RREG32_SMC(ixCGTT_ROM_CLK_CTRL0); | |
| 1454 | + if (!(data & CGTT_ROM_CLK_CTRL0__SOFT_OVERRIDE0_MASK)) | |
| 1455 | + *flags |= AMD_CG_SUPPORT_ROM_MGCG; | |
| 1456 | +} | |
| 1457 | + | |
| 1371 | 1458 | static const struct amd_ip_funcs vi_common_ip_funcs = { |
| 1372 | 1459 | .name = "vi_common", |
| 1373 | 1460 | .early_init = vi_common_early_init, |
| 1374 | − .late_init = NULL, | |
| 1461 | + .late_init = vi_common_late_init, | |
| 1375 | 1462 | .sw_init = vi_common_sw_init, |
| 1376 | 1463 | .sw_fini = vi_common_sw_fini, |
| 1377 | 1464 | .hw_init = vi_common_hw_init, |
| @@ -1383,6 +1470,7 @@ static const struct amd_ip_funcs vi_common_ip_funcs = { · 5 unmodified lines | ||
| 1383 | 1470 | .soft_reset = vi_common_soft_reset, |
| 1384 | 1471 | .set_clockgating_state = vi_common_set_clockgating_state, |
| 1385 | 1472 | .set_powergating_state = vi_common_set_powergating_state, |
| 1473 | + .get_clockgating_state = vi_common_get_clockgating_state, | |
| 1386 | 1474 | }; |
| 1387 | 1475 | |
| 1388 | 1476 | static const struct amdgpu_ip_block_version vi_common_ip_block = |
| @@ -1396,6 +1484,12 @@ static const struct amdgpu_ip_block_version vi_common_ip_block = · 7 unmodified lines | ||
| 1396 | 1484 | |
| 1397 | 1485 | int vi_set_ip_blocks(struct amdgpu_device *adev) |
| 1398 | 1486 | { |
| 1487 | + /* in early init stage, vbios code won't work */ | |
| 1488 | + vi_detect_hw_virtualization(adev); | |
| 1489 | + | |
| 1490 | + if (amdgpu_sriov_vf(adev)) | |
| 1491 | + adev->virt.ops = &xgpu_vi_virt_ops; | |
| 1492 | + | |
| 1399 | 1493 | switch (adev->asic_type) { |
| 1400 | 1494 | case CHIP_TOPAZ: |
| 1401 | 1495 | /* topaz has no DCE, UVD, VCE */ |
| @@ -1413,28 +1507,32 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) · 11 unmodified lines | ||
| 1413 | 1507 | amdgpu_ip_block_add(adev, &gmc_v8_5_ip_block); |
| 1414 | 1508 | amdgpu_ip_block_add(adev, &tonga_ih_ip_block); |
| 1415 | 1509 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); |
| 1416 | − if (adev->enable_virtual_display) | |
| 1510 | + if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | |
| 1417 | 1511 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); |
| 1418 | 1512 | else |
| 1419 | 1513 | amdgpu_ip_block_add(adev, &dce_v10_1_ip_block); |
| 1420 | 1514 | amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); |
| 1421 | 1515 | amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block); |
| 1422 | − amdgpu_ip_block_add(adev, &uvd_v6_0_ip_block); | |
| 1423 | − amdgpu_ip_block_add(adev, &vce_v3_0_ip_block); | |
| 1516 | + if (!amdgpu_sriov_vf(adev)) { | |
| 1517 | + amdgpu_ip_block_add(adev, &uvd_v6_0_ip_block); | |
| 1518 | + amdgpu_ip_block_add(adev, &vce_v3_0_ip_block); | |
| 1519 | + } | |
| 1424 | 1520 | break; |
| 1425 | 1521 | case CHIP_TONGA: |
| 1426 | 1522 | amdgpu_ip_block_add(adev, &vi_common_ip_block); |
| 1427 | 1523 | amdgpu_ip_block_add(adev, &gmc_v8_0_ip_block); |
| 1428 | 1524 | amdgpu_ip_block_add(adev, &tonga_ih_ip_block); |
| 1429 | 1525 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); |
| 1430 | − if (adev->enable_virtual_display) | |
| 1526 | + if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | |
| 1431 | 1527 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); |
| 1432 | 1528 | else |
| 1433 | 1529 | amdgpu_ip_block_add(adev, &dce_v10_0_ip_block); |
| 1434 | 1530 | amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); |
| 1435 | 1531 | amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block); |
| 1436 | − amdgpu_ip_block_add(adev, &uvd_v5_0_ip_block); | |
| 1437 | − amdgpu_ip_block_add(adev, &vce_v3_0_ip_block); | |
| 1532 | + if (!amdgpu_sriov_vf(adev)) { | |
| 1533 | + amdgpu_ip_block_add(adev, &uvd_v5_0_ip_block); | |
| 1534 | + amdgpu_ip_block_add(adev, &vce_v3_0_ip_block); | |
| 1535 | + } | |
| 1438 | 1536 | break; |
| 1439 | 1537 | case CHIP_POLARIS11: |
| 1440 | 1538 | case CHIP_POLARIS10: |
| @@ -28,4 +28,116 @@ void vi_srbm_select(struct amdgpu_device *adev, · 27 unmodified lines | ||
| 28 | 28 | u32 me, u32 pipe, u32 queue, u32 vmid); |
| 29 | 29 | int vi_set_ip_blocks(struct amdgpu_device *adev); |
| 30 | 30 | |
| 31 | +struct amdgpu_ce_ib_state | |
| 32 | +{ | |
| 33 | + uint32_t ce_ib_completion_status; | |
| 34 | + uint32_t ce_constegnine_count; | |
| 35 | + uint32_t ce_ibOffset_ib1; | |
| 36 | + uint32_t ce_ibOffset_ib2; | |
| 37 | +}; /* Total of 4 DWORD */ | |
| 38 | + | |
| 39 | +struct amdgpu_de_ib_state | |
| 40 | +{ | |
| 41 | + uint32_t ib_completion_status; | |
| 42 | + uint32_t de_constEngine_count; | |
| 43 | + uint32_t ib_offset_ib1; | |
| 44 | + uint32_t ib_offset_ib2; | |
| 45 | + uint32_t preamble_begin_ib1; | |
| 46 | + uint32_t preamble_begin_ib2; | |
| 47 | + uint32_t preamble_end_ib1; | |
| 48 | + uint32_t preamble_end_ib2; | |
| 49 | + uint32_t draw_indirect_baseLo; | |
| 50 | + uint32_t draw_indirect_baseHi; | |
| 51 | + uint32_t disp_indirect_baseLo; | |
| 52 | + uint32_t disp_indirect_baseHi; | |
| 53 | + uint32_t gds_backup_addrlo; | |
| 54 | + uint32_t gds_backup_addrhi; | |
| 55 | + uint32_t index_base_addrlo; | |
| 56 | + uint32_t index_base_addrhi; | |
| 57 | + uint32_t sample_cntl; | |
| 58 | +}; /* Total of 17 DWORD */ | |
| 59 | + | |
| 60 | +struct amdgpu_ce_ib_state_chained_ib | |
| 61 | +{ | |
| 62 | + /* section of non chained ib part */ | |
| 63 | + uint32_t ce_ib_completion_status; | |
| 64 | + uint32_t ce_constegnine_count; | |
| 65 | + uint32_t ce_ibOffset_ib1; | |
| 66 | + uint32_t ce_ibOffset_ib2; | |
| 67 | + | |
| 68 | + /* section of chained ib */ | |
| 69 | + uint32_t ce_chainib_addrlo_ib1; | |
| 70 | + uint32_t ce_chainib_addrlo_ib2; | |
| 71 | + uint32_t ce_chainib_addrhi_ib1; | |
| 72 | + uint32_t ce_chainib_addrhi_ib2; | |
| 73 | + uint32_t ce_chainib_size_ib1; | |
| 74 | + uint32_t ce_chainib_size_ib2; | |
| 75 | +}; /* total 10 DWORD */ | |
| 76 | + | |
| 77 | +struct amdgpu_de_ib_state_chained_ib | |
| 78 | +{ | |
| 79 | + /* section of non chained ib part */ | |
| 80 | + uint32_t ib_completion_status; | |
| 81 | + uint32_t de_constEngine_count; | |
| 82 | + uint32_t ib_offset_ib1; | |
| 83 | + uint32_t ib_offset_ib2; | |
| 84 | + | |
| 85 | + /* section of chained ib */ | |
| 86 | + uint32_t chain_ib_addrlo_ib1; | |
| 87 | + uint32_t chain_ib_addrlo_ib2; | |
| 88 | + uint32_t chain_ib_addrhi_ib1; | |
| 89 | + uint32_t chain_ib_addrhi_ib2; | |
| 90 | + uint32_t chain_ib_size_ib1; | |
| 91 | + uint32_t chain_ib_size_ib2; | |
| 92 | + | |
| 93 | + /* section of non chained ib part */ | |
| 94 | + uint32_t preamble_begin_ib1; | |
| 95 | + uint32_t preamble_begin_ib2; | |
| 96 | + uint32_t preamble_end_ib1; | |
| 97 | + uint32_t preamble_end_ib2; | |
| 98 | + | |
| 99 | + /* section of chained ib */ | |
| 100 | + uint32_t chain_ib_pream_addrlo_ib1; | |
| 101 | + uint32_t chain_ib_pream_addrlo_ib2; | |
| 102 | + uint32_t chain_ib_pream_addrhi_ib1; | |
| 103 | + uint32_t chain_ib_pream_addrhi_ib2; | |
| 104 | + | |
| 105 | + /* section of non chained ib part */ | |
| 106 | + uint32_t draw_indirect_baseLo; | |
| 107 | + uint32_t draw_indirect_baseHi; | |
| 108 | + uint32_t disp_indirect_baseLo; | |
| 109 | + uint32_t disp_indirect_baseHi; | |
| 110 | + uint32_t gds_backup_addrlo; | |
| 111 | + uint32_t gds_backup_addrhi; | |
| 112 | + uint32_t index_base_addrlo; | |
| 113 | + uint32_t index_base_addrhi; | |
| 114 | + uint32_t sample_cntl; | |
| 115 | +}; /* Total of 27 DWORD */ | |
| 116 | + | |
| 117 | +struct amdgpu_gfx_meta_data | |
| 118 | +{ | |
| 119 | + /* 4 DWORD, address must be 4KB aligned */ | |
| 120 | + struct amdgpu_ce_ib_state ce_payload; | |
| 121 | + uint32_t reserved1[60]; | |
| 122 | + /* 17 DWORD, address must be 64B aligned */ | |
| 123 | + struct amdgpu_de_ib_state de_payload; | |
| 124 | + /* PFP IB base address which get pre-empted */ | |
| 125 | + uint32_t DeIbBaseAddrLo; | |
| 126 | + uint32_t DeIbBaseAddrHi; | |
| 127 | + uint32_t reserved2[941]; | |
| 128 | +}; /* Total of 4K Bytes */ | |
| 129 | + | |
| 130 | +struct amdgpu_gfx_meta_data_chained_ib | |
| 131 | +{ | |
| 132 | + /* 10 DWORD, address must be 4KB aligned */ | |
| 133 | + struct amdgpu_ce_ib_state_chained_ib ce_payload; | |
| 134 | + uint32_t reserved1[54]; | |
| 135 | + /* 27 DWORD, address must be 64B aligned */ | |
| 136 | + struct amdgpu_de_ib_state_chained_ib de_payload; | |
| 137 | + /* PFP IB base address which get pre-empted */ | |
| 138 | + uint32_t DeIbBaseAddrLo; | |
| 139 | + uint32_t DeIbBaseAddrHi; | |
| 140 | + uint32_t reserved2[931]; | |
| 141 | +}; /* Total of 4K Bytes */ | |
| 142 | + | |
| 31 | 143 | #endif |
| @@ -29,8 +29,4 @@ int cz_smu_init(struct amdgpu_device *adev); · 28 unmodified lines | ||
| 29 | 29 | int cz_smu_start(struct amdgpu_device *adev); |
| 30 | 30 | int cz_smu_fini(struct amdgpu_device *adev); |
| 31 | 31 | |
| 32 | −extern const struct amd_ip_funcs tonga_dpm_ip_funcs; | |
| 33 | −extern const struct amd_ip_funcs fiji_dpm_ip_funcs; | |
| 34 | −extern const struct amd_ip_funcs iceland_dpm_ip_funcs; | |
| 35 | − | |
| 36 | 32 | #endif |
| @@ -360,6 +360,8 @@ · 359 unmodified lines | ||
| 360 | 360 | #define PACKET3_WAIT_ON_CE_COUNTER 0x86 |
| 361 | 361 | #define PACKET3_WAIT_ON_DE_COUNTER_DIFF 0x88 |
| 362 | 362 | #define PACKET3_SWITCH_BUFFER 0x8B |
| 363 | +#define PACKET3_SET_RESOURCES 0xA0 | |
| 364 | +#define PACKET3_MAP_QUEUES 0xA2 | |
| 363 | 365 | |
| 364 | 366 | #define VCE_CMD_NO_OP 0x00000000 |
| 365 | 367 | #define VCE_CMD_END 0x00000001 |
| @@ -80,6 +80,18 @@ enum amd_clockgating_state { · 79 unmodified lines | ||
| 80 | 80 | AMD_CG_STATE_UNGATE, |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | +enum amd_dpm_forced_level { | |
| 84 | + AMD_DPM_FORCED_LEVEL_AUTO = 0x1, | |
| 85 | + AMD_DPM_FORCED_LEVEL_MANUAL = 0x2, | |
| 86 | + AMD_DPM_FORCED_LEVEL_LOW = 0x4, | |
| 87 | + AMD_DPM_FORCED_LEVEL_HIGH = 0x8, | |
| 88 | + AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD = 0x10, | |
| 89 | + AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK = 0x20, | |
| 90 | + AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK = 0x40, | |
| 91 | + AMD_DPM_FORCED_LEVEL_PROFILE_PEAK = 0x80, | |
| 92 | + AMD_DPM_FORCED_LEVEL_PROFILE_EXIT = 0x100, | |
| 93 | +}; | |
| 94 | + | |
| 83 | 95 | enum amd_powergating_state { |
| 84 | 96 | AMD_PG_STATE_GATE = 0, |
| 85 | 97 | AMD_PG_STATE_UNGATE, |
| @@ -206,6 +218,8 @@ struct amd_ip_funcs { · 120 unmodified lines | ||
| 206 | 218 | /* enable/disable pg for the IP block */ |
| 207 | 219 | int (*set_powergating_state)(void *handle, |
| 208 | 220 | enum amd_powergating_state state); |
| 221 | + /* get current clockgating status */ | |
| 222 | + void (*get_clockgating_state)(void *handle, u32 *flags); | |
| 209 | 223 | }; |
| 210 | 224 | |
| 211 | 225 | #endif /* __AMD_SHARED_H__ */ |
| @@ -4552,6 +4552,14 @@ · 4551 unmodified lines | ||
| 4552 | 4552 | #define mmDP4_DP_DPHY_PRBS_CNTL 0x4eb5 |
| 4553 | 4553 | #define mmDP5_DP_DPHY_PRBS_CNTL 0x4fb5 |
| 4554 | 4554 | #define mmDP6_DP_DPHY_PRBS_CNTL 0x54b5 |
| 4555 | +#define mmDP_DPHY_SCRAM_CNTL 0x4ab6 | |
| 4556 | +#define mmDP0_DP_DPHY_SCRAM_CNTL 0x4ab6 | |
| 4557 | +#define mmDP1_DP_DPHY_SCRAM_CNTL 0x4bb6 | |
| 4558 | +#define mmDP2_DP_DPHY_SCRAM_CNTL 0x4cb6 | |
| 4559 | +#define mmDP3_DP_DPHY_SCRAM_CNTL 0x4db6 | |
| 4560 | +#define mmDP4_DP_DPHY_SCRAM_CNTL 0x4eb6 | |
| 4561 | +#define mmDP5_DP_DPHY_SCRAM_CNTL 0x4fb6 | |
| 4562 | +#define mmDP6_DP_DPHY_SCRAM_CNTL 0x54b6 | |
| 4555 | 4563 | #define mmDP_DPHY_CRC_EN 0x4ab7 |
| 4556 | 4564 | #define mmDP0_DP_DPHY_CRC_EN 0x4ab7 |
| 4557 | 4565 | #define mmDP1_DP_DPHY_CRC_EN 0x4bb7 |
| @@ -8690,6 +8690,10 @@ · 8689 unmodified lines | ||
| 8690 | 8690 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEL__SHIFT 0x4 |
| 8691 | 8691 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEED_MASK 0x7fffff00 |
| 8692 | 8692 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEED__SHIFT 0x8 |
| 8693 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_ADVANCE_MASK 0x10 | |
| 8694 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_ADVANCE__SHIFT 0x4 | |
| 8695 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_BS_COUNT_MASK 0x3ff00 | |
| 8696 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_BS_COUNT__SHIFT 0x8 | |
| 8693 | 8697 | #define DP_DPHY_CRC_EN__DPHY_CRC_EN_MASK 0x1 |
| 8694 | 8698 | #define DP_DPHY_CRC_EN__DPHY_CRC_EN__SHIFT 0x0 |
| 8695 | 8699 | #define DP_DPHY_CRC_EN__DPHY_CRC_CONT_EN_MASK 0x10 |
| @@ -4544,6 +4544,15 @@ · 4543 unmodified lines | ||
| 4544 | 4544 | #define mmDP6_DP_DPHY_PRBS_CNTL 0x54b5 |
| 4545 | 4545 | #define mmDP7_DP_DPHY_PRBS_CNTL 0x56b5 |
| 4546 | 4546 | #define mmDP8_DP_DPHY_PRBS_CNTL 0x57b5 |
| 4547 | +#define mmDP_DPHY_SCRAM_CNTL 0x4ab6 | |
| 4548 | +#define mmDP0_DP_DPHY_SCRAM_CNTL 0x4ab6 | |
| 4549 | +#define mmDP1_DP_DPHY_SCRAM_CNTL 0x4bb6 | |
| 4550 | +#define mmDP2_DP_DPHY_SCRAM_CNTL 0x4cb6 | |
| 4551 | +#define mmDP3_DP_DPHY_SCRAM_CNTL 0x4db6 | |
| 4552 | +#define mmDP4_DP_DPHY_SCRAM_CNTL 0x4eb6 | |
| 4553 | +#define mmDP5_DP_DPHY_SCRAM_CNTL 0x4fb6 | |
| 4554 | +#define mmDP6_DP_DPHY_SCRAM_CNTL 0x54b6 | |
| 4555 | +#define mmDP8_DP_DPHY_SCRAM_CNTL 0x56b6 | |
| 4547 | 4556 | #define mmDP_DPHY_BS_SR_SWAP_CNTL 0x4adc |
| 4548 | 4557 | #define mmDP0_DP_DPHY_BS_SR_SWAP_CNTL 0x4adc |
| 4549 | 4558 | #define mmDP1_DP_DPHY_BS_SR_SWAP_CNTL 0x4bdc |
| @@ -6004,6 +6004,8 @@ · 6003 unmodified lines | ||
| 6004 | 6004 | #define DIG_DISPCLK_SWITCH_STATUS__DIG_DISPCLK_SWITCH_ALLOWED_INT_MASK__SHIFT 0xc |
| 6005 | 6005 | #define HDMI_CONTROL__HDMI_KEEPOUT_MODE_MASK 0x1 |
| 6006 | 6006 | #define HDMI_CONTROL__HDMI_KEEPOUT_MODE__SHIFT 0x0 |
| 6007 | +#define HDMI_CONTROL__HDMI_DATA_SCRAMBLE_EN_MASK 0x2 | |
| 6008 | +#define HDMI_CONTROL__HDMI_DATA_SCRAMBLE_EN__SHIFT 0x1 | |
| 6007 | 6009 | #define HDMI_CONTROL__HDMI_CLOCK_CHANNEL_RATE_MASK 0x4 |
| 6008 | 6010 | #define HDMI_CONTROL__HDMI_CLOCK_CHANNEL_RATE__SHIFT 0x2 |
| 6009 | 6011 | #define HDMI_CONTROL__HDMI_NO_EXTRA_NULL_PACKET_FILLED_MASK 0x8 |
| @@ -8364,6 +8366,10 @@ · 2354 unmodified lines | ||
| 8364 | 8366 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEL__SHIFT 0x4 |
| 8365 | 8367 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEED_MASK 0x7fffff00 |
| 8366 | 8368 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEED__SHIFT 0x8 |
| 8369 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_ADVANCE_MASK 0x10 | |
| 8370 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_ADVANCE__SHIFT 0x4 | |
| 8371 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_BS_COUNT_MASK 0x3ff00 | |
| 8372 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_BS_COUNT__SHIFT 0x8 | |
| 8367 | 8373 | #define DP_DPHY_BS_SR_SWAP_CNTL__DPHY_LOAD_BS_COUNT_MASK 0x3ff |
| 8368 | 8374 | #define DP_DPHY_BS_SR_SWAP_CNTL__DPHY_LOAD_BS_COUNT__SHIFT 0x0 |
| 8369 | 8375 | #define DP_DPHY_BS_SR_SWAP_CNTL__DPHY_BS_SR_SWAP_DONE_MASK 0x8000 |
| @@ -5776,6 +5776,15 @@ · 5775 unmodified lines | ||
| 5776 | 5776 | #define mmDP6_DP_DPHY_PRBS_CNTL 0x54b5 |
| 5777 | 5777 | #define mmDP7_DP_DPHY_PRBS_CNTL 0x56b5 |
| 5778 | 5778 | #define mmDP8_DP_DPHY_PRBS_CNTL 0x57b5 |
| 5779 | +#define mmDP_DPHY_SCRAM_CNTL 0x4ab6 | |
| 5780 | +#define mmDP0_DP_DPHY_SCRAM_CNTL 0x4ab6 | |
| 5781 | +#define mmDP1_DP_DPHY_SCRAM_CNTL 0x4bb6 | |
| 5782 | +#define mmDP2_DP_DPHY_SCRAM_CNTL 0x4cb6 | |
| 5783 | +#define mmDP3_DP_DPHY_SCRAM_CNTL 0x4db6 | |
| 5784 | +#define mmDP4_DP_DPHY_SCRAM_CNTL 0x4eb6 | |
| 5785 | +#define mmDP5_DP_DPHY_SCRAM_CNTL 0x4fb6 | |
| 5786 | +#define mmDP6_DP_DPHY_SCRAM_CNTL 0x54b6 | |
| 5787 | +#define mmDP8_DP_DPHY_SCRAM_CNTL 0x56b6 | |
| 5779 | 5788 | #define mmDP_DPHY_BS_SR_SWAP_CNTL 0x4adc |
| 5780 | 5789 | #define mmDP0_DP_DPHY_BS_SR_SWAP_CNTL 0x4adc |
| 5781 | 5790 | #define mmDP1_DP_DPHY_BS_SR_SWAP_CNTL 0x4bdc |
| @@ -7088,6 +7088,8 @@ · 7087 unmodified lines | ||
| 7088 | 7088 | #define DIG_DISPCLK_SWITCH_STATUS__DIG_DISPCLK_SWITCH_ALLOWED_INT_MASK__SHIFT 0xc |
| 7089 | 7089 | #define HDMI_CONTROL__HDMI_KEEPOUT_MODE_MASK 0x1 |
| 7090 | 7090 | #define HDMI_CONTROL__HDMI_KEEPOUT_MODE__SHIFT 0x0 |
| 7091 | +#define HDMI_CONTROL__HDMI_DATA_SCRAMBLE_EN_MASK 0x2 | |
| 7092 | +#define HDMI_CONTROL__HDMI_DATA_SCRAMBLE_EN__SHIFT 0x1 | |
| 7091 | 7093 | #define HDMI_CONTROL__HDMI_CLOCK_CHANNEL_RATE_MASK 0x4 |
| 7092 | 7094 | #define HDMI_CONTROL__HDMI_CLOCK_CHANNEL_RATE__SHIFT 0x2 |
| 7093 | 7095 | #define HDMI_CONTROL__HDMI_NO_EXTRA_NULL_PACKET_FILLED_MASK 0x8 |
| @@ -9626,6 +9628,10 @@ · 2532 unmodified lines | ||
| 9626 | 9628 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEL__SHIFT 0x4 |
| 9627 | 9629 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEED_MASK 0x7fffff00 |
| 9628 | 9630 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEED__SHIFT 0x8 |
| 9631 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_ADVANCE_MASK 0x10 | |
| 9632 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_ADVANCE__SHIFT 0x4 | |
| 9633 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_BS_COUNT_MASK 0x3ff00 | |
| 9634 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_BS_COUNT__SHIFT 0x8 | |
| 9629 | 9635 | #define DP_DPHY_BS_SR_SWAP_CNTL__DPHY_LOAD_BS_COUNT_MASK 0x3ff |
| 9630 | 9636 | #define DP_DPHY_BS_SR_SWAP_CNTL__DPHY_LOAD_BS_COUNT__SHIFT 0x0 |
| 9631 | 9637 | #define DP_DPHY_BS_SR_SWAP_CNTL__DPHY_BS_SR_SWAP_DONE_MASK 0x8000 |
| @@ -3920,6 +3920,14 @@ · 3919 unmodified lines | ||
| 3920 | 3920 | #define mmDP4_DP_DPHY_PRBS_CNTL 0x48d4 |
| 3921 | 3921 | #define mmDP5_DP_DPHY_PRBS_CNTL 0x4bd4 |
| 3922 | 3922 | #define mmDP6_DP_DPHY_PRBS_CNTL 0x4ed4 |
| 3923 | +#define mmDP_DPHY_SCRAM_CNTL 0x1cd5 | |
| 3924 | +#define mmDP0_DP_DPHY_SCRAM_CNTL 0x1cd5 | |
| 3925 | +#define mmDP1_DP_DPHY_SCRAM_CNTL 0x1fd5 | |
| 3926 | +#define mmDP2_DP_DPHY_SCRAM_CNTL 0x42d5 | |
| 3927 | +#define mmDP3_DP_DPHY_SCRAM_CNTL 0x45d5 | |
| 3928 | +#define mmDP4_DP_DPHY_SCRAM_CNTL 0x48d5 | |
| 3929 | +#define mmDP5_DP_DPHY_SCRAM_CNTL 0x4bd5 | |
| 3930 | +#define mmDP6_DP_DPHY_SCRAM_CNTL 0x4ed5 | |
| 3923 | 3931 | #define mmDP_DPHY_CRC_EN 0x1cd6 |
| 3924 | 3932 | #define mmDP0_DP_DPHY_CRC_EN 0x1cd6 |
| 3925 | 3933 | #define mmDP1_DP_DPHY_CRC_EN 0x1fd6 |
| @@ -9214,6 +9214,10 @@ · 9213 unmodified lines | ||
| 9214 | 9214 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEL__SHIFT 0x4 |
| 9215 | 9215 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEED_MASK 0x7fffff00 |
| 9216 | 9216 | #define DP_DPHY_PRBS_CNTL__DPHY_PRBS_SEED__SHIFT 0x8 |
| 9217 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_ADVANCE_MASK 0x10 | |
| 9218 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_ADVANCE__SHIFT 0x4 | |
| 9219 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_BS_COUNT_MASK 0x3ff00 | |
| 9220 | +#define DP_DPHY_SCRAM_CNTL__DPHY_SCRAMBLER_BS_COUNT__SHIFT 0x8 | |
| 9217 | 9221 | #define DP_DPHY_CRC_EN__DPHY_CRC_EN_MASK 0x1 |
| 9218 | 9222 | #define DP_DPHY_CRC_EN__DPHY_CRC_EN__SHIFT 0x0 |
| 9219 | 9223 | #define DP_DPHY_CRC_EN__DPHY_CRC_CONT_EN_MASK 0x10 |
| @@ -1,105 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright 2010 Advanced Micro Devices, Inc. | |
| 3 | − * | |
| 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: | |
| 10 | − * | |
| 11 | − * The above copyright notice and this permission notice shall be included in | |
| 12 | − * all copies or substantial portions of the Software. | |
| 13 | − * | |
| 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. | |
| 21 | − * | |
| 22 | − * Authors: Alex Deucher | |
| 23 | − */ | |
| 24 | −#ifndef __SI_REG_H__ | |
| 25 | −#define __SI_REG_H__ | |
| 26 | − | |
| 27 | −/* SI */ | |
| 28 | −#define SI_DC_GPIO_HPD_MASK 0x196c | |
| 29 | −#define SI_DC_GPIO_HPD_A 0x196d | |
| 30 | −#define SI_DC_GPIO_HPD_EN 0x196e | |
| 31 | −#define SI_DC_GPIO_HPD_Y 0x196f | |
| 32 | − | |
| 33 | −#define SI_GRPH_CONTROL 0x1a01 | |
| 34 | −# define SI_GRPH_DEPTH(x) (((x) & 0x3) << 0) | |
| 35 | −# define SI_GRPH_DEPTH_8BPP 0 | |
| 36 | −# define SI_GRPH_DEPTH_16BPP 1 | |
| 37 | −# define SI_GRPH_DEPTH_32BPP 2 | |
| 38 | −# define SI_GRPH_NUM_BANKS(x) (((x) & 0x3) << 2) | |
| 39 | −# define SI_ADDR_SURF_2_BANK 0 | |
| 40 | −# define SI_ADDR_SURF_4_BANK 1 | |
| 41 | −# define SI_ADDR_SURF_8_BANK 2 | |
| 42 | −# define SI_ADDR_SURF_16_BANK 3 | |
| 43 | −# define SI_GRPH_Z(x) (((x) & 0x3) << 4) | |
| 44 | −# define SI_GRPH_BANK_WIDTH(x) (((x) & 0x3) << 6) | |
| 45 | −# define SI_ADDR_SURF_BANK_WIDTH_1 0 | |
| 46 | −# define SI_ADDR_SURF_BANK_WIDTH_2 1 | |
| 47 | −# define SI_ADDR_SURF_BANK_WIDTH_4 2 | |
| 48 | −# define SI_ADDR_SURF_BANK_WIDTH_8 3 | |
| 49 | −# define SI_GRPH_FORMAT(x) (((x) & 0x7) << 8) | |
| 50 | −/* 8 BPP */ | |
| 51 | −# define SI_GRPH_FORMAT_INDEXED 0 | |
| 52 | −/* 16 BPP */ | |
| 53 | −# define SI_GRPH_FORMAT_ARGB1555 0 | |
| 54 | −# define SI_GRPH_FORMAT_ARGB565 1 | |
| 55 | −# define SI_GRPH_FORMAT_ARGB4444 2 | |
| 56 | −# define SI_GRPH_FORMAT_AI88 3 | |
| 57 | −# define SI_GRPH_FORMAT_MONO16 4 | |
| 58 | −# define SI_GRPH_FORMAT_BGRA5551 5 | |
| 59 | −/* 32 BPP */ | |
| 60 | −# define SI_GRPH_FORMAT_ARGB8888 0 | |
| 61 | −# define SI_GRPH_FORMAT_ARGB2101010 1 | |
| 62 | −# define SI_GRPH_FORMAT_32BPP_DIG 2 | |
| 63 | −# define SI_GRPH_FORMAT_8B_ARGB2101010 3 | |
| 64 | −# define SI_GRPH_FORMAT_BGRA1010102 4 | |
| 65 | −# define SI_GRPH_FORMAT_8B_BGRA1010102 5 | |
| 66 | −# define SI_GRPH_FORMAT_RGB111110 6 | |
| 67 | −# define SI_GRPH_FORMAT_BGR101111 7 | |
| 68 | −# define SI_GRPH_BANK_HEIGHT(x) (((x) & 0x3) << 11) | |
| 69 | −# define SI_ADDR_SURF_BANK_HEIGHT_1 0 | |
| 70 | −# define SI_ADDR_SURF_BANK_HEIGHT_2 1 | |
| 71 | −# define SI_ADDR_SURF_BANK_HEIGHT_4 2 | |
| 72 | −# define SI_ADDR_SURF_BANK_HEIGHT_8 3 | |
| 73 | −# define SI_GRPH_TILE_SPLIT(x) (((x) & 0x7) << 13) | |
| 74 | −# define SI_ADDR_SURF_TILE_SPLIT_64B 0 | |
| 75 | −# define SI_ADDR_SURF_TILE_SPLIT_128B 1 | |
| 76 | −# define SI_ADDR_SURF_TILE_SPLIT_256B 2 | |
| 77 | −# define SI_ADDR_SURF_TILE_SPLIT_512B 3 | |
| 78 | −# define SI_ADDR_SURF_TILE_SPLIT_1KB 4 | |
| 79 | −# define SI_ADDR_SURF_TILE_SPLIT_2KB 5 | |
| 80 | −# define SI_ADDR_SURF_TILE_SPLIT_4KB 6 | |
| 81 | −# define SI_GRPH_MACRO_TILE_ASPECT(x) (((x) & 0x3) << 18) | |
| 82 | −# define SI_ADDR_SURF_MACRO_TILE_ASPECT_1 0 | |
| 83 | −# define SI_ADDR_SURF_MACRO_TILE_ASPECT_2 1 | |
| 84 | −# define SI_ADDR_SURF_MACRO_TILE_ASPECT_4 2 | |
| 85 | −# define SI_ADDR_SURF_MACRO_TILE_ASPECT_8 3 | |
| 86 | −# define SI_GRPH_ARRAY_MODE(x) (((x) & 0x7) << 20) | |
| 87 | −# define SI_GRPH_ARRAY_LINEAR_GENERAL 0 | |
| 88 | −# define SI_GRPH_ARRAY_LINEAR_ALIGNED 1 | |
| 89 | −# define SI_GRPH_ARRAY_1D_TILED_THIN1 2 | |
| 90 | −# define SI_GRPH_ARRAY_2D_TILED_THIN1 4 | |
| 91 | −# define SI_GRPH_PIPE_CONFIG(x) (((x) & 0x1f) << 24) | |
| 92 | −# define SI_ADDR_SURF_P2 0 | |
| 93 | −# define SI_ADDR_SURF_P4_8x16 4 | |
| 94 | −# define SI_ADDR_SURF_P4_16x16 5 | |
| 95 | −# define SI_ADDR_SURF_P4_16x32 6 | |
| 96 | −# define SI_ADDR_SURF_P4_32x32 7 | |
| 97 | −# define SI_ADDR_SURF_P8_16x16_8x16 8 | |
| 98 | −# define SI_ADDR_SURF_P8_16x32_8x16 9 | |
| 99 | −# define SI_ADDR_SURF_P8_32x32_8x16 10 | |
| 100 | −# define SI_ADDR_SURF_P8_16x32_16x16 11 | |
| 101 | −# define SI_ADDR_SURF_P8_32x32_16x16 12 | |
| 102 | −# define SI_ADDR_SURF_P8_32x32_16x32 13 | |
| 103 | −# define SI_ADDR_SURF_P8_32x64_32x32 14 | |
| 104 | − | |
| 105 | −#endif | |
| @@ -622,6 +622,8 @@ typedef int (*cgs_query_system_info)(struct cgs_device *cgs_device, · 621 unmodified lines | ||
| 622 | 622 | |
| 623 | 623 | typedef int (*cgs_is_virtualization_enabled_t)(void *cgs_device); |
| 624 | 624 | |
| 625 | +typedef int (*cgs_enter_safe_mode)(struct cgs_device *cgs_device, bool en); | |
| 626 | + | |
| 625 | 627 | struct cgs_ops { |
| 626 | 628 | /* memory management calls (similar to KFD interface) */ |
| 627 | 629 | cgs_gpu_mem_info_t gpu_mem_info; |
| @@ -674,6 +676,7 @@ struct cgs_ops { · 46 unmodified lines | ||
| 674 | 676 | /* get system info */ |
| 675 | 677 | cgs_query_system_info query_system_info; |
| 676 | 678 | cgs_is_virtualization_enabled_t is_virtualization_enabled; |
| 679 | + cgs_enter_safe_mode enter_safe_mode; | |
| 677 | 680 | }; |
| 678 | 681 | |
| 679 | 682 | struct cgs_os_ops; /* To be define in OS-specific CGS header */ |
| @@ -779,4 +782,8 @@ struct cgs_device · 99 unmodified lines | ||
| 779 | 782 | |
| 780 | 783 | #define cgs_is_virtualization_enabled(cgs_device) \ |
| 781 | 784 | CGS_CALL(is_virtualization_enabled, cgs_device) |
| 785 | + | |
| 786 | +#define cgs_enter_safe_mode(cgs_device, en) \ | |
| 787 | + CGS_CALL(enter_safe_mode, cgs_device, en) | |
| 788 | + | |
| 782 | 789 | #endif /* _CGS_COMMON_H */ |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | +#include "pp_debug.h" | |
| 23 | 24 | #include <linux/types.h> |
| 24 | 25 | #include <linux/kernel.h> |
| 25 | 26 | #include <linux/gfp.h> |
| @@ -29,153 +30,154 @@ · 3 unmodified lines | ||
| 29 | 30 | #include "pp_instance.h" |
| 30 | 31 | #include "power_state.h" |
| 31 | 32 | #include "eventmanager.h" |
| 32 | −#include "pp_debug.h" | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | −#define PP_CHECK(handle) \ | |
| 36 | − do { \ | |
| 37 | − if ((handle) == NULL || (handle)->pp_valid != PP_VALID) \ | |
| 38 | − return -EINVAL; \ | |
| 39 | − } while (0) | |
| 35 | +static inline int pp_check(struct pp_instance *handle) | |
| 36 | +{ | |
| 37 | + if (handle == NULL || handle->pp_valid != PP_VALID) | |
| 38 | + return -EINVAL; | |
| 40 | 39 | |
| 41 | −#define PP_CHECK_HW(hwmgr) \ | |
| 42 | − do { \ | |
| 43 | − if ((hwmgr) == NULL || (hwmgr)->hwmgr_func == NULL) \ | |
| 44 | − return 0; \ | |
| 45 | − } while (0) | |
| 40 | + if (handle->smu_mgr == NULL || handle->smu_mgr->smumgr_funcs == NULL) | |
| 41 | + return -EINVAL; | |
| 42 | + | |
| 43 | + if (handle->pm_en == 0) | |
| 44 | + return PP_DPM_DISABLED; | |
| 45 | + | |
| 46 | + if (handle->hwmgr == NULL || handle->hwmgr->hwmgr_func == NULL | |
| 47 | + || handle->eventmgr == NULL) | |
| 48 | + return PP_DPM_DISABLED; | |
| 49 | + | |
| 50 | + return 0; | |
| 51 | +} | |
| 46 | 52 | |
| 47 | 53 | static int pp_early_init(void *handle) |
| 48 | 54 | { |
| 55 | + int ret; | |
| 56 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 57 | + | |
| 58 | + ret = smum_early_init(pp_handle); | |
| 59 | + if (ret) | |
| 60 | + return ret; | |
| 61 | + | |
| 62 | + if ((pp_handle->pm_en == 0) | |
| 63 | + || cgs_is_virtualization_enabled(pp_handle->device)) | |
| 64 | + return PP_DPM_DISABLED; | |
| 65 | + | |
| 66 | + ret = hwmgr_early_init(pp_handle); | |
| 67 | + if (ret) { | |
| 68 | + pp_handle->pm_en = 0; | |
| 69 | + return PP_DPM_DISABLED; | |
| 70 | + } | |
| 71 | + | |
| 72 | + ret = eventmgr_early_init(pp_handle); | |
| 73 | + if (ret) { | |
| 74 | + kfree(pp_handle->hwmgr); | |
| 75 | + pp_handle->hwmgr = NULL; | |
| 76 | + pp_handle->pm_en = 0; | |
| 77 | + return PP_DPM_DISABLED; | |
| 78 | + } | |
| 79 | + | |
| 49 | 80 | return 0; |
| 50 | 81 | } |
| 51 | 82 | |
| 52 | 83 | static int pp_sw_init(void *handle) |
| 53 | 84 | { |
| 54 | − struct pp_instance *pp_handle; | |
| 55 | − struct pp_hwmgr *hwmgr; | |
| 85 | + struct pp_smumgr *smumgr; | |
| 56 | 86 | int ret = 0; |
| 87 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 57 | 88 | |
| 58 | − if (handle == NULL) | |
| 59 | − return -EINVAL; | |
| 60 | − | |
| 61 | − pp_handle = (struct pp_instance *)handle; | |
| 62 | − hwmgr = pp_handle->hwmgr; | |
| 63 | − | |
| 64 | − PP_CHECK_HW(hwmgr); | |
| 65 | − | |
| 66 | − if (hwmgr->pptable_func == NULL || | |
| 67 | − hwmgr->pptable_func->pptable_init == NULL || | |
| 68 | − hwmgr->hwmgr_func->backend_init == NULL) | |
| 69 | − return -EINVAL; | |
| 89 | + ret = pp_check(pp_handle); | |
| 70 | 90 | |
| 71 | − ret = hwmgr->pptable_func->pptable_init(hwmgr); | |
| 72 | − if (ret) | |
| 73 | − goto err; | |
| 91 | + if (ret == 0 || ret == PP_DPM_DISABLED) { | |
| 92 | + smumgr = pp_handle->smu_mgr; | |
| 74 | 93 | |
| 75 | − ret = hwmgr->hwmgr_func->backend_init(hwmgr); | |
| 76 | − if (ret) | |
| 77 | − goto err1; | |
| 94 | + if (smumgr->smumgr_funcs->smu_init == NULL) | |
| 95 | + return -EINVAL; | |
| 78 | 96 | |
| 79 | − pr_info("amdgpu: powerplay initialized\n"); | |
| 97 | + ret = smumgr->smumgr_funcs->smu_init(smumgr); | |
| 80 | 98 | |
| 81 | − return 0; | |
| 82 | −err1: | |
| 83 | − if (hwmgr->pptable_func->pptable_fini) | |
| 84 | − hwmgr->pptable_func->pptable_fini(hwmgr); | |
| 85 | −err: | |
| 86 | − pr_err("amdgpu: powerplay initialization failed\n"); | |
| 99 | + pr_info("amdgpu: powerplay sw initialized\n"); | |
| 100 | + } | |
| 87 | 101 | return ret; |
| 88 | 102 | } |
| 89 | 103 | |
| 90 | 104 | static int pp_sw_fini(void *handle) |
| 91 | 105 | { |
| 92 | − struct pp_instance *pp_handle; | |
| 93 | − struct pp_hwmgr *hwmgr; | |
| 106 | + struct pp_smumgr *smumgr; | |
| 94 | 107 | int ret = 0; |
| 108 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 95 | 109 | |
| 96 | − if (handle == NULL) | |
| 97 | − return -EINVAL; | |
| 110 | + ret = pp_check(pp_handle); | |
| 111 | + if (ret == 0 || ret == PP_DPM_DISABLED) { | |
| 112 | + smumgr = pp_handle->smu_mgr; | |
| 98 | 113 | |
| 99 | − pp_handle = (struct pp_instance *)handle; | |
| 100 | − hwmgr = pp_handle->hwmgr; | |
| 101 | − | |
| 102 | − PP_CHECK_HW(hwmgr); | |
| 103 | − | |
| 104 | − if (hwmgr->hwmgr_func->backend_fini != NULL) | |
| 105 | − ret = hwmgr->hwmgr_func->backend_fini(hwmgr); | |
| 106 | − | |
| 107 | − if (hwmgr->pptable_func->pptable_fini) | |
| 108 | − hwmgr->pptable_func->pptable_fini(hwmgr); | |
| 114 | + if (smumgr->smumgr_funcs->smu_fini == NULL) | |
| 115 | + return -EINVAL; | |
| 109 | 116 | |
| 117 | + ret = smumgr->smumgr_funcs->smu_fini(smumgr); | |
| 118 | + } | |
| 110 | 119 | return ret; |
| 111 | 120 | } |
| 112 | 121 | |
| 113 | 122 | static int pp_hw_init(void *handle) |
| 114 | 123 | { |
| 115 | − struct pp_instance *pp_handle; | |
| 116 | 124 | struct pp_smumgr *smumgr; |
| 117 | 125 | struct pp_eventmgr *eventmgr; |
| 118 | − struct pp_hwmgr *hwmgr; | |
| 119 | 126 | int ret = 0; |
| 127 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 120 | 128 | |
| 121 | − if (handle == NULL) | |
| 122 | − return -EINVAL; | |
| 129 | + ret = pp_check(pp_handle); | |
| 123 | 130 | |
| 124 | − pp_handle = (struct pp_instance *)handle; | |
| 125 | − smumgr = pp_handle->smu_mgr; | |
| 126 | − hwmgr = pp_handle->hwmgr; | |
| 131 | + if (ret == 0 || ret == PP_DPM_DISABLED) { | |
| 132 | + smumgr = pp_handle->smu_mgr; | |
| 127 | 133 | |
| 128 | − if (smumgr == NULL || smumgr->smumgr_funcs == NULL || | |
| 129 | − smumgr->smumgr_funcs->smu_init == NULL || | |
| 130 | − smumgr->smumgr_funcs->start_smu == NULL) | |
| 131 | − return -EINVAL; | |
| 132 | − | |
| 133 | − ret = smumgr->smumgr_funcs->smu_init(smumgr); | |
| 134 | − if (ret) { | |
| 135 | − printk(KERN_ERR "[ powerplay ] smc initialization failed\n"); | |
| 136 | − return ret; | |
| 137 | − } | |
| 134 | + if (smumgr->smumgr_funcs->start_smu == NULL) | |
| 135 | + return -EINVAL; | |
| 138 | 136 | |
| 139 | − ret = smumgr->smumgr_funcs->start_smu(smumgr); | |
| 140 | − if (ret) { | |
| 141 | − printk(KERN_ERR "[ powerplay ] smc start failed\n"); | |
| 142 | − smumgr->smumgr_funcs->smu_fini(smumgr); | |
| 143 | − return ret; | |
| 137 | + if(smumgr->smumgr_funcs->start_smu(smumgr)) { | |
| 138 | + pr_err("smc start failed\n"); | |
| 139 | + smumgr->smumgr_funcs->smu_fini(smumgr); | |
| 140 | + return -EINVAL;; | |
| 141 | + } | |
| 142 | + if (ret == PP_DPM_DISABLED) | |
| 143 | + return PP_DPM_DISABLED; | |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | − PP_CHECK_HW(hwmgr); | |
| 147 | − | |
| 148 | − hw_init_power_state_table(hwmgr); | |
| 146 | + ret = hwmgr_hw_init(pp_handle); | |
| 147 | + if (ret) | |
| 148 | + goto err; | |
| 149 | 149 | |
| 150 | 150 | eventmgr = pp_handle->eventmgr; |
| 151 | − if (eventmgr == NULL || eventmgr->pp_eventmgr_init == NULL) | |
| 152 | − return -EINVAL; | |
| 151 | + if (eventmgr->pp_eventmgr_init == NULL || | |
| 152 | + eventmgr->pp_eventmgr_init(eventmgr)) | |
| 153 | + goto err; | |
| 153 | 154 | |
| 154 | − ret = eventmgr->pp_eventmgr_init(eventmgr); | |
| 155 | 155 | return 0; |
| 156 | +err: | |
| 157 | + pp_handle->pm_en = 0; | |
| 158 | + kfree(pp_handle->eventmgr); | |
| 159 | + kfree(pp_handle->hwmgr); | |
| 160 | + pp_handle->hwmgr = NULL; | |
| 161 | + pp_handle->eventmgr = NULL; | |
| 162 | + return PP_DPM_DISABLED; | |
| 156 | 163 | } |
| 157 | 164 | |
| 158 | 165 | static int pp_hw_fini(void *handle) |
| 159 | 166 | { |
| 160 | − struct pp_instance *pp_handle; | |
| 161 | − struct pp_smumgr *smumgr; | |
| 162 | 167 | struct pp_eventmgr *eventmgr; |
| 168 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 169 | + int ret = 0; | |
| 163 | 170 | |
| 164 | − if (handle == NULL) | |
| 165 | − return -EINVAL; | |
| 166 | − | |
| 167 | − pp_handle = (struct pp_instance *)handle; | |
| 168 | − eventmgr = pp_handle->eventmgr; | |
| 171 | + ret = pp_check(pp_handle); | |
| 169 | 172 | |
| 170 | − if (eventmgr != NULL && eventmgr->pp_eventmgr_fini != NULL) | |
| 171 | − eventmgr->pp_eventmgr_fini(eventmgr); | |
| 173 | + if (ret == 0) { | |
| 174 | + eventmgr = pp_handle->eventmgr; | |
| 172 | 175 | |
| 173 | − smumgr = pp_handle->smu_mgr; | |
| 174 | − | |
| 175 | − if (smumgr != NULL && smumgr->smumgr_funcs != NULL && | |
| 176 | − smumgr->smumgr_funcs->smu_fini != NULL) | |
| 177 | − smumgr->smumgr_funcs->smu_fini(smumgr); | |
| 176 | + if (eventmgr->pp_eventmgr_fini != NULL) | |
| 177 | + eventmgr->pp_eventmgr_fini(eventmgr); | |
| 178 | 178 | |
| 179 | + hwmgr_hw_fini(pp_handle); | |
| 180 | + } | |
| 179 | 181 | return 0; |
| 180 | 182 | } |
| 181 | 183 | |
| @@ -198,16 +200,18 @@ static int pp_sw_reset(void *handle) · 16 unmodified lines | ||
| 198 | 200 | int amd_set_clockgating_by_smu(void *handle, uint32_t msg_id) |
| 199 | 201 | { |
| 200 | 202 | struct pp_hwmgr *hwmgr; |
| 203 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 204 | + int ret = 0; | |
| 201 | 205 | |
| 202 | − if (handle == NULL) | |
| 203 | − return -EINVAL; | |
| 206 | + ret = pp_check(pp_handle); | |
| 204 | 207 | |
| 205 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 208 | + if (ret != 0) | |
| 209 | + return ret; | |
| 206 | 210 | |
| 207 | − PP_CHECK_HW(hwmgr); | |
| 211 | + hwmgr = pp_handle->hwmgr; | |
| 208 | 212 | |
| 209 | 213 | if (hwmgr->hwmgr_func->update_clock_gatings == NULL) { |
| 210 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 214 | + pr_info("%s was not implemented.\n", __func__); | |
| 211 | 215 | return 0; |
| 212 | 216 | } |
| 213 | 217 | |
| @@ -218,16 +222,18 @@ static int pp_set_powergating_state(void *handle, · 4 unmodified lines | ||
| 218 | 222 | enum amd_powergating_state state) |
| 219 | 223 | { |
| 220 | 224 | struct pp_hwmgr *hwmgr; |
| 225 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 226 | + int ret = 0; | |
| 221 | 227 | |
| 222 | − if (handle == NULL) | |
| 223 | − return -EINVAL; | |
| 228 | + ret = pp_check(pp_handle); | |
| 224 | 229 | |
| 225 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 230 | + if (ret != 0) | |
| 231 | + return ret; | |
| 226 | 232 | |
| 227 | − PP_CHECK_HW(hwmgr); | |
| 233 | + hwmgr = pp_handle->hwmgr; | |
| 228 | 234 | |
| 229 | 235 | if (hwmgr->hwmgr_func->enable_per_cu_power_gating == NULL) { |
| 230 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 236 | + pr_info("%s was not implemented.\n", __func__); | |
| 231 | 237 | return 0; |
| 232 | 238 | } |
| 233 | 239 | |
| @@ -238,49 +244,53 @@ static int pp_set_powergating_state(void *handle, · 4 unmodified lines | ||
| 238 | 244 | |
| 239 | 245 | static int pp_suspend(void *handle) |
| 240 | 246 | { |
| 241 | − struct pp_instance *pp_handle; | |
| 242 | 247 | struct pp_eventmgr *eventmgr; |
| 243 | 248 | struct pem_event_data event_data = { {0} }; |
| 249 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 250 | + int ret = 0; | |
| 244 | 251 | |
| 245 | − if (handle == NULL) | |
| 246 | − return -EINVAL; | |
| 252 | + ret = pp_check(pp_handle); | |
| 253 | + | |
| 254 | + if (ret != 0) | |
| 255 | + return ret; | |
| 247 | 256 | |
| 248 | − pp_handle = (struct pp_instance *)handle; | |
| 249 | 257 | eventmgr = pp_handle->eventmgr; |
| 258 | + pem_handle_event(eventmgr, AMD_PP_EVENT_SUSPEND, &event_data); | |
| 250 | 259 | |
| 251 | − if (eventmgr != NULL) | |
| 252 | − pem_handle_event(eventmgr, AMD_PP_EVENT_SUSPEND, &event_data); | |
| 253 | 260 | return 0; |
| 254 | 261 | } |
| 255 | 262 | |
| 256 | 263 | static int pp_resume(void *handle) |
| 257 | 264 | { |
| 258 | − struct pp_instance *pp_handle; | |
| 259 | 265 | struct pp_eventmgr *eventmgr; |
| 260 | 266 | struct pem_event_data event_data = { {0} }; |
| 261 | 267 | struct pp_smumgr *smumgr; |
| 262 | − int ret; | |
| 268 | + int ret, ret1; | |
| 269 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 263 | 270 | |
| 264 | − if (handle == NULL) | |
| 265 | − return -EINVAL; | |
| 271 | + ret1 = pp_check(pp_handle); | |
| 272 | + | |
| 273 | + if (ret1 != 0 && ret1 != PP_DPM_DISABLED) | |
| 274 | + return ret1; | |
| 266 | 275 | |
| 267 | − pp_handle = (struct pp_instance *)handle; | |
| 268 | 276 | smumgr = pp_handle->smu_mgr; |
| 269 | 277 | |
| 270 | − if (smumgr == NULL || smumgr->smumgr_funcs == NULL || | |
| 271 | − smumgr->smumgr_funcs->start_smu == NULL) | |
| 278 | + if (smumgr->smumgr_funcs->start_smu == NULL) | |
| 272 | 279 | return -EINVAL; |
| 273 | 280 | |
| 274 | 281 | ret = smumgr->smumgr_funcs->start_smu(smumgr); |
| 275 | 282 | if (ret) { |
| 276 | − printk(KERN_ERR "[ powerplay ] smc start failed\n"); | |
| 283 | + pr_err("smc start failed\n"); | |
| 277 | 284 | smumgr->smumgr_funcs->smu_fini(smumgr); |
| 278 | 285 | return ret; |
| 279 | 286 | } |
| 280 | 287 | |
| 288 | + if (ret1 == PP_DPM_DISABLED) | |
| 289 | + return ret1; | |
| 290 | + | |
| 281 | 291 | eventmgr = pp_handle->eventmgr; |
| 282 | − if (eventmgr != NULL) | |
| 283 | − pem_handle_event(eventmgr, AMD_PP_EVENT_RESUME, &event_data); | |
| 292 | + | |
| 293 | + pem_handle_event(eventmgr, AMD_PP_EVENT_RESUME, &event_data); | |
| 284 | 294 | |
| 285 | 295 | return 0; |
| 286 | 296 | } |
| @@ -315,20 +325,19 @@ static int pp_dpm_fw_loading_complete(void *handle) · 28 unmodified lines | ||
| 315 | 325 | static int pp_dpm_force_performance_level(void *handle, |
| 316 | 326 | enum amd_dpm_forced_level level) |
| 317 | 327 | { |
| 318 | − struct pp_instance *pp_handle; | |
| 319 | 328 | struct pp_hwmgr *hwmgr; |
| 329 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 330 | + int ret = 0; | |
| 320 | 331 | |
| 321 | − if (handle == NULL) | |
| 322 | − return -EINVAL; | |
| 332 | + ret = pp_check(pp_handle); | |
| 323 | 333 | |
| 324 | − pp_handle = (struct pp_instance *)handle; | |
| 334 | + if (ret != 0) | |
| 335 | + return ret; | |
| 325 | 336 | |
| 326 | 337 | hwmgr = pp_handle->hwmgr; |
| 327 | 338 | |
| 328 | − PP_CHECK_HW(hwmgr); | |
| 329 | − | |
| 330 | 339 | if (hwmgr->hwmgr_func->force_dpm_level == NULL) { |
| 331 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 340 | + pr_info("%s was not implemented.\n", __func__); | |
| 332 | 341 | return 0; |
| 333 | 342 | } |
| 334 | 343 | |
| @@ -341,30 +350,34 @@ static enum amd_dpm_forced_level pp_dpm_get_performance_level( · 6 unmodified lines | ||
| 341 | 350 | void *handle) |
| 342 | 351 | { |
| 343 | 352 | struct pp_hwmgr *hwmgr; |
| 353 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 354 | + int ret = 0; | |
| 344 | 355 | |
| 345 | − if (handle == NULL) | |
| 346 | − return -EINVAL; | |
| 356 | + ret = pp_check(pp_handle); | |
| 347 | 357 | |
| 348 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 358 | + if (ret != 0) | |
| 359 | + return ret; | |
| 349 | 360 | |
| 350 | − PP_CHECK_HW(hwmgr); | |
| 361 | + hwmgr = pp_handle->hwmgr; | |
| 351 | 362 | |
| 352 | − return (((struct pp_instance *)handle)->hwmgr->dpm_level); | |
| 363 | + return hwmgr->dpm_level; | |
| 353 | 364 | } |
| 354 | 365 | |
| 355 | 366 | static int pp_dpm_get_sclk(void *handle, bool low) |
| 356 | 367 | { |
| 357 | 368 | struct pp_hwmgr *hwmgr; |
| 369 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 370 | + int ret = 0; | |
| 358 | 371 | |
| 359 | − if (handle == NULL) | |
| 360 | − return -EINVAL; | |
| 372 | + ret = pp_check(pp_handle); | |
| 361 | 373 | |
| 362 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 374 | + if (ret != 0) | |
| 375 | + return ret; | |
| 363 | 376 | |
| 364 | − PP_CHECK_HW(hwmgr); | |
| 377 | + hwmgr = pp_handle->hwmgr; | |
| 365 | 378 | |
| 366 | 379 | if (hwmgr->hwmgr_func->get_sclk == NULL) { |
| 367 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 380 | + pr_info("%s was not implemented.\n", __func__); | |
| 368 | 381 | return 0; |
| 369 | 382 | } |
| 370 | 383 | |
| @@ -374,16 +387,18 @@ static int pp_dpm_get_sclk(void *handle, bool low) · 3 unmodified lines | ||
| 374 | 387 | static int pp_dpm_get_mclk(void *handle, bool low) |
| 375 | 388 | { |
| 376 | 389 | struct pp_hwmgr *hwmgr; |
| 390 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 391 | + int ret = 0; | |
| 377 | 392 | |
| 378 | − if (handle == NULL) | |
| 379 | − return -EINVAL; | |
| 393 | + ret = pp_check(pp_handle); | |
| 380 | 394 | |
| 381 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 395 | + if (ret != 0) | |
| 396 | + return ret; | |
| 382 | 397 | |
| 383 | − PP_CHECK_HW(hwmgr); | |
| 398 | + hwmgr = pp_handle->hwmgr; | |
| 384 | 399 | |
| 385 | 400 | if (hwmgr->hwmgr_func->get_mclk == NULL) { |
| 386 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 401 | + pr_info("%s was not implemented.\n", __func__); | |
| 387 | 402 | return 0; |
| 388 | 403 | } |
| 389 | 404 | |
| @@ -393,16 +408,18 @@ static int pp_dpm_get_mclk(void *handle, bool low) · 3 unmodified lines | ||
| 393 | 408 | static int pp_dpm_powergate_vce(void *handle, bool gate) |
| 394 | 409 | { |
| 395 | 410 | struct pp_hwmgr *hwmgr; |
| 411 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 412 | + int ret = 0; | |
| 396 | 413 | |
| 397 | − if (handle == NULL) | |
| 398 | − return -EINVAL; | |
| 414 | + ret = pp_check(pp_handle); | |
| 399 | 415 | |
| 400 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 416 | + if (ret != 0) | |
| 417 | + return ret; | |
| 401 | 418 | |
| 402 | − PP_CHECK_HW(hwmgr); | |
| 419 | + hwmgr = pp_handle->hwmgr; | |
| 403 | 420 | |
| 404 | 421 | if (hwmgr->hwmgr_func->powergate_vce == NULL) { |
| 405 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 422 | + pr_info("%s was not implemented.\n", __func__); | |
| 406 | 423 | return 0; |
| 407 | 424 | } |
| 408 | 425 | |
| @@ -412,16 +429,18 @@ static int pp_dpm_powergate_vce(void *handle, bool gate) · 3 unmodified lines | ||
| 412 | 429 | static int pp_dpm_powergate_uvd(void *handle, bool gate) |
| 413 | 430 | { |
| 414 | 431 | struct pp_hwmgr *hwmgr; |
| 432 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 433 | + int ret = 0; | |
| 415 | 434 | |
| 416 | − if (handle == NULL) | |
| 417 | − return -EINVAL; | |
| 435 | + ret = pp_check(pp_handle); | |
| 418 | 436 | |
| 419 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 437 | + if (ret != 0) | |
| 438 | + return ret; | |
| 420 | 439 | |
| 421 | − PP_CHECK_HW(hwmgr); | |
| 440 | + hwmgr = pp_handle->hwmgr; | |
| 422 | 441 | |
| 423 | 442 | if (hwmgr->hwmgr_func->powergate_uvd == NULL) { |
| 424 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 443 | + pr_info("%s was not implemented.\n", __func__); | |
| 425 | 444 | return 0; |
| 426 | 445 | } |
| 427 | 446 | |
| @@ -446,16 +465,13 @@ static int pp_dpm_dispatch_tasks(void *handle, enum amd_pp_event event_id, · 18 unmodified lines | ||
| 446 | 465 | void *input, void *output) |
| 447 | 466 | { |
| 448 | 467 | int ret = 0; |
| 449 | − struct pp_instance *pp_handle; | |
| 450 | 468 | struct pem_event_data data = { {0} }; |
| 469 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 451 | 470 | |
| 452 | − pp_handle = (struct pp_instance *)handle; | |
| 471 | + ret = pp_check(pp_handle); | |
| 453 | 472 | |
| 454 | − if (pp_handle == NULL) | |
| 455 | − return -EINVAL; | |
| 456 | − | |
| 457 | − if (pp_handle->eventmgr == NULL) | |
| 458 | − return 0; | |
| 473 | + if (ret != 0) | |
| 474 | + return ret; | |
| 459 | 475 | |
| 460 | 476 | switch (event_id) { |
| 461 | 477 | case AMD_PP_EVENT_DISPLAY_CONFIG_CHANGE: |
| @@ -489,13 +505,17 @@ static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle) · 27 unmodified lines | ||
| 489 | 505 | { |
| 490 | 506 | struct pp_hwmgr *hwmgr; |
| 491 | 507 | struct pp_power_state *state; |
| 508 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 509 | + int ret = 0; | |
| 492 | 510 | |
| 493 | − if (handle == NULL) | |
| 494 | − return -EINVAL; | |
| 511 | + ret = pp_check(pp_handle); | |
| 495 | 512 | |
| 496 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 513 | + if (ret != 0) | |
| 514 | + return ret; | |
| 497 | 515 | |
| 498 | − if (hwmgr == NULL || hwmgr->current_ps == NULL) | |
| 516 | + hwmgr = pp_handle->hwmgr; | |
| 517 | + | |
| 518 | + if (hwmgr->current_ps == NULL) | |
| 499 | 519 | return -EINVAL; |
| 500 | 520 | |
| 501 | 521 | state = hwmgr->current_ps; |
| @@ -518,16 +538,18 @@ static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle) · 16 unmodified lines | ||
| 518 | 538 | static int pp_dpm_set_fan_control_mode(void *handle, uint32_t mode) |
| 519 | 539 | { |
| 520 | 540 | struct pp_hwmgr *hwmgr; |
| 541 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 542 | + int ret = 0; | |
| 521 | 543 | |
| 522 | − if (handle == NULL) | |
| 523 | − return -EINVAL; | |
| 544 | + ret = pp_check(pp_handle); | |
| 524 | 545 | |
| 525 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 546 | + if (ret != 0) | |
| 547 | + return ret; | |
| 526 | 548 | |
| 527 | − PP_CHECK_HW(hwmgr); | |
| 549 | + hwmgr = pp_handle->hwmgr; | |
| 528 | 550 | |
| 529 | 551 | if (hwmgr->hwmgr_func->set_fan_control_mode == NULL) { |
| 530 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 552 | + pr_info("%s was not implemented.\n", __func__); | |
| 531 | 553 | return 0; |
| 532 | 554 | } |
| 533 | 555 | |
| @@ -537,16 +559,18 @@ static int pp_dpm_set_fan_control_mode(void *handle, uint32_t mode) · 3 unmodified lines | ||
| 537 | 559 | static int pp_dpm_get_fan_control_mode(void *handle) |
| 538 | 560 | { |
| 539 | 561 | struct pp_hwmgr *hwmgr; |
| 562 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 563 | + int ret = 0; | |
| 540 | 564 | |
| 541 | − if (handle == NULL) | |
| 542 | − return -EINVAL; | |
| 565 | + ret = pp_check(pp_handle); | |
| 543 | 566 | |
| 544 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 567 | + if (ret != 0) | |
| 568 | + return ret; | |
| 545 | 569 | |
| 546 | − PP_CHECK_HW(hwmgr); | |
| 570 | + hwmgr = pp_handle->hwmgr; | |
| 547 | 571 | |
| 548 | 572 | if (hwmgr->hwmgr_func->get_fan_control_mode == NULL) { |
| 549 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 573 | + pr_info("%s was not implemented.\n", __func__); | |
| 550 | 574 | return 0; |
| 551 | 575 | } |
| 552 | 576 | |
| @@ -556,16 +580,18 @@ static int pp_dpm_get_fan_control_mode(void *handle) · 3 unmodified lines | ||
| 556 | 580 | static int pp_dpm_set_fan_speed_percent(void *handle, uint32_t percent) |
| 557 | 581 | { |
| 558 | 582 | struct pp_hwmgr *hwmgr; |
| 583 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 584 | + int ret = 0; | |
| 559 | 585 | |
| 560 | − if (handle == NULL) | |
| 561 | − return -EINVAL; | |
| 586 | + ret = pp_check(pp_handle); | |
| 562 | 587 | |
| 563 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 588 | + if (ret != 0) | |
| 589 | + return ret; | |
| 564 | 590 | |
| 565 | − PP_CHECK_HW(hwmgr); | |
| 591 | + hwmgr = pp_handle->hwmgr; | |
| 566 | 592 | |
| 567 | 593 | if (hwmgr->hwmgr_func->set_fan_speed_percent == NULL) { |
| 568 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 594 | + pr_info("%s was not implemented.\n", __func__); | |
| 569 | 595 | return 0; |
| 570 | 596 | } |
| 571 | 597 | |
| @@ -575,16 +601,18 @@ static int pp_dpm_set_fan_speed_percent(void *handle, uint32_t percent) · 3 unmodified lines | ||
| 575 | 601 | static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed) |
| 576 | 602 | { |
| 577 | 603 | struct pp_hwmgr *hwmgr; |
| 604 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 605 | + int ret = 0; | |
| 578 | 606 | |
| 579 | − if (handle == NULL) | |
| 580 | − return -EINVAL; | |
| 607 | + ret = pp_check(pp_handle); | |
| 581 | 608 | |
| 582 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 609 | + if (ret != 0) | |
| 610 | + return ret; | |
| 583 | 611 | |
| 584 | − PP_CHECK_HW(hwmgr); | |
| 612 | + hwmgr = pp_handle->hwmgr; | |
| 585 | 613 | |
| 586 | 614 | if (hwmgr->hwmgr_func->get_fan_speed_percent == NULL) { |
| 587 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 615 | + pr_info("%s was not implemented.\n", __func__); | |
| 588 | 616 | return 0; |
| 589 | 617 | } |
| 590 | 618 | |
| @@ -594,13 +622,15 @@ static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed) · 3 unmodified lines | ||
| 594 | 622 | static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm) |
| 595 | 623 | { |
| 596 | 624 | struct pp_hwmgr *hwmgr; |
| 625 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 626 | + int ret = 0; | |
| 597 | 627 | |
| 598 | − if (handle == NULL) | |
| 599 | − return -EINVAL; | |
| 628 | + ret = pp_check(pp_handle); | |
| 600 | 629 | |
| 601 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 630 | + if (ret != 0) | |
| 631 | + return ret; | |
| 602 | 632 | |
| 603 | − PP_CHECK_HW(hwmgr); | |
| 633 | + hwmgr = pp_handle->hwmgr; | |
| 604 | 634 | |
| 605 | 635 | if (hwmgr->hwmgr_func->get_fan_speed_rpm == NULL) |
| 606 | 636 | return -EINVAL; |
| @@ -611,16 +641,18 @@ static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm) · 4 unmodified lines | ||
| 611 | 641 | static int pp_dpm_get_temperature(void *handle) |
| 612 | 642 | { |
| 613 | 643 | struct pp_hwmgr *hwmgr; |
| 644 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 645 | + int ret = 0; | |
| 614 | 646 | |
| 615 | − if (handle == NULL) | |
| 616 | − return -EINVAL; | |
| 647 | + ret = pp_check(pp_handle); | |
| 617 | 648 | |
| 618 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 649 | + if (ret != 0) | |
| 650 | + return ret; | |
| 619 | 651 | |
| 620 | − PP_CHECK_HW(hwmgr); | |
| 652 | + hwmgr = pp_handle->hwmgr; | |
| 621 | 653 | |
| 622 | 654 | if (hwmgr->hwmgr_func->get_temperature == NULL) { |
| 623 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 655 | + pr_info("%s was not implemented.\n", __func__); | |
| 624 | 656 | return 0; |
| 625 | 657 | } |
| 626 | 658 | |
| @@ -632,13 +664,17 @@ static int pp_dpm_get_pp_num_states(void *handle, · 5 unmodified lines | ||
| 632 | 664 | { |
| 633 | 665 | struct pp_hwmgr *hwmgr; |
| 634 | 666 | int i; |
| 667 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 668 | + int ret = 0; | |
| 635 | 669 | |
| 636 | − if (!handle) | |
| 637 | − return -EINVAL; | |
| 670 | + ret = pp_check(pp_handle); | |
| 638 | 671 | |
| 639 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 672 | + if (ret != 0) | |
| 673 | + return ret; | |
| 674 | + | |
| 675 | + hwmgr = pp_handle->hwmgr; | |
| 640 | 676 | |
| 641 | − if (hwmgr == NULL || hwmgr->ps == NULL) | |
| 677 | + if (hwmgr->ps == NULL) | |
| 642 | 678 | return -EINVAL; |
| 643 | 679 | |
| 644 | 680 | data->nums = hwmgr->num_ps; |
| @@ -670,13 +706,15 @@ static int pp_dpm_get_pp_num_states(void *handle, · 25 unmodified lines | ||
| 670 | 706 | static int pp_dpm_get_pp_table(void *handle, char **table) |
| 671 | 707 | { |
| 672 | 708 | struct pp_hwmgr *hwmgr; |
| 709 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 710 | + int ret = 0; | |
| 673 | 711 | |
| 674 | − if (!handle) | |
| 675 | − return -EINVAL; | |
| 712 | + ret = pp_check(pp_handle); | |
| 676 | 713 | |
| 677 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 714 | + if (ret != 0) | |
| 715 | + return ret; | |
| 678 | 716 | |
| 679 | − PP_CHECK_HW(hwmgr); | |
| 717 | + hwmgr = pp_handle->hwmgr; | |
| 680 | 718 | |
| 681 | 719 | if (!hwmgr->soft_pp_table) |
| 682 | 720 | return -EINVAL; |
| @@ -689,13 +727,15 @@ static int pp_dpm_get_pp_table(void *handle, char **table) · 6 unmodified lines | ||
| 689 | 727 | static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size) |
| 690 | 728 | { |
| 691 | 729 | struct pp_hwmgr *hwmgr; |
| 730 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 731 | + int ret = 0; | |
| 692 | 732 | |
| 693 | − if (!handle) | |
| 694 | − return -EINVAL; | |
| 733 | + ret = pp_check(pp_handle); | |
| 695 | 734 | |
| 696 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 735 | + if (ret != 0) | |
| 736 | + return ret; | |
| 697 | 737 | |
| 698 | − PP_CHECK_HW(hwmgr); | |
| 738 | + hwmgr = pp_handle->hwmgr; | |
| 699 | 739 | |
| 700 | 740 | if (!hwmgr->hardcode_pp_table) { |
| 701 | 741 | hwmgr->hardcode_pp_table = kmemdup(hwmgr->soft_pp_table, |
| @@ -717,16 +757,18 @@ static int pp_dpm_force_clock_level(void *handle, · 15 unmodified lines | ||
| 717 | 757 | enum pp_clock_type type, uint32_t mask) |
| 718 | 758 | { |
| 719 | 759 | struct pp_hwmgr *hwmgr; |
| 760 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 761 | + int ret = 0; | |
| 720 | 762 | |
| 721 | − if (!handle) | |
| 722 | − return -EINVAL; | |
| 763 | + ret = pp_check(pp_handle); | |
| 723 | 764 | |
| 724 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 765 | + if (ret != 0) | |
| 766 | + return ret; | |
| 725 | 767 | |
| 726 | − PP_CHECK_HW(hwmgr); | |
| 768 | + hwmgr = pp_handle->hwmgr; | |
| 727 | 769 | |
| 728 | 770 | if (hwmgr->hwmgr_func->force_clock_level == NULL) { |
| 729 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 771 | + pr_info("%s was not implemented.\n", __func__); | |
| 730 | 772 | return 0; |
| 731 | 773 | } |
| 732 | 774 | |
| @@ -737,16 +779,18 @@ static int pp_dpm_print_clock_levels(void *handle, · 4 unmodified lines | ||
| 737 | 779 | enum pp_clock_type type, char *buf) |
| 738 | 780 | { |
| 739 | 781 | struct pp_hwmgr *hwmgr; |
| 782 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 783 | + int ret = 0; | |
| 740 | 784 | |
| 741 | − if (!handle) | |
| 742 | − return -EINVAL; | |
| 785 | + ret = pp_check(pp_handle); | |
| 743 | 786 | |
| 744 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 787 | + if (ret != 0) | |
| 788 | + return ret; | |
| 745 | 789 | |
| 746 | − PP_CHECK_HW(hwmgr); | |
| 790 | + hwmgr = pp_handle->hwmgr; | |
| 747 | 791 | |
| 748 | 792 | if (hwmgr->hwmgr_func->print_clock_levels == NULL) { |
| 749 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 793 | + pr_info("%s was not implemented.\n", __func__); | |
| 750 | 794 | return 0; |
| 751 | 795 | } |
| 752 | 796 | return hwmgr->hwmgr_func->print_clock_levels(hwmgr, type, buf); |
| @@ -755,16 +799,18 @@ static int pp_dpm_print_clock_levels(void *handle, · 2 unmodified lines | ||
| 755 | 799 | static int pp_dpm_get_sclk_od(void *handle) |
| 756 | 800 | { |
| 757 | 801 | struct pp_hwmgr *hwmgr; |
| 802 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 803 | + int ret = 0; | |
| 758 | 804 | |
| 759 | − if (!handle) | |
| 760 | − return -EINVAL; | |
| 805 | + ret = pp_check(pp_handle); | |
| 761 | 806 | |
| 762 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 807 | + if (ret != 0) | |
| 808 | + return ret; | |
| 763 | 809 | |
| 764 | − PP_CHECK_HW(hwmgr); | |
| 810 | + hwmgr = pp_handle->hwmgr; | |
| 765 | 811 | |
| 766 | 812 | if (hwmgr->hwmgr_func->get_sclk_od == NULL) { |
| 767 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 813 | + pr_info("%s was not implemented.\n", __func__); | |
| 768 | 814 | return 0; |
| 769 | 815 | } |
| 770 | 816 | |
| @@ -774,16 +820,18 @@ static int pp_dpm_get_sclk_od(void *handle) · 3 unmodified lines | ||
| 774 | 820 | static int pp_dpm_set_sclk_od(void *handle, uint32_t value) |
| 775 | 821 | { |
| 776 | 822 | struct pp_hwmgr *hwmgr; |
| 823 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 824 | + int ret = 0; | |
| 777 | 825 | |
| 778 | − if (!handle) | |
| 779 | − return -EINVAL; | |
| 826 | + ret = pp_check(pp_handle); | |
| 780 | 827 | |
| 781 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 828 | + if (ret != 0) | |
| 829 | + return ret; | |
| 782 | 830 | |
| 783 | − PP_CHECK_HW(hwmgr); | |
| 831 | + hwmgr = pp_handle->hwmgr; | |
| 784 | 832 | |
| 785 | 833 | if (hwmgr->hwmgr_func->set_sclk_od == NULL) { |
| 786 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 834 | + pr_info("%s was not implemented.\n", __func__); | |
| 787 | 835 | return 0; |
| 788 | 836 | } |
| 789 | 837 | |
| @@ -793,16 +841,18 @@ static int pp_dpm_set_sclk_od(void *handle, uint32_t value) · 3 unmodified lines | ||
| 793 | 841 | static int pp_dpm_get_mclk_od(void *handle) |
| 794 | 842 | { |
| 795 | 843 | struct pp_hwmgr *hwmgr; |
| 844 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 845 | + int ret = 0; | |
| 796 | 846 | |
| 797 | − if (!handle) | |
| 798 | − return -EINVAL; | |
| 847 | + ret = pp_check(pp_handle); | |
| 799 | 848 | |
| 800 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 849 | + if (ret != 0) | |
| 850 | + return ret; | |
| 801 | 851 | |
| 802 | − PP_CHECK_HW(hwmgr); | |
| 852 | + hwmgr = pp_handle->hwmgr; | |
| 803 | 853 | |
| 804 | 854 | if (hwmgr->hwmgr_func->get_mclk_od == NULL) { |
| 805 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 855 | + pr_info("%s was not implemented.\n", __func__); | |
| 806 | 856 | return 0; |
| 807 | 857 | } |
| 808 | 858 | |
| @@ -812,16 +862,18 @@ static int pp_dpm_get_mclk_od(void *handle) · 3 unmodified lines | ||
| 812 | 862 | static int pp_dpm_set_mclk_od(void *handle, uint32_t value) |
| 813 | 863 | { |
| 814 | 864 | struct pp_hwmgr *hwmgr; |
| 865 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 866 | + int ret = 0; | |
| 815 | 867 | |
| 816 | − if (!handle) | |
| 817 | − return -EINVAL; | |
| 868 | + ret = pp_check(pp_handle); | |
| 818 | 869 | |
| 819 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 870 | + if (ret != 0) | |
| 871 | + return ret; | |
| 820 | 872 | |
| 821 | − PP_CHECK_HW(hwmgr); | |
| 873 | + hwmgr = pp_handle->hwmgr; | |
| 822 | 874 | |
| 823 | 875 | if (hwmgr->hwmgr_func->set_mclk_od == NULL) { |
| 824 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 876 | + pr_info("%s was not implemented.\n", __func__); | |
| 825 | 877 | return 0; |
| 826 | 878 | } |
| 827 | 879 | |
| @@ -831,16 +883,18 @@ static int pp_dpm_set_mclk_od(void *handle, uint32_t value) · 3 unmodified lines | ||
| 831 | 883 | static int pp_dpm_read_sensor(void *handle, int idx, int32_t *value) |
| 832 | 884 | { |
| 833 | 885 | struct pp_hwmgr *hwmgr; |
| 886 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 887 | + int ret = 0; | |
| 834 | 888 | |
| 835 | − if (!handle) | |
| 836 | − return -EINVAL; | |
| 889 | + ret = pp_check(pp_handle); | |
| 837 | 890 | |
| 838 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 891 | + if (ret != 0) | |
| 892 | + return ret; | |
| 839 | 893 | |
| 840 | − PP_CHECK_HW(hwmgr); | |
| 894 | + hwmgr = pp_handle->hwmgr; | |
| 841 | 895 | |
| 842 | 896 | if (hwmgr->hwmgr_func->read_sensor == NULL) { |
| 843 | − printk(KERN_INFO "%s was not implemented.\n", __func__); | |
| 897 | + pr_info("%s was not implemented.\n", __func__); | |
| 844 | 898 | return 0; |
| 845 | 899 | } |
| 846 | 900 | |
| @@ -851,13 +905,18 @@ static struct amd_vce_state* · 4 unmodified lines | ||
| 851 | 905 | pp_dpm_get_vce_clock_state(void *handle, unsigned idx) |
| 852 | 906 | { |
| 853 | 907 | struct pp_hwmgr *hwmgr; |
| 908 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 909 | + int ret = 0; | |
| 854 | 910 | |
| 855 | − if (handle) { | |
| 856 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 911 | + ret = pp_check(pp_handle); | |
| 857 | 912 | |
| 858 | − if (hwmgr && idx < hwmgr->num_vce_state_tables) | |
| 859 | − return &hwmgr->vce_states[idx]; | |
| 860 | − } | |
| 913 | + if (ret != 0) | |
| 914 | + return NULL; | |
| 915 | + | |
| 916 | + hwmgr = pp_handle->hwmgr; | |
| 917 | + | |
| 918 | + if (hwmgr && idx < hwmgr->num_vce_state_tables) | |
| 919 | + return &hwmgr->vce_states[idx]; | |
| 861 | 920 | |
| 862 | 921 | return NULL; |
| 863 | 922 | } |
| @@ -892,89 +951,44 @@ const struct amd_powerplay_funcs pp_dpm_funcs = { · 28 unmodified lines | ||
| 892 | 951 | .get_vce_clock_state = pp_dpm_get_vce_clock_state, |
| 893 | 952 | }; |
| 894 | 953 | |
| 895 | −static int amd_pp_instance_init(struct amd_pp_init *pp_init, | |
| 896 | − struct amd_powerplay *amd_pp) | |
| 954 | +int amd_powerplay_create(struct amd_pp_init *pp_init, | |
| 955 | + void **handle) | |
| 897 | 956 | { |
| 898 | − int ret; | |
| 899 | − struct pp_instance *handle; | |
| 900 | − | |
| 901 | − handle = kzalloc(sizeof(struct pp_instance), GFP_KERNEL); | |
| 902 | − if (handle == NULL) | |
| 903 | − return -ENOMEM; | |
| 904 | − | |
| 905 | − handle->pp_valid = PP_VALID; | |
| 906 | − | |
| 907 | − ret = smum_init(pp_init, handle); | |
| 908 | − if (ret) | |
| 909 | − goto fail_smum; | |
| 910 | − | |
| 911 | − | |
| 912 | − amd_pp->pp_handle = handle; | |
| 957 | + struct pp_instance *instance; | |
| 913 | 958 | |
| 914 | − if ((amdgpu_dpm == 0) | |
| 915 | − || cgs_is_virtualization_enabled(pp_init->device)) | |
| 916 | − return 0; | |
| 959 | + if (pp_init == NULL || handle == NULL) | |
| 960 | + return -EINVAL; | |
| 917 | 961 | |
| 918 | − ret = hwmgr_init(pp_init, handle); | |
| 919 | − if (ret) | |
| 920 | − goto fail_hwmgr; | |
| 962 | + instance = kzalloc(sizeof(struct pp_instance), GFP_KERNEL); | |
| 963 | + if (instance == NULL) | |
| 964 | + return -ENOMEM; | |
| 921 | 965 | |
| 922 | − ret = eventmgr_init(handle); | |
| 923 | − if (ret) | |
| 924 | − goto fail_eventmgr; | |
| 966 | + instance->pp_valid = PP_VALID; | |
| 967 | + instance->chip_family = pp_init->chip_family; | |
| 968 | + instance->chip_id = pp_init->chip_id; | |
| 969 | + instance->pm_en = pp_init->pm_en; | |
| 970 | + instance->feature_mask = pp_init->feature_mask; | |
| 971 | + instance->device = pp_init->device; | |
| 972 | + *handle = instance; | |
| 925 | 973 | |
| 926 | 974 | return 0; |
| 927 | − | |
| 928 | −fail_eventmgr: | |
| 929 | − hwmgr_fini(handle->hwmgr); | |
| 930 | −fail_hwmgr: | |
| 931 | − smum_fini(handle->smu_mgr); | |
| 932 | −fail_smum: | |
| 933 | − kfree(handle); | |
| 934 | − return ret; | |
| 935 | 975 | } |
| 936 | 976 | |
| 937 | −static int amd_pp_instance_fini(void *handle) | |
| 977 | +int amd_powerplay_destroy(void *handle) | |
| 938 | 978 | { |
| 939 | 979 | struct pp_instance *instance = (struct pp_instance *)handle; |
| 940 | 980 | |
| 941 | − if (instance == NULL) | |
| 942 | − return -EINVAL; | |
| 943 | − | |
| 944 | − if ((amdgpu_dpm != 0) | |
| 945 | − && !cgs_is_virtualization_enabled(instance->smu_mgr->device)) { | |
| 946 | − eventmgr_fini(instance->eventmgr); | |
| 947 | − hwmgr_fini(instance->hwmgr); | |
| 981 | + if (instance->pm_en) { | |
| 982 | + kfree(instance->eventmgr); | |
| 983 | + kfree(instance->hwmgr); | |
| 984 | + instance->hwmgr = NULL; | |
| 985 | + instance->eventmgr = NULL; | |
| 948 | 986 | } |
| 949 | 987 | |
| 950 | − smum_fini(instance->smu_mgr); | |
| 951 | − kfree(handle); | |
| 952 | − return 0; | |
| 953 | −} | |
| 954 | − | |
| 955 | −int amd_powerplay_init(struct amd_pp_init *pp_init, | |
| 956 | − struct amd_powerplay *amd_pp) | |
| 957 | −{ | |
| 958 | − int ret; | |
| 959 | − | |
| 960 | − if (pp_init == NULL || amd_pp == NULL) | |
| 961 | − return -EINVAL; | |
| 962 | − | |
| 963 | − ret = amd_pp_instance_init(pp_init, amd_pp); | |
| 964 | − | |
| 965 | − if (ret) | |
| 966 | − return ret; | |
| 967 | − | |
| 968 | − amd_pp->ip_funcs = &pp_ip_funcs; | |
| 969 | − amd_pp->pp_funcs = &pp_dpm_funcs; | |
| 970 | − | |
| 971 | − return 0; | |
| 972 | −} | |
| 973 | − | |
| 974 | −int amd_powerplay_fini(void *handle) | |
| 975 | −{ | |
| 976 | − amd_pp_instance_fini(handle); | |
| 977 | − | |
| 988 | + kfree(instance->smu_mgr); | |
| 989 | + instance->smu_mgr = NULL; | |
| 990 | + kfree(instance); | |
| 991 | + instance = NULL; | |
| 978 | 992 | return 0; |
| 979 | 993 | } |
| 980 | 994 | |
| @@ -985,33 +999,25 @@ int amd_powerplay_reset(void *handle) · 4 unmodified lines | ||
| 985 | 999 | struct pem_event_data event_data = { {0} }; |
| 986 | 1000 | int ret; |
| 987 | 1001 | |
| 988 | − if (instance == NULL) | |
| 989 | − return -EINVAL; | |
| 990 | − | |
| 991 | − eventmgr = instance->eventmgr; | |
| 992 | − if (!eventmgr || !eventmgr->pp_eventmgr_fini) | |
| 993 | − return -EINVAL; | |
| 994 | − | |
| 995 | − eventmgr->pp_eventmgr_fini(eventmgr); | |
| 1002 | + if (cgs_is_virtualization_enabled(instance->smu_mgr->device)) | |
| 1003 | + return PP_DPM_DISABLED; | |
| 996 | 1004 | |
| 997 | − ret = pp_sw_fini(handle); | |
| 998 | − if (ret) | |
| 1005 | + ret = pp_check(instance); | |
| 1006 | + if (ret != 0) | |
| 999 | 1007 | return ret; |
| 1000 | 1008 | |
| 1001 | − kfree(instance->hwmgr->ps); | |
| 1002 | − | |
| 1003 | − ret = pp_sw_init(handle); | |
| 1009 | + ret = pp_hw_fini(handle); | |
| 1004 | 1010 | if (ret) |
| 1005 | 1011 | return ret; |
| 1006 | 1012 | |
| 1007 | − if ((amdgpu_dpm == 0) | |
| 1008 | − || cgs_is_virtualization_enabled(instance->smu_mgr->device)) | |
| 1009 | − return 0; | |
| 1013 | + ret = hwmgr_hw_init(instance); | |
| 1014 | + if (ret) | |
| 1015 | + return PP_DPM_DISABLED; | |
| 1010 | 1016 | |
| 1011 | − hw_init_power_state_table(instance->hwmgr); | |
| 1017 | + eventmgr = instance->eventmgr; | |
| 1012 | 1018 | |
| 1013 | − if (eventmgr == NULL || eventmgr->pp_eventmgr_init == NULL) | |
| 1014 | − return -EINVAL; | |
| 1019 | + if (eventmgr->pp_eventmgr_init == NULL) | |
| 1020 | + return PP_DPM_DISABLED; | |
| 1015 | 1021 | |
| 1016 | 1022 | ret = eventmgr->pp_eventmgr_init(eventmgr); |
| 1017 | 1023 | if (ret) |
| @@ -1026,12 +1032,15 @@ int amd_powerplay_display_configuration_change(void *handle, · 8 unmodified lines | ||
| 1026 | 1032 | const struct amd_pp_display_configuration *display_config) |
| 1027 | 1033 | { |
| 1028 | 1034 | struct pp_hwmgr *hwmgr; |
| 1035 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 1036 | + int ret = 0; | |
| 1029 | 1037 | |
| 1030 | − PP_CHECK((struct pp_instance *)handle); | |
| 1038 | + ret = pp_check(pp_handle); | |
| 1031 | 1039 | |
| 1032 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 1040 | + if (ret != 0) | |
| 1041 | + return ret; | |
| 1033 | 1042 | |
| 1034 | − PP_CHECK_HW(hwmgr); | |
| 1043 | + hwmgr = pp_handle->hwmgr; | |
| 1035 | 1044 | |
| 1036 | 1045 | phm_store_dal_configuration_data(hwmgr, display_config); |
| 1037 | 1046 | |
| @@ -1042,15 +1051,18 @@ int amd_powerplay_get_display_power_level(void *handle, · 4 unmodified lines | ||
| 1042 | 1051 | struct amd_pp_simple_clock_info *output) |
| 1043 | 1052 | { |
| 1044 | 1053 | struct pp_hwmgr *hwmgr; |
| 1054 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 1055 | + int ret = 0; | |
| 1045 | 1056 | |
| 1046 | − PP_CHECK((struct pp_instance *)handle); | |
| 1057 | + ret = pp_check(pp_handle); | |
| 1047 | 1058 | |
| 1048 | − if (output == NULL) | |
| 1049 | − return -EINVAL; | |
| 1059 | + if (ret != 0) | |
| 1060 | + return ret; | |
| 1050 | 1061 | |
| 1051 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 1062 | + hwmgr = pp_handle->hwmgr; | |
| 1052 | 1063 | |
| 1053 | − PP_CHECK_HW(hwmgr); | |
| 1064 | + if (output == NULL) | |
| 1065 | + return -EINVAL; | |
| 1054 | 1066 | |
| 1055 | 1067 | return phm_get_dal_power_level(hwmgr, output); |
| 1056 | 1068 | } |
| @@ -1058,18 +1070,18 @@ int amd_powerplay_get_display_power_level(void *handle, · 1 unmodified line | ||
| 1058 | 1070 | int amd_powerplay_get_current_clocks(void *handle, |
| 1059 | 1071 | struct amd_pp_clock_info *clocks) |
| 1060 | 1072 | { |
| 1061 | − struct pp_hwmgr *hwmgr; | |
| 1062 | 1073 | struct amd_pp_simple_clock_info simple_clocks; |
| 1063 | 1074 | struct pp_clock_info hw_clocks; |
| 1075 | + struct pp_hwmgr *hwmgr; | |
| 1076 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 1077 | + int ret = 0; | |
| 1064 | 1078 | |
| 1065 | − PP_CHECK((struct pp_instance *)handle); | |
| 1066 | − | |
| 1067 | − if (clocks == NULL) | |
| 1068 | − return -EINVAL; | |
| 1079 | + ret = pp_check(pp_handle); | |
| 1069 | 1080 | |
| 1070 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 1081 | + if (ret != 0) | |
| 1082 | + return ret; | |
| 1071 | 1083 | |
| 1072 | − PP_CHECK_HW(hwmgr); | |
| 1084 | + hwmgr = pp_handle->hwmgr; | |
| 1073 | 1085 | |
| 1074 | 1086 | phm_get_dal_power_level(hwmgr, &simple_clocks); |
| 1075 | 1087 | |
| @@ -1105,18 +1117,20 @@ int amd_powerplay_get_current_clocks(void *handle, · 29 unmodified lines | ||
| 1105 | 1117 | int amd_powerplay_get_clock_by_type(void *handle, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks) |
| 1106 | 1118 | { |
| 1107 | 1119 | int result = -1; |
| 1120 | + struct pp_hwmgr *hwmgr; | |
| 1121 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 1122 | + int ret = 0; | |
| 1108 | 1123 | |
| 1109 | − struct pp_hwmgr *hwmgr; | |
| 1124 | + ret = pp_check(pp_handle); | |
| 1110 | 1125 | |
| 1111 | − PP_CHECK((struct pp_instance *)handle); | |
| 1126 | + if (ret != 0) | |
| 1127 | + return ret; | |
| 1128 | + | |
| 1129 | + hwmgr = pp_handle->hwmgr; | |
| 1112 | 1130 | |
| 1113 | 1131 | if (clocks == NULL) |
| 1114 | 1132 | return -EINVAL; |
| 1115 | 1133 | |
| 1116 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 1117 | − | |
| 1118 | − PP_CHECK_HW(hwmgr); | |
| 1119 | − | |
| 1120 | 1134 | result = phm_get_clock_by_type(hwmgr, type, clocks); |
| 1121 | 1135 | |
| 1122 | 1136 | return result; |
| @@ -1125,21 +1139,24 @@ int amd_powerplay_get_clock_by_type(void *handle, enum amd_pp_clock_type type, s · 2 unmodified lines | ||
| 1125 | 1139 | int amd_powerplay_get_display_mode_validation_clocks(void *handle, |
| 1126 | 1140 | struct amd_pp_simple_clock_info *clocks) |
| 1127 | 1141 | { |
| 1128 | − int result = -1; | |
| 1129 | 1142 | struct pp_hwmgr *hwmgr; |
| 1143 | + struct pp_instance *pp_handle = (struct pp_instance *)handle; | |
| 1144 | + int ret = 0; | |
| 1130 | 1145 | |
| 1131 | − PP_CHECK((struct pp_instance *)handle); | |
| 1146 | + ret = pp_check(pp_handle); | |
| 1132 | 1147 | |
| 1133 | − if (clocks == NULL) | |
| 1134 | − return -EINVAL; | |
| 1148 | + if (ret != 0) | |
| 1149 | + return ret; | |
| 1150 | + | |
| 1151 | + hwmgr = pp_handle->hwmgr; | |
| 1135 | 1152 | |
| 1136 | − hwmgr = ((struct pp_instance *)handle)->hwmgr; | |
| 1137 | 1153 | |
| 1138 | − PP_CHECK_HW(hwmgr); | |
| 1154 | + if (clocks == NULL) | |
| 1155 | + return -EINVAL; | |
| 1139 | 1156 | |
| 1140 | 1157 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DynamicPatchPowerState)) |
| 1141 | − result = phm_get_max_high_clocks(hwmgr, clocks); | |
| 1158 | + ret = phm_get_max_high_clocks(hwmgr, clocks); | |
| 1142 | 1159 | |
| 1143 | − return result; | |
| 1160 | + return ret; | |
| 1144 | 1161 | } |
| 1145 | 1162 | |
| @@ -151,7 +151,7 @@ static int thermal_interrupt_callback(void *private_data, · 150 unmodified lines | ||
| 151 | 151 | unsigned src_id, const uint32_t *iv_entry) |
| 152 | 152 | { |
| 153 | 153 | /* TO DO hanle PEM_Event_ThermalNotification (struct pp_eventmgr *)private_data*/ |
| 154 | − printk("current thermal is out of range \n"); | |
| 154 | + pr_info("current thermal is out of range \n"); | |
| 155 | 155 | return 0; |
| 156 | 156 | } |
| 157 | 157 | |
| @@ -60,9 +60,8 @@ static void pem_fini(struct pp_eventmgr *eventmgr) · 59 unmodified lines | ||
| 60 | 60 | pem_handle_event(eventmgr, AMD_PP_EVENT_UNINITIALIZE, &event_data); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | −int eventmgr_init(struct pp_instance *handle) | |
| 63 | +int eventmgr_early_init(struct pp_instance *handle) | |
| 64 | 64 | { |
| 65 | − int result = 0; | |
| 66 | 65 | struct pp_eventmgr *eventmgr; |
| 67 | 66 | |
| 68 | 67 | if (handle == NULL) |
| @@ -79,12 +78,6 @@ int eventmgr_init(struct pp_instance *handle) · 10 unmodified lines | ||
| 79 | 78 | eventmgr->pp_eventmgr_init = pem_init; |
| 80 | 79 | eventmgr->pp_eventmgr_fini = pem_fini; |
| 81 | 80 | |
| 82 | − return result; | |
| 83 | −} | |
| 84 | − | |
| 85 | −int eventmgr_fini(struct pp_eventmgr *eventmgr) | |
| 86 | −{ | |
| 87 | − kfree(eventmgr); | |
| 88 | 81 | return 0; |
| 89 | 82 | } |
| 90 | 83 | |
| @@ -38,10 +38,13 @@ · 37 unmodified lines | ||
| 38 | 38 | int pem_task_update_allowed_performance_levels(struct pp_eventmgr *eventmgr, struct pem_event_data *event_data) |
| 39 | 39 | { |
| 40 | 40 | |
| 41 | + if (eventmgr == NULL || eventmgr->hwmgr == NULL) | |
| 42 | + return -EINVAL; | |
| 43 | + | |
| 41 | 44 | if (pem_is_hw_access_blocked(eventmgr)) |
| 42 | 45 | return 0; |
| 43 | 46 | |
| 44 | − phm_force_dpm_levels(eventmgr->hwmgr, AMD_DPM_FORCED_LEVEL_AUTO); | |
| 47 | + phm_force_dpm_levels(eventmgr->hwmgr, eventmgr->hwmgr->dpm_level); | |
| 45 | 48 | |
| 46 | 49 | return 0; |
| 47 | 50 | } |
| @@ -240,10 +240,16 @@ int cz_dpm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate) · 239 unmodified lines | ||
| 240 | 240 | |
| 241 | 241 | static const struct phm_master_table_item cz_enable_clock_power_gatings_list[] = { |
| 242 | 242 | /*we don't need an exit table here, because there is only D3 cold on Kv*/ |
| 243 | − { phm_cf_want_uvd_power_gating, cz_tf_uvd_power_gating_initialize }, | |
| 244 | − { phm_cf_want_vce_power_gating, cz_tf_vce_power_gating_initialize }, | |
| 243 | + { | |
| 244 | + .isFunctionNeededInRuntimeTable = phm_cf_want_uvd_power_gating, | |
| 245 | + .tableFunction = cz_tf_uvd_power_gating_initialize | |
| 246 | + }, | |
| 247 | + { | |
| 248 | + .isFunctionNeededInRuntimeTable = phm_cf_want_vce_power_gating, | |
| 249 | + .tableFunction = cz_tf_vce_power_gating_initialize | |
| 250 | + }, | |
| 245 | 251 | /* to do { NULL, cz_tf_xdma_power_gating_enable }, */ |
| 246 | − { NULL, NULL } | |
| 252 | + { } | |
| 247 | 253 | }; |
| 248 | 254 | |
| 249 | 255 | const struct phm_master_table_header cz_phm_enable_clock_power_gatings_master = { |
| @@ -20,13 +20,13 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | +#include "pp_debug.h" | |
| 23 | 24 | #include <linux/types.h> |
| 24 | 25 | #include <linux/kernel.h> |
| 25 | 26 | #include <linux/slab.h> |
| 26 | 27 | #include "atom-types.h" |
| 27 | 28 | #include "atombios.h" |
| 28 | 29 | #include "processpptables.h" |
| 29 | −#include "pp_debug.h" | |
| 30 | 30 | #include "cgs_common.h" |
| 31 | 31 | #include "smu/smu_8_0_d.h" |
| 32 | 32 | #include "smu8_fusion.h" |
| @@ -38,7 +38,6 @@ · 5 unmodified lines | ||
| 38 | 38 | #include "cz_hwmgr.h" |
| 39 | 39 | #include "power_state.h" |
| 40 | 40 | #include "cz_clockpowergating.h" |
| 41 | −#include "pp_debug.h" | |
| 42 | 41 | |
| 43 | 42 | #define ixSMUSVI_NB_CURRENTVID 0xD8230044 |
| 44 | 43 | #define CURRENT_NB_VID_MASK 0xff000000 |
| @@ -288,7 +287,7 @@ static int cz_init_dynamic_state_adjustment_rule_settings( · 243 unmodified lines | ||
| 288 | 287 | kzalloc(table_size, GFP_KERNEL); |
| 289 | 288 | |
| 290 | 289 | if (NULL == table_clk_vlt) { |
| 291 | − printk(KERN_ERR "[ powerplay ] Can not allocate memory!\n"); | |
| 290 | + pr_err("Can not allocate memory!\n"); | |
| 292 | 291 | return -ENOMEM; |
| 293 | 292 | } |
| 294 | 293 | |
| @@ -329,12 +328,12 @@ static int cz_get_system_info_data(struct pp_hwmgr *hwmgr) · 34 unmodified lines | ||
| 329 | 328 | &size, &frev, &crev); |
| 330 | 329 | |
| 331 | 330 | if (crev != 9) { |
| 332 | − printk(KERN_ERR "[ powerplay ] Unsupported IGP table: %d %d\n", frev, crev); | |
| 331 | + pr_err("Unsupported IGP table: %d %d\n", frev, crev); | |
| 333 | 332 | return -EINVAL; |
| 334 | 333 | } |
| 335 | 334 | |
| 336 | 335 | if (info == NULL) { |
| 337 | − printk(KERN_ERR "[ powerplay ] Could not retrieve the Integrated System Info Table!\n"); | |
| 336 | + pr_err("Could not retrieve the Integrated System Info Table!\n"); | |
| 338 | 337 | return -EINVAL; |
| 339 | 338 | } |
| 340 | 339 | |
| @@ -361,7 +360,7 @@ static int cz_get_system_info_data(struct pp_hwmgr *hwmgr) · 20 unmodified lines | ||
| 361 | 360 | |
| 362 | 361 | if (cz_hwmgr->sys_info.htc_tmp_lmt <= |
| 363 | 362 | cz_hwmgr->sys_info.htc_hyst_lmt) { |
| 364 | − printk(KERN_ERR "[ powerplay ] The htcTmpLmt should be larger than htcHystLmt.\n"); | |
| 363 | + pr_err("The htcTmpLmt should be larger than htcHystLmt.\n"); | |
| 365 | 364 | return -EINVAL; |
| 366 | 365 | } |
| 367 | 366 | |
| @@ -723,7 +722,7 @@ static int cz_tf_update_sclk_limit(struct pp_hwmgr *hwmgr, · 355 unmodified lines | ||
| 723 | 722 | |
| 724 | 723 | clock = hwmgr->display_config.min_core_set_clock; |
| 725 | 724 | if (clock == 0) |
| 726 | − printk(KERN_INFO "[ powerplay ] min_core_set_clock not set\n"); | |
| 725 | + pr_info("min_core_set_clock not set\n"); | |
| 727 | 726 | |
| 728 | 727 | if (cz_hwmgr->sclk_dpm.hard_min_clk != clock) { |
| 729 | 728 | cz_hwmgr->sclk_dpm.hard_min_clk = clock; |
| @@ -888,13 +887,13 @@ static int cz_tf_update_low_mem_pstate(struct pp_hwmgr *hwmgr, · 158 unmodified lines | ||
| 888 | 887 | } |
| 889 | 888 | |
| 890 | 889 | static const struct phm_master_table_item cz_set_power_state_list[] = { |
| 891 | − {NULL, cz_tf_update_sclk_limit}, | |
| 892 | − {NULL, cz_tf_set_deep_sleep_sclk_threshold}, | |
| 893 | − {NULL, cz_tf_set_watermark_threshold}, | |
| 894 | − {NULL, cz_tf_set_enabled_levels}, | |
| 895 | − {NULL, cz_tf_enable_nb_dpm}, | |
| 896 | − {NULL, cz_tf_update_low_mem_pstate}, | |
| 897 | − {NULL, NULL} | |
| 890 | + { .tableFunction = cz_tf_update_sclk_limit }, | |
| 891 | + { .tableFunction = cz_tf_set_deep_sleep_sclk_threshold }, | |
| 892 | + { .tableFunction = cz_tf_set_watermark_threshold }, | |
| 893 | + { .tableFunction = cz_tf_set_enabled_levels }, | |
| 894 | + { .tableFunction = cz_tf_enable_nb_dpm }, | |
| 895 | + { .tableFunction = cz_tf_update_low_mem_pstate }, | |
| 896 | + { } | |
| 898 | 897 | }; |
| 899 | 898 | |
| 900 | 899 | static const struct phm_master_table_header cz_set_power_state_master = { |
| @@ -904,15 +903,15 @@ static const struct phm_master_table_header cz_set_power_state_master = { · 3 unmodified lines | ||
| 904 | 903 | }; |
| 905 | 904 | |
| 906 | 905 | static const struct phm_master_table_item cz_setup_asic_list[] = { |
| 907 | − {NULL, cz_tf_reset_active_process_mask}, | |
| 908 | − {NULL, cz_tf_upload_pptable_to_smu}, | |
| 909 | − {NULL, cz_tf_init_sclk_limit}, | |
| 910 | − {NULL, cz_tf_init_uvd_limit}, | |
| 911 | − {NULL, cz_tf_init_vce_limit}, | |
| 912 | − {NULL, cz_tf_init_acp_limit}, | |
| 913 | − {NULL, cz_tf_init_power_gate_state}, | |
| 914 | − {NULL, cz_tf_init_sclk_threshold}, | |
| 915 | − {NULL, NULL} | |
| 906 | + { .tableFunction = cz_tf_reset_active_process_mask }, | |
| 907 | + { .tableFunction = cz_tf_upload_pptable_to_smu }, | |
| 908 | + { .tableFunction = cz_tf_init_sclk_limit }, | |
| 909 | + { .tableFunction = cz_tf_init_uvd_limit }, | |
| 910 | + { .tableFunction = cz_tf_init_vce_limit }, | |
| 911 | + { .tableFunction = cz_tf_init_acp_limit }, | |
| 912 | + { .tableFunction = cz_tf_init_power_gate_state }, | |
| 913 | + { .tableFunction = cz_tf_init_sclk_threshold }, | |
| 914 | + { } | |
| 916 | 915 | }; |
| 917 | 916 | |
| 918 | 917 | static const struct phm_master_table_header cz_setup_asic_master = { |
| @@ -957,10 +956,10 @@ static int cz_tf_reset_cc6_data(struct pp_hwmgr *hwmgr, · 38 unmodified lines | ||
| 957 | 956 | } |
| 958 | 957 | |
| 959 | 958 | static const struct phm_master_table_item cz_power_down_asic_list[] = { |
| 960 | − {NULL, cz_tf_power_up_display_clock_sys_pll}, | |
| 961 | − {NULL, cz_tf_clear_nb_dpm_flag}, | |
| 962 | − {NULL, cz_tf_reset_cc6_data}, | |
| 963 | − {NULL, NULL} | |
| 959 | + { .tableFunction = cz_tf_power_up_display_clock_sys_pll }, | |
| 960 | + { .tableFunction = cz_tf_clear_nb_dpm_flag }, | |
| 961 | + { .tableFunction = cz_tf_reset_cc6_data }, | |
| 962 | + { } | |
| 964 | 963 | }; |
| 965 | 964 | |
| 966 | 965 | static const struct phm_master_table_header cz_power_down_asic_master = { |
| @@ -1068,8 +1067,8 @@ static int cz_tf_check_for_dpm_enabled(struct pp_hwmgr *hwmgr, · 101 unmodified lines | ||
| 1068 | 1067 | } |
| 1069 | 1068 | |
| 1070 | 1069 | static const struct phm_master_table_item cz_disable_dpm_list[] = { |
| 1071 | − { NULL, cz_tf_check_for_dpm_enabled}, | |
| 1072 | − {NULL, NULL}, | |
| 1070 | + { .tableFunction = cz_tf_check_for_dpm_enabled }, | |
| 1071 | + { }, | |
| 1073 | 1072 | }; |
| 1074 | 1073 | |
| 1075 | 1074 | |
| @@ -1080,13 +1079,13 @@ static const struct phm_master_table_header cz_disable_dpm_master = { · 4 unmodified lines | ||
| 1080 | 1079 | }; |
| 1081 | 1080 | |
| 1082 | 1081 | static const struct phm_master_table_item cz_enable_dpm_list[] = { |
| 1083 | − { NULL, cz_tf_check_for_dpm_disabled }, | |
| 1084 | − { NULL, cz_tf_program_voting_clients }, | |
| 1085 | − { NULL, cz_tf_start_dpm}, | |
| 1086 | − { NULL, cz_tf_program_bootup_state}, | |
| 1087 | − { NULL, cz_tf_enable_didt }, | |
| 1088 | − { NULL, cz_tf_reset_acp_boot_level }, | |
| 1089 | − {NULL, NULL}, | |
| 1082 | + { .tableFunction = cz_tf_check_for_dpm_disabled }, | |
| 1083 | + { .tableFunction = cz_tf_program_voting_clients }, | |
| 1084 | + { .tableFunction = cz_tf_start_dpm }, | |
| 1085 | + { .tableFunction = cz_tf_program_bootup_state }, | |
| 1086 | + { .tableFunction = cz_tf_enable_didt }, | |
| 1087 | + { .tableFunction = cz_tf_reset_acp_boot_level }, | |
| 1088 | + { }, | |
| 1090 | 1089 | }; |
| 1091 | 1090 | |
| 1092 | 1091 | static const struct phm_master_table_header cz_enable_dpm_master = { |
| @@ -1162,13 +1161,13 @@ static int cz_hwmgr_backend_init(struct pp_hwmgr *hwmgr) · 69 unmodified lines | ||
| 1162 | 1161 | |
| 1163 | 1162 | result = cz_initialize_dpm_defaults(hwmgr); |
| 1164 | 1163 | if (result != 0) { |
| 1165 | − printk(KERN_ERR "[ powerplay ] cz_initialize_dpm_defaults failed\n"); | |
| 1164 | + pr_err("cz_initialize_dpm_defaults failed\n"); | |
| 1166 | 1165 | return result; |
| 1167 | 1166 | } |
| 1168 | 1167 | |
| 1169 | 1168 | result = cz_get_system_info_data(hwmgr); |
| 1170 | 1169 | if (result != 0) { |
| 1171 | − printk(KERN_ERR "[ powerplay ] cz_get_system_info_data failed\n"); | |
| 1170 | + pr_err("cz_get_system_info_data failed\n"); | |
| 1172 | 1171 | return result; |
| 1173 | 1172 | } |
| 1174 | 1173 | |
| @@ -1177,40 +1176,40 @@ static int cz_hwmgr_backend_init(struct pp_hwmgr *hwmgr) · 2 unmodified lines | ||
| 1177 | 1176 | result = phm_construct_table(hwmgr, &cz_setup_asic_master, |
| 1178 | 1177 | &(hwmgr->setup_asic)); |
| 1179 | 1178 | if (result != 0) { |
| 1180 | − printk(KERN_ERR "[ powerplay ] Fail to construct setup ASIC\n"); | |
| 1179 | + pr_err("Fail to construct setup ASIC\n"); | |
| 1181 | 1180 | return result; |
| 1182 | 1181 | } |
| 1183 | 1182 | |
| 1184 | 1183 | result = phm_construct_table(hwmgr, &cz_power_down_asic_master, |
| 1185 | 1184 | &(hwmgr->power_down_asic)); |
| 1186 | 1185 | if (result != 0) { |
| 1187 | − printk(KERN_ERR "[ powerplay ] Fail to construct power down ASIC\n"); | |
| 1186 | + pr_err("Fail to construct power down ASIC\n"); | |
| 1188 | 1187 | return result; |
| 1189 | 1188 | } |
| 1190 | 1189 | |
| 1191 | 1190 | result = phm_construct_table(hwmgr, &cz_disable_dpm_master, |
| 1192 | 1191 | &(hwmgr->disable_dynamic_state_management)); |
| 1193 | 1192 | if (result != 0) { |
| 1194 | − printk(KERN_ERR "[ powerplay ] Fail to disable_dynamic_state\n"); | |
| 1193 | + pr_err("Fail to disable_dynamic_state\n"); | |
| 1195 | 1194 | return result; |
| 1196 | 1195 | } |
| 1197 | 1196 | result = phm_construct_table(hwmgr, &cz_enable_dpm_master, |
| 1198 | 1197 | &(hwmgr->enable_dynamic_state_management)); |
| 1199 | 1198 | if (result != 0) { |
| 1200 | − printk(KERN_ERR "[ powerplay ] Fail to enable_dynamic_state\n"); | |
| 1199 | + pr_err("Fail to enable_dynamic_state\n"); | |
| 1201 | 1200 | return result; |
| 1202 | 1201 | } |
| 1203 | 1202 | result = phm_construct_table(hwmgr, &cz_set_power_state_master, |
| 1204 | 1203 | &(hwmgr->set_power_state)); |
| 1205 | 1204 | if (result != 0) { |
| 1206 | − printk(KERN_ERR "[ powerplay ] Fail to construct set_power_state\n"); | |
| 1205 | + pr_err("Fail to construct set_power_state\n"); | |
| 1207 | 1206 | return result; |
| 1208 | 1207 | } |
| 1209 | 1208 | hwmgr->platform_descriptor.hardwareActivityPerformanceLevels = CZ_MAX_HARDWARE_POWERLEVELS; |
| 1210 | 1209 | |
| 1211 | 1210 | result = phm_construct_table(hwmgr, &cz_phm_enable_clock_power_gatings_master, &(hwmgr->enable_clock_power_gatings)); |
| 1212 | 1211 | if (result != 0) { |
| 1213 | − printk(KERN_ERR "[ powerplay ] Fail to construct enable_clock_power_gatings\n"); | |
| 1212 | + pr_err("Fail to construct enable_clock_power_gatings\n"); | |
| 1214 | 1213 | return result; |
| 1215 | 1214 | } |
| 1216 | 1215 | return result; |
| @@ -1218,9 +1217,15 @@ static int cz_hwmgr_backend_init(struct pp_hwmgr *hwmgr) · 1 unmodified line | ||
| 1218 | 1217 | |
| 1219 | 1218 | static int cz_hwmgr_backend_fini(struct pp_hwmgr *hwmgr) |
| 1220 | 1219 | { |
| 1221 | − if (hwmgr != NULL && hwmgr->backend != NULL) { | |
| 1220 | + if (hwmgr != NULL) { | |
| 1221 | + phm_destroy_table(hwmgr, &(hwmgr->enable_clock_power_gatings)); | |
| 1222 | + phm_destroy_table(hwmgr, &(hwmgr->set_power_state)); | |
| 1223 | + phm_destroy_table(hwmgr, &(hwmgr->enable_dynamic_state_management)); | |
| 1224 | + phm_destroy_table(hwmgr, &(hwmgr->disable_dynamic_state_management)); | |
| 1225 | + phm_destroy_table(hwmgr, &(hwmgr->power_down_asic)); | |
| 1226 | + phm_destroy_table(hwmgr, &(hwmgr->setup_asic)); | |
| 1222 | 1227 | kfree(hwmgr->backend); |
| 1223 | − kfree(hwmgr); | |
| 1228 | + hwmgr->backend = NULL; | |
| 1224 | 1229 | } |
| 1225 | 1230 | return 0; |
| 1226 | 1231 | } |
| @@ -1939,7 +1944,7 @@ static const struct pp_hwmgr_func cz_hwmgr_funcs = { · 712 unmodified lines | ||
| 1939 | 1944 | .read_sensor = cz_read_sensor, |
| 1940 | 1945 | }; |
| 1941 | 1946 | |
| 1942 | −int cz_hwmgr_init(struct pp_hwmgr *hwmgr) | |
| 1947 | +int cz_init_function_pointers(struct pp_hwmgr *hwmgr) | |
| 1943 | 1948 | { |
| 1944 | 1949 | hwmgr->hwmgr_func = &cz_hwmgr_funcs; |
| 1945 | 1950 | hwmgr->pptable_func = &pptable_funcs; |
| @@ -316,7 +316,6 @@ struct cz_hwmgr { · 315 unmodified lines | ||
| 316 | 316 | |
| 317 | 317 | struct pp_hwmgr; |
| 318 | 318 | |
| 319 | −int cz_hwmgr_init(struct pp_hwmgr *hwmgr); | |
| 320 | 319 | int cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr); |
| 321 | 320 | int cz_dpm_powerup_uvd(struct pp_hwmgr *hwmgr); |
| 322 | 321 | int cz_dpm_powerdown_vce(struct pp_hwmgr *hwmgr); |
| @@ -35,7 +35,7 @@ static int phm_run_table(struct pp_hwmgr *hwmgr, · 34 unmodified lines | ||
| 35 | 35 | phm_table_function *function; |
| 36 | 36 | |
| 37 | 37 | if (rt_table->function_list == NULL) { |
| 38 | − pr_debug("[ powerplay ] this function not implement!\n"); | |
| 38 | + pr_debug("this function not implement!\n"); | |
| 39 | 39 | return 0; |
| 40 | 40 | } |
| 41 | 41 | |
| @@ -63,14 +63,14 @@ int phm_dispatch_table(struct pp_hwmgr *hwmgr, · 21 unmodified lines | ||
| 63 | 63 | void *temp_storage; |
| 64 | 64 | |
| 65 | 65 | if (hwmgr == NULL || rt_table == NULL) { |
| 66 | − printk(KERN_ERR "[ powerplay ] Invalid Parameter!\n"); | |
| 66 | + pr_err("Invalid Parameter!\n"); | |
| 67 | 67 | return -EINVAL; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if (0 != rt_table->storage_size) { |
| 71 | 71 | temp_storage = kzalloc(rt_table->storage_size, GFP_KERNEL); |
| 72 | 72 | if (temp_storage == NULL) { |
| 73 | − printk(KERN_ERR "[ powerplay ] Could not allocate table temporary storage\n"); | |
| 73 | + pr_err("Could not allocate table temporary storage\n"); | |
| 74 | 74 | return -ENOMEM; |
| 75 | 75 | } |
| 76 | 76 | } else { |
| @@ -95,7 +95,7 @@ int phm_construct_table(struct pp_hwmgr *hwmgr, · 18 unmodified lines | ||
| 95 | 95 | phm_table_function *rtf; |
| 96 | 96 | |
| 97 | 97 | if (hwmgr == NULL || master_table == NULL || rt_table == NULL) { |
| 98 | − printk(KERN_ERR "[ powerplay ] Invalid Parameter!\n"); | |
| 98 | + pr_err("Invalid Parameter!\n"); | |
| 99 | 99 | return -EINVAL; |
| 100 | 100 | } |
| 101 | 101 | |
| @@ -116,7 +116,7 @@ int phm_construct_table(struct pp_hwmgr *hwmgr, · 14 unmodified lines | ||
| 116 | 116 | for (table_item = master_table->master_list; |
| 117 | 117 | NULL != table_item->tableFunction; table_item++) { |
| 118 | 118 | if ((rtf - run_time_list) > function_count) { |
| 119 | − printk(KERN_ERR "[ powerplay ] Check function results have changed\n"); | |
| 119 | + pr_err("Check function results have changed\n"); | |
| 120 | 120 | kfree(run_time_list); |
| 121 | 121 | return -EINVAL; |
| 122 | 122 | } |
| @@ -128,7 +128,7 @@ int phm_construct_table(struct pp_hwmgr *hwmgr, · 5 unmodified lines | ||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | if ((rtf - run_time_list) > function_count) { |
| 131 | − printk(KERN_ERR "[ powerplay ] Check function results have changed\n"); | |
| 131 | + pr_err("Check function results have changed\n"); | |
| 132 | 132 | kfree(run_time_list); |
| 133 | 133 | return -EINVAL; |
| 134 | 134 | } |
| @@ -144,7 +144,7 @@ int phm_destroy_table(struct pp_hwmgr *hwmgr, · 9 unmodified lines | ||
| 144 | 144 | struct phm_runtime_table_header *rt_table) |
| 145 | 145 | { |
| 146 | 146 | if (hwmgr == NULL || rt_table == NULL) { |
| 147 | − printk(KERN_ERR "[ powerplay ] Invalid Parameter\n"); | |
| 147 | + pr_err("Invalid Parameter\n"); | |
| 148 | 148 | return -EINVAL; |
| 149 | 149 | } |
| 150 | 150 | |
| @@ -20,11 +20,11 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | +#include "pp_debug.h" | |
| 23 | 24 | #include <linux/errno.h> |
| 24 | 25 | #include "hwmgr.h" |
| 25 | 26 | #include "hardwaremanager.h" |
| 26 | 27 | #include "power_state.h" |
| 27 | −#include "pp_debug.h" | |
| 28 | 28 | |
| 29 | 29 | #define PHM_FUNC_CHECK(hw) \ |
| 30 | 30 | do { \ |
| @@ -20,6 +20,8 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | + | |
| 24 | +#include "pp_debug.h" | |
| 23 | 25 | #include "linux/delay.h" |
| 24 | 26 | #include <linux/types.h> |
| 25 | 27 | #include <linux/kernel.h> |
| @@ -29,13 +31,12 @@ · 3 unmodified lines | ||
| 29 | 31 | #include "power_state.h" |
| 30 | 32 | #include "hwmgr.h" |
| 31 | 33 | #include "pppcielanes.h" |
| 32 | −#include "pp_debug.h" | |
| 33 | 34 | #include "ppatomctrl.h" |
| 34 | 35 | #include "ppsmc.h" |
| 35 | 36 | #include "pp_acpi.h" |
| 36 | 37 | #include "amd_acpi.h" |
| 37 | 38 | |
| 38 | −extern int cz_hwmgr_init(struct pp_hwmgr *hwmgr); | |
| 39 | +extern int cz_init_function_pointers(struct pp_hwmgr *hwmgr); | |
| 39 | 40 | |
| 40 | 41 | static int polaris_set_asic_special_caps(struct pp_hwmgr *hwmgr); |
| 41 | 42 | static void hwmgr_init_default_caps(struct pp_hwmgr *hwmgr); |
| @@ -49,11 +50,11 @@ uint8_t convert_to_vid(uint16_t vddc) · 7 unmodified lines | ||
| 49 | 50 | return (uint8_t) ((6200 - (vddc * VOLTAGE_SCALE)) / 25); |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | −int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle) | |
| 53 | +int hwmgr_early_init(struct pp_instance *handle) | |
| 53 | 54 | { |
| 54 | 55 | struct pp_hwmgr *hwmgr; |
| 55 | 56 | |
| 56 | − if ((handle == NULL) || (pp_init == NULL)) | |
| 57 | + if (handle == NULL) | |
| 57 | 58 | return -EINVAL; |
| 58 | 59 | |
| 59 | 60 | hwmgr = kzalloc(sizeof(struct pp_hwmgr), GFP_KERNEL); |
| @@ -62,19 +63,20 @@ int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle) · 2 unmodified lines | ||
| 62 | 63 | |
| 63 | 64 | handle->hwmgr = hwmgr; |
| 64 | 65 | hwmgr->smumgr = handle->smu_mgr; |
| 65 | − hwmgr->device = pp_init->device; | |
| 66 | − hwmgr->chip_family = pp_init->chip_family; | |
| 67 | − hwmgr->chip_id = pp_init->chip_id; | |
| 66 | + hwmgr->device = handle->device; | |
| 67 | + hwmgr->chip_family = handle->chip_family; | |
| 68 | + hwmgr->chip_id = handle->chip_id; | |
| 69 | + hwmgr->feature_mask = handle->feature_mask; | |
| 68 | 70 | hwmgr->usec_timeout = AMD_MAX_USEC_TIMEOUT; |
| 69 | 71 | hwmgr->power_source = PP_PowerSource_AC; |
| 70 | 72 | hwmgr->pp_table_version = PP_TABLE_V1; |
| 71 | − | |
| 73 | + hwmgr->dpm_level = AMD_DPM_FORCED_LEVEL_AUTO; | |
| 72 | 74 | hwmgr_init_default_caps(hwmgr); |
| 73 | 75 | hwmgr_set_user_specify_caps(hwmgr); |
| 74 | 76 | |
| 75 | 77 | switch (hwmgr->chip_family) { |
| 76 | 78 | case AMDGPU_FAMILY_CZ: |
| 77 | − cz_hwmgr_init(hwmgr); | |
| 79 | + cz_init_function_pointers(hwmgr); | |
| 78 | 80 | break; |
| 79 | 81 | case AMDGPU_FAMILY_VI: |
| 80 | 82 | switch (hwmgr->chip_id) { |
| @@ -102,7 +104,7 @@ int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle) · 21 unmodified lines | ||
| 102 | 104 | default: |
| 103 | 105 | return -EINVAL; |
| 104 | 106 | } |
| 105 | − smu7_hwmgr_init(hwmgr); | |
| 107 | + smu7_init_function_pointers(hwmgr); | |
| 106 | 108 | break; |
| 107 | 109 | default: |
| 108 | 110 | return -EINVAL; |
| @@ -111,28 +113,7 @@ int hwmgr_init(struct amd_pp_init *pp_init, struct pp_instance *handle) · 2 unmodified lines | ||
| 111 | 113 | return 0; |
| 112 | 114 | } |
| 113 | 115 | |
| 114 | −int hwmgr_fini(struct pp_hwmgr *hwmgr) | |
| 115 | −{ | |
| 116 | − if (hwmgr == NULL || hwmgr->ps == NULL) | |
| 117 | − return -EINVAL; | |
| 118 | − | |
| 119 | − /* do hwmgr finish*/ | |
| 120 | − kfree(hwmgr->hardcode_pp_table); | |
| 121 | − | |
| 122 | − kfree(hwmgr->backend); | |
| 123 | − | |
| 124 | − kfree(hwmgr->start_thermal_controller.function_list); | |
| 125 | − | |
| 126 | − kfree(hwmgr->set_temperature_range.function_list); | |
| 127 | − | |
| 128 | − kfree(hwmgr->ps); | |
| 129 | − kfree(hwmgr->current_ps); | |
| 130 | − kfree(hwmgr->request_ps); | |
| 131 | − kfree(hwmgr); | |
| 132 | − return 0; | |
| 133 | −} | |
| 134 | − | |
| 135 | −int hw_init_power_state_table(struct pp_hwmgr *hwmgr) | |
| 116 | +static int hw_init_power_state_table(struct pp_hwmgr *hwmgr) | |
| 136 | 117 | { |
| 137 | 118 | int result; |
| 138 | 119 | unsigned int i; |
| @@ -156,12 +137,20 @@ int hw_init_power_state_table(struct pp_hwmgr *hwmgr) · 17 unmodified lines | ||
| 156 | 137 | return -ENOMEM; |
| 157 | 138 | |
| 158 | 139 | hwmgr->request_ps = kzalloc(size, GFP_KERNEL); |
| 159 | − if (hwmgr->request_ps == NULL) | |
| 140 | + if (hwmgr->request_ps == NULL) { | |
| 141 | + kfree(hwmgr->ps); | |
| 142 | + hwmgr->ps = NULL; | |
| 160 | 143 | return -ENOMEM; |
| 144 | + } | |
| 161 | 145 | |
| 162 | 146 | hwmgr->current_ps = kzalloc(size, GFP_KERNEL); |
| 163 | − if (hwmgr->current_ps == NULL) | |
| 147 | + if (hwmgr->current_ps == NULL) { | |
| 148 | + kfree(hwmgr->request_ps); | |
| 149 | + kfree(hwmgr->ps); | |
| 150 | + hwmgr->request_ps = NULL; | |
| 151 | + hwmgr->ps = NULL; | |
| 164 | 152 | return -ENOMEM; |
| 153 | + } | |
| 165 | 154 | |
| 166 | 155 | state = hwmgr->ps; |
| 167 | 156 | |
| @@ -181,10 +170,77 @@ int hw_init_power_state_table(struct pp_hwmgr *hwmgr) · 13 unmodified lines | ||
| 181 | 170 | state = (struct pp_power_state *)((unsigned long)state + size); |
| 182 | 171 | } |
| 183 | 172 | |
| 173 | + return 0; | |
| 174 | +} | |
| 184 | 175 | |
| 176 | +static int hw_fini_power_state_table(struct pp_hwmgr *hwmgr) | |
| 177 | +{ | |
| 178 | + if (hwmgr == NULL) | |
| 179 | + return -EINVAL; | |
| 180 | + | |
| 181 | + kfree(hwmgr->current_ps); | |
| 182 | + kfree(hwmgr->request_ps); | |
| 183 | + kfree(hwmgr->ps); | |
| 184 | + hwmgr->request_ps = NULL; | |
| 185 | + hwmgr->ps = NULL; | |
| 186 | + hwmgr->current_ps = NULL; | |
| 185 | 187 | return 0; |
| 186 | 188 | } |
| 187 | 189 | |
| 190 | +int hwmgr_hw_init(struct pp_instance *handle) | |
| 191 | +{ | |
| 192 | + struct pp_hwmgr *hwmgr; | |
| 193 | + int ret = 0; | |
| 194 | + | |
| 195 | + if (handle == NULL) | |
| 196 | + return -EINVAL; | |
| 197 | + | |
| 198 | + hwmgr = handle->hwmgr; | |
| 199 | + | |
| 200 | + if (hwmgr->pptable_func == NULL || | |
| 201 | + hwmgr->pptable_func->pptable_init == NULL || | |
| 202 | + hwmgr->hwmgr_func->backend_init == NULL) | |
| 203 | + return -EINVAL; | |
| 204 | + | |
| 205 | + ret = hwmgr->pptable_func->pptable_init(hwmgr); | |
| 206 | + if (ret) | |
| 207 | + goto err; | |
| 208 | + | |
| 209 | + ret = hwmgr->hwmgr_func->backend_init(hwmgr); | |
| 210 | + if (ret) | |
| 211 | + goto err1; | |
| 212 | + | |
| 213 | + ret = hw_init_power_state_table(hwmgr); | |
| 214 | + if (ret) | |
| 215 | + goto err2; | |
| 216 | + return 0; | |
| 217 | +err2: | |
| 218 | + if (hwmgr->hwmgr_func->backend_fini) | |
| 219 | + hwmgr->hwmgr_func->backend_fini(hwmgr); | |
| 220 | +err1: | |
| 221 | + if (hwmgr->pptable_func->pptable_fini) | |
| 222 | + hwmgr->pptable_func->pptable_fini(hwmgr); | |
| 223 | +err: | |
| 224 | + pr_err("amdgpu: powerplay initialization failed\n"); | |
| 225 | + return ret; | |
| 226 | +} | |
| 227 | + | |
| 228 | +int hwmgr_hw_fini(struct pp_instance *handle) | |
| 229 | +{ | |
| 230 | + struct pp_hwmgr *hwmgr; | |
| 231 | + | |
| 232 | + if (handle == NULL) | |
| 233 | + return -EINVAL; | |
| 234 | + | |
| 235 | + hwmgr = handle->hwmgr; | |
| 236 | + | |
| 237 | + if (hwmgr->hwmgr_func->backend_fini) | |
| 238 | + hwmgr->hwmgr_func->backend_fini(hwmgr); | |
| 239 | + if (hwmgr->pptable_func->pptable_fini) | |
| 240 | + hwmgr->pptable_func->pptable_fini(hwmgr); | |
| 241 | + return hw_fini_power_state_table(hwmgr); | |
| 242 | +} | |
| 243 | + | |
| 188 | 244 | |
| 189 | 245 | /** |
| 190 | 246 | * Returns once the part of the register indicated by the mask has |
| @@ -197,7 +253,7 @@ int phm_wait_on_register(struct pp_hwmgr *hwmgr, uint32_t index, · 6 unmodified lines | ||
| 197 | 253 | uint32_t cur_value; |
| 198 | 254 | |
| 199 | 255 | if (hwmgr == NULL || hwmgr->device == NULL) { |
| 200 | − printk(KERN_ERR "[ powerplay ] Invalid Hardware Manager!"); | |
| 256 | + pr_err("Invalid Hardware Manager!"); | |
| 201 | 257 | return -EINVAL; |
| 202 | 258 | } |
| 203 | 259 | |
| @@ -227,7 +283,7 @@ void phm_wait_on_indirect_register(struct pp_hwmgr *hwmgr, · 23 unmodified lines | ||
| 227 | 283 | uint32_t mask) |
| 228 | 284 | { |
| 229 | 285 | if (hwmgr == NULL || hwmgr->device == NULL) { |
| 230 | − printk(KERN_ERR "[ powerplay ] Invalid Hardware Manager!"); | |
| 286 | + pr_err("Invalid Hardware Manager!"); | |
| 231 | 287 | return; |
| 232 | 288 | } |
| 233 | 289 | |
| @@ -288,7 +344,7 @@ int phm_trim_voltage_table(struct pp_atomctrl_voltage_table *vol_table) · 54 unmodified lines | ||
| 288 | 344 | |
| 289 | 345 | memcpy(vol_table, table, sizeof(struct pp_atomctrl_voltage_table)); |
| 290 | 346 | kfree(table); |
| 291 | − | |
| 347 | + table = NULL; | |
| 292 | 348 | return 0; |
| 293 | 349 | } |
| 294 | 350 | |
| @@ -549,7 +605,7 @@ int phm_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr · 254 unmodified lines | ||
| 549 | 605 | table_clk_vlt = kzalloc(table_size, GFP_KERNEL); |
| 550 | 606 | |
| 551 | 607 | if (NULL == table_clk_vlt) { |
| 552 | − printk(KERN_ERR "[ powerplay ] Can not allocate space for vddc_dep_on_dal_pwrl! \n"); | |
| 608 | + pr_err("Can not allocate space for vddc_dep_on_dal_pwrl! \n"); | |
| 553 | 609 | return -ENOMEM; |
| 554 | 610 | } else { |
| 555 | 611 | table_clk_vlt->count = 4; |
| @@ -569,21 +625,6 @@ int phm_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr · 13 unmodified lines | ||
| 569 | 625 | return 0; |
| 570 | 626 | } |
| 571 | 627 | |
| 572 | −int phm_hwmgr_backend_fini(struct pp_hwmgr *hwmgr) | |
| 573 | −{ | |
| 574 | − if (NULL != hwmgr->dyn_state.vddc_dep_on_dal_pwrl) { | |
| 575 | − kfree(hwmgr->dyn_state.vddc_dep_on_dal_pwrl); | |
| 576 | − hwmgr->dyn_state.vddc_dep_on_dal_pwrl = NULL; | |
| 577 | − } | |
| 578 | − | |
| 579 | − if (NULL != hwmgr->backend) { | |
| 580 | − kfree(hwmgr->backend); | |
| 581 | − hwmgr->backend = NULL; | |
| 582 | − } | |
| 583 | − | |
| 584 | − return 0; | |
| 585 | −} | |
| 586 | − | |
| 587 | 628 | uint32_t phm_get_lowest_enabled_level(struct pp_hwmgr *hwmgr, uint32_t mask) |
| 588 | 629 | { |
| 589 | 630 | uint32_t level = 0; |
| @@ -625,7 +666,7 @@ void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr) · 35 unmodified lines | ||
| 625 | 666 | return; |
| 626 | 667 | } |
| 627 | 668 | } |
| 628 | − printk(KERN_ERR "DAL requested level can not" | |
| 669 | + pr_err("DAL requested level can not" | |
| 629 | 670 | " found a available voltage in VDDC DPM Table \n"); |
| 630 | 671 | } |
| 631 | 672 | |
| @@ -683,14 +724,14 @@ void hwmgr_init_default_caps(struct pp_hwmgr *hwmgr) · 51 unmodified lines | ||
| 683 | 724 | |
| 684 | 725 | int hwmgr_set_user_specify_caps(struct pp_hwmgr *hwmgr) |
| 685 | 726 | { |
| 686 | − if (amdgpu_pp_feature_mask & PP_SCLK_DEEP_SLEEP_MASK) | |
| 727 | + if (hwmgr->feature_mask & PP_SCLK_DEEP_SLEEP_MASK) | |
| 687 | 728 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, |
| 688 | 729 | PHM_PlatformCaps_SclkDeepSleep); |
| 689 | 730 | else |
| 690 | 731 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, |
| 691 | 732 | PHM_PlatformCaps_SclkDeepSleep); |
| 692 | 733 | |
| 693 | − if (amdgpu_pp_feature_mask & PP_POWER_CONTAINMENT_MASK) { | |
| 734 | + if (hwmgr->feature_mask & PP_POWER_CONTAINMENT_MASK) { | |
| 694 | 735 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, |
| 695 | 736 | PHM_PlatformCaps_PowerContainment); |
| 696 | 737 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, |
| @@ -701,7 +742,6 @@ int hwmgr_set_user_specify_caps(struct pp_hwmgr *hwmgr) · 4 unmodified lines | ||
| 701 | 742 | phm_cap_unset(hwmgr->platform_descriptor.platformCaps, |
| 702 | 743 | PHM_PlatformCaps_CAC); |
| 703 | 744 | } |
| 704 | − hwmgr->feature_mask = amdgpu_pp_feature_mask; | |
| 705 | 745 | |
| 706 | 746 | return 0; |
| 707 | 747 | } |
| @@ -727,16 +767,9 @@ int phm_get_voltage_evv_on_sclk(struct pp_hwmgr *hwmgr, uint8_t voltage_type, · 19 unmodified lines | ||
| 727 | 767 | |
| 728 | 768 | int polaris_set_asic_special_caps(struct pp_hwmgr *hwmgr) |
| 729 | 769 | { |
| 730 | − /* power tune caps Assume disabled */ | |
| 770 | + | |
| 731 | 771 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, |
| 732 | 772 | PHM_PlatformCaps_SQRamping); |
| 733 | − phm_cap_set(hwmgr->platform_descriptor.platformCaps, | |
| 734 | − PHM_PlatformCaps_DBRamping); | |
| 735 | − phm_cap_set(hwmgr->platform_descriptor.platformCaps, | |
| 736 | − PHM_PlatformCaps_TDRamping); | |
| 737 | − phm_cap_set(hwmgr->platform_descriptor.platformCaps, | |
| 738 | − PHM_PlatformCaps_TCPRamping); | |
| 739 | − | |
| 740 | 773 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, |
| 741 | 774 | PHM_PlatformCaps_RegulatorHot); |
| 742 | 775 | |
| @@ -746,9 +779,19 @@ int polaris_set_asic_special_caps(struct pp_hwmgr *hwmgr) · 3 unmodified lines | ||
| 746 | 779 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, |
| 747 | 780 | PHM_PlatformCaps_TablelessHardwareInterface); |
| 748 | 781 | |
| 749 | − if ((hwmgr->chip_id == CHIP_POLARIS11) || (hwmgr->chip_id == CHIP_POLARIS12)) | |
| 782 | + | |
| 783 | + if (hwmgr->chip_id != CHIP_POLARIS10) | |
| 750 | 784 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, |
| 751 | 785 | PHM_PlatformCaps_SPLLShutdownSupport); |
| 786 | + | |
| 787 | + if (hwmgr->chip_id != CHIP_POLARIS11) { | |
| 788 | + phm_cap_set(hwmgr->platform_descriptor.platformCaps, | |
| 789 | + PHM_PlatformCaps_DBRamping); | |
| 790 | + phm_cap_set(hwmgr->platform_descriptor.platformCaps, | |
| 791 | + PHM_PlatformCaps_TDRamping); | |
| 792 | + phm_cap_set(hwmgr->platform_descriptor.platformCaps, | |
| 793 | + PHM_PlatformCaps_TCPRamping); | |
| 794 | + } | |
| 752 | 795 | return 0; |
| 753 | 796 | } |
| 754 | 797 | |
| @@ -20,13 +20,13 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | +#include "pp_debug.h" | |
| 23 | 24 | #include <linux/module.h> |
| 24 | 25 | #include <linux/slab.h> |
| 25 | 26 | |
| 26 | 27 | #include "ppatomctrl.h" |
| 27 | 28 | #include "atombios.h" |
| 28 | 29 | #include "cgs_common.h" |
| 29 | −#include "pp_debug.h" | |
| 30 | 30 | #include "ppevvmath.h" |
| 31 | 31 | |
| 32 | 32 | #define MEM_ID_MASK 0xff000000 |
| @@ -145,10 +145,10 @@ int atomctrl_initialize_mc_reg_table( · 112 unmodified lines | ||
| 145 | 145 | GetIndexIntoMasterTable(DATA, VRAM_Info), &size, &frev, &crev); |
| 146 | 146 | |
| 147 | 147 | if (module_index >= vram_info->ucNumOfVRAMModule) { |
| 148 | − printk(KERN_ERR "[ powerplay ] Invalid VramInfo table."); | |
| 148 | + pr_err("Invalid VramInfo table."); | |
| 149 | 149 | result = -1; |
| 150 | 150 | } else if (vram_info->sHeader.ucTableFormatRevision < 2) { |
| 151 | − printk(KERN_ERR "[ powerplay ] Invalid VramInfo table."); | |
| 151 | + pr_err("Invalid VramInfo table."); | |
| 152 | 152 | result = -1; |
| 153 | 153 | } |
| 154 | 154 | |
| @@ -688,7 +688,7 @@ int atomctrl_calculate_voltage_evv_on_sclk( · 533 unmodified lines | ||
| 688 | 688 | fDerateTDP = GetScaledFraction(le32_to_cpu(getASICProfilingInfo->ulTdpDerateDPM7), 1000); |
| 689 | 689 | break; |
| 690 | 690 | default: |
| 691 | − printk(KERN_ERR "DPM Level not supported\n"); | |
| 691 | + pr_err("DPM Level not supported\n"); | |
| 692 | 692 | fPowerDPMx = Convert_ULONG_ToFraction(1); |
| 693 | 693 | fDerateTDP = GetScaledFraction(le32_to_cpu(getASICProfilingInfo->ulTdpDerateDPM0), 1000); |
| 694 | 694 | } |
| @@ -20,13 +20,13 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | +#include "pp_debug.h" | |
| 23 | 24 | #include <linux/module.h> |
| 24 | 25 | #include <linux/slab.h> |
| 25 | 26 | |
| 26 | 27 | #include "process_pptables_v1_0.h" |
| 27 | 28 | #include "ppatomctrl.h" |
| 28 | 29 | #include "atombios.h" |
| 29 | −#include "pp_debug.h" | |
| 30 | 30 | #include "hwmgr.h" |
| 31 | 31 | #include "cgs_common.h" |
| 32 | 32 | #include "pptable_v1_0.h" |
| @@ -535,7 +535,7 @@ static int get_pcie_table( · 502 unmodified lines | ||
| 535 | 535 | if ((uint32_t)atom_pcie_table->ucNumEntries <= pcie_count) |
| 536 | 536 | pcie_count = (uint32_t)atom_pcie_table->ucNumEntries; |
| 537 | 537 | else |
| 538 | − printk(KERN_ERR "[ powerplay ] Number of Pcie Entries exceed the number of SCLK Dpm Levels! \ | |
| 538 | + pr_err("Number of Pcie Entries exceed the number of SCLK Dpm Levels! \ | |
| 539 | 539 | Disregarding the excess entries... \n"); |
| 540 | 540 | |
| 541 | 541 | pcie_table->count = pcie_count; |
| @@ -577,7 +577,7 @@ static int get_pcie_table( · 35 unmodified lines | ||
| 577 | 577 | if ((uint32_t)atom_pcie_table->ucNumEntries <= pcie_count) |
| 578 | 578 | pcie_count = (uint32_t)atom_pcie_table->ucNumEntries; |
| 579 | 579 | else |
| 580 | − printk(KERN_ERR "[ powerplay ] Number of Pcie Entries exceed the number of SCLK Dpm Levels! \ | |
| 580 | + pr_err("Number of Pcie Entries exceed the number of SCLK Dpm Levels! \ | |
| 581 | 581 | Disregarding the excess entries... \n"); |
| 582 | 582 | |
| 583 | 583 | pcie_table->count = pcie_count; |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | +#include "pp_debug.h" | |
| 23 | 24 | #include <linux/types.h> |
| 24 | 25 | #include <linux/kernel.h> |
| 25 | 26 | #include <linux/slab.h> |
| @@ -27,7 +28,6 @@ · 1 unmodified line | ||
| 27 | 28 | #include "processpptables.h" |
| 28 | 29 | #include <atom-types.h> |
| 29 | 30 | #include <atombios.h> |
| 30 | −#include "pp_debug.h" | |
| 31 | 31 | #include "pptable.h" |
| 32 | 32 | #include "power_state.h" |
| 33 | 33 | #include "hwmgr.h" |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | 24 | #ifndef _SMU7_CLOCK_POWER_GATING_H_ |
| 25 | −#define _SMU7_CLOCK__POWER_GATING_H_ | |
| 25 | +#define _SMU7_CLOCK_POWER_GATING_H_ | |
| 26 | 26 | |
| 27 | 27 | #include "smu7_hwmgr.h" |
| 28 | 28 | #include "pp_asicblocks.h" |
| @@ -20,13 +20,13 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | +#include "pp_debug.h" | |
| 23 | 24 | #include <linux/module.h> |
| 24 | 25 | #include <linux/slab.h> |
| 25 | 26 | #include <linux/fb.h> |
| 26 | 27 | #include <asm/div64.h> |
| 27 | 28 | #include "linux/delay.h" |
| 28 | 29 | #include "pp_acpi.h" |
| 29 | −#include "pp_debug.h" | |
| 30 | 30 | #include "ppatomctrl.h" |
| 31 | 31 | #include "atombios.h" |
| 32 | 32 | #include "pptable_v1_0.h" |
| @@ -40,6 +40,8 @@ · 7 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | #include "hwmgr.h" |
| 42 | 42 | #include "smu7_hwmgr.h" |
| 43 | +#include "smu7_smumgr.h" | |
| 44 | +#include "smu_ucode_xfer_vi.h" | |
| 43 | 45 | #include "smu7_powertune.h" |
| 44 | 46 | #include "smu7_dyn_defaults.h" |
| 45 | 47 | #include "smu7_thermal.h" |
| @@ -88,6 +90,8 @@ enum DPM_EVENT_SRC { · 42 unmodified lines | ||
| 88 | 90 | }; |
| 89 | 91 | |
| 90 | 92 | static const unsigned long PhwVIslands_Magic = (unsigned long)(PHM_VIslands_Magic); |
| 93 | +static int smu7_force_clock_level(struct pp_hwmgr *hwmgr, | |
| 94 | + enum pp_clock_type type, uint32_t mask); | |
| 91 | 95 | |
| 92 | 96 | static struct smu7_power_state *cast_phw_smu7_power_state( |
| 93 | 97 | struct pp_hw_power_state *hw_ps) |
| @@ -994,7 +998,7 @@ static int smu7_start_dpm(struct pp_hwmgr *hwmgr) · 900 unmodified lines | ||
| 994 | 998 | SWRST_COMMAND_1, RESETLC, 0x0); |
| 995 | 999 | |
| 996 | 1000 | if (smu7_enable_sclk_mclk_dpm(hwmgr)) { |
| 997 | − printk(KERN_ERR "Failed to enable Sclk DPM and Mclk DPM!"); | |
| 1001 | + pr_err("Failed to enable Sclk DPM and Mclk DPM!"); | |
| 998 | 1002 | return -EINVAL; |
| 999 | 1003 | } |
| 1000 | 1004 | |
| @@ -1079,7 +1083,7 @@ static void smu7_set_dpm_event_sources(struct pp_hwmgr *hwmgr, uint32_t sources) · 78 unmodified lines | ||
| 1079 | 1083 | |
| 1080 | 1084 | switch (sources) { |
| 1081 | 1085 | default: |
| 1082 | − printk(KERN_ERR "Unknown throttling event sources."); | |
| 1086 | + pr_err("Unknown throttling event sources."); | |
| 1083 | 1087 | /* fall through */ |
| 1084 | 1088 | case 0: |
| 1085 | 1089 | protection = false; |
| @@ -1292,6 +1296,10 @@ int smu7_disable_dpm_tasks(struct pp_hwmgr *hwmgr) · 206 unmodified lines | ||
| 1292 | 1296 | PP_ASSERT_WITH_CODE((tmp_result == 0), |
| 1293 | 1297 | "Failed to disable SMC CAC!", result = tmp_result); |
| 1294 | 1298 | |
| 1299 | + tmp_result = smu7_disable_didt_config(hwmgr); | |
| 1300 | + PP_ASSERT_WITH_CODE((tmp_result == 0), | |
| 1301 | + "Failed to disable DIDT!", result = tmp_result); | |
| 1302 | + | |
| 1295 | 1303 | PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, |
| 1296 | 1304 | CG_SPLL_SPREAD_SPECTRUM, SSEN, 0); |
| 1297 | 1305 | PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, |
| @@ -1499,7 +1507,7 @@ static int smu7_get_evv_voltages(struct pp_hwmgr *hwmgr) · 201 unmodified lines | ||
| 1499 | 1507 | data->vddcgfx_leakage.count++; |
| 1500 | 1508 | } |
| 1501 | 1509 | } else { |
| 1502 | − printk("Error retrieving EVV voltage value!\n"); | |
| 1510 | + pr_info("Error retrieving EVV voltage value!\n"); | |
| 1503 | 1511 | } |
| 1504 | 1512 | } |
| 1505 | 1513 | } else { |
| @@ -1527,7 +1535,7 @@ static int smu7_get_evv_voltages(struct pp_hwmgr *hwmgr) · 21 unmodified lines | ||
| 1527 | 1535 | if (vddc >= 2000 || vddc == 0) |
| 1528 | 1536 | return -EINVAL; |
| 1529 | 1537 | } else { |
| 1530 | − printk(KERN_WARNING "failed to retrieving EVV voltage!\n"); | |
| 1538 | + pr_warning("failed to retrieving EVV voltage!\n"); | |
| 1531 | 1539 | continue; |
| 1532 | 1540 | } |
| 1533 | 1541 | |
| @@ -1567,7 +1575,7 @@ static void smu7_patch_ppt_v1_with_vdd_leakage(struct pp_hwmgr *hwmgr, · 33 unmodified lines | ||
| 1567 | 1575 | } |
| 1568 | 1576 | |
| 1569 | 1577 | if (*voltage > ATOM_VIRTUAL_VOLTAGE_ID0) |
| 1570 | − printk(KERN_ERR "Voltage value looks like a Leakage ID but it's not patched \n"); | |
| 1578 | + pr_err("Voltage value looks like a Leakage ID but it's not patched \n"); | |
| 1571 | 1579 | } |
| 1572 | 1580 | |
| 1573 | 1581 | /** |
| @@ -2032,7 +2040,7 @@ static void smu7_patch_ppt_v0_with_vdd_leakage(struct pp_hwmgr *hwmgr, · 458 unmodified lines | ||
| 2032 | 2040 | } |
| 2033 | 2041 | |
| 2034 | 2042 | if (*voltage > ATOM_VIRTUAL_VOLTAGE_ID0) |
| 2035 | − printk(KERN_ERR "Voltage value looks like a Leakage ID but it's not patched \n"); | |
| 2043 | + pr_err("Voltage value looks like a Leakage ID but it's not patched \n"); | |
| 2036 | 2044 | } |
| 2037 | 2045 | |
| 2038 | 2046 | |
| @@ -2267,6 +2275,21 @@ static int smu7_set_private_data_based_on_pptable_v0(struct pp_hwmgr *hwmgr) · 228 unmodified lines | ||
| 2267 | 2275 | return 0; |
| 2268 | 2276 | } |
| 2269 | 2277 | |
| 2278 | +static int smu7_hwmgr_backend_fini(struct pp_hwmgr *hwmgr) | |
| 2279 | +{ | |
| 2280 | + if (NULL != hwmgr->dyn_state.vddc_dep_on_dal_pwrl) { | |
| 2281 | + kfree(hwmgr->dyn_state.vddc_dep_on_dal_pwrl); | |
| 2282 | + hwmgr->dyn_state.vddc_dep_on_dal_pwrl = NULL; | |
| 2283 | + } | |
| 2284 | + pp_smu7_thermal_fini(hwmgr); | |
| 2285 | + if (NULL != hwmgr->backend) { | |
| 2286 | + kfree(hwmgr->backend); | |
| 2287 | + hwmgr->backend = NULL; | |
| 2288 | + } | |
| 2289 | + | |
| 2290 | + return 0; | |
| 2291 | +} | |
| 2292 | + | |
| 2270 | 2293 | static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr) |
| 2271 | 2294 | { |
| 2272 | 2295 | struct smu7_hwmgr *data; |
| @@ -2277,6 +2300,7 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr) · 4 unmodified lines | ||
| 2277 | 2300 | return -ENOMEM; |
| 2278 | 2301 | |
| 2279 | 2302 | hwmgr->backend = data; |
| 2303 | + pp_smu7_thermal_initialize(hwmgr); | |
| 2280 | 2304 | |
| 2281 | 2305 | smu7_patch_voltage_workaround(hwmgr); |
| 2282 | 2306 | smu7_init_dpm_defaults(hwmgr); |
| @@ -2285,7 +2309,7 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr) · 2 unmodified lines | ||
| 2285 | 2309 | result = smu7_get_evv_voltages(hwmgr); |
| 2286 | 2310 | |
| 2287 | 2311 | if (result) { |
| 2288 | − printk("Get EVV Voltage Failed. Abort Driver loading!\n"); | |
| 2312 | + pr_info("Get EVV Voltage Failed. Abort Driver loading!\n"); | |
| 2289 | 2313 | return -EINVAL; |
| 2290 | 2314 | } |
| 2291 | 2315 | |
| @@ -2334,7 +2358,7 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr) · 42 unmodified lines | ||
| 2334 | 2358 | smu7_thermal_parameter_init(hwmgr); |
| 2335 | 2359 | } else { |
| 2336 | 2360 | /* Ignore return value in here, we are cleaning up a mess. */ |
| 2337 | − phm_hwmgr_backend_fini(hwmgr); | |
| 2361 | + smu7_hwmgr_backend_fini(hwmgr); | |
| 2338 | 2362 | } |
| 2339 | 2363 | |
| 2340 | 2364 | return 0; |
| @@ -2466,36 +2490,155 @@ static int smu7_force_dpm_lowest(struct pp_hwmgr *hwmgr) · 125 unmodified lines | ||
| 2466 | 2490 | } |
| 2467 | 2491 | |
| 2468 | 2492 | return 0; |
| 2493 | +} | |
| 2469 | 2494 | |
| 2495 | +static int smu7_get_profiling_clk(struct pp_hwmgr *hwmgr, enum amd_dpm_forced_level level, | |
| 2496 | + uint32_t *sclk_mask, uint32_t *mclk_mask, uint32_t *pcie_mask) | |
| 2497 | +{ | |
| 2498 | + uint32_t percentage; | |
| 2499 | + struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); | |
| 2500 | + struct smu7_dpm_table *golden_dpm_table = &data->golden_dpm_table; | |
| 2501 | + int32_t tmp_mclk; | |
| 2502 | + int32_t tmp_sclk; | |
| 2503 | + int32_t count; | |
| 2504 | + | |
| 2505 | + if (golden_dpm_table->mclk_table.count < 1) | |
| 2506 | + return -EINVAL; | |
| 2507 | + | |
| 2508 | + percentage = 100 * golden_dpm_table->sclk_table.dpm_levels[golden_dpm_table->sclk_table.count - 1].value / | |
| 2509 | + golden_dpm_table->mclk_table.dpm_levels[golden_dpm_table->mclk_table.count - 1].value; | |
| 2510 | + | |
| 2511 | + if (golden_dpm_table->mclk_table.count == 1) { | |
| 2512 | + percentage = 70; | |
| 2513 | + tmp_mclk = golden_dpm_table->mclk_table.dpm_levels[golden_dpm_table->mclk_table.count - 1].value; | |
| 2514 | + *mclk_mask = golden_dpm_table->mclk_table.count - 1; | |
| 2515 | + } else { | |
| 2516 | + tmp_mclk = golden_dpm_table->mclk_table.dpm_levels[golden_dpm_table->mclk_table.count - 2].value; | |
| 2517 | + *mclk_mask = golden_dpm_table->mclk_table.count - 2; | |
| 2518 | + } | |
| 2519 | + | |
| 2520 | + tmp_sclk = tmp_mclk * percentage / 100; | |
| 2521 | + | |
| 2522 | + if (hwmgr->pp_table_version == PP_TABLE_V0) { | |
| 2523 | + for (count = hwmgr->dyn_state.vddc_dependency_on_sclk->count-1; | |
| 2524 | + count >= 0; count--) { | |
| 2525 | + if (tmp_sclk >= hwmgr->dyn_state.vddc_dependency_on_sclk->entries[count].clk) { | |
| 2526 | + tmp_sclk = hwmgr->dyn_state.vddc_dependency_on_sclk->entries[count].clk; | |
| 2527 | + *sclk_mask = count; | |
| 2528 | + break; | |
| 2529 | + } | |
| 2530 | + } | |
| 2531 | + if (count < 0 || level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) | |
| 2532 | + *sclk_mask = 0; | |
| 2533 | + | |
| 2534 | + if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) | |
| 2535 | + *sclk_mask = hwmgr->dyn_state.vddc_dependency_on_sclk->count-1; | |
| 2536 | + } else if (hwmgr->pp_table_version == PP_TABLE_V1) { | |
| 2537 | + struct phm_ppt_v1_information *table_info = | |
| 2538 | + (struct phm_ppt_v1_information *)(hwmgr->pptable); | |
| 2539 | + | |
| 2540 | + for (count = table_info->vdd_dep_on_sclk->count-1; count >= 0; count--) { | |
| 2541 | + if (tmp_sclk >= table_info->vdd_dep_on_sclk->entries[count].clk) { | |
| 2542 | + tmp_sclk = table_info->vdd_dep_on_sclk->entries[count].clk; | |
| 2543 | + *sclk_mask = count; | |
| 2544 | + break; | |
| 2545 | + } | |
| 2546 | + } | |
| 2547 | + if (count < 0 || level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) | |
| 2548 | + *sclk_mask = 0; | |
| 2549 | + | |
| 2550 | + if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) | |
| 2551 | + *sclk_mask = table_info->vdd_dep_on_sclk->count - 1; | |
| 2552 | + } | |
| 2553 | + | |
| 2554 | + if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK) | |
| 2555 | + *mclk_mask = 0; | |
| 2556 | + else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) | |
| 2557 | + *mclk_mask = golden_dpm_table->mclk_table.count - 1; | |
| 2558 | + | |
| 2559 | + *pcie_mask = data->dpm_table.pcie_speed_table.count - 1; | |
| 2560 | + return 0; | |
| 2470 | 2561 | } |
| 2562 | + | |
| 2471 | 2563 | static int smu7_force_dpm_level(struct pp_hwmgr *hwmgr, |
| 2472 | 2564 | enum amd_dpm_forced_level level) |
| 2473 | 2565 | { |
| 2474 | 2566 | int ret = 0; |
| 2567 | + uint32_t sclk_mask = 0; | |
| 2568 | + uint32_t mclk_mask = 0; | |
| 2569 | + uint32_t pcie_mask = 0; | |
| 2570 | + uint32_t profile_mode_mask = AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD | | |
| 2571 | + AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK | | |
| 2572 | + AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK | | |
| 2573 | + AMD_DPM_FORCED_LEVEL_PROFILE_PEAK; | |
| 2574 | + | |
| 2575 | + if (level == hwmgr->dpm_level) | |
| 2576 | + return ret; | |
| 2577 | + | |
| 2578 | + if (!(hwmgr->dpm_level & profile_mode_mask)) { | |
| 2579 | + /* enter profile mode, save current level, disable gfx cg*/ | |
| 2580 | + if (level & profile_mode_mask) { | |
| 2581 | + hwmgr->saved_dpm_level = hwmgr->dpm_level; | |
| 2582 | + cgs_set_clockgating_state(hwmgr->device, | |
| 2583 | + AMD_IP_BLOCK_TYPE_GFX, | |
| 2584 | + AMD_CG_STATE_UNGATE); | |
| 2585 | + } | |
| 2586 | + } else { | |
| 2587 | + /* exit profile mode, restore level, enable gfx cg*/ | |
| 2588 | + if (!(level & profile_mode_mask)) { | |
| 2589 | + if (level == AMD_DPM_FORCED_LEVEL_PROFILE_EXIT) | |
| 2590 | + level = hwmgr->saved_dpm_level; | |
| 2591 | + cgs_set_clockgating_state(hwmgr->device, | |
| 2592 | + AMD_IP_BLOCK_TYPE_GFX, | |
| 2593 | + AMD_CG_STATE_GATE); | |
| 2594 | + } | |
| 2595 | + } | |
| 2475 | 2596 | |
| 2476 | 2597 | switch (level) { |
| 2477 | 2598 | case AMD_DPM_FORCED_LEVEL_HIGH: |
| 2478 | 2599 | ret = smu7_force_dpm_highest(hwmgr); |
| 2479 | 2600 | if (ret) |
| 2480 | 2601 | return ret; |
| 2602 | + hwmgr->dpm_level = level; | |
| 2481 | 2603 | break; |
| 2482 | 2604 | case AMD_DPM_FORCED_LEVEL_LOW: |
| 2483 | 2605 | ret = smu7_force_dpm_lowest(hwmgr); |
| 2484 | 2606 | if (ret) |
| 2485 | 2607 | return ret; |
| 2608 | + hwmgr->dpm_level = level; | |
| 2486 | 2609 | break; |
| 2487 | 2610 | case AMD_DPM_FORCED_LEVEL_AUTO: |
| 2488 | 2611 | ret = smu7_unforce_dpm_levels(hwmgr); |
| 2489 | 2612 | if (ret) |
| 2490 | 2613 | return ret; |
| 2614 | + hwmgr->dpm_level = level; | |
| 2615 | + break; | |
| 2616 | + case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD: | |
| 2617 | + case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK: | |
| 2618 | + case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK: | |
| 2619 | + case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK: | |
| 2620 | + ret = smu7_get_profiling_clk(hwmgr, level, &sclk_mask, &mclk_mask, &pcie_mask); | |
| 2621 | + if (ret) | |
| 2622 | + return ret; | |
| 2623 | + hwmgr->dpm_level = level; | |
| 2624 | + smu7_force_clock_level(hwmgr, PP_SCLK, 1<<sclk_mask); | |
| 2625 | + smu7_force_clock_level(hwmgr, PP_MCLK, 1<<mclk_mask); | |
| 2626 | + smu7_force_clock_level(hwmgr, PP_PCIE, 1<<pcie_mask); | |
| 2627 | + break; | |
| 2628 | + case AMD_DPM_FORCED_LEVEL_MANUAL: | |
| 2629 | + hwmgr->dpm_level = level; | |
| 2491 | 2630 | break; |
| 2631 | + case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT: | |
| 2492 | 2632 | default: |
| 2493 | 2633 | break; |
| 2494 | 2634 | } |
| 2495 | 2635 | |
| 2496 | − hwmgr->dpm_level = level; | |
| 2636 | + if (level & (AMD_DPM_FORCED_LEVEL_PROFILE_PEAK | AMD_DPM_FORCED_LEVEL_HIGH)) | |
| 2637 | + smu7_fan_ctrl_set_fan_speed_percent(hwmgr, 100); | |
| 2638 | + else | |
| 2639 | + smu7_fan_ctrl_reset_fan_speed_to_default(hwmgr); | |
| 2497 | 2640 | |
| 2498 | − return ret; | |
| 2641 | + return 0; | |
| 2499 | 2642 | } |
| 2500 | 2643 | |
| 2501 | 2644 | static int smu7_get_power_state_size(struct pp_hwmgr *hwmgr) |
| @@ -2898,11 +3041,11 @@ static int smu7_get_pp_table_entry_v1(struct pp_hwmgr *hwmgr, · 396 unmodified lines | ||
| 2898 | 3041 | if (dep_mclk_table != NULL && dep_mclk_table->count == 1) { |
| 2899 | 3042 | if (dep_mclk_table->entries[0].clk != |
| 2900 | 3043 | data->vbios_boot_state.mclk_bootup_value) |
| 2901 | − printk(KERN_ERR "Single MCLK entry VDDCI/MCLK dependency table " | |
| 3044 | + pr_err("Single MCLK entry VDDCI/MCLK dependency table " | |
| 2902 | 3045 | "does not match VBIOS boot MCLK level"); |
| 2903 | 3046 | if (dep_mclk_table->entries[0].vddci != |
| 2904 | 3047 | data->vbios_boot_state.vddci_bootup_value) |
| 2905 | − printk(KERN_ERR "Single VDDCI entry VDDCI/MCLK dependency table " | |
| 3048 | + pr_err("Single VDDCI entry VDDCI/MCLK dependency table " | |
| 2906 | 3049 | "does not match VBIOS boot VDDCI level"); |
| 2907 | 3050 | } |
| 2908 | 3051 | |
| @@ -3046,11 +3189,11 @@ static int smu7_get_pp_table_entry_v0(struct pp_hwmgr *hwmgr, · 137 unmodified lines | ||
| 3046 | 3189 | if (dep_mclk_table != NULL && dep_mclk_table->count == 1) { |
| 3047 | 3190 | if (dep_mclk_table->entries[0].clk != |
| 3048 | 3191 | data->vbios_boot_state.mclk_bootup_value) |
| 3049 | − printk(KERN_ERR "Single MCLK entry VDDCI/MCLK dependency table " | |
| 3192 | + pr_err("Single MCLK entry VDDCI/MCLK dependency table " | |
| 3050 | 3193 | "does not match VBIOS boot MCLK level"); |
| 3051 | 3194 | if (dep_mclk_table->entries[0].v != |
| 3052 | 3195 | data->vbios_boot_state.vddci_bootup_value) |
| 3053 | − printk(KERN_ERR "Single VDDCI entry VDDCI/MCLK dependency table " | |
| 3196 | + pr_err("Single VDDCI entry VDDCI/MCLK dependency table " | |
| 3054 | 3197 | "does not match VBIOS boot VDDCI level"); |
| 3055 | 3198 | } |
| 3056 | 3199 | |
| @@ -3590,9 +3733,9 @@ static int smu7_notify_link_speed_change_after_state_change( · 533 unmodified lines | ||
| 3590 | 3733 | |
| 3591 | 3734 | if (acpi_pcie_perf_request(hwmgr->device, request, false)) { |
| 3592 | 3735 | if (PP_PCIEGen2 == target_link_speed) |
| 3593 | − printk("PSPP request to switch to Gen2 from Gen3 Failed!"); | |
| 3736 | + pr_info("PSPP request to switch to Gen2 from Gen3 Failed!"); | |
| 3594 | 3737 | else |
| 3595 | − printk("PSPP request to switch to Gen1 from Gen2 Failed!"); | |
| 3738 | + pr_info("PSPP request to switch to Gen1 from Gen2 Failed!"); | |
| 3596 | 3739 | } |
| 3597 | 3740 | } |
| 3598 | 3741 | |
| @@ -4029,7 +4172,9 @@ static int smu7_force_clock_level(struct pp_hwmgr *hwmgr, · 430 unmodified lines | ||
| 4029 | 4172 | { |
| 4030 | 4173 | struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); |
| 4031 | 4174 | |
| 4032 | − if (hwmgr->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) | |
| 4175 | + if (hwmgr->dpm_level & (AMD_DPM_FORCED_LEVEL_AUTO | | |
| 4176 | + AMD_DPM_FORCED_LEVEL_LOW | | |
| 4177 | + AMD_DPM_FORCED_LEVEL_HIGH)) | |
| 4033 | 4178 | return -EINVAL; |
| 4034 | 4179 | |
| 4035 | 4180 | switch (type) { |
| @@ -4324,9 +4469,35 @@ static int smu7_get_clock_by_type(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type · 288 unmodified lines | ||
| 4324 | 4469 | return 0; |
| 4325 | 4470 | } |
| 4326 | 4471 | |
| 4472 | +static int smu7_request_firmware(struct pp_hwmgr *hwmgr) | |
| 4473 | +{ | |
| 4474 | + int ret; | |
| 4475 | + struct cgs_firmware_info info = {0}; | |
| 4476 | + | |
| 4477 | + ret = cgs_get_firmware_info(hwmgr->device, | |
| 4478 | + smu7_convert_fw_type_to_cgs(UCODE_ID_SMU), | |
| 4479 | + &info); | |
| 4480 | + if (ret || !info.kptr) | |
| 4481 | + return -EINVAL; | |
| 4482 | + | |
| 4483 | + return 0; | |
| 4484 | +} | |
| 4485 | + | |
| 4486 | +static int smu7_release_firmware(struct pp_hwmgr *hwmgr) | |
| 4487 | +{ | |
| 4488 | + int ret; | |
| 4489 | + | |
| 4490 | + ret = cgs_rel_firmware(hwmgr->device, | |
| 4491 | + smu7_convert_fw_type_to_cgs(UCODE_ID_SMU)); | |
| 4492 | + if (ret) | |
| 4493 | + return -EINVAL; | |
| 4494 | + | |
| 4495 | + return 0; | |
| 4496 | +} | |
| 4497 | + | |
| 4327 | 4498 | static const struct pp_hwmgr_func smu7_hwmgr_funcs = { |
| 4328 | 4499 | .backend_init = &smu7_hwmgr_backend_init, |
| 4329 | − .backend_fini = &phm_hwmgr_backend_fini, | |
| 4500 | + .backend_fini = &smu7_hwmgr_backend_fini, | |
| 4330 | 4501 | .asic_setup = &smu7_setup_asic_task, |
| 4331 | 4502 | .dynamic_state_management_enable = &smu7_enable_dpm_tasks, |
| 4332 | 4503 | .apply_state_adjust_rules = smu7_apply_state_adjust_rules, |
| @@ -4371,6 +4542,8 @@ static const struct pp_hwmgr_func smu7_hwmgr_funcs = { · 38 unmodified lines | ||
| 4371 | 4542 | .get_clock_by_type = smu7_get_clock_by_type, |
| 4372 | 4543 | .read_sensor = smu7_read_sensor, |
| 4373 | 4544 | .dynamic_state_management_disable = smu7_disable_dpm_tasks, |
| 4545 | + .request_firmware = smu7_request_firmware, | |
| 4546 | + .release_firmware = smu7_release_firmware, | |
| 4374 | 4547 | }; |
| 4375 | 4548 | |
| 4376 | 4549 | uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock, |
| @@ -4390,7 +4563,7 @@ uint8_t smu7_get_sleep_divider_id_from_clock(uint32_t clock, · 13 unmodified lines | ||
| 4390 | 4563 | return i; |
| 4391 | 4564 | } |
| 4392 | 4565 | |
| 4393 | −int smu7_hwmgr_init(struct pp_hwmgr *hwmgr) | |
| 4566 | +int smu7_init_function_pointers(struct pp_hwmgr *hwmgr) | |
| 4394 | 4567 | { |
| 4395 | 4568 | int ret = 0; |
| 4396 | 4569 | |
| @@ -4400,7 +4573,6 @@ int smu7_hwmgr_init(struct pp_hwmgr *hwmgr) · 3 unmodified lines | ||
| 4400 | 4573 | else if (hwmgr->pp_table_version == PP_TABLE_V1) |
| 4401 | 4574 | hwmgr->pptable_func = &pptable_v1_0_funcs; |
| 4402 | 4575 | |
| 4403 | − pp_smu7_thermal_initialize(hwmgr); | |
| 4404 | 4576 | return ret; |
| 4405 | 4577 | } |
| 4406 | 4578 | |
| @@ -20,17 +20,19 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | +#include "pp_debug.h" | |
| 23 | 24 | #include "hwmgr.h" |
| 24 | 25 | #include "smumgr.h" |
| 25 | 26 | #include "smu7_hwmgr.h" |
| 26 | 27 | #include "smu7_powertune.h" |
| 27 | −#include "pp_debug.h" | |
| 28 | 28 | #include "smu7_common.h" |
| 29 | 29 | |
| 30 | 30 | #define VOLTAGE_SCALE 4 |
| 31 | 31 | |
| 32 | 32 | static uint32_t DIDTBlock_Info = SQ_IR_MASK | TCP_IR_MASK | TD_PCC_MASK; |
| 33 | 33 | |
| 34 | +static uint32_t Polaris11_DIDTBlock_Info = SQ_PCC_MASK | TCP_IR_MASK | TD_PCC_MASK; | |
| 35 | + | |
| 34 | 36 | static const struct gpu_pt_config_reg GCCACConfig_Polaris10[] = { |
| 35 | 37 | /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 36 | 38 | * Offset Mask Shift Value Type |
| @@ -261,9 +263,9 @@ static const struct gpu_pt_config_reg DIDTConfig_Polaris11[] = { · 224 unmodified lines | ||
| 261 | 263 | { ixDIDT_SQ_CTRL_OCP, DIDT_SQ_CTRL_OCP__UNUSED_0_MASK, DIDT_SQ_CTRL_OCP__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 262 | 264 | { ixDIDT_SQ_CTRL_OCP, DIDT_SQ_CTRL_OCP__OCP_MAX_POWER_MASK, DIDT_SQ_CTRL_OCP__OCP_MAX_POWER__SHIFT, 0xffff, GPU_CONFIGREG_DIDT_IND }, |
| 263 | 265 | |
| 264 | − { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__MAX_POWER_DELTA_MASK, DIDT_SQ_CTRL2__MAX_POWER_DELTA__SHIFT, 0x3853, GPU_CONFIGREG_DIDT_IND }, | |
| 266 | + { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__MAX_POWER_DELTA_MASK, DIDT_SQ_CTRL2__MAX_POWER_DELTA__SHIFT, 0x3fff, GPU_CONFIGREG_DIDT_IND }, | |
| 265 | 267 | { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__UNUSED_0_MASK, DIDT_SQ_CTRL2__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 266 | − { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK, DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x005a, GPU_CONFIGREG_DIDT_IND }, | |
| 268 | + { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK, DIDT_SQ_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x000f, GPU_CONFIGREG_DIDT_IND }, | |
| 267 | 269 | { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__UNUSED_1_MASK, DIDT_SQ_CTRL2__UNUSED_1__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 268 | 270 | { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__LONG_TERM_INTERVAL_RATIO_MASK, DIDT_SQ_CTRL2__LONG_TERM_INTERVAL_RATIO__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 269 | 271 | { ixDIDT_SQ_CTRL2, DIDT_SQ_CTRL2__UNUSED_2_MASK, DIDT_SQ_CTRL2__UNUSED_2__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| @@ -271,12 +273,12 @@ static const struct gpu_pt_config_reg DIDTConfig_Polaris11[] = { · 1 unmodified line | ||
| 271 | 273 | { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__DIDT_STALL_CTRL_ENABLE_MASK, DIDT_SQ_STALL_CTRL__DIDT_STALL_CTRL_ENABLE__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, |
| 272 | 274 | { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_HI_MASK, DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_HI__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, |
| 273 | 275 | { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_LO_MASK, DIDT_SQ_STALL_CTRL__DIDT_STALL_DELAY_LO__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, |
| 274 | − { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__DIDT_HI_POWER_THRESHOLD_MASK, DIDT_SQ_STALL_CTRL__DIDT_HI_POWER_THRESHOLD__SHIFT, 0x0ebb, GPU_CONFIGREG_DIDT_IND }, | |
| 276 | + { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__DIDT_HI_POWER_THRESHOLD_MASK, DIDT_SQ_STALL_CTRL__DIDT_HI_POWER_THRESHOLD__SHIFT, 0x01aa, GPU_CONFIGREG_DIDT_IND }, | |
| 275 | 277 | { ixDIDT_SQ_STALL_CTRL, DIDT_SQ_STALL_CTRL__UNUSED_0_MASK, DIDT_SQ_STALL_CTRL__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 276 | 278 | |
| 277 | − { ixDIDT_SQ_TUNING_CTRL, DIDT_SQ_TUNING_CTRL__DIDT_TUNING_ENABLE_MASK, DIDT_SQ_TUNING_CTRL__DIDT_TUNING_ENABLE__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 278 | − { ixDIDT_SQ_TUNING_CTRL, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_HI_MASK, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_HI__SHIFT, 0x3853, GPU_CONFIGREG_DIDT_IND }, | |
| 279 | − { ixDIDT_SQ_TUNING_CTRL, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_LO_MASK, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_LO__SHIFT, 0x3153, GPU_CONFIGREG_DIDT_IND }, | |
| 279 | + { ixDIDT_SQ_TUNING_CTRL, DIDT_SQ_TUNING_CTRL__DIDT_TUNING_ENABLE_MASK, DIDT_SQ_TUNING_CTRL__DIDT_TUNING_ENABLE__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 280 | + { ixDIDT_SQ_TUNING_CTRL, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_HI_MASK, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_HI__SHIFT, 0x0dde, GPU_CONFIGREG_DIDT_IND }, | |
| 281 | + { ixDIDT_SQ_TUNING_CTRL, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_LO_MASK, DIDT_SQ_TUNING_CTRL__MAX_POWER_DELTA_LO__SHIFT, 0x0dde, GPU_CONFIGREG_DIDT_IND }, | |
| 280 | 282 | { ixDIDT_SQ_TUNING_CTRL, DIDT_SQ_TUNING_CTRL__UNUSED_0_MASK, DIDT_SQ_TUNING_CTRL__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 281 | 283 | |
| 282 | 284 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_CTRL_EN_MASK, DIDT_SQ_CTRL0__DIDT_CTRL_EN__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, |
| @@ -284,8 +286,8 @@ static const struct gpu_pt_config_reg DIDTConfig_Polaris11[] = { · 1 unmodified line | ||
| 284 | 286 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__PHASE_OFFSET_MASK, DIDT_SQ_CTRL0__PHASE_OFFSET__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 285 | 287 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_CTRL_RST_MASK, DIDT_SQ_CTRL0__DIDT_CTRL_RST__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 286 | 288 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_CLK_EN_OVERRIDE_MASK, DIDT_SQ_CTRL0__DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 287 | − { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_MAX_STALLS_ALLOWED_HI_MASK, DIDT_SQ_CTRL0__DIDT_MAX_STALLS_ALLOWED_HI__SHIFT, 0x0010, GPU_CONFIGREG_DIDT_IND }, | |
| 288 | − { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_MAX_STALLS_ALLOWED_LO_MASK, DIDT_SQ_CTRL0__DIDT_MAX_STALLS_ALLOWED_LO__SHIFT, 0x0010, GPU_CONFIGREG_DIDT_IND }, | |
| 289 | + { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_MAX_STALLS_ALLOWED_HI_MASK, DIDT_SQ_CTRL0__DIDT_MAX_STALLS_ALLOWED_HI__SHIFT, 0x0008, GPU_CONFIGREG_DIDT_IND }, | |
| 290 | + { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__DIDT_MAX_STALLS_ALLOWED_LO_MASK, DIDT_SQ_CTRL0__DIDT_MAX_STALLS_ALLOWED_LO__SHIFT, 0x0008, GPU_CONFIGREG_DIDT_IND }, | |
| 289 | 291 | { ixDIDT_SQ_CTRL0, DIDT_SQ_CTRL0__UNUSED_0_MASK, DIDT_SQ_CTRL0__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 290 | 292 | |
| 291 | 293 | { ixDIDT_TD_WEIGHT0_3, DIDT_TD_WEIGHT0_3__WEIGHT0_MASK, DIDT_TD_WEIGHT0_3__WEIGHT0__SHIFT, 0x000a, GPU_CONFIGREG_DIDT_IND }, |
| @@ -365,6 +367,105 @@ static const struct gpu_pt_config_reg DIDTConfig_Polaris11[] = { · 73 unmodified lines | ||
| 365 | 367 | { ixDIDT_TCP_TUNING_CTRL, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_LO_MASK, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_LO__SHIFT, 0x3dde, GPU_CONFIGREG_DIDT_IND }, |
| 366 | 368 | { ixDIDT_TCP_TUNING_CTRL, DIDT_TCP_TUNING_CTRL__UNUSED_0_MASK, DIDT_TCP_TUNING_CTRL__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 367 | 369 | |
| 370 | + { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_CTRL_EN_MASK, DIDT_TCP_CTRL0__DIDT_CTRL_EN__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 371 | + { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__USE_REF_CLOCK_MASK, DIDT_TCP_CTRL0__USE_REF_CLOCK__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 372 | + { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__PHASE_OFFSET_MASK, DIDT_TCP_CTRL0__PHASE_OFFSET__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 373 | + { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_CTRL_RST_MASK, DIDT_TCP_CTRL0__DIDT_CTRL_RST__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 374 | + { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_CLK_EN_OVERRIDE_MASK, DIDT_TCP_CTRL0__DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 375 | + { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_MAX_STALLS_ALLOWED_HI_MASK, DIDT_TCP_CTRL0__DIDT_MAX_STALLS_ALLOWED_HI__SHIFT, 0x0010, GPU_CONFIGREG_DIDT_IND }, | |
| 376 | + { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_MAX_STALLS_ALLOWED_LO_MASK, DIDT_TCP_CTRL0__DIDT_MAX_STALLS_ALLOWED_LO__SHIFT, 0x0010, GPU_CONFIGREG_DIDT_IND }, | |
| 377 | + { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__UNUSED_0_MASK, DIDT_TCP_CTRL0__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 378 | + | |
| 379 | + { 0xFFFFFFFF } | |
| 380 | +}; | |
| 381 | + | |
| 382 | +static const struct gpu_pt_config_reg DIDTConfig_Polaris12[] = { | |
| 383 | +/* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 384 | + * Offset Mask Shift Value Type | |
| 385 | + * --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 386 | + */ | |
| 387 | + { ixDIDT_SQ_WEIGHT0_3, DIDT_SQ_WEIGHT0_3__WEIGHT0_MASK, DIDT_SQ_WEIGHT0_3__WEIGHT0__SHIFT, 0x0073, GPU_CONFIGREG_DIDT_IND }, | |
| 388 | + { ixDIDT_SQ_WEIGHT0_3, DIDT_SQ_WEIGHT0_3__WEIGHT1_MASK, DIDT_SQ_WEIGHT0_3__WEIGHT1__SHIFT, 0x00ab, GPU_CONFIGREG_DIDT_IND }, | |
| 389 | + { ixDIDT_SQ_WEIGHT0_3, DIDT_SQ_WEIGHT0_3__WEIGHT2_MASK, DIDT_SQ_WEIGHT0_3__WEIGHT2__SHIFT, 0x0084, GPU_CONFIGREG_DIDT_IND }, | |
| 390 | + { ixDIDT_SQ_WEIGHT0_3, DIDT_SQ_WEIGHT0_3__WEIGHT3_MASK, DIDT_SQ_WEIGHT0_3__WEIGHT3__SHIFT, 0x005a, GPU_CONFIGREG_DIDT_IND }, | |
| 391 | + | |
| 392 | + { ixDIDT_SQ_WEIGHT4_7, DIDT_SQ_WEIGHT4_7__WEIGHT4_MASK, DIDT_SQ_WEIGHT4_7__WEIGHT4__SHIFT, 0x0067, GPU_CONFIGREG_DIDT_IND }, | |
| 393 | + { ixDIDT_SQ_WEIGHT4_7, DIDT_SQ_WEIGHT4_7__WEIGHT5_MASK, DIDT_SQ_WEIGHT4_7__WEIGHT5__SHIFT, 0x0084, GPU_CONFIGREG_DIDT_IND }, | |
| 394 | + { ixDIDT_SQ_WEIGHT4_7, DIDT_SQ_WEIGHT4_7__WEIGHT6_MASK, DIDT_SQ_WEIGHT4_7__WEIGHT6__SHIFT, 0x0027, GPU_CONFIGREG_DIDT_IND }, | |
| 395 | + { ixDIDT_SQ_WEIGHT4_7, DIDT_SQ_WEIGHT4_7__WEIGHT7_MASK, DIDT_SQ_WEIGHT4_7__WEIGHT7__SHIFT, 0x0046, GPU_CONFIGREG_DIDT_IND }, | |
| 396 | + | |
| 397 | + { ixDIDT_SQ_WEIGHT8_11, DIDT_SQ_WEIGHT8_11__WEIGHT8_MASK, DIDT_SQ_WEIGHT8_11__WEIGHT8__SHIFT, 0x00aa, GPU_CONFIGREG_DIDT_IND }, | |
| 398 | + { ixDIDT_SQ_WEIGHT8_11, DIDT_SQ_WEIGHT8_11__WEIGHT9_MASK, DIDT_SQ_WEIGHT8_11__WEIGHT9__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 399 | + { ixDIDT_SQ_WEIGHT8_11, DIDT_SQ_WEIGHT8_11__WEIGHT10_MASK, DIDT_SQ_WEIGHT8_11__WEIGHT10__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 400 | + { ixDIDT_SQ_WEIGHT8_11, DIDT_SQ_WEIGHT8_11__WEIGHT11_MASK, DIDT_SQ_WEIGHT8_11__WEIGHT11__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 401 | + | |
| 402 | + { ixDIDT_SQ_CTRL1, DIDT_SQ_CTRL1__MIN_POWER_MASK, DIDT_SQ_CTRL1__MIN_POWER__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 403 | + { ixDIDT_SQ_CTRL1, DIDT_SQ_CTRL1__MAX_POWER_MASK, DIDT_SQ_CTRL1__MAX_POWER__SHIFT, 0xffff, GPU_CONFIGREG_DIDT_IND }, | |
| 404 | + | |
| 405 | + { ixDIDT_SQ_CTRL_OCP, DIDT_SQ_CTRL_OCP__UNUSED_0_MASK, DIDT_SQ_CTRL_OCP__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 406 | + { ixDIDT_TD_CTRL_OCP, DIDT_TD_CTRL_OCP__OCP_MAX_POWER_MASK, DIDT_TD_CTRL_OCP__OCP_MAX_POWER__SHIFT, 0x00ff, GPU_CONFIGREG_DIDT_IND }, | |
| 407 | + | |
| 408 | + { ixDIDT_TD_CTRL2, DIDT_TD_CTRL2__MAX_POWER_DELTA_MASK, DIDT_TD_CTRL2__MAX_POWER_DELTA__SHIFT, 0x3fff, GPU_CONFIGREG_DIDT_IND }, | |
| 409 | + { ixDIDT_TD_CTRL2, DIDT_TD_CTRL2__UNUSED_0_MASK, DIDT_TD_CTRL2__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 410 | + { ixDIDT_TD_CTRL2, DIDT_TD_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK, DIDT_TD_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x000f, GPU_CONFIGREG_DIDT_IND }, | |
| 411 | + { ixDIDT_TD_CTRL2, DIDT_TD_CTRL2__UNUSED_1_MASK, DIDT_TD_CTRL2__UNUSED_1__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 412 | + { ixDIDT_TD_CTRL2, DIDT_TD_CTRL2__LONG_TERM_INTERVAL_RATIO_MASK, DIDT_TD_CTRL2__LONG_TERM_INTERVAL_RATIO__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 413 | + { ixDIDT_TD_CTRL2, DIDT_TD_CTRL2__UNUSED_2_MASK, DIDT_TD_CTRL2__UNUSED_2__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 414 | + | |
| 415 | + { ixDIDT_TD_STALL_CTRL, DIDT_TD_STALL_CTRL__DIDT_STALL_CTRL_ENABLE_MASK, DIDT_TD_STALL_CTRL__DIDT_STALL_CTRL_ENABLE__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 416 | + { ixDIDT_TD_STALL_CTRL, DIDT_TD_STALL_CTRL__DIDT_STALL_DELAY_HI_MASK, DIDT_TD_STALL_CTRL__DIDT_STALL_DELAY_HI__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 417 | + { ixDIDT_TD_STALL_CTRL, DIDT_TD_STALL_CTRL__DIDT_STALL_DELAY_LO_MASK, DIDT_TD_STALL_CTRL__DIDT_STALL_DELAY_LO__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 418 | + { ixDIDT_TD_STALL_CTRL, DIDT_TD_STALL_CTRL__DIDT_HI_POWER_THRESHOLD_MASK, DIDT_TD_STALL_CTRL__DIDT_HI_POWER_THRESHOLD__SHIFT, 0x01aa, GPU_CONFIGREG_DIDT_IND }, | |
| 419 | + { ixDIDT_TD_STALL_CTRL, DIDT_TD_STALL_CTRL__UNUSED_0_MASK, DIDT_TD_STALL_CTRL__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 420 | + | |
| 421 | + { ixDIDT_TD_TUNING_CTRL, DIDT_TD_TUNING_CTRL__DIDT_TUNING_ENABLE_MASK, DIDT_TD_TUNING_CTRL__DIDT_TUNING_ENABLE__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 422 | + { ixDIDT_TD_TUNING_CTRL, DIDT_TD_TUNING_CTRL__MAX_POWER_DELTA_HI_MASK, DIDT_TD_TUNING_CTRL__MAX_POWER_DELTA_HI__SHIFT, 0x0dde, GPU_CONFIGREG_DIDT_IND }, | |
| 423 | + { ixDIDT_TD_TUNING_CTRL, DIDT_TD_TUNING_CTRL__MAX_POWER_DELTA_LO_MASK, DIDT_TD_TUNING_CTRL__MAX_POWER_DELTA_LO__SHIFT, 0x0dde, GPU_CONFIGREG_DIDT_IND }, | |
| 424 | + { ixDIDT_TD_TUNING_CTRL, DIDT_TD_TUNING_CTRL__UNUSED_0_MASK, DIDT_TD_TUNING_CTRL__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 425 | + | |
| 426 | + { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_CTRL_EN_MASK, DIDT_TD_CTRL0__DIDT_CTRL_EN__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 427 | + { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__USE_REF_CLOCK_MASK, DIDT_TD_CTRL0__USE_REF_CLOCK__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 428 | + { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__PHASE_OFFSET_MASK, DIDT_TD_CTRL0__PHASE_OFFSET__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 429 | + { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_CTRL_RST_MASK, DIDT_TD_CTRL0__DIDT_CTRL_RST__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 430 | + { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_CLK_EN_OVERRIDE_MASK, DIDT_TD_CTRL0__DIDT_CLK_EN_OVERRIDE__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 431 | + { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_MAX_STALLS_ALLOWED_HI_MASK, DIDT_TD_CTRL0__DIDT_MAX_STALLS_ALLOWED_HI__SHIFT, 0x0008, GPU_CONFIGREG_DIDT_IND }, | |
| 432 | + { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__DIDT_MAX_STALLS_ALLOWED_LO_MASK, DIDT_TD_CTRL0__DIDT_MAX_STALLS_ALLOWED_LO__SHIFT, 0x0008, GPU_CONFIGREG_DIDT_IND }, | |
| 433 | + { ixDIDT_TD_CTRL0, DIDT_TD_CTRL0__UNUSED_0_MASK, DIDT_TD_CTRL0__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 434 | + | |
| 435 | + { ixDIDT_TCP_WEIGHT0_3, DIDT_TCP_WEIGHT0_3__WEIGHT0_MASK, DIDT_TCP_WEIGHT0_3__WEIGHT0__SHIFT, 0x0004, GPU_CONFIGREG_DIDT_IND }, | |
| 436 | + { ixDIDT_TCP_WEIGHT0_3, DIDT_TCP_WEIGHT0_3__WEIGHT1_MASK, DIDT_TCP_WEIGHT0_3__WEIGHT1__SHIFT, 0x0037, GPU_CONFIGREG_DIDT_IND }, | |
| 437 | + { ixDIDT_TCP_WEIGHT0_3, DIDT_TCP_WEIGHT0_3__WEIGHT2_MASK, DIDT_TCP_WEIGHT0_3__WEIGHT2__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 438 | + { ixDIDT_TCP_WEIGHT0_3, DIDT_TCP_WEIGHT0_3__WEIGHT3_MASK, DIDT_TCP_WEIGHT0_3__WEIGHT3__SHIFT, 0x00ff, GPU_CONFIGREG_DIDT_IND }, | |
| 439 | + | |
| 440 | + { ixDIDT_TCP_WEIGHT4_7, DIDT_TCP_WEIGHT4_7__WEIGHT4_MASK, DIDT_TCP_WEIGHT4_7__WEIGHT4__SHIFT, 0x0054, GPU_CONFIGREG_DIDT_IND }, | |
| 441 | + { ixDIDT_TCP_WEIGHT4_7, DIDT_TCP_WEIGHT4_7__WEIGHT5_MASK, DIDT_TCP_WEIGHT4_7__WEIGHT5__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 442 | + { ixDIDT_TCP_WEIGHT4_7, DIDT_TCP_WEIGHT4_7__WEIGHT6_MASK, DIDT_TCP_WEIGHT4_7__WEIGHT6__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 443 | + { ixDIDT_TCP_WEIGHT4_7, DIDT_TCP_WEIGHT4_7__WEIGHT7_MASK, DIDT_TCP_WEIGHT4_7__WEIGHT7__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 444 | + | |
| 445 | + { ixDIDT_TCP_CTRL1, DIDT_TCP_CTRL1__MIN_POWER_MASK, DIDT_TCP_CTRL1__MIN_POWER__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 446 | + { ixDIDT_TCP_CTRL1, DIDT_TCP_CTRL1__MAX_POWER_MASK, DIDT_TCP_CTRL1__MAX_POWER__SHIFT, 0xffff, GPU_CONFIGREG_DIDT_IND }, | |
| 447 | + | |
| 448 | + { ixDIDT_TCP_CTRL_OCP, DIDT_TCP_CTRL_OCP__UNUSED_0_MASK, DIDT_TCP_CTRL_OCP__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 449 | + { ixDIDT_TCP_CTRL_OCP, DIDT_TCP_CTRL_OCP__OCP_MAX_POWER_MASK, DIDT_TCP_CTRL_OCP__OCP_MAX_POWER__SHIFT, 0xffff, GPU_CONFIGREG_DIDT_IND }, | |
| 450 | + | |
| 451 | + { ixDIDT_TCP_CTRL2, DIDT_TCP_CTRL2__MAX_POWER_DELTA_MASK, DIDT_TCP_CTRL2__MAX_POWER_DELTA__SHIFT, 0x3dde, GPU_CONFIGREG_DIDT_IND }, | |
| 452 | + { ixDIDT_TCP_CTRL2, DIDT_TCP_CTRL2__UNUSED_0_MASK, DIDT_TCP_CTRL2__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 453 | + { ixDIDT_TCP_CTRL2, DIDT_TCP_CTRL2__SHORT_TERM_INTERVAL_SIZE_MASK, DIDT_TCP_CTRL2__SHORT_TERM_INTERVAL_SIZE__SHIFT, 0x0032, GPU_CONFIGREG_DIDT_IND }, | |
| 454 | + { ixDIDT_TCP_CTRL2, DIDT_TCP_CTRL2__UNUSED_1_MASK, DIDT_TCP_CTRL2__UNUSED_1__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 455 | + { ixDIDT_TCP_CTRL2, DIDT_TCP_CTRL2__LONG_TERM_INTERVAL_RATIO_MASK, DIDT_TCP_CTRL2__LONG_TERM_INTERVAL_RATIO__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 456 | + { ixDIDT_TCP_CTRL2, DIDT_TCP_CTRL2__UNUSED_2_MASK, DIDT_TCP_CTRL2__UNUSED_2__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 457 | + | |
| 458 | + { ixDIDT_TCP_STALL_CTRL, DIDT_TCP_STALL_CTRL__DIDT_STALL_CTRL_ENABLE_MASK, DIDT_TCP_STALL_CTRL__DIDT_STALL_CTRL_ENABLE__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 459 | + { ixDIDT_TCP_STALL_CTRL, DIDT_TCP_STALL_CTRL__DIDT_STALL_DELAY_HI_MASK, DIDT_TCP_STALL_CTRL__DIDT_STALL_DELAY_HI__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 460 | + { ixDIDT_TCP_STALL_CTRL, DIDT_TCP_STALL_CTRL__DIDT_STALL_DELAY_LO_MASK, DIDT_TCP_STALL_CTRL__DIDT_STALL_DELAY_LO__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 461 | + { ixDIDT_TCP_STALL_CTRL, DIDT_TCP_STALL_CTRL__DIDT_HI_POWER_THRESHOLD_MASK, DIDT_TCP_STALL_CTRL__DIDT_HI_POWER_THRESHOLD__SHIFT, 0x01aa, GPU_CONFIGREG_DIDT_IND }, | |
| 462 | + { ixDIDT_TCP_STALL_CTRL, DIDT_TCP_STALL_CTRL__UNUSED_0_MASK, DIDT_TCP_STALL_CTRL__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 463 | + | |
| 464 | + { ixDIDT_TCP_TUNING_CTRL, DIDT_TCP_TUNING_CTRL__DIDT_TUNING_ENABLE_MASK, DIDT_TCP_TUNING_CTRL__DIDT_TUNING_ENABLE__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, | |
| 465 | + { ixDIDT_TCP_TUNING_CTRL, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_HI_MASK, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_HI__SHIFT, 0x3dde, GPU_CONFIGREG_DIDT_IND }, | |
| 466 | + { ixDIDT_TCP_TUNING_CTRL, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_LO_MASK, DIDT_TCP_TUNING_CTRL__MAX_POWER_DELTA_LO__SHIFT, 0x3dde, GPU_CONFIGREG_DIDT_IND }, | |
| 467 | + { ixDIDT_TCP_TUNING_CTRL, DIDT_TCP_TUNING_CTRL__UNUSED_0_MASK, DIDT_TCP_TUNING_CTRL__UNUSED_0__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, | |
| 468 | + | |
| 368 | 469 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__DIDT_CTRL_EN_MASK, DIDT_TCP_CTRL0__DIDT_CTRL_EN__SHIFT, 0x0001, GPU_CONFIGREG_DIDT_IND }, |
| 369 | 470 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__USE_REF_CLOCK_MASK, DIDT_TCP_CTRL0__USE_REF_CLOCK__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| 370 | 471 | { ixDIDT_TCP_CTRL0, DIDT_TCP_CTRL0__PHASE_OFFSET_MASK, DIDT_TCP_CTRL0__PHASE_OFFSET__SHIFT, 0x0000, GPU_CONFIGREG_DIDT_IND }, |
| @@ -379,49 +480,55 @@ static const struct gpu_pt_config_reg DIDTConfig_Polaris11[] = { · 8 unmodified lines | ||
| 379 | 480 | |
| 380 | 481 | static int smu7_enable_didt(struct pp_hwmgr *hwmgr, const bool enable) |
| 381 | 482 | { |
| 382 | − | |
| 383 | 483 | uint32_t en = enable ? 1 : 0; |
| 484 | + uint32_t block_en = 0; | |
| 384 | 485 | int32_t result = 0; |
| 486 | + uint32_t didt_block; | |
| 385 | 487 | uint32_t data; |
| 386 | 488 | |
| 387 | − if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_SQRamping)) { | |
| 388 | − data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_SQ_CTRL0); | |
| 389 | − data &= ~DIDT_SQ_CTRL0__DIDT_CTRL_EN_MASK; | |
| 390 | − data |= ((en << DIDT_SQ_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_SQ_CTRL0__DIDT_CTRL_EN_MASK); | |
| 391 | − cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_SQ_CTRL0, data); | |
| 392 | − DIDTBlock_Info &= ~SQ_Enable_MASK; | |
| 393 | − DIDTBlock_Info |= en << SQ_Enable_SHIFT; | |
| 394 | − } | |
| 489 | + if (hwmgr->chip_id == CHIP_POLARIS11) | |
| 490 | + didt_block = Polaris11_DIDTBlock_Info; | |
| 491 | + else | |
| 492 | + didt_block = DIDTBlock_Info; | |
| 395 | 493 | |
| 396 | − if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DBRamping)) { | |
| 397 | − data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DB_CTRL0); | |
| 398 | − data &= ~DIDT_DB_CTRL0__DIDT_CTRL_EN_MASK; | |
| 399 | − data |= ((en << DIDT_DB_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_DB_CTRL0__DIDT_CTRL_EN_MASK); | |
| 400 | − cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DB_CTRL0, data); | |
| 401 | − DIDTBlock_Info &= ~DB_Enable_MASK; | |
| 402 | − DIDTBlock_Info |= en << DB_Enable_SHIFT; | |
| 403 | − } | |
| 494 | + block_en = phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_SQRamping) ? en : 0; | |
| 404 | 495 | |
| 405 | − if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TDRamping)) { | |
| 406 | − data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TD_CTRL0); | |
| 407 | − data &= ~DIDT_TD_CTRL0__DIDT_CTRL_EN_MASK; | |
| 408 | − data |= ((en << DIDT_TD_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_TD_CTRL0__DIDT_CTRL_EN_MASK); | |
| 409 | − cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TD_CTRL0, data); | |
| 410 | − DIDTBlock_Info &= ~TD_Enable_MASK; | |
| 411 | − DIDTBlock_Info |= en << TD_Enable_SHIFT; | |
| 412 | − } | |
| 496 | + data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_SQ_CTRL0); | |
| 497 | + data &= ~DIDT_SQ_CTRL0__DIDT_CTRL_EN_MASK; | |
| 498 | + data |= ((block_en << DIDT_SQ_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_SQ_CTRL0__DIDT_CTRL_EN_MASK); | |
| 499 | + cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_SQ_CTRL0, data); | |
| 500 | + didt_block &= ~SQ_Enable_MASK; | |
| 501 | + didt_block |= block_en << SQ_Enable_SHIFT; | |
| 502 | + | |
| 503 | + block_en = phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DBRamping) ? en : 0; | |
| 504 | + | |
| 505 | + data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DB_CTRL0); | |
| 506 | + data &= ~DIDT_DB_CTRL0__DIDT_CTRL_EN_MASK; | |
| 507 | + data |= ((block_en << DIDT_DB_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_DB_CTRL0__DIDT_CTRL_EN_MASK); | |
| 508 | + cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_DB_CTRL0, data); | |
| 509 | + didt_block &= ~DB_Enable_MASK; | |
| 510 | + didt_block |= block_en << DB_Enable_SHIFT; | |
| 511 | + | |
| 512 | + block_en = phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TDRamping) ? en : 0; | |
| 513 | + data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TD_CTRL0); | |
| 514 | + data &= ~DIDT_TD_CTRL0__DIDT_CTRL_EN_MASK; | |
| 515 | + data |= ((block_en << DIDT_TD_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_TD_CTRL0__DIDT_CTRL_EN_MASK); | |
| 516 | + cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TD_CTRL0, data); | |
| 517 | + didt_block &= ~TD_Enable_MASK; | |
| 518 | + didt_block |= block_en << TD_Enable_SHIFT; | |
| 519 | + | |
| 520 | + block_en = phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TCPRamping) ? en : 0; | |
| 521 | + | |
| 522 | + data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TCP_CTRL0); | |
| 523 | + data &= ~DIDT_TCP_CTRL0__DIDT_CTRL_EN_MASK; | |
| 524 | + data |= ((block_en << DIDT_TCP_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_TCP_CTRL0__DIDT_CTRL_EN_MASK); | |
| 525 | + cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TCP_CTRL0, data); | |
| 526 | + didt_block &= ~TCP_Enable_MASK; | |
| 527 | + didt_block |= block_en << TCP_Enable_SHIFT; | |
| 413 | 528 | |
| 414 | − if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TCPRamping)) { | |
| 415 | − data = cgs_read_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TCP_CTRL0); | |
| 416 | − data &= ~DIDT_TCP_CTRL0__DIDT_CTRL_EN_MASK; | |
| 417 | − data |= ((en << DIDT_TCP_CTRL0__DIDT_CTRL_EN__SHIFT) & DIDT_TCP_CTRL0__DIDT_CTRL_EN_MASK); | |
| 418 | − cgs_write_ind_register(hwmgr->device, CGS_IND_REG__DIDT, ixDIDT_TCP_CTRL0, data); | |
| 419 | − DIDTBlock_Info &= ~TCP_Enable_MASK; | |
| 420 | − DIDTBlock_Info |= en << TCP_Enable_SHIFT; | |
| 421 | − } | |
| 422 | 529 | |
| 423 | 530 | if (enable) |
| 424 | − result = smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_Didt_Block_Function, DIDTBlock_Info); | |
| 531 | + result = smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, PPSMC_MSG_Didt_Block_Function, didt_block); | |
| 425 | 532 | |
| 426 | 533 | return result; |
| 427 | 534 | } |
| @@ -498,7 +605,6 @@ int smu7_enable_didt_config(struct pp_hwmgr *hwmgr) · 70 unmodified lines | ||
| 498 | 605 | sys_info.info_id = CGS_SYSTEM_INFO_GFX_SE_INFO; |
| 499 | 606 | result = cgs_query_system_info(hwmgr->device, &sys_info); |
| 500 | 607 | |
| 501 | − | |
| 502 | 608 | if (result == 0) |
| 503 | 609 | num_se = sys_info.value; |
| 504 | 610 | |
| @@ -507,7 +613,7 @@ int smu7_enable_didt_config(struct pp_hwmgr *hwmgr) · 2 unmodified lines | ||
| 507 | 613 | phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TDRamping) || |
| 508 | 614 | phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TCPRamping)) { |
| 509 | 615 | |
| 510 | − /* TO DO Pre DIDT disable clock gating */ | |
| 616 | + cgs_enter_safe_mode(hwmgr->device, true); | |
| 511 | 617 | value = 0; |
| 512 | 618 | value2 = cgs_read_register(hwmgr->device, mmGRBM_GFX_INDEX); |
| 513 | 619 | for (count = 0; count < num_se; count++) { |
| @@ -521,11 +627,16 @@ int smu7_enable_didt_config(struct pp_hwmgr *hwmgr) · 7 unmodified lines | ||
| 521 | 627 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); |
| 522 | 628 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris10); |
| 523 | 629 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); |
| 524 | − } else if ((hwmgr->chip_id == CHIP_POLARIS11) || (hwmgr->chip_id == CHIP_POLARIS12)) { | |
| 630 | + } else if (hwmgr->chip_id == CHIP_POLARIS11) { | |
| 525 | 631 | result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11); |
| 526 | 632 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); |
| 527 | 633 | result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris11); |
| 528 | 634 | PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); |
| 635 | + } else if (hwmgr->chip_id == CHIP_POLARIS12) { | |
| 636 | + result = smu7_program_pt_config_registers(hwmgr, GCCACConfig_Polaris11); | |
| 637 | + PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | |
| 638 | + result = smu7_program_pt_config_registers(hwmgr, DIDTConfig_Polaris12); | |
| 639 | + PP_ASSERT_WITH_CODE((result == 0), "DIDT Config failed.", return result); | |
| 529 | 640 | } |
| 530 | 641 | } |
| 531 | 642 | cgs_write_register(hwmgr->device, mmGRBM_GFX_INDEX, value2); |
| @@ -533,7 +644,13 @@ int smu7_enable_didt_config(struct pp_hwmgr *hwmgr) · 1 unmodified line | ||
| 533 | 644 | result = smu7_enable_didt(hwmgr, true); |
| 534 | 645 | PP_ASSERT_WITH_CODE((result == 0), "EnableDiDt failed.", return result); |
| 535 | 646 | |
| 536 | − /* TO DO Post DIDT enable clock gating */ | |
| 647 | + if (hwmgr->chip_id == CHIP_POLARIS11) { | |
| 648 | + result = smum_send_msg_to_smc(hwmgr->smumgr, | |
| 649 | + (uint16_t)(PPSMC_MSG_EnableDpmDidt)); | |
| 650 | + PP_ASSERT_WITH_CODE((0 == result), | |
| 651 | + "Failed to enable DPM DIDT.", return result); | |
| 652 | + } | |
| 653 | + cgs_enter_safe_mode(hwmgr->device, false); | |
| 537 | 654 | } |
| 538 | 655 | |
| 539 | 656 | return 0; |
| @@ -547,11 +664,20 @@ int smu7_disable_didt_config(struct pp_hwmgr *hwmgr) · 7 unmodified lines | ||
| 547 | 664 | phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DBRamping) || |
| 548 | 665 | phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TDRamping) || |
| 549 | 666 | phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_TCPRamping)) { |
| 550 | − /* TO DO Pre DIDT disable clock gating */ | |
| 667 | + | |
| 668 | + cgs_enter_safe_mode(hwmgr->device, true); | |
| 551 | 669 | |
| 552 | 670 | result = smu7_enable_didt(hwmgr, false); |
| 553 | − PP_ASSERT_WITH_CODE((result == 0), "Post DIDT enable clock gating failed.", return result); | |
| 554 | − /* TO DO Post DIDT enable clock gating */ | |
| 671 | + PP_ASSERT_WITH_CODE((result == 0), | |
| 672 | + "Post DIDT enable clock gating failed.", | |
| 673 | + return result); | |
| 674 | + if (hwmgr->chip_id == CHIP_POLARIS11) { | |
| 675 | + result = smum_send_msg_to_smc(hwmgr->smumgr, | |
| 676 | + (uint16_t)(PPSMC_MSG_DisableDpmDidt)); | |
| 677 | + PP_ASSERT_WITH_CODE((0 == result), | |
| 678 | + "Failed to disable DPM DIDT.", return result); | |
| 679 | + } | |
| 680 | + cgs_enter_safe_mode(hwmgr->device, false); | |
| 555 | 681 | } |
| 556 | 682 | |
| 557 | 683 | return 0; |
| @@ -651,7 +777,7 @@ int smu7_enable_power_containment(struct pp_hwmgr *hwmgr) · 93 unmodified lines | ||
| 651 | 777 | POWERCONTAINMENT_FEATURE_PkgPwrLimit; |
| 652 | 778 | |
| 653 | 779 | if (smu7_set_power_limit(hwmgr, default_limit)) |
| 654 | − printk(KERN_ERR "Failed to set Default Power Limit in SMC!"); | |
| 780 | + pr_err("Failed to set Default Power Limit in SMC!"); | |
| 655 | 781 | } |
| 656 | 782 | } |
| 657 | 783 | } |
| @@ -506,18 +506,18 @@ static int tf_smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr, · 505 unmodified lines | ||
| 506 | 506 | |
| 507 | 507 | static const struct phm_master_table_item |
| 508 | 508 | phm_thermal_start_thermal_controller_master_list[] = { |
| 509 | − {NULL, tf_smu7_thermal_initialize}, | |
| 510 | − {NULL, tf_smu7_thermal_set_temperature_range}, | |
| 511 | − {NULL, tf_smu7_thermal_enable_alert}, | |
| 512 | − {NULL, smum_thermal_avfs_enable}, | |
| 509 | + { .tableFunction = tf_smu7_thermal_initialize }, | |
| 510 | + { .tableFunction = tf_smu7_thermal_set_temperature_range }, | |
| 511 | + { .tableFunction = tf_smu7_thermal_enable_alert }, | |
| 512 | + { .tableFunction = smum_thermal_avfs_enable }, | |
| 513 | 513 | /* We should restrict performance levels to low before we halt the SMC. |
| 514 | 514 | * On the other hand we are still in boot state when we do this |
| 515 | 515 | * so it would be pointless. |
| 516 | 516 | * If this assumption changes we have to revisit this table. |
| 517 | 517 | */ |
| 518 | − {NULL, smum_thermal_setup_fan_table}, | |
| 519 | − {NULL, tf_smu7_thermal_start_smc_fan_control}, | |
| 520 | − {NULL, NULL} | |
| 518 | + { .tableFunction = smum_thermal_setup_fan_table }, | |
| 519 | + { .tableFunction = tf_smu7_thermal_start_smc_fan_control }, | |
| 520 | + { } | |
| 521 | 521 | }; |
| 522 | 522 | |
| 523 | 523 | static const struct phm_master_table_header |
| @@ -529,10 +529,10 @@ phm_thermal_start_thermal_controller_master = { · 5 unmodified lines | ||
| 529 | 529 | |
| 530 | 530 | static const struct phm_master_table_item |
| 531 | 531 | phm_thermal_set_temperature_range_master_list[] = { |
| 532 | − {NULL, tf_smu7_thermal_disable_alert}, | |
| 533 | − {NULL, tf_smu7_thermal_set_temperature_range}, | |
| 534 | − {NULL, tf_smu7_thermal_enable_alert}, | |
| 535 | − {NULL, NULL} | |
| 532 | + { .tableFunction = tf_smu7_thermal_disable_alert }, | |
| 533 | + { .tableFunction = tf_smu7_thermal_set_temperature_range }, | |
| 534 | + { .tableFunction = tf_smu7_thermal_enable_alert }, | |
| 535 | + { } | |
| 536 | 536 | }; |
| 537 | 537 | |
| 538 | 538 | static const struct phm_master_table_header |
| @@ -575,3 +575,9 @@ int pp_smu7_thermal_initialize(struct pp_hwmgr *hwmgr) · 36 unmodified lines | ||
| 575 | 575 | return result; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | +void pp_smu7_thermal_fini(struct pp_hwmgr *hwmgr) | |
| 579 | +{ | |
| 580 | + phm_destroy_table(hwmgr, &(hwmgr->set_temperature_range)); | |
| 581 | + phm_destroy_table(hwmgr, &(hwmgr->start_thermal_controller)); | |
| 582 | + return; | |
| 583 | +} | |
| @@ -47,6 +47,7 @@ extern int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode); · 46 unmodified lines | ||
| 47 | 47 | extern int smu7_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t speed); |
| 48 | 48 | extern int smu7_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); |
| 49 | 49 | extern int pp_smu7_thermal_initialize(struct pp_hwmgr *hwmgr); |
| 50 | +extern void pp_smu7_thermal_fini(struct pp_hwmgr *hwmgr); | |
| 50 | 51 | extern int smu7_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr); |
| 51 | 52 | extern int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed); |
| 52 | 53 | extern int smu7_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed); |
| @@ -29,7 +29,10 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "amd_shared.h" |
| 30 | 30 | #include "cgs_common.h" |
| 31 | 31 | |
| 32 | −extern int amdgpu_dpm; | |
| 32 | +extern const struct amd_ip_funcs pp_ip_funcs; | |
| 33 | +extern const struct amd_powerplay_funcs pp_dpm_funcs; | |
| 34 | + | |
| 35 | +#define PP_DPM_DISABLED 0xCCCC | |
| 33 | 36 | |
| 34 | 37 | enum amd_pp_sensors { |
| 35 | 38 | AMDGPU_PP_SENSOR_GFX_SCLK = 0, |
| @@ -135,17 +138,12 @@ enum amd_pp_event { · 99 unmodified lines | ||
| 135 | 138 | AMD_PP_EVENT_MAX |
| 136 | 139 | }; |
| 137 | 140 | |
| 138 | −enum amd_dpm_forced_level { | |
| 139 | − AMD_DPM_FORCED_LEVEL_AUTO = 0, | |
| 140 | − AMD_DPM_FORCED_LEVEL_LOW = 1, | |
| 141 | − AMD_DPM_FORCED_LEVEL_HIGH = 2, | |
| 142 | − AMD_DPM_FORCED_LEVEL_MANUAL = 3, | |
| 143 | −}; | |
| 144 | − | |
| 145 | 141 | struct amd_pp_init { |
| 146 | 142 | struct cgs_device *device; |
| 147 | 143 | uint32_t chip_family; |
| 148 | 144 | uint32_t chip_id; |
| 145 | + bool pm_en; | |
| 146 | + uint32_t feature_mask; | |
| 149 | 147 | }; |
| 150 | 148 | |
| 151 | 149 | enum amd_pp_display_config_type{ |
| @@ -371,10 +369,10 @@ struct amd_powerplay { · 219 unmodified lines | ||
| 371 | 369 | const struct amd_powerplay_funcs *pp_funcs; |
| 372 | 370 | }; |
| 373 | 371 | |
| 374 | −int amd_powerplay_init(struct amd_pp_init *pp_init, | |
| 375 | − struct amd_powerplay *amd_pp); | |
| 372 | +int amd_powerplay_create(struct amd_pp_init *pp_init, | |
| 373 | + void **handle); | |
| 376 | 374 | |
| 377 | −int amd_powerplay_fini(void *handle); | |
| 375 | +int amd_powerplay_destroy(void *handle); | |
| 378 | 376 | |
| 379 | 377 | int amd_powerplay_reset(void *handle); |
| 380 | 378 | |
| @@ -119,7 +119,6 @@ struct pp_eventmgr { · 118 unmodified lines | ||
| 119 | 119 | void (*pp_eventmgr_fini)(struct pp_eventmgr *eventmgr); |
| 120 | 120 | }; |
| 121 | 121 | |
| 122 | −int eventmgr_init(struct pp_instance *handle); | |
| 123 | −int eventmgr_fini(struct pp_eventmgr *eventmgr); | |
| 122 | +int eventmgr_early_init(struct pp_instance *handle); | |
| 124 | 123 | |
| 125 | 124 | #endif /* _EVENTMGR_H_ */ |
| @@ -38,8 +38,6 @@ struct pp_hwmgr; · 37 unmodified lines | ||
| 38 | 38 | struct phm_fan_speed_info; |
| 39 | 39 | struct pp_atomctrl_voltage_table; |
| 40 | 40 | |
| 41 | −extern unsigned amdgpu_pp_feature_mask; | |
| 42 | − | |
| 43 | 41 | #define VOLTAGE_SCALE 4 |
| 44 | 42 | |
| 45 | 43 | uint8_t convert_to_vid(uint16_t vddc); |
| @@ -358,6 +356,8 @@ struct pp_hwmgr_func { · 312 unmodified lines | ||
| 358 | 356 | int (*get_mclk_od)(struct pp_hwmgr *hwmgr); |
| 359 | 357 | int (*set_mclk_od)(struct pp_hwmgr *hwmgr, uint32_t value); |
| 360 | 358 | int (*read_sensor)(struct pp_hwmgr *hwmgr, int idx, int32_t *value); |
| 359 | + int (*request_firmware)(struct pp_hwmgr *hwmgr); | |
| 360 | + int (*release_firmware)(struct pp_hwmgr *hwmgr); | |
| 361 | 361 | }; |
| 362 | 362 | |
| 363 | 363 | struct pp_table_func { |
| @@ -612,6 +612,7 @@ struct pp_hwmgr { · 248 unmodified lines | ||
| 612 | 612 | uint32_t num_vce_state_tables; |
| 613 | 613 | |
| 614 | 614 | enum amd_dpm_forced_level dpm_level; |
| 615 | + enum amd_dpm_forced_level saved_dpm_level; | |
| 615 | 616 | bool block_hw_access; |
| 616 | 617 | struct phm_gfx_arbiter gfx_arbiter; |
| 617 | 618 | struct phm_acp_arbiter acp_arbiter; |
| @@ -651,19 +652,12 @@ struct pp_hwmgr { · 33 unmodified lines | ||
| 651 | 652 | uint32_t feature_mask; |
| 652 | 653 | }; |
| 653 | 654 | |
| 654 | − | |
| 655 | −extern int hwmgr_init(struct amd_pp_init *pp_init, | |
| 656 | − struct pp_instance *handle); | |
| 657 | − | |
| 658 | −extern int hwmgr_fini(struct pp_hwmgr *hwmgr); | |
| 659 | − | |
| 660 | −extern int hw_init_power_state_table(struct pp_hwmgr *hwmgr); | |
| 661 | − | |
| 655 | +extern int hwmgr_early_init(struct pp_instance *handle); | |
| 656 | +extern int hwmgr_hw_init(struct pp_instance *handle); | |
| 657 | +extern int hwmgr_hw_fini(struct pp_instance *handle); | |
| 662 | 658 | extern int phm_wait_on_register(struct pp_hwmgr *hwmgr, uint32_t index, |
| 663 | 659 | uint32_t value, uint32_t mask); |
| 664 | 660 | |
| 665 | − | |
| 666 | − | |
| 667 | 661 | extern void phm_wait_on_indirect_register(struct pp_hwmgr *hwmgr, |
| 668 | 662 | uint32_t indirect_port, |
| 669 | 663 | uint32_t index, |
| @@ -692,11 +686,10 @@ extern int phm_find_boot_level(void *table, uint32_t value, uint32_t *boot_level · 22 unmodified lines | ||
| 692 | 686 | extern int phm_get_sclk_for_voltage_evv(struct pp_hwmgr *hwmgr, phm_ppt_v1_voltage_lookup_table *lookup_table, |
| 693 | 687 | uint16_t virtual_voltage_id, int32_t *sclk); |
| 694 | 688 | extern int phm_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr); |
| 695 | −extern int phm_hwmgr_backend_fini(struct pp_hwmgr *hwmgr); | |
| 696 | 689 | extern uint32_t phm_get_lowest_enabled_level(struct pp_hwmgr *hwmgr, uint32_t mask); |
| 697 | 690 | extern void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr); |
| 698 | 691 | |
| 699 | −extern int smu7_hwmgr_init(struct pp_hwmgr *hwmgr); | |
| 692 | +extern int smu7_init_function_pointers(struct pp_hwmgr *hwmgr); | |
| 700 | 693 | extern int phm_get_voltage_evv_on_sclk(struct pp_hwmgr *hwmgr, uint8_t voltage_type, |
| 701 | 694 | uint32_t sclk, uint16_t id, uint16_t *voltage); |
| 702 | 695 | |
| @@ -24,6 +24,12 @@ · 23 unmodified lines | ||
| 24 | 24 | #ifndef PP_DEBUG_H |
| 25 | 25 | #define PP_DEBUG_H |
| 26 | 26 | |
| 27 | +#ifdef pr_fmt | |
| 28 | +#undef pr_fmt | |
| 29 | +#endif | |
| 30 | + | |
| 31 | +#define pr_fmt(fmt) "amdgpu: [powerplay] " fmt | |
| 32 | + | |
| 27 | 33 | #include <linux/types.h> |
| 28 | 34 | #include <linux/kernel.h> |
| 29 | 35 | #include <linux/slab.h> |
| @@ -31,7 +37,7 @@ · 1 unmodified line | ||
| 31 | 37 | #define PP_ASSERT_WITH_CODE(cond, msg, code) \ |
| 32 | 38 | do { \ |
| 33 | 39 | if (!(cond)) { \ |
| 34 | − printk("%s\n", msg); \ | |
| 40 | + pr_warning("%s\n", msg); \ | |
| 35 | 41 | code; \ |
| 36 | 42 | } \ |
| 37 | 43 | } while (0) |
| @@ -39,7 +45,7 @@ · 1 unmodified line | ||
| 39 | 45 | |
| 40 | 46 | #define PP_DBG_LOG(fmt, ...) \ |
| 41 | 47 | do { \ |
| 42 | − if(0)printk(KERN_INFO "[ pp_dbg ] " fmt, ##__VA_ARGS__); \ | |
| 48 | + pr_debug(fmt, ##__VA_ARGS__); \ | |
| 43 | 49 | } while (0) |
| 44 | 50 | |
| 45 | 51 | |
| @@ -31,6 +31,11 @@ · 30 unmodified lines | ||
| 31 | 31 | |
| 32 | 32 | struct pp_instance { |
| 33 | 33 | uint32_t pp_valid; |
| 34 | + uint32_t chip_family; | |
| 35 | + uint32_t chip_id; | |
| 36 | + bool pm_en; | |
| 37 | + uint32_t feature_mask; | |
| 38 | + void *device; | |
| 34 | 39 | struct pp_smumgr *smu_mgr; |
| 35 | 40 | struct pp_hwmgr *hwmgr; |
| 36 | 41 | struct pp_eventmgr *eventmgr; |
| @@ -394,6 +394,9 @@ typedef uint16_t PPSMC_Result; · 393 unmodified lines | ||
| 394 | 394 | |
| 395 | 395 | #define PPSMC_MSG_SetVBITimeout ((uint16_t) 0x306) |
| 396 | 396 | |
| 397 | +#define PPSMC_MSG_EnableDpmDidt ((uint16_t) 0x309) | |
| 398 | +#define PPSMC_MSG_DisableDpmDidt ((uint16_t) 0x30A) | |
| 399 | + | |
| 397 | 400 | #define PPSMC_MSG_SecureSRBMWrite ((uint16_t) 0x600) |
| 398 | 401 | #define PPSMC_MSG_SecureSRBMRead ((uint16_t) 0x601) |
| 399 | 402 | #define PPSMC_MSG_SetAddress ((uint16_t) 0x800) |
| @@ -33,6 +33,12 @@ struct pp_hwmgr; · 32 unmodified lines | ||
| 33 | 33 | #define smu_lower_32_bits(n) ((uint32_t)(n)) |
| 34 | 34 | #define smu_upper_32_bits(n) ((uint32_t)(((n)>>16)>>16)) |
| 35 | 35 | |
| 36 | +extern const struct pp_smumgr_func cz_smu_funcs; | |
| 37 | +extern const struct pp_smumgr_func iceland_smu_funcs; | |
| 38 | +extern const struct pp_smumgr_func tonga_smu_funcs; | |
| 39 | +extern const struct pp_smumgr_func fiji_smu_funcs; | |
| 40 | +extern const struct pp_smumgr_func polaris10_smu_funcs; | |
| 41 | + | |
| 36 | 42 | enum AVFS_BTC_STATUS { |
| 37 | 43 | AVFS_BTC_BOOT = 0, |
| 38 | 44 | AVFS_BTC_BOOT_STARTEDSMU, |
| @@ -133,11 +139,7 @@ struct pp_smumgr { · 94 unmodified lines | ||
| 133 | 139 | const struct pp_smumgr_func *smumgr_funcs; |
| 134 | 140 | }; |
| 135 | 141 | |
| 136 | − | |
| 137 | −extern int smum_init(struct amd_pp_init *pp_init, | |
| 138 | − struct pp_instance *handle); | |
| 139 | − | |
| 140 | −extern int smum_fini(struct pp_smumgr *smumgr); | |
| 142 | +extern int smum_early_init(struct pp_instance *handle); | |
| 141 | 143 | |
| 142 | 144 | extern int smum_get_argument(struct pp_smumgr *smumgr); |
| 143 | 145 | |
| @@ -172,13 +174,6 @@ extern int smu_allocate_memory(void *device, uint32_t size, · 28 unmodified lines | ||
| 172 | 174 | void **kptr, void *handle); |
| 173 | 175 | |
| 174 | 176 | extern int smu_free_memory(void *device, void *handle); |
| 175 | − | |
| 176 | −extern int cz_smum_init(struct pp_smumgr *smumgr); | |
| 177 | −extern int iceland_smum_init(struct pp_smumgr *smumgr); | |
| 178 | −extern int tonga_smum_init(struct pp_smumgr *smumgr); | |
| 179 | −extern int fiji_smum_init(struct pp_smumgr *smumgr); | |
| 180 | −extern int polaris10_smum_init(struct pp_smumgr *smumgr); | |
| 181 | − | |
| 182 | 177 | extern int smum_update_sclk_threshold(struct pp_hwmgr *hwmgr); |
| 183 | 178 | |
| 184 | 179 | extern int smum_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type); |
| @@ -70,7 +70,7 @@ static int cz_send_msg_to_smc_async(struct pp_smumgr *smumgr, · 69 unmodified lines | ||
| 70 | 70 | result = SMUM_WAIT_FIELD_UNEQUAL(smumgr, |
| 71 | 71 | SMU_MP1_SRBM2P_RESP_0, CONTENT, 0); |
| 72 | 72 | if (result != 0) { |
| 73 | − printk(KERN_ERR "[ powerplay ] cz_send_msg_to_smc_async failed\n"); | |
| 73 | + pr_err("cz_send_msg_to_smc_async failed\n"); | |
| 74 | 74 | return result; |
| 75 | 75 | } |
| 76 | 76 | |
| @@ -100,12 +100,12 @@ static int cz_set_smc_sram_address(struct pp_smumgr *smumgr, · 23 unmodified lines | ||
| 100 | 100 | return -EINVAL; |
| 101 | 101 | |
| 102 | 102 | if (0 != (3 & smc_address)) { |
| 103 | − printk(KERN_ERR "[ powerplay ] SMC address must be 4 byte aligned\n"); | |
| 103 | + pr_err("SMC address must be 4 byte aligned\n"); | |
| 104 | 104 | return -EINVAL; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | if (limit <= (smc_address + 3)) { |
| 108 | − printk(KERN_ERR "[ powerplay ] SMC address beyond the SMC RAM area\n"); | |
| 108 | + pr_err("SMC address beyond the SMC RAM area\n"); | |
| 109 | 109 | return -EINVAL; |
| 110 | 110 | } |
| 111 | 111 | |
| @@ -141,42 +141,6 @@ static int cz_send_msg_to_smc_with_parameter(struct pp_smumgr *smumgr, · 29 unmodified lines | ||
| 141 | 141 | return cz_send_msg_to_smc(smumgr, msg); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | −static int cz_request_smu_load_fw(struct pp_smumgr *smumgr) | |
| 145 | −{ | |
| 146 | − struct cz_smumgr *cz_smu = (struct cz_smumgr *)(smumgr->backend); | |
| 147 | − uint32_t smc_address; | |
| 148 | − | |
| 149 | − if (!smumgr->reload_fw) { | |
| 150 | − printk(KERN_INFO "[ powerplay ] skip reloading...\n"); | |
| 151 | − return 0; | |
| 152 | − } | |
| 153 | − | |
| 154 | − smc_address = SMU8_FIRMWARE_HEADER_LOCATION + | |
| 155 | − offsetof(struct SMU8_Firmware_Header, UcodeLoadStatus); | |
| 156 | − | |
| 157 | − cz_write_smc_sram_dword(smumgr, smc_address, 0, smc_address+4); | |
| 158 | − | |
| 159 | − cz_send_msg_to_smc_with_parameter(smumgr, | |
| 160 | − PPSMC_MSG_DriverDramAddrHi, | |
| 161 | − cz_smu->toc_buffer.mc_addr_high); | |
| 162 | − | |
| 163 | − cz_send_msg_to_smc_with_parameter(smumgr, | |
| 164 | − PPSMC_MSG_DriverDramAddrLo, | |
| 165 | − cz_smu->toc_buffer.mc_addr_low); | |
| 166 | − | |
| 167 | − cz_send_msg_to_smc(smumgr, PPSMC_MSG_InitJobs); | |
| 168 | − | |
| 169 | − cz_send_msg_to_smc_with_parameter(smumgr, | |
| 170 | − PPSMC_MSG_ExecuteJob, | |
| 171 | − cz_smu->toc_entry_aram); | |
| 172 | − cz_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_ExecuteJob, | |
| 173 | − cz_smu->toc_entry_power_profiling_index); | |
| 174 | − | |
| 175 | − return cz_send_msg_to_smc_with_parameter(smumgr, | |
| 176 | − PPSMC_MSG_ExecuteJob, | |
| 177 | − cz_smu->toc_entry_initialize_index); | |
| 178 | −} | |
| 179 | − | |
| 180 | 144 | static int cz_check_fw_load_finish(struct pp_smumgr *smumgr, |
| 181 | 145 | uint32_t firmware) |
| 182 | 146 | { |
| @@ -198,7 +162,7 @@ static int cz_check_fw_load_finish(struct pp_smumgr *smumgr, · 15 unmodified lines | ||
| 198 | 162 | } |
| 199 | 163 | |
| 200 | 164 | if (i >= smumgr->usec_timeout) { |
| 201 | − printk(KERN_ERR "[ powerplay ] SMU check loaded firmware failed.\n"); | |
| 165 | + pr_err("SMU check loaded firmware failed.\n"); | |
| 202 | 166 | return -EINVAL; |
| 203 | 167 | } |
| 204 | 168 | |
| @@ -250,34 +214,6 @@ static int cz_load_mec_firmware(struct pp_smumgr *smumgr) · 45 unmodified lines | ||
| 250 | 214 | return 0; |
| 251 | 215 | } |
| 252 | 216 | |
| 253 | −static int cz_start_smu(struct pp_smumgr *smumgr) | |
| 254 | −{ | |
| 255 | − int ret = 0; | |
| 256 | − uint32_t fw_to_check = UCODE_ID_RLC_G_MASK | | |
| 257 | − UCODE_ID_SDMA0_MASK | | |
| 258 | − UCODE_ID_SDMA1_MASK | | |
| 259 | − UCODE_ID_CP_CE_MASK | | |
| 260 | − UCODE_ID_CP_ME_MASK | | |
| 261 | − UCODE_ID_CP_PFP_MASK | | |
| 262 | − UCODE_ID_CP_MEC_JT1_MASK | | |
| 263 | − UCODE_ID_CP_MEC_JT2_MASK; | |
| 264 | − | |
| 265 | − if (smumgr->chip_id == CHIP_STONEY) | |
| 266 | − fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); | |
| 267 | − | |
| 268 | − ret = cz_request_smu_load_fw(smumgr); | |
| 269 | − if (ret) | |
| 270 | − printk(KERN_ERR "[ powerplay] SMU firmware load failed\n"); | |
| 271 | − | |
| 272 | − cz_check_fw_load_finish(smumgr, fw_to_check); | |
| 273 | − | |
| 274 | − ret = cz_load_mec_firmware(smumgr); | |
| 275 | − if (ret) | |
| 276 | − printk(KERN_ERR "[ powerplay ] Mec Firmware load failed\n"); | |
| 277 | − | |
| 278 | − return ret; | |
| 279 | −} | |
| 280 | − | |
| 281 | 217 | static uint8_t cz_translate_firmware_enum_to_arg(struct pp_smumgr *smumgr, |
| 282 | 218 | enum cz_scratch_entry firmware_enum) |
| 283 | 219 | { |
| @@ -406,7 +342,7 @@ static int cz_smu_populate_single_scratch_task( · 122 unmodified lines | ||
| 406 | 342 | break; |
| 407 | 343 | |
| 408 | 344 | if (i >= cz_smu->scratch_buffer_length) { |
| 409 | − printk(KERN_ERR "[ powerplay ] Invalid Firmware Type\n"); | |
| 345 | + pr_err("Invalid Firmware Type\n"); | |
| 410 | 346 | return -EINVAL; |
| 411 | 347 | } |
| 412 | 348 | |
| @@ -443,7 +379,7 @@ static int cz_smu_populate_single_ucode_load_task( · 30 unmodified lines | ||
| 443 | 379 | break; |
| 444 | 380 | |
| 445 | 381 | if (i >= cz_smu->driver_buffer_length) { |
| 446 | − printk(KERN_ERR "[ powerplay ] Invalid Firmware Type\n"); | |
| 382 | + pr_err("Invalid Firmware Type\n"); | |
| 447 | 383 | return -EINVAL; |
| 448 | 384 | } |
| 449 | 385 | |
| @@ -729,11 +665,87 @@ static int cz_upload_pptable_settings(struct pp_smumgr *smumgr) · 279 unmodified lines | ||
| 729 | 665 | return 0; |
| 730 | 666 | } |
| 731 | 667 | |
| 668 | +static int cz_request_smu_load_fw(struct pp_smumgr *smumgr) | |
| 669 | +{ | |
| 670 | + struct cz_smumgr *cz_smu = (struct cz_smumgr *)(smumgr->backend); | |
| 671 | + uint32_t smc_address; | |
| 672 | + | |
| 673 | + if (!smumgr->reload_fw) { | |
| 674 | + pr_info("skip reloading...\n"); | |
| 675 | + return 0; | |
| 676 | + } | |
| 677 | + | |
| 678 | + cz_smu_populate_firmware_entries(smumgr); | |
| 679 | + | |
| 680 | + cz_smu_construct_toc(smumgr); | |
| 681 | + | |
| 682 | + smc_address = SMU8_FIRMWARE_HEADER_LOCATION + | |
| 683 | + offsetof(struct SMU8_Firmware_Header, UcodeLoadStatus); | |
| 684 | + | |
| 685 | + cz_write_smc_sram_dword(smumgr, smc_address, 0, smc_address+4); | |
| 686 | + | |
| 687 | + cz_send_msg_to_smc_with_parameter(smumgr, | |
| 688 | + PPSMC_MSG_DriverDramAddrHi, | |
| 689 | + cz_smu->toc_buffer.mc_addr_high); | |
| 690 | + | |
| 691 | + cz_send_msg_to_smc_with_parameter(smumgr, | |
| 692 | + PPSMC_MSG_DriverDramAddrLo, | |
| 693 | + cz_smu->toc_buffer.mc_addr_low); | |
| 694 | + | |
| 695 | + cz_send_msg_to_smc(smumgr, PPSMC_MSG_InitJobs); | |
| 696 | + | |
| 697 | + cz_send_msg_to_smc_with_parameter(smumgr, | |
| 698 | + PPSMC_MSG_ExecuteJob, | |
| 699 | + cz_smu->toc_entry_aram); | |
| 700 | + cz_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_ExecuteJob, | |
| 701 | + cz_smu->toc_entry_power_profiling_index); | |
| 702 | + | |
| 703 | + return cz_send_msg_to_smc_with_parameter(smumgr, | |
| 704 | + PPSMC_MSG_ExecuteJob, | |
| 705 | + cz_smu->toc_entry_initialize_index); | |
| 706 | +} | |
| 707 | + | |
| 708 | +static int cz_start_smu(struct pp_smumgr *smumgr) | |
| 709 | +{ | |
| 710 | + int ret = 0; | |
| 711 | + uint32_t fw_to_check = 0; | |
| 712 | + | |
| 713 | + fw_to_check = UCODE_ID_RLC_G_MASK | | |
| 714 | + UCODE_ID_SDMA0_MASK | | |
| 715 | + UCODE_ID_SDMA1_MASK | | |
| 716 | + UCODE_ID_CP_CE_MASK | | |
| 717 | + UCODE_ID_CP_ME_MASK | | |
| 718 | + UCODE_ID_CP_PFP_MASK | | |
| 719 | + UCODE_ID_CP_MEC_JT1_MASK | | |
| 720 | + UCODE_ID_CP_MEC_JT2_MASK; | |
| 721 | + | |
| 722 | + if (smumgr->chip_id == CHIP_STONEY) | |
| 723 | + fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); | |
| 724 | + | |
| 725 | + ret = cz_request_smu_load_fw(smumgr); | |
| 726 | + if (ret) | |
| 727 | + pr_err("SMU firmware load failed\n"); | |
| 728 | + | |
| 729 | + cz_check_fw_load_finish(smumgr, fw_to_check); | |
| 730 | + | |
| 731 | + ret = cz_load_mec_firmware(smumgr); | |
| 732 | + if (ret) | |
| 733 | + pr_err("Mec Firmware load failed\n"); | |
| 734 | + | |
| 735 | + return ret; | |
| 736 | +} | |
| 737 | + | |
| 732 | 738 | static int cz_smu_init(struct pp_smumgr *smumgr) |
| 733 | 739 | { |
| 734 | − struct cz_smumgr *cz_smu = (struct cz_smumgr *)smumgr->backend; | |
| 735 | 740 | uint64_t mc_addr = 0; |
| 736 | 741 | int ret = 0; |
| 742 | + struct cz_smumgr *cz_smu; | |
| 743 | + | |
| 744 | + cz_smu = kzalloc(sizeof(struct cz_smumgr), GFP_KERNEL); | |
| 745 | + if (cz_smu == NULL) | |
| 746 | + return -ENOMEM; | |
| 747 | + | |
| 748 | + smumgr->backend = cz_smu; | |
| 737 | 749 | |
| 738 | 750 | cz_smu->toc_buffer.data_size = 4096; |
| 739 | 751 | cz_smu->smu_buffer.data_size = |
| @@ -769,12 +781,11 @@ static int cz_smu_init(struct pp_smumgr *smumgr) · 29 unmodified lines | ||
| 769 | 781 | cz_smu->smu_buffer.mc_addr_high = smu_upper_32_bits(mc_addr); |
| 770 | 782 | cz_smu->smu_buffer.mc_addr_low = smu_lower_32_bits(mc_addr); |
| 771 | 783 | |
| 772 | − cz_smu_populate_firmware_entries(smumgr); | |
| 773 | 784 | if (0 != cz_smu_populate_single_scratch_entry(smumgr, |
| 774 | 785 | CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SCRATCH, |
| 775 | 786 | UCODE_ID_RLC_SCRATCH_SIZE_BYTE, |
| 776 | 787 | &cz_smu->scratch_buffer[cz_smu->scratch_buffer_length++])) { |
| 777 | − printk(KERN_ERR "[ powerplay ] Error when Populate Firmware Entry.\n"); | |
| 788 | + pr_err("Error when Populate Firmware Entry.\n"); | |
| 778 | 789 | return -1; |
| 779 | 790 | } |
| 780 | 791 | |
| @@ -782,14 +793,14 @@ static int cz_smu_init(struct pp_smumgr *smumgr) · 1 unmodified line | ||
| 782 | 793 | CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_ARAM, |
| 783 | 794 | UCODE_ID_RLC_SRM_ARAM_SIZE_BYTE, |
| 784 | 795 | &cz_smu->scratch_buffer[cz_smu->scratch_buffer_length++])) { |
| 785 | − printk(KERN_ERR "[ powerplay ] Error when Populate Firmware Entry.\n"); | |
| 796 | + pr_err("Error when Populate Firmware Entry.\n"); | |
| 786 | 797 | return -1; |
| 787 | 798 | } |
| 788 | 799 | if (0 != cz_smu_populate_single_scratch_entry(smumgr, |
| 789 | 800 | CZ_SCRATCH_ENTRY_UCODE_ID_RLC_SRM_DRAM, |
| 790 | 801 | UCODE_ID_RLC_SRM_DRAM_SIZE_BYTE, |
| 791 | 802 | &cz_smu->scratch_buffer[cz_smu->scratch_buffer_length++])) { |
| 792 | − printk(KERN_ERR "[ powerplay ] Error when Populate Firmware Entry.\n"); | |
| 803 | + pr_err("Error when Populate Firmware Entry.\n"); | |
| 793 | 804 | return -1; |
| 794 | 805 | } |
| 795 | 806 | |
| @@ -797,7 +808,7 @@ static int cz_smu_init(struct pp_smumgr *smumgr) · 1 unmodified line | ||
| 797 | 808 | CZ_SCRATCH_ENTRY_UCODE_ID_POWER_PROFILING, |
| 798 | 809 | sizeof(struct SMU8_MultimediaPowerLogData), |
| 799 | 810 | &cz_smu->scratch_buffer[cz_smu->scratch_buffer_length++])) { |
| 800 | − printk(KERN_ERR "[ powerplay ] Error when Populate Firmware Entry.\n"); | |
| 811 | + pr_err("Error when Populate Firmware Entry.\n"); | |
| 801 | 812 | return -1; |
| 802 | 813 | } |
| 803 | 814 | |
| @@ -805,10 +816,9 @@ static int cz_smu_init(struct pp_smumgr *smumgr) · 1 unmodified line | ||
| 805 | 816 | CZ_SCRATCH_ENTRY_SMU8_FUSION_CLKTABLE, |
| 806 | 817 | sizeof(struct SMU8_Fusion_ClkTable), |
| 807 | 818 | &cz_smu->scratch_buffer[cz_smu->scratch_buffer_length++])) { |
| 808 | − printk(KERN_ERR "[ powerplay ] Error when Populate Firmware Entry.\n"); | |
| 819 | + pr_err("Error when Populate Firmware Entry.\n"); | |
| 809 | 820 | return -1; |
| 810 | 821 | } |
| 811 | − cz_smu_construct_toc(smumgr); | |
| 812 | 822 | |
| 813 | 823 | return 0; |
| 814 | 824 | } |
| @@ -827,13 +837,12 @@ static int cz_smu_fini(struct pp_smumgr *smumgr) · 12 unmodified lines | ||
| 827 | 837 | cgs_free_gpu_mem(smumgr->device, |
| 828 | 838 | cz_smu->smu_buffer.handle); |
| 829 | 839 | kfree(cz_smu); |
| 830 | − kfree(smumgr); | |
| 831 | 840 | } |
| 832 | 841 | |
| 833 | 842 | return 0; |
| 834 | 843 | } |
| 835 | 844 | |
| 836 | −static const struct pp_smumgr_func cz_smu_funcs = { | |
| 845 | +const struct pp_smumgr_func cz_smu_funcs = { | |
| 837 | 846 | .smu_init = cz_smu_init, |
| 838 | 847 | .smu_fini = cz_smu_fini, |
| 839 | 848 | .start_smu = cz_start_smu, |
| @@ -847,15 +856,3 @@ static const struct pp_smumgr_func cz_smu_funcs = { · 7 unmodified lines | ||
| 847 | 856 | .upload_pptable_settings = cz_upload_pptable_settings, |
| 848 | 857 | }; |
| 849 | 858 | |
| 850 | −int cz_smum_init(struct pp_smumgr *smumgr) | |
| 851 | −{ | |
| 852 | − struct cz_smumgr *cz_smu; | |
| 853 | − | |
| 854 | − cz_smu = kzalloc(sizeof(struct cz_smumgr), GFP_KERNEL); | |
| 855 | − if (cz_smu == NULL) | |
| 856 | − return -ENOMEM; | |
| 857 | − | |
| 858 | − smumgr->backend = cz_smu; | |
| 859 | − smumgr->smumgr_funcs = &cz_smu_funcs; | |
| 860 | − return 0; | |
| 861 | −} | |
| @@ -95,8 +95,4 @@ struct cz_smumgr { · 94 unmodified lines | ||
| 95 | 95 | struct cz_buffer_entry scratch_buffer[MAX_NUM_SCRATCH]; |
| 96 | 96 | }; |
| 97 | 97 | |
| 98 | −struct pp_smumgr; | |
| 99 | − | |
| 100 | −extern int cz_smum_init(struct pp_smumgr *smumgr); | |
| 101 | − | |
| 102 | 98 | #endif |
| @@ -21,13 +21,13 @@ · 20 unmodified lines | ||
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | +#include "pp_debug.h" | |
| 24 | 25 | #include "fiji_smc.h" |
| 25 | 26 | #include "smu7_dyn_defaults.h" |
| 26 | 27 | |
| 27 | 28 | #include "smu7_hwmgr.h" |
| 28 | 29 | #include "hardwaremanager.h" |
| 29 | 30 | #include "ppatomctrl.h" |
| 30 | −#include "pp_debug.h" | |
| 31 | 31 | #include "cgs_common.h" |
| 32 | 32 | #include "atombios.h" |
| 33 | 33 | #include "fiji_smumgr.h" |
| @@ -2131,7 +2131,7 @@ uint32_t fiji_get_offsetof(uint32_t type, uint32_t member) · 2097 unmodified lines | ||
| 2131 | 2131 | return offsetof(SMU73_Discrete_DpmTable, LowSclkInterruptThreshold); |
| 2132 | 2132 | } |
| 2133 | 2133 | } |
| 2134 | − printk(KERN_WARNING "can't get the offset of type %x member %x\n", type, member); | |
| 2134 | + pr_warning("can't get the offset of type %x member %x\n", type, member); | |
| 2135 | 2135 | return 0; |
| 2136 | 2136 | } |
| 2137 | 2137 | |
| @@ -2156,7 +2156,7 @@ uint32_t fiji_get_mac_definition(uint32_t value) · 18 unmodified lines | ||
| 2156 | 2156 | return SMU73_MAX_LEVELS_MVDD; |
| 2157 | 2157 | } |
| 2158 | 2158 | |
| 2159 | − printk(KERN_WARNING "can't get the mac of %x\n", value); | |
| 2159 | + pr_warning("can't get the mac of %x\n", value); | |
| 2160 | 2160 | return 0; |
| 2161 | 2161 | } |
| 2162 | 2162 | |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | +#include "pp_debug.h" | |
| 24 | 25 | #include "smumgr.h" |
| 25 | 26 | #include "smu73.h" |
| 26 | 27 | #include "smu_ucode_xfer_vi.h" |
| @@ -36,7 +37,6 @@ · 9 unmodified lines | ||
| 36 | 37 | #include "gca/gfx_8_0_d.h" |
| 37 | 38 | #include "bif/bif_5_0_d.h" |
| 38 | 39 | #include "bif/bif_5_0_sh_mask.h" |
| 39 | −#include "pp_debug.h" | |
| 40 | 40 | #include "fiji_pwrvirus.h" |
| 41 | 41 | #include "fiji_smc.h" |
| 42 | 42 | |
| @@ -179,7 +179,7 @@ static int fiji_setup_pwr_virus(struct pp_smumgr *smumgr) · 136 unmodified lines | ||
| 179 | 179 | result = 0; |
| 180 | 180 | break; |
| 181 | 181 | default: |
| 182 | − printk(KERN_ERR "Table Exit with Invalid Command!"); | |
| 182 | + pr_err("Table Exit with Invalid Command!"); | |
| 183 | 183 | priv->avfs.AvfsBtcStatus = AVFS_BTC_VIRUS_FAIL; |
| 184 | 184 | result = -1; |
| 185 | 185 | break; |
| @@ -202,13 +202,13 @@ static int fiji_start_avfs_btc(struct pp_smumgr *smumgr) · 16 unmodified lines | ||
| 202 | 202 | priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_UNSAVED; |
| 203 | 203 | result = 0; |
| 204 | 204 | } else { |
| 205 | − printk(KERN_ERR "[AVFS][fiji_start_avfs_btc] Attempt" | |
| 205 | + pr_err("[AVFS][fiji_start_avfs_btc] Attempt" | |
| 206 | 206 | " to Enable AVFS Failed!"); |
| 207 | 207 | smum_send_msg_to_smc(smumgr, PPSMC_MSG_DisableAvfs); |
| 208 | 208 | result = -1; |
| 209 | 209 | } |
| 210 | 210 | } else { |
| 211 | − printk(KERN_ERR "[AVFS][fiji_start_avfs_btc] " | |
| 211 | + pr_err("[AVFS][fiji_start_avfs_btc] " | |
| 212 | 212 | "PerformBTC SMU msg failed"); |
| 213 | 213 | result = -1; |
| 214 | 214 | } |
| @@ -384,7 +384,7 @@ static int fiji_avfs_event_mgr(struct pp_smumgr *smumgr, bool smu_started) · 169 unmodified lines | ||
| 384 | 384 | case AVFS_BTC_NOTSUPPORTED: /* Do nothing */ |
| 385 | 385 | break; |
| 386 | 386 | default: |
| 387 | − printk(KERN_ERR "[AVFS] Something is broken. See log!"); | |
| 387 | + pr_err("[AVFS] Something is broken. See log!"); | |
| 388 | 388 | break; |
| 389 | 389 | } |
| 390 | 390 | return 0; |
| @@ -464,13 +464,20 @@ static bool fiji_is_hw_avfs_present(struct pp_smumgr *smumgr) · 73 unmodified lines | ||
| 464 | 464 | */ |
| 465 | 465 | static int fiji_smu_init(struct pp_smumgr *smumgr) |
| 466 | 466 | { |
| 467 | − struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend); | |
| 468 | 467 | int i; |
| 468 | + struct fiji_smumgr *fiji_priv = NULL; | |
| 469 | + | |
| 470 | + fiji_priv = kzalloc(sizeof(struct fiji_smumgr), GFP_KERNEL); | |
| 471 | + | |
| 472 | + if (fiji_priv == NULL) | |
| 473 | + return -ENOMEM; | |
| 474 | + | |
| 475 | + smumgr->backend = fiji_priv; | |
| 469 | 476 | |
| 470 | 477 | if (smu7_init(smumgr)) |
| 471 | 478 | return -EINVAL; |
| 472 | 479 | |
| 473 | − priv->avfs.AvfsBtcStatus = AVFS_BTC_BOOT; | |
| 480 | + fiji_priv->avfs.AvfsBtcStatus = AVFS_BTC_BOOT; | |
| 474 | 481 | if (fiji_is_hw_avfs_present(smumgr)) |
| 475 | 482 | /* AVFS Parameter |
| 476 | 483 | * 0 - BTC DC disabled, BTC AC disabled |
| @@ -479,18 +486,18 @@ static int fiji_smu_init(struct pp_smumgr *smumgr) · 2 unmodified lines | ||
| 479 | 486 | * 3 - BTC DC enabled, BTC AC enabled |
| 480 | 487 | * Default is 0 - BTC DC disabled, BTC AC disabled |
| 481 | 488 | */ |
| 482 | − priv->avfs.AvfsBtcParam = 0; | |
| 489 | + fiji_priv->avfs.AvfsBtcParam = 0; | |
| 483 | 490 | else |
| 484 | − priv->avfs.AvfsBtcStatus = AVFS_BTC_NOTSUPPORTED; | |
| 491 | + fiji_priv->avfs.AvfsBtcStatus = AVFS_BTC_NOTSUPPORTED; | |
| 485 | 492 | |
| 486 | 493 | for (i = 0; i < SMU73_MAX_LEVELS_GRAPHICS; i++) |
| 487 | − priv->activity_target[i] = 30; | |
| 494 | + fiji_priv->activity_target[i] = 30; | |
| 488 | 495 | |
| 489 | 496 | return 0; |
| 490 | 497 | } |
| 491 | 498 | |
| 492 | 499 | |
| 493 | −static const struct pp_smumgr_func fiji_smu_funcs = { | |
| 500 | +const struct pp_smumgr_func fiji_smu_funcs = { | |
| 494 | 501 | .smu_init = &fiji_smu_init, |
| 495 | 502 | .smu_fini = &smu7_smu_fini, |
| 496 | 503 | .start_smu = &fiji_start_smu, |
| @@ -513,18 +520,3 @@ static const struct pp_smumgr_func fiji_smu_funcs = { · 16 unmodified lines | ||
| 513 | 520 | .initialize_mc_reg_table = fiji_initialize_mc_reg_table, |
| 514 | 521 | .is_dpm_running = fiji_is_dpm_running, |
| 515 | 522 | }; |
| 516 | − | |
| 517 | −int fiji_smum_init(struct pp_smumgr *smumgr) | |
| 518 | −{ | |
| 519 | − struct fiji_smumgr *fiji_smu = NULL; | |
| 520 | − | |
| 521 | − fiji_smu = kzalloc(sizeof(struct fiji_smumgr), GFP_KERNEL); | |
| 522 | − | |
| 523 | − if (fiji_smu == NULL) | |
| 524 | − return -ENOMEM; | |
| 525 | − | |
| 526 | − smumgr->backend = fiji_smu; | |
| 527 | − smumgr->smumgr_funcs = &fiji_smu_funcs; | |
| 528 | − | |
| 529 | − return 0; | |
| 530 | −} | |
| @@ -21,13 +21,13 @@ · 20 unmodified lines | ||
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | +#include "pp_debug.h" | |
| 24 | 25 | #include "iceland_smc.h" |
| 25 | 26 | #include "smu7_dyn_defaults.h" |
| 26 | 27 | |
| 27 | 28 | #include "smu7_hwmgr.h" |
| 28 | 29 | #include "hardwaremanager.h" |
| 29 | 30 | #include "ppatomctrl.h" |
| 30 | −#include "pp_debug.h" | |
| 31 | 31 | #include "cgs_common.h" |
| 32 | 32 | #include "atombios.h" |
| 33 | 33 | #include "pppcielanes.h" |
| @@ -1545,7 +1545,7 @@ static int iceland_populate_smc_boot_level(struct pp_hwmgr *hwmgr, · 1511 unmodified lines | ||
| 1545 | 1545 | |
| 1546 | 1546 | if (0 != result) { |
| 1547 | 1547 | smu_data->smc_state_table.GraphicsBootLevel = 0; |
| 1548 | − printk(KERN_ERR "[ powerplay ] VBIOS did not find boot engine clock value \ | |
| 1548 | + pr_err("VBIOS did not find boot engine clock value \ | |
| 1549 | 1549 | in dependency table. Using Graphics DPM level 0!"); |
| 1550 | 1550 | result = 0; |
| 1551 | 1551 | } |
| @@ -1556,7 +1556,7 @@ static int iceland_populate_smc_boot_level(struct pp_hwmgr *hwmgr, · 4 unmodified lines | ||
| 1556 | 1556 | |
| 1557 | 1557 | if (0 != result) { |
| 1558 | 1558 | smu_data->smc_state_table.MemoryBootLevel = 0; |
| 1559 | − printk(KERN_ERR "[ powerplay ] VBIOS did not find boot engine clock value \ | |
| 1559 | + pr_err("VBIOS did not find boot engine clock value \ | |
| 1560 | 1560 | in dependency table. Using Memory DPM level 0!"); |
| 1561 | 1561 | result = 0; |
| 1562 | 1562 | } |
| @@ -2146,7 +2146,7 @@ uint32_t iceland_get_offsetof(uint32_t type, uint32_t member) · 583 unmodified lines | ||
| 2146 | 2146 | return offsetof(SMU71_Discrete_DpmTable, LowSclkInterruptThreshold); |
| 2147 | 2147 | } |
| 2148 | 2148 | } |
| 2149 | − printk(KERN_WARNING "can't get the offset of type %x member %x\n", type, member); | |
| 2149 | + pr_warning("can't get the offset of type %x member %x\n", type, member); | |
| 2150 | 2150 | return 0; |
| 2151 | 2151 | } |
| 2152 | 2152 | |
| @@ -2169,7 +2169,7 @@ uint32_t iceland_get_mac_definition(uint32_t value) · 16 unmodified lines | ||
| 2169 | 2169 | return SMU71_MAX_LEVELS_MVDD; |
| 2170 | 2170 | } |
| 2171 | 2171 | |
| 2172 | − printk(KERN_WARNING "can't get the mac of %x\n", value); | |
| 2172 | + pr_warning("can't get the mac of %x\n", value); | |
| 2173 | 2173 | return 0; |
| 2174 | 2174 | } |
| 2175 | 2175 | |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | * Author: Huang Rui <ray.huang@amd.com> |
| 23 | 23 | * |
| 24 | 24 | */ |
| 25 | +#include "pp_debug.h" | |
| 25 | 26 | #include <linux/types.h> |
| 26 | 27 | #include <linux/kernel.h> |
| 27 | 28 | #include <linux/slab.h> |
| @@ -29,7 +30,6 @@ · 1 unmodified line | ||
| 29 | 30 | |
| 30 | 31 | #include "smumgr.h" |
| 31 | 32 | #include "iceland_smumgr.h" |
| 32 | −#include "pp_debug.h" | |
| 33 | 33 | #include "smu_ucode_xfer_vi.h" |
| 34 | 34 | #include "ppsmc.h" |
| 35 | 35 | #include "smu/smu_7_1_1_d.h" |
| @@ -176,7 +176,7 @@ static int iceland_start_smu(struct pp_smumgr *smumgr) · 140 unmodified lines | ||
| 176 | 176 | return result; |
| 177 | 177 | |
| 178 | 178 | if (!smu7_is_smc_ram_running(smumgr)) { |
| 179 | − printk("smu not running, upload firmware again \n"); | |
| 179 | + pr_info("smu not running, upload firmware again \n"); | |
| 180 | 180 | result = iceland_smu_upload_firmware_image(smumgr); |
| 181 | 181 | if (result) |
| 182 | 182 | return result; |
| @@ -201,17 +201,25 @@ static int iceland_start_smu(struct pp_smumgr *smumgr) · 18 unmodified lines | ||
| 201 | 201 | static int iceland_smu_init(struct pp_smumgr *smumgr) |
| 202 | 202 | { |
| 203 | 203 | int i; |
| 204 | − struct iceland_smumgr *smu_data = (struct iceland_smumgr *)(smumgr->backend); | |
| 204 | + struct iceland_smumgr *iceland_priv = NULL; | |
| 205 | + | |
| 206 | + iceland_priv = kzalloc(sizeof(struct iceland_smumgr), GFP_KERNEL); | |
| 207 | + | |
| 208 | + if (iceland_priv == NULL) | |
| 209 | + return -ENOMEM; | |
| 210 | + | |
| 211 | + smumgr->backend = iceland_priv; | |
| 212 | + | |
| 205 | 213 | if (smu7_init(smumgr)) |
| 206 | 214 | return -EINVAL; |
| 207 | 215 | |
| 208 | 216 | for (i = 0; i < SMU71_MAX_LEVELS_GRAPHICS; i++) |
| 209 | − smu_data->activity_target[i] = 30; | |
| 217 | + iceland_priv->activity_target[i] = 30; | |
| 210 | 218 | |
| 211 | 219 | return 0; |
| 212 | 220 | } |
| 213 | 221 | |
| 214 | −static const struct pp_smumgr_func iceland_smu_funcs = { | |
| 222 | +const struct pp_smumgr_func iceland_smu_funcs = { | |
| 215 | 223 | .smu_init = &iceland_smu_init, |
| 216 | 224 | .smu_fini = &smu7_smu_fini, |
| 217 | 225 | .start_smu = &iceland_start_smu, |
| @@ -234,17 +242,3 @@ static const struct pp_smumgr_func iceland_smu_funcs = { · 16 unmodified lines | ||
| 234 | 242 | .is_dpm_running = iceland_is_dpm_running, |
| 235 | 243 | }; |
| 236 | 244 | |
| 237 | −int iceland_smum_init(struct pp_smumgr *smumgr) | |
| 238 | −{ | |
| 239 | − struct iceland_smumgr *iceland_smu = NULL; | |
| 240 | − | |
| 241 | − iceland_smu = kzalloc(sizeof(struct iceland_smumgr), GFP_KERNEL); | |
| 242 | − | |
| 243 | − if (iceland_smu == NULL) | |
| 244 | − return -ENOMEM; | |
| 245 | − | |
| 246 | − smumgr->backend = iceland_smu; | |
| 247 | − smumgr->smumgr_funcs = &iceland_smu_funcs; | |
| 248 | − | |
| 249 | − return 0; | |
| 250 | −} | |
| @@ -21,13 +21,13 @@ · 20 unmodified lines | ||
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | +#include "pp_debug.h" | |
| 24 | 25 | #include "polaris10_smc.h" |
| 25 | 26 | #include "smu7_dyn_defaults.h" |
| 26 | 27 | |
| 27 | 28 | #include "smu7_hwmgr.h" |
| 28 | 29 | #include "hardwaremanager.h" |
| 29 | 30 | #include "ppatomctrl.h" |
| 30 | −#include "pp_debug.h" | |
| 31 | 31 | #include "cgs_common.h" |
| 32 | 32 | #include "atombios.h" |
| 33 | 33 | #include "polaris10_smumgr.h" |
| @@ -2180,7 +2180,7 @@ uint32_t polaris10_get_offsetof(uint32_t type, uint32_t member) · 2146 unmodified lines | ||
| 2180 | 2180 | return offsetof(SMU74_Discrete_DpmTable, LowSclkInterruptThreshold); |
| 2181 | 2181 | } |
| 2182 | 2182 | } |
| 2183 | − printk(KERN_WARNING "can't get the offset of type %x member %x\n", type, member); | |
| 2183 | + pr_warning("can't get the offset of type %x member %x\n", type, member); | |
| 2184 | 2184 | return 0; |
| 2185 | 2185 | } |
| 2186 | 2186 | |
| @@ -2207,7 +2207,7 @@ uint32_t polaris10_get_mac_definition(uint32_t value) · 20 unmodified lines | ||
| 2207 | 2207 | return SMU7_UVD_MCLK_HANDSHAKE_DISABLE; |
| 2208 | 2208 | } |
| 2209 | 2209 | |
| 2210 | − printk(KERN_WARNING "can't get the mac of %x\n", value); | |
| 2210 | + pr_warning("can't get the mac of %x\n", value); | |
| 2211 | 2211 | return 0; |
| 2212 | 2212 | } |
| 2213 | 2213 | |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | +#include "pp_debug.h" | |
| 24 | 25 | #include "smumgr.h" |
| 25 | 26 | #include "smu74.h" |
| 26 | 27 | #include "smu_ucode_xfer_vi.h" |
| @@ -36,7 +37,6 @@ · 9 unmodified lines | ||
| 36 | 37 | #include "bif/bif_5_0_sh_mask.h" |
| 37 | 38 | #include "polaris10_pwrvirus.h" |
| 38 | 39 | #include "ppatomctrl.h" |
| 39 | −#include "pp_debug.h" | |
| 40 | 40 | #include "cgs_common.h" |
| 41 | 41 | #include "polaris10_smc.h" |
| 42 | 42 | #include "smu7_ppsmc.h" |
| @@ -84,7 +84,7 @@ static int polaris10_setup_pwr_virus(struct pp_smumgr *smumgr) · 41 unmodified lines | ||
| 84 | 84 | break; |
| 85 | 85 | |
| 86 | 86 | default: |
| 87 | − printk("Table Exit with Invalid Command!"); | |
| 87 | + pr_info("Table Exit with Invalid Command!"); | |
| 88 | 88 | smu_data->avfs.avfs_btc_status = AVFS_BTC_VIRUS_FAIL; |
| 89 | 89 | result = -1; |
| 90 | 90 | break; |
| @@ -102,7 +102,7 @@ static int polaris10_perform_btc(struct pp_smumgr *smumgr) · 11 unmodified lines | ||
| 102 | 102 | |
| 103 | 103 | if (0 != smu_data->avfs.avfs_btc_param) { |
| 104 | 104 | if (0 != smu7_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_PerformBtc, smu_data->avfs.avfs_btc_param)) { |
| 105 | − printk("[AVFS][SmuPolaris10_PerformBtc] PerformBTC SMU msg failed"); | |
| 105 | + pr_info("[AVFS][SmuPolaris10_PerformBtc] PerformBTC SMU msg failed"); | |
| 106 | 106 | result = -1; |
| 107 | 107 | } |
| 108 | 108 | } |
| @@ -189,7 +189,7 @@ polaris10_avfs_event_mgr(struct pp_smumgr *smumgr, bool SMU_VFT_INTACT) · 80 unmodified lines | ||
| 189 | 189 | return -1); |
| 190 | 190 | |
| 191 | 191 | if (smu_data->avfs.avfs_btc_param > 1) { |
| 192 | − printk("[AVFS][Polaris10_AVFSEventMgr] AC BTC has not been successfully verified on Fiji. There may be in this setting."); | |
| 192 | + pr_info("[AVFS][Polaris10_AVFSEventMgr] AC BTC has not been successfully verified on Fiji. There may be in this setting."); | |
| 193 | 193 | smu_data->avfs.avfs_btc_status = AVFS_BTC_VIRUS_FAIL; |
| 194 | 194 | PP_ASSERT_WITH_CODE(-1 == polaris10_setup_pwr_virus(smumgr), |
| 195 | 195 | "[AVFS][Polaris10_AVFSEventMgr] Could not setup Pwr Virus for AVFS ", |
| @@ -208,7 +208,7 @@ polaris10_avfs_event_mgr(struct pp_smumgr *smumgr, bool SMU_VFT_INTACT) · 12 unmodified lines | ||
| 208 | 208 | break; |
| 209 | 209 | |
| 210 | 210 | default: |
| 211 | − printk("[AVFS] Something is broken. See log!"); | |
| 211 | + pr_info("[AVFS] Something is broken. See log!"); | |
| 212 | 212 | break; |
| 213 | 213 | } |
| 214 | 214 | |
| @@ -328,6 +328,7 @@ static int polaris10_start_smu(struct pp_smumgr *smumgr) · 113 unmodified lines | ||
| 328 | 328 | /* If failed, try with different security Key. */ |
| 329 | 329 | if (result != 0) { |
| 330 | 330 | smu_data->smu7_data.security_hard_key ^= 1; |
| 331 | + cgs_rel_firmware(smumgr->device, CGS_UCODE_ID_SMU); | |
| 331 | 332 | result = polaris10_start_smu_in_protection_mode(smumgr); |
| 332 | 333 | } |
| 333 | 334 | } |
| @@ -363,9 +364,15 @@ static bool polaris10_is_hw_avfs_present(struct pp_smumgr *smumgr) · 29 unmodified lines | ||
| 363 | 364 | |
| 364 | 365 | static int polaris10_smu_init(struct pp_smumgr *smumgr) |
| 365 | 366 | { |
| 366 | − struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)(smumgr->backend); | |
| 367 | + struct polaris10_smumgr *smu_data; | |
| 367 | 368 | int i; |
| 368 | 369 | |
| 370 | + smu_data = kzalloc(sizeof(struct polaris10_smumgr), GFP_KERNEL); | |
| 371 | + if (smu_data == NULL) | |
| 372 | + return -ENOMEM; | |
| 373 | + | |
| 374 | + smumgr->backend = smu_data; | |
| 375 | + | |
| 369 | 376 | if (smu7_init(smumgr)) |
| 370 | 377 | return -EINVAL; |
| 371 | 378 | |
| @@ -380,7 +387,7 @@ static int polaris10_smu_init(struct pp_smumgr *smumgr) · 8 unmodified lines | ||
| 380 | 387 | return 0; |
| 381 | 388 | } |
| 382 | 389 | |
| 383 | −static const struct pp_smumgr_func polaris10_smu_funcs = { | |
| 390 | +const struct pp_smumgr_func polaris10_smu_funcs = { | |
| 384 | 391 | .smu_init = polaris10_smu_init, |
| 385 | 392 | .smu_fini = smu7_smu_fini, |
| 386 | 393 | .start_smu = polaris10_start_smu, |
| @@ -403,18 +410,3 @@ static const struct pp_smumgr_func polaris10_smu_funcs = { · 16 unmodified lines | ||
| 403 | 410 | .get_mac_definition = polaris10_get_mac_definition, |
| 404 | 411 | .is_dpm_running = polaris10_is_dpm_running, |
| 405 | 412 | }; |
| 406 | − | |
| 407 | −int polaris10_smum_init(struct pp_smumgr *smumgr) | |
| 408 | −{ | |
| 409 | − struct polaris10_smumgr *polaris10_smu = NULL; | |
| 410 | − | |
| 411 | − polaris10_smu = kzalloc(sizeof(struct polaris10_smumgr), GFP_KERNEL); | |
| 412 | − | |
| 413 | − if (polaris10_smu == NULL) | |
| 414 | − return -EINVAL; | |
| 415 | − | |
| 416 | − smumgr->backend = polaris10_smu; | |
| 417 | − smumgr->smumgr_funcs = &polaris10_smu_funcs; | |
| 418 | − | |
| 419 | − return 0; | |
| 420 | −} | |
| @@ -22,12 +22,12 @@ · 21 unmodified lines | ||
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | 24 | |
| 25 | +#include "pp_debug.h" | |
| 25 | 26 | #include "smumgr.h" |
| 26 | 27 | #include "smu_ucode_xfer_vi.h" |
| 27 | 28 | #include "smu/smu_7_1_3_d.h" |
| 28 | 29 | #include "smu/smu_7_1_3_sh_mask.h" |
| 29 | 30 | #include "ppatomctrl.h" |
| 30 | −#include "pp_debug.h" | |
| 31 | 31 | #include "cgs_common.h" |
| 32 | 32 | #include "smu7_ppsmc.h" |
| 33 | 33 | #include "smu7_smumgr.h" |
| @@ -175,7 +175,7 @@ int smu7_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg) · 141 unmodified lines | ||
| 175 | 175 | ret = SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP); |
| 176 | 176 | |
| 177 | 177 | if (ret != 1) |
| 178 | − printk("\n failed to send pre message %x ret is %d \n", msg, ret); | |
| 178 | + pr_info("\n failed to send pre message %x ret is %d \n", msg, ret); | |
| 179 | 179 | |
| 180 | 180 | cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg); |
| 181 | 181 | |
| @@ -184,7 +184,7 @@ int smu7_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg) · 2 unmodified lines | ||
| 184 | 184 | ret = SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP); |
| 185 | 185 | |
| 186 | 186 | if (ret != 1) |
| 187 | − printk("\n failed to send message %x ret is %d \n", msg, ret); | |
| 187 | + pr_info("\n failed to send message %x ret is %d \n", msg, ret); | |
| 188 | 188 | |
| 189 | 189 | return 0; |
| 190 | 190 | } |
| @@ -225,7 +225,7 @@ int smu7_send_msg_to_smc_offset(struct pp_smumgr *smumgr) · 34 unmodified lines | ||
| 225 | 225 | SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0); |
| 226 | 226 | |
| 227 | 227 | if (1 != SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, SMC_RESP)) |
| 228 | − printk("Failed to send Message.\n"); | |
| 228 | + pr_info("Failed to send Message.\n"); | |
| 229 | 229 | |
| 230 | 230 | return 0; |
| 231 | 231 | } |
| @@ -347,7 +347,7 @@ static uint32_t smu7_get_mask_for_firmware_type(uint32_t fw_type) · 115 unmodified lines | ||
| 347 | 347 | result = UCODE_ID_RLC_G_MASK; |
| 348 | 348 | break; |
| 349 | 349 | default: |
| 350 | − printk("UCode type is out of range! \n"); | |
| 350 | + pr_info("UCode type is out of range! \n"); | |
| 351 | 351 | result = 0; |
| 352 | 352 | } |
| 353 | 353 | |
| @@ -396,7 +396,7 @@ int smu7_request_smu_load_fw(struct pp_smumgr *smumgr) · 42 unmodified lines | ||
| 396 | 396 | struct SMU_DRAMData_TOC *toc; |
| 397 | 397 | |
| 398 | 398 | if (!smumgr->reload_fw) { |
| 399 | − printk(KERN_INFO "[ powerplay ] skip reloading...\n"); | |
| 399 | + pr_info("skip reloading...\n"); | |
| 400 | 400 | return 0; |
| 401 | 401 | } |
| 402 | 402 | |
| @@ -474,7 +474,7 @@ int smu7_request_smu_load_fw(struct pp_smumgr *smumgr) · 71 unmodified lines | ||
| 474 | 474 | smu7_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_DRV_DRAM_ADDR_LO, smu_data->header_buffer.mc_addr_low); |
| 475 | 475 | |
| 476 | 476 | if (smu7_send_msg_to_smc_with_parameter(smumgr, PPSMC_MSG_LoadUcodes, fw_to_load)) |
| 477 | − printk(KERN_ERR "Fail to Request SMU Load uCode"); | |
| 477 | + pr_err("Fail to Request SMU Load uCode"); | |
| 478 | 478 | |
| 479 | 479 | return result; |
| 480 | 480 | } |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | */ |
| 23 | 23 | #include <linux/types.h> |
| 24 | 24 | #include <linux/kernel.h> |
| 25 | +#include <linux/module.h> | |
| 25 | 26 | #include <linux/slab.h> |
| 26 | 27 | #include <drm/amdgpu_drm.h> |
| 27 | 28 | #include "pp_instance.h" |
| @@ -29,44 +30,55 @@ · 1 unmodified line | ||
| 29 | 30 | #include "cgs_common.h" |
| 30 | 31 | #include "linux/delay.h" |
| 31 | 32 | |
| 33 | +MODULE_FIRMWARE("amdgpu/topaz_smc.bin"); | |
| 34 | +MODULE_FIRMWARE("amdgpu/topaz_k_smc.bin"); | |
| 35 | +MODULE_FIRMWARE("amdgpu/tonga_smc.bin"); | |
| 36 | +MODULE_FIRMWARE("amdgpu/tonga_k_smc.bin"); | |
| 37 | +MODULE_FIRMWARE("amdgpu/fiji_smc.bin"); | |
| 38 | +MODULE_FIRMWARE("amdgpu/polaris10_smc.bin"); | |
| 39 | +MODULE_FIRMWARE("amdgpu/polaris10_smc_sk.bin"); | |
| 40 | +MODULE_FIRMWARE("amdgpu/polaris11_smc.bin"); | |
| 41 | +MODULE_FIRMWARE("amdgpu/polaris11_smc_sk.bin"); | |
| 42 | +MODULE_FIRMWARE("amdgpu/polaris12_smc.bin"); | |
| 32 | 43 | |
| 33 | −int smum_init(struct amd_pp_init *pp_init, struct pp_instance *handle) | |
| 44 | + | |
| 45 | +int smum_early_init(struct pp_instance *handle) | |
| 34 | 46 | { |
| 35 | 47 | struct pp_smumgr *smumgr; |
| 36 | 48 | |
| 37 | − if ((handle == NULL) || (pp_init == NULL)) | |
| 49 | + if (handle == NULL) | |
| 38 | 50 | return -EINVAL; |
| 39 | 51 | |
| 40 | 52 | smumgr = kzalloc(sizeof(struct pp_smumgr), GFP_KERNEL); |
| 41 | 53 | if (smumgr == NULL) |
| 42 | 54 | return -ENOMEM; |
| 43 | 55 | |
| 44 | − smumgr->device = pp_init->device; | |
| 45 | − smumgr->chip_family = pp_init->chip_family; | |
| 46 | − smumgr->chip_id = pp_init->chip_id; | |
| 56 | + smumgr->device = handle->device; | |
| 57 | + smumgr->chip_family = handle->chip_family; | |
| 58 | + smumgr->chip_id = handle->chip_id; | |
| 47 | 59 | smumgr->usec_timeout = AMD_MAX_USEC_TIMEOUT; |
| 48 | 60 | smumgr->reload_fw = 1; |
| 49 | 61 | handle->smu_mgr = smumgr; |
| 50 | 62 | |
| 51 | 63 | switch (smumgr->chip_family) { |
| 52 | 64 | case AMDGPU_FAMILY_CZ: |
| 53 | − cz_smum_init(smumgr); | |
| 65 | + smumgr->smumgr_funcs = &cz_smu_funcs; | |
| 54 | 66 | break; |
| 55 | 67 | case AMDGPU_FAMILY_VI: |
| 56 | 68 | switch (smumgr->chip_id) { |
| 57 | 69 | case CHIP_TOPAZ: |
| 58 | − iceland_smum_init(smumgr); | |
| 70 | + smumgr->smumgr_funcs = &iceland_smu_funcs; | |
| 59 | 71 | break; |
| 60 | 72 | case CHIP_TONGA: |
| 61 | − tonga_smum_init(smumgr); | |
| 73 | + smumgr->smumgr_funcs = &tonga_smu_funcs; | |
| 62 | 74 | break; |
| 63 | 75 | case CHIP_FIJI: |
| 64 | − fiji_smum_init(smumgr); | |
| 76 | + smumgr->smumgr_funcs = &fiji_smu_funcs; | |
| 65 | 77 | break; |
| 66 | 78 | case CHIP_POLARIS11: |
| 67 | 79 | case CHIP_POLARIS10: |
| 68 | 80 | case CHIP_POLARIS12: |
| 69 | − polaris10_smum_init(smumgr); | |
| 81 | + smumgr->smumgr_funcs = &polaris10_smu_funcs; | |
| 70 | 82 | break; |
| 71 | 83 | default: |
| 72 | 84 | return -EINVAL; |
| @@ -80,13 +92,6 @@ int smum_init(struct amd_pp_init *pp_init, struct pp_instance *handle) · 7 unmodified lines | ||
| 80 | 92 | return 0; |
| 81 | 93 | } |
| 82 | 94 | |
| 83 | −int smum_fini(struct pp_smumgr *smumgr) | |
| 84 | −{ | |
| 85 | − kfree(smumgr->device); | |
| 86 | − kfree(smumgr); | |
| 87 | − return 0; | |
| 88 | −} | |
| 89 | − | |
| 90 | 95 | int smum_thermal_avfs_enable(struct pp_hwmgr *hwmgr, |
| 91 | 96 | void *input, void *output, void *storage, int result) |
| 92 | 97 | { |
| @@ -21,13 +21,13 @@ · 20 unmodified lines | ||
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | +#include "pp_debug.h" | |
| 24 | 25 | #include "tonga_smc.h" |
| 25 | 26 | #include "smu7_dyn_defaults.h" |
| 26 | 27 | |
| 27 | 28 | #include "smu7_hwmgr.h" |
| 28 | 29 | #include "hardwaremanager.h" |
| 29 | 30 | #include "ppatomctrl.h" |
| 30 | −#include "pp_debug.h" | |
| 31 | 31 | #include "cgs_common.h" |
| 32 | 32 | #include "atombios.h" |
| 33 | 33 | #include "tonga_smumgr.h" |
| @@ -656,7 +656,7 @@ int tonga_populate_all_graphic_levels(struct pp_hwmgr *hwmgr) · 622 unmodified lines | ||
| 656 | 656 | } |
| 657 | 657 | } else { |
| 658 | 658 | if (0 == data->dpm_level_enable_mask.pcie_dpm_enable_mask) |
| 659 | − printk(KERN_ERR "[ powerplay ] Pcie Dpm Enablemask is 0 !"); | |
| 659 | + pr_err("Pcie Dpm Enablemask is 0 !"); | |
| 660 | 660 | |
| 661 | 661 | while (data->dpm_level_enable_mask.pcie_dpm_enable_mask && |
| 662 | 662 | ((data->dpm_level_enable_mask.pcie_dpm_enable_mask & |
| @@ -1503,7 +1503,7 @@ static int tonga_populate_smc_boot_level(struct pp_hwmgr *hwmgr, · 840 unmodified lines | ||
| 1503 | 1503 | |
| 1504 | 1504 | if (result != 0) { |
| 1505 | 1505 | smu_data->smc_state_table.GraphicsBootLevel = 0; |
| 1506 | − printk(KERN_ERR "[powerplay] VBIOS did not find boot engine " | |
| 1506 | + pr_err("[powerplay] VBIOS did not find boot engine " | |
| 1507 | 1507 | "clock value in dependency table. " |
| 1508 | 1508 | "Using Graphics DPM level 0 !"); |
| 1509 | 1509 | result = 0; |
| @@ -1515,7 +1515,7 @@ static int tonga_populate_smc_boot_level(struct pp_hwmgr *hwmgr, · 5 unmodified lines | ||
| 1515 | 1515 | |
| 1516 | 1516 | if (result != 0) { |
| 1517 | 1517 | smu_data->smc_state_table.MemoryBootLevel = 0; |
| 1518 | − printk(KERN_ERR "[powerplay] VBIOS did not find boot " | |
| 1518 | + pr_err("[powerplay] VBIOS did not find boot " | |
| 1519 | 1519 | "engine clock value in dependency table." |
| 1520 | 1520 | "Using Memory DPM level 0 !"); |
| 1521 | 1521 | result = 0; |
| @@ -1739,7 +1739,7 @@ static int tonga_populate_vr_config(struct pp_hwmgr *hwmgr, · 217 unmodified lines | ||
| 1739 | 1739 | config = VR_SVI2_PLANE_2; |
| 1740 | 1740 | table->VRConfig |= config; |
| 1741 | 1741 | } else { |
| 1742 | − printk(KERN_ERR "[ powerplay ] VDDC and VDDGFX should " | |
| 1742 | + pr_err("VDDC and VDDGFX should " | |
| 1743 | 1743 | "be both on SVI2 control in splitted mode !\n"); |
| 1744 | 1744 | } |
| 1745 | 1745 | } else { |
| @@ -1752,7 +1752,7 @@ static int tonga_populate_vr_config(struct pp_hwmgr *hwmgr, · 6 unmodified lines | ||
| 1752 | 1752 | config = VR_SVI2_PLANE_1; |
| 1753 | 1753 | table->VRConfig |= config; |
| 1754 | 1754 | } else { |
| 1755 | − printk(KERN_ERR "[ powerplay ] VDDC should be on " | |
| 1755 | + pr_err("VDDC should be on " | |
| 1756 | 1756 | "SVI2 control in merged mode !\n"); |
| 1757 | 1757 | } |
| 1758 | 1758 | } |
| @@ -2657,7 +2657,7 @@ uint32_t tonga_get_offsetof(uint32_t type, uint32_t member) · 898 unmodified lines | ||
| 2657 | 2657 | return offsetof(SMU72_Discrete_DpmTable, LowSclkInterruptThreshold); |
| 2658 | 2658 | } |
| 2659 | 2659 | } |
| 2660 | − printk(KERN_WARNING "can't get the offset of type %x member %x\n", type, member); | |
| 2660 | + pr_warning("can't get the offset of type %x member %x\n", type, member); | |
| 2661 | 2661 | return 0; |
| 2662 | 2662 | } |
| 2663 | 2663 | |
| @@ -2681,7 +2681,7 @@ uint32_t tonga_get_mac_definition(uint32_t value) · 17 unmodified lines | ||
| 2681 | 2681 | case SMU_MAX_LEVELS_MVDD: |
| 2682 | 2682 | return SMU72_MAX_LEVELS_MVDD; |
| 2683 | 2683 | } |
| 2684 | − printk(KERN_WARNING "can't get the mac value %x\n", value); | |
| 2684 | + pr_warning("can't get the mac value %x\n", value); | |
| 2685 | 2685 | |
| 2686 | 2686 | return 0; |
| 2687 | 2687 | } |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | +#include "pp_debug.h" | |
| 23 | 24 | #include <linux/types.h> |
| 24 | 25 | #include <linux/kernel.h> |
| 25 | 26 | #include <linux/slab.h> |
| @@ -27,7 +28,6 @@ · 1 unmodified line | ||
| 27 | 28 | |
| 28 | 29 | #include "smumgr.h" |
| 29 | 30 | #include "tonga_smumgr.h" |
| 30 | −#include "pp_debug.h" | |
| 31 | 31 | #include "smu_ucode_xfer_vi.h" |
| 32 | 32 | #include "tonga_ppsmc.h" |
| 33 | 33 | #include "smu/smu_7_1_2_d.h" |
| @@ -84,7 +84,7 @@ static int tonga_start_in_protection_mode(struct pp_smumgr *smumgr) · 50 unmodified lines | ||
| 84 | 84 | /* Check pass/failed indicator */ |
| 85 | 85 | if (1 != SMUM_READ_VFPF_INDIRECT_FIELD(smumgr->device, |
| 86 | 86 | CGS_IND_REG__SMC, SMU_STATUS, SMU_PASS)) { |
| 87 | − printk(KERN_ERR "[ powerplay ] SMU Firmware start failed\n"); | |
| 87 | + pr_err("SMU Firmware start failed\n"); | |
| 88 | 88 | return -EINVAL; |
| 89 | 89 | } |
| 90 | 90 | |
| @@ -169,20 +169,25 @@ static int tonga_start_smu(struct pp_smumgr *smumgr) · 78 unmodified lines | ||
| 169 | 169 | */ |
| 170 | 170 | static int tonga_smu_init(struct pp_smumgr *smumgr) |
| 171 | 171 | { |
| 172 | − struct tonga_smumgr *smu_data = (struct tonga_smumgr *)(smumgr->backend); | |
| 172 | + struct tonga_smumgr *tonga_priv = NULL; | |
| 173 | + int i; | |
| 174 | + | |
| 175 | + tonga_priv = kzalloc(sizeof(struct tonga_smumgr), GFP_KERNEL); | |
| 176 | + if (tonga_priv == NULL) | |
| 177 | + return -ENOMEM; | |
| 173 | 178 | |
| 174 | − int i; | |
| 179 | + smumgr->backend = tonga_priv; | |
| 175 | 180 | |
| 176 | 181 | if (smu7_init(smumgr)) |
| 177 | 182 | return -EINVAL; |
| 178 | 183 | |
| 179 | 184 | for (i = 0; i < SMU72_MAX_LEVELS_GRAPHICS; i++) |
| 180 | − smu_data->activity_target[i] = 30; | |
| 185 | + tonga_priv->activity_target[i] = 30; | |
| 181 | 186 | |
| 182 | 187 | return 0; |
| 183 | 188 | } |
| 184 | 189 | |
| 185 | −static const struct pp_smumgr_func tonga_smu_funcs = { | |
| 190 | +const struct pp_smumgr_func tonga_smu_funcs = { | |
| 186 | 191 | .smu_init = &tonga_smu_init, |
| 187 | 192 | .smu_fini = &smu7_smu_fini, |
| 188 | 193 | .start_smu = &tonga_start_smu, |
| @@ -205,18 +210,3 @@ static const struct pp_smumgr_func tonga_smu_funcs = { · 16 unmodified lines | ||
| 205 | 210 | .initialize_mc_reg_table = tonga_initialize_mc_reg_table, |
| 206 | 211 | .is_dpm_running = tonga_is_dpm_running, |
| 207 | 212 | }; |
| 208 | − | |
| 209 | −int tonga_smum_init(struct pp_smumgr *smumgr) | |
| 210 | −{ | |
| 211 | − struct tonga_smumgr *tonga_smu = NULL; | |
| 212 | − | |
| 213 | − tonga_smu = kzalloc(sizeof(struct tonga_smumgr), GFP_KERNEL); | |
| 214 | − | |
| 215 | − if (tonga_smu == NULL) | |
| 216 | − return -ENOMEM; | |
| 217 | − | |
| 218 | − smumgr->backend = tonga_smu; | |
| 219 | − smumgr->smumgr_funcs = &tonga_smu_funcs; | |
| 220 | − | |
| 221 | − return 0; | |
| 222 | −} | |
| @@ -236,8 +236,6 @@ struct ttm_bo_driver ast_bo_driver = { · 235 unmodified lines | ||
| 236 | 236 | .verify_access = ast_bo_verify_access, |
| 237 | 237 | .io_mem_reserve = &ast_ttm_io_mem_reserve, |
| 238 | 238 | .io_mem_free = &ast_ttm_io_mem_free, |
| 239 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 240 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 241 | 239 | }; |
| 242 | 240 | |
| 243 | 241 | int ast_mm_init(struct ast_private *ast) |
| @@ -205,8 +205,6 @@ struct ttm_bo_driver bochs_bo_driver = { · 204 unmodified lines | ||
| 205 | 205 | .verify_access = bochs_bo_verify_access, |
| 206 | 206 | .io_mem_reserve = &bochs_ttm_io_mem_reserve, |
| 207 | 207 | .io_mem_free = &bochs_ttm_io_mem_free, |
| 208 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 209 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 210 | 208 | }; |
| 211 | 209 | |
| 212 | 210 | int bochs_mm_init(struct bochs_device *bochs) |
| @@ -236,8 +236,6 @@ struct ttm_bo_driver cirrus_bo_driver = { · 235 unmodified lines | ||
| 236 | 236 | .verify_access = cirrus_bo_verify_access, |
| 237 | 237 | .io_mem_reserve = &cirrus_ttm_io_mem_reserve, |
| 238 | 238 | .io_mem_free = &cirrus_ttm_io_mem_free, |
| 239 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 240 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 241 | 239 | }; |
| 242 | 240 | |
| 243 | 241 | int cirrus_mm_init(struct cirrus_device *cirrus) |
| @@ -243,8 +243,6 @@ struct ttm_bo_driver hibmc_bo_driver = { · 242 unmodified lines | ||
| 243 | 243 | .verify_access = hibmc_bo_verify_access, |
| 244 | 244 | .io_mem_reserve = &hibmc_ttm_io_mem_reserve, |
| 245 | 245 | .io_mem_free = NULL, |
| 246 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 247 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 248 | 246 | }; |
| 249 | 247 | |
| 250 | 248 | int hibmc_mm_init(struct hibmc_drm_private *hibmc) |
| @@ -236,8 +236,6 @@ struct ttm_bo_driver mgag200_bo_driver = { · 235 unmodified lines | ||
| 236 | 236 | .verify_access = mgag200_bo_verify_access, |
| 237 | 237 | .io_mem_reserve = &mgag200_ttm_io_mem_reserve, |
| 238 | 238 | .io_mem_free = &mgag200_ttm_io_mem_free, |
| 239 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 240 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 241 | 239 | }; |
| 242 | 240 | |
| 243 | 241 | int mgag200_mm_init(struct mga_device *mdev) |
| @@ -1194,7 +1194,8 @@ out: · 1193 unmodified lines | ||
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | static void |
| 1197 | −nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) | |
| 1197 | +nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, bool evict, | |
| 1198 | + struct ttm_mem_reg *new_mem) | |
| 1198 | 1199 | { |
| 1199 | 1200 | struct nouveau_bo *nvbo = nouveau_bo(bo); |
| 1200 | 1201 | struct nvkm_vma *vma; |
| @@ -1570,8 +1571,6 @@ struct ttm_bo_driver nouveau_bo_driver = { · 369 unmodified lines | ||
| 1570 | 1571 | .fault_reserve_notify = &nouveau_ttm_fault_reserve_notify, |
| 1571 | 1572 | .io_mem_reserve = &nouveau_ttm_io_mem_reserve, |
| 1572 | 1573 | .io_mem_free = &nouveau_ttm_io_mem_free, |
| 1573 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 1574 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 1575 | 1574 | }; |
| 1576 | 1575 | |
| 1577 | 1576 | struct nvkm_vma * |
| @@ -366,6 +366,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, · 365 unmodified lines | ||
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | static void qxl_bo_move_notify(struct ttm_buffer_object *bo, |
| 369 | + bool evict, | |
| 369 | 370 | struct ttm_mem_reg *new_mem) |
| 370 | 371 | { |
| 371 | 372 | struct qxl_bo *qbo; |
| @@ -393,8 +394,6 @@ static struct ttm_bo_driver qxl_bo_driver = { · 21 unmodified lines | ||
| 393 | 394 | .io_mem_reserve = &qxl_ttm_io_mem_reserve, |
| 394 | 395 | .io_mem_free = &qxl_ttm_io_mem_free, |
| 395 | 396 | .move_notify = &qxl_bo_move_notify, |
| 396 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 397 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 398 | 397 | }; |
| 399 | 398 | |
| 400 | 399 | int qxl_ttm_init(struct qxl_device *qdev) |
| @@ -596,52 +596,58 @@ static bool radeon_read_disabled_bios(struct radeon_device *rdev) · 595 unmodified lines | ||
| 596 | 596 | #ifdef CONFIG_ACPI |
| 597 | 597 | static bool radeon_acpi_vfct_bios(struct radeon_device *rdev) |
| 598 | 598 | { |
| 599 | − bool ret = false; | |
| 600 | 599 | struct acpi_table_header *hdr; |
| 601 | 600 | acpi_size tbl_size; |
| 602 | 601 | UEFI_ACPI_VFCT *vfct; |
| 603 | − GOP_VBIOS_CONTENT *vbios; | |
| 604 | − VFCT_IMAGE_HEADER *vhdr; | |
| 602 | + unsigned offset; | |
| 605 | 603 | |
| 606 | 604 | if (!ACPI_SUCCESS(acpi_get_table("VFCT", 1, &hdr))) |
| 607 | 605 | return false; |
| 608 | 606 | tbl_size = hdr->length; |
| 609 | 607 | if (tbl_size < sizeof(UEFI_ACPI_VFCT)) { |
| 610 | 608 | DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n"); |
| 611 | − goto out_unmap; | |
| 609 | + return false; | |
| 612 | 610 | } |
| 613 | 611 | |
| 614 | 612 | vfct = (UEFI_ACPI_VFCT *)hdr; |
| 615 | − if (vfct->VBIOSImageOffset + sizeof(VFCT_IMAGE_HEADER) > tbl_size) { | |
| 616 | − DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n"); | |
| 617 | − goto out_unmap; | |
| 618 | − } | |
| 613 | + offset = vfct->VBIOSImageOffset; | |
| 619 | 614 | |
| 620 | − vbios = (GOP_VBIOS_CONTENT *)((char *)hdr + vfct->VBIOSImageOffset); | |
| 621 | − vhdr = &vbios->VbiosHeader; | |
| 622 | − DRM_INFO("ACPI VFCT contains a BIOS for %02x:%02x.%d %04x:%04x, size %d\n", | |
| 623 | − vhdr->PCIBus, vhdr->PCIDevice, vhdr->PCIFunction, | |
| 624 | − vhdr->VendorID, vhdr->DeviceID, vhdr->ImageLength); | |
| 625 | − | |
| 626 | − if (vhdr->PCIBus != rdev->pdev->bus->number || | |
| 627 | − vhdr->PCIDevice != PCI_SLOT(rdev->pdev->devfn) || | |
| 628 | − vhdr->PCIFunction != PCI_FUNC(rdev->pdev->devfn) || | |
| 629 | − vhdr->VendorID != rdev->pdev->vendor || | |
| 630 | − vhdr->DeviceID != rdev->pdev->device) { | |
| 631 | − DRM_INFO("ACPI VFCT table is not for this card\n"); | |
| 632 | − goto out_unmap; | |
| 633 | − } | |
| 615 | + while (offset < tbl_size) { | |
| 616 | + GOP_VBIOS_CONTENT *vbios = (GOP_VBIOS_CONTENT *)((char *)hdr + offset); | |
| 617 | + VFCT_IMAGE_HEADER *vhdr = &vbios->VbiosHeader; | |
| 634 | 618 | |
| 635 | − if (vfct->VBIOSImageOffset + sizeof(VFCT_IMAGE_HEADER) + vhdr->ImageLength > tbl_size) { | |
| 636 | − DRM_ERROR("ACPI VFCT image truncated\n"); | |
| 637 | − goto out_unmap; | |
| 638 | − } | |
| 619 | + offset += sizeof(VFCT_IMAGE_HEADER); | |
| 620 | + if (offset > tbl_size) { | |
| 621 | + DRM_ERROR("ACPI VFCT image header truncated\n"); | |
| 622 | + return false; | |
| 623 | + } | |
| 639 | 624 | |
| 640 | − rdev->bios = kmemdup(&vbios->VbiosContent, vhdr->ImageLength, GFP_KERNEL); | |
| 641 | − ret = !!rdev->bios; | |
| 625 | + offset += vhdr->ImageLength; | |
| 626 | + if (offset > tbl_size) { | |
| 627 | + DRM_ERROR("ACPI VFCT image truncated\n"); | |
| 628 | + return false; | |
| 629 | + } | |
| 630 | + | |
| 631 | + if (vhdr->ImageLength && | |
| 632 | + vhdr->PCIBus == rdev->pdev->bus->number && | |
| 633 | + vhdr->PCIDevice == PCI_SLOT(rdev->pdev->devfn) && | |
| 634 | + vhdr->PCIFunction == PCI_FUNC(rdev->pdev->devfn) && | |
| 635 | + vhdr->VendorID == rdev->pdev->vendor && | |
| 636 | + vhdr->DeviceID == rdev->pdev->device) { | |
| 637 | + rdev->bios = kmemdup(&vbios->VbiosContent, | |
| 638 | + vhdr->ImageLength, | |
| 639 | + GFP_KERNEL); | |
| 640 | + | |
| 641 | + if (!rdev->bios) { | |
| 642 | + kfree(rdev->bios); | |
| 643 | + return false; | |
| 644 | + } | |
| 645 | + return true; | |
| 646 | + } | |
| 647 | + } | |
| 642 | 648 | |
| 643 | −out_unmap: | |
| 644 | − return ret; | |
| 649 | + DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n"); | |
| 650 | + return false; | |
| 645 | 651 | } |
| 646 | 652 | #else |
| 647 | 653 | static inline bool radeon_acpi_vfct_bios(struct radeon_device *rdev) |
| @@ -765,6 +765,7 @@ int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved, · 764 unmodified lines | ||
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | void radeon_bo_move_notify(struct ttm_buffer_object *bo, |
| 768 | + bool evict, | |
| 768 | 769 | struct ttm_mem_reg *new_mem) |
| 769 | 770 | { |
| 770 | 771 | struct radeon_bo *rbo; |
| @@ -150,6 +150,7 @@ extern void radeon_bo_get_tiling_flags(struct radeon_bo *bo, · 149 unmodified lines | ||
| 150 | 150 | extern int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved, |
| 151 | 151 | bool force_drop); |
| 152 | 152 | extern void radeon_bo_move_notify(struct ttm_buffer_object *bo, |
| 153 | + bool evict, | |
| 153 | 154 | struct ttm_mem_reg *new_mem); |
| 154 | 155 | extern int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo); |
| 155 | 156 | extern int radeon_bo_get_surface_reg(struct radeon_bo *bo); |
| @@ -502,6 +502,8 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_ · 501 unmodified lines | ||
| 502 | 502 | mem->bus.addr = |
| 503 | 503 | ioremap_nocache(mem->bus.base + mem->bus.offset, |
| 504 | 504 | mem->bus.size); |
| 505 | + if (!mem->bus.addr) | |
| 506 | + return -ENOMEM; | |
| 505 | 507 | |
| 506 | 508 | /* |
| 507 | 509 | * Alpha: Use just the bus offset plus |
| @@ -871,8 +873,6 @@ static struct ttm_bo_driver radeon_bo_driver = { · 363 unmodified lines | ||
| 871 | 873 | .fault_reserve_notify = &radeon_bo_fault_reserve_notify, |
| 872 | 874 | .io_mem_reserve = &radeon_ttm_io_mem_reserve, |
| 873 | 875 | .io_mem_free = &radeon_ttm_io_mem_free, |
| 874 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 875 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 876 | 876 | }; |
| 877 | 877 | |
| 878 | 878 | int radeon_ttm_init(struct radeon_device *rdev) |
| @@ -2912,29 +2912,6 @@ static int si_init_smc_spll_table(struct radeon_device *rdev) · 2911 unmodified lines | ||
| 2912 | 2912 | return ret; |
| 2913 | 2913 | } |
| 2914 | 2914 | |
| 2915 | −struct si_dpm_quirk { | |
| 2916 | − u32 chip_vendor; | |
| 2917 | − u32 chip_device; | |
| 2918 | − u32 subsys_vendor; | |
| 2919 | − u32 subsys_device; | |
| 2920 | − u32 max_sclk; | |
| 2921 | − u32 max_mclk; | |
| 2922 | −}; | |
| 2923 | − | |
| 2924 | −/* cards with dpm stability problems */ | |
| 2925 | −static struct si_dpm_quirk si_dpm_quirk_list[] = { | |
| 2926 | − /* PITCAIRN - https://bugs.freedesktop.org/show_bug.cgi?id=76490 */ | |
| 2927 | − { PCI_VENDOR_ID_ATI, 0x6810, 0x1462, 0x3036, 0, 120000 }, | |
| 2928 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0xe271, 0, 120000 }, | |
| 2929 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0x2015, 0, 120000 }, | |
| 2930 | − { PCI_VENDOR_ID_ATI, 0x6810, 0x174b, 0xe271, 85000, 90000 }, | |
| 2931 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x1462, 0x2015, 0, 120000 }, | |
| 2932 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x1043, 0x2015, 0, 120000 }, | |
| 2933 | − { PCI_VENDOR_ID_ATI, 0x6811, 0x148c, 0x2015, 0, 120000 }, | |
| 2934 | − { PCI_VENDOR_ID_ATI, 0x6810, 0x1682, 0x9275, 0, 120000 }, | |
| 2935 | − { 0, 0, 0, 0 }, | |
| 2936 | −}; | |
| 2937 | − | |
| 2938 | 2915 | static u16 si_get_lower_of_leakage_and_vce_voltage(struct radeon_device *rdev, |
| 2939 | 2916 | u16 vce_voltage) |
| 2940 | 2917 | { |
| @@ -2997,18 +2974,8 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev, · 56 unmodified lines | ||
| 2997 | 2974 | u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc; |
| 2998 | 2975 | u32 max_sclk = 0, max_mclk = 0; |
| 2999 | 2976 | int i; |
| 3000 | − struct si_dpm_quirk *p = si_dpm_quirk_list; | |
| 3001 | 2977 | |
| 3002 | − /* limit all SI kickers */ | |
| 3003 | − if (rdev->family == CHIP_PITCAIRN) { | |
| 3004 | − if ((rdev->pdev->revision == 0x81) || | |
| 3005 | − (rdev->pdev->device == 0x6810) || | |
| 3006 | − (rdev->pdev->device == 0x6811) || | |
| 3007 | − (rdev->pdev->device == 0x6816) || | |
| 3008 | − (rdev->pdev->device == 0x6817) || | |
| 3009 | − (rdev->pdev->device == 0x6806)) | |
| 3010 | − max_mclk = 120000; | |
| 3011 | − } else if (rdev->family == CHIP_HAINAN) { | |
| 2978 | + if (rdev->family == CHIP_HAINAN) { | |
| 3012 | 2979 | if ((rdev->pdev->revision == 0x81) || |
| 3013 | 2980 | (rdev->pdev->revision == 0x83) || |
| 3014 | 2981 | (rdev->pdev->revision == 0xC3) || |
| @@ -3018,18 +2985,6 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev, · 3 unmodified lines | ||
| 3018 | 2985 | max_sclk = 75000; |
| 3019 | 2986 | } |
| 3020 | 2987 | } |
| 3021 | − /* Apply dpm quirks */ | |
| 3022 | − while (p && p->chip_device != 0) { | |
| 3023 | − if (rdev->pdev->vendor == p->chip_vendor && | |
| 3024 | − rdev->pdev->device == p->chip_device && | |
| 3025 | − rdev->pdev->subsystem_vendor == p->subsys_vendor && | |
| 3026 | − rdev->pdev->subsystem_device == p->subsys_device) { | |
| 3027 | − max_sclk = p->max_sclk; | |
| 3028 | − max_mclk = p->max_mclk; | |
| 3029 | − break; | |
| 3030 | − } | |
| 3031 | − ++p; | |
| 3032 | − } | |
| 3033 | 2988 | |
| 3034 | 2989 | if (rps->vce_active) { |
| 3035 | 2990 | rps->evclk = rdev->pm.dpm.vce_states[rdev->pm.dpm.vce_level].evclk; |
| @@ -163,6 +163,7 @@ static void ttm_bo_release_list(struct kref *list_kref) · 162 unmodified lines | ||
| 163 | 163 | void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) |
| 164 | 164 | { |
| 165 | 165 | struct ttm_bo_device *bdev = bo->bdev; |
| 166 | + struct ttm_mem_type_manager *man; | |
| 166 | 167 | |
| 167 | 168 | lockdep_assert_held(&bo->resv->lock.base); |
| 168 | 169 | |
| @@ -170,11 +171,13 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) · 1 unmodified line | ||
| 170 | 171 | |
| 171 | 172 | BUG_ON(!list_empty(&bo->lru)); |
| 172 | 173 | |
| 173 | − list_add(&bo->lru, bdev->driver->lru_tail(bo)); | |
| 174 | + man = &bdev->man[bo->mem.mem_type]; | |
| 175 | + list_add_tail(&bo->lru, &man->lru[bo->priority]); | |
| 174 | 176 | kref_get(&bo->list_kref); |
| 175 | 177 | |
| 176 | 178 | if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) { |
| 177 | − list_add(&bo->swap, bdev->driver->swap_lru_tail(bo)); | |
| 179 | + list_add_tail(&bo->swap, | |
| 180 | + &bo->glob->swap_lru[bo->priority]); | |
| 178 | 181 | kref_get(&bo->list_kref); |
| 179 | 182 | } |
| 180 | 183 | } |
| @@ -183,12 +186,8 @@ EXPORT_SYMBOL(ttm_bo_add_to_lru); · 2 unmodified lines | ||
| 183 | 186 | |
| 184 | 187 | int ttm_bo_del_from_lru(struct ttm_buffer_object *bo) |
| 185 | 188 | { |
| 186 | − struct ttm_bo_device *bdev = bo->bdev; | |
| 187 | 189 | int put_count = 0; |
| 188 | 190 | |
| 189 | − if (bdev->driver->lru_removal) | |
| 190 | − bdev->driver->lru_removal(bo); | |
| 191 | − | |
| 192 | 191 | if (!list_empty(&bo->swap)) { |
| 193 | 192 | list_del_init(&bo->swap); |
| 194 | 193 | ++put_count; |
| @@ -198,6 +197,11 @@ int ttm_bo_del_from_lru(struct ttm_buffer_object *bo) · 3 unmodified lines | ||
| 198 | 197 | ++put_count; |
| 199 | 198 | } |
| 200 | 199 | |
| 200 | + /* | |
| 201 | + * TODO: Add a driver hook to delete from | |
| 202 | + * driver-specific LRU's here. | |
| 203 | + */ | |
| 204 | + | |
| 201 | 205 | return put_count; |
| 202 | 206 | } |
| 203 | 207 | |
| @@ -226,32 +230,16 @@ EXPORT_SYMBOL(ttm_bo_del_sub_from_lru); · 22 unmodified lines | ||
| 226 | 230 | |
| 227 | 231 | void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) |
| 228 | 232 | { |
| 229 | − struct ttm_bo_device *bdev = bo->bdev; | |
| 230 | 233 | int put_count = 0; |
| 231 | 234 | |
| 232 | 235 | lockdep_assert_held(&bo->resv->lock.base); |
| 233 | 236 | |
| 234 | − if (bdev->driver->lru_removal) | |
| 235 | − bdev->driver->lru_removal(bo); | |
| 236 | − | |
| 237 | 237 | put_count = ttm_bo_del_from_lru(bo); |
| 238 | 238 | ttm_bo_list_ref_sub(bo, put_count, true); |
| 239 | 239 | ttm_bo_add_to_lru(bo); |
| 240 | 240 | } |
| 241 | 241 | EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); |
| 242 | 242 | |
| 243 | −struct list_head *ttm_bo_default_lru_tail(struct ttm_buffer_object *bo) | |
| 244 | −{ | |
| 245 | − return bo->bdev->man[bo->mem.mem_type].lru.prev; | |
| 246 | −} | |
| 247 | −EXPORT_SYMBOL(ttm_bo_default_lru_tail); | |
| 248 | − | |
| 249 | −struct list_head *ttm_bo_default_swap_lru_tail(struct ttm_buffer_object *bo) | |
| 250 | −{ | |
| 251 | − return bo->glob->swap_lru.prev; | |
| 252 | −} | |
| 253 | −EXPORT_SYMBOL(ttm_bo_default_swap_lru_tail); | |
| 254 | − | |
| 255 | 243 | /* |
| 256 | 244 | * Call bo->mutex locked. |
| 257 | 245 | */ |
| @@ -342,7 +330,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, · 84 unmodified lines | ||
| 342 | 330 | |
| 343 | 331 | if (bo->mem.mem_type == TTM_PL_SYSTEM) { |
| 344 | 332 | if (bdev->driver->move_notify) |
| 345 | − bdev->driver->move_notify(bo, mem); | |
| 333 | + bdev->driver->move_notify(bo, evict, mem); | |
| 346 | 334 | bo->mem = *mem; |
| 347 | 335 | mem->mm_node = NULL; |
| 348 | 336 | goto moved; |
| @@ -350,7 +338,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, · 1 unmodified line | ||
| 350 | 338 | } |
| 351 | 339 | |
| 352 | 340 | if (bdev->driver->move_notify) |
| 353 | − bdev->driver->move_notify(bo, mem); | |
| 341 | + bdev->driver->move_notify(bo, evict, mem); | |
| 354 | 342 | |
| 355 | 343 | if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) && |
| 356 | 344 | !(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) |
| @@ -366,7 +354,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, · 9 unmodified lines | ||
| 366 | 354 | struct ttm_mem_reg tmp_mem = *mem; |
| 367 | 355 | *mem = bo->mem; |
| 368 | 356 | bo->mem = tmp_mem; |
| 369 | − bdev->driver->move_notify(bo, mem); | |
| 357 | + bdev->driver->move_notify(bo, false, mem); | |
| 370 | 358 | bo->mem = *mem; |
| 371 | 359 | *mem = tmp_mem; |
| 372 | 360 | } |
| @@ -414,7 +402,7 @@ out_err: · 41 unmodified lines | ||
| 414 | 402 | static void ttm_bo_cleanup_memtype_use(struct ttm_buffer_object *bo) |
| 415 | 403 | { |
| 416 | 404 | if (bo->bdev->driver->move_notify) |
| 417 | − bo->bdev->driver->move_notify(bo, NULL); | |
| 405 | + bo->bdev->driver->move_notify(bo, false, NULL); | |
| 418 | 406 | |
| 419 | 407 | ttm_tt_destroy(bo->ttm); |
| 420 | 408 | bo->ttm = NULL; |
| @@ -741,20 +729,27 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, · 320 unmodified lines | ||
| 741 | 729 | struct ttm_mem_type_manager *man = &bdev->man[mem_type]; |
| 742 | 730 | struct ttm_buffer_object *bo; |
| 743 | 731 | int ret = -EBUSY, put_count; |
| 732 | + unsigned i; | |
| 744 | 733 | |
| 745 | 734 | spin_lock(&glob->lru_lock); |
| 746 | − list_for_each_entry(bo, &man->lru, lru) { | |
| 747 | − ret = __ttm_bo_reserve(bo, false, true, NULL); | |
| 748 | − if (ret) | |
| 749 | − continue; | |
| 735 | + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { | |
| 736 | + list_for_each_entry(bo, &man->lru[i], lru) { | |
| 737 | + ret = __ttm_bo_reserve(bo, false, true, NULL); | |
| 738 | + if (ret) | |
| 739 | + continue; | |
| 750 | 740 | |
| 751 | − if (place && !bdev->driver->eviction_valuable(bo, place)) { | |
| 752 | − __ttm_bo_unreserve(bo); | |
| 753 | − ret = -EBUSY; | |
| 754 | − continue; | |
| 741 | + if (place && !bdev->driver->eviction_valuable(bo, | |
| 742 | + place)) { | |
| 743 | + __ttm_bo_unreserve(bo); | |
| 744 | + ret = -EBUSY; | |
| 745 | + continue; | |
| 746 | + } | |
| 747 | + | |
| 748 | + break; | |
| 755 | 749 | } |
| 756 | 750 | |
| 757 | − break; | |
| 751 | + if (!ret) | |
| 752 | + break; | |
| 758 | 753 | } |
| 759 | 754 | |
| 760 | 755 | if (ret) { |
| @@ -1197,6 +1192,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev, · 436 unmodified lines | ||
| 1197 | 1192 | } |
| 1198 | 1193 | atomic_inc(&bo->glob->bo_count); |
| 1199 | 1194 | drm_vma_node_reset(&bo->vma_node); |
| 1195 | + bo->priority = 0; | |
| 1200 | 1196 | |
| 1201 | 1197 | /* |
| 1202 | 1198 | * For ttm_bo_type_device buffers, allocate |
| @@ -1291,29 +1287,27 @@ int ttm_bo_create(struct ttm_bo_device *bdev, · 88 unmodified lines | ||
| 1291 | 1287 | EXPORT_SYMBOL(ttm_bo_create); |
| 1292 | 1288 | |
| 1293 | 1289 | static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, |
| 1294 | − unsigned mem_type, bool allow_errors) | |
| 1290 | + unsigned mem_type) | |
| 1295 | 1291 | { |
| 1296 | 1292 | struct ttm_mem_type_manager *man = &bdev->man[mem_type]; |
| 1297 | 1293 | struct ttm_bo_global *glob = bdev->glob; |
| 1298 | 1294 | struct dma_fence *fence; |
| 1299 | 1295 | int ret; |
| 1296 | + unsigned i; | |
| 1300 | 1297 | |
| 1301 | 1298 | /* |
| 1302 | 1299 | * Can't use standard list traversal since we're unlocking. |
| 1303 | 1300 | */ |
| 1304 | 1301 | |
| 1305 | 1302 | spin_lock(&glob->lru_lock); |
| 1306 | − while (!list_empty(&man->lru)) { | |
| 1307 | − spin_unlock(&glob->lru_lock); | |
| 1308 | − ret = ttm_mem_evict_first(bdev, mem_type, NULL, false, false); | |
| 1309 | − if (ret) { | |
| 1310 | − if (allow_errors) { | |
| 1303 | + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { | |
| 1304 | + while (!list_empty(&man->lru[i])) { | |
| 1305 | + spin_unlock(&glob->lru_lock); | |
| 1306 | + ret = ttm_mem_evict_first(bdev, mem_type, NULL, false, false); | |
| 1307 | + if (ret) | |
| 1311 | 1308 | return ret; |
| 1312 | − } else { | |
| 1313 | − pr_err("Cleanup eviction failed\n"); | |
| 1314 | − } | |
| 1309 | + spin_lock(&glob->lru_lock); | |
| 1315 | 1310 | } |
| 1316 | − spin_lock(&glob->lru_lock); | |
| 1317 | 1311 | } |
| 1318 | 1312 | spin_unlock(&glob->lru_lock); |
| 1319 | 1313 | |
| @@ -1324,13 +1318,8 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, · 4 unmodified lines | ||
| 1324 | 1318 | if (fence) { |
| 1325 | 1319 | ret = dma_fence_wait(fence, false); |
| 1326 | 1320 | dma_fence_put(fence); |
| 1327 | − if (ret) { | |
| 1328 | − if (allow_errors) { | |
| 1329 | − return ret; | |
| 1330 | − } else { | |
| 1331 | − pr_err("Cleanup eviction failed\n"); | |
| 1332 | − } | |
| 1333 | − } | |
| 1321 | + if (ret) | |
| 1322 | + return ret; | |
| 1334 | 1323 | } |
| 1335 | 1324 | |
| 1336 | 1325 | return 0; |
| @@ -1359,7 +1348,11 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) · 22 unmodified lines | ||
| 1359 | 1348 | |
| 1360 | 1349 | ret = 0; |
| 1361 | 1350 | if (mem_type > 0) { |
| 1362 | − ttm_bo_force_list_clean(bdev, mem_type, false); | |
| 1351 | + ret = ttm_bo_force_list_clean(bdev, mem_type); | |
| 1352 | + if (ret) { | |
| 1353 | + pr_err("Cleanup eviction failed\n"); | |
| 1354 | + return ret; | |
| 1355 | + } | |
| 1363 | 1356 | |
| 1364 | 1357 | ret = (*man->func->takedown)(man); |
| 1365 | 1358 | } |
| @@ -1382,7 +1375,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) · 16 unmodified lines | ||
| 1382 | 1375 | return 0; |
| 1383 | 1376 | } |
| 1384 | 1377 | |
| 1385 | − return ttm_bo_force_list_clean(bdev, mem_type, true); | |
| 1378 | + return ttm_bo_force_list_clean(bdev, mem_type); | |
| 1386 | 1379 | } |
| 1387 | 1380 | EXPORT_SYMBOL(ttm_bo_evict_mm); |
| 1388 | 1381 | |
| @@ -1391,6 +1384,7 @@ int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, · 2 unmodified lines | ||
| 1391 | 1384 | { |
| 1392 | 1385 | int ret = -EINVAL; |
| 1393 | 1386 | struct ttm_mem_type_manager *man; |
| 1387 | + unsigned i; | |
| 1394 | 1388 | |
| 1395 | 1389 | BUG_ON(type >= TTM_NUM_MEM_TYPES); |
| 1396 | 1390 | man = &bdev->man[type]; |
| @@ -1416,7 +1410,8 @@ int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, · 19 unmodified lines | ||
| 1416 | 1410 | man->use_type = true; |
| 1417 | 1411 | man->size = p_size; |
| 1418 | 1412 | |
| 1419 | − INIT_LIST_HEAD(&man->lru); | |
| 1413 | + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) | |
| 1414 | + INIT_LIST_HEAD(&man->lru[i]); | |
| 1420 | 1415 | man->move = NULL; |
| 1421 | 1416 | |
| 1422 | 1417 | return 0; |
| @@ -1448,6 +1443,7 @@ int ttm_bo_global_init(struct drm_global_reference *ref) · 25 unmodified lines | ||
| 1448 | 1443 | container_of(ref, struct ttm_bo_global_ref, ref); |
| 1449 | 1444 | struct ttm_bo_global *glob = ref->object; |
| 1450 | 1445 | int ret; |
| 1446 | + unsigned i; | |
| 1451 | 1447 | |
| 1452 | 1448 | mutex_init(&glob->device_list_mutex); |
| 1453 | 1449 | spin_lock_init(&glob->lru_lock); |
| @@ -1459,7 +1455,8 @@ int ttm_bo_global_init(struct drm_global_reference *ref) · 5 unmodified lines | ||
| 1459 | 1455 | goto out_no_drp; |
| 1460 | 1456 | } |
| 1461 | 1457 | |
| 1462 | − INIT_LIST_HEAD(&glob->swap_lru); | |
| 1458 | + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) | |
| 1459 | + INIT_LIST_HEAD(&glob->swap_lru[i]); | |
| 1463 | 1460 | INIT_LIST_HEAD(&glob->device_list); |
| 1464 | 1461 | |
| 1465 | 1462 | ttm_mem_init_shrink(&glob->shrink, ttm_bo_swapout); |
| @@ -1518,8 +1515,9 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) · 52 unmodified lines | ||
| 1518 | 1515 | if (list_empty(&bdev->ddestroy)) |
| 1519 | 1516 | TTM_DEBUG("Delayed destroy list was clean\n"); |
| 1520 | 1517 | |
| 1521 | − if (list_empty(&bdev->man[0].lru)) | |
| 1522 | − TTM_DEBUG("Swap list was clean\n"); | |
| 1518 | + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) | |
| 1519 | + if (list_empty(&bdev->man[0].lru[0])) | |
| 1520 | + TTM_DEBUG("Swap list %d was clean\n", i); | |
| 1523 | 1521 | spin_unlock(&glob->lru_lock); |
| 1524 | 1522 | |
| 1525 | 1523 | drm_vma_offset_manager_destroy(&bdev->vma_manager); |
| @@ -1670,10 +1668,15 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) · 144 unmodified lines | ||
| 1670 | 1668 | struct ttm_buffer_object *bo; |
| 1671 | 1669 | int ret = -EBUSY; |
| 1672 | 1670 | int put_count; |
| 1671 | + unsigned i; | |
| 1673 | 1672 | |
| 1674 | 1673 | spin_lock(&glob->lru_lock); |
| 1675 | − list_for_each_entry(bo, &glob->swap_lru, swap) { | |
| 1676 | − ret = __ttm_bo_reserve(bo, false, true, NULL); | |
| 1674 | + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { | |
| 1675 | + list_for_each_entry(bo, &glob->swap_lru[i], swap) { | |
| 1676 | + ret = __ttm_bo_reserve(bo, false, true, NULL); | |
| 1677 | + if (!ret) | |
| 1678 | + break; | |
| 1679 | + } | |
| 1677 | 1680 | if (!ret) |
| 1678 | 1681 | break; |
| 1679 | 1682 | } |
| @@ -386,6 +386,7 @@ static int virtio_gpu_bo_move(struct ttm_buffer_object *bo, · 385 unmodified lines | ||
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | static void virtio_gpu_bo_move_notify(struct ttm_buffer_object *tbo, |
| 389 | + bool evict, | |
| 389 | 390 | struct ttm_mem_reg *new_mem) |
| 390 | 391 | { |
| 391 | 392 | struct virtio_gpu_object *bo; |
| @@ -433,8 +434,6 @@ static struct ttm_bo_driver virtio_gpu_bo_driver = { · 41 unmodified lines | ||
| 433 | 434 | .io_mem_free = &virtio_gpu_ttm_io_mem_free, |
| 434 | 435 | .move_notify = &virtio_gpu_bo_move_notify, |
| 435 | 436 | .swap_notify = &virtio_gpu_bo_swap_notify, |
| 436 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 437 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 438 | 437 | }; |
| 439 | 438 | |
| 440 | 439 | int virtio_gpu_ttm_init(struct virtio_gpu_device *vgdev) |
| @@ -825,6 +825,7 @@ static int vmw_ttm_fault_reserve_notify(struct ttm_buffer_object *bo) · 824 unmodified lines | ||
| 825 | 825 | * (currently only resources). |
| 826 | 826 | */ |
| 827 | 827 | static void vmw_move_notify(struct ttm_buffer_object *bo, |
| 828 | + bool evict, | |
| 828 | 829 | struct ttm_mem_reg *mem) |
| 829 | 830 | { |
| 830 | 831 | vmw_resource_move_notify(bo, mem); |
| @@ -858,6 +859,4 @@ struct ttm_bo_driver vmw_bo_driver = { · 27 unmodified lines | ||
| 858 | 859 | .fault_reserve_notify = &vmw_ttm_fault_reserve_notify, |
| 859 | 860 | .io_mem_reserve = &vmw_ttm_io_mem_reserve, |
| 860 | 861 | .io_mem_free = &vmw_ttm_io_mem_free, |
| 861 | − .lru_tail = &ttm_bo_default_lru_tail, | |
| 862 | − .swap_lru_tail = &ttm_bo_default_swap_lru_tail, | |
| 863 | 862 | }; |
| @@ -215,6 +215,8 @@ struct ttm_buffer_object { · 214 unmodified lines | ||
| 215 | 215 | |
| 216 | 216 | struct drm_vma_offset_node vma_node; |
| 217 | 217 | |
| 218 | + unsigned priority; | |
| 219 | + | |
| 218 | 220 | /** |
| 219 | 221 | * Special members that are protected by the reserve lock |
| 220 | 222 | * and the bo::lock when written to. Can be read with |
| @@ -42,6 +42,8 @@ · 41 unmodified lines | ||
| 42 | 42 | #include <linux/spinlock.h> |
| 43 | 43 | #include <linux/reservation.h> |
| 44 | 44 | |
| 45 | +#define TTM_MAX_BO_PRIORITY 16 | |
| 46 | + | |
| 45 | 47 | struct ttm_backend_func { |
| 46 | 48 | /** |
| 47 | 49 | * struct ttm_backend_func member bind |
| @@ -298,7 +300,7 @@ struct ttm_mem_type_manager { · 250 unmodified lines | ||
| 298 | 300 | * Protected by the global->lru_lock. |
| 299 | 301 | */ |
| 300 | 302 | |
| 301 | − struct list_head lru; | |
| 303 | + struct list_head lru[TTM_MAX_BO_PRIORITY]; | |
| 302 | 304 | |
| 303 | 305 | /* |
| 304 | 306 | * Protected by @move_lock. |
| @@ -431,9 +433,15 @@ struct ttm_bo_driver { · 126 unmodified lines | ||
| 431 | 433 | int (*verify_access)(struct ttm_buffer_object *bo, |
| 432 | 434 | struct file *filp); |
| 433 | 435 | |
| 434 | − /* hook to notify driver about a driver move so it | |
| 435 | − * can do tiling things */ | |
| 436 | + /** | |
| 437 | + * Hook to notify driver about a driver move so it | |
| 438 | + * can do tiling things and book-keeping. | |
| 439 | + * | |
| 440 | + * @evict: whether this move is evicting the buffer from the graphics | |
| 441 | + * address space | |
| 442 | + */ | |
| 436 | 443 | void (*move_notify)(struct ttm_buffer_object *bo, |
| 444 | + bool evict, | |
| 437 | 445 | struct ttm_mem_reg *new_mem); |
| 438 | 446 | /* notify the driver we are taking a fault on this BO |
| 439 | 447 | * and have reserved it */ |
| @@ -454,18 +462,6 @@ struct ttm_bo_driver { · 14 unmodified lines | ||
| 454 | 462 | struct ttm_mem_reg *mem); |
| 455 | 463 | void (*io_mem_free)(struct ttm_bo_device *bdev, |
| 456 | 464 | struct ttm_mem_reg *mem); |
| 457 | − | |
| 458 | − /** | |
| 459 | − * Optional driver callback for when BO is removed from the LRU. | |
| 460 | − * Called with LRU lock held immediately before the removal. | |
| 461 | − */ | |
| 462 | − void (*lru_removal)(struct ttm_buffer_object *bo); | |
| 463 | − | |
| 464 | − /** | |
| 465 | − * Return the list_head after which a BO should be inserted in the LRU. | |
| 466 | − */ | |
| 467 | − struct list_head *(*lru_tail)(struct ttm_buffer_object *bo); | |
| 468 | − struct list_head *(*swap_lru_tail)(struct ttm_buffer_object *bo); | |
| 469 | 465 | }; |
| 470 | 466 | |
| 471 | 467 | /** |
| @@ -512,7 +508,7 @@ struct ttm_bo_global { · 40 unmodified lines | ||
| 512 | 508 | /** |
| 513 | 509 | * Protected by the lru_lock. |
| 514 | 510 | */ |
| 515 | − struct list_head swap_lru; | |
| 511 | + struct list_head swap_lru[TTM_MAX_BO_PRIORITY]; | |
| 516 | 512 | |
| 517 | 513 | /** |
| 518 | 514 | * Internal protection. |
| @@ -780,9 +776,6 @@ extern void ttm_mem_io_unlock(struct ttm_mem_type_manager *man); · 261 unmodified lines | ||
| 780 | 776 | extern void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo); |
| 781 | 777 | extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo); |
| 782 | 778 | |
| 783 | −struct list_head *ttm_bo_default_lru_tail(struct ttm_buffer_object *bo); | |
| 784 | −struct list_head *ttm_bo_default_swap_lru_tail(struct ttm_buffer_object *bo); | |
| 785 | − | |
| 786 | 779 | /** |
| 787 | 780 | * __ttm_bo_reserve: |
| 788 | 781 | * |
| @@ -528,6 +528,8 @@ struct drm_amdgpu_cs_chunk_data { · 527 unmodified lines | ||
| 528 | 528 | #define AMDGPU_INFO_VBIOS_SIZE 0x1 |
| 529 | 529 | /* Subquery id: Query vbios image */ |
| 530 | 530 | #define AMDGPU_INFO_VBIOS_IMAGE 0x2 |
| 531 | +/* Query UVD handles */ | |
| 532 | +#define AMDGPU_INFO_NUM_HANDLES 0x1C | |
| 531 | 533 | |
| 532 | 534 | #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0 |
| 533 | 535 | #define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff |
| @@ -719,6 +721,13 @@ struct drm_amdgpu_info_hw_ip { · 185 unmodified lines | ||
| 719 | 721 | __u32 _pad; |
| 720 | 722 | }; |
| 721 | 723 | |
| 724 | +struct drm_amdgpu_info_num_handles { | |
| 725 | + /** Max handles as supported by firmware for UVD */ | |
| 726 | + __u32 uvd_max_handles; | |
| 727 | + /** Handles currently in use for UVD */ | |
| 728 | + __u32 uvd_used_handles; | |
| 729 | +}; | |
| 730 | + | |
| 722 | 731 | #define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6 |
| 723 | 732 | |
| 724 | 733 | struct drm_amdgpu_info_vce_clock_table_entry { |