Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'drm-next-4.20' of git://people.freedesktop.org/~agd5f/linux into drm-next

Add a new list.h helper for doing bulk updates. Used by ttm.
- Fixes for display underflow on VI APUs at 4K with UVD running
- Endian fixes for powerplay on vega
- DC fixes for interlaced video
- Vega20 powerplay fixes
- RV/RV2/PCO powerplay fixes
- Fix for spurious ACPI events on HG laptops
- Fix a memory leak in DC on driver unload
- Fixes for manual fan control mode switching
- Suspend/resume robustness fixes
- Fix display handling on RV2
- VCN fixes for DPG on PCO
- Misc code cleanups and warning fixes

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Alex Deucher <alexdeucher@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181011014739.3117-1-alexander.deucher@amd.com

+1653 -1145
+21 -28
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 81 81 #include "amdgpu_bo_list.h" 82 82 #include "amdgpu_gem.h" 83 83 84 + #define MAX_GPU_INSTANCE 16 85 + 86 + struct amdgpu_gpu_instance 87 + { 88 + struct amdgpu_device *adev; 89 + int mgpu_fan_enabled; 90 + }; 91 + 92 + struct amdgpu_mgpu_info 93 + { 94 + struct amdgpu_gpu_instance gpu_ins[MAX_GPU_INSTANCE]; 95 + struct mutex mutex; 96 + uint32_t num_gpu; 97 + uint32_t num_dgpu; 98 + uint32_t num_apu; 99 + }; 100 + 84 101 /* 85 102 * Modules parameters. 86 103 */ ··· 151 134 extern int amdgpu_gpu_recovery; 152 135 extern int amdgpu_emu_mode; 153 136 extern uint amdgpu_smu_memory_pool_size; 137 + extern struct amdgpu_mgpu_info mgpu_info; 154 138 155 139 #ifdef CONFIG_DRM_AMDGPU_SI 156 140 extern int amdgpu_si_support; ··· 616 598 */ 617 599 void amdgpu_test_moves(struct amdgpu_device *adev); 618 600 619 - 620 - /* 621 - * amdgpu smumgr functions 622 - */ 623 - struct amdgpu_smumgr_funcs { 624 - int (*check_fw_load_finish)(struct amdgpu_device *adev, uint32_t fwtype); 625 - int (*request_smu_load_fw)(struct amdgpu_device *adev); 626 - int (*request_smu_specific_fw)(struct amdgpu_device *adev, uint32_t fwtype); 627 - }; 628 - 629 - /* 630 - * amdgpu smumgr 631 - */ 632 - struct amdgpu_smumgr { 633 - struct amdgpu_bo *toc_buf; 634 - struct amdgpu_bo *smu_buf; 635 - /* asic priv smu data */ 636 - void *priv; 637 - spinlock_t smu_lock; 638 - /* smumgr functions */ 639 - const struct amdgpu_smumgr_funcs *smumgr_funcs; 640 - /* ucode loading complete flag */ 641 - uint32_t fw_flags; 642 - }; 643 - 644 601 /* 645 602 * ASIC specific register table accessible by UMD 646 603 */ ··· 951 958 u32 cg_flags; 952 959 u32 pg_flags; 953 960 954 - /* amdgpu smumgr */ 955 - struct amdgpu_smumgr smu; 956 - 957 961 /* gfx */ 958 962 struct amdgpu_gfx gfx; 959 963 ··· 1014 1024 /* record hw reset is performed */ 1015 1025 bool has_hw_reset; 1016 1026 u8 reset_magic[AMDGPU_RESET_MAGIC_NUM]; 1027 + 1028 + /* s3/s4 mask */ 1029 + bool in_suspend; 1017 1030 1018 1031 /* record last mm index being written through WREG32*/ 1019 1032 unsigned long last_mm_index;
+12 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
··· 359 359 * 360 360 * Checks the acpi event and if it matches an atif event, 361 361 * handles it. 362 - * Returns NOTIFY code 362 + * 363 + * Returns: 364 + * NOTIFY_BAD or NOTIFY_DONE, depending on the event. 363 365 */ 364 366 static int amdgpu_atif_handler(struct amdgpu_device *adev, 365 367 struct acpi_bus_event *event) ··· 375 373 if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0) 376 374 return NOTIFY_DONE; 377 375 376 + /* Is this actually our event? */ 378 377 if (!atif || 379 378 !atif->notification_cfg.enabled || 380 - event->type != atif->notification_cfg.command_code) 381 - /* Not our event */ 382 - return NOTIFY_DONE; 379 + event->type != atif->notification_cfg.command_code) { 380 + /* These events will generate keypresses otherwise */ 381 + if (event->type == ACPI_VIDEO_NOTIFY_PROBE) 382 + return NOTIFY_BAD; 383 + else 384 + return NOTIFY_DONE; 385 + } 383 386 384 387 if (atif->functions.sbios_requests) { 385 388 struct atif_sbios_requests req; ··· 393 386 count = amdgpu_atif_get_sbios_requests(atif, &req); 394 387 395 388 if (count <= 0) 396 - return NOTIFY_DONE; 389 + return NOTIFY_BAD; 397 390 398 391 DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count); 399 392
+165 -18
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 1525 1525 return 0; 1526 1526 } 1527 1527 1528 + static int amdgpu_device_ip_hw_init_phase1(struct amdgpu_device *adev) 1529 + { 1530 + int i, r; 1531 + 1532 + for (i = 0; i < adev->num_ip_blocks; i++) { 1533 + if (!adev->ip_blocks[i].status.sw) 1534 + continue; 1535 + if (adev->ip_blocks[i].status.hw) 1536 + continue; 1537 + if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON || 1538 + adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH) { 1539 + r = adev->ip_blocks[i].version->funcs->hw_init(adev); 1540 + if (r) { 1541 + DRM_ERROR("hw_init of IP block <%s> failed %d\n", 1542 + adev->ip_blocks[i].version->funcs->name, r); 1543 + return r; 1544 + } 1545 + adev->ip_blocks[i].status.hw = true; 1546 + } 1547 + } 1548 + 1549 + return 0; 1550 + } 1551 + 1552 + static int amdgpu_device_ip_hw_init_phase2(struct amdgpu_device *adev) 1553 + { 1554 + int i, r; 1555 + 1556 + for (i = 0; i < adev->num_ip_blocks; i++) { 1557 + if (!adev->ip_blocks[i].status.sw) 1558 + continue; 1559 + if (adev->ip_blocks[i].status.hw) 1560 + continue; 1561 + r = adev->ip_blocks[i].version->funcs->hw_init(adev); 1562 + if (r) { 1563 + DRM_ERROR("hw_init of IP block <%s> failed %d\n", 1564 + adev->ip_blocks[i].version->funcs->name, r); 1565 + return r; 1566 + } 1567 + adev->ip_blocks[i].status.hw = true; 1568 + } 1569 + 1570 + return 0; 1571 + } 1572 + 1573 + static int amdgpu_device_fw_loading(struct amdgpu_device *adev) 1574 + { 1575 + int r = 0; 1576 + int i; 1577 + 1578 + if (adev->asic_type >= CHIP_VEGA10) { 1579 + for (i = 0; i < adev->num_ip_blocks; i++) { 1580 + if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_PSP) { 1581 + if (adev->in_gpu_reset || adev->in_suspend) { 1582 + if (amdgpu_sriov_vf(adev) && adev->in_gpu_reset) 1583 + break; /* sriov gpu reset, psp need to do hw_init before IH because of hw limit */ 1584 + r = adev->ip_blocks[i].version->funcs->resume(adev); 1585 + if (r) { 1586 + DRM_ERROR("resume of IP block <%s> failed %d\n", 1587 + adev->ip_blocks[i].version->funcs->name, r); 1588 + return r; 1589 + } 1590 + } else { 1591 + r = adev->ip_blocks[i].version->funcs->hw_init(adev); 1592 + if (r) { 1593 + DRM_ERROR("hw_init of IP block <%s> failed %d\n", 1594 + adev->ip_blocks[i].version->funcs->name, r); 1595 + return r; 1596 + } 1597 + } 1598 + adev->ip_blocks[i].status.hw = true; 1599 + } 1600 + } 1601 + } 1602 + 1603 + if (adev->powerplay.pp_funcs->load_firmware) { 1604 + r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle); 1605 + if (r) { 1606 + pr_err("firmware loading failed\n"); 1607 + return r; 1608 + } 1609 + } 1610 + 1611 + return 0; 1612 + } 1613 + 1528 1614 /** 1529 1615 * amdgpu_device_ip_init - run init for hardware IPs 1530 1616 * ··· 1667 1581 } 1668 1582 } 1669 1583 1670 - for (i = 0; i < adev->num_ip_blocks; i++) { 1671 - if (!adev->ip_blocks[i].status.sw) 1672 - continue; 1673 - if (adev->ip_blocks[i].status.hw) 1674 - continue; 1675 - r = adev->ip_blocks[i].version->funcs->hw_init((void *)adev); 1676 - if (r) { 1677 - DRM_ERROR("hw_init of IP block <%s> failed %d\n", 1678 - adev->ip_blocks[i].version->funcs->name, r); 1679 - return r; 1680 - } 1681 - adev->ip_blocks[i].status.hw = true; 1682 - } 1584 + r = amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init complete*/ 1585 + if (r) 1586 + return r; 1587 + 1588 + r = amdgpu_device_ip_hw_init_phase1(adev); 1589 + if (r) 1590 + return r; 1591 + 1592 + r = amdgpu_device_fw_loading(adev); 1593 + if (r) 1594 + return r; 1595 + 1596 + r = amdgpu_device_ip_hw_init_phase2(adev); 1597 + if (r) 1598 + return r; 1683 1599 1684 1600 amdgpu_xgmi_add_device(adev); 1685 1601 amdgpu_amdkfd_device_init(adev); ··· 1744 1656 1745 1657 for (j = 0; j < adev->num_ip_blocks; j++) { 1746 1658 i = state == AMD_CG_STATE_GATE ? j : adev->num_ip_blocks - j - 1; 1747 - if (!adev->ip_blocks[i].status.valid) 1659 + if (!adev->ip_blocks[i].status.late_initialized) 1748 1660 continue; 1749 1661 /* skip CG for VCE/UVD, it's handled specially */ 1750 1662 if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && ··· 1774 1686 1775 1687 for (j = 0; j < adev->num_ip_blocks; j++) { 1776 1688 i = state == AMD_PG_STATE_GATE ? j : adev->num_ip_blocks - j - 1; 1777 - if (!adev->ip_blocks[i].status.valid) 1689 + if (!adev->ip_blocks[i].status.late_initialized) 1778 1690 continue; 1779 1691 /* skip CG for VCE/UVD, it's handled specially */ 1780 1692 if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && ··· 1811 1723 int i = 0, r; 1812 1724 1813 1725 for (i = 0; i < adev->num_ip_blocks; i++) { 1814 - if (!adev->ip_blocks[i].status.valid) 1726 + if (!adev->ip_blocks[i].status.hw) 1815 1727 continue; 1816 1728 if (adev->ip_blocks[i].version->funcs->late_init) { 1817 1729 r = adev->ip_blocks[i].version->funcs->late_init((void *)adev); ··· 1820 1732 adev->ip_blocks[i].version->funcs->name, r); 1821 1733 return r; 1822 1734 } 1823 - adev->ip_blocks[i].status.late_initialized = true; 1824 1735 } 1736 + adev->ip_blocks[i].status.late_initialized = true; 1825 1737 } 1826 1738 1827 1739 amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE); ··· 1891 1803 continue; 1892 1804 1893 1805 if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) { 1806 + amdgpu_ucode_free_bo(adev); 1894 1807 amdgpu_free_static_csa(adev); 1895 1808 amdgpu_device_wb_fini(adev); 1896 1809 amdgpu_device_vram_scratch_fini(adev); ··· 1922 1833 return 0; 1923 1834 } 1924 1835 1836 + static int amdgpu_device_enable_mgpu_fan_boost(void) 1837 + { 1838 + struct amdgpu_gpu_instance *gpu_ins; 1839 + struct amdgpu_device *adev; 1840 + int i, ret = 0; 1841 + 1842 + mutex_lock(&mgpu_info.mutex); 1843 + 1844 + /* 1845 + * MGPU fan boost feature should be enabled 1846 + * only when there are two or more dGPUs in 1847 + * the system 1848 + */ 1849 + if (mgpu_info.num_dgpu < 2) 1850 + goto out; 1851 + 1852 + for (i = 0; i < mgpu_info.num_dgpu; i++) { 1853 + gpu_ins = &(mgpu_info.gpu_ins[i]); 1854 + adev = gpu_ins->adev; 1855 + if (!(adev->flags & AMD_IS_APU) && 1856 + !gpu_ins->mgpu_fan_enabled && 1857 + adev->powerplay.pp_funcs && 1858 + adev->powerplay.pp_funcs->enable_mgpu_fan_boost) { 1859 + ret = amdgpu_dpm_enable_mgpu_fan_boost(adev); 1860 + if (ret) 1861 + break; 1862 + 1863 + gpu_ins->mgpu_fan_enabled = 1; 1864 + } 1865 + } 1866 + 1867 + out: 1868 + mutex_unlock(&mgpu_info.mutex); 1869 + 1870 + return ret; 1871 + } 1872 + 1925 1873 /** 1926 1874 * amdgpu_device_ip_late_init_func_handler - work handler for ib test 1927 1875 * ··· 1973 1847 r = amdgpu_ib_ring_tests(adev); 1974 1848 if (r) 1975 1849 DRM_ERROR("ib ring test failed (%d).\n", r); 1850 + 1851 + r = amdgpu_device_enable_mgpu_fan_boost(); 1852 + if (r) 1853 + DRM_ERROR("enable mgpu fan boost failed (%d).\n", r); 1976 1854 } 1977 1855 1978 1856 static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work) ··· 2212 2082 continue; 2213 2083 if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON || 2214 2084 adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC || 2215 - adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH) 2085 + adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH || 2086 + adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_PSP) 2216 2087 continue; 2217 2088 r = adev->ip_blocks[i].version->funcs->resume(adev); 2218 2089 if (r) { ··· 2245 2114 r = amdgpu_device_ip_resume_phase1(adev); 2246 2115 if (r) 2247 2116 return r; 2117 + 2118 + r = amdgpu_device_fw_loading(adev); 2119 + if (r) 2120 + return r; 2121 + 2248 2122 r = amdgpu_device_ip_resume_phase2(adev); 2249 2123 2250 2124 return r; ··· 2744 2608 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 2745 2609 return 0; 2746 2610 2611 + adev->in_suspend = true; 2747 2612 drm_kms_helper_poll_disable(dev); 2748 2613 2749 2614 if (fbcon) ··· 2930 2793 #ifdef CONFIG_PM 2931 2794 dev->dev->power.disable_depth--; 2932 2795 #endif 2796 + adev->in_suspend = false; 2797 + 2933 2798 return 0; 2934 2799 } 2935 2800 ··· 3200 3061 if (r) 3201 3062 goto out; 3202 3063 3064 + r = amdgpu_device_fw_loading(adev); 3065 + if (r) 3066 + return r; 3067 + 3203 3068 r = amdgpu_device_ip_resume_phase2(adev); 3204 3069 if (r) 3205 3070 goto out; ··· 3259 3116 3260 3117 /* we need recover gart prior to run SMC/CP/SDMA resume */ 3261 3118 amdgpu_gtt_mgr_recover(&adev->mman.bdev.man[TTM_PL_TT]); 3119 + 3120 + r = amdgpu_device_fw_loading(adev); 3121 + if (r) 3122 + return r; 3262 3123 3263 3124 /* now we are okay to resume SMC/CP/SDMA */ 3264 3125 r = amdgpu_device_ip_reinit_late_sriov(adev);
+7
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h
··· 278 278 #define amdgpu_dpm_get_fan_speed_rpm(adev, s) \ 279 279 ((adev)->powerplay.pp_funcs->get_fan_speed_rpm)((adev)->powerplay.pp_handle, (s)) 280 280 281 + #define amdgpu_dpm_set_fan_speed_rpm(adev, s) \ 282 + ((adev)->powerplay.pp_funcs->set_fan_speed_rpm)((adev)->powerplay.pp_handle, (s)) 283 + 281 284 #define amdgpu_dpm_get_sclk(adev, l) \ 282 285 ((adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l))) 283 286 ··· 359 356 #define amdgpu_dpm_odn_edit_dpm_table(adev, type, parameter, size) \ 360 357 ((adev)->powerplay.pp_funcs->odn_edit_dpm_table(\ 361 358 (adev)->powerplay.pp_handle, type, parameter, size)) 359 + 360 + #define amdgpu_dpm_enable_mgpu_fan_boost(adev) \ 361 + ((adev)->powerplay.pp_funcs->enable_mgpu_fan_boost(\ 362 + (adev)->powerplay.pp_handle)) 362 363 363 364 struct amdgpu_dpm { 364 365 struct amdgpu_ps *ps;
+3
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 127 127 int amdgpu_gpu_recovery = -1; /* auto */ 128 128 int amdgpu_emu_mode = 0; 129 129 uint amdgpu_smu_memory_pool_size = 0; 130 + struct amdgpu_mgpu_info mgpu_info = { 131 + .mutex = __MUTEX_INITIALIZER(mgpu_info.mutex), 132 + }; 130 133 131 134 /** 132 135 * DOC: vramlimit (int)
+1 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
··· 297 297 /* reset mask */ 298 298 uint32_t grbm_soft_reset; 299 299 uint32_t srbm_soft_reset; 300 - /* s3/s4 mask */ 301 - bool in_suspend; 300 + 302 301 /* NGG */ 303 302 struct amdgpu_ngg ngg; 304 303
+6 -7
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
··· 146 146 { 147 147 const uint64_t four_gb = 0x100000000ULL; 148 148 u64 size_af, size_bf; 149 + /*To avoid the hole, limit the max mc address to AMDGPU_GMC_HOLE_START*/ 150 + u64 max_mc_address = min(adev->gmc.mc_mask, AMDGPU_GMC_HOLE_START - 1); 149 151 150 152 mc->gart_size += adev->pm.smu_prv_buffer_size; 151 153 ··· 155 153 * the GART base on a 4GB boundary as well. 156 154 */ 157 155 size_bf = mc->fb_start; 158 - size_af = adev->gmc.mc_mask + 1 - ALIGN(mc->fb_end + 1, four_gb); 156 + size_af = max_mc_address + 1 - ALIGN(mc->fb_end + 1, four_gb); 159 157 160 158 if (mc->gart_size > max(size_bf, size_af)) { 161 159 dev_warn(adev->dev, "limiting GART\n"); ··· 166 164 (size_af < mc->gart_size)) 167 165 mc->gart_start = 0; 168 166 else 169 - mc->gart_start = mc->mc_mask - mc->gart_size + 1; 167 + mc->gart_start = max_mc_address - mc->gart_size + 1; 170 168 171 169 mc->gart_start &= ~(four_gb - 1); 172 170 mc->gart_end = mc->gart_start + mc->gart_size - 1; ··· 202 200 } 203 201 204 202 if (size_bf > size_af) { 205 - mc->agp_start = mc->fb_start > mc->gart_start ? 206 - mc->gart_end + 1 : 0; 203 + mc->agp_start = (mc->fb_start - size_bf) & sixteen_gb_mask; 207 204 mc->agp_size = size_bf; 208 205 } else { 209 - mc->agp_start = (mc->fb_start > mc->gart_start ? 210 - mc->fb_end : mc->gart_end) + 1, 206 + mc->agp_start = ALIGN(mc->fb_end + 1, sixteen_gb); 211 207 mc->agp_size = size_af; 212 208 } 213 209 214 - mc->agp_start = ALIGN(mc->agp_start, sixteen_gb); 215 210 mc->agp_end = mc->agp_start + mc->agp_size - 1; 216 211 dev_info(adev->dev, "AGP: %lluM 0x%016llX - 0x%016llX\n", 217 212 mc->agp_size >> 20, mc->agp_start, mc->agp_end);
+8
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
··· 354 354 if (!ring || !ring->ready) 355 355 continue; 356 356 357 + /* skip IB tests for KIQ in general for the below reasons: 358 + * 1. We never submit IBs to the KIQ 359 + * 2. KIQ doesn't use the EOP interrupts, 360 + * we use some other CP interrupt. 361 + */ 362 + if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ) 363 + continue; 364 + 357 365 /* MM engine need more time */ 358 366 if (ring->funcs->type == AMDGPU_RING_TYPE_UVD || 359 367 ring->funcs->type == AMDGPU_RING_TYPE_VCE ||
+52
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
··· 40 40 #include "amdgpu_gem.h" 41 41 #include "amdgpu_display.h" 42 42 43 + static void amdgpu_unregister_gpu_instance(struct amdgpu_device *adev) 44 + { 45 + struct amdgpu_gpu_instance *gpu_instance; 46 + int i; 47 + 48 + mutex_lock(&mgpu_info.mutex); 49 + 50 + for (i = 0; i < mgpu_info.num_gpu; i++) { 51 + gpu_instance = &(mgpu_info.gpu_ins[i]); 52 + if (gpu_instance->adev == adev) { 53 + mgpu_info.gpu_ins[i] = 54 + mgpu_info.gpu_ins[mgpu_info.num_gpu - 1]; 55 + mgpu_info.num_gpu--; 56 + if (adev->flags & AMD_IS_APU) 57 + mgpu_info.num_apu--; 58 + else 59 + mgpu_info.num_dgpu--; 60 + break; 61 + } 62 + } 63 + 64 + mutex_unlock(&mgpu_info.mutex); 65 + } 66 + 43 67 /** 44 68 * amdgpu_driver_unload_kms - Main unload function for KMS. 45 69 * ··· 78 54 79 55 if (adev == NULL) 80 56 return; 57 + 58 + amdgpu_unregister_gpu_instance(adev); 81 59 82 60 if (adev->rmmio == NULL) 83 61 goto done_free; ··· 99 73 done_free: 100 74 kfree(adev); 101 75 dev->dev_private = NULL; 76 + } 77 + 78 + static void amdgpu_register_gpu_instance(struct amdgpu_device *adev) 79 + { 80 + struct amdgpu_gpu_instance *gpu_instance; 81 + 82 + mutex_lock(&mgpu_info.mutex); 83 + 84 + if (mgpu_info.num_gpu >= MAX_GPU_INSTANCE) { 85 + DRM_ERROR("Cannot register more gpu instance\n"); 86 + mutex_unlock(&mgpu_info.mutex); 87 + return; 88 + } 89 + 90 + gpu_instance = &(mgpu_info.gpu_ins[mgpu_info.num_gpu]); 91 + gpu_instance->adev = adev; 92 + gpu_instance->mgpu_fan_enabled = 0; 93 + 94 + mgpu_info.num_gpu++; 95 + if (adev->flags & AMD_IS_APU) 96 + mgpu_info.num_apu++; 97 + else 98 + mgpu_info.num_dgpu++; 99 + 100 + mutex_unlock(&mgpu_info.mutex); 102 101 } 103 102 104 103 /** ··· 220 169 pm_runtime_put_autosuspend(dev->dev); 221 170 } 222 171 172 + amdgpu_register_gpu_instance(adev); 223 173 out: 224 174 if (r) { 225 175 /* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
+184 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
··· 1120 1120 struct amdgpu_device *adev = dev_get_drvdata(dev); 1121 1121 int err; 1122 1122 u32 value; 1123 + u32 pwm_mode; 1123 1124 1124 1125 /* Can't adjust fan when the card is off */ 1125 1126 if ((adev->flags & AMD_IS_PX) && 1126 1127 (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 1127 1128 return -EINVAL; 1129 + 1130 + pwm_mode = amdgpu_dpm_get_fan_control_mode(adev); 1131 + if (pwm_mode != AMD_FAN_CTRL_MANUAL) { 1132 + pr_info("manual fan speed control should be enabled first\n"); 1133 + return -EINVAL; 1134 + } 1128 1135 1129 1136 err = kstrtou32(buf, 10, &value); 1130 1137 if (err) ··· 1192 1185 } 1193 1186 1194 1187 return sprintf(buf, "%i\n", speed); 1188 + } 1189 + 1190 + static ssize_t amdgpu_hwmon_get_fan1_min(struct device *dev, 1191 + struct device_attribute *attr, 1192 + char *buf) 1193 + { 1194 + struct amdgpu_device *adev = dev_get_drvdata(dev); 1195 + u32 min_rpm = 0; 1196 + u32 size = sizeof(min_rpm); 1197 + int r; 1198 + 1199 + if (!adev->powerplay.pp_funcs->read_sensor) 1200 + return -EINVAL; 1201 + 1202 + r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_MIN_FAN_RPM, 1203 + (void *)&min_rpm, &size); 1204 + if (r) 1205 + return r; 1206 + 1207 + return snprintf(buf, PAGE_SIZE, "%d\n", min_rpm); 1208 + } 1209 + 1210 + static ssize_t amdgpu_hwmon_get_fan1_max(struct device *dev, 1211 + struct device_attribute *attr, 1212 + char *buf) 1213 + { 1214 + struct amdgpu_device *adev = dev_get_drvdata(dev); 1215 + u32 max_rpm = 0; 1216 + u32 size = sizeof(max_rpm); 1217 + int r; 1218 + 1219 + if (!adev->powerplay.pp_funcs->read_sensor) 1220 + return -EINVAL; 1221 + 1222 + r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_MAX_FAN_RPM, 1223 + (void *)&max_rpm, &size); 1224 + if (r) 1225 + return r; 1226 + 1227 + return snprintf(buf, PAGE_SIZE, "%d\n", max_rpm); 1228 + } 1229 + 1230 + static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev, 1231 + struct device_attribute *attr, 1232 + char *buf) 1233 + { 1234 + struct amdgpu_device *adev = dev_get_drvdata(dev); 1235 + int err; 1236 + u32 rpm = 0; 1237 + 1238 + /* Can't adjust fan when the card is off */ 1239 + if ((adev->flags & AMD_IS_PX) && 1240 + (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 1241 + return -EINVAL; 1242 + 1243 + if (adev->powerplay.pp_funcs->get_fan_speed_rpm) { 1244 + err = amdgpu_dpm_get_fan_speed_rpm(adev, &rpm); 1245 + if (err) 1246 + return err; 1247 + } 1248 + 1249 + return sprintf(buf, "%i\n", rpm); 1250 + } 1251 + 1252 + static ssize_t amdgpu_hwmon_set_fan1_target(struct device *dev, 1253 + struct device_attribute *attr, 1254 + const char *buf, size_t count) 1255 + { 1256 + struct amdgpu_device *adev = dev_get_drvdata(dev); 1257 + int err; 1258 + u32 value; 1259 + u32 pwm_mode; 1260 + 1261 + pwm_mode = amdgpu_dpm_get_fan_control_mode(adev); 1262 + if (pwm_mode != AMD_FAN_CTRL_MANUAL) 1263 + return -ENODATA; 1264 + 1265 + /* Can't adjust fan when the card is off */ 1266 + if ((adev->flags & AMD_IS_PX) && 1267 + (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 1268 + return -EINVAL; 1269 + 1270 + err = kstrtou32(buf, 10, &value); 1271 + if (err) 1272 + return err; 1273 + 1274 + if (adev->powerplay.pp_funcs->set_fan_speed_rpm) { 1275 + err = amdgpu_dpm_set_fan_speed_rpm(adev, value); 1276 + if (err) 1277 + return err; 1278 + } 1279 + 1280 + return count; 1281 + } 1282 + 1283 + static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev, 1284 + struct device_attribute *attr, 1285 + char *buf) 1286 + { 1287 + struct amdgpu_device *adev = dev_get_drvdata(dev); 1288 + u32 pwm_mode = 0; 1289 + 1290 + if (!adev->powerplay.pp_funcs->get_fan_control_mode) 1291 + return -EINVAL; 1292 + 1293 + pwm_mode = amdgpu_dpm_get_fan_control_mode(adev); 1294 + 1295 + return sprintf(buf, "%i\n", pwm_mode == AMD_FAN_CTRL_AUTO ? 0 : 1); 1296 + } 1297 + 1298 + static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev, 1299 + struct device_attribute *attr, 1300 + const char *buf, 1301 + size_t count) 1302 + { 1303 + struct amdgpu_device *adev = dev_get_drvdata(dev); 1304 + int err; 1305 + int value; 1306 + u32 pwm_mode; 1307 + 1308 + /* Can't adjust fan when the card is off */ 1309 + if ((adev->flags & AMD_IS_PX) && 1310 + (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 1311 + return -EINVAL; 1312 + 1313 + if (!adev->powerplay.pp_funcs->set_fan_control_mode) 1314 + return -EINVAL; 1315 + 1316 + err = kstrtoint(buf, 10, &value); 1317 + if (err) 1318 + return err; 1319 + 1320 + if (value == 0) 1321 + pwm_mode = AMD_FAN_CTRL_AUTO; 1322 + else if (value == 1) 1323 + pwm_mode = AMD_FAN_CTRL_MANUAL; 1324 + else 1325 + return -EINVAL; 1326 + 1327 + amdgpu_dpm_set_fan_control_mode(adev, pwm_mode); 1328 + 1329 + return count; 1195 1330 } 1196 1331 1197 1332 static ssize_t amdgpu_hwmon_show_vddgfx(struct device *dev, ··· 1555 1406 * 1556 1407 * - pwm1_max: pulse width modulation fan control maximum level (255) 1557 1408 * 1409 + * - fan1_min: an minimum value Unit: revolution/min (RPM) 1410 + * 1411 + * - fan1_max: an maxmum value Unit: revolution/max (RPM) 1412 + * 1558 1413 * - fan1_input: fan speed in RPM 1414 + * 1415 + * - fan[1-*]_target: Desired fan speed Unit: revolution/min (RPM) 1416 + * 1417 + * - fan[1-*]_enable: Enable or disable the sensors.1: Enable 0: Disable 1559 1418 * 1560 1419 * You can use hwmon tools like sensors to view this information on your system. 1561 1420 * ··· 1577 1420 static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0); 1578 1421 static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0); 1579 1422 static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0); 1423 + static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO, amdgpu_hwmon_get_fan1_min, NULL, 0); 1424 + static SENSOR_DEVICE_ATTR(fan1_max, S_IRUGO, amdgpu_hwmon_get_fan1_max, NULL, 0); 1425 + static SENSOR_DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_fan1_target, amdgpu_hwmon_set_fan1_target, 0); 1426 + static SENSOR_DEVICE_ATTR(fan1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_fan1_enable, amdgpu_hwmon_set_fan1_enable, 0); 1580 1427 static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, amdgpu_hwmon_show_vddgfx, NULL, 0); 1581 1428 static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, amdgpu_hwmon_show_vddgfx_label, NULL, 0); 1582 1429 static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, amdgpu_hwmon_show_vddnb, NULL, 0); ··· 1599 1438 &sensor_dev_attr_pwm1_min.dev_attr.attr, 1600 1439 &sensor_dev_attr_pwm1_max.dev_attr.attr, 1601 1440 &sensor_dev_attr_fan1_input.dev_attr.attr, 1441 + &sensor_dev_attr_fan1_min.dev_attr.attr, 1442 + &sensor_dev_attr_fan1_max.dev_attr.attr, 1443 + &sensor_dev_attr_fan1_target.dev_attr.attr, 1444 + &sensor_dev_attr_fan1_enable.dev_attr.attr, 1602 1445 &sensor_dev_attr_in0_input.dev_attr.attr, 1603 1446 &sensor_dev_attr_in0_label.dev_attr.attr, 1604 1447 &sensor_dev_attr_in1_input.dev_attr.attr, ··· 1621 1456 struct amdgpu_device *adev = dev_get_drvdata(dev); 1622 1457 umode_t effective_mode = attr->mode; 1623 1458 1624 - 1625 1459 /* Skip fan attributes if fan is not present */ 1626 1460 if (adev->pm.no_fan && (attr == &sensor_dev_attr_pwm1.dev_attr.attr || 1627 1461 attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || 1628 1462 attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || 1629 1463 attr == &sensor_dev_attr_pwm1_min.dev_attr.attr || 1630 - attr == &sensor_dev_attr_fan1_input.dev_attr.attr)) 1464 + attr == &sensor_dev_attr_fan1_input.dev_attr.attr || 1465 + attr == &sensor_dev_attr_fan1_min.dev_attr.attr || 1466 + attr == &sensor_dev_attr_fan1_max.dev_attr.attr || 1467 + attr == &sensor_dev_attr_fan1_target.dev_attr.attr || 1468 + attr == &sensor_dev_attr_fan1_enable.dev_attr.attr)) 1631 1469 return 0; 1632 1470 1633 1471 /* Skip limit attributes if DPM is not enabled */ ··· 1640 1472 attr == &sensor_dev_attr_pwm1.dev_attr.attr || 1641 1473 attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || 1642 1474 attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || 1643 - attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) 1475 + attr == &sensor_dev_attr_pwm1_min.dev_attr.attr || 1476 + attr == &sensor_dev_attr_fan1_input.dev_attr.attr || 1477 + attr == &sensor_dev_attr_fan1_min.dev_attr.attr || 1478 + attr == &sensor_dev_attr_fan1_max.dev_attr.attr || 1479 + attr == &sensor_dev_attr_fan1_target.dev_attr.attr || 1480 + attr == &sensor_dev_attr_fan1_enable.dev_attr.attr)) 1644 1481 return 0; 1645 1482 1646 1483 /* mask fan attributes if we have no bindings for this asic to expose */ ··· 1670 1497 /* hide max/min values if we can't both query and manage the fan */ 1671 1498 if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && 1672 1499 !adev->powerplay.pp_funcs->get_fan_speed_percent) && 1500 + (!adev->powerplay.pp_funcs->set_fan_speed_rpm && 1501 + !adev->powerplay.pp_funcs->get_fan_speed_rpm) && 1673 1502 (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || 1674 1503 attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) 1504 + return 0; 1505 + 1506 + if ((!adev->powerplay.pp_funcs->set_fan_speed_rpm && 1507 + !adev->powerplay.pp_funcs->get_fan_speed_rpm) && 1508 + (attr == &sensor_dev_attr_fan1_max.dev_attr.attr || 1509 + attr == &sensor_dev_attr_fan1_min.dev_attr.attr)) 1675 1510 return 0; 1676 1511 1677 1512 /* only APUs have vddnb */
-2
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 452 452 if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) 453 453 return 0; 454 454 455 - amdgpu_ucode_fini_bo(adev); 456 - 457 455 psp_ring_destroy(psp, PSP_RING_TYPE__KM); 458 456 459 457 amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
-4
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
··· 46 46 47 47 struct amdgpu_sdma { 48 48 struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES]; 49 - #ifdef CONFIG_DRM_AMDGPU_SI 50 - //SI DMA has a difference trap irq number for the second engine 51 - struct amdgpu_irq_src trap_irq_1; 52 - #endif 53 49 struct amdgpu_irq_src trap_irq; 54 50 struct amdgpu_irq_src illegal_inst_irq; 55 51 int num_instances;
+30 -54
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
··· 297 297 case CHIP_POLARIS11: 298 298 case CHIP_POLARIS12: 299 299 case CHIP_VEGAM: 300 - if (!load_type) 301 - return AMDGPU_FW_LOAD_DIRECT; 302 - else 303 - return AMDGPU_FW_LOAD_SMU; 300 + return AMDGPU_FW_LOAD_SMU; 304 301 case CHIP_VEGA10: 305 302 case CHIP_RAVEN: 306 303 case CHIP_VEGA12: ··· 420 423 return 0; 421 424 } 422 425 426 + int amdgpu_ucode_create_bo(struct amdgpu_device *adev) 427 + { 428 + if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT) { 429 + amdgpu_bo_create_kernel(adev, adev->firmware.fw_size, PAGE_SIZE, 430 + amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT, 431 + &adev->firmware.fw_buf, 432 + &adev->firmware.fw_buf_mc, 433 + &adev->firmware.fw_buf_ptr); 434 + if (!adev->firmware.fw_buf) { 435 + dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n"); 436 + return -ENOMEM; 437 + } else if (amdgpu_sriov_vf(adev)) { 438 + memset(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size); 439 + } 440 + } 441 + return 0; 442 + } 443 + 444 + void amdgpu_ucode_free_bo(struct amdgpu_device *adev) 445 + { 446 + if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT) 447 + amdgpu_bo_free_kernel(&adev->firmware.fw_buf, 448 + &adev->firmware.fw_buf_mc, 449 + &adev->firmware.fw_buf_ptr); 450 + } 451 + 423 452 int amdgpu_ucode_init_bo(struct amdgpu_device *adev) 424 453 { 425 454 uint64_t fw_offset = 0; 426 - int i, err; 455 + int i; 427 456 struct amdgpu_firmware_info *ucode = NULL; 428 - const struct common_firmware_header *header = NULL; 429 457 430 - if (!adev->firmware.fw_size) { 431 - dev_warn(adev->dev, "No ip firmware need to load\n"); 458 + /* for baremetal, the ucode is allocated in gtt, so don't need to fill the bo when reset/suspend */ 459 + if (!amdgpu_sriov_vf(adev) && (adev->in_gpu_reset || adev->in_suspend)) 432 460 return 0; 433 - } 434 - 435 - if (!adev->in_gpu_reset) { 436 - err = amdgpu_bo_create_kernel(adev, adev->firmware.fw_size, PAGE_SIZE, 437 - amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT, 438 - &adev->firmware.fw_buf, 439 - &adev->firmware.fw_buf_mc, 440 - &adev->firmware.fw_buf_ptr); 441 - if (err) { 442 - dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n"); 443 - goto failed; 444 - } 445 - } 446 - 447 - memset(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size); 448 - 449 461 /* 450 462 * if SMU loaded firmware, it needn't add SMC, UVD, and VCE 451 463 * ucode info here ··· 471 465 for (i = 0; i < adev->firmware.max_ucodes; i++) { 472 466 ucode = &adev->firmware.ucode[i]; 473 467 if (ucode->fw) { 474 - header = (const struct common_firmware_header *)ucode->fw->data; 475 468 amdgpu_ucode_init_single_fw(adev, ucode, adev->firmware.fw_buf_mc + fw_offset, 476 469 adev->firmware.fw_buf_ptr + fw_offset); 477 470 if (i == AMDGPU_UCODE_ID_CP_MEC1 && ··· 484 479 fw_offset += ALIGN(ucode->ucode_size, PAGE_SIZE); 485 480 } 486 481 } 487 - return 0; 488 - 489 - failed: 490 - if (err) 491 - adev->firmware.load_type = AMDGPU_FW_LOAD_DIRECT; 492 - 493 - return err; 494 - } 495 - 496 - int amdgpu_ucode_fini_bo(struct amdgpu_device *adev) 497 - { 498 - int i; 499 - struct amdgpu_firmware_info *ucode = NULL; 500 - 501 - if (!adev->firmware.fw_size) 502 - return 0; 503 - 504 - for (i = 0; i < adev->firmware.max_ucodes; i++) { 505 - ucode = &adev->firmware.ucode[i]; 506 - if (ucode->fw) { 507 - ucode->mc_addr = 0; 508 - ucode->kaddr = NULL; 509 - } 510 - } 511 - 512 - amdgpu_bo_free_kernel(&adev->firmware.fw_buf, 513 - &adev->firmware.fw_buf_mc, 514 - &adev->firmware.fw_buf_ptr); 515 - 516 482 return 0; 517 483 }
+3 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
··· 276 276 int amdgpu_ucode_validate(const struct firmware *fw); 277 277 bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr, 278 278 uint16_t hdr_major, uint16_t hdr_minor); 279 + 279 280 int amdgpu_ucode_init_bo(struct amdgpu_device *adev); 280 - int amdgpu_ucode_fini_bo(struct amdgpu_device *adev); 281 + int amdgpu_ucode_create_bo(struct amdgpu_device *adev); 282 + void amdgpu_ucode_free_bo(struct amdgpu_device *adev); 281 283 282 284 enum amdgpu_firmware_load_type 283 285 amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type);
+10 -8
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
··· 121 121 version_major, version_minor, family_id); 122 122 } 123 123 124 - bo_size = AMDGPU_VCN_STACK_SIZE + AMDGPU_VCN_HEAP_SIZE 125 - + AMDGPU_VCN_SESSION_SIZE * 40; 124 + bo_size = AMDGPU_VCN_STACK_SIZE + AMDGPU_VCN_CONTEXT_SIZE; 126 125 if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) 127 126 bo_size += AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8); 128 127 r = amdgpu_bo_create_kernel(adev, bo_size, PAGE_SIZE, ··· 262 263 263 264 ring = &adev->vcn.ring_dec; 264 265 WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, 265 - lower_32_bits(ring->wptr) | 0x80000000); 266 + RREG32_SOC15(UVD, 0, mmUVD_SCRATCH2)); 266 267 SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, 267 268 UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, 268 269 UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); ··· 308 309 /* Restore */ 309 310 ring = &adev->vcn.ring_jpeg; 310 311 WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_VMID, 0); 311 - WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 0x00000001L | 0x00000002L); 312 + WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 313 + UVD_JRBC_RB_CNTL__RB_NO_FETCH_MASK | 314 + UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK); 312 315 WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_LOW, 313 - lower_32_bits(ring->gpu_addr)); 316 + lower_32_bits(ring->gpu_addr)); 314 317 WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_HIGH, 315 - upper_32_bits(ring->gpu_addr)); 318 + upper_32_bits(ring->gpu_addr)); 316 319 WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_RPTR, ring->wptr); 317 320 WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR, ring->wptr); 318 - WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 0x00000002L); 321 + WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 322 + UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK); 319 323 320 324 ring = &adev->vcn.ring_dec; 321 325 WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, 322 - lower_32_bits(ring->wptr) | 0x80000000); 326 + RREG32_SOC15(UVD, 0, mmUVD_SCRATCH2)); 323 327 SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, 324 328 UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, 325 329 UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code);
+3 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
··· 24 24 #ifndef __AMDGPU_VCN_H__ 25 25 #define __AMDGPU_VCN_H__ 26 26 27 - #define AMDGPU_VCN_STACK_SIZE (200*1024) 28 - #define AMDGPU_VCN_HEAP_SIZE (256*1024) 29 - #define AMDGPU_VCN_SESSION_SIZE (50*1024) 27 + #define AMDGPU_VCN_STACK_SIZE (128*1024) 28 + #define AMDGPU_VCN_CONTEXT_SIZE (512*1024) 29 + 30 30 #define AMDGPU_VCN_FIRMWARE_OFFSET 256 31 31 #define AMDGPU_VCN_MAX_ENC_RINGS 3 32 32
+9 -8
drivers/gpu/drm/amd/amdgpu/cik.c
··· 2002 2002 amdgpu_device_ip_block_add(adev, &cik_common_ip_block); 2003 2003 amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); 2004 2004 amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); 2005 + amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block); 2006 + amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); 2005 2007 if (amdgpu_dpm == -1) 2006 2008 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 2007 2009 else ··· 2016 2014 #endif 2017 2015 else 2018 2016 amdgpu_device_ip_block_add(adev, &dce_v8_2_ip_block); 2019 - amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block); 2020 - amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); 2021 2017 amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); 2022 2018 amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); 2023 2019 break; ··· 2023 2023 amdgpu_device_ip_block_add(adev, &cik_common_ip_block); 2024 2024 amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); 2025 2025 amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); 2026 + amdgpu_device_ip_block_add(adev, &gfx_v7_3_ip_block); 2027 + amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); 2026 2028 if (amdgpu_dpm == -1) 2027 2029 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 2028 2030 else ··· 2037 2035 #endif 2038 2036 else 2039 2037 amdgpu_device_ip_block_add(adev, &dce_v8_5_ip_block); 2040 - amdgpu_device_ip_block_add(adev, &gfx_v7_3_ip_block); 2041 - amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); 2042 2038 amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); 2043 2039 amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); 2044 2040 break; ··· 2044 2044 amdgpu_device_ip_block_add(adev, &cik_common_ip_block); 2045 2045 amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); 2046 2046 amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); 2047 + amdgpu_device_ip_block_add(adev, &gfx_v7_1_ip_block); 2048 + amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); 2047 2049 amdgpu_device_ip_block_add(adev, &kv_smu_ip_block); 2048 2050 if (adev->enable_virtual_display) 2049 2051 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); ··· 2055 2053 #endif 2056 2054 else 2057 2055 amdgpu_device_ip_block_add(adev, &dce_v8_1_ip_block); 2058 - amdgpu_device_ip_block_add(adev, &gfx_v7_1_ip_block); 2059 - amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); 2056 + 2060 2057 amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); 2061 2058 amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); 2062 2059 break; ··· 2064 2063 amdgpu_device_ip_block_add(adev, &cik_common_ip_block); 2065 2064 amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); 2066 2065 amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); 2066 + amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block); 2067 + amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); 2067 2068 amdgpu_device_ip_block_add(adev, &kv_smu_ip_block); 2068 2069 if (adev->enable_virtual_display) 2069 2070 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); ··· 2075 2072 #endif 2076 2073 else 2077 2074 amdgpu_device_ip_block_add(adev, &dce_v8_3_ip_block); 2078 - amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block); 2079 - amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); 2080 2075 amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); 2081 2076 amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); 2082 2077 break;
+50 -267
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
··· 1173 1173 } 1174 1174 } 1175 1175 1176 - if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { 1177 - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_PFP]; 1178 - info->ucode_id = AMDGPU_UCODE_ID_CP_PFP; 1179 - info->fw = adev->gfx.pfp_fw; 1180 - header = (const struct common_firmware_header *)info->fw->data; 1181 - adev->firmware.fw_size += 1182 - ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1176 + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_PFP]; 1177 + info->ucode_id = AMDGPU_UCODE_ID_CP_PFP; 1178 + info->fw = adev->gfx.pfp_fw; 1179 + header = (const struct common_firmware_header *)info->fw->data; 1180 + adev->firmware.fw_size += 1181 + ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1183 1182 1184 - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_ME]; 1185 - info->ucode_id = AMDGPU_UCODE_ID_CP_ME; 1186 - info->fw = adev->gfx.me_fw; 1187 - header = (const struct common_firmware_header *)info->fw->data; 1188 - adev->firmware.fw_size += 1189 - ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1183 + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_ME]; 1184 + info->ucode_id = AMDGPU_UCODE_ID_CP_ME; 1185 + info->fw = adev->gfx.me_fw; 1186 + header = (const struct common_firmware_header *)info->fw->data; 1187 + adev->firmware.fw_size += 1188 + ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1190 1189 1191 - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_CE]; 1192 - info->ucode_id = AMDGPU_UCODE_ID_CP_CE; 1193 - info->fw = adev->gfx.ce_fw; 1194 - header = (const struct common_firmware_header *)info->fw->data; 1195 - adev->firmware.fw_size += 1196 - ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1190 + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_CE]; 1191 + info->ucode_id = AMDGPU_UCODE_ID_CP_CE; 1192 + info->fw = adev->gfx.ce_fw; 1193 + header = (const struct common_firmware_header *)info->fw->data; 1194 + adev->firmware.fw_size += 1195 + ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1197 1196 1198 - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G]; 1199 - info->ucode_id = AMDGPU_UCODE_ID_RLC_G; 1200 - info->fw = adev->gfx.rlc_fw; 1201 - header = (const struct common_firmware_header *)info->fw->data; 1202 - adev->firmware.fw_size += 1203 - ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1197 + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G]; 1198 + info->ucode_id = AMDGPU_UCODE_ID_RLC_G; 1199 + info->fw = adev->gfx.rlc_fw; 1200 + header = (const struct common_firmware_header *)info->fw->data; 1201 + adev->firmware.fw_size += 1202 + ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1204 1203 1205 - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1]; 1206 - info->ucode_id = AMDGPU_UCODE_ID_CP_MEC1; 1204 + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1]; 1205 + info->ucode_id = AMDGPU_UCODE_ID_CP_MEC1; 1206 + info->fw = adev->gfx.mec_fw; 1207 + header = (const struct common_firmware_header *)info->fw->data; 1208 + adev->firmware.fw_size += 1209 + ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1210 + 1211 + /* we need account JT in */ 1212 + cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data; 1213 + adev->firmware.fw_size += 1214 + ALIGN(le32_to_cpu(cp_hdr->jt_size) << 2, PAGE_SIZE); 1215 + 1216 + if (amdgpu_sriov_vf(adev)) { 1217 + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_STORAGE]; 1218 + info->ucode_id = AMDGPU_UCODE_ID_STORAGE; 1207 1219 info->fw = adev->gfx.mec_fw; 1220 + adev->firmware.fw_size += 1221 + ALIGN(le32_to_cpu(64 * PAGE_SIZE), PAGE_SIZE); 1222 + } 1223 + 1224 + if (adev->gfx.mec2_fw) { 1225 + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC2]; 1226 + info->ucode_id = AMDGPU_UCODE_ID_CP_MEC2; 1227 + info->fw = adev->gfx.mec2_fw; 1208 1228 header = (const struct common_firmware_header *)info->fw->data; 1209 1229 adev->firmware.fw_size += 1210 1230 ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1211 - 1212 - /* we need account JT in */ 1213 - cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data; 1214 - adev->firmware.fw_size += 1215 - ALIGN(le32_to_cpu(cp_hdr->jt_size) << 2, PAGE_SIZE); 1216 - 1217 - if (amdgpu_sriov_vf(adev)) { 1218 - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_STORAGE]; 1219 - info->ucode_id = AMDGPU_UCODE_ID_STORAGE; 1220 - info->fw = adev->gfx.mec_fw; 1221 - adev->firmware.fw_size += 1222 - ALIGN(le32_to_cpu(64 * PAGE_SIZE), PAGE_SIZE); 1223 - } 1224 - 1225 - if (adev->gfx.mec2_fw) { 1226 - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC2]; 1227 - info->ucode_id = AMDGPU_UCODE_ID_CP_MEC2; 1228 - info->fw = adev->gfx.mec2_fw; 1229 - header = (const struct common_firmware_header *)info->fw->data; 1230 - adev->firmware.fw_size += 1231 - ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 1232 - } 1233 - 1234 1231 } 1235 1232 1236 1233 out: ··· 2044 2047 2045 2048 adev->gfx.mec.num_pipe_per_mec = 4; 2046 2049 adev->gfx.mec.num_queue_per_pipe = 8; 2047 - 2048 - /* KIQ event */ 2049 - r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_INT_IB2, &adev->gfx.kiq.irq); 2050 - if (r) 2051 - return r; 2052 2050 2053 2051 /* EOP Event */ 2054 2052 r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_END_OF_PIPE, &adev->gfx.eop_irq); ··· 4173 4181 udelay(50); 4174 4182 } 4175 4183 4176 - static int gfx_v8_0_rlc_load_microcode(struct amdgpu_device *adev) 4177 - { 4178 - const struct rlc_firmware_header_v2_0 *hdr; 4179 - const __le32 *fw_data; 4180 - unsigned i, fw_size; 4181 - 4182 - if (!adev->gfx.rlc_fw) 4183 - return -EINVAL; 4184 - 4185 - hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; 4186 - amdgpu_ucode_print_rlc_hdr(&hdr->header); 4187 - 4188 - fw_data = (const __le32 *)(adev->gfx.rlc_fw->data + 4189 - le32_to_cpu(hdr->header.ucode_array_offset_bytes)); 4190 - fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; 4191 - 4192 - WREG32(mmRLC_GPM_UCODE_ADDR, 0); 4193 - for (i = 0; i < fw_size; i++) 4194 - WREG32(mmRLC_GPM_UCODE_DATA, le32_to_cpup(fw_data++)); 4195 - WREG32(mmRLC_GPM_UCODE_ADDR, adev->gfx.rlc_fw_version); 4196 - 4197 - return 0; 4198 - } 4199 - 4200 4184 static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev) 4201 4185 { 4202 - int r; 4203 - 4204 4186 gfx_v8_0_rlc_stop(adev); 4205 4187 gfx_v8_0_rlc_reset(adev); 4206 4188 gfx_v8_0_init_pg(adev); 4207 - 4208 - if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { 4209 - /* legacy rlc firmware loading */ 4210 - r = gfx_v8_0_rlc_load_microcode(adev); 4211 - if (r) 4212 - return r; 4213 - } 4214 - 4215 4189 gfx_v8_0_rlc_start(adev); 4216 4190 4217 4191 return 0; ··· 4201 4243 } 4202 4244 WREG32(mmCP_ME_CNTL, tmp); 4203 4245 udelay(50); 4204 - } 4205 - 4206 - static int gfx_v8_0_cp_gfx_load_microcode(struct amdgpu_device *adev) 4207 - { 4208 - const struct gfx_firmware_header_v1_0 *pfp_hdr; 4209 - const struct gfx_firmware_header_v1_0 *ce_hdr; 4210 - const struct gfx_firmware_header_v1_0 *me_hdr; 4211 - const __le32 *fw_data; 4212 - unsigned i, fw_size; 4213 - 4214 - if (!adev->gfx.me_fw || !adev->gfx.pfp_fw || !adev->gfx.ce_fw) 4215 - return -EINVAL; 4216 - 4217 - pfp_hdr = (const struct gfx_firmware_header_v1_0 *) 4218 - adev->gfx.pfp_fw->data; 4219 - ce_hdr = (const struct gfx_firmware_header_v1_0 *) 4220 - adev->gfx.ce_fw->data; 4221 - me_hdr = (const struct gfx_firmware_header_v1_0 *) 4222 - adev->gfx.me_fw->data; 4223 - 4224 - amdgpu_ucode_print_gfx_hdr(&pfp_hdr->header); 4225 - amdgpu_ucode_print_gfx_hdr(&ce_hdr->header); 4226 - amdgpu_ucode_print_gfx_hdr(&me_hdr->header); 4227 - 4228 - gfx_v8_0_cp_gfx_enable(adev, false); 4229 - 4230 - /* PFP */ 4231 - fw_data = (const __le32 *) 4232 - (adev->gfx.pfp_fw->data + 4233 - le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes)); 4234 - fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes) / 4; 4235 - WREG32(mmCP_PFP_UCODE_ADDR, 0); 4236 - for (i = 0; i < fw_size; i++) 4237 - WREG32(mmCP_PFP_UCODE_DATA, le32_to_cpup(fw_data++)); 4238 - WREG32(mmCP_PFP_UCODE_ADDR, adev->gfx.pfp_fw_version); 4239 - 4240 - /* CE */ 4241 - fw_data = (const __le32 *) 4242 - (adev->gfx.ce_fw->data + 4243 - le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes)); 4244 - fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes) / 4; 4245 - WREG32(mmCP_CE_UCODE_ADDR, 0); 4246 - for (i = 0; i < fw_size; i++) 4247 - WREG32(mmCP_CE_UCODE_DATA, le32_to_cpup(fw_data++)); 4248 - WREG32(mmCP_CE_UCODE_ADDR, adev->gfx.ce_fw_version); 4249 - 4250 - /* ME */ 4251 - fw_data = (const __le32 *) 4252 - (adev->gfx.me_fw->data + 4253 - le32_to_cpu(me_hdr->header.ucode_array_offset_bytes)); 4254 - fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes) / 4; 4255 - WREG32(mmCP_ME_RAM_WADDR, 0); 4256 - for (i = 0; i < fw_size; i++) 4257 - WREG32(mmCP_ME_RAM_DATA, le32_to_cpup(fw_data++)); 4258 - WREG32(mmCP_ME_RAM_WADDR, adev->gfx.me_fw_version); 4259 - 4260 - return 0; 4261 4246 } 4262 4247 4263 4248 static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev) ··· 4400 4499 adev->gfx.kiq.ring.ready = false; 4401 4500 } 4402 4501 udelay(50); 4403 - } 4404 - 4405 - static int gfx_v8_0_cp_compute_load_microcode(struct amdgpu_device *adev) 4406 - { 4407 - const struct gfx_firmware_header_v1_0 *mec_hdr; 4408 - const __le32 *fw_data; 4409 - unsigned i, fw_size; 4410 - 4411 - if (!adev->gfx.mec_fw) 4412 - return -EINVAL; 4413 - 4414 - gfx_v8_0_cp_compute_enable(adev, false); 4415 - 4416 - mec_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data; 4417 - amdgpu_ucode_print_gfx_hdr(&mec_hdr->header); 4418 - 4419 - fw_data = (const __le32 *) 4420 - (adev->gfx.mec_fw->data + 4421 - le32_to_cpu(mec_hdr->header.ucode_array_offset_bytes)); 4422 - fw_size = le32_to_cpu(mec_hdr->header.ucode_size_bytes) / 4; 4423 - 4424 - /* MEC1 */ 4425 - WREG32(mmCP_MEC_ME1_UCODE_ADDR, 0); 4426 - for (i = 0; i < fw_size; i++) 4427 - WREG32(mmCP_MEC_ME1_UCODE_DATA, le32_to_cpup(fw_data+i)); 4428 - WREG32(mmCP_MEC_ME1_UCODE_ADDR, adev->gfx.mec_fw_version); 4429 - 4430 - /* Loading MEC2 firmware is only necessary if MEC2 should run different microcode than MEC1. */ 4431 - if (adev->gfx.mec2_fw) { 4432 - const struct gfx_firmware_header_v1_0 *mec2_hdr; 4433 - 4434 - mec2_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data; 4435 - amdgpu_ucode_print_gfx_hdr(&mec2_hdr->header); 4436 - 4437 - fw_data = (const __le32 *) 4438 - (adev->gfx.mec2_fw->data + 4439 - le32_to_cpu(mec2_hdr->header.ucode_array_offset_bytes)); 4440 - fw_size = le32_to_cpu(mec2_hdr->header.ucode_size_bytes) / 4; 4441 - 4442 - WREG32(mmCP_MEC_ME2_UCODE_ADDR, 0); 4443 - for (i = 0; i < fw_size; i++) 4444 - WREG32(mmCP_MEC_ME2_UCODE_DATA, le32_to_cpup(fw_data+i)); 4445 - WREG32(mmCP_MEC_ME2_UCODE_ADDR, adev->gfx.mec2_fw_version); 4446 - } 4447 - 4448 - return 0; 4449 4502 } 4450 4503 4451 4504 /* KIQ functions */ ··· 4727 4872 struct vi_mqd *mqd = ring->mqd_ptr; 4728 4873 int mqd_idx = ring - &adev->gfx.compute_ring[0]; 4729 4874 4730 - if (!adev->in_gpu_reset && !adev->gfx.in_suspend) { 4875 + if (!adev->in_gpu_reset && !adev->in_suspend) { 4731 4876 memset((void *)mqd, 0, sizeof(struct vi_mqd_allocation)); 4732 4877 ((struct vi_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF; 4733 4878 ((struct vi_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF; ··· 4834 4979 4835 4980 if (!(adev->flags & AMD_IS_APU)) 4836 4981 gfx_v8_0_enable_gui_idle_interrupt(adev, false); 4837 - 4838 - if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { 4839 - /* legacy firmware loading */ 4840 - r = gfx_v8_0_cp_gfx_load_microcode(adev); 4841 - if (r) 4842 - return r; 4843 - 4844 - r = gfx_v8_0_cp_compute_load_microcode(adev); 4845 - if (r) 4846 - return r; 4847 - } 4848 4982 4849 4983 r = gfx_v8_0_kiq_resume(adev); 4850 4984 if (r) ··· 4986 5142 4987 5143 static int gfx_v8_0_suspend(void *handle) 4988 5144 { 4989 - struct amdgpu_device *adev = (struct amdgpu_device *)handle; 4990 - adev->gfx.in_suspend = true; 4991 - return gfx_v8_0_hw_fini(adev); 5145 + return gfx_v8_0_hw_fini(handle); 4992 5146 } 4993 5147 4994 5148 static int gfx_v8_0_resume(void *handle) 4995 5149 { 4996 - int r; 4997 - struct amdgpu_device *adev = (struct amdgpu_device *)handle; 4998 - 4999 - r = gfx_v8_0_hw_init(adev); 5000 - adev->gfx.in_suspend = false; 5001 - return r; 5150 + return gfx_v8_0_hw_init(handle); 5002 5151 } 5003 5152 5004 5153 static bool gfx_v8_0_check_soft_reset(void *handle) ··· 6862 7025 return 0; 6863 7026 } 6864 7027 6865 - static int gfx_v8_0_kiq_set_interrupt_state(struct amdgpu_device *adev, 6866 - struct amdgpu_irq_src *src, 6867 - unsigned int type, 6868 - enum amdgpu_interrupt_state state) 6869 - { 6870 - struct amdgpu_ring *ring = &(adev->gfx.kiq.ring); 6871 - 6872 - switch (type) { 6873 - case AMDGPU_CP_KIQ_IRQ_DRIVER0: 6874 - WREG32_FIELD(CPC_INT_CNTL, GENERIC2_INT_ENABLE, 6875 - state == AMDGPU_IRQ_STATE_DISABLE ? 0 : 1); 6876 - if (ring->me == 1) 6877 - WREG32_FIELD_OFFSET(CP_ME1_PIPE0_INT_CNTL, 6878 - ring->pipe, 6879 - GENERIC2_INT_ENABLE, 6880 - state == AMDGPU_IRQ_STATE_DISABLE ? 0 : 1); 6881 - else 6882 - WREG32_FIELD_OFFSET(CP_ME2_PIPE0_INT_CNTL, 6883 - ring->pipe, 6884 - GENERIC2_INT_ENABLE, 6885 - state == AMDGPU_IRQ_STATE_DISABLE ? 0 : 1); 6886 - break; 6887 - default: 6888 - BUG(); /* kiq only support GENERIC2_INT now */ 6889 - break; 6890 - } 6891 - return 0; 6892 - } 6893 - 6894 - static int gfx_v8_0_kiq_irq(struct amdgpu_device *adev, 6895 - struct amdgpu_irq_src *source, 6896 - struct amdgpu_iv_entry *entry) 6897 - { 6898 - u8 me_id, pipe_id, queue_id; 6899 - struct amdgpu_ring *ring = &(adev->gfx.kiq.ring); 6900 - 6901 - me_id = (entry->ring_id & 0x0c) >> 2; 6902 - pipe_id = (entry->ring_id & 0x03) >> 0; 6903 - queue_id = (entry->ring_id & 0x70) >> 4; 6904 - DRM_DEBUG("IH: CPC GENERIC2_INT, me:%d, pipe:%d, queue:%d\n", 6905 - me_id, pipe_id, queue_id); 6906 - 6907 - amdgpu_fence_process(ring); 6908 - return 0; 6909 - } 6910 - 6911 7028 static const struct amd_ip_funcs gfx_v8_0_ip_funcs = { 6912 7029 .name = "gfx_v8_0", 6913 7030 .early_init = gfx_v8_0_early_init, ··· 7012 7221 .process = gfx_v8_0_priv_inst_irq, 7013 7222 }; 7014 7223 7015 - static const struct amdgpu_irq_src_funcs gfx_v8_0_kiq_irq_funcs = { 7016 - .set = gfx_v8_0_kiq_set_interrupt_state, 7017 - .process = gfx_v8_0_kiq_irq, 7018 - }; 7019 - 7020 7224 static const struct amdgpu_irq_src_funcs gfx_v8_0_cp_ecc_error_irq_funcs = { 7021 7225 .set = gfx_v8_0_set_cp_ecc_int_state, 7022 7226 .process = gfx_v8_0_cp_ecc_error_irq, ··· 7032 7246 7033 7247 adev->gfx.priv_inst_irq.num_types = 1; 7034 7248 adev->gfx.priv_inst_irq.funcs = &gfx_v8_0_priv_inst_irq_funcs; 7035 - 7036 - adev->gfx.kiq.irq.num_types = AMDGPU_CP_KIQ_IRQ_LAST; 7037 - adev->gfx.kiq.irq.funcs = &gfx_v8_0_kiq_irq_funcs; 7038 7249 7039 7250 adev->gfx.cp_ecc_error_irq.num_types = 1; 7040 7251 adev->gfx.cp_ecc_error_irq.funcs = &gfx_v8_0_cp_ecc_error_irq_funcs;
+126 -93
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
··· 133 133 SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000), 134 134 SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x01000107), 135 135 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x00001800, 0x00000800), 136 - SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080) 136 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080), 137 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800), 138 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800), 139 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000) 137 140 }; 138 141 139 142 static const struct soc15_reg_golden golden_settings_gc_9_0_vg20[] = ··· 176 173 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003120), 177 174 SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000), 178 175 SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000000ff), 179 - SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080) 176 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080), 177 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800), 178 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800), 179 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000) 180 180 }; 181 181 182 182 static const struct soc15_reg_golden golden_settings_gc_9_1_rv1[] = ··· 253 247 SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0xffff03ff, 0x01000107), 254 248 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000), 255 249 SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x76325410), 256 - SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01bd9f33, 0x01000000) 250 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01bd9f33, 0x01000000), 251 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800), 252 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800), 253 + SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000) 257 254 }; 258 255 259 256 static const u32 GFX_RLC_SRM_INDEX_CNTL_ADDR_OFFSETS[] = ··· 917 908 buffer[count++] = cpu_to_le32(0); 918 909 } 919 910 911 + static void gfx_v9_0_init_always_on_cu_mask(struct amdgpu_device *adev) 912 + { 913 + struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info; 914 + uint32_t pg_always_on_cu_num = 2; 915 + uint32_t always_on_cu_num; 916 + uint32_t i, j, k; 917 + uint32_t mask, cu_bitmap, counter; 918 + 919 + if (adev->flags & AMD_IS_APU) 920 + always_on_cu_num = 4; 921 + else if (adev->asic_type == CHIP_VEGA12) 922 + always_on_cu_num = 8; 923 + else 924 + always_on_cu_num = 12; 925 + 926 + mutex_lock(&adev->grbm_idx_mutex); 927 + for (i = 0; i < adev->gfx.config.max_shader_engines; i++) { 928 + for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) { 929 + mask = 1; 930 + cu_bitmap = 0; 931 + counter = 0; 932 + gfx_v9_0_select_se_sh(adev, i, j, 0xffffffff); 933 + 934 + for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) { 935 + if (cu_info->bitmap[i][j] & mask) { 936 + if (counter == pg_always_on_cu_num) 937 + WREG32_SOC15(GC, 0, mmRLC_PG_ALWAYS_ON_CU_MASK, cu_bitmap); 938 + if (counter < always_on_cu_num) 939 + cu_bitmap |= mask; 940 + else 941 + break; 942 + counter++; 943 + } 944 + mask <<= 1; 945 + } 946 + 947 + WREG32_SOC15(GC, 0, mmRLC_LB_ALWAYS_ACTIVE_CU_MASK, cu_bitmap); 948 + cu_info->ao_cu_bitmap[i][j] = cu_bitmap; 949 + } 950 + } 951 + gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); 952 + mutex_unlock(&adev->grbm_idx_mutex); 953 + } 954 + 920 955 static void gfx_v9_0_init_lbpw(struct amdgpu_device *adev) 921 956 { 922 957 uint32_t data; ··· 994 941 data |= 0x00C00000; 995 942 WREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7, data); 996 943 997 - /* set RLC_LB_ALWAYS_ACTIVE_CU_MASK = 0xFFF */ 998 - WREG32_SOC15(GC, 0, mmRLC_LB_ALWAYS_ACTIVE_CU_MASK, 0xFFF); 944 + /* 945 + * RLC_LB_ALWAYS_ACTIVE_CU_MASK = 0xF (4 CUs AON for Raven), 946 + * programmed in gfx_v9_0_init_always_on_cu_mask() 947 + */ 999 948 1000 949 /* set RLC_LB_CNTL = 0x8000_0095, 31 bit is reserved, 1001 950 * but used for RLC_LB_CNTL configuration */ ··· 1006 951 data |= REG_SET_FIELD(data, RLC_LB_CNTL, RESERVED, 0x80000); 1007 952 WREG32_SOC15(GC, 0, mmRLC_LB_CNTL, data); 1008 953 mutex_unlock(&adev->grbm_idx_mutex); 954 + 955 + gfx_v9_0_init_always_on_cu_mask(adev); 956 + } 957 + 958 + static void gfx_v9_4_init_lbpw(struct amdgpu_device *adev) 959 + { 960 + uint32_t data; 961 + 962 + /* set mmRLC_LB_THR_CONFIG_1/2/3/4 */ 963 + WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_1, 0x0000007F); 964 + WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_2, 0x033388F8); 965 + WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_3, 0x00000077); 966 + WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_4, (0x10 | 0x27 << 8 | 0x02FA << 16)); 967 + 968 + /* set mmRLC_LB_CNTR_INIT = 0x0000_0000 */ 969 + WREG32_SOC15(GC, 0, mmRLC_LB_CNTR_INIT, 0x00000000); 970 + 971 + /* set mmRLC_LB_CNTR_MAX = 0x0000_0500 */ 972 + WREG32_SOC15(GC, 0, mmRLC_LB_CNTR_MAX, 0x00000800); 973 + 974 + mutex_lock(&adev->grbm_idx_mutex); 975 + /* set mmRLC_LB_INIT_CU_MASK thru broadcast mode to enable all SE/SH*/ 976 + gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); 977 + WREG32_SOC15(GC, 0, mmRLC_LB_INIT_CU_MASK, 0xffffffff); 978 + 979 + /* set mmRLC_LB_PARAMS = 0x003F_1006 */ 980 + data = REG_SET_FIELD(0, RLC_LB_PARAMS, FIFO_SAMPLES, 0x0003); 981 + data |= REG_SET_FIELD(data, RLC_LB_PARAMS, PG_IDLE_SAMPLES, 0x0010); 982 + data |= REG_SET_FIELD(data, RLC_LB_PARAMS, PG_IDLE_SAMPLE_INTERVAL, 0x033F); 983 + WREG32_SOC15(GC, 0, mmRLC_LB_PARAMS, data); 984 + 985 + /* set mmRLC_GPM_GENERAL_7[31-16] = 0x00C0 */ 986 + data = RREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7); 987 + data &= 0x0000FFFF; 988 + data |= 0x00C00000; 989 + WREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7, data); 990 + 991 + /* 992 + * RLC_LB_ALWAYS_ACTIVE_CU_MASK = 0xFFF (12 CUs AON), 993 + * programmed in gfx_v9_0_init_always_on_cu_mask() 994 + */ 995 + 996 + /* set RLC_LB_CNTL = 0x8000_0095, 31 bit is reserved, 997 + * but used for RLC_LB_CNTL configuration */ 998 + data = RLC_LB_CNTL__LB_CNT_SPIM_ACTIVE_MASK; 999 + data |= REG_SET_FIELD(data, RLC_LB_CNTL, CU_MASK_USED_OFF_HYST, 0x09); 1000 + data |= REG_SET_FIELD(data, RLC_LB_CNTL, RESERVED, 0x80000); 1001 + WREG32_SOC15(GC, 0, mmRLC_LB_CNTL, data); 1002 + mutex_unlock(&adev->grbm_idx_mutex); 1003 + 1004 + gfx_v9_0_init_always_on_cu_mask(adev); 1009 1005 } 1010 1006 1011 1007 static void gfx_v9_0_enable_lbpw(struct amdgpu_device *adev, bool enable) ··· 1190 1084 rv_init_cp_jump_table(adev); 1191 1085 amdgpu_bo_kunmap(adev->gfx.rlc.cp_table_obj); 1192 1086 amdgpu_bo_unreserve(adev->gfx.rlc.cp_table_obj); 1087 + } 1193 1088 1089 + switch (adev->asic_type) { 1090 + case CHIP_RAVEN: 1194 1091 gfx_v9_0_init_lbpw(adev); 1092 + break; 1093 + case CHIP_VEGA20: 1094 + gfx_v9_4_init_lbpw(adev); 1095 + break; 1096 + default: 1097 + break; 1195 1098 } 1196 1099 1197 1100 return 0; ··· 1719 1604 1720 1605 adev->gfx.mec.num_pipe_per_mec = 4; 1721 1606 adev->gfx.mec.num_queue_per_pipe = 8; 1722 - 1723 - /* KIQ event */ 1724 - r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP, GFX_9_0__SRCID__CP_IB2_INTERRUPT_PKT, &adev->gfx.kiq.irq); 1725 - if (r) 1726 - return r; 1727 1607 1728 1608 /* EOP Event */ 1729 1609 r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP, GFX_9_0__SRCID__CP_EOP_INTERRUPT, &adev->gfx.eop_irq); ··· 2513 2403 return r; 2514 2404 } 2515 2405 2516 - if (adev->asic_type == CHIP_RAVEN) { 2406 + if (adev->asic_type == CHIP_RAVEN || 2407 + adev->asic_type == CHIP_VEGA20) { 2517 2408 if (amdgpu_lbpw != 0) 2518 2409 gfx_v9_0_enable_lbpw(adev, true); 2519 2410 else ··· 3202 3091 struct v9_mqd *mqd = ring->mqd_ptr; 3203 3092 int mqd_idx = ring - &adev->gfx.compute_ring[0]; 3204 3093 3205 - if (!adev->in_gpu_reset && !adev->gfx.in_suspend) { 3094 + if (!adev->in_gpu_reset && !adev->in_suspend) { 3206 3095 memset((void *)mqd, 0, sizeof(struct v9_mqd_allocation)); 3207 3096 ((struct v9_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF; 3208 3097 ((struct v9_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF; ··· 3421 3310 /* Use deinitialize sequence from CAIL when unbinding device from driver, 3422 3311 * otherwise KIQ is hanging when binding back 3423 3312 */ 3424 - if (!adev->in_gpu_reset && !adev->gfx.in_suspend) { 3313 + if (!adev->in_gpu_reset && !adev->in_suspend) { 3425 3314 mutex_lock(&adev->srbm_mutex); 3426 3315 soc15_grbm_select(adev, adev->gfx.kiq.ring.me, 3427 3316 adev->gfx.kiq.ring.pipe, ··· 3441 3330 3442 3331 static int gfx_v9_0_suspend(void *handle) 3443 3332 { 3444 - struct amdgpu_device *adev = (struct amdgpu_device *)handle; 3445 - 3446 - adev->gfx.in_suspend = true; 3447 - return gfx_v9_0_hw_fini(adev); 3333 + return gfx_v9_0_hw_fini(handle); 3448 3334 } 3449 3335 3450 3336 static int gfx_v9_0_resume(void *handle) 3451 3337 { 3452 - struct amdgpu_device *adev = (struct amdgpu_device *)handle; 3453 - int r; 3454 - 3455 - r = gfx_v9_0_hw_init(adev); 3456 - adev->gfx.in_suspend = false; 3457 - return r; 3338 + return gfx_v9_0_hw_init(handle); 3458 3339 } 3459 3340 3460 3341 static bool gfx_v9_0_is_idle(void *handle) ··· 4712 4609 return 0; 4713 4610 } 4714 4611 4715 - static int gfx_v9_0_kiq_set_interrupt_state(struct amdgpu_device *adev, 4716 - struct amdgpu_irq_src *src, 4717 - unsigned int type, 4718 - enum amdgpu_interrupt_state state) 4719 - { 4720 - uint32_t tmp, target; 4721 - struct amdgpu_ring *ring = &(adev->gfx.kiq.ring); 4722 - 4723 - if (ring->me == 1) 4724 - target = SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE0_INT_CNTL); 4725 - else 4726 - target = SOC15_REG_OFFSET(GC, 0, mmCP_ME2_PIPE0_INT_CNTL); 4727 - target += ring->pipe; 4728 - 4729 - switch (type) { 4730 - case AMDGPU_CP_KIQ_IRQ_DRIVER0: 4731 - if (state == AMDGPU_IRQ_STATE_DISABLE) { 4732 - tmp = RREG32_SOC15(GC, 0, mmCPC_INT_CNTL); 4733 - tmp = REG_SET_FIELD(tmp, CPC_INT_CNTL, 4734 - GENERIC2_INT_ENABLE, 0); 4735 - WREG32_SOC15(GC, 0, mmCPC_INT_CNTL, tmp); 4736 - 4737 - tmp = RREG32(target); 4738 - tmp = REG_SET_FIELD(tmp, CP_ME2_PIPE0_INT_CNTL, 4739 - GENERIC2_INT_ENABLE, 0); 4740 - WREG32(target, tmp); 4741 - } else { 4742 - tmp = RREG32_SOC15(GC, 0, mmCPC_INT_CNTL); 4743 - tmp = REG_SET_FIELD(tmp, CPC_INT_CNTL, 4744 - GENERIC2_INT_ENABLE, 1); 4745 - WREG32_SOC15(GC, 0, mmCPC_INT_CNTL, tmp); 4746 - 4747 - tmp = RREG32(target); 4748 - tmp = REG_SET_FIELD(tmp, CP_ME2_PIPE0_INT_CNTL, 4749 - GENERIC2_INT_ENABLE, 1); 4750 - WREG32(target, tmp); 4751 - } 4752 - break; 4753 - default: 4754 - BUG(); /* kiq only support GENERIC2_INT now */ 4755 - break; 4756 - } 4757 - return 0; 4758 - } 4759 - 4760 - static int gfx_v9_0_kiq_irq(struct amdgpu_device *adev, 4761 - struct amdgpu_irq_src *source, 4762 - struct amdgpu_iv_entry *entry) 4763 - { 4764 - u8 me_id, pipe_id, queue_id; 4765 - struct amdgpu_ring *ring = &(adev->gfx.kiq.ring); 4766 - 4767 - me_id = (entry->ring_id & 0x0c) >> 2; 4768 - pipe_id = (entry->ring_id & 0x03) >> 0; 4769 - queue_id = (entry->ring_id & 0x70) >> 4; 4770 - DRM_DEBUG("IH: CPC GENERIC2_INT, me:%d, pipe:%d, queue:%d\n", 4771 - me_id, pipe_id, queue_id); 4772 - 4773 - amdgpu_fence_process(ring); 4774 - return 0; 4775 - } 4776 - 4777 4612 static const struct amd_ip_funcs gfx_v9_0_ip_funcs = { 4778 4613 .name = "gfx_v9_0", 4779 4614 .early_init = gfx_v9_0_early_init, ··· 4860 4819 adev->gfx.compute_ring[i].funcs = &gfx_v9_0_ring_funcs_compute; 4861 4820 } 4862 4821 4863 - static const struct amdgpu_irq_src_funcs gfx_v9_0_kiq_irq_funcs = { 4864 - .set = gfx_v9_0_kiq_set_interrupt_state, 4865 - .process = gfx_v9_0_kiq_irq, 4866 - }; 4867 - 4868 4822 static const struct amdgpu_irq_src_funcs gfx_v9_0_eop_irq_funcs = { 4869 4823 .set = gfx_v9_0_set_eop_interrupt_state, 4870 4824 .process = gfx_v9_0_eop_irq, ··· 4885 4849 4886 4850 adev->gfx.priv_inst_irq.num_types = 1; 4887 4851 adev->gfx.priv_inst_irq.funcs = &gfx_v9_0_priv_inst_irq_funcs; 4888 - 4889 - adev->gfx.kiq.irq.num_types = AMDGPU_CP_KIQ_IRQ_LAST; 4890 - adev->gfx.kiq.irq.funcs = &gfx_v9_0_kiq_irq_funcs; 4891 4852 } 4892 4853 4893 4854 static void gfx_v9_0_set_rlc_funcs(struct amdgpu_device *adev)
-3
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
··· 306 306 enum psp_ring_type ring_type) 307 307 { 308 308 int ret = 0; 309 - struct psp_ring *ring; 310 309 struct amdgpu_device *adev = psp->adev; 311 - 312 - ring = &psp->km_ring; 313 310 314 311 /* Write the ring destroy command to C2PMSG_64 */ 315 312 WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_64, GFX_CTRL_CMD_ID_DESTROY_RINGS);
-42
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
··· 504 504 return 0; 505 505 } 506 506 507 - /** 508 - * sdma_v2_4_load_microcode - load the sDMA ME ucode 509 - * 510 - * @adev: amdgpu_device pointer 511 - * 512 - * Loads the sDMA0/1 ucode. 513 - * Returns 0 for success, -EINVAL if the ucode is not available. 514 - */ 515 - static int sdma_v2_4_load_microcode(struct amdgpu_device *adev) 516 - { 517 - const struct sdma_firmware_header_v1_0 *hdr; 518 - const __le32 *fw_data; 519 - u32 fw_size; 520 - int i, j; 521 - 522 - /* halt the MEs */ 523 - sdma_v2_4_enable(adev, false); 524 - 525 - for (i = 0; i < adev->sdma.num_instances; i++) { 526 - if (!adev->sdma.instance[i].fw) 527 - return -EINVAL; 528 - hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma.instance[i].fw->data; 529 - amdgpu_ucode_print_sdma_hdr(&hdr->header); 530 - fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; 531 - fw_data = (const __le32 *) 532 - (adev->sdma.instance[i].fw->data + 533 - le32_to_cpu(hdr->header.ucode_array_offset_bytes)); 534 - WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], 0); 535 - for (j = 0; j < fw_size; j++) 536 - WREG32(mmSDMA0_UCODE_DATA + sdma_offsets[i], le32_to_cpup(fw_data++)); 537 - WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], adev->sdma.instance[i].fw_version); 538 - } 539 - 540 - return 0; 541 - } 542 507 543 508 /** 544 509 * sdma_v2_4_start - setup and start the async dma engines ··· 516 551 static int sdma_v2_4_start(struct amdgpu_device *adev) 517 552 { 518 553 int r; 519 - 520 - 521 - if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { 522 - r = sdma_v2_4_load_microcode(adev); 523 - if (r) 524 - return r; 525 - } 526 554 527 555 /* halt the engine before programing */ 528 556 sdma_v2_4_enable(adev, false);
+7 -50
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
··· 318 318 if (adev->sdma.instance[i].feature_version >= 20) 319 319 adev->sdma.instance[i].burst_nop = true; 320 320 321 - if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { 322 - info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i]; 323 - info->ucode_id = AMDGPU_UCODE_ID_SDMA0 + i; 324 - info->fw = adev->sdma.instance[i].fw; 325 - header = (const struct common_firmware_header *)info->fw->data; 326 - adev->firmware.fw_size += 327 - ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 328 - } 321 + info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i]; 322 + info->ucode_id = AMDGPU_UCODE_ID_SDMA0 + i; 323 + info->fw = adev->sdma.instance[i].fw; 324 + header = (const struct common_firmware_header *)info->fw->data; 325 + adev->firmware.fw_size += 326 + ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); 327 + 329 328 } 330 329 out: 331 330 if (err) { ··· 777 778 } 778 779 779 780 /** 780 - * sdma_v3_0_load_microcode - load the sDMA ME ucode 781 - * 782 - * @adev: amdgpu_device pointer 783 - * 784 - * Loads the sDMA0/1 ucode. 785 - * Returns 0 for success, -EINVAL if the ucode is not available. 786 - */ 787 - static int sdma_v3_0_load_microcode(struct amdgpu_device *adev) 788 - { 789 - const struct sdma_firmware_header_v1_0 *hdr; 790 - const __le32 *fw_data; 791 - u32 fw_size; 792 - int i, j; 793 - 794 - /* halt the MEs */ 795 - sdma_v3_0_enable(adev, false); 796 - 797 - for (i = 0; i < adev->sdma.num_instances; i++) { 798 - if (!adev->sdma.instance[i].fw) 799 - return -EINVAL; 800 - hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma.instance[i].fw->data; 801 - amdgpu_ucode_print_sdma_hdr(&hdr->header); 802 - fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; 803 - fw_data = (const __le32 *) 804 - (adev->sdma.instance[i].fw->data + 805 - le32_to_cpu(hdr->header.ucode_array_offset_bytes)); 806 - WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], 0); 807 - for (j = 0; j < fw_size; j++) 808 - WREG32(mmSDMA0_UCODE_DATA + sdma_offsets[i], le32_to_cpup(fw_data++)); 809 - WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], adev->sdma.instance[i].fw_version); 810 - } 811 - 812 - return 0; 813 - } 814 - 815 - /** 816 781 * sdma_v3_0_start - setup and start the async dma engines 817 782 * 818 783 * @adev: amdgpu_device pointer ··· 787 824 static int sdma_v3_0_start(struct amdgpu_device *adev) 788 825 { 789 826 int r; 790 - 791 - if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { 792 - r = sdma_v3_0_load_microcode(adev); 793 - if (r) 794 - return r; 795 - } 796 827 797 828 /* disable sdma engine before programing it */ 798 829 sdma_v3_0_ctx_switch_enable(adev, false);
+7 -1
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
··· 818 818 uint32_t def, data; 819 819 820 820 if (enable && (adev->pg_flags & AMD_PG_SUPPORT_SDMA)) { 821 - /* disable idle interrupt */ 821 + /* enable idle interrupt */ 822 822 def = data = RREG32(SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_CNTL)); 823 823 data |= SDMA0_CNTL__CTXEMPTY_INT_ENABLE_MASK; 824 824 ··· 1364 1364 int r; 1365 1365 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1366 1366 1367 + if (adev->asic_type == CHIP_RAVEN && adev->powerplay.pp_funcs->set_powergating_by_smu) 1368 + amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_SDMA, false); 1369 + 1367 1370 sdma_v4_0_init_golden_registers(adev); 1368 1371 1369 1372 r = sdma_v4_0_start(adev); ··· 1383 1380 1384 1381 sdma_v4_0_ctx_switch_enable(adev, false); 1385 1382 sdma_v4_0_enable(adev, false); 1383 + 1384 + if (adev->asic_type == CHIP_RAVEN && adev->powerplay.pp_funcs->set_powergating_by_smu) 1385 + amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_SDMA, true); 1386 1386 1387 1387 return 0; 1388 1388 }
+7 -6
drivers/gpu/drm/amd/amdgpu/si.c
··· 2057 2057 amdgpu_device_ip_block_add(adev, &si_common_ip_block); 2058 2058 amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 2059 2059 amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 2060 + amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 2061 + amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2060 2062 amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2061 2063 if (adev->enable_virtual_display) 2062 2064 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 2063 2065 else 2064 2066 amdgpu_device_ip_block_add(adev, &dce_v6_0_ip_block); 2065 - amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 2066 - amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2067 2067 /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ 2068 2068 /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ 2069 2069 break; ··· 2071 2071 amdgpu_device_ip_block_add(adev, &si_common_ip_block); 2072 2072 amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 2073 2073 amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 2074 + amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 2075 + amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2074 2076 amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2075 2077 if (adev->enable_virtual_display) 2076 2078 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 2077 2079 else 2078 2080 amdgpu_device_ip_block_add(adev, &dce_v6_4_ip_block); 2079 - amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 2080 - amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2081 + 2081 2082 /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ 2082 2083 /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ 2083 2084 break; ··· 2086 2085 amdgpu_device_ip_block_add(adev, &si_common_ip_block); 2087 2086 amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); 2088 2087 amdgpu_device_ip_block_add(adev, &si_ih_ip_block); 2088 + amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 2089 + amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2089 2090 amdgpu_device_ip_block_add(adev, &si_smu_ip_block); 2090 2091 if (adev->enable_virtual_display) 2091 2092 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 2092 - amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); 2093 - amdgpu_device_ip_block_add(adev, &si_dma_ip_block); 2094 2093 break; 2095 2094 default: 2096 2095 BUG();
+8 -19
drivers/gpu/drm/amd/amdgpu/si_dma.c
··· 502 502 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 503 503 504 504 /* DMA0 trap event */ 505 - r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 224, &adev->sdma.trap_irq); 505 + r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 224, 506 + &adev->sdma.trap_irq); 506 507 if (r) 507 508 return r; 508 509 509 510 /* DMA1 trap event */ 510 - r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 244, &adev->sdma.trap_irq_1); 511 + r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 244, 512 + &adev->sdma.trap_irq); 511 513 if (r) 512 514 return r; 513 515 ··· 651 649 struct amdgpu_irq_src *source, 652 650 struct amdgpu_iv_entry *entry) 653 651 { 654 - amdgpu_fence_process(&adev->sdma.instance[0].ring); 655 - 656 - return 0; 657 - } 658 - 659 - static int si_dma_process_trap_irq_1(struct amdgpu_device *adev, 660 - struct amdgpu_irq_src *source, 661 - struct amdgpu_iv_entry *entry) 662 - { 663 - amdgpu_fence_process(&adev->sdma.instance[1].ring); 664 - 652 + if (entry->src_id == 224) 653 + amdgpu_fence_process(&adev->sdma.instance[0].ring); 654 + else 655 + amdgpu_fence_process(&adev->sdma.instance[1].ring); 665 656 return 0; 666 657 } 667 658 ··· 781 786 .process = si_dma_process_trap_irq, 782 787 }; 783 788 784 - static const struct amdgpu_irq_src_funcs si_dma_trap_irq_funcs_1 = { 785 - .set = si_dma_set_trap_irq_state, 786 - .process = si_dma_process_trap_irq_1, 787 - }; 788 - 789 789 static const struct amdgpu_irq_src_funcs si_dma_illegal_inst_irq_funcs = { 790 790 .process = si_dma_process_illegal_inst_irq, 791 791 }; ··· 789 799 { 790 800 adev->sdma.trap_irq.num_types = AMDGPU_SDMA_IRQ_LAST; 791 801 adev->sdma.trap_irq.funcs = &si_dma_trap_irq_funcs; 792 - adev->sdma.trap_irq_1.funcs = &si_dma_trap_irq_funcs_1; 793 802 adev->sdma.illegal_inst_irq.funcs = &si_dma_illegal_inst_irq_funcs; 794 803 } 795 804
+4 -4
drivers/gpu/drm/amd/amdgpu/soc15.c
··· 529 529 amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); 530 530 else 531 531 amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block); 532 + amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block); 533 + amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); 532 534 if (!amdgpu_sriov_vf(adev)) 533 535 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 534 536 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) ··· 541 539 #else 542 540 # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." 543 541 #endif 544 - amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block); 545 - amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); 546 542 if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev))) { 547 543 amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block); 548 544 amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block); ··· 551 551 amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); 552 552 amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block); 553 553 amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block); 554 + amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block); 555 + amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); 554 556 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 555 557 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) 556 558 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); ··· 562 560 #else 563 561 # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." 564 562 #endif 565 - amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block); 566 - amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); 567 563 amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block); 568 564 break; 569 565 default:
+3 -7
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
··· 274 274 */ 275 275 static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring, 276 276 uint32_t handle, 277 - bool direct, struct dma_fence **fence) 277 + struct dma_fence **fence) 278 278 { 279 279 const unsigned ib_size_dw = 16; 280 280 struct amdgpu_job *job; ··· 310 310 for (i = ib->length_dw; i < ib_size_dw; ++i) 311 311 ib->ptr[i] = 0x0; 312 312 313 - if (direct) 314 - r = amdgpu_job_submit_direct(job, ring, &f); 315 - else 316 - r = amdgpu_job_submit(job, &ring->adev->vce.entity, 317 - AMDGPU_FENCE_OWNER_UNDEFINED, &f); 313 + r = amdgpu_job_submit_direct(job, ring, &f); 318 314 if (r) 319 315 goto err; 320 316 ··· 341 345 goto error; 342 346 } 343 347 344 - r = uvd_v6_0_enc_get_destroy_msg(ring, 1, true, &fence); 348 + r = uvd_v6_0_enc_get_destroy_msg(ring, 1, &fence); 345 349 if (r) { 346 350 DRM_ERROR("amdgpu: failed to get destroy ib (%ld).\n", r); 347 351 goto error;
+4 -8
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
··· 280 280 * 281 281 * Close up a stream for HW test or if userspace failed to do so 282 282 */ 283 - int uvd_v7_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, 284 - bool direct, struct dma_fence **fence) 283 + static int uvd_v7_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, 284 + struct dma_fence **fence) 285 285 { 286 286 const unsigned ib_size_dw = 16; 287 287 struct amdgpu_job *job; ··· 317 317 for (i = ib->length_dw; i < ib_size_dw; ++i) 318 318 ib->ptr[i] = 0x0; 319 319 320 - if (direct) 321 - r = amdgpu_job_submit_direct(job, ring, &f); 322 - else 323 - r = amdgpu_job_submit(job, &ring->adev->vce.entity, 324 - AMDGPU_FENCE_OWNER_UNDEFINED, &f); 320 + r = amdgpu_job_submit_direct(job, ring, &f); 325 321 if (r) 326 322 goto err; 327 323 ··· 348 352 goto error; 349 353 } 350 354 351 - r = uvd_v7_0_enc_get_destroy_msg(ring, 1, true, &fence); 355 + r = uvd_v7_0_enc_get_destroy_msg(ring, 1, &fence); 352 356 if (r) { 353 357 DRM_ERROR("amdgpu: (%d)failed to get destroy ib (%ld).\n", ring->me, r); 354 358 goto error;
+33 -20
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
··· 278 278 uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->vcn.fw->size + 4); 279 279 uint32_t offset; 280 280 281 + /* cache window 0: fw */ 281 282 if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { 282 283 WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, 283 284 (adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].tmr_mc_addr_lo)); ··· 298 297 299 298 WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE0, size); 300 299 300 + /* cache window 1: stack */ 301 301 WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW, 302 302 lower_32_bits(adev->vcn.gpu_addr + offset)); 303 303 WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH, 304 304 upper_32_bits(adev->vcn.gpu_addr + offset)); 305 305 WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_OFFSET1, 0); 306 - WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_VCN_HEAP_SIZE); 306 + WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_VCN_STACK_SIZE); 307 307 308 + /* cache window 2: context */ 308 309 WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW, 309 - lower_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE)); 310 + lower_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_STACK_SIZE)); 310 311 WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH, 311 - upper_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE)); 312 + upper_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_STACK_SIZE)); 312 313 WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_OFFSET2, 0); 313 - WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, 314 - AMDGPU_VCN_STACK_SIZE + (AMDGPU_VCN_SESSION_SIZE * 40)); 314 + WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, AMDGPU_VCN_CONTEXT_SIZE); 315 315 316 316 WREG32_SOC15(UVD, 0, mmUVD_UDEC_ADDR_CONFIG, 317 317 adev->gfx.config.gb_addr_config); ··· 327 325 uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->vcn.fw->size + 4); 328 326 uint32_t offset; 329 327 328 + /* cache window 0: fw */ 330 329 if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { 331 330 WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, 332 331 (adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].tmr_mc_addr_lo), ··· 350 347 351 348 WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE0, size, 0xFFFFFFFF, 0); 352 349 350 + /* cache window 1: stack */ 353 351 WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW, 354 352 lower_32_bits(adev->vcn.gpu_addr + offset), 0xFFFFFFFF, 0); 355 353 WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH, 356 354 upper_32_bits(adev->vcn.gpu_addr + offset), 0xFFFFFFFF, 0); 357 355 WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET1, 0, 358 356 0xFFFFFFFF, 0); 359 - WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_VCN_HEAP_SIZE, 357 + WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_VCN_STACK_SIZE, 360 358 0xFFFFFFFF, 0); 361 359 360 + /* cache window 2: context */ 362 361 WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW, 363 - lower_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE), 362 + lower_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_STACK_SIZE), 364 363 0xFFFFFFFF, 0); 365 364 WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH, 366 - upper_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE), 365 + upper_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_STACK_SIZE), 367 366 0xFFFFFFFF, 0); 368 367 WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET2, 0, 0xFFFFFFFF, 0); 369 - WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, 370 - AMDGPU_VCN_STACK_SIZE + (AMDGPU_VCN_SESSION_SIZE * 40), 368 + WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, AMDGPU_VCN_CONTEXT_SIZE, 371 369 0xFFFFFFFF, 0); 372 370 373 371 WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_UDEC_ADDR_CONFIG, ··· 605 601 reg_data = 0 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; 606 602 reg_data |= 1 << UVD_CGC_CTRL__CLK_GATE_DLY_TIMER__SHIFT; 607 603 reg_data |= 4 << UVD_CGC_CTRL__CLK_OFF_DELAY__SHIFT; 608 - WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_CGC_CTRL, reg_data, 0xFFFFFFFF, sram_sel); 609 - 610 604 reg_data &= ~(UVD_CGC_CTRL__UDEC_RE_MODE_MASK | 611 605 UVD_CGC_CTRL__UDEC_CM_MODE_MASK | 612 606 UVD_CGC_CTRL__UDEC_IT_MODE_MASK | ··· 814 812 815 813 for (j = 0; j < 100; ++j) { 816 814 status = RREG32_SOC15(UVD, 0, mmUVD_STATUS); 817 - if (status & 2) 815 + if (status & UVD_STATUS__IDLE) 818 816 break; 819 817 mdelay(10); 820 818 } 821 819 r = 0; 822 - if (status & 2) 820 + if (status & UVD_STATUS__IDLE) 823 821 break; 824 822 825 823 DRM_ERROR("VCN decode not responding, trying to reset the VCPU!!!\n"); ··· 877 875 /* Initialize the ring buffer's read and write pointers */ 878 876 WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR, 0); 879 877 878 + WREG32_SOC15(UVD, 0, mmUVD_SCRATCH2, 0); 879 + 880 880 ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR); 881 881 WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, 882 882 lower_32_bits(ring->wptr)); ··· 902 898 903 899 ring = &adev->vcn.ring_jpeg; 904 900 WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_VMID, 0); 905 - WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, (0x00000001L | 0x00000002L)); 901 + WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, UVD_JRBC_RB_CNTL__RB_NO_FETCH_MASK | 902 + UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK); 906 903 WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_LOW, lower_32_bits(ring->gpu_addr)); 907 904 WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_HIGH, upper_32_bits(ring->gpu_addr)); 908 905 WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_RPTR, 0); 909 906 WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR, 0); 910 - WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 0x00000002L); 907 + WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK); 911 908 912 909 /* initialize wptr */ 913 910 ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR); ··· 1056 1051 /* Initialize the ring buffer's read and write pointers */ 1057 1052 WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR, 0); 1058 1053 1054 + WREG32_SOC15(UVD, 0, mmUVD_SCRATCH2, 0); 1055 + 1059 1056 ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR); 1060 1057 WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, 1061 1058 lower_32_bits(ring->wptr)); ··· 1127 1120 { 1128 1121 int ret_code; 1129 1122 1130 - /* Wait for power status to be 1 */ 1131 - SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, 0x1, 1123 + /* Wait for power status to be UVD_POWER_STATUS__UVD_POWER_STATUS_TILES_OFF */ 1124 + SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, 1125 + UVD_POWER_STATUS__UVD_POWER_STATUS_TILES_OFF, 1132 1126 UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); 1133 1127 1134 1128 /* disable dynamic power gating mode */ ··· 1155 1147 { 1156 1148 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1157 1149 1158 - return (RREG32_SOC15(VCN, 0, mmUVD_STATUS) == 0x2); 1150 + return (RREG32_SOC15(VCN, 0, mmUVD_STATUS) == UVD_STATUS__IDLE); 1159 1151 } 1160 1152 1161 1153 static int vcn_v1_0_wait_for_idle(void *handle) ··· 1163 1155 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1164 1156 int ret = 0; 1165 1157 1166 - SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_STATUS, 0x2, 0x2, ret); 1158 + SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_STATUS, UVD_STATUS__IDLE, 1159 + UVD_STATUS__IDLE, ret); 1167 1160 1168 1161 return ret; 1169 1162 } ··· 1225 1216 static void vcn_v1_0_dec_ring_set_wptr(struct amdgpu_ring *ring) 1226 1217 { 1227 1218 struct amdgpu_device *adev = ring->adev; 1219 + 1220 + if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) 1221 + WREG32_SOC15(UVD, 0, mmUVD_SCRATCH2, 1222 + lower_32_bits(ring->wptr) | 0x80000000); 1228 1223 1229 1224 WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr)); 1230 1225 }
+12 -12
drivers/gpu/drm/amd/amdgpu/vi.c
··· 1596 1596 amdgpu_device_ip_block_add(adev, &vi_common_ip_block); 1597 1597 amdgpu_device_ip_block_add(adev, &gmc_v7_4_ip_block); 1598 1598 amdgpu_device_ip_block_add(adev, &iceland_ih_ip_block); 1599 + amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1600 + amdgpu_device_ip_block_add(adev, &sdma_v2_4_ip_block); 1599 1601 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 1600 1602 if (adev->enable_virtual_display) 1601 1603 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); 1602 - amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1603 - amdgpu_device_ip_block_add(adev, &sdma_v2_4_ip_block); 1604 1604 break; 1605 1605 case CHIP_FIJI: 1606 1606 amdgpu_device_ip_block_add(adev, &vi_common_ip_block); 1607 1607 amdgpu_device_ip_block_add(adev, &gmc_v8_5_ip_block); 1608 1608 amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block); 1609 + amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1610 + amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 1609 1611 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 1610 1612 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) 1611 1613 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); ··· 1617 1615 #endif 1618 1616 else 1619 1617 amdgpu_device_ip_block_add(adev, &dce_v10_1_ip_block); 1620 - amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1621 - amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 1622 1618 if (!amdgpu_sriov_vf(adev)) { 1623 1619 amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block); 1624 1620 amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block); ··· 1626 1626 amdgpu_device_ip_block_add(adev, &vi_common_ip_block); 1627 1627 amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); 1628 1628 amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block); 1629 + amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1630 + amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 1629 1631 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 1630 1632 if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) 1631 1633 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); ··· 1637 1635 #endif 1638 1636 else 1639 1637 amdgpu_device_ip_block_add(adev, &dce_v10_0_ip_block); 1640 - amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1641 - amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 1642 1638 if (!amdgpu_sriov_vf(adev)) { 1643 1639 amdgpu_device_ip_block_add(adev, &uvd_v5_0_ip_block); 1644 1640 amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block); ··· 1649 1649 amdgpu_device_ip_block_add(adev, &vi_common_ip_block); 1650 1650 amdgpu_device_ip_block_add(adev, &gmc_v8_1_ip_block); 1651 1651 amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block); 1652 + amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1653 + amdgpu_device_ip_block_add(adev, &sdma_v3_1_ip_block); 1652 1654 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 1653 1655 if (adev->enable_virtual_display) 1654 1656 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); ··· 1660 1658 #endif 1661 1659 else 1662 1660 amdgpu_device_ip_block_add(adev, &dce_v11_2_ip_block); 1663 - amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1664 - amdgpu_device_ip_block_add(adev, &sdma_v3_1_ip_block); 1665 1661 amdgpu_device_ip_block_add(adev, &uvd_v6_3_ip_block); 1666 1662 amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block); 1667 1663 break; ··· 1667 1667 amdgpu_device_ip_block_add(adev, &vi_common_ip_block); 1668 1668 amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); 1669 1669 amdgpu_device_ip_block_add(adev, &cz_ih_ip_block); 1670 + amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1671 + amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 1670 1672 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 1671 1673 if (adev->enable_virtual_display) 1672 1674 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); ··· 1678 1676 #endif 1679 1677 else 1680 1678 amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block); 1681 - amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); 1682 - amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 1683 1679 amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block); 1684 1680 amdgpu_device_ip_block_add(adev, &vce_v3_1_ip_block); 1685 1681 #if defined(CONFIG_DRM_AMD_ACP) ··· 1688 1688 amdgpu_device_ip_block_add(adev, &vi_common_ip_block); 1689 1689 amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); 1690 1690 amdgpu_device_ip_block_add(adev, &cz_ih_ip_block); 1691 + amdgpu_device_ip_block_add(adev, &gfx_v8_1_ip_block); 1692 + amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 1691 1693 amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); 1692 1694 if (adev->enable_virtual_display) 1693 1695 amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); ··· 1699 1697 #endif 1700 1698 else 1701 1699 amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block); 1702 - amdgpu_device_ip_block_add(adev, &gfx_v8_1_ip_block); 1703 - amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); 1704 1700 amdgpu_device_ip_block_add(adev, &uvd_v6_2_ip_block); 1705 1701 amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block); 1706 1702 #if defined(CONFIG_DRM_AMD_ACP)
+29 -11
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
··· 358 358 struct queue *q, 359 359 struct qcm_process_device *qpd) 360 360 { 361 - int retval; 362 361 struct mqd_manager *mqd_mgr; 362 + int retval; 363 363 364 364 mqd_mgr = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE); 365 365 if (!mqd_mgr) ··· 387 387 if (!q->properties.is_active) 388 388 return 0; 389 389 390 - retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, q->queue, 391 - &q->properties, q->process->mm); 390 + if (WARN(q->process->mm != current->mm, 391 + "should only run in user thread")) 392 + retval = -EFAULT; 393 + else 394 + retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, q->queue, 395 + &q->properties, current->mm); 392 396 if (retval) 393 397 goto out_uninit_mqd; 394 398 ··· 549 545 retval = map_queues_cpsch(dqm); 550 546 else if (q->properties.is_active && 551 547 (q->properties.type == KFD_QUEUE_TYPE_COMPUTE || 552 - q->properties.type == KFD_QUEUE_TYPE_SDMA)) 553 - retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, q->queue, 554 - &q->properties, q->process->mm); 548 + q->properties.type == KFD_QUEUE_TYPE_SDMA)) { 549 + if (WARN(q->process->mm != current->mm, 550 + "should only run in user thread")) 551 + retval = -EFAULT; 552 + else 553 + retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, 554 + q->pipe, q->queue, 555 + &q->properties, current->mm); 556 + } 555 557 556 558 out_unlock: 557 559 dqm_unlock(dqm); ··· 663 653 static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, 664 654 struct qcm_process_device *qpd) 665 655 { 656 + struct mm_struct *mm = NULL; 666 657 struct queue *q; 667 658 struct mqd_manager *mqd_mgr; 668 659 struct kfd_process_device *pdd; ··· 697 686 kfd_flush_tlb(pdd); 698 687 } 699 688 689 + /* Take a safe reference to the mm_struct, which may otherwise 690 + * disappear even while the kfd_process is still referenced. 691 + */ 692 + mm = get_task_mm(pdd->process->lead_thread); 693 + if (!mm) { 694 + retval = -EFAULT; 695 + goto out; 696 + } 697 + 700 698 /* activate all active queues on the qpd */ 701 699 list_for_each_entry(q, &qpd->queues_list, list) { 702 700 if (!q->properties.is_evicted) ··· 720 700 q->properties.is_evicted = false; 721 701 q->properties.is_active = true; 722 702 retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, 723 - q->queue, &q->properties, 724 - q->process->mm); 703 + q->queue, &q->properties, mm); 725 704 if (retval) 726 705 goto out; 727 706 dqm->queue_count++; 728 707 } 729 708 qpd->evicted = 0; 730 709 out: 710 + if (mm) 711 + mmput(mm); 731 712 dqm_unlock(dqm); 732 713 return retval; 733 714 } ··· 1364 1343 { 1365 1344 int retval; 1366 1345 struct mqd_manager *mqd_mgr; 1367 - bool preempt_all_queues; 1368 - 1369 - preempt_all_queues = false; 1370 1346 1371 1347 retval = 0; 1372 1348
+8 -2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 4740 4740 } 4741 4741 spin_unlock_irqrestore(&adev->ddev->event_lock, flags); 4742 4742 4743 - /* Signal HW programming completion */ 4744 - drm_atomic_helper_commit_hw_done(state); 4745 4743 4746 4744 if (wait_for_vblank) 4747 4745 drm_atomic_helper_wait_for_flip_done(dev, state); 4746 + 4747 + /* 4748 + * FIXME: 4749 + * Delay hw_done() until flip_done() is signaled. This is to block 4750 + * another commit from freeing the CRTC state while we're still 4751 + * waiting on flip_done. 4752 + */ 4753 + drm_atomic_helper_commit_hw_done(state); 4748 4754 4749 4755 drm_atomic_helper_cleanup_planes(dev, state); 4750 4756
+14 -23
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
··· 36 36 * Private declarations. 37 37 *****************************************************************************/ 38 38 39 - struct handler_common_data { 39 + struct amdgpu_dm_irq_handler_data { 40 40 struct list_head list; 41 41 interrupt_handler handler; 42 42 void *handler_arg; 43 43 44 44 /* DM which this handler belongs to */ 45 45 struct amdgpu_display_manager *dm; 46 - }; 47 - 48 - struct amdgpu_dm_irq_handler_data { 49 - struct handler_common_data hcd; 50 46 /* DAL irq source which registered for this interrupt. */ 51 47 enum dc_irq_source irq_source; 52 48 }; ··· 57 61 * Private functions. 58 62 *****************************************************************************/ 59 63 60 - static void init_handler_common_data(struct handler_common_data *hcd, 64 + static void init_handler_common_data(struct amdgpu_dm_irq_handler_data *hcd, 61 65 void (*ih)(void *), 62 66 void *args, 63 67 struct amdgpu_display_manager *dm) ··· 81 85 struct amdgpu_dm_irq_handler_data *handler_data; 82 86 83 87 list_for_each(entry, handler_list) { 84 - handler_data = 85 - list_entry( 86 - entry, 87 - struct amdgpu_dm_irq_handler_data, 88 - hcd.list); 88 + handler_data = list_entry(entry, 89 + struct amdgpu_dm_irq_handler_data, 90 + list); 89 91 90 92 DRM_DEBUG_KMS("DM_IRQ: work_func: for dal_src=%d\n", 91 93 handler_data->irq_source); ··· 91 97 DRM_DEBUG_KMS("DM_IRQ: schedule_work: for dal_src=%d\n", 92 98 handler_data->irq_source); 93 99 94 - handler_data->hcd.handler(handler_data->hcd.handler_arg); 100 + handler_data->handler(handler_data->handler_arg); 95 101 } 96 102 97 103 /* Call a DAL subcomponent which registered for interrupt notification ··· 131 137 list_for_each_safe(entry, tmp, hnd_list) { 132 138 133 139 handler = list_entry(entry, struct amdgpu_dm_irq_handler_data, 134 - hcd.list); 140 + list); 135 141 136 142 if (ih == handler) { 137 143 /* Found our handler. Remove it from the list. */ 138 - list_del(&handler->hcd.list); 144 + list_del(&handler->list); 139 145 handler_removed = true; 140 146 break; 141 147 } ··· 224 230 225 231 memset(handler_data, 0, sizeof(*handler_data)); 226 232 227 - init_handler_common_data(&handler_data->hcd, ih, handler_args, 228 - &adev->dm); 233 + init_handler_common_data(handler_data, ih, handler_args, &adev->dm); 229 234 230 235 irq_source = int_params->irq_source; 231 236 ··· 243 250 break; 244 251 } 245 252 246 - list_add_tail(&handler_data->hcd.list, hnd_list); 253 + list_add_tail(&handler_data->list, hnd_list); 247 254 248 255 DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags); 249 256 ··· 455 462 entry, 456 463 &adev->dm.irq_handler_list_high_tab[irq_source]) { 457 464 458 - handler_data = 459 - list_entry( 460 - entry, 461 - struct amdgpu_dm_irq_handler_data, 462 - hcd.list); 465 + handler_data = list_entry(entry, 466 + struct amdgpu_dm_irq_handler_data, 467 + list); 463 468 464 469 /* Call a subcomponent which registered for immediate 465 470 * interrupt notification */ 466 - handler_data->hcd.handler(handler_data->hcd.handler_arg); 471 + handler_data->handler(handler_data->handler_arg); 467 472 } 468 473 469 474 DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags);
+18 -28
drivers/gpu/drm/amd/display/dc/core/dc.c
··· 60 60 #define DC_LOGGER \ 61 61 dc->ctx->logger 62 62 63 + const static char DC_BUILD_ID[] = "production-build"; 63 64 64 65 /******************************************************************************* 65 66 * Private functions ··· 759 758 760 759 dc->config = init_params->flags; 761 760 761 + dc->build_id = DC_BUILD_ID; 762 + 762 763 DC_LOG_DC("Display Core initialized\n"); 763 764 764 765 ··· 1113 1110 return false; 1114 1111 } 1115 1112 1116 - static unsigned int pixel_format_to_bpp(enum surface_pixel_format format) 1117 - { 1118 - switch (format) { 1119 - case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr: 1120 - case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb: 1121 - return 12; 1122 - case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555: 1123 - case SURFACE_PIXEL_FORMAT_GRPH_RGB565: 1124 - case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr: 1125 - case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb: 1126 - return 16; 1127 - case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888: 1128 - case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888: 1129 - case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010: 1130 - case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010: 1131 - return 32; 1132 - case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616: 1133 - case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F: 1134 - case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F: 1135 - return 64; 1136 - default: 1137 - ASSERT_CRITICAL(false); 1138 - return -1; 1139 - } 1140 - } 1141 - 1142 1113 static enum surface_update_type get_plane_info_update_type(const struct dc_surface_update *u) 1143 1114 { 1144 1115 union surface_update_flags *update_flags = &u->surface->update_flags; ··· 1146 1169 || u->plane_info->dcc.grph.meta_pitch != u->surface->dcc.grph.meta_pitch) 1147 1170 update_flags->bits.dcc_change = 1; 1148 1171 1149 - if (pixel_format_to_bpp(u->plane_info->format) != 1150 - pixel_format_to_bpp(u->surface->format)) 1172 + if (resource_pixel_format_to_bpp(u->plane_info->format) != 1173 + resource_pixel_format_to_bpp(u->surface->format)) 1151 1174 /* different bytes per element will require full bandwidth 1152 1175 * and DML calculation 1153 1176 */ ··· 1835 1858 return; 1836 1859 } 1837 1860 } 1861 + } 1862 + 1863 + void get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info) 1864 + { 1865 + info->displayClock = (unsigned int)state->bw.dcn.clk.dispclk_khz; 1866 + info->engineClock = (unsigned int)state->bw.dcn.clk.dcfclk_khz; 1867 + info->memoryClock = (unsigned int)state->bw.dcn.clk.dramclk_khz; 1868 + info->maxSupportedDppClock = (unsigned int)state->bw.dcn.clk.max_supported_dppclk_khz; 1869 + info->dppClock = (unsigned int)state->bw.dcn.clk.dppclk_khz; 1870 + info->socClock = (unsigned int)state->bw.dcn.clk.socclk_khz; 1871 + info->dcfClockDeepSleep = (unsigned int)state->bw.dcn.clk.dcfclk_deep_sleep_khz; 1872 + info->fClock = (unsigned int)state->bw.dcn.clk.fclk_khz; 1873 + info->phyClock = (unsigned int)state->bw.dcn.clk.phyclk_khz; 1838 1874 }
+40
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
··· 1975 1975 else 1976 1976 stream->phy_pix_clk = 1977 1977 stream->timing.pix_clk_khz; 1978 + 1979 + if (stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING) 1980 + stream->phy_pix_clk *= 2; 1978 1981 } 1979 1982 1980 1983 enum dc_status resource_map_pool_resources( ··· 2098 2095 2099 2096 if (pipe_ctx->stream != stream) 2100 2097 continue; 2098 + 2099 + if (dc->res_pool->funcs->get_default_swizzle_mode && 2100 + pipe_ctx->plane_state && 2101 + pipe_ctx->plane_state->tiling_info.gfx9.swizzle == DC_SW_UNKNOWN) { 2102 + result = dc->res_pool->funcs->get_default_swizzle_mode(pipe_ctx->plane_state); 2103 + if (result != DC_OK) 2104 + return result; 2105 + } 2101 2106 2102 2107 /* Switch to dp clock source only if there is 2103 2108 * no non dp stream that shares the same timing ··· 2895 2884 return dc->res_pool->funcs->validate_plane(plane_state, &dc->caps); 2896 2885 2897 2886 return res; 2887 + } 2888 + 2889 + unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format) 2890 + { 2891 + switch (format) { 2892 + case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS: 2893 + return 8; 2894 + case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr: 2895 + case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb: 2896 + return 12; 2897 + case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555: 2898 + case SURFACE_PIXEL_FORMAT_GRPH_RGB565: 2899 + case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr: 2900 + case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb: 2901 + return 16; 2902 + case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888: 2903 + case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888: 2904 + case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010: 2905 + case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010: 2906 + case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS: 2907 + return 32; 2908 + case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616: 2909 + case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F: 2910 + case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F: 2911 + return 64; 2912 + default: 2913 + ASSERT_CRITICAL(false); 2914 + return -1; 2915 + } 2898 2916 }
+6 -2
drivers/gpu/drm/amd/display/dc/dc.h
··· 38 38 #include "inc/compressor.h" 39 39 #include "dml/display_mode_lib.h" 40 40 41 - #define DC_VER "3.1.67" 41 + #define DC_VER "3.1.68" 42 42 43 43 #define MAX_SURFACES 3 44 44 #define MAX_STREAMS 6 45 45 #define MAX_SINKS_PER_LINK 4 46 - 47 46 48 47 /******************************************************************************* 49 48 * Display Core Interfaces ··· 207 208 int dcfclk_deep_sleep_khz; 208 209 int fclk_khz; 209 210 int phyclk_khz; 211 + int dramclk_khz; 210 212 }; 211 213 212 214 struct dc_debug_options { ··· 315 315 struct compressor *fbc_compressor; 316 316 317 317 struct dc_debug_data debug_data; 318 + 319 + const char *build_id; 318 320 }; 319 321 320 322 enum frame_buffer_mode { ··· 600 598 }; 601 599 602 600 enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state); 601 + 602 + void get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info); 603 603 604 604 enum dc_status dc_validate_global_state( 605 605 struct dc *dc,
+2 -1
drivers/gpu/drm/amd/display/dc/dc_hw_types.h
··· 289 289 DC_SW_VAR_S_X = 29, 290 290 DC_SW_VAR_D_X = 30, 291 291 DC_SW_VAR_R_X = 31, 292 - DC_SW_MAX 292 + DC_SW_MAX = 32, 293 + DC_SW_UNKNOWN = DC_SW_MAX 293 294 }; 294 295 295 296 union dc_tiling_info {
+12
drivers/gpu/drm/amd/display/dc/dc_types.h
··· 659 659 I2C_MOT_FALSE 660 660 }; 661 661 662 + struct AsicStateEx { 663 + unsigned int memoryClock; 664 + unsigned int displayClock; 665 + unsigned int engineClock; 666 + unsigned int maxSupportedDppClock; 667 + unsigned int dppClock; 668 + unsigned int socClock; 669 + unsigned int dcfClockDeepSleep; 670 + unsigned int fClock; 671 + unsigned int phyClock; 672 + }; 673 + 662 674 #endif /* DC_TYPES_H_ */
+1 -1
drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
··· 312 312 313 313 /* in case HPD is LOW, exit AUX transaction */ 314 314 if ((sw_status & AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK)) { 315 - reply->status = AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON; 315 + reply->status = AUX_TRANSACTION_REPLY_HPD_DISCON; 316 316 return; 317 317 } 318 318
+5
drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c
··· 664 664 bool safe_to_lower) 665 665 { 666 666 struct dm_pp_power_level_change_request level_change_req; 667 + struct dce_dccg *clk_dce = TO_DCE_CLOCKS(dccg); 668 + 669 + /* TODO: Investigate why this is needed to fix display corruption. */ 670 + if (!clk_dce->dfs_bypass_active) 671 + new_clocks->dispclk_khz = new_clocks->dispclk_khz * 115 / 100; 667 672 668 673 level_change_req.power_level = dce_get_required_clocks_state(dccg, new_clocks); 669 674 /* get max clock state from PPLIB */
+3 -2
drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
··· 551 551 .max_hdmi_deep_color = COLOR_DEPTH_121212, 552 552 .max_hdmi_pixel_clock = 300000, 553 553 .flags.bits.IS_HBR2_CAPABLE = true, 554 - .flags.bits.IS_TPS3_CAPABLE = true, 555 - .flags.bits.IS_YCBCR_CAPABLE = true 554 + .flags.bits.IS_TPS3_CAPABLE = true 556 555 }; 557 556 558 557 struct link_encoder *dce100_link_encoder_create( ··· 689 690 kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); 690 691 pool->base.timing_generators[i] = NULL; 691 692 } 693 + } 692 694 695 + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 693 696 if (pool->base.engines[i] != NULL) 694 697 dce110_engine_destroy(&pool->base.engines[i]); 695 698 if (pool->base.hw_i2cs[i] != NULL) {
+3 -2
drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
··· 570 570 .max_hdmi_deep_color = COLOR_DEPTH_121212, 571 571 .max_hdmi_pixel_clock = 594000, 572 572 .flags.bits.IS_HBR2_CAPABLE = true, 573 - .flags.bits.IS_TPS3_CAPABLE = true, 574 - .flags.bits.IS_YCBCR_CAPABLE = true 573 + .flags.bits.IS_TPS3_CAPABLE = true 575 574 }; 576 575 577 576 static struct link_encoder *dce110_link_encoder_create( ··· 719 720 kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); 720 721 pool->base.timing_generators[i] = NULL; 721 722 } 723 + } 722 724 725 + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 723 726 if (pool->base.engines[i] != NULL) 724 727 dce110_engine_destroy(&pool->base.engines[i]); 725 728 if (pool->base.hw_i2cs[i] != NULL) {
+6 -5
drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c
··· 555 555 .flags.bits.IS_HBR2_CAPABLE = true, 556 556 .flags.bits.IS_HBR3_CAPABLE = true, 557 557 .flags.bits.IS_TPS3_CAPABLE = true, 558 - .flags.bits.IS_TPS4_CAPABLE = true, 559 - .flags.bits.IS_YCBCR_CAPABLE = true 558 + .flags.bits.IS_TPS4_CAPABLE = true 560 559 }; 561 560 562 561 struct link_encoder *dce112_link_encoder_create( ··· 693 694 if (pool->base.opps[i] != NULL) 694 695 dce110_opp_destroy(&pool->base.opps[i]); 695 696 696 - if (pool->base.engines[i] != NULL) 697 - dce110_engine_destroy(&pool->base.engines[i]); 698 - 699 697 if (pool->base.transforms[i] != NULL) 700 698 dce112_transform_destroy(&pool->base.transforms[i]); 701 699 ··· 708 712 kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); 709 713 pool->base.timing_generators[i] = NULL; 710 714 } 715 + } 716 + 717 + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 718 + if (pool->base.engines[i] != NULL) 719 + dce110_engine_destroy(&pool->base.engines[i]); 711 720 if (pool->base.hw_i2cs[i] != NULL) { 712 721 kfree(pool->base.hw_i2cs[i]); 713 722 pool->base.hw_i2cs[i] = NULL;
+2 -1
drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
··· 533 533 kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); 534 534 pool->base.timing_generators[i] = NULL; 535 535 } 536 + } 536 537 538 + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 537 539 if (pool->base.engines[i] != NULL) 538 540 dce110_engine_destroy(&pool->base.engines[i]); 539 541 if (pool->base.hw_i2cs[i] != NULL) { ··· 611 609 .flags.bits.IS_HBR3_CAPABLE = true, 612 610 .flags.bits.IS_TPS3_CAPABLE = true, 613 611 .flags.bits.IS_TPS4_CAPABLE = true, 614 - .flags.bits.IS_YCBCR_CAPABLE = true 615 612 }; 616 613 617 614 static struct link_encoder *dce120_link_encoder_create(
+3 -2
drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c
··· 650 650 .max_hdmi_deep_color = COLOR_DEPTH_121212, 651 651 .max_hdmi_pixel_clock = 297000, 652 652 .flags.bits.IS_HBR2_CAPABLE = true, 653 - .flags.bits.IS_TPS3_CAPABLE = true, 654 - .flags.bits.IS_YCBCR_CAPABLE = true 653 + .flags.bits.IS_TPS3_CAPABLE = true 655 654 }; 656 655 657 656 struct link_encoder *dce80_link_encoder_create( ··· 738 739 kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); 739 740 pool->base.timing_generators[i] = NULL; 740 741 } 742 + } 741 743 744 + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 742 745 if (pool->base.engines[i] != NULL) 743 746 dce110_engine_destroy(&pool->base.engines[i]); 744 747 if (pool->base.hw_i2cs[i] != NULL) {
+58 -2
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c
··· 87 87 s->dram_clk_chanage = REG_READ(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_D); 88 88 } 89 89 90 + void hubbub1_disable_allow_self_refresh(struct hubbub *hubbub) 91 + { 92 + REG_UPDATE(DCHUBBUB_ARB_DRAM_STATE_CNTL, 93 + DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_ENABLE, 0); 94 + } 95 + 96 + bool hububu1_is_allow_self_refresh_enabled(struct hubbub *hubbub) 97 + { 98 + uint32_t enable = 0; 99 + 100 + REG_GET(DCHUBBUB_ARB_DRAM_STATE_CNTL, 101 + DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_ENABLE, &enable); 102 + 103 + return true ? false : enable; 104 + } 105 + 106 + 90 107 bool hubbub1_verify_allow_pstate_change_high( 91 108 struct hubbub *hubbub) 92 109 { ··· 133 116 forced_pstate_allow = false; 134 117 } 135 118 136 - /* RV1: 119 + /* RV2: 120 + * dchubbubdebugind, at: 0xB 121 + * description 122 + * 0: Pipe0 Plane0 Allow Pstate Change 123 + * 1: Pipe0 Plane1 Allow Pstate Change 124 + * 2: Pipe0 Cursor0 Allow Pstate Change 125 + * 3: Pipe0 Cursor1 Allow Pstate Change 126 + * 4: Pipe1 Plane0 Allow Pstate Change 127 + * 5: Pipe1 Plane1 Allow Pstate Change 128 + * 6: Pipe1 Cursor0 Allow Pstate Change 129 + * 7: Pipe1 Cursor1 Allow Pstate Change 130 + * 8: Pipe2 Plane0 Allow Pstate Change 131 + * 9: Pipe2 Plane1 Allow Pstate Change 132 + * 10: Pipe2 Cursor0 Allow Pstate Change 133 + * 11: Pipe2 Cursor1 Allow Pstate Change 134 + * 12: Pipe3 Plane0 Allow Pstate Change 135 + * 13: Pipe3 Plane1 Allow Pstate Change 136 + * 14: Pipe3 Cursor0 Allow Pstate Change 137 + * 15: Pipe3 Cursor1 Allow Pstate Change 138 + * 16: Pipe4 Plane0 Allow Pstate Change 139 + * 17: Pipe4 Plane1 Allow Pstate Change 140 + * 18: Pipe4 Cursor0 Allow Pstate Change 141 + * 19: Pipe4 Cursor1 Allow Pstate Change 142 + * 20: Pipe5 Plane0 Allow Pstate Change 143 + * 21: Pipe5 Plane1 Allow Pstate Change 144 + * 22: Pipe5 Cursor0 Allow Pstate Change 145 + * 23: Pipe5 Cursor1 Allow Pstate Change 146 + * 24: Pipe6 Plane0 Allow Pstate Change 147 + * 25: Pipe6 Plane1 Allow Pstate Change 148 + * 26: Pipe6 Cursor0 Allow Pstate Change 149 + * 27: Pipe6 Cursor1 Allow Pstate Change 150 + * 28: WB0 Allow Pstate Change 151 + * 29: WB1 Allow Pstate Change 152 + * 30: Arbiter's allow_pstate_change 153 + * 31: SOC pstate change request" 154 + * 155 + * RV1: 137 156 * dchubbubdebugind, at: 0x7 138 157 * description "3-0: Pipe0 cursor0 QOS 139 158 * 7-4: Pipe1 cursor0 QOS ··· 192 139 * 30: Arbiter's allow_pstate_change 193 140 * 31: SOC pstate change request 194 141 */ 195 - 196 142 197 143 REG_WRITE(DCHUBBUB_TEST_DEBUG_INDEX, hubbub->debug_test_index_pstate); 198 144 ··· 854 802 hubbub->masks = hubbub_mask; 855 803 856 804 hubbub->debug_test_index_pstate = 0x7; 805 + #if defined(CONFIG_DRM_AMD_DC_DCN1_01) 806 + if (ctx->dce_version == DCN_VERSION_1_01) 807 + hubbub->debug_test_index_pstate = 0xB; 808 + #endif 857 809 } 858 810
+4
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h
··· 203 203 unsigned int refclk_mhz, 204 204 bool safe_to_lower); 205 205 206 + void hubbub1_disable_allow_self_refresh(struct hubbub *hubbub); 207 + 208 + bool hububu1_is_allow_self_refresh_enabled(struct hubbub *hubub); 209 + 206 210 void hubbub1_toggle_watermark_change_req( 207 211 struct hubbub *hubbub); 208 212
+14
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
··· 997 997 } else { 998 998 999 999 if (!dcb->funcs->is_accelerated_mode(dcb)) { 1000 + bool allow_self_fresh_force_enable = 1001 + hububu1_is_allow_self_refresh_enabled(dc->res_pool->hubbub); 1002 + 1000 1003 bios_golden_init(dc); 1004 + 1005 + /* WA for making DF sleep when idle after resume from S0i3. 1006 + * DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_ENABLE is set to 1 by 1007 + * command table, if DCHUBBUB_ARB_ALLOW_SELF_REFRESH_FORCE_ENABLE = 0 1008 + * before calling command table and it changed to 1 after, 1009 + * it should be set back to 0. 1010 + */ 1011 + if (allow_self_fresh_force_enable == false && 1012 + hububu1_is_allow_self_refresh_enabled(dc->res_pool->hubbub)) 1013 + hubbub1_disable_allow_self_refresh(dc->res_pool->hubbub); 1014 + 1001 1015 disable_vga(dc->hwseq); 1002 1016 } 1003 1017
+8 -26
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c
··· 98 98 struct dc_crtc_timing patched_crtc_timing; 99 99 int vesa_sync_start; 100 100 int asic_blank_end; 101 - int interlace_factor; 102 101 int vertical_line_start; 103 102 104 103 patched_crtc_timing = *dc_crtc_timing; ··· 111 112 vesa_sync_start - 112 113 patched_crtc_timing.h_border_left; 113 114 114 - interlace_factor = patched_crtc_timing.flags.INTERLACE ? 2 : 1; 115 - 116 115 vesa_sync_start = patched_crtc_timing.v_addressable + 117 116 patched_crtc_timing.v_border_bottom + 118 117 patched_crtc_timing.v_front_porch; 119 118 120 119 asic_blank_end = (patched_crtc_timing.v_total - 121 120 vesa_sync_start - 122 - patched_crtc_timing.v_border_top) 123 - * interlace_factor; 121 + patched_crtc_timing.v_border_top); 124 122 125 123 vertical_line_start = asic_blank_end - optc->dlg_otg_param.vstartup_start + 1; 126 124 if (vertical_line_start < 0) { ··· 150 154 req_delta_lines--; 151 155 152 156 if (req_delta_lines > vsync_line) 153 - start_line = dc_crtc_timing->v_total - (req_delta_lines - vsync_line) - 1; 157 + start_line = dc_crtc_timing->v_total - (req_delta_lines - vsync_line) + 2; 154 158 else 155 159 start_line = vsync_line - req_delta_lines; 156 160 ··· 182 186 uint32_t v_sync_end; 183 187 uint32_t v_init, v_fp2; 184 188 uint32_t h_sync_polarity, v_sync_polarity; 185 - uint32_t interlace_factor; 186 189 uint32_t start_point = 0; 187 190 uint32_t field_num = 0; 188 191 uint32_t h_div_2; ··· 232 237 REG_UPDATE(OTG_H_SYNC_A_CNTL, 233 238 OTG_H_SYNC_A_POL, h_sync_polarity); 234 239 235 - /* Load vertical timing */ 240 + v_total = patched_crtc_timing.v_total - 1; 236 241 237 - /* CRTC_V_TOTAL = v_total - 1 */ 238 - if (patched_crtc_timing.flags.INTERLACE) { 239 - interlace_factor = 2; 240 - v_total = 2 * patched_crtc_timing.v_total; 241 - } else { 242 - interlace_factor = 1; 243 - v_total = patched_crtc_timing.v_total - 1; 244 - } 245 242 REG_SET(OTG_V_TOTAL, 0, 246 243 OTG_V_TOTAL, v_total); 247 244 ··· 246 259 OTG_V_TOTAL_MIN, v_total); 247 260 248 261 /* v_sync_start = 0, v_sync_end = v_sync_width */ 249 - v_sync_end = patched_crtc_timing.v_sync_width * interlace_factor; 262 + v_sync_end = patched_crtc_timing.v_sync_width; 250 263 251 264 REG_UPDATE_2(OTG_V_SYNC_A, 252 265 OTG_V_SYNC_A_START, 0, ··· 258 271 259 272 asic_blank_end = (patched_crtc_timing.v_total - 260 273 vesa_sync_start - 261 - patched_crtc_timing.v_border_top) 262 - * interlace_factor; 274 + patched_crtc_timing.v_border_top); 263 275 264 276 /* v_blank_start = v_blank_end + v_active */ 265 277 asic_blank_start = asic_blank_end + 266 278 (patched_crtc_timing.v_border_top + 267 279 patched_crtc_timing.v_addressable + 268 - patched_crtc_timing.v_border_bottom) 269 - * interlace_factor; 280 + patched_crtc_timing.v_border_bottom); 270 281 271 282 REG_UPDATE_2(OTG_V_BLANK_START_END, 272 283 OTG_V_BLANK_START, asic_blank_start, ··· 286 301 0 : 1; 287 302 288 303 REG_UPDATE(OTG_V_SYNC_A_CNTL, 289 - OTG_V_SYNC_A_POL, v_sync_polarity); 304 + OTG_V_SYNC_A_POL, v_sync_polarity); 290 305 291 306 v_init = asic_blank_start; 292 307 if (optc->dlg_otg_param.signal == SIGNAL_TYPE_DISPLAY_PORT || ··· 517 532 struct timing_generator *optc, 518 533 const struct dc_crtc_timing *timing) 519 534 { 520 - uint32_t interlace_factor; 521 535 uint32_t v_blank; 522 536 uint32_t h_blank; 523 537 uint32_t min_v_blank; ··· 524 540 525 541 ASSERT(timing != NULL); 526 542 527 - interlace_factor = timing->flags.INTERLACE ? 2 : 1; 528 543 v_blank = (timing->v_total - timing->v_addressable - 529 - timing->v_border_top - timing->v_border_bottom) * 530 - interlace_factor; 544 + timing->v_border_top - timing->v_border_bottom); 531 545 532 546 h_blank = (timing->h_total - timing->h_addressable - 533 547 timing->h_border_right -
+41 -4
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
··· 507 507 .num_ddc = 4, 508 508 }; 509 509 510 + #if defined(CONFIG_DRM_AMD_DC_DCN1_01) 511 + static const struct resource_caps rv2_res_cap = { 512 + .num_timing_generator = 3, 513 + .num_opp = 3, 514 + .num_video_plane = 3, 515 + .num_audio = 3, 516 + .num_stream_encoder = 3, 517 + .num_pll = 3, 518 + .num_ddc = 3, 519 + }; 520 + #endif 521 + 510 522 static const struct dc_debug_options debug_defaults_drv = { 511 523 .sanity_checks = true, 512 524 .disable_dmcu = true, ··· 723 711 .flags.bits.IS_HBR2_CAPABLE = true, 724 712 .flags.bits.IS_HBR3_CAPABLE = true, 725 713 .flags.bits.IS_TPS3_CAPABLE = true, 726 - .flags.bits.IS_TPS4_CAPABLE = true, 727 - .flags.bits.IS_YCBCR_CAPABLE = true 714 + .flags.bits.IS_TPS4_CAPABLE = true 728 715 }; 729 716 730 717 struct link_encoder *dcn10_link_encoder_create( ··· 908 897 kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i])); 909 898 pool->base.timing_generators[i] = NULL; 910 899 } 900 + } 911 901 902 + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 912 903 if (pool->base.engines[i] != NULL) 913 904 pool->base.engines[i]->funcs->destroy_engine(&pool->base.engines[i]); 914 905 if (pool->base.hw_i2cs[i] != NULL) { ··· 1132 1119 return DC_OK; 1133 1120 } 1134 1121 1122 + static enum dc_status dcn10_get_default_swizzle_mode(struct dc_plane_state *plane_state) 1123 + { 1124 + enum dc_status result = DC_OK; 1125 + 1126 + enum surface_pixel_format surf_pix_format = plane_state->format; 1127 + unsigned int bpp = resource_pixel_format_to_bpp(surf_pix_format); 1128 + 1129 + enum swizzle_mode_values swizzle = DC_SW_LINEAR; 1130 + 1131 + if (bpp == 64) 1132 + swizzle = DC_SW_64KB_D; 1133 + else 1134 + swizzle = DC_SW_64KB_S; 1135 + 1136 + plane_state->tiling_info.gfx9.swizzle = swizzle; 1137 + return result; 1138 + } 1139 + 1135 1140 static const struct dc_cap_funcs cap_funcs = { 1136 1141 .get_dcc_compression_cap = dcn10_get_dcc_compression_cap 1137 1142 }; ··· 1160 1129 .validate_bandwidth = dcn_validate_bandwidth, 1161 1130 .acquire_idle_pipe_for_layer = dcn10_acquire_idle_pipe_for_layer, 1162 1131 .validate_plane = dcn10_validate_plane, 1163 - .add_stream_to_ctx = dcn10_add_stream_to_ctx 1132 + .add_stream_to_ctx = dcn10_add_stream_to_ctx, 1133 + .get_default_swizzle_mode = dcn10_get_default_swizzle_mode 1164 1134 }; 1165 1135 1166 1136 static uint32_t read_pipe_fuses(struct dc_context *ctx) ··· 1184 1152 1185 1153 ctx->dc_bios->regs = &bios_regs; 1186 1154 1187 - pool->base.res_cap = &res_cap; 1155 + #if defined(CONFIG_DRM_AMD_DC_DCN1_01) 1156 + if (ctx->dce_version == DCN_VERSION_1_01) 1157 + pool->base.res_cap = &rv2_res_cap; 1158 + else 1159 + #endif 1160 + pool->base.res_cap = &res_cap; 1188 1161 pool->base.funcs = &dcn10_res_pool_funcs; 1189 1162 1190 1163 /*
+1 -1
drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c
··· 346 346 347 347 /* in case HPD is LOW, exit AUX transaction */ 348 348 if ((sw_status & AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK)) { 349 - reply->status = AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON; 349 + reply->status = AUX_TRANSACTION_REPLY_HPD_DISCON; 350 350 return; 351 351 } 352 352
+3
drivers/gpu/drm/amd/display/dc/inc/core_types.h
··· 120 120 struct dc *dc, 121 121 struct dc_state *new_ctx, 122 122 struct dc_stream_state *stream); 123 + enum dc_status (*get_default_swizzle_mode)( 124 + struct dc_plane_state *plane_state); 125 + 123 126 }; 124 127 125 128 struct audio_support{
+3
drivers/gpu/drm/amd/display/dc/inc/resource.h
··· 172 172 const struct resource_pool *pool, 173 173 struct audio *audio, 174 174 bool acquired); 175 + 176 + unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format); 177 + 175 178 #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
+5
drivers/gpu/drm/amd/display/include/signal_types.h
··· 102 102 dc_is_hdmi_signal(signal)); 103 103 } 104 104 105 + static inline bool dc_is_virtual_signal(enum signal_type signal) 106 + { 107 + return (signal == SIGNAL_TYPE_VIRTUAL); 108 + } 109 + 105 110 #endif
+2
drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_offset.h
··· 2449 2449 #define mmCP_ECC_FIRSTOCCURRENCE_RING2_BASE_IDX 0 2450 2450 #define mmGB_EDC_MODE 0x107e 2451 2451 #define mmGB_EDC_MODE_BASE_IDX 0 2452 + #define mmCP_DEBUG 0x107f 2453 + #define mmCP_DEBUG_BASE_IDX 0 2452 2454 #define mmCP_CPF_DEBUG 0x1080 2453 2455 #define mmCP_PQ_WPTR_POLL_CNTL 0x1083 2454 2456 #define mmCP_PQ_WPTR_POLL_CNTL_BASE_IDX 0
+3
drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_offset.h
··· 175 175 #define mmSMUSVI0_PLANE0_CURRENTVID_BASE_IDX 0 176 176 #define mmSMUSVI0_PLANE0_CURRENTVID 0x0013 177 177 178 + #define mmSMUSVI0_TEL_PLANE0_BASE_IDX 0 179 + #define mmSMUSVI0_TEL_PLANE0 0x0004 180 + 178 181 #endif
+3
drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_sh_mask.h
··· 258 258 #define SMUSVI0_PLANE0_CURRENTVID__CURRENT_SVI0_PLANE0_VID__SHIFT 0x18 259 259 #define SMUSVI0_PLANE0_CURRENTVID__CURRENT_SVI0_PLANE0_VID_MASK 0xFF000000L 260 260 261 + #define SMUSVI0_TEL_PLANE0__SVI0_PLANE0_VDDCOR__SHIFT 0x10 262 + #define SMUSVI0_TEL_PLANE0__SVI0_PLANE0_VDDCOR_MASK 0x01FF0000L 263 + 261 264 #endif
+12
drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_offset.h
··· 26 26 #define mmCG_MULT_THERMAL_STATUS 0x005f 27 27 #define mmCG_MULT_THERMAL_STATUS_BASE_IDX 0 28 28 29 + #define mmCG_FDO_CTRL0 0x0067 30 + #define mmCG_FDO_CTRL0_BASE_IDX 0 31 + 32 + #define mmCG_FDO_CTRL1 0x0068 33 + #define mmCG_FDO_CTRL1_BASE_IDX 0 34 + 35 + #define mmCG_FDO_CTRL2 0x0069 36 + #define mmCG_FDO_CTRL2_BASE_IDX 0 37 + 38 + #define mmCG_TACH_CTRL 0x006a 39 + #define mmCG_TACH_CTRL_BASE_IDX 0 40 + 29 41 #define mmTHM_THERMAL_INT_ENA 0x000a 30 42 #define mmTHM_THERMAL_INT_ENA_BASE_IDX 0 31 43 #define mmTHM_THERMAL_INT_CTRL 0x000b
+10
drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_sh_mask.h
··· 28 28 #define CG_MULT_THERMAL_STATUS__CTF_TEMP__SHIFT 0x9 29 29 #define CG_MULT_THERMAL_STATUS__ASIC_MAX_TEMP_MASK 0x000001FFL 30 30 #define CG_MULT_THERMAL_STATUS__CTF_TEMP_MASK 0x0003FE00L 31 + #define CG_FDO_CTRL2__TMIN__SHIFT 0x0 32 + #define CG_FDO_CTRL2__TMIN_MASK 0x000000FFL 33 + #define CG_FDO_CTRL2__FDO_PWM_MODE__SHIFT 0xb 34 + #define CG_FDO_CTRL2__FDO_PWM_MODE_MASK 0x00003800L 35 + #define CG_FDO_CTRL1__FMAX_DUTY100__SHIFT 0x0 36 + #define CG_FDO_CTRL1__FMAX_DUTY100_MASK 0x000000FFL 37 + #define CG_FDO_CTRL0__FDO_STATIC_DUTY__SHIFT 0x0 38 + #define CG_FDO_CTRL0__FDO_STATIC_DUTY_MASK 0x000000FFL 39 + #define CG_TACH_CTRL__TARGET_PERIOD__SHIFT 0x3 40 + #define CG_TACH_CTRL__TARGET_PERIOD_MASK 0xFFFFFFF8L 31 41 32 42 //THM_THERMAL_INT_ENA 33 43 #define THM_THERMAL_INT_ENA__THERM_INTH_SET__SHIFT 0x0
+4
drivers/gpu/drm/amd/include/kgd_pp_interface.h
··· 114 114 AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK, 115 115 AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK, 116 116 AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK, 117 + AMDGPU_PP_SENSOR_MIN_FAN_RPM, 118 + AMDGPU_PP_SENSOR_MAX_FAN_RPM, 117 119 }; 118 120 119 121 enum amd_pp_task { ··· 230 228 enum amd_dpm_forced_level (*get_performance_level)(void *handle); 231 229 enum amd_pm_state_type (*get_current_power_state)(void *handle); 232 230 int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm); 231 + int (*set_fan_speed_rpm)(void *handle, uint32_t rpm); 233 232 int (*get_pp_num_states)(void *handle, struct pp_states_info *data); 234 233 int (*get_pp_table)(void *handle, char **table); 235 234 int (*set_pp_table)(void *handle, const char *buf, size_t size); ··· 275 272 int (*get_display_mode_validation_clocks)(void *handle, 276 273 struct amd_pp_simple_clock_info *clocks); 277 274 int (*notify_smu_enable_pwe)(void *handle); 275 + int (*enable_mgpu_fan_boost)(void *handle); 278 276 }; 279 277 280 278 #endif
+79 -8
drivers/gpu/drm/amd/powerplay/amd_powerplay.c
··· 109 109 110 110 hwmgr_sw_fini(hwmgr); 111 111 112 - if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { 113 - release_firmware(adev->pm.fw); 114 - adev->pm.fw = NULL; 115 - amdgpu_ucode_fini_bo(adev); 116 - } 112 + release_firmware(adev->pm.fw); 113 + adev->pm.fw = NULL; 117 114 118 115 return 0; 119 116 } ··· 120 123 int ret = 0; 121 124 struct amdgpu_device *adev = handle; 122 125 struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; 123 - 124 - if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) 125 - amdgpu_ucode_init_bo(adev); 126 126 127 127 ret = hwmgr_hw_init(hwmgr); 128 128 ··· 267 273 .funcs = &pp_ip_funcs, 268 274 }; 269 275 276 + /* This interface only be supported On Vi, 277 + * because only smu7/8 can help to load gfx/sdma fw, 278 + * smu need to be enabled before load other ip's fw. 279 + * so call start smu to load smu7 fw and other ip's fw 280 + */ 270 281 static int pp_dpm_load_fw(void *handle) 271 282 { 283 + struct pp_hwmgr *hwmgr = handle; 284 + 285 + if (!hwmgr || !hwmgr->smumgr_funcs || !hwmgr->smumgr_funcs->start_smu) 286 + return -EINVAL; 287 + 288 + if (hwmgr->smumgr_funcs->start_smu(hwmgr)) { 289 + pr_err("fw load failed\n"); 290 + return -EINVAL; 291 + } 292 + 272 293 return 0; 273 294 } 274 295 ··· 585 576 return ret; 586 577 } 587 578 579 + static int pp_dpm_set_fan_speed_rpm(void *handle, uint32_t rpm) 580 + { 581 + struct pp_hwmgr *hwmgr = handle; 582 + int ret = 0; 583 + 584 + if (!hwmgr || !hwmgr->pm_en) 585 + return -EINVAL; 586 + 587 + if (hwmgr->hwmgr_func->set_fan_speed_rpm == NULL) { 588 + pr_info("%s was not implemented.\n", __func__); 589 + return 0; 590 + } 591 + mutex_lock(&hwmgr->smu_lock); 592 + ret = hwmgr->hwmgr_func->set_fan_speed_rpm(hwmgr, rpm); 593 + mutex_unlock(&hwmgr->smu_lock); 594 + return ret; 595 + } 596 + 588 597 static int pp_dpm_get_pp_num_states(void *handle, 589 598 struct pp_states_info *data) 590 599 { ··· 839 812 return 0; 840 813 case AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK: 841 814 *((uint32_t *)value) = hwmgr->pstate_mclk; 815 + return 0; 816 + case AMDGPU_PP_SENSOR_MIN_FAN_RPM: 817 + *((uint32_t *)value) = hwmgr->thermal_controller.fanInfo.ulMinRPM; 818 + return 0; 819 + case AMDGPU_PP_SENSOR_MAX_FAN_RPM: 820 + *((uint32_t *)value) = hwmgr->thermal_controller.fanInfo.ulMaxRPM; 842 821 return 0; 843 822 default: 844 823 mutex_lock(&hwmgr->smu_lock); ··· 1229 1196 hwmgr->hwmgr_func->powergate_acp(hwmgr, gate); 1230 1197 } 1231 1198 1199 + static void pp_dpm_powergate_sdma(void *handle, bool gate) 1200 + { 1201 + struct pp_hwmgr *hwmgr = handle; 1202 + 1203 + if (!hwmgr) 1204 + return; 1205 + 1206 + if (hwmgr->hwmgr_func->powergate_sdma == NULL) { 1207 + pr_info("%s was not implemented.\n", __func__); 1208 + return; 1209 + } 1210 + 1211 + hwmgr->hwmgr_func->powergate_sdma(hwmgr, gate); 1212 + } 1213 + 1232 1214 static int pp_set_powergating_by_smu(void *handle, 1233 1215 uint32_t block_type, bool gate) 1234 1216 { ··· 1265 1217 break; 1266 1218 case AMD_IP_BLOCK_TYPE_ACP: 1267 1219 pp_dpm_powergate_acp(handle, gate); 1220 + break; 1221 + case AMD_IP_BLOCK_TYPE_SDMA: 1222 + pp_dpm_powergate_sdma(handle, gate); 1268 1223 break; 1269 1224 default: 1270 1225 break; ··· 1294 1243 return 0; 1295 1244 } 1296 1245 1246 + static int pp_enable_mgpu_fan_boost(void *handle) 1247 + { 1248 + struct pp_hwmgr *hwmgr = handle; 1249 + 1250 + if (!hwmgr || !hwmgr->pm_en) 1251 + return -EINVAL; 1252 + 1253 + if (hwmgr->hwmgr_func->enable_mgpu_fan_boost == NULL) { 1254 + return 0; 1255 + } 1256 + 1257 + mutex_lock(&hwmgr->smu_lock); 1258 + hwmgr->hwmgr_func->enable_mgpu_fan_boost(hwmgr); 1259 + mutex_unlock(&hwmgr->smu_lock); 1260 + 1261 + return 0; 1262 + } 1263 + 1297 1264 static const struct amd_pm_funcs pp_dpm_funcs = { 1298 1265 .load_firmware = pp_dpm_load_fw, 1299 1266 .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete, ··· 1324 1255 .set_fan_speed_percent = pp_dpm_set_fan_speed_percent, 1325 1256 .get_fan_speed_percent = pp_dpm_get_fan_speed_percent, 1326 1257 .get_fan_speed_rpm = pp_dpm_get_fan_speed_rpm, 1258 + .set_fan_speed_rpm = pp_dpm_set_fan_speed_rpm, 1327 1259 .get_pp_num_states = pp_dpm_get_pp_num_states, 1328 1260 .get_pp_table = pp_dpm_get_pp_table, 1329 1261 .set_pp_table = pp_dpm_set_pp_table, ··· 1357 1287 .display_clock_voltage_request = pp_display_clock_voltage_request, 1358 1288 .get_display_mode_validation_clocks = pp_get_display_mode_validation_clocks, 1359 1289 .notify_smu_enable_pwe = pp_notify_smu_enable_pwe, 1290 + .enable_mgpu_fan_boost = pp_enable_mgpu_fan_boost, 1360 1291 };
-19
drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
··· 89 89 hwmgr_init_default_caps(hwmgr); 90 90 hwmgr_set_user_specify_caps(hwmgr); 91 91 hwmgr->fan_ctrl_is_in_default_mode = true; 92 - hwmgr->reload_fw = 1; 93 92 hwmgr_init_workload_prority(hwmgr); 94 93 95 94 switch (hwmgr->chip_family) { ··· 208 209 { 209 210 int ret = 0; 210 211 211 - if (!hwmgr || !hwmgr->smumgr_funcs) 212 - return -EINVAL; 213 - 214 - if (hwmgr->smumgr_funcs->start_smu) { 215 - ret = hwmgr->smumgr_funcs->start_smu(hwmgr); 216 - if (ret) { 217 - pr_err("smc start failed\n"); 218 - return -EINVAL; 219 - } 220 - } 221 - 222 212 if (!hwmgr->pm_en) 223 213 return 0; 224 214 ··· 307 319 308 320 if (!hwmgr) 309 321 return -EINVAL; 310 - 311 - if (hwmgr->smumgr_funcs && hwmgr->smumgr_funcs->start_smu) { 312 - if (hwmgr->smumgr_funcs->start_smu(hwmgr)) { 313 - pr_err("smc start failed\n"); 314 - return -EINVAL; 315 - } 316 - } 317 322 318 323 if (!hwmgr->pm_en) 319 324 return 0;
+9
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
··· 1153 1153 return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PowerGateMmHub); 1154 1154 } 1155 1155 1156 + static int smu10_powergate_sdma(struct pp_hwmgr *hwmgr, bool gate) 1157 + { 1158 + if (gate) 1159 + return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PowerDownSdma); 1160 + else 1161 + return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PowerUpSdma); 1162 + } 1163 + 1156 1164 static void smu10_powergate_vcn(struct pp_hwmgr *hwmgr, bool bgate) 1157 1165 { 1158 1166 if (bgate) { ··· 1216 1208 .smus_notify_pwe = smu10_smus_notify_pwe, 1217 1209 .display_clock_voltage_request = smu10_display_clock_voltage_request, 1218 1210 .powergate_gfx = smu10_gfx_off_control, 1211 + .powergate_sdma = smu10_powergate_sdma, 1219 1212 }; 1220 1213 1221 1214 int smu10_init_function_pointers(struct pp_hwmgr *hwmgr)
+2 -1
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c
··· 260 260 if (hwmgr->thermal_controller.fanInfo.bNoFan || 261 261 (hwmgr->thermal_controller.fanInfo. 262 262 ucTachometerPulsesPerRevolution == 0) || 263 + speed == 0 || 263 264 (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || 264 265 (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) 265 266 return 0; ··· 273 272 tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); 274 273 275 274 PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, 276 - CG_TACH_STATUS, TACH_PERIOD, tach_period); 275 + CG_TACH_CTRL, TARGET_PERIOD, tach_period); 277 276 278 277 return smu7_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM); 279 278 }
+4 -1
drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c
··· 1228 1228 1229 1229 static int smu8_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr) 1230 1230 { 1231 - if (PP_CAP(PHM_PlatformCaps_UVDPowerGating)) 1231 + if (PP_CAP(PHM_PlatformCaps_UVDPowerGating)) { 1232 + smu8_nbdpm_pstate_enable_disable(hwmgr, true, true); 1232 1233 return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_UVDPowerOFF); 1234 + } 1233 1235 return 0; 1234 1236 } 1235 1237 1236 1238 static int smu8_dpm_powerup_uvd(struct pp_hwmgr *hwmgr) 1237 1239 { 1238 1240 if (PP_CAP(PHM_PlatformCaps_UVDPowerGating)) { 1241 + smu8_nbdpm_pstate_enable_disable(hwmgr, false, true); 1239 1242 return smum_send_msg_to_smc_with_parameter( 1240 1243 hwmgr, 1241 1244 PPSMC_MSG_UVDPowerON,
+44
drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c
··· 39 39 return (uint16_t) ((6200 - (vid * 25)) / VOLTAGE_SCALE); 40 40 } 41 41 42 + int phm_copy_clock_limits_array( 43 + struct pp_hwmgr *hwmgr, 44 + uint32_t **pptable_info_array, 45 + const uint32_t *pptable_array, 46 + uint32_t power_saving_clock_count) 47 + { 48 + uint32_t array_size, i; 49 + uint32_t *table; 50 + 51 + array_size = sizeof(uint32_t) * power_saving_clock_count; 52 + table = kzalloc(array_size, GFP_KERNEL); 53 + if (NULL == table) 54 + return -ENOMEM; 55 + 56 + for (i = 0; i < power_saving_clock_count; i++) 57 + table[i] = le32_to_cpu(pptable_array[i]); 58 + 59 + *pptable_info_array = table; 60 + 61 + return 0; 62 + } 63 + 64 + int phm_copy_overdrive_settings_limits_array( 65 + struct pp_hwmgr *hwmgr, 66 + uint32_t **pptable_info_array, 67 + const uint32_t *pptable_array, 68 + uint32_t od_setting_count) 69 + { 70 + uint32_t array_size, i; 71 + uint32_t *table; 72 + 73 + array_size = sizeof(uint32_t) * od_setting_count; 74 + table = kzalloc(array_size, GFP_KERNEL); 75 + if (NULL == table) 76 + return -ENOMEM; 77 + 78 + for (i = 0; i < od_setting_count; i++) 79 + table[i] = le32_to_cpu(pptable_array[i]); 80 + 81 + *pptable_info_array = table; 82 + 83 + return 0; 84 + } 85 + 42 86 uint32_t phm_set_field_to_u32(u32 offset, u32 original_data, u32 field, u32 size) 43 87 { 44 88 u32 mask = 0;
+12
drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h
··· 47 47 uint32_t padding[7]; 48 48 }; 49 49 50 + int phm_copy_clock_limits_array( 51 + struct pp_hwmgr *hwmgr, 52 + uint32_t **pptable_info_array, 53 + const uint32_t *pptable_array, 54 + uint32_t power_saving_clock_count); 55 + 56 + int phm_copy_overdrive_settings_limits_array( 57 + struct pp_hwmgr *hwmgr, 58 + uint32_t **pptable_info_array, 59 + const uint32_t *pptable_array, 60 + uint32_t od_setting_count); 61 + 50 62 extern int phm_wait_for_register_unequal(struct pp_hwmgr *hwmgr, 51 63 uint32_t index, 52 64 uint32_t value, uint32_t mask);
+15 -15
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
··· 451 451 le16_to_cpu(power_tune_table_v2->usLoadLineResistance); 452 452 } else { 453 453 power_tune_table_v3 = (ATOM_Vega10_PowerTune_Table_V3 *)table; 454 - tdp_table->usMaximumPowerDeliveryLimit = power_tune_table_v3->usSocketPowerLimit; 455 - tdp_table->usTDC = power_tune_table_v3->usTdcLimit; 456 - tdp_table->usEDCLimit = power_tune_table_v3->usEdcLimit; 457 - tdp_table->usSoftwareShutdownTemp = power_tune_table_v3->usSoftwareShutdownTemp; 458 - tdp_table->usTemperatureLimitTedge = power_tune_table_v3->usTemperatureLimitTedge; 459 - tdp_table->usTemperatureLimitHotspot = power_tune_table_v3->usTemperatureLimitHotSpot; 460 - tdp_table->usTemperatureLimitLiquid1 = power_tune_table_v3->usTemperatureLimitLiquid1; 461 - tdp_table->usTemperatureLimitLiquid2 = power_tune_table_v3->usTemperatureLimitLiquid2; 462 - tdp_table->usTemperatureLimitHBM = power_tune_table_v3->usTemperatureLimitHBM; 463 - tdp_table->usTemperatureLimitVrVddc = power_tune_table_v3->usTemperatureLimitVrSoc; 464 - tdp_table->usTemperatureLimitVrMvdd = power_tune_table_v3->usTemperatureLimitVrMem; 465 - tdp_table->usTemperatureLimitPlx = power_tune_table_v3->usTemperatureLimitPlx; 454 + tdp_table->usMaximumPowerDeliveryLimit = le16_to_cpu(power_tune_table_v3->usSocketPowerLimit); 455 + tdp_table->usTDC = le16_to_cpu(power_tune_table_v3->usTdcLimit); 456 + tdp_table->usEDCLimit = le16_to_cpu(power_tune_table_v3->usEdcLimit); 457 + tdp_table->usSoftwareShutdownTemp = le16_to_cpu(power_tune_table_v3->usSoftwareShutdownTemp); 458 + tdp_table->usTemperatureLimitTedge = le16_to_cpu(power_tune_table_v3->usTemperatureLimitTedge); 459 + tdp_table->usTemperatureLimitHotspot = le16_to_cpu(power_tune_table_v3->usTemperatureLimitHotSpot); 460 + tdp_table->usTemperatureLimitLiquid1 = le16_to_cpu(power_tune_table_v3->usTemperatureLimitLiquid1); 461 + tdp_table->usTemperatureLimitLiquid2 = le16_to_cpu(power_tune_table_v3->usTemperatureLimitLiquid2); 462 + tdp_table->usTemperatureLimitHBM = le16_to_cpu(power_tune_table_v3->usTemperatureLimitHBM); 463 + tdp_table->usTemperatureLimitVrVddc = le16_to_cpu(power_tune_table_v3->usTemperatureLimitVrSoc); 464 + tdp_table->usTemperatureLimitVrMvdd = le16_to_cpu(power_tune_table_v3->usTemperatureLimitVrMem); 465 + tdp_table->usTemperatureLimitPlx = le16_to_cpu(power_tune_table_v3->usTemperatureLimitPlx); 466 466 tdp_table->ucLiquid1_I2C_address = power_tune_table_v3->ucLiquid1_I2C_address; 467 467 tdp_table->ucLiquid2_I2C_address = power_tune_table_v3->ucLiquid2_I2C_address; 468 - tdp_table->usBoostStartTemperature = power_tune_table_v3->usBoostStartTemperature; 469 - tdp_table->usBoostStopTemperature = power_tune_table_v3->usBoostStopTemperature; 470 - tdp_table->ulBoostClock = power_tune_table_v3->ulBoostClock; 468 + tdp_table->usBoostStartTemperature = le16_to_cpu(power_tune_table_v3->usBoostStartTemperature); 469 + tdp_table->usBoostStopTemperature = le16_to_cpu(power_tune_table_v3->usBoostStopTemperature); 470 + tdp_table->ulBoostClock = le32_to_cpu(power_tune_table_v3->ulBoostClock); 471 471 472 472 get_scl_sda_value(power_tune_table_v3->ucLiquid_I2C_Line, &scl, &sda); 473 473
+4 -3
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
··· 312 312 int result = 0; 313 313 314 314 if (hwmgr->thermal_controller.fanInfo.bNoFan || 315 + speed == 0 || 315 316 (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || 316 317 (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) 317 318 return -1; ··· 323 322 if (!result) { 324 323 crystal_clock_freq = amdgpu_asic_get_xclk((struct amdgpu_device *)hwmgr->adev); 325 324 tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); 326 - WREG32_SOC15(THM, 0, mmCG_TACH_STATUS, 327 - REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_STATUS), 328 - CG_TACH_STATUS, TACH_PERIOD, 325 + WREG32_SOC15(THM, 0, mmCG_TACH_CTRL, 326 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL), 327 + CG_TACH_CTRL, TARGET_PERIOD, 329 328 tach_period)); 330 329 } 331 330 return vega10_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM);
+22 -58
drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c
··· 99 99 return 0; 100 100 } 101 101 102 - static int copy_clock_limits_array( 103 - struct pp_hwmgr *hwmgr, 104 - uint32_t **pptable_info_array, 105 - const uint32_t *pptable_array) 106 - { 107 - uint32_t array_size, i; 108 - uint32_t *table; 109 - 110 - array_size = sizeof(uint32_t) * ATOM_VEGA12_PPCLOCK_COUNT; 111 - 112 - table = kzalloc(array_size, GFP_KERNEL); 113 - if (NULL == table) 114 - return -ENOMEM; 115 - 116 - for (i = 0; i < ATOM_VEGA12_PPCLOCK_COUNT; i++) 117 - table[i] = pptable_array[i]; 118 - 119 - *pptable_info_array = table; 120 - 121 - return 0; 122 - } 123 - 124 - static int copy_overdrive_settings_limits_array( 125 - struct pp_hwmgr *hwmgr, 126 - uint32_t **pptable_info_array, 127 - const uint32_t *pptable_array) 128 - { 129 - uint32_t array_size, i; 130 - uint32_t *table; 131 - 132 - array_size = sizeof(uint32_t) * ATOM_VEGA12_ODSETTING_COUNT; 133 - 134 - table = kzalloc(array_size, GFP_KERNEL); 135 - if (NULL == table) 136 - return -ENOMEM; 137 - 138 - for (i = 0; i < ATOM_VEGA12_ODSETTING_COUNT; i++) 139 - table[i] = pptable_array[i]; 140 - 141 - *pptable_info_array = table; 142 - 143 - return 0; 144 - } 145 - 146 102 static int append_vbios_pptable(struct pp_hwmgr *hwmgr, PPTable_t *ppsmc_pptable) 147 103 { 148 104 struct pp_atomfwctrl_smc_dpm_parameters smc_dpm_table; ··· 206 250 207 251 phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl); 208 252 209 - if (powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_GFXCLKFMAX] > VEGA12_ENGINECLOCK_HARDMAX) 253 + if (le32_to_cpu(powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_GFXCLKFMAX]) > VEGA12_ENGINECLOCK_HARDMAX) 210 254 hwmgr->platform_descriptor.overdriveLimit.engineClock = VEGA12_ENGINECLOCK_HARDMAX; 211 255 else 212 - hwmgr->platform_descriptor.overdriveLimit.engineClock = powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_GFXCLKFMAX]; 213 - hwmgr->platform_descriptor.overdriveLimit.memoryClock = powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_UCLKFMAX]; 256 + hwmgr->platform_descriptor.overdriveLimit.engineClock = 257 + le32_to_cpu(powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_GFXCLKFMAX]); 258 + hwmgr->platform_descriptor.overdriveLimit.memoryClock = 259 + le32_to_cpu(powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_UCLKFMAX]); 214 260 215 - copy_overdrive_settings_limits_array(hwmgr, &pptable_information->od_settings_max, powerplay_table->ODSettingsMax); 216 - copy_overdrive_settings_limits_array(hwmgr, &pptable_information->od_settings_min, powerplay_table->ODSettingsMin); 261 + phm_copy_overdrive_settings_limits_array(hwmgr, 262 + &pptable_information->od_settings_max, 263 + powerplay_table->ODSettingsMax, 264 + ATOM_VEGA12_ODSETTING_COUNT); 265 + phm_copy_overdrive_settings_limits_array(hwmgr, 266 + &pptable_information->od_settings_min, 267 + powerplay_table->ODSettingsMin, 268 + ATOM_VEGA12_ODSETTING_COUNT); 217 269 218 270 /* hwmgr->platformDescriptor.minOverdriveVDDC = 0; 219 271 hwmgr->platformDescriptor.maxOverdriveVDDC = 0; ··· 231 267 && hwmgr->platform_descriptor.overdriveLimit.memoryClock > 0) 232 268 phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_ACOverdriveSupport); 233 269 234 - pptable_information->us_small_power_limit1 = powerplay_table->usSmallPowerLimit1; 235 - pptable_information->us_small_power_limit2 = powerplay_table->usSmallPowerLimit2; 236 - pptable_information->us_boost_power_limit = powerplay_table->usBoostPowerLimit; 237 - pptable_information->us_od_turbo_power_limit = powerplay_table->usODTurboPowerLimit; 238 - pptable_information->us_od_powersave_power_limit = powerplay_table->usODPowerSavePowerLimit; 270 + pptable_information->us_small_power_limit1 = le16_to_cpu(powerplay_table->usSmallPowerLimit1); 271 + pptable_information->us_small_power_limit2 = le16_to_cpu(powerplay_table->usSmallPowerLimit2); 272 + pptable_information->us_boost_power_limit = le16_to_cpu(powerplay_table->usBoostPowerLimit); 273 + pptable_information->us_od_turbo_power_limit = le16_to_cpu(powerplay_table->usODTurboPowerLimit); 274 + pptable_information->us_od_powersave_power_limit = le16_to_cpu(powerplay_table->usODPowerSavePowerLimit); 239 275 240 - pptable_information->us_software_shutdown_temp = powerplay_table->usSoftwareShutdownTemp; 276 + pptable_information->us_software_shutdown_temp = le16_to_cpu(powerplay_table->usSoftwareShutdownTemp); 241 277 242 - hwmgr->platform_descriptor.TDPODLimit = (uint16_t)powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_POWERPERCENTAGE]; 278 + hwmgr->platform_descriptor.TDPODLimit = le32_to_cpu(powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_POWERPERCENTAGE]); 243 279 244 280 disable_power_control = 0; 245 281 if (!disable_power_control) { ··· 249 285 PHM_PlatformCaps_PowerControl); 250 286 } 251 287 252 - copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_max, powerplay_table->PowerSavingClockMax); 253 - copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_min, powerplay_table->PowerSavingClockMin); 288 + phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_max, powerplay_table->PowerSavingClockMax, ATOM_VEGA12_PPCLOCK_COUNT); 289 + phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_min, powerplay_table->PowerSavingClockMin, ATOM_VEGA12_PPCLOCK_COUNT); 254 290 255 291 pptable_information->smc_pptable = (PPTable_t *)kmalloc(sizeof(PPTable_t), GFP_KERNEL); 256 292 if (pptable_information->smc_pptable == NULL)
+63 -1
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
··· 46 46 #include "ppinterrupt.h" 47 47 #include "pp_overdriver.h" 48 48 #include "pp_thermal.h" 49 + #include "soc15_common.h" 50 + #include "smuio/smuio_9_0_offset.h" 51 + #include "smuio/smuio_9_0_sh_mask.h" 49 52 50 53 static void vega20_set_default_registry_data(struct pp_hwmgr *hwmgr) 51 54 { ··· 1477 1474 return 0; 1478 1475 } 1479 1476 1477 + static int vega20_enable_mgpu_fan_boost(struct pp_hwmgr *hwmgr) 1478 + { 1479 + int result; 1480 + 1481 + result = smum_send_msg_to_smc(hwmgr, 1482 + PPSMC_MSG_SetMGpuFanBoostLimitRpm); 1483 + PP_ASSERT_WITH_CODE(!result, 1484 + "[EnableMgpuFan] Failed to enable mgpu fan boost!", 1485 + return result); 1486 + 1487 + return 0; 1488 + } 1489 + 1480 1490 static void vega20_init_powergate_state(struct pp_hwmgr *hwmgr) 1481 1491 { 1482 1492 struct vega20_hwmgr *data = ··· 1559 1543 PP_ASSERT_WITH_CODE(!result, 1560 1544 "[EnableDPMTasks] Failed to populate umdpstate clocks!", 1561 1545 return result); 1546 + 1547 + result = smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_GetPptLimit, 1548 + POWER_SOURCE_AC << 16); 1549 + PP_ASSERT_WITH_CODE(!result, 1550 + "[GetPptLimit] get default PPT limit failed!", 1551 + return result); 1552 + hwmgr->power_limit = 1553 + hwmgr->default_power_limit = smum_get_argument(hwmgr); 1562 1554 1563 1555 return 0; 1564 1556 } ··· 1931 1907 void *value, int *size) 1932 1908 { 1933 1909 struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); 1910 + struct amdgpu_device *adev = hwmgr->adev; 1911 + uint32_t val_vid; 1934 1912 int ret = 0; 1935 1913 1936 1914 switch (idx) { ··· 1966 1940 case AMDGPU_PP_SENSOR_GPU_POWER: 1967 1941 *size = 16; 1968 1942 ret = vega20_get_gpu_power(hwmgr, (uint32_t *)value); 1943 + break; 1944 + case AMDGPU_PP_SENSOR_VDDGFX: 1945 + val_vid = (RREG32_SOC15(SMUIO, 0, mmSMUSVI0_TEL_PLANE0) & 1946 + SMUSVI0_TEL_PLANE0__SVI0_PLANE0_VDDCOR_MASK) >> 1947 + SMUSVI0_TEL_PLANE0__SVI0_PLANE0_VDDCOR__SHIFT; 1948 + *((uint32_t *)value) = 1949 + (uint32_t)convert_to_vddc((uint8_t)val_vid); 1969 1950 break; 1970 1951 case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK: 1971 1952 ret = vega20_get_enabled_smc_features(hwmgr, (uint64_t *)value); ··· 2300 2267 return AMD_FAN_CTRL_MANUAL; 2301 2268 else 2302 2269 return AMD_FAN_CTRL_AUTO; 2270 + } 2271 + 2272 + static void vega20_set_fan_control_mode(struct pp_hwmgr *hwmgr, uint32_t mode) 2273 + { 2274 + switch (mode) { 2275 + case AMD_FAN_CTRL_NONE: 2276 + vega20_fan_ctrl_set_fan_speed_percent(hwmgr, 100); 2277 + break; 2278 + case AMD_FAN_CTRL_MANUAL: 2279 + if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) 2280 + vega20_fan_ctrl_stop_smc_fan_control(hwmgr); 2281 + break; 2282 + case AMD_FAN_CTRL_AUTO: 2283 + if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) 2284 + vega20_fan_ctrl_start_smc_fan_control(hwmgr); 2285 + break; 2286 + default: 2287 + break; 2288 + } 2303 2289 } 2304 2290 2305 2291 static int vega20_get_dal_power_level(struct pp_hwmgr *hwmgr, ··· 3217 3165 "[GetPowerProfile] Failed to get activity monitor!", 3218 3166 return result); 3219 3167 3220 - size += sprintf(buf + size, "%2d(%14s%s)\n", 3168 + size += sprintf(buf + size, "%2d %14s%s:\n", 3221 3169 i, profile_name[i], (i == hwmgr->power_profile_mode) ? "*" : " "); 3222 3170 3223 3171 size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", ··· 3484 3432 .disable_smc_firmware_ctf = 3485 3433 vega20_thermal_disable_alert, 3486 3434 /* fan control related */ 3435 + .get_fan_speed_percent = 3436 + vega20_fan_ctrl_get_fan_speed_percent, 3437 + .set_fan_speed_percent = 3438 + vega20_fan_ctrl_set_fan_speed_percent, 3487 3439 .get_fan_speed_info = 3488 3440 vega20_fan_ctrl_get_fan_speed_info, 3489 3441 .get_fan_speed_rpm = 3490 3442 vega20_fan_ctrl_get_fan_speed_rpm, 3443 + .set_fan_speed_rpm = 3444 + vega20_fan_ctrl_set_fan_speed_rpm, 3491 3445 .get_fan_control_mode = 3492 3446 vega20_get_fan_control_mode, 3447 + .set_fan_control_mode = 3448 + vega20_set_fan_control_mode, 3493 3449 /* smu memory related */ 3494 3450 .notify_cac_buffer_info = 3495 3451 vega20_notify_cac_buffer_info, 3452 + .enable_mgpu_fan_boost = 3453 + vega20_enable_mgpu_fan_boost, 3496 3454 }; 3497 3455 3498 3456 int vega20_hwmgr_init(struct pp_hwmgr *hwmgr)
+29 -62
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_processpptables.c
··· 661 661 return 0; 662 662 } 663 663 664 - static int copy_clock_limits_array( 665 - struct pp_hwmgr *hwmgr, 666 - uint32_t **pptable_info_array, 667 - const uint32_t *pptable_array, 668 - uint32_t power_saving_clock_count) 669 - { 670 - uint32_t array_size, i; 671 - uint32_t *table; 672 - 673 - array_size = sizeof(uint32_t) * power_saving_clock_count; 674 - table = kzalloc(array_size, GFP_KERNEL); 675 - if (NULL == table) 676 - return -ENOMEM; 677 - 678 - for (i = 0; i < power_saving_clock_count; i++) 679 - table[i] = pptable_array[i]; 680 - 681 - *pptable_info_array = table; 682 - 683 - return 0; 684 - } 685 - 686 - static int copy_overdrive_settings_limits_array( 687 - struct pp_hwmgr *hwmgr, 688 - uint32_t **pptable_info_array, 689 - const uint32_t *pptable_array, 690 - uint32_t od_setting_count) 691 - { 692 - uint32_t array_size, i; 693 - uint32_t *table; 694 - 695 - array_size = sizeof(uint32_t) * od_setting_count; 696 - table = kzalloc(array_size, GFP_KERNEL); 697 - if (NULL == table) 698 - return -ENOMEM; 699 - 700 - for (i = 0; i < od_setting_count; i++) 701 - table[i] = pptable_array[i]; 702 - 703 - *pptable_info_array = table; 704 - 705 - return 0; 706 - } 707 - 708 664 static int copy_overdrive_feature_capabilities_array( 709 665 struct pp_hwmgr *hwmgr, 710 666 uint8_t **pptable_info_array, ··· 677 721 return -ENOMEM; 678 722 679 723 for (i = 0; i < od_feature_count; i++) { 680 - table[i] = pptable_array[i]; 724 + table[i] = le32_to_cpu(pptable_array[i]); 681 725 if (table[i]) 682 726 od_supported = true; 683 727 } ··· 790 834 791 835 hwmgr->thermal_controller.ucType = powerplay_table->ucThermalControllerType; 792 836 pptable_information->uc_thermal_controller_type = powerplay_table->ucThermalControllerType; 837 + hwmgr->thermal_controller.fanInfo.ulMinRPM = 0; 838 + hwmgr->thermal_controller.fanInfo.ulMaxRPM = powerplay_table->smcPPTable.FanMaximumRpm; 793 839 794 840 set_hw_cap(hwmgr, 795 841 ATOM_VEGA20_PP_THERMALCONTROLLER_NONE != hwmgr->thermal_controller.ucType, ··· 800 842 phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl); 801 843 802 844 if (powerplay_table->OverDrive8Table.ucODTableRevision == 1) { 803 - od_feature_count = (powerplay_table->OverDrive8Table.ODFeatureCount > ATOM_VEGA20_ODFEATURE_COUNT) ? 804 - ATOM_VEGA20_ODFEATURE_COUNT : powerplay_table->OverDrive8Table.ODFeatureCount; 805 - od_setting_count = (powerplay_table->OverDrive8Table.ODSettingCount > ATOM_VEGA20_ODSETTING_COUNT) ? 806 - ATOM_VEGA20_ODSETTING_COUNT : powerplay_table->OverDrive8Table.ODSettingCount; 845 + od_feature_count = 846 + (le32_to_cpu(powerplay_table->OverDrive8Table.ODFeatureCount) > 847 + ATOM_VEGA20_ODFEATURE_COUNT) ? 848 + ATOM_VEGA20_ODFEATURE_COUNT : 849 + le32_to_cpu(powerplay_table->OverDrive8Table.ODFeatureCount); 850 + od_setting_count = 851 + (le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingCount) > 852 + ATOM_VEGA20_ODSETTING_COUNT) ? 853 + ATOM_VEGA20_ODSETTING_COUNT : 854 + le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingCount); 807 855 808 856 copy_overdrive_feature_capabilities_array(hwmgr, 809 857 &pptable_information->od_feature_capabilities, 810 858 powerplay_table->OverDrive8Table.ODFeatureCapabilities, 811 859 od_feature_count); 812 - copy_overdrive_settings_limits_array(hwmgr, 860 + phm_copy_overdrive_settings_limits_array(hwmgr, 813 861 &pptable_information->od_settings_max, 814 862 powerplay_table->OverDrive8Table.ODSettingsMax, 815 863 od_setting_count); 816 - copy_overdrive_settings_limits_array(hwmgr, 864 + phm_copy_overdrive_settings_limits_array(hwmgr, 817 865 &pptable_information->od_settings_min, 818 866 powerplay_table->OverDrive8Table.ODSettingsMin, 819 867 od_setting_count); 820 868 } 821 869 822 - pptable_information->us_small_power_limit1 = powerplay_table->usSmallPowerLimit1; 823 - pptable_information->us_small_power_limit2 = powerplay_table->usSmallPowerLimit2; 824 - pptable_information->us_boost_power_limit = powerplay_table->usBoostPowerLimit; 825 - pptable_information->us_od_turbo_power_limit = powerplay_table->usODTurboPowerLimit; 826 - pptable_information->us_od_powersave_power_limit = powerplay_table->usODPowerSavePowerLimit; 870 + pptable_information->us_small_power_limit1 = le16_to_cpu(powerplay_table->usSmallPowerLimit1); 871 + pptable_information->us_small_power_limit2 = le16_to_cpu(powerplay_table->usSmallPowerLimit2); 872 + pptable_information->us_boost_power_limit = le16_to_cpu(powerplay_table->usBoostPowerLimit); 873 + pptable_information->us_od_turbo_power_limit = le16_to_cpu(powerplay_table->usODTurboPowerLimit); 874 + pptable_information->us_od_powersave_power_limit = le16_to_cpu(powerplay_table->usODPowerSavePowerLimit); 827 875 828 - pptable_information->us_software_shutdown_temp = powerplay_table->usSoftwareShutdownTemp; 876 + pptable_information->us_software_shutdown_temp = le16_to_cpu(powerplay_table->usSoftwareShutdownTemp); 829 877 830 - hwmgr->platform_descriptor.TDPODLimit = (uint16_t)powerplay_table->OverDrive8Table.ODSettingsMax[ATOM_VEGA20_ODSETTING_POWERPERCENTAGE]; 878 + hwmgr->platform_descriptor.TDPODLimit = le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingsMax[ATOM_VEGA20_ODSETTING_POWERPERCENTAGE]); 831 879 832 880 disable_power_control = 0; 833 881 if (!disable_power_control && hwmgr->platform_descriptor.TDPODLimit) ··· 841 877 phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PowerControl); 842 878 843 879 if (powerplay_table->PowerSavingClockTable.ucTableRevision == 1) { 844 - power_saving_clock_count = (powerplay_table->PowerSavingClockTable.PowerSavingClockCount >= ATOM_VEGA20_PPCLOCK_COUNT) ? 845 - ATOM_VEGA20_PPCLOCK_COUNT : powerplay_table->PowerSavingClockTable.PowerSavingClockCount; 846 - copy_clock_limits_array(hwmgr, 880 + power_saving_clock_count = 881 + (le32_to_cpu(powerplay_table->PowerSavingClockTable.PowerSavingClockCount) >= 882 + ATOM_VEGA20_PPCLOCK_COUNT) ? 883 + ATOM_VEGA20_PPCLOCK_COUNT : 884 + le32_to_cpu(powerplay_table->PowerSavingClockTable.PowerSavingClockCount); 885 + phm_copy_clock_limits_array(hwmgr, 847 886 &pptable_information->power_saving_clock_max, 848 887 powerplay_table->PowerSavingClockTable.PowerSavingClockMax, 849 888 power_saving_clock_count); 850 - copy_clock_limits_array(hwmgr, 889 + phm_copy_clock_limits_array(hwmgr, 851 890 &pptable_information->power_saving_clock_min, 852 891 powerplay_table->PowerSavingClockTable.PowerSavingClockMin, 853 892 power_saving_clock_count);
+149 -2
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c
··· 29 29 #include "soc15_common.h" 30 30 #include "pp_debug.h" 31 31 32 + static int vega20_disable_fan_control_feature(struct pp_hwmgr *hwmgr) 33 + { 34 + struct vega20_hwmgr *data = hwmgr->backend; 35 + int ret = 0; 36 + 37 + if (data->smu_features[GNLD_FAN_CONTROL].supported) { 38 + ret = vega20_enable_smc_features( 39 + hwmgr, false, 40 + data->smu_features[GNLD_FAN_CONTROL]. 41 + smu_feature_bitmap); 42 + PP_ASSERT_WITH_CODE(!ret, 43 + "Disable FAN CONTROL feature Failed!", 44 + return ret); 45 + data->smu_features[GNLD_FAN_CONTROL].enabled = false; 46 + } 47 + 48 + return ret; 49 + } 50 + 51 + int vega20_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr) 52 + { 53 + struct vega20_hwmgr *data = hwmgr->backend; 54 + 55 + if (data->smu_features[GNLD_FAN_CONTROL].supported) 56 + return vega20_disable_fan_control_feature(hwmgr); 57 + 58 + return 0; 59 + } 60 + 61 + static int vega20_enable_fan_control_feature(struct pp_hwmgr *hwmgr) 62 + { 63 + struct vega20_hwmgr *data = hwmgr->backend; 64 + int ret = 0; 65 + 66 + if (data->smu_features[GNLD_FAN_CONTROL].supported) { 67 + ret = vega20_enable_smc_features( 68 + hwmgr, true, 69 + data->smu_features[GNLD_FAN_CONTROL]. 70 + smu_feature_bitmap); 71 + PP_ASSERT_WITH_CODE(!ret, 72 + "Enable FAN CONTROL feature Failed!", 73 + return ret); 74 + data->smu_features[GNLD_FAN_CONTROL].enabled = true; 75 + } 76 + 77 + return ret; 78 + } 79 + 80 + int vega20_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr) 81 + { 82 + struct vega20_hwmgr *data = hwmgr->backend; 83 + 84 + if (data->smu_features[GNLD_FAN_CONTROL].supported) 85 + return vega20_enable_fan_control_feature(hwmgr); 86 + 87 + return 0; 88 + } 89 + 90 + static int vega20_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode) 91 + { 92 + struct amdgpu_device *adev = hwmgr->adev; 93 + 94 + WREG32_SOC15(THM, 0, mmCG_FDO_CTRL2, 95 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL2), 96 + CG_FDO_CTRL2, TMIN, 0)); 97 + WREG32_SOC15(THM, 0, mmCG_FDO_CTRL2, 98 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL2), 99 + CG_FDO_CTRL2, FDO_PWM_MODE, mode)); 100 + 101 + return 0; 102 + } 103 + 32 104 static int vega20_get_current_rpm(struct pp_hwmgr *hwmgr, uint32_t *current_rpm) 33 105 { 34 106 int ret = 0; ··· 114 42 return 0; 115 43 } 116 44 45 + int vega20_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, 46 + uint32_t *speed) 47 + { 48 + struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); 49 + PPTable_t *pp_table = &(data->smc_state_table.pp_table); 50 + uint32_t current_rpm, percent = 0; 51 + int ret = 0; 52 + 53 + ret = vega20_get_current_rpm(hwmgr, &current_rpm); 54 + if (ret) 55 + return ret; 56 + 57 + percent = current_rpm * 100 / pp_table->FanMaximumRpm; 58 + 59 + *speed = percent > 100 ? 100 : percent; 60 + 61 + return 0; 62 + } 63 + 64 + int vega20_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, 65 + uint32_t speed) 66 + { 67 + struct amdgpu_device *adev = hwmgr->adev; 68 + uint32_t duty100; 69 + uint32_t duty; 70 + uint64_t tmp64; 71 + 72 + if (speed > 100) 73 + speed = 100; 74 + 75 + if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) 76 + vega20_fan_ctrl_stop_smc_fan_control(hwmgr); 77 + 78 + duty100 = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL1), 79 + CG_FDO_CTRL1, FMAX_DUTY100); 80 + 81 + if (duty100 == 0) 82 + return -EINVAL; 83 + 84 + tmp64 = (uint64_t)speed * duty100; 85 + do_div(tmp64, 100); 86 + duty = (uint32_t)tmp64; 87 + 88 + WREG32_SOC15(THM, 0, mmCG_FDO_CTRL0, 89 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL0), 90 + CG_FDO_CTRL0, FDO_STATIC_DUTY, duty)); 91 + 92 + return vega20_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC); 93 + } 94 + 117 95 int vega20_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, 118 96 struct phm_fan_speed_info *fan_speed_info) 119 97 { 120 98 memset(fan_speed_info, 0, sizeof(*fan_speed_info)); 121 - fan_speed_info->supports_percent_read = false; 122 - fan_speed_info->supports_percent_write = false; 99 + fan_speed_info->supports_percent_read = true; 100 + fan_speed_info->supports_percent_write = true; 123 101 fan_speed_info->supports_rpm_read = true; 124 102 fan_speed_info->supports_rpm_write = true; 125 103 ··· 181 59 *speed = 0; 182 60 183 61 return vega20_get_current_rpm(hwmgr, speed); 62 + } 63 + 64 + int vega20_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed) 65 + { 66 + struct amdgpu_device *adev = hwmgr->adev; 67 + uint32_t tach_period, crystal_clock_freq; 68 + int result = 0; 69 + 70 + if (!speed) 71 + return -EINVAL; 72 + 73 + if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) { 74 + result = vega20_fan_ctrl_stop_smc_fan_control(hwmgr); 75 + if (result) 76 + return result; 77 + } 78 + 79 + crystal_clock_freq = amdgpu_asic_get_xclk((struct amdgpu_device *)hwmgr->adev); 80 + tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); 81 + WREG32_SOC15(THM, 0, mmCG_TACH_CTRL, 82 + REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL), 83 + CG_TACH_CTRL, TARGET_PERIOD, 84 + tach_period)); 85 + 86 + return vega20_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM); 184 87 } 185 88 186 89 /**
+9 -2
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.h
··· 50 50 #define FDO_PWM_MODE_STATIC_RPM 5 51 51 52 52 extern int vega20_thermal_get_temperature(struct pp_hwmgr *hwmgr); 53 - extern int vega20_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr); 54 53 extern int vega20_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, 55 54 struct phm_fan_speed_info *fan_speed_info); 56 - extern int vega20_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr); 57 55 extern int vega20_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, 58 56 uint32_t *speed); 57 + extern int vega20_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, 58 + uint32_t speed); 59 + extern int vega20_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, 60 + uint32_t *speed); 61 + extern int vega20_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, 62 + uint32_t speed); 63 + extern int vega20_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr); 64 + extern int vega20_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr); 59 65 extern int vega20_thermal_disable_alert(struct pp_hwmgr *hwmgr); 60 66 extern int vega20_start_thermal_controller(struct pp_hwmgr *hwmgr, 61 67 struct PP_TemperatureRange *range); 68 + extern int vega20_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr); 62 69 63 70 #endif 64 71
+2 -1
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
··· 328 328 int (*set_power_limit)(struct pp_hwmgr *hwmgr, uint32_t n); 329 329 int (*powergate_mmhub)(struct pp_hwmgr *hwmgr); 330 330 int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); 331 + int (*powergate_sdma)(struct pp_hwmgr *hwmgr, bool bgate); 332 + int (*enable_mgpu_fan_boost)(struct pp_hwmgr *hwmgr); 331 333 }; 332 334 333 335 struct pp_table_func { ··· 734 732 void *smu_backend; 735 733 const struct pp_smumgr_func *smumgr_funcs; 736 734 bool is_kicker; 737 - bool reload_fw; 738 735 739 736 enum PP_DAL_POWERLEVEL dal_power_level; 740 737 struct phm_dynamic_state_info dyn_state;
+6
drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h
··· 269 269 } PPCLK_e; 270 270 271 271 typedef enum { 272 + POWER_SOURCE_AC, 273 + POWER_SOURCE_DC, 274 + POWER_SOURCE_COUNT, 275 + } POWER_SOURCE_e; 276 + 277 + typedef enum { 272 278 VOLTAGE_MODE_AVFS = 0, 273 279 VOLTAGE_MODE_AVFS_SS, 274 280 VOLTAGE_MODE_SS,
+2
drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
··· 2269 2269 case DRAM_LOG_BUFF_SIZE: 2270 2270 return offsetof(SMU7_SoftRegisters, DRAM_LOG_BUFF_SIZE); 2271 2271 } 2272 + break; 2272 2273 case SMU_Discrete_DpmTable: 2273 2274 switch (member) { 2274 2275 case LowSclkInterruptThreshold: 2275 2276 return offsetof(SMU7_Discrete_DpmTable, LowSclkInterruptT); 2276 2277 } 2278 + break; 2277 2279 } 2278 2280 pr_debug("can't get the offset of type %x member %x\n", type, member); 2279 2281 return 0;
+2 -10
drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
··· 302 302 hwmgr->avfs_supported = false; 303 303 } 304 304 305 - /* To initialize all clock gating before RLC loaded and running.*/ 306 - amdgpu_device_ip_set_clockgating_state(hwmgr->adev, 307 - AMD_IP_BLOCK_TYPE_GFX, AMD_CG_STATE_GATE); 308 - amdgpu_device_ip_set_clockgating_state(hwmgr->adev, 309 - AMD_IP_BLOCK_TYPE_GMC, AMD_CG_STATE_GATE); 310 - amdgpu_device_ip_set_clockgating_state(hwmgr->adev, 311 - AMD_IP_BLOCK_TYPE_SDMA, AMD_CG_STATE_GATE); 312 - amdgpu_device_ip_set_clockgating_state(hwmgr->adev, 313 - AMD_IP_BLOCK_TYPE_COMMON, AMD_CG_STATE_GATE); 314 - 315 305 /* Setup SoftRegsStart here for register lookup in case 316 306 * DummyBackEnd is used and ProcessFirmwareHeader is not executed 317 307 */ ··· 2321 2331 case DRAM_LOG_BUFF_SIZE: 2322 2332 return offsetof(SMU73_SoftRegisters, DRAM_LOG_BUFF_SIZE); 2323 2333 } 2334 + break; 2324 2335 case SMU_Discrete_DpmTable: 2325 2336 switch (member) { 2326 2337 case UvdBootLevel: ··· 2331 2340 case LowSclkInterruptThreshold: 2332 2341 return offsetof(SMU73_Discrete_DpmTable, LowSclkInterruptThreshold); 2333 2342 } 2343 + break; 2334 2344 } 2335 2345 pr_warn("can't get the offset of type %x member %x\n", type, member); 2336 2346 return 0;
+13 -12
drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c
··· 232 232 233 233 static int iceland_start_smu(struct pp_hwmgr *hwmgr) 234 234 { 235 + struct iceland_smumgr *priv = hwmgr->smu_backend; 235 236 int result; 236 237 237 - result = iceland_smu_upload_firmware_image(hwmgr); 238 - if (result) 239 - return result; 240 - result = iceland_smu_start_smc(hwmgr); 241 - if (result) 242 - return result; 243 - 244 238 if (!smu7_is_smc_ram_running(hwmgr)) { 245 - pr_info("smu not running, upload firmware again \n"); 246 239 result = iceland_smu_upload_firmware_image(hwmgr); 247 240 if (result) 248 241 return result; 249 242 250 - result = iceland_smu_start_smc(hwmgr); 251 - if (result) 252 - return result; 243 + iceland_smu_start_smc(hwmgr); 253 244 } 245 + 246 + /* Setup SoftRegsStart here to visit the register UcodeLoadStatus 247 + * to check fw loading state 248 + */ 249 + smu7_read_smc_sram_dword(hwmgr, 250 + SMU71_FIRMWARE_HEADER_LOCATION + 251 + offsetof(SMU71_Firmware_Header, SoftRegisters), 252 + &(priv->smu7_data.soft_regs_start), 0x40000); 254 253 255 254 result = smu7_request_smu_load_fw(hwmgr); 256 255 ··· 2236 2237 case DRAM_LOG_BUFF_SIZE: 2237 2238 return offsetof(SMU71_SoftRegisters, DRAM_LOG_BUFF_SIZE); 2238 2239 } 2240 + break; 2239 2241 case SMU_Discrete_DpmTable: 2240 2242 switch (member) { 2241 2243 case LowSclkInterruptThreshold: 2242 2244 return offsetof(SMU71_Discrete_DpmTable, LowSclkInterruptThreshold); 2243 2245 } 2246 + break; 2244 2247 } 2245 2248 pr_warn("can't get the offset of type %x member %x\n", type, member); 2246 2249 return 0; ··· 2663 2662 .smu_fini = &smu7_smu_fini, 2664 2663 .start_smu = &iceland_start_smu, 2665 2664 .check_fw_load_finish = &smu7_check_fw_load_finish, 2666 - .request_smu_load_fw = &smu7_reload_firmware, 2665 + .request_smu_load_fw = &smu7_request_smu_load_fw, 2667 2666 .request_smu_load_specific_fw = &iceland_request_smu_load_specific_fw, 2668 2667 .send_msg_to_smc = &smu7_send_msg_to_smc, 2669 2668 .send_msg_to_smc_with_parameter = &smu7_send_msg_to_smc_with_parameter,
+1 -30
drivers/gpu/drm/amd/powerplay/smumgr/smu10_smumgr.c
··· 186 186 return 0; 187 187 } 188 188 189 - /* sdma is disabled by default in vbios, need to re-enable in driver */ 190 - static void smu10_smc_enable_sdma(struct pp_hwmgr *hwmgr) 191 - { 192 - smu10_send_msg_to_smc(hwmgr, 193 - PPSMC_MSG_PowerUpSdma); 194 - } 195 - 196 - static void smu10_smc_disable_sdma(struct pp_hwmgr *hwmgr) 197 - { 198 - smu10_send_msg_to_smc(hwmgr, 199 - PPSMC_MSG_PowerDownSdma); 200 - } 201 - 202 - /* vcn is disabled by default in vbios, need to re-enable in driver */ 203 - static void smu10_smc_enable_vcn(struct pp_hwmgr *hwmgr) 204 - { 205 - smu10_send_msg_to_smc_with_parameter(hwmgr, 206 - PPSMC_MSG_PowerUpVcn, 0); 207 - } 208 - 209 - static void smu10_smc_disable_vcn(struct pp_hwmgr *hwmgr) 210 - { 211 - smu10_send_msg_to_smc_with_parameter(hwmgr, 212 - PPSMC_MSG_PowerDownVcn, 0); 213 - } 214 - 215 189 static int smu10_smu_fini(struct pp_hwmgr *hwmgr) 216 190 { 217 191 struct smu10_smumgr *priv = 218 192 (struct smu10_smumgr *)(hwmgr->smu_backend); 219 193 220 194 if (priv) { 221 - smu10_smc_disable_sdma(hwmgr); 222 - smu10_smc_disable_vcn(hwmgr); 223 195 amdgpu_bo_free_kernel(&priv->smu_tables.entry[SMU10_WMTABLE].handle, 224 196 &priv->smu_tables.entry[SMU10_WMTABLE].mc_addr, 225 197 &priv->smu_tables.entry[SMU10_WMTABLE].table); ··· 215 243 216 244 if (smu10_verify_smc_interface(hwmgr)) 217 245 return -EINVAL; 218 - smu10_smc_enable_sdma(hwmgr); 219 - smu10_smc_enable_vcn(hwmgr); 246 + 220 247 return 0; 221 248 } 222 249
+8 -47
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c
··· 302 302 return 0; 303 303 } 304 304 305 - /* Convert the firmware type to SMU type mask. For MEC, we need to check all MEC related type */ 306 - 307 - static uint32_t smu7_get_mask_for_firmware_type(uint32_t fw_type) 308 - { 309 - uint32_t result = 0; 310 - 311 - switch (fw_type) { 312 - case UCODE_ID_SDMA0: 313 - result = UCODE_ID_SDMA0_MASK; 314 - break; 315 - case UCODE_ID_SDMA1: 316 - result = UCODE_ID_SDMA1_MASK; 317 - break; 318 - case UCODE_ID_CP_CE: 319 - result = UCODE_ID_CP_CE_MASK; 320 - break; 321 - case UCODE_ID_CP_PFP: 322 - result = UCODE_ID_CP_PFP_MASK; 323 - break; 324 - case UCODE_ID_CP_ME: 325 - result = UCODE_ID_CP_ME_MASK; 326 - break; 327 - case UCODE_ID_CP_MEC: 328 - case UCODE_ID_CP_MEC_JT1: 329 - case UCODE_ID_CP_MEC_JT2: 330 - result = UCODE_ID_CP_MEC_MASK; 331 - break; 332 - case UCODE_ID_RLC_G: 333 - result = UCODE_ID_RLC_G_MASK; 334 - break; 335 - default: 336 - pr_info("UCode type is out of range! \n"); 337 - result = 0; 338 - } 339 - 340 - return result; 341 - } 342 - 343 305 static int smu7_populate_single_firmware_entry(struct pp_hwmgr *hwmgr, 344 306 uint32_t fw_type, 345 307 struct SMU_Entry *entry) ··· 343 381 uint32_t fw_to_load; 344 382 int r = 0; 345 383 346 - if (!hwmgr->reload_fw) { 347 - pr_info("skip reloading...\n"); 348 - return 0; 349 - } 384 + amdgpu_ucode_init_bo(hwmgr->adev); 350 385 351 386 if (smu_data->soft_regs_start) 352 387 cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, ··· 426 467 smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_HI, upper_32_bits(smu_data->header_buffer.mc_addr)); 427 468 smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_LO, lower_32_bits(smu_data->header_buffer.mc_addr)); 428 469 429 - if (smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_LoadUcodes, fw_to_load)) 430 - pr_err("Fail to Request SMU Load uCode"); 470 + smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_LoadUcodes, fw_to_load); 431 471 432 - return r; 472 + r = smu7_check_fw_load_finish(hwmgr, fw_to_load); 473 + if (!r) 474 + return 0; 475 + 476 + pr_err("SMU load firmware failed\n"); 433 477 434 478 failed: 435 479 kfree(smu_data->toc); ··· 444 482 int smu7_check_fw_load_finish(struct pp_hwmgr *hwmgr, uint32_t fw_type) 445 483 { 446 484 struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend); 447 - uint32_t fw_mask = smu7_get_mask_for_firmware_type(fw_type); 448 485 uint32_t ret; 449 486 450 487 ret = phm_wait_on_indirect_register(hwmgr, mmSMC_IND_INDEX_11, 451 488 smu_data->soft_regs_start + smum_get_offsetof(hwmgr, 452 489 SMU_SoftRegisters, UcodeLoadStatus), 453 - fw_mask, fw_mask); 490 + fw_type, fw_type); 454 491 return ret; 455 492 } 456 493
+31 -32
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c
··· 658 658 { 659 659 struct smu8_smumgr *smu8_smu = hwmgr->smu_backend; 660 660 uint32_t smc_address; 661 + uint32_t fw_to_check = 0; 662 + int ret; 661 663 662 - if (!hwmgr->reload_fw) { 663 - pr_info("skip reloading...\n"); 664 - return 0; 665 - } 664 + amdgpu_ucode_init_bo(hwmgr->adev); 666 665 667 666 smu8_smu_populate_firmware_entries(hwmgr); 668 667 ··· 688 689 smu8_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_ExecuteJob, 689 690 smu8_smu->toc_entry_power_profiling_index); 690 691 691 - return smu8_send_msg_to_smc_with_parameter(hwmgr, 692 + smu8_send_msg_to_smc_with_parameter(hwmgr, 692 693 PPSMC_MSG_ExecuteJob, 693 694 smu8_smu->toc_entry_initialize_index); 695 + 696 + fw_to_check = UCODE_ID_RLC_G_MASK | 697 + UCODE_ID_SDMA0_MASK | 698 + UCODE_ID_SDMA1_MASK | 699 + UCODE_ID_CP_CE_MASK | 700 + UCODE_ID_CP_ME_MASK | 701 + UCODE_ID_CP_PFP_MASK | 702 + UCODE_ID_CP_MEC_JT1_MASK | 703 + UCODE_ID_CP_MEC_JT2_MASK; 704 + 705 + if (hwmgr->chip_id == CHIP_STONEY) 706 + fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); 707 + 708 + ret = smu8_check_fw_load_finish(hwmgr, fw_to_check); 709 + if (ret) { 710 + pr_err("SMU firmware load failed\n"); 711 + return ret; 712 + } 713 + 714 + ret = smu8_load_mec_firmware(hwmgr); 715 + if (ret) { 716 + pr_err("Mec Firmware load failed\n"); 717 + return ret; 718 + } 719 + 720 + return 0; 694 721 } 695 722 696 723 static int smu8_start_smu(struct pp_hwmgr *hwmgr) 697 724 { 698 - int ret = 0; 699 - uint32_t fw_to_check = 0; 700 725 struct amdgpu_device *adev = hwmgr->adev; 701 726 702 727 uint32_t index = SMN_MP1_SRAM_START_ADDR + ··· 735 712 hwmgr->smu_version = cgs_read_register(hwmgr->device, mmMP0PUB_IND_DATA); 736 713 adev->pm.fw_version = hwmgr->smu_version >> 8; 737 714 738 - fw_to_check = UCODE_ID_RLC_G_MASK | 739 - UCODE_ID_SDMA0_MASK | 740 - UCODE_ID_SDMA1_MASK | 741 - UCODE_ID_CP_CE_MASK | 742 - UCODE_ID_CP_ME_MASK | 743 - UCODE_ID_CP_PFP_MASK | 744 - UCODE_ID_CP_MEC_JT1_MASK | 745 - UCODE_ID_CP_MEC_JT2_MASK; 746 - 747 - if (hwmgr->chip_id == CHIP_STONEY) 748 - fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); 749 - 750 - smu8_request_smu_load_fw(hwmgr); 751 - 752 - ret = smu8_check_fw_load_finish(hwmgr, fw_to_check); 753 - if (ret) { 754 - pr_err("SMU firmware load failed\n"); 755 - return ret; 756 - } 757 - 758 - ret = smu8_load_mec_firmware(hwmgr); 759 - if (ret) 760 - pr_err("Mec Firmware load failed\n"); 761 - 762 - return ret; 715 + return smu8_request_smu_load_fw(hwmgr); 763 716 } 764 717 765 718 static int smu8_smu_init(struct pp_hwmgr *hwmgr)
+11
drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
··· 192 192 193 193 static int tonga_start_smu(struct pp_hwmgr *hwmgr) 194 194 { 195 + struct tonga_smumgr *priv = hwmgr->smu_backend; 195 196 int result; 196 197 197 198 /* Only start SMC if SMC RAM is not running */ ··· 209 208 return result; 210 209 } 211 210 } 211 + 212 + /* Setup SoftRegsStart here to visit the register UcodeLoadStatus 213 + * to check fw loading state 214 + */ 215 + smu7_read_smc_sram_dword(hwmgr, 216 + SMU72_FIRMWARE_HEADER_LOCATION + 217 + offsetof(SMU72_Firmware_Header, SoftRegisters), 218 + &(priv->smu7_data.soft_regs_start), 0x40000); 212 219 213 220 result = smu7_request_smu_load_fw(hwmgr); 214 221 ··· 2628 2619 case DRAM_LOG_BUFF_SIZE: 2629 2620 return offsetof(SMU72_SoftRegisters, DRAM_LOG_BUFF_SIZE); 2630 2621 } 2622 + break; 2631 2623 case SMU_Discrete_DpmTable: 2632 2624 switch (member) { 2633 2625 case UvdBootLevel: ··· 2638 2628 case LowSclkInterruptThreshold: 2639 2629 return offsetof(SMU72_Discrete_DpmTable, LowSclkInterruptThreshold); 2640 2630 } 2631 + break; 2641 2632 } 2642 2633 pr_warn("can't get the offset of type %x member %x\n", type, member); 2643 2634 return 0;
+2
drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c
··· 2185 2185 case DRAM_LOG_BUFF_SIZE: 2186 2186 return offsetof(SMU75_SoftRegisters, DRAM_LOG_BUFF_SIZE); 2187 2187 } 2188 + break; 2188 2189 case SMU_Discrete_DpmTable: 2189 2190 switch (member) { 2190 2191 case UvdBootLevel: ··· 2195 2194 case LowSclkInterruptThreshold: 2196 2195 return offsetof(SMU75_Discrete_DpmTable, LowSclkInterruptThreshold); 2197 2196 } 2197 + break; 2198 2198 } 2199 2199 pr_warn("can't get the offset of type %x member %x\n", type, member); 2200 2200 return 0;
+1 -1
drivers/gpu/drm/radeon/evergreen_cs.c
··· 2416 2416 size = radeon_get_ib_value(p, idx+1+(i*8)+1); 2417 2417 if (p->rdev && (size + offset) > radeon_bo_size(reloc->robj)) { 2418 2418 /* force size to size of the buffer */ 2419 - dev_warn(p->dev, "vbo resource seems too big for the bo\n"); 2419 + dev_warn_ratelimited(p->dev, "vbo resource seems too big for the bo\n"); 2420 2420 ib[idx+1+(i*8)+1] = radeon_bo_size(reloc->robj) - offset; 2421 2421 } 2422 2422
+1 -2
drivers/gpu/drm/scheduler/sched_entity.c
··· 467 467 struct dma_fence *fence; 468 468 struct drm_sched_rq *rq; 469 469 470 - if (!spsc_queue_count(&entity->job_queue) == 0 || 471 - entity->num_rq_list <= 1) 470 + if (spsc_queue_count(&entity->job_queue) || entity->num_rq_list <= 1) 472 471 return; 473 472 474 473 fence = READ_ONCE(entity->last_scheduled);
+5 -20
drivers/gpu/drm/ttm/ttm_bo.c
··· 247 247 } 248 248 EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); 249 249 250 - static void ttm_list_move_bulk_tail(struct list_head *list, 251 - struct list_head *first, 252 - struct list_head *last) 253 - { 254 - first->prev->next = last->next; 255 - last->next->prev = first->prev; 256 - 257 - list->prev->next = first; 258 - first->prev = list->prev; 259 - 260 - last->next = list; 261 - list->prev = last; 262 - } 263 - 264 250 void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) 265 251 { 266 252 unsigned i; ··· 262 276 reservation_object_assert_held(pos->last->resv); 263 277 264 278 man = &pos->first->bdev->man[TTM_PL_TT]; 265 - ttm_list_move_bulk_tail(&man->lru[i], &pos->first->lru, 266 - &pos->last->lru); 279 + list_bulk_move_tail(&man->lru[i], &pos->first->lru, 280 + &pos->last->lru); 267 281 } 268 282 269 283 for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { ··· 277 291 reservation_object_assert_held(pos->last->resv); 278 292 279 293 man = &pos->first->bdev->man[TTM_PL_VRAM]; 280 - ttm_list_move_bulk_tail(&man->lru[i], &pos->first->lru, 281 - &pos->last->lru); 294 + list_bulk_move_tail(&man->lru[i], &pos->first->lru, 295 + &pos->last->lru); 282 296 } 283 297 284 298 for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { ··· 292 306 reservation_object_assert_held(pos->last->resv); 293 307 294 308 lru = &pos->first->bdev->glob->swap_lru[i]; 295 - ttm_list_move_bulk_tail(lru, &pos->first->swap, 296 - &pos->last->swap); 309 + list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap); 297 310 } 298 311 } 299 312 EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail);
+23
include/linux/list.h
··· 184 184 } 185 185 186 186 /** 187 + * list_bulk_move_tail - move a subsection of a list to its tail 188 + * @head: the head that will follow our entry 189 + * @first: first entry to move 190 + * @last: last entry to move, can be the same as first 191 + * 192 + * Move all entries between @first and including @last before @head. 193 + * All three entries must belong to the same linked list. 194 + */ 195 + static inline void list_bulk_move_tail(struct list_head *head, 196 + struct list_head *first, 197 + struct list_head *last) 198 + { 199 + first->prev->next = last->next; 200 + last->next->prev = first->prev; 201 + 202 + head->prev->next = first; 203 + first->prev = head->prev; 204 + 205 + last->next = head; 206 + head->prev = last; 207 + } 208 + 209 + /** 187 210 * list_is_last - tests whether @list is the last entry in list @head 188 211 * @list: the entry to test 189 212 * @head: the head of the list