diff options
author | Dave Airlie <airlied@redhat.com> | 2018-10-11 00:53:40 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2018-10-11 00:53:45 -0400 |
commit | ca4b869240d5810ebac6b1570ad7beffcfbac2f5 (patch) | |
tree | d7e36e551b058316ab35e28f1bb992ce06b2ce0c /drivers | |
parent | 46972c03ab667dc298cad0c9db517fb9b1521b5f (diff) | |
parent | df2fc43d09d3ee5ede82cab9299df5e78aa427b5 (diff) |
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
Diffstat (limited to 'drivers')
90 files changed, 1629 insertions, 1144 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index c05b39438663..d0102cfc8efb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -81,6 +81,23 @@ | |||
81 | #include "amdgpu_bo_list.h" | 81 | #include "amdgpu_bo_list.h" |
82 | #include "amdgpu_gem.h" | 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 | * Modules parameters. | 102 | * Modules parameters. |
86 | */ | 103 | */ |
@@ -134,6 +151,7 @@ extern int amdgpu_compute_multipipe; | |||
134 | extern int amdgpu_gpu_recovery; | 151 | extern int amdgpu_gpu_recovery; |
135 | extern int amdgpu_emu_mode; | 152 | extern int amdgpu_emu_mode; |
136 | extern uint amdgpu_smu_memory_pool_size; | 153 | extern uint amdgpu_smu_memory_pool_size; |
154 | extern struct amdgpu_mgpu_info mgpu_info; | ||
137 | 155 | ||
138 | #ifdef CONFIG_DRM_AMDGPU_SI | 156 | #ifdef CONFIG_DRM_AMDGPU_SI |
139 | extern int amdgpu_si_support; | 157 | extern int amdgpu_si_support; |
@@ -598,31 +616,6 @@ void amdgpu_benchmark(struct amdgpu_device *adev, int test_number); | |||
598 | */ | 616 | */ |
599 | void amdgpu_test_moves(struct amdgpu_device *adev); | 617 | void amdgpu_test_moves(struct amdgpu_device *adev); |
600 | 618 | ||
601 | |||
602 | /* | ||
603 | * amdgpu smumgr functions | ||
604 | */ | ||
605 | struct amdgpu_smumgr_funcs { | ||
606 | int (*check_fw_load_finish)(struct amdgpu_device *adev, uint32_t fwtype); | ||
607 | int (*request_smu_load_fw)(struct amdgpu_device *adev); | ||
608 | int (*request_smu_specific_fw)(struct amdgpu_device *adev, uint32_t fwtype); | ||
609 | }; | ||
610 | |||
611 | /* | ||
612 | * amdgpu smumgr | ||
613 | */ | ||
614 | struct amdgpu_smumgr { | ||
615 | struct amdgpu_bo *toc_buf; | ||
616 | struct amdgpu_bo *smu_buf; | ||
617 | /* asic priv smu data */ | ||
618 | void *priv; | ||
619 | spinlock_t smu_lock; | ||
620 | /* smumgr functions */ | ||
621 | const struct amdgpu_smumgr_funcs *smumgr_funcs; | ||
622 | /* ucode loading complete flag */ | ||
623 | uint32_t fw_flags; | ||
624 | }; | ||
625 | |||
626 | /* | 619 | /* |
627 | * ASIC specific register table accessible by UMD | 620 | * ASIC specific register table accessible by UMD |
628 | */ | 621 | */ |
@@ -958,9 +951,6 @@ struct amdgpu_device { | |||
958 | u32 cg_flags; | 951 | u32 cg_flags; |
959 | u32 pg_flags; | 952 | u32 pg_flags; |
960 | 953 | ||
961 | /* amdgpu smumgr */ | ||
962 | struct amdgpu_smumgr smu; | ||
963 | |||
964 | /* gfx */ | 954 | /* gfx */ |
965 | struct amdgpu_gfx gfx; | 955 | struct amdgpu_gfx gfx; |
966 | 956 | ||
@@ -1025,6 +1015,9 @@ struct amdgpu_device { | |||
1025 | bool has_hw_reset; | 1015 | bool has_hw_reset; |
1026 | u8 reset_magic[AMDGPU_RESET_MAGIC_NUM]; | 1016 | u8 reset_magic[AMDGPU_RESET_MAGIC_NUM]; |
1027 | 1017 | ||
1018 | /* s3/s4 mask */ | ||
1019 | bool in_suspend; | ||
1020 | |||
1028 | /* record last mm index being written through WREG32*/ | 1021 | /* record last mm index being written through WREG32*/ |
1029 | unsigned long last_mm_index; | 1022 | unsigned long last_mm_index; |
1030 | bool in_gpu_reset; | 1023 | bool in_gpu_reset; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c index 6488e90ec948..7f0afc526419 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | |||
@@ -359,7 +359,9 @@ out: | |||
359 | * | 359 | * |
360 | * Checks the acpi event and if it matches an atif event, | 360 | * Checks the acpi event and if it matches an atif event, |
361 | * handles it. | 361 | * handles it. |
362 | * Returns NOTIFY code | 362 | * |
363 | * Returns: | ||
364 | * NOTIFY_BAD or NOTIFY_DONE, depending on the event. | ||
363 | */ | 365 | */ |
364 | static int amdgpu_atif_handler(struct amdgpu_device *adev, | 366 | static int amdgpu_atif_handler(struct amdgpu_device *adev, |
365 | struct acpi_bus_event *event) | 367 | struct acpi_bus_event *event) |
@@ -373,11 +375,16 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev, | |||
373 | if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0) | 375 | if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0) |
374 | return NOTIFY_DONE; | 376 | return NOTIFY_DONE; |
375 | 377 | ||
378 | /* Is this actually our event? */ | ||
376 | if (!atif || | 379 | if (!atif || |
377 | !atif->notification_cfg.enabled || | 380 | !atif->notification_cfg.enabled || |
378 | event->type != atif->notification_cfg.command_code) | 381 | event->type != atif->notification_cfg.command_code) { |
379 | /* Not our event */ | 382 | /* These events will generate keypresses otherwise */ |
380 | return NOTIFY_DONE; | 383 | if (event->type == ACPI_VIDEO_NOTIFY_PROBE) |
384 | return NOTIFY_BAD; | ||
385 | else | ||
386 | return NOTIFY_DONE; | ||
387 | } | ||
381 | 388 | ||
382 | if (atif->functions.sbios_requests) { | 389 | if (atif->functions.sbios_requests) { |
383 | struct atif_sbios_requests req; | 390 | struct atif_sbios_requests req; |
@@ -386,7 +393,7 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev, | |||
386 | count = amdgpu_atif_get_sbios_requests(atif, &req); | 393 | count = amdgpu_atif_get_sbios_requests(atif, &req); |
387 | 394 | ||
388 | if (count <= 0) | 395 | if (count <= 0) |
389 | return NOTIFY_DONE; | 396 | return NOTIFY_BAD; |
390 | 397 | ||
391 | DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count); | 398 | DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count); |
392 | 399 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index bd79d0a31942..1e4dd09a5072 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -1525,6 +1525,92 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) | |||
1525 | return 0; | 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 | * amdgpu_device_ip_init - run init for hardware IPs | 1615 | * amdgpu_device_ip_init - run init for hardware IPs |
1530 | * | 1616 | * |
@@ -1581,19 +1667,21 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) | |||
1581 | } | 1667 | } |
1582 | } | 1668 | } |
1583 | 1669 | ||
1584 | for (i = 0; i < adev->num_ip_blocks; i++) { | 1670 | r = amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init complete*/ |
1585 | if (!adev->ip_blocks[i].status.sw) | 1671 | if (r) |
1586 | continue; | 1672 | return r; |
1587 | if (adev->ip_blocks[i].status.hw) | 1673 | |
1588 | continue; | 1674 | r = amdgpu_device_ip_hw_init_phase1(adev); |
1589 | r = adev->ip_blocks[i].version->funcs->hw_init((void *)adev); | 1675 | if (r) |
1590 | if (r) { | 1676 | return r; |
1591 | DRM_ERROR("hw_init of IP block <%s> failed %d\n", | 1677 | |
1592 | adev->ip_blocks[i].version->funcs->name, r); | 1678 | r = amdgpu_device_fw_loading(adev); |
1593 | return r; | 1679 | if (r) |
1594 | } | 1680 | return r; |
1595 | adev->ip_blocks[i].status.hw = true; | 1681 | |
1596 | } | 1682 | r = amdgpu_device_ip_hw_init_phase2(adev); |
1683 | if (r) | ||
1684 | return r; | ||
1597 | 1685 | ||
1598 | amdgpu_xgmi_add_device(adev); | 1686 | amdgpu_xgmi_add_device(adev); |
1599 | amdgpu_amdkfd_device_init(adev); | 1687 | amdgpu_amdkfd_device_init(adev); |
@@ -1656,7 +1744,7 @@ static int amdgpu_device_set_cg_state(struct amdgpu_device *adev, | |||
1656 | 1744 | ||
1657 | for (j = 0; j < adev->num_ip_blocks; j++) { | 1745 | for (j = 0; j < adev->num_ip_blocks; j++) { |
1658 | i = state == AMD_CG_STATE_GATE ? j : adev->num_ip_blocks - j - 1; | 1746 | i = state == AMD_CG_STATE_GATE ? j : adev->num_ip_blocks - j - 1; |
1659 | if (!adev->ip_blocks[i].status.valid) | 1747 | if (!adev->ip_blocks[i].status.late_initialized) |
1660 | continue; | 1748 | continue; |
1661 | /* skip CG for VCE/UVD, it's handled specially */ | 1749 | /* skip CG for VCE/UVD, it's handled specially */ |
1662 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && | 1750 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && |
@@ -1686,7 +1774,7 @@ static int amdgpu_device_set_pg_state(struct amdgpu_device *adev, enum amd_power | |||
1686 | 1774 | ||
1687 | for (j = 0; j < adev->num_ip_blocks; j++) { | 1775 | for (j = 0; j < adev->num_ip_blocks; j++) { |
1688 | i = state == AMD_PG_STATE_GATE ? j : adev->num_ip_blocks - j - 1; | 1776 | i = state == AMD_PG_STATE_GATE ? j : adev->num_ip_blocks - j - 1; |
1689 | if (!adev->ip_blocks[i].status.valid) | 1777 | if (!adev->ip_blocks[i].status.late_initialized) |
1690 | continue; | 1778 | continue; |
1691 | /* skip CG for VCE/UVD, it's handled specially */ | 1779 | /* skip CG for VCE/UVD, it's handled specially */ |
1692 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && | 1780 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && |
@@ -1723,7 +1811,7 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev) | |||
1723 | int i = 0, r; | 1811 | int i = 0, r; |
1724 | 1812 | ||
1725 | for (i = 0; i < adev->num_ip_blocks; i++) { | 1813 | for (i = 0; i < adev->num_ip_blocks; i++) { |
1726 | if (!adev->ip_blocks[i].status.valid) | 1814 | if (!adev->ip_blocks[i].status.hw) |
1727 | continue; | 1815 | continue; |
1728 | if (adev->ip_blocks[i].version->funcs->late_init) { | 1816 | if (adev->ip_blocks[i].version->funcs->late_init) { |
1729 | r = adev->ip_blocks[i].version->funcs->late_init((void *)adev); | 1817 | r = adev->ip_blocks[i].version->funcs->late_init((void *)adev); |
@@ -1732,8 +1820,8 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev) | |||
1732 | adev->ip_blocks[i].version->funcs->name, r); | 1820 | adev->ip_blocks[i].version->funcs->name, r); |
1733 | return r; | 1821 | return r; |
1734 | } | 1822 | } |
1735 | adev->ip_blocks[i].status.late_initialized = true; | ||
1736 | } | 1823 | } |
1824 | adev->ip_blocks[i].status.late_initialized = true; | ||
1737 | } | 1825 | } |
1738 | 1826 | ||
1739 | amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE); | 1827 | amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE); |
@@ -1803,6 +1891,7 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) | |||
1803 | continue; | 1891 | continue; |
1804 | 1892 | ||
1805 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) { | 1893 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) { |
1894 | amdgpu_ucode_free_bo(adev); | ||
1806 | amdgpu_free_static_csa(adev); | 1895 | amdgpu_free_static_csa(adev); |
1807 | amdgpu_device_wb_fini(adev); | 1896 | amdgpu_device_wb_fini(adev); |
1808 | amdgpu_device_vram_scratch_fini(adev); | 1897 | amdgpu_device_vram_scratch_fini(adev); |
@@ -1833,6 +1922,43 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) | |||
1833 | return 0; | 1922 | return 0; |
1834 | } | 1923 | } |
1835 | 1924 | ||
1925 | static int amdgpu_device_enable_mgpu_fan_boost(void) | ||
1926 | { | ||
1927 | struct amdgpu_gpu_instance *gpu_ins; | ||
1928 | struct amdgpu_device *adev; | ||
1929 | int i, ret = 0; | ||
1930 | |||
1931 | mutex_lock(&mgpu_info.mutex); | ||
1932 | |||
1933 | /* | ||
1934 | * MGPU fan boost feature should be enabled | ||
1935 | * only when there are two or more dGPUs in | ||
1936 | * the system | ||
1937 | */ | ||
1938 | if (mgpu_info.num_dgpu < 2) | ||
1939 | goto out; | ||
1940 | |||
1941 | for (i = 0; i < mgpu_info.num_dgpu; i++) { | ||
1942 | gpu_ins = &(mgpu_info.gpu_ins[i]); | ||
1943 | adev = gpu_ins->adev; | ||
1944 | if (!(adev->flags & AMD_IS_APU) && | ||
1945 | !gpu_ins->mgpu_fan_enabled && | ||
1946 | adev->powerplay.pp_funcs && | ||
1947 | adev->powerplay.pp_funcs->enable_mgpu_fan_boost) { | ||
1948 | ret = amdgpu_dpm_enable_mgpu_fan_boost(adev); | ||
1949 | if (ret) | ||
1950 | break; | ||
1951 | |||
1952 | gpu_ins->mgpu_fan_enabled = 1; | ||
1953 | } | ||
1954 | } | ||
1955 | |||
1956 | out: | ||
1957 | mutex_unlock(&mgpu_info.mutex); | ||
1958 | |||
1959 | return ret; | ||
1960 | } | ||
1961 | |||
1836 | /** | 1962 | /** |
1837 | * amdgpu_device_ip_late_init_func_handler - work handler for ib test | 1963 | * amdgpu_device_ip_late_init_func_handler - work handler for ib test |
1838 | * | 1964 | * |
@@ -1847,6 +1973,10 @@ static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work) | |||
1847 | r = amdgpu_ib_ring_tests(adev); | 1973 | r = amdgpu_ib_ring_tests(adev); |
1848 | if (r) | 1974 | if (r) |
1849 | DRM_ERROR("ib ring test failed (%d).\n", r); | 1975 | DRM_ERROR("ib ring test failed (%d).\n", r); |
1976 | |||
1977 | r = amdgpu_device_enable_mgpu_fan_boost(); | ||
1978 | if (r) | ||
1979 | DRM_ERROR("enable mgpu fan boost failed (%d).\n", r); | ||
1850 | } | 1980 | } |
1851 | 1981 | ||
1852 | static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work) | 1982 | static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work) |
@@ -2082,7 +2212,8 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev) | |||
2082 | continue; | 2212 | continue; |
2083 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON || | 2213 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON || |
2084 | adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC || | 2214 | adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC || |
2085 | adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH) | 2215 | adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_IH || |
2216 | adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_PSP) | ||
2086 | continue; | 2217 | continue; |
2087 | r = adev->ip_blocks[i].version->funcs->resume(adev); | 2218 | r = adev->ip_blocks[i].version->funcs->resume(adev); |
2088 | if (r) { | 2219 | if (r) { |
@@ -2114,6 +2245,11 @@ static int amdgpu_device_ip_resume(struct amdgpu_device *adev) | |||
2114 | r = amdgpu_device_ip_resume_phase1(adev); | 2245 | r = amdgpu_device_ip_resume_phase1(adev); |
2115 | if (r) | 2246 | if (r) |
2116 | return r; | 2247 | return r; |
2248 | |||
2249 | r = amdgpu_device_fw_loading(adev); | ||
2250 | if (r) | ||
2251 | return r; | ||
2252 | |||
2117 | r = amdgpu_device_ip_resume_phase2(adev); | 2253 | r = amdgpu_device_ip_resume_phase2(adev); |
2118 | 2254 | ||
2119 | return r; | 2255 | return r; |
@@ -2608,6 +2744,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) | |||
2608 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) | 2744 | if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) |
2609 | return 0; | 2745 | return 0; |
2610 | 2746 | ||
2747 | adev->in_suspend = true; | ||
2611 | drm_kms_helper_poll_disable(dev); | 2748 | drm_kms_helper_poll_disable(dev); |
2612 | 2749 | ||
2613 | if (fbcon) | 2750 | if (fbcon) |
@@ -2793,6 +2930,8 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) | |||
2793 | #ifdef CONFIG_PM | 2930 | #ifdef CONFIG_PM |
2794 | dev->dev->power.disable_depth--; | 2931 | dev->dev->power.disable_depth--; |
2795 | #endif | 2932 | #endif |
2933 | adev->in_suspend = false; | ||
2934 | |||
2796 | return 0; | 2935 | return 0; |
2797 | } | 2936 | } |
2798 | 2937 | ||
@@ -3061,6 +3200,10 @@ retry: | |||
3061 | if (r) | 3200 | if (r) |
3062 | goto out; | 3201 | goto out; |
3063 | 3202 | ||
3203 | r = amdgpu_device_fw_loading(adev); | ||
3204 | if (r) | ||
3205 | return r; | ||
3206 | |||
3064 | r = amdgpu_device_ip_resume_phase2(adev); | 3207 | r = amdgpu_device_ip_resume_phase2(adev); |
3065 | if (r) | 3208 | if (r) |
3066 | goto out; | 3209 | goto out; |
@@ -3117,6 +3260,10 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev, | |||
3117 | /* we need recover gart prior to run SMC/CP/SDMA resume */ | 3260 | /* we need recover gart prior to run SMC/CP/SDMA resume */ |
3118 | amdgpu_gtt_mgr_recover(&adev->mman.bdev.man[TTM_PL_TT]); | 3261 | amdgpu_gtt_mgr_recover(&adev->mman.bdev.man[TTM_PL_TT]); |
3119 | 3262 | ||
3263 | r = amdgpu_device_fw_loading(adev); | ||
3264 | if (r) | ||
3265 | return r; | ||
3266 | |||
3120 | /* now we are okay to resume SMC/CP/SDMA */ | 3267 | /* now we are okay to resume SMC/CP/SDMA */ |
3121 | r = amdgpu_device_ip_reinit_late_sriov(adev); | 3268 | r = amdgpu_device_ip_reinit_late_sriov(adev); |
3122 | if (r) | 3269 | if (r) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h index ff24e1cc5b65..f972cd156795 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | |||
@@ -278,6 +278,9 @@ enum amdgpu_pcie_gen { | |||
278 | #define amdgpu_dpm_get_fan_speed_rpm(adev, s) \ | 278 | #define amdgpu_dpm_get_fan_speed_rpm(adev, s) \ |
279 | ((adev)->powerplay.pp_funcs->get_fan_speed_rpm)((adev)->powerplay.pp_handle, (s)) | 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 | #define amdgpu_dpm_get_sclk(adev, l) \ | 284 | #define amdgpu_dpm_get_sclk(adev, l) \ |
282 | ((adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l))) | 285 | ((adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l))) |
283 | 286 | ||
@@ -357,6 +360,10 @@ enum amdgpu_pcie_gen { | |||
357 | ((adev)->powerplay.pp_funcs->odn_edit_dpm_table(\ | 360 | ((adev)->powerplay.pp_funcs->odn_edit_dpm_table(\ |
358 | (adev)->powerplay.pp_handle, type, parameter, size)) | 361 | (adev)->powerplay.pp_handle, type, parameter, size)) |
359 | 362 | ||
363 | #define amdgpu_dpm_enable_mgpu_fan_boost(adev) \ | ||
364 | ((adev)->powerplay.pp_funcs->enable_mgpu_fan_boost(\ | ||
365 | (adev)->powerplay.pp_handle)) | ||
366 | |||
360 | struct amdgpu_dpm { | 367 | struct amdgpu_dpm { |
361 | struct amdgpu_ps *ps; | 368 | struct amdgpu_ps *ps; |
362 | /* number of valid power states */ | 369 | /* number of valid power states */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 723f0f7754bd..28781414d71c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | |||
@@ -127,6 +127,9 @@ int amdgpu_compute_multipipe = -1; | |||
127 | int amdgpu_gpu_recovery = -1; /* auto */ | 127 | int amdgpu_gpu_recovery = -1; /* auto */ |
128 | int amdgpu_emu_mode = 0; | 128 | int amdgpu_emu_mode = 0; |
129 | uint amdgpu_smu_memory_pool_size = 0; | 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 | * DOC: vramlimit (int) | 135 | * DOC: vramlimit (int) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h index f172e92c463c..b61b5c11aead 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | |||
@@ -297,8 +297,7 @@ struct amdgpu_gfx { | |||
297 | /* reset mask */ | 297 | /* reset mask */ |
298 | uint32_t grbm_soft_reset; | 298 | uint32_t grbm_soft_reset; |
299 | uint32_t srbm_soft_reset; | 299 | uint32_t srbm_soft_reset; |
300 | /* s3/s4 mask */ | 300 | |
301 | bool in_suspend; | ||
302 | /* NGG */ | 301 | /* NGG */ |
303 | struct amdgpu_ngg ngg; | 302 | struct amdgpu_ngg ngg; |
304 | 303 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c index 9a5b252784a1..d73367cab4f3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | |||
@@ -146,6 +146,8 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) | |||
146 | { | 146 | { |
147 | const uint64_t four_gb = 0x100000000ULL; | 147 | const uint64_t four_gb = 0x100000000ULL; |
148 | u64 size_af, size_bf; | 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 | mc->gart_size += adev->pm.smu_prv_buffer_size; | 152 | mc->gart_size += adev->pm.smu_prv_buffer_size; |
151 | 153 | ||
@@ -153,7 +155,7 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) | |||
153 | * the GART base on a 4GB boundary as well. | 155 | * the GART base on a 4GB boundary as well. |
154 | */ | 156 | */ |
155 | size_bf = mc->fb_start; | 157 | size_bf = mc->fb_start; |
156 | size_af = adev->gmc.mc_mask + 1 - ALIGN(mc->fb_end + 1, four_gb); | 158 | size_af = max_mc_address + 1 - ALIGN(mc->fb_end + 1, four_gb); |
157 | 159 | ||
158 | if (mc->gart_size > max(size_bf, size_af)) { | 160 | if (mc->gart_size > max(size_bf, size_af)) { |
159 | dev_warn(adev->dev, "limiting GART\n"); | 161 | dev_warn(adev->dev, "limiting GART\n"); |
@@ -164,7 +166,7 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) | |||
164 | (size_af < mc->gart_size)) | 166 | (size_af < mc->gart_size)) |
165 | mc->gart_start = 0; | 167 | mc->gart_start = 0; |
166 | else | 168 | else |
167 | mc->gart_start = mc->mc_mask - mc->gart_size + 1; | 169 | mc->gart_start = max_mc_address - mc->gart_size + 1; |
168 | 170 | ||
169 | mc->gart_start &= ~(four_gb - 1); | 171 | mc->gart_start &= ~(four_gb - 1); |
170 | mc->gart_end = mc->gart_start + mc->gart_size - 1; | 172 | mc->gart_end = mc->gart_start + mc->gart_size - 1; |
@@ -200,16 +202,13 @@ void amdgpu_gmc_agp_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) | |||
200 | } | 202 | } |
201 | 203 | ||
202 | if (size_bf > size_af) { | 204 | if (size_bf > size_af) { |
203 | mc->agp_start = mc->fb_start > mc->gart_start ? | 205 | mc->agp_start = (mc->fb_start - size_bf) & sixteen_gb_mask; |
204 | mc->gart_end + 1 : 0; | ||
205 | mc->agp_size = size_bf; | 206 | mc->agp_size = size_bf; |
206 | } else { | 207 | } else { |
207 | mc->agp_start = (mc->fb_start > mc->gart_start ? | 208 | mc->agp_start = ALIGN(mc->fb_end + 1, sixteen_gb); |
208 | mc->fb_end : mc->gart_end) + 1, | ||
209 | mc->agp_size = size_af; | 209 | mc->agp_size = size_af; |
210 | } | 210 | } |
211 | 211 | ||
212 | mc->agp_start = ALIGN(mc->agp_start, sixteen_gb); | ||
213 | mc->agp_end = mc->agp_start + mc->agp_size - 1; | 212 | mc->agp_end = mc->agp_start + mc->agp_size - 1; |
214 | dev_info(adev->dev, "AGP: %lluM 0x%016llX - 0x%016llX\n", | 213 | dev_info(adev->dev, "AGP: %lluM 0x%016llX - 0x%016llX\n", |
215 | mc->agp_size >> 20, mc->agp_start, mc->agp_end); | 214 | mc->agp_size >> 20, mc->agp_start, mc->agp_end); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index 47817e00f54f..b8963b725dfa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | |||
@@ -354,6 +354,14 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev) | |||
354 | if (!ring || !ring->ready) | 354 | if (!ring || !ring->ready) |
355 | continue; | 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 | /* MM engine need more time */ | 365 | /* MM engine need more time */ |
358 | if (ring->funcs->type == AMDGPU_RING_TYPE_UVD || | 366 | if (ring->funcs->type == AMDGPU_RING_TYPE_UVD || |
359 | ring->funcs->type == AMDGPU_RING_TYPE_VCE || | 367 | ring->funcs->type == AMDGPU_RING_TYPE_VCE || |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index a64056dadc58..81732a84c2ab 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |||
@@ -40,6 +40,30 @@ | |||
40 | #include "amdgpu_gem.h" | 40 | #include "amdgpu_gem.h" |
41 | #include "amdgpu_display.h" | 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 | * amdgpu_driver_unload_kms - Main unload function for KMS. | 68 | * amdgpu_driver_unload_kms - Main unload function for KMS. |
45 | * | 69 | * |
@@ -55,6 +79,8 @@ void amdgpu_driver_unload_kms(struct drm_device *dev) | |||
55 | if (adev == NULL) | 79 | if (adev == NULL) |
56 | return; | 80 | return; |
57 | 81 | ||
82 | amdgpu_unregister_gpu_instance(adev); | ||
83 | |||
58 | if (adev->rmmio == NULL) | 84 | if (adev->rmmio == NULL) |
59 | goto done_free; | 85 | goto done_free; |
60 | 86 | ||
@@ -75,6 +101,31 @@ done_free: | |||
75 | dev->dev_private = NULL; | 101 | dev->dev_private = NULL; |
76 | } | 102 | } |
77 | 103 | ||
104 | static void amdgpu_register_gpu_instance(struct amdgpu_device *adev) | ||
105 | { | ||
106 | struct amdgpu_gpu_instance *gpu_instance; | ||
107 | |||
108 | mutex_lock(&mgpu_info.mutex); | ||
109 | |||
110 | if (mgpu_info.num_gpu >= MAX_GPU_INSTANCE) { | ||
111 | DRM_ERROR("Cannot register more gpu instance\n"); | ||
112 | mutex_unlock(&mgpu_info.mutex); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | gpu_instance = &(mgpu_info.gpu_ins[mgpu_info.num_gpu]); | ||
117 | gpu_instance->adev = adev; | ||
118 | gpu_instance->mgpu_fan_enabled = 0; | ||
119 | |||
120 | mgpu_info.num_gpu++; | ||
121 | if (adev->flags & AMD_IS_APU) | ||
122 | mgpu_info.num_apu++; | ||
123 | else | ||
124 | mgpu_info.num_dgpu++; | ||
125 | |||
126 | mutex_unlock(&mgpu_info.mutex); | ||
127 | } | ||
128 | |||
78 | /** | 129 | /** |
79 | * amdgpu_driver_load_kms - Main load function for KMS. | 130 | * amdgpu_driver_load_kms - Main load function for KMS. |
80 | * | 131 | * |
@@ -169,6 +220,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) | |||
169 | pm_runtime_put_autosuspend(dev->dev); | 220 | pm_runtime_put_autosuspend(dev->dev); |
170 | } | 221 | } |
171 | 222 | ||
223 | amdgpu_register_gpu_instance(adev); | ||
172 | out: | 224 | out: |
173 | if (r) { | 225 | if (r) { |
174 | /* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */ | 226 | /* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index 18d989e0e362..94055a485e01 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |||
@@ -1120,12 +1120,19 @@ static ssize_t amdgpu_hwmon_set_pwm1(struct device *dev, | |||
1120 | struct amdgpu_device *adev = dev_get_drvdata(dev); | 1120 | struct amdgpu_device *adev = dev_get_drvdata(dev); |
1121 | int err; | 1121 | int err; |
1122 | u32 value; | 1122 | u32 value; |
1123 | u32 pwm_mode; | ||
1123 | 1124 | ||
1124 | /* Can't adjust fan when the card is off */ | 1125 | /* Can't adjust fan when the card is off */ |
1125 | if ((adev->flags & AMD_IS_PX) && | 1126 | if ((adev->flags & AMD_IS_PX) && |
1126 | (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) | 1127 | (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) |
1127 | return -EINVAL; | 1128 | return -EINVAL; |
1128 | 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 | } | ||
1135 | |||
1129 | err = kstrtou32(buf, 10, &value); | 1136 | err = kstrtou32(buf, 10, &value); |
1130 | if (err) | 1137 | if (err) |
1131 | return err; | 1138 | return err; |
@@ -1187,6 +1194,148 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev, | |||
1187 | return sprintf(buf, "%i\n", speed); | 1194 | return sprintf(buf, "%i\n", speed); |
1188 | } | 1195 | } |
1189 | 1196 | ||
1197 | static ssize_t amdgpu_hwmon_get_fan1_min(struct device *dev, | ||
1198 | struct device_attribute *attr, | ||
1199 | char *buf) | ||
1200 | { | ||
1201 | struct amdgpu_device *adev = dev_get_drvdata(dev); | ||
1202 | u32 min_rpm = 0; | ||
1203 | u32 size = sizeof(min_rpm); | ||
1204 | int r; | ||
1205 | |||
1206 | if (!adev->powerplay.pp_funcs->read_sensor) | ||
1207 | return -EINVAL; | ||
1208 | |||
1209 | r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_MIN_FAN_RPM, | ||
1210 | (void *)&min_rpm, &size); | ||
1211 | if (r) | ||
1212 | return r; | ||
1213 | |||
1214 | return snprintf(buf, PAGE_SIZE, "%d\n", min_rpm); | ||
1215 | } | ||
1216 | |||
1217 | static ssize_t amdgpu_hwmon_get_fan1_max(struct device *dev, | ||
1218 | struct device_attribute *attr, | ||
1219 | char *buf) | ||
1220 | { | ||
1221 | struct amdgpu_device *adev = dev_get_drvdata(dev); | ||
1222 | u32 max_rpm = 0; | ||
1223 | u32 size = sizeof(max_rpm); | ||
1224 | int r; | ||
1225 | |||
1226 | if (!adev->powerplay.pp_funcs->read_sensor) | ||
1227 | return -EINVAL; | ||
1228 | |||
1229 | r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_MAX_FAN_RPM, | ||
1230 | (void *)&max_rpm, &size); | ||
1231 | if (r) | ||
1232 | return r; | ||
1233 | |||
1234 | return snprintf(buf, PAGE_SIZE, "%d\n", max_rpm); | ||
1235 | } | ||
1236 | |||
1237 | static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev, | ||
1238 | struct device_attribute *attr, | ||
1239 | char *buf) | ||
1240 | { | ||
1241 | struct amdgpu_device *adev = dev_get_drvdata(dev); | ||
1242 | int err; | ||
1243 | u32 rpm = 0; | ||
1244 | |||
1245 | /* Can't adjust fan when the card is off */ | ||
1246 | if ((adev->flags & AMD_IS_PX) && | ||
1247 | (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) | ||
1248 | return -EINVAL; | ||
1249 | |||
1250 | if (adev->powerplay.pp_funcs->get_fan_speed_rpm) { | ||
1251 | err = amdgpu_dpm_get_fan_speed_rpm(adev, &rpm); | ||
1252 | if (err) | ||
1253 | return err; | ||
1254 | } | ||
1255 | |||
1256 | return sprintf(buf, "%i\n", rpm); | ||
1257 | } | ||
1258 | |||
1259 | static ssize_t amdgpu_hwmon_set_fan1_target(struct device *dev, | ||
1260 | struct device_attribute *attr, | ||
1261 | const char *buf, size_t count) | ||
1262 | { | ||
1263 | struct amdgpu_device *adev = dev_get_drvdata(dev); | ||
1264 | int err; | ||
1265 | u32 value; | ||
1266 | u32 pwm_mode; | ||
1267 | |||
1268 | pwm_mode = amdgpu_dpm_get_fan_control_mode(adev); | ||
1269 | if (pwm_mode != AMD_FAN_CTRL_MANUAL) | ||
1270 | return -ENODATA; | ||
1271 | |||
1272 | /* Can't adjust fan when the card is off */ | ||
1273 | if ((adev->flags & AMD_IS_PX) && | ||
1274 | (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) | ||
1275 | return -EINVAL; | ||
1276 | |||
1277 | err = kstrtou32(buf, 10, &value); | ||
1278 | if (err) | ||
1279 | return err; | ||
1280 | |||
1281 | if (adev->powerplay.pp_funcs->set_fan_speed_rpm) { | ||
1282 | err = amdgpu_dpm_set_fan_speed_rpm(adev, value); | ||
1283 | if (err) | ||
1284 | return err; | ||
1285 | } | ||
1286 | |||
1287 | return count; | ||
1288 | } | ||
1289 | |||
1290 | static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev, | ||
1291 | struct device_attribute *attr, | ||
1292 | char *buf) | ||
1293 | { | ||
1294 | struct amdgpu_device *adev = dev_get_drvdata(dev); | ||
1295 | u32 pwm_mode = 0; | ||
1296 | |||
1297 | if (!adev->powerplay.pp_funcs->get_fan_control_mode) | ||
1298 | return -EINVAL; | ||
1299 | |||
1300 | pwm_mode = amdgpu_dpm_get_fan_control_mode(adev); | ||
1301 | |||
1302 | return sprintf(buf, "%i\n", pwm_mode == AMD_FAN_CTRL_AUTO ? 0 : 1); | ||
1303 | } | ||
1304 | |||
1305 | static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev, | ||
1306 | struct device_attribute *attr, | ||
1307 | const char *buf, | ||
1308 | size_t count) | ||
1309 | { | ||
1310 | struct amdgpu_device *adev = dev_get_drvdata(dev); | ||
1311 | int err; | ||
1312 | int value; | ||
1313 | u32 pwm_mode; | ||
1314 | |||
1315 | /* Can't adjust fan when the card is off */ | ||
1316 | if ((adev->flags & AMD_IS_PX) && | ||
1317 | (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON)) | ||
1318 | return -EINVAL; | ||
1319 | |||
1320 | if (!adev->powerplay.pp_funcs->set_fan_control_mode) | ||
1321 | return -EINVAL; | ||
1322 | |||
1323 | err = kstrtoint(buf, 10, &value); | ||
1324 | if (err) | ||
1325 | return err; | ||
1326 | |||
1327 | if (value == 0) | ||
1328 | pwm_mode = AMD_FAN_CTRL_AUTO; | ||
1329 | else if (value == 1) | ||
1330 | pwm_mode = AMD_FAN_CTRL_MANUAL; | ||
1331 | else | ||
1332 | return -EINVAL; | ||
1333 | |||
1334 | amdgpu_dpm_set_fan_control_mode(adev, pwm_mode); | ||
1335 | |||
1336 | return count; | ||
1337 | } | ||
1338 | |||
1190 | static ssize_t amdgpu_hwmon_show_vddgfx(struct device *dev, | 1339 | static ssize_t amdgpu_hwmon_show_vddgfx(struct device *dev, |
1191 | struct device_attribute *attr, | 1340 | struct device_attribute *attr, |
1192 | char *buf) | 1341 | char *buf) |
@@ -1406,8 +1555,16 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev, | |||
1406 | * | 1555 | * |
1407 | * - pwm1_max: pulse width modulation fan control maximum level (255) | 1556 | * - pwm1_max: pulse width modulation fan control maximum level (255) |
1408 | * | 1557 | * |
1558 | * - fan1_min: an minimum value Unit: revolution/min (RPM) | ||
1559 | * | ||
1560 | * - fan1_max: an maxmum value Unit: revolution/max (RPM) | ||
1561 | * | ||
1409 | * - fan1_input: fan speed in RPM | 1562 | * - fan1_input: fan speed in RPM |
1410 | * | 1563 | * |
1564 | * - fan[1-*]_target: Desired fan speed Unit: revolution/min (RPM) | ||
1565 | * | ||
1566 | * - fan[1-*]_enable: Enable or disable the sensors.1: Enable 0: Disable | ||
1567 | * | ||
1411 | * You can use hwmon tools like sensors to view this information on your system. | 1568 | * You can use hwmon tools like sensors to view this information on your system. |
1412 | * | 1569 | * |
1413 | */ | 1570 | */ |
@@ -1420,6 +1577,10 @@ static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_ | |||
1420 | static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0); | 1577 | static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0); |
1421 | static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0); | 1578 | static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0); |
1422 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0); | 1579 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0); |
1580 | static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO, amdgpu_hwmon_get_fan1_min, NULL, 0); | ||
1581 | static SENSOR_DEVICE_ATTR(fan1_max, S_IRUGO, amdgpu_hwmon_get_fan1_max, NULL, 0); | ||
1582 | static SENSOR_DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_fan1_target, amdgpu_hwmon_set_fan1_target, 0); | ||
1583 | static SENSOR_DEVICE_ATTR(fan1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_fan1_enable, amdgpu_hwmon_set_fan1_enable, 0); | ||
1423 | static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, amdgpu_hwmon_show_vddgfx, NULL, 0); | 1584 | static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, amdgpu_hwmon_show_vddgfx, NULL, 0); |
1424 | static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, amdgpu_hwmon_show_vddgfx_label, NULL, 0); | 1585 | static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, amdgpu_hwmon_show_vddgfx_label, NULL, 0); |
1425 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, amdgpu_hwmon_show_vddnb, NULL, 0); | 1586 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, amdgpu_hwmon_show_vddnb, NULL, 0); |
@@ -1438,6 +1599,10 @@ static struct attribute *hwmon_attributes[] = { | |||
1438 | &sensor_dev_attr_pwm1_min.dev_attr.attr, | 1599 | &sensor_dev_attr_pwm1_min.dev_attr.attr, |
1439 | &sensor_dev_attr_pwm1_max.dev_attr.attr, | 1600 | &sensor_dev_attr_pwm1_max.dev_attr.attr, |
1440 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 1601 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
1602 | &sensor_dev_attr_fan1_min.dev_attr.attr, | ||
1603 | &sensor_dev_attr_fan1_max.dev_attr.attr, | ||
1604 | &sensor_dev_attr_fan1_target.dev_attr.attr, | ||
1605 | &sensor_dev_attr_fan1_enable.dev_attr.attr, | ||
1441 | &sensor_dev_attr_in0_input.dev_attr.attr, | 1606 | &sensor_dev_attr_in0_input.dev_attr.attr, |
1442 | &sensor_dev_attr_in0_label.dev_attr.attr, | 1607 | &sensor_dev_attr_in0_label.dev_attr.attr, |
1443 | &sensor_dev_attr_in1_input.dev_attr.attr, | 1608 | &sensor_dev_attr_in1_input.dev_attr.attr, |
@@ -1456,13 +1621,16 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, | |||
1456 | struct amdgpu_device *adev = dev_get_drvdata(dev); | 1621 | struct amdgpu_device *adev = dev_get_drvdata(dev); |
1457 | umode_t effective_mode = attr->mode; | 1622 | umode_t effective_mode = attr->mode; |
1458 | 1623 | ||
1459 | |||
1460 | /* Skip fan attributes if fan is not present */ | 1624 | /* Skip fan attributes if fan is not present */ |
1461 | if (adev->pm.no_fan && (attr == &sensor_dev_attr_pwm1.dev_attr.attr || | 1625 | if (adev->pm.no_fan && (attr == &sensor_dev_attr_pwm1.dev_attr.attr || |
1462 | attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || | 1626 | attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || |
1463 | attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || | 1627 | attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || |
1464 | attr == &sensor_dev_attr_pwm1_min.dev_attr.attr || | 1628 | attr == &sensor_dev_attr_pwm1_min.dev_attr.attr || |
1465 | attr == &sensor_dev_attr_fan1_input.dev_attr.attr)) | 1629 | attr == &sensor_dev_attr_fan1_input.dev_attr.attr || |
1630 | attr == &sensor_dev_attr_fan1_min.dev_attr.attr || | ||
1631 | attr == &sensor_dev_attr_fan1_max.dev_attr.attr || | ||
1632 | attr == &sensor_dev_attr_fan1_target.dev_attr.attr || | ||
1633 | attr == &sensor_dev_attr_fan1_enable.dev_attr.attr)) | ||
1466 | return 0; | 1634 | return 0; |
1467 | 1635 | ||
1468 | /* Skip limit attributes if DPM is not enabled */ | 1636 | /* Skip limit attributes if DPM is not enabled */ |
@@ -1472,7 +1640,12 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, | |||
1472 | attr == &sensor_dev_attr_pwm1.dev_attr.attr || | 1640 | attr == &sensor_dev_attr_pwm1.dev_attr.attr || |
1473 | attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || | 1641 | attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || |
1474 | attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || | 1642 | attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || |
1475 | attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) | 1643 | attr == &sensor_dev_attr_pwm1_min.dev_attr.attr || |
1644 | attr == &sensor_dev_attr_fan1_input.dev_attr.attr || | ||
1645 | attr == &sensor_dev_attr_fan1_min.dev_attr.attr || | ||
1646 | attr == &sensor_dev_attr_fan1_max.dev_attr.attr || | ||
1647 | attr == &sensor_dev_attr_fan1_target.dev_attr.attr || | ||
1648 | attr == &sensor_dev_attr_fan1_enable.dev_attr.attr)) | ||
1476 | return 0; | 1649 | return 0; |
1477 | 1650 | ||
1478 | /* mask fan attributes if we have no bindings for this asic to expose */ | 1651 | /* mask fan attributes if we have no bindings for this asic to expose */ |
@@ -1497,10 +1670,18 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, | |||
1497 | /* hide max/min values if we can't both query and manage the fan */ | 1670 | /* hide max/min values if we can't both query and manage the fan */ |
1498 | if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && | 1671 | if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && |
1499 | !adev->powerplay.pp_funcs->get_fan_speed_percent) && | 1672 | !adev->powerplay.pp_funcs->get_fan_speed_percent) && |
1673 | (!adev->powerplay.pp_funcs->set_fan_speed_rpm && | ||
1674 | !adev->powerplay.pp_funcs->get_fan_speed_rpm) && | ||
1500 | (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || | 1675 | (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || |
1501 | attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) | 1676 | attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) |
1502 | return 0; | 1677 | return 0; |
1503 | 1678 | ||
1679 | if ((!adev->powerplay.pp_funcs->set_fan_speed_rpm && | ||
1680 | !adev->powerplay.pp_funcs->get_fan_speed_rpm) && | ||
1681 | (attr == &sensor_dev_attr_fan1_max.dev_attr.attr || | ||
1682 | attr == &sensor_dev_attr_fan1_min.dev_attr.attr)) | ||
1683 | return 0; | ||
1684 | |||
1504 | /* only APUs have vddnb */ | 1685 | /* only APUs have vddnb */ |
1505 | if (!(adev->flags & AMD_IS_APU) && | 1686 | if (!(adev->flags & AMD_IS_APU) && |
1506 | (attr == &sensor_dev_attr_in1_input.dev_attr.attr || | 1687 | (attr == &sensor_dev_attr_in1_input.dev_attr.attr || |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index bd397d2916fb..25d2f3e757f1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | |||
@@ -452,8 +452,6 @@ static int psp_hw_fini(void *handle) | |||
452 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) | 452 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) |
453 | return 0; | 453 | return 0; |
454 | 454 | ||
455 | amdgpu_ucode_fini_bo(adev); | ||
456 | |||
457 | psp_ring_destroy(psp, PSP_RING_TYPE__KM); | 455 | psp_ring_destroy(psp, PSP_RING_TYPE__KM); |
458 | 456 | ||
459 | amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf); | 457 | amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h index d17503f0df8e..500113ec65ca 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h | |||
@@ -46,10 +46,6 @@ struct amdgpu_sdma_instance { | |||
46 | 46 | ||
47 | struct amdgpu_sdma { | 47 | struct amdgpu_sdma { |
48 | struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES]; | 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 | struct amdgpu_irq_src trap_irq; | 49 | struct amdgpu_irq_src trap_irq; |
54 | struct amdgpu_irq_src illegal_inst_irq; | 50 | struct amdgpu_irq_src illegal_inst_irq; |
55 | int num_instances; | 51 | int num_instances; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c index 1fa8bc337859..7b33867036e7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | |||
@@ -297,10 +297,7 @@ amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type) | |||
297 | case CHIP_POLARIS11: | 297 | case CHIP_POLARIS11: |
298 | case CHIP_POLARIS12: | 298 | case CHIP_POLARIS12: |
299 | case CHIP_VEGAM: | 299 | case CHIP_VEGAM: |
300 | if (!load_type) | 300 | return AMDGPU_FW_LOAD_SMU; |
301 | return AMDGPU_FW_LOAD_DIRECT; | ||
302 | else | ||
303 | return AMDGPU_FW_LOAD_SMU; | ||
304 | case CHIP_VEGA10: | 301 | case CHIP_VEGA10: |
305 | case CHIP_RAVEN: | 302 | case CHIP_RAVEN: |
306 | case CHIP_VEGA12: | 303 | case CHIP_VEGA12: |
@@ -423,32 +420,41 @@ static int amdgpu_ucode_patch_jt(struct amdgpu_firmware_info *ucode, | |||
423 | return 0; | 420 | return 0; |
424 | } | 421 | } |
425 | 422 | ||
426 | int amdgpu_ucode_init_bo(struct amdgpu_device *adev) | 423 | int amdgpu_ucode_create_bo(struct amdgpu_device *adev) |
427 | { | 424 | { |
428 | uint64_t fw_offset = 0; | 425 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT) { |
429 | int i, err; | 426 | amdgpu_bo_create_kernel(adev, adev->firmware.fw_size, PAGE_SIZE, |
430 | struct amdgpu_firmware_info *ucode = NULL; | 427 | amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT, |
431 | const struct common_firmware_header *header = NULL; | 428 | &adev->firmware.fw_buf, |
432 | 429 | &adev->firmware.fw_buf_mc, | |
433 | if (!adev->firmware.fw_size) { | 430 | &adev->firmware.fw_buf_ptr); |
434 | dev_warn(adev->dev, "No ip firmware need to load\n"); | 431 | if (!adev->firmware.fw_buf) { |
435 | return 0; | ||
436 | } | ||
437 | |||
438 | if (!adev->in_gpu_reset) { | ||
439 | err = amdgpu_bo_create_kernel(adev, adev->firmware.fw_size, PAGE_SIZE, | ||
440 | amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT, | ||
441 | &adev->firmware.fw_buf, | ||
442 | &adev->firmware.fw_buf_mc, | ||
443 | &adev->firmware.fw_buf_ptr); | ||
444 | if (err) { | ||
445 | dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n"); | 432 | dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n"); |
446 | goto failed; | 433 | return -ENOMEM; |
434 | } else if (amdgpu_sriov_vf(adev)) { | ||
435 | memset(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size); | ||
447 | } | 436 | } |
448 | } | 437 | } |
438 | return 0; | ||
439 | } | ||
440 | |||
441 | void amdgpu_ucode_free_bo(struct amdgpu_device *adev) | ||
442 | { | ||
443 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT) | ||
444 | amdgpu_bo_free_kernel(&adev->firmware.fw_buf, | ||
445 | &adev->firmware.fw_buf_mc, | ||
446 | &adev->firmware.fw_buf_ptr); | ||
447 | } | ||
449 | 448 | ||
450 | memset(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size); | 449 | int amdgpu_ucode_init_bo(struct amdgpu_device *adev) |
450 | { | ||
451 | uint64_t fw_offset = 0; | ||
452 | int i; | ||
453 | struct amdgpu_firmware_info *ucode = NULL; | ||
451 | 454 | ||
455 | /* for baremetal, the ucode is allocated in gtt, so don't need to fill the bo when reset/suspend */ | ||
456 | if (!amdgpu_sriov_vf(adev) && (adev->in_gpu_reset || adev->in_suspend)) | ||
457 | return 0; | ||
452 | /* | 458 | /* |
453 | * if SMU loaded firmware, it needn't add SMC, UVD, and VCE | 459 | * if SMU loaded firmware, it needn't add SMC, UVD, and VCE |
454 | * ucode info here | 460 | * ucode info here |
@@ -465,7 +471,6 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev) | |||
465 | for (i = 0; i < adev->firmware.max_ucodes; i++) { | 471 | for (i = 0; i < adev->firmware.max_ucodes; i++) { |
466 | ucode = &adev->firmware.ucode[i]; | 472 | ucode = &adev->firmware.ucode[i]; |
467 | if (ucode->fw) { | 473 | if (ucode->fw) { |
468 | header = (const struct common_firmware_header *)ucode->fw->data; | ||
469 | amdgpu_ucode_init_single_fw(adev, ucode, adev->firmware.fw_buf_mc + fw_offset, | 474 | amdgpu_ucode_init_single_fw(adev, ucode, adev->firmware.fw_buf_mc + fw_offset, |
470 | adev->firmware.fw_buf_ptr + fw_offset); | 475 | adev->firmware.fw_buf_ptr + fw_offset); |
471 | if (i == AMDGPU_UCODE_ID_CP_MEC1 && | 476 | if (i == AMDGPU_UCODE_ID_CP_MEC1 && |
@@ -480,33 +485,4 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev) | |||
480 | } | 485 | } |
481 | } | 486 | } |
482 | return 0; | 487 | return 0; |
483 | |||
484 | failed: | ||
485 | if (err) | ||
486 | adev->firmware.load_type = AMDGPU_FW_LOAD_DIRECT; | ||
487 | |||
488 | return err; | ||
489 | } | ||
490 | |||
491 | int amdgpu_ucode_fini_bo(struct amdgpu_device *adev) | ||
492 | { | ||
493 | int i; | ||
494 | struct amdgpu_firmware_info *ucode = NULL; | ||
495 | |||
496 | if (!adev->firmware.fw_size) | ||
497 | return 0; | ||
498 | |||
499 | for (i = 0; i < adev->firmware.max_ucodes; i++) { | ||
500 | ucode = &adev->firmware.ucode[i]; | ||
501 | if (ucode->fw) { | ||
502 | ucode->mc_addr = 0; | ||
503 | ucode->kaddr = NULL; | ||
504 | } | ||
505 | } | ||
506 | |||
507 | amdgpu_bo_free_kernel(&adev->firmware.fw_buf, | ||
508 | &adev->firmware.fw_buf_mc, | ||
509 | &adev->firmware.fw_buf_ptr); | ||
510 | |||
511 | return 0; | ||
512 | } | 488 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h index 8f3f1117728c..aa6641b944a0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h | |||
@@ -276,8 +276,10 @@ void amdgpu_ucode_print_gpu_info_hdr(const struct common_firmware_header *hdr); | |||
276 | int amdgpu_ucode_validate(const struct firmware *fw); | 276 | int amdgpu_ucode_validate(const struct firmware *fw); |
277 | bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr, | 277 | bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr, |
278 | uint16_t hdr_major, uint16_t hdr_minor); | 278 | uint16_t hdr_major, uint16_t hdr_minor); |
279 | |||
279 | int amdgpu_ucode_init_bo(struct amdgpu_device *adev); | 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 | enum amdgpu_firmware_load_type | 284 | enum amdgpu_firmware_load_type |
283 | amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type); | 285 | amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c index 64e527b1c02f..27da13df2f11 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | |||
@@ -121,8 +121,7 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev) | |||
121 | version_major, version_minor, family_id); | 121 | version_major, version_minor, family_id); |
122 | } | 122 | } |
123 | 123 | ||
124 | bo_size = AMDGPU_VCN_STACK_SIZE + AMDGPU_VCN_HEAP_SIZE | 124 | bo_size = AMDGPU_VCN_STACK_SIZE + AMDGPU_VCN_CONTEXT_SIZE; |
125 | + AMDGPU_VCN_SESSION_SIZE * 40; | ||
126 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) | 125 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) |
127 | bo_size += AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8); | 126 | bo_size += AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8); |
128 | r = amdgpu_bo_create_kernel(adev, bo_size, PAGE_SIZE, | 127 | r = amdgpu_bo_create_kernel(adev, bo_size, PAGE_SIZE, |
@@ -263,7 +262,7 @@ static int amdgpu_vcn_pause_dpg_mode(struct amdgpu_device *adev, | |||
263 | 262 | ||
264 | ring = &adev->vcn.ring_dec; | 263 | ring = &adev->vcn.ring_dec; |
265 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, | 264 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, |
266 | lower_32_bits(ring->wptr) | 0x80000000); | 265 | RREG32_SOC15(UVD, 0, mmUVD_SCRATCH2)); |
267 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, | 266 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, |
268 | UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, | 267 | UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, |
269 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); | 268 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); |
@@ -309,18 +308,21 @@ static int amdgpu_vcn_pause_dpg_mode(struct amdgpu_device *adev, | |||
309 | /* Restore */ | 308 | /* Restore */ |
310 | ring = &adev->vcn.ring_jpeg; | 309 | ring = &adev->vcn.ring_jpeg; |
311 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_VMID, 0); | 310 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_VMID, 0); |
312 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 0x00000001L | 0x00000002L); | 311 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, |
312 | UVD_JRBC_RB_CNTL__RB_NO_FETCH_MASK | | ||
313 | UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK); | ||
313 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_LOW, | 314 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_LOW, |
314 | lower_32_bits(ring->gpu_addr)); | 315 | lower_32_bits(ring->gpu_addr)); |
315 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_HIGH, | 316 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_HIGH, |
316 | upper_32_bits(ring->gpu_addr)); | 317 | upper_32_bits(ring->gpu_addr)); |
317 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_RPTR, ring->wptr); | 318 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_RPTR, ring->wptr); |
318 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR, ring->wptr); | 319 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR, ring->wptr); |
319 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 0x00000002L); | 320 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, |
321 | UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK); | ||
320 | 322 | ||
321 | ring = &adev->vcn.ring_dec; | 323 | ring = &adev->vcn.ring_dec; |
322 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, | 324 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, |
323 | lower_32_bits(ring->wptr) | 0x80000000); | 325 | RREG32_SOC15(UVD, 0, mmUVD_SCRATCH2)); |
324 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, | 326 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, |
325 | UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, | 327 | UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, |
326 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); | 328 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h index 0b88a4672da5..a0ad19af9080 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | |||
@@ -24,9 +24,9 @@ | |||
24 | #ifndef __AMDGPU_VCN_H__ | 24 | #ifndef __AMDGPU_VCN_H__ |
25 | #define __AMDGPU_VCN_H__ | 25 | #define __AMDGPU_VCN_H__ |
26 | 26 | ||
27 | #define AMDGPU_VCN_STACK_SIZE (200*1024) | 27 | #define AMDGPU_VCN_STACK_SIZE (128*1024) |
28 | #define AMDGPU_VCN_HEAP_SIZE (256*1024) | 28 | #define AMDGPU_VCN_CONTEXT_SIZE (512*1024) |
29 | #define AMDGPU_VCN_SESSION_SIZE (50*1024) | 29 | |
30 | #define AMDGPU_VCN_FIRMWARE_OFFSET 256 | 30 | #define AMDGPU_VCN_FIRMWARE_OFFSET 256 |
31 | #define AMDGPU_VCN_MAX_ENC_RINGS 3 | 31 | #define AMDGPU_VCN_MAX_ENC_RINGS 3 |
32 | 32 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c index 78ab939ae5d8..f41f5f57e9f3 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik.c +++ b/drivers/gpu/drm/amd/amdgpu/cik.c | |||
@@ -2002,6 +2002,8 @@ int cik_set_ip_blocks(struct amdgpu_device *adev) | |||
2002 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); | 2002 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); |
2003 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); | 2003 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); |
2004 | amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); | 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 | if (amdgpu_dpm == -1) | 2007 | if (amdgpu_dpm == -1) |
2006 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 2008 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
2007 | else | 2009 | else |
@@ -2014,8 +2016,6 @@ int cik_set_ip_blocks(struct amdgpu_device *adev) | |||
2014 | #endif | 2016 | #endif |
2015 | else | 2017 | else |
2016 | amdgpu_device_ip_block_add(adev, &dce_v8_2_ip_block); | 2018 | amdgpu_device_ip_block_add(adev, &dce_v8_2_ip_block); |
2017 | amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block); | ||
2018 | amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); | ||
2019 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); | 2019 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); |
2020 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); | 2020 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); |
2021 | break; | 2021 | break; |
@@ -2023,6 +2023,8 @@ int cik_set_ip_blocks(struct amdgpu_device *adev) | |||
2023 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); | 2023 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); |
2024 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); | 2024 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); |
2025 | amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); | 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 | if (amdgpu_dpm == -1) | 2028 | if (amdgpu_dpm == -1) |
2027 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 2029 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
2028 | else | 2030 | else |
@@ -2035,8 +2037,6 @@ int cik_set_ip_blocks(struct amdgpu_device *adev) | |||
2035 | #endif | 2037 | #endif |
2036 | else | 2038 | else |
2037 | amdgpu_device_ip_block_add(adev, &dce_v8_5_ip_block); | 2039 | amdgpu_device_ip_block_add(adev, &dce_v8_5_ip_block); |
2038 | amdgpu_device_ip_block_add(adev, &gfx_v7_3_ip_block); | ||
2039 | amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); | ||
2040 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); | 2040 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); |
2041 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); | 2041 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); |
2042 | break; | 2042 | break; |
@@ -2044,6 +2044,8 @@ int cik_set_ip_blocks(struct amdgpu_device *adev) | |||
2044 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); | 2044 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); |
2045 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); | 2045 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); |
2046 | amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &kv_smu_ip_block); | 2049 | amdgpu_device_ip_block_add(adev, &kv_smu_ip_block); |
2048 | if (adev->enable_virtual_display) | 2050 | if (adev->enable_virtual_display) |
2049 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 2051 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
@@ -2053,8 +2055,7 @@ int cik_set_ip_blocks(struct amdgpu_device *adev) | |||
2053 | #endif | 2055 | #endif |
2054 | else | 2056 | else |
2055 | amdgpu_device_ip_block_add(adev, &dce_v8_1_ip_block); | 2057 | amdgpu_device_ip_block_add(adev, &dce_v8_1_ip_block); |
2056 | amdgpu_device_ip_block_add(adev, &gfx_v7_1_ip_block); | 2058 | |
2057 | amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); | ||
2058 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); | 2059 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); |
2059 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); | 2060 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); |
2060 | break; | 2061 | break; |
@@ -2063,6 +2064,8 @@ int cik_set_ip_blocks(struct amdgpu_device *adev) | |||
2063 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); | 2064 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); |
2064 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); | 2065 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); |
2065 | amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); | 2066 | amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); |
2067 | amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block); | ||
2068 | amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); | ||
2066 | amdgpu_device_ip_block_add(adev, &kv_smu_ip_block); | 2069 | amdgpu_device_ip_block_add(adev, &kv_smu_ip_block); |
2067 | if (adev->enable_virtual_display) | 2070 | if (adev->enable_virtual_display) |
2068 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 2071 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
@@ -2072,8 +2075,6 @@ int cik_set_ip_blocks(struct amdgpu_device *adev) | |||
2072 | #endif | 2075 | #endif |
2073 | else | 2076 | else |
2074 | amdgpu_device_ip_block_add(adev, &dce_v8_3_ip_block); | 2077 | amdgpu_device_ip_block_add(adev, &dce_v8_3_ip_block); |
2075 | amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block); | ||
2076 | amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); | ||
2077 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); | 2078 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); |
2078 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); | 2079 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); |
2079 | break; | 2080 | break; |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index 2aeef2bb93a4..3d0f277a6523 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
@@ -1173,64 +1173,61 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) | |||
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { | 1176 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_PFP]; |
1177 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_PFP]; | 1177 | info->ucode_id = AMDGPU_UCODE_ID_CP_PFP; |
1178 | info->ucode_id = AMDGPU_UCODE_ID_CP_PFP; | 1178 | info->fw = adev->gfx.pfp_fw; |
1179 | info->fw = adev->gfx.pfp_fw; | 1179 | header = (const struct common_firmware_header *)info->fw->data; |
1180 | header = (const struct common_firmware_header *)info->fw->data; | 1180 | adev->firmware.fw_size += |
1181 | adev->firmware.fw_size += | 1181 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); |
1182 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); | 1182 | |
1183 | 1183 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_ME]; | |
1184 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_ME]; | 1184 | info->ucode_id = AMDGPU_UCODE_ID_CP_ME; |
1185 | info->ucode_id = AMDGPU_UCODE_ID_CP_ME; | 1185 | info->fw = adev->gfx.me_fw; |
1186 | info->fw = adev->gfx.me_fw; | 1186 | header = (const struct common_firmware_header *)info->fw->data; |
1187 | header = (const struct common_firmware_header *)info->fw->data; | 1187 | adev->firmware.fw_size += |
1188 | adev->firmware.fw_size += | 1188 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); |
1189 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); | 1189 | |
1190 | 1190 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_CE]; | |
1191 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_CE]; | 1191 | info->ucode_id = AMDGPU_UCODE_ID_CP_CE; |
1192 | info->ucode_id = AMDGPU_UCODE_ID_CP_CE; | 1192 | info->fw = adev->gfx.ce_fw; |
1193 | info->fw = adev->gfx.ce_fw; | 1193 | header = (const struct common_firmware_header *)info->fw->data; |
1194 | header = (const struct common_firmware_header *)info->fw->data; | 1194 | adev->firmware.fw_size += |
1195 | adev->firmware.fw_size += | 1195 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); |
1196 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); | 1196 | |
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); | ||
1203 | |||
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); | ||
1197 | 1215 | ||
1198 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G]; | 1216 | if (amdgpu_sriov_vf(adev)) { |
1199 | info->ucode_id = AMDGPU_UCODE_ID_RLC_G; | 1217 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_STORAGE]; |
1200 | info->fw = adev->gfx.rlc_fw; | 1218 | info->ucode_id = AMDGPU_UCODE_ID_STORAGE; |
1201 | header = (const struct common_firmware_header *)info->fw->data; | 1219 | info->fw = adev->gfx.mec_fw; |
1202 | adev->firmware.fw_size += | 1220 | adev->firmware.fw_size += |
1203 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); | 1221 | ALIGN(le32_to_cpu(64 * PAGE_SIZE), PAGE_SIZE); |
1222 | } | ||
1204 | 1223 | ||
1205 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1]; | 1224 | if (adev->gfx.mec2_fw) { |
1206 | info->ucode_id = AMDGPU_UCODE_ID_CP_MEC1; | 1225 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC2]; |
1207 | info->fw = adev->gfx.mec_fw; | 1226 | info->ucode_id = AMDGPU_UCODE_ID_CP_MEC2; |
1227 | info->fw = adev->gfx.mec2_fw; | ||
1208 | header = (const struct common_firmware_header *)info->fw->data; | 1228 | header = (const struct common_firmware_header *)info->fw->data; |
1209 | adev->firmware.fw_size += | 1229 | adev->firmware.fw_size += |
1210 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); | 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 | out: | 1233 | out: |
@@ -2048,11 +2045,6 @@ static int gfx_v8_0_sw_init(void *handle) | |||
2048 | adev->gfx.mec.num_pipe_per_mec = 4; | 2045 | adev->gfx.mec.num_pipe_per_mec = 4; |
2049 | adev->gfx.mec.num_queue_per_pipe = 8; | 2046 | adev->gfx.mec.num_queue_per_pipe = 8; |
2050 | 2047 | ||
2051 | /* KIQ event */ | ||
2052 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_INT_IB2, &adev->gfx.kiq.irq); | ||
2053 | if (r) | ||
2054 | return r; | ||
2055 | |||
2056 | /* EOP Event */ | 2048 | /* EOP Event */ |
2057 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_END_OF_PIPE, &adev->gfx.eop_irq); | 2049 | r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_CP_END_OF_PIPE, &adev->gfx.eop_irq); |
2058 | if (r) | 2050 | if (r) |
@@ -4181,45 +4173,11 @@ static void gfx_v8_0_rlc_start(struct amdgpu_device *adev) | |||
4181 | udelay(50); | 4173 | udelay(50); |
4182 | } | 4174 | } |
4183 | 4175 | ||
4184 | static int gfx_v8_0_rlc_load_microcode(struct amdgpu_device *adev) | ||
4185 | { | ||
4186 | const struct rlc_firmware_header_v2_0 *hdr; | ||
4187 | const __le32 *fw_data; | ||
4188 | unsigned i, fw_size; | ||
4189 | |||
4190 | if (!adev->gfx.rlc_fw) | ||
4191 | return -EINVAL; | ||
4192 | |||
4193 | hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; | ||
4194 | amdgpu_ucode_print_rlc_hdr(&hdr->header); | ||
4195 | |||
4196 | fw_data = (const __le32 *)(adev->gfx.rlc_fw->data + | ||
4197 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
4198 | fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; | ||
4199 | |||
4200 | WREG32(mmRLC_GPM_UCODE_ADDR, 0); | ||
4201 | for (i = 0; i < fw_size; i++) | ||
4202 | WREG32(mmRLC_GPM_UCODE_DATA, le32_to_cpup(fw_data++)); | ||
4203 | WREG32(mmRLC_GPM_UCODE_ADDR, adev->gfx.rlc_fw_version); | ||
4204 | |||
4205 | return 0; | ||
4206 | } | ||
4207 | |||
4208 | static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev) | 4176 | static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev) |
4209 | { | 4177 | { |
4210 | int r; | ||
4211 | |||
4212 | gfx_v8_0_rlc_stop(adev); | 4178 | gfx_v8_0_rlc_stop(adev); |
4213 | gfx_v8_0_rlc_reset(adev); | 4179 | gfx_v8_0_rlc_reset(adev); |
4214 | gfx_v8_0_init_pg(adev); | 4180 | gfx_v8_0_init_pg(adev); |
4215 | |||
4216 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { | ||
4217 | /* legacy rlc firmware loading */ | ||
4218 | r = gfx_v8_0_rlc_load_microcode(adev); | ||
4219 | if (r) | ||
4220 | return r; | ||
4221 | } | ||
4222 | |||
4223 | gfx_v8_0_rlc_start(adev); | 4181 | gfx_v8_0_rlc_start(adev); |
4224 | 4182 | ||
4225 | return 0; | 4183 | return 0; |
@@ -4245,63 +4203,6 @@ static void gfx_v8_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable) | |||
4245 | udelay(50); | 4203 | udelay(50); |
4246 | } | 4204 | } |
4247 | 4205 | ||
4248 | static int gfx_v8_0_cp_gfx_load_microcode(struct amdgpu_device *adev) | ||
4249 | { | ||
4250 | const struct gfx_firmware_header_v1_0 *pfp_hdr; | ||
4251 | const struct gfx_firmware_header_v1_0 *ce_hdr; | ||
4252 | const struct gfx_firmware_header_v1_0 *me_hdr; | ||
4253 | const __le32 *fw_data; | ||
4254 | unsigned i, fw_size; | ||
4255 | |||
4256 | if (!adev->gfx.me_fw || !adev->gfx.pfp_fw || !adev->gfx.ce_fw) | ||
4257 | return -EINVAL; | ||
4258 | |||
4259 | pfp_hdr = (const struct gfx_firmware_header_v1_0 *) | ||
4260 | adev->gfx.pfp_fw->data; | ||
4261 | ce_hdr = (const struct gfx_firmware_header_v1_0 *) | ||
4262 | adev->gfx.ce_fw->data; | ||
4263 | me_hdr = (const struct gfx_firmware_header_v1_0 *) | ||
4264 | adev->gfx.me_fw->data; | ||
4265 | |||
4266 | amdgpu_ucode_print_gfx_hdr(&pfp_hdr->header); | ||
4267 | amdgpu_ucode_print_gfx_hdr(&ce_hdr->header); | ||
4268 | amdgpu_ucode_print_gfx_hdr(&me_hdr->header); | ||
4269 | |||
4270 | gfx_v8_0_cp_gfx_enable(adev, false); | ||
4271 | |||
4272 | /* PFP */ | ||
4273 | fw_data = (const __le32 *) | ||
4274 | (adev->gfx.pfp_fw->data + | ||
4275 | le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes)); | ||
4276 | fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes) / 4; | ||
4277 | WREG32(mmCP_PFP_UCODE_ADDR, 0); | ||
4278 | for (i = 0; i < fw_size; i++) | ||
4279 | WREG32(mmCP_PFP_UCODE_DATA, le32_to_cpup(fw_data++)); | ||
4280 | WREG32(mmCP_PFP_UCODE_ADDR, adev->gfx.pfp_fw_version); | ||
4281 | |||
4282 | /* CE */ | ||
4283 | fw_data = (const __le32 *) | ||
4284 | (adev->gfx.ce_fw->data + | ||
4285 | le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes)); | ||
4286 | fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes) / 4; | ||
4287 | WREG32(mmCP_CE_UCODE_ADDR, 0); | ||
4288 | for (i = 0; i < fw_size; i++) | ||
4289 | WREG32(mmCP_CE_UCODE_DATA, le32_to_cpup(fw_data++)); | ||
4290 | WREG32(mmCP_CE_UCODE_ADDR, adev->gfx.ce_fw_version); | ||
4291 | |||
4292 | /* ME */ | ||
4293 | fw_data = (const __le32 *) | ||
4294 | (adev->gfx.me_fw->data + | ||
4295 | le32_to_cpu(me_hdr->header.ucode_array_offset_bytes)); | ||
4296 | fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes) / 4; | ||
4297 | WREG32(mmCP_ME_RAM_WADDR, 0); | ||
4298 | for (i = 0; i < fw_size; i++) | ||
4299 | WREG32(mmCP_ME_RAM_DATA, le32_to_cpup(fw_data++)); | ||
4300 | WREG32(mmCP_ME_RAM_WADDR, adev->gfx.me_fw_version); | ||
4301 | |||
4302 | return 0; | ||
4303 | } | ||
4304 | |||
4305 | static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev) | 4206 | static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev) |
4306 | { | 4207 | { |
4307 | u32 count = 0; | 4208 | u32 count = 0; |
@@ -4501,52 +4402,6 @@ static void gfx_v8_0_cp_compute_enable(struct amdgpu_device *adev, bool enable) | |||
4501 | udelay(50); | 4402 | udelay(50); |
4502 | } | 4403 | } |
4503 | 4404 | ||
4504 | static int gfx_v8_0_cp_compute_load_microcode(struct amdgpu_device *adev) | ||
4505 | { | ||
4506 | const struct gfx_firmware_header_v1_0 *mec_hdr; | ||
4507 | const __le32 *fw_data; | ||
4508 | unsigned i, fw_size; | ||
4509 | |||
4510 | if (!adev->gfx.mec_fw) | ||
4511 | return -EINVAL; | ||
4512 | |||
4513 | gfx_v8_0_cp_compute_enable(adev, false); | ||
4514 | |||
4515 | mec_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data; | ||
4516 | amdgpu_ucode_print_gfx_hdr(&mec_hdr->header); | ||
4517 | |||
4518 | fw_data = (const __le32 *) | ||
4519 | (adev->gfx.mec_fw->data + | ||
4520 | le32_to_cpu(mec_hdr->header.ucode_array_offset_bytes)); | ||
4521 | fw_size = le32_to_cpu(mec_hdr->header.ucode_size_bytes) / 4; | ||
4522 | |||
4523 | /* MEC1 */ | ||
4524 | WREG32(mmCP_MEC_ME1_UCODE_ADDR, 0); | ||
4525 | for (i = 0; i < fw_size; i++) | ||
4526 | WREG32(mmCP_MEC_ME1_UCODE_DATA, le32_to_cpup(fw_data+i)); | ||
4527 | WREG32(mmCP_MEC_ME1_UCODE_ADDR, adev->gfx.mec_fw_version); | ||
4528 | |||
4529 | /* Loading MEC2 firmware is only necessary if MEC2 should run different microcode than MEC1. */ | ||
4530 | if (adev->gfx.mec2_fw) { | ||
4531 | const struct gfx_firmware_header_v1_0 *mec2_hdr; | ||
4532 | |||
4533 | mec2_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data; | ||
4534 | amdgpu_ucode_print_gfx_hdr(&mec2_hdr->header); | ||
4535 | |||
4536 | fw_data = (const __le32 *) | ||
4537 | (adev->gfx.mec2_fw->data + | ||
4538 | le32_to_cpu(mec2_hdr->header.ucode_array_offset_bytes)); | ||
4539 | fw_size = le32_to_cpu(mec2_hdr->header.ucode_size_bytes) / 4; | ||
4540 | |||
4541 | WREG32(mmCP_MEC_ME2_UCODE_ADDR, 0); | ||
4542 | for (i = 0; i < fw_size; i++) | ||
4543 | WREG32(mmCP_MEC_ME2_UCODE_DATA, le32_to_cpup(fw_data+i)); | ||
4544 | WREG32(mmCP_MEC_ME2_UCODE_ADDR, adev->gfx.mec2_fw_version); | ||
4545 | } | ||
4546 | |||
4547 | return 0; | ||
4548 | } | ||
4549 | |||
4550 | /* KIQ functions */ | 4405 | /* KIQ functions */ |
4551 | static void gfx_v8_0_kiq_setting(struct amdgpu_ring *ring) | 4406 | static void gfx_v8_0_kiq_setting(struct amdgpu_ring *ring) |
4552 | { | 4407 | { |
@@ -4872,7 +4727,7 @@ static int gfx_v8_0_kcq_init_queue(struct amdgpu_ring *ring) | |||
4872 | struct vi_mqd *mqd = ring->mqd_ptr; | 4727 | struct vi_mqd *mqd = ring->mqd_ptr; |
4873 | int mqd_idx = ring - &adev->gfx.compute_ring[0]; | 4728 | int mqd_idx = ring - &adev->gfx.compute_ring[0]; |
4874 | 4729 | ||
4875 | if (!adev->in_gpu_reset && !adev->gfx.in_suspend) { | 4730 | if (!adev->in_gpu_reset && !adev->in_suspend) { |
4876 | memset((void *)mqd, 0, sizeof(struct vi_mqd_allocation)); | 4731 | memset((void *)mqd, 0, sizeof(struct vi_mqd_allocation)); |
4877 | ((struct vi_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF; | 4732 | ((struct vi_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF; |
4878 | ((struct vi_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF; | 4733 | ((struct vi_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF; |
@@ -4980,17 +4835,6 @@ static int gfx_v8_0_cp_resume(struct amdgpu_device *adev) | |||
4980 | if (!(adev->flags & AMD_IS_APU)) | 4835 | if (!(adev->flags & AMD_IS_APU)) |
4981 | gfx_v8_0_enable_gui_idle_interrupt(adev, false); | 4836 | gfx_v8_0_enable_gui_idle_interrupt(adev, false); |
4982 | 4837 | ||
4983 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { | ||
4984 | /* legacy firmware loading */ | ||
4985 | r = gfx_v8_0_cp_gfx_load_microcode(adev); | ||
4986 | if (r) | ||
4987 | return r; | ||
4988 | |||
4989 | r = gfx_v8_0_cp_compute_load_microcode(adev); | ||
4990 | if (r) | ||
4991 | return r; | ||
4992 | } | ||
4993 | |||
4994 | r = gfx_v8_0_kiq_resume(adev); | 4838 | r = gfx_v8_0_kiq_resume(adev); |
4995 | if (r) | 4839 | if (r) |
4996 | return r; | 4840 | return r; |
@@ -5142,19 +4986,12 @@ static int gfx_v8_0_hw_fini(void *handle) | |||
5142 | 4986 | ||
5143 | static int gfx_v8_0_suspend(void *handle) | 4987 | static int gfx_v8_0_suspend(void *handle) |
5144 | { | 4988 | { |
5145 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 4989 | return gfx_v8_0_hw_fini(handle); |
5146 | adev->gfx.in_suspend = true; | ||
5147 | return gfx_v8_0_hw_fini(adev); | ||
5148 | } | 4990 | } |
5149 | 4991 | ||
5150 | static int gfx_v8_0_resume(void *handle) | 4992 | static int gfx_v8_0_resume(void *handle) |
5151 | { | 4993 | { |
5152 | int r; | 4994 | return gfx_v8_0_hw_init(handle); |
5153 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
5154 | |||
5155 | r = gfx_v8_0_hw_init(adev); | ||
5156 | adev->gfx.in_suspend = false; | ||
5157 | return r; | ||
5158 | } | 4995 | } |
5159 | 4996 | ||
5160 | static bool gfx_v8_0_check_soft_reset(void *handle) | 4997 | static bool gfx_v8_0_check_soft_reset(void *handle) |
@@ -7025,52 +6862,6 @@ static int gfx_v8_0_sq_irq(struct amdgpu_device *adev, | |||
7025 | return 0; | 6862 | return 0; |
7026 | } | 6863 | } |
7027 | 6864 | ||
7028 | static int gfx_v8_0_kiq_set_interrupt_state(struct amdgpu_device *adev, | ||
7029 | struct amdgpu_irq_src *src, | ||
7030 | unsigned int type, | ||
7031 | enum amdgpu_interrupt_state state) | ||
7032 | { | ||
7033 | struct amdgpu_ring *ring = &(adev->gfx.kiq.ring); | ||
7034 | |||
7035 | switch (type) { | ||
7036 | case AMDGPU_CP_KIQ_IRQ_DRIVER0: | ||
7037 | WREG32_FIELD(CPC_INT_CNTL, GENERIC2_INT_ENABLE, | ||
7038 | state == AMDGPU_IRQ_STATE_DISABLE ? 0 : 1); | ||
7039 | if (ring->me == 1) | ||
7040 | WREG32_FIELD_OFFSET(CP_ME1_PIPE0_INT_CNTL, | ||
7041 | ring->pipe, | ||
7042 | GENERIC2_INT_ENABLE, | ||
7043 | state == AMDGPU_IRQ_STATE_DISABLE ? 0 : 1); | ||
7044 | else | ||
7045 | WREG32_FIELD_OFFSET(CP_ME2_PIPE0_INT_CNTL, | ||
7046 | ring->pipe, | ||
7047 | GENERIC2_INT_ENABLE, | ||
7048 | state == AMDGPU_IRQ_STATE_DISABLE ? 0 : 1); | ||
7049 | break; | ||
7050 | default: | ||
7051 | BUG(); /* kiq only support GENERIC2_INT now */ | ||
7052 | break; | ||
7053 | } | ||
7054 | return 0; | ||
7055 | } | ||
7056 | |||
7057 | static int gfx_v8_0_kiq_irq(struct amdgpu_device *adev, | ||
7058 | struct amdgpu_irq_src *source, | ||
7059 | struct amdgpu_iv_entry *entry) | ||
7060 | { | ||
7061 | u8 me_id, pipe_id, queue_id; | ||
7062 | struct amdgpu_ring *ring = &(adev->gfx.kiq.ring); | ||
7063 | |||
7064 | me_id = (entry->ring_id & 0x0c) >> 2; | ||
7065 | pipe_id = (entry->ring_id & 0x03) >> 0; | ||
7066 | queue_id = (entry->ring_id & 0x70) >> 4; | ||
7067 | DRM_DEBUG("IH: CPC GENERIC2_INT, me:%d, pipe:%d, queue:%d\n", | ||
7068 | me_id, pipe_id, queue_id); | ||
7069 | |||
7070 | amdgpu_fence_process(ring); | ||
7071 | return 0; | ||
7072 | } | ||
7073 | |||
7074 | static const struct amd_ip_funcs gfx_v8_0_ip_funcs = { | 6865 | static const struct amd_ip_funcs gfx_v8_0_ip_funcs = { |
7075 | .name = "gfx_v8_0", | 6866 | .name = "gfx_v8_0", |
7076 | .early_init = gfx_v8_0_early_init, | 6867 | .early_init = gfx_v8_0_early_init, |
@@ -7221,11 +7012,6 @@ static const struct amdgpu_irq_src_funcs gfx_v8_0_priv_inst_irq_funcs = { | |||
7221 | .process = gfx_v8_0_priv_inst_irq, | 7012 | .process = gfx_v8_0_priv_inst_irq, |
7222 | }; | 7013 | }; |
7223 | 7014 | ||
7224 | static const struct amdgpu_irq_src_funcs gfx_v8_0_kiq_irq_funcs = { | ||
7225 | .set = gfx_v8_0_kiq_set_interrupt_state, | ||
7226 | .process = gfx_v8_0_kiq_irq, | ||
7227 | }; | ||
7228 | |||
7229 | static const struct amdgpu_irq_src_funcs gfx_v8_0_cp_ecc_error_irq_funcs = { | 7015 | static const struct amdgpu_irq_src_funcs gfx_v8_0_cp_ecc_error_irq_funcs = { |
7230 | .set = gfx_v8_0_set_cp_ecc_int_state, | 7016 | .set = gfx_v8_0_set_cp_ecc_int_state, |
7231 | .process = gfx_v8_0_cp_ecc_error_irq, | 7017 | .process = gfx_v8_0_cp_ecc_error_irq, |
@@ -7247,9 +7033,6 @@ static void gfx_v8_0_set_irq_funcs(struct amdgpu_device *adev) | |||
7247 | adev->gfx.priv_inst_irq.num_types = 1; | 7033 | adev->gfx.priv_inst_irq.num_types = 1; |
7248 | adev->gfx.priv_inst_irq.funcs = &gfx_v8_0_priv_inst_irq_funcs; | 7034 | adev->gfx.priv_inst_irq.funcs = &gfx_v8_0_priv_inst_irq_funcs; |
7249 | 7035 | ||
7250 | adev->gfx.kiq.irq.num_types = AMDGPU_CP_KIQ_IRQ_LAST; | ||
7251 | adev->gfx.kiq.irq.funcs = &gfx_v8_0_kiq_irq_funcs; | ||
7252 | |||
7253 | adev->gfx.cp_ecc_error_irq.num_types = 1; | 7036 | adev->gfx.cp_ecc_error_irq.num_types = 1; |
7254 | adev->gfx.cp_ecc_error_irq.funcs = &gfx_v8_0_cp_ecc_error_irq_funcs; | 7037 | adev->gfx.cp_ecc_error_irq.funcs = &gfx_v8_0_cp_ecc_error_irq_funcs; |
7255 | 7038 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index 261bb051b14d..e61f6a3ca241 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | |||
@@ -133,7 +133,10 @@ static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] = | |||
133 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000), | 133 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000), |
134 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x01000107), | 134 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x01000107), |
135 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x00001800, 0x00000800), | 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 | static const struct soc15_reg_golden golden_settings_gc_9_0_vg20[] = | 142 | static const struct soc15_reg_golden golden_settings_gc_9_0_vg20[] = |
@@ -173,7 +176,10 @@ static const struct soc15_reg_golden golden_settings_gc_9_1[] = | |||
173 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003120), | 176 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003120), |
174 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000), | 177 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000), |
175 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000000ff), | 178 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000000ff), |
176 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080) | 179 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080), |
180 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800), | ||
181 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800), | ||
182 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000) | ||
177 | }; | 183 | }; |
178 | 184 | ||
179 | static const struct soc15_reg_golden golden_settings_gc_9_1_rv1[] = | 185 | static const struct soc15_reg_golden golden_settings_gc_9_1_rv1[] = |
@@ -247,7 +253,10 @@ static const struct soc15_reg_golden golden_settings_gc_9_2_1_vg12[] = | |||
247 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0xffff03ff, 0x01000107), | 253 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0xffff03ff, 0x01000107), |
248 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000), | 254 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000), |
249 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x76325410), | 255 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x76325410), |
250 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01bd9f33, 0x01000000) | 256 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01bd9f33, 0x01000000), |
257 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC1_F32_INT_DIS, 0x00000000, 0x00000800), | ||
258 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_MEC2_F32_INT_DIS, 0x00000000, 0x00000800), | ||
259 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCP_DEBUG, 0x00000000, 0x00008000) | ||
251 | }; | 260 | }; |
252 | 261 | ||
253 | static const u32 GFX_RLC_SRM_INDEX_CNTL_ADDR_OFFSETS[] = | 262 | static const u32 GFX_RLC_SRM_INDEX_CNTL_ADDR_OFFSETS[] = |
@@ -908,6 +917,50 @@ static void gfx_v9_0_get_csb_buffer(struct amdgpu_device *adev, | |||
908 | buffer[count++] = cpu_to_le32(0); | 917 | buffer[count++] = cpu_to_le32(0); |
909 | } | 918 | } |
910 | 919 | ||
920 | static void gfx_v9_0_init_always_on_cu_mask(struct amdgpu_device *adev) | ||
921 | { | ||
922 | struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info; | ||
923 | uint32_t pg_always_on_cu_num = 2; | ||
924 | uint32_t always_on_cu_num; | ||
925 | uint32_t i, j, k; | ||
926 | uint32_t mask, cu_bitmap, counter; | ||
927 | |||
928 | if (adev->flags & AMD_IS_APU) | ||
929 | always_on_cu_num = 4; | ||
930 | else if (adev->asic_type == CHIP_VEGA12) | ||
931 | always_on_cu_num = 8; | ||
932 | else | ||
933 | always_on_cu_num = 12; | ||
934 | |||
935 | mutex_lock(&adev->grbm_idx_mutex); | ||
936 | for (i = 0; i < adev->gfx.config.max_shader_engines; i++) { | ||
937 | for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) { | ||
938 | mask = 1; | ||
939 | cu_bitmap = 0; | ||
940 | counter = 0; | ||
941 | gfx_v9_0_select_se_sh(adev, i, j, 0xffffffff); | ||
942 | |||
943 | for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) { | ||
944 | if (cu_info->bitmap[i][j] & mask) { | ||
945 | if (counter == pg_always_on_cu_num) | ||
946 | WREG32_SOC15(GC, 0, mmRLC_PG_ALWAYS_ON_CU_MASK, cu_bitmap); | ||
947 | if (counter < always_on_cu_num) | ||
948 | cu_bitmap |= mask; | ||
949 | else | ||
950 | break; | ||
951 | counter++; | ||
952 | } | ||
953 | mask <<= 1; | ||
954 | } | ||
955 | |||
956 | WREG32_SOC15(GC, 0, mmRLC_LB_ALWAYS_ACTIVE_CU_MASK, cu_bitmap); | ||
957 | cu_info->ao_cu_bitmap[i][j] = cu_bitmap; | ||
958 | } | ||
959 | } | ||
960 | gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
961 | mutex_unlock(&adev->grbm_idx_mutex); | ||
962 | } | ||
963 | |||
911 | static void gfx_v9_0_init_lbpw(struct amdgpu_device *adev) | 964 | static void gfx_v9_0_init_lbpw(struct amdgpu_device *adev) |
912 | { | 965 | { |
913 | uint32_t data; | 966 | uint32_t data; |
@@ -941,8 +994,10 @@ static void gfx_v9_0_init_lbpw(struct amdgpu_device *adev) | |||
941 | data |= 0x00C00000; | 994 | data |= 0x00C00000; |
942 | WREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7, data); | 995 | WREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7, data); |
943 | 996 | ||
944 | /* set RLC_LB_ALWAYS_ACTIVE_CU_MASK = 0xFFF */ | 997 | /* |
945 | WREG32_SOC15(GC, 0, mmRLC_LB_ALWAYS_ACTIVE_CU_MASK, 0xFFF); | 998 | * RLC_LB_ALWAYS_ACTIVE_CU_MASK = 0xF (4 CUs AON for Raven), |
999 | * programmed in gfx_v9_0_init_always_on_cu_mask() | ||
1000 | */ | ||
946 | 1001 | ||
947 | /* set RLC_LB_CNTL = 0x8000_0095, 31 bit is reserved, | 1002 | /* set RLC_LB_CNTL = 0x8000_0095, 31 bit is reserved, |
948 | * but used for RLC_LB_CNTL configuration */ | 1003 | * but used for RLC_LB_CNTL configuration */ |
@@ -951,6 +1006,57 @@ static void gfx_v9_0_init_lbpw(struct amdgpu_device *adev) | |||
951 | data |= REG_SET_FIELD(data, RLC_LB_CNTL, RESERVED, 0x80000); | 1006 | data |= REG_SET_FIELD(data, RLC_LB_CNTL, RESERVED, 0x80000); |
952 | WREG32_SOC15(GC, 0, mmRLC_LB_CNTL, data); | 1007 | WREG32_SOC15(GC, 0, mmRLC_LB_CNTL, data); |
953 | mutex_unlock(&adev->grbm_idx_mutex); | 1008 | mutex_unlock(&adev->grbm_idx_mutex); |
1009 | |||
1010 | gfx_v9_0_init_always_on_cu_mask(adev); | ||
1011 | } | ||
1012 | |||
1013 | static void gfx_v9_4_init_lbpw(struct amdgpu_device *adev) | ||
1014 | { | ||
1015 | uint32_t data; | ||
1016 | |||
1017 | /* set mmRLC_LB_THR_CONFIG_1/2/3/4 */ | ||
1018 | WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_1, 0x0000007F); | ||
1019 | WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_2, 0x033388F8); | ||
1020 | WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_3, 0x00000077); | ||
1021 | WREG32_SOC15(GC, 0, mmRLC_LB_THR_CONFIG_4, (0x10 | 0x27 << 8 | 0x02FA << 16)); | ||
1022 | |||
1023 | /* set mmRLC_LB_CNTR_INIT = 0x0000_0000 */ | ||
1024 | WREG32_SOC15(GC, 0, mmRLC_LB_CNTR_INIT, 0x00000000); | ||
1025 | |||
1026 | /* set mmRLC_LB_CNTR_MAX = 0x0000_0500 */ | ||
1027 | WREG32_SOC15(GC, 0, mmRLC_LB_CNTR_MAX, 0x00000800); | ||
1028 | |||
1029 | mutex_lock(&adev->grbm_idx_mutex); | ||
1030 | /* set mmRLC_LB_INIT_CU_MASK thru broadcast mode to enable all SE/SH*/ | ||
1031 | gfx_v9_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
1032 | WREG32_SOC15(GC, 0, mmRLC_LB_INIT_CU_MASK, 0xffffffff); | ||
1033 | |||
1034 | /* set mmRLC_LB_PARAMS = 0x003F_1006 */ | ||
1035 | data = REG_SET_FIELD(0, RLC_LB_PARAMS, FIFO_SAMPLES, 0x0003); | ||
1036 | data |= REG_SET_FIELD(data, RLC_LB_PARAMS, PG_IDLE_SAMPLES, 0x0010); | ||
1037 | data |= REG_SET_FIELD(data, RLC_LB_PARAMS, PG_IDLE_SAMPLE_INTERVAL, 0x033F); | ||
1038 | WREG32_SOC15(GC, 0, mmRLC_LB_PARAMS, data); | ||
1039 | |||
1040 | /* set mmRLC_GPM_GENERAL_7[31-16] = 0x00C0 */ | ||
1041 | data = RREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7); | ||
1042 | data &= 0x0000FFFF; | ||
1043 | data |= 0x00C00000; | ||
1044 | WREG32_SOC15(GC, 0, mmRLC_GPM_GENERAL_7, data); | ||
1045 | |||
1046 | /* | ||
1047 | * RLC_LB_ALWAYS_ACTIVE_CU_MASK = 0xFFF (12 CUs AON), | ||
1048 | * programmed in gfx_v9_0_init_always_on_cu_mask() | ||
1049 | */ | ||
1050 | |||
1051 | /* set RLC_LB_CNTL = 0x8000_0095, 31 bit is reserved, | ||
1052 | * but used for RLC_LB_CNTL configuration */ | ||
1053 | data = RLC_LB_CNTL__LB_CNT_SPIM_ACTIVE_MASK; | ||
1054 | data |= REG_SET_FIELD(data, RLC_LB_CNTL, CU_MASK_USED_OFF_HYST, 0x09); | ||
1055 | data |= REG_SET_FIELD(data, RLC_LB_CNTL, RESERVED, 0x80000); | ||
1056 | WREG32_SOC15(GC, 0, mmRLC_LB_CNTL, data); | ||
1057 | mutex_unlock(&adev->grbm_idx_mutex); | ||
1058 | |||
1059 | gfx_v9_0_init_always_on_cu_mask(adev); | ||
954 | } | 1060 | } |
955 | 1061 | ||
956 | static void gfx_v9_0_enable_lbpw(struct amdgpu_device *adev, bool enable) | 1062 | static void gfx_v9_0_enable_lbpw(struct amdgpu_device *adev, bool enable) |
@@ -1084,8 +1190,17 @@ static int gfx_v9_0_rlc_init(struct amdgpu_device *adev) | |||
1084 | rv_init_cp_jump_table(adev); | 1190 | rv_init_cp_jump_table(adev); |
1085 | amdgpu_bo_kunmap(adev->gfx.rlc.cp_table_obj); | 1191 | amdgpu_bo_kunmap(adev->gfx.rlc.cp_table_obj); |
1086 | amdgpu_bo_unreserve(adev->gfx.rlc.cp_table_obj); | 1192 | amdgpu_bo_unreserve(adev->gfx.rlc.cp_table_obj); |
1193 | } | ||
1087 | 1194 | ||
1195 | switch (adev->asic_type) { | ||
1196 | case CHIP_RAVEN: | ||
1088 | gfx_v9_0_init_lbpw(adev); | 1197 | gfx_v9_0_init_lbpw(adev); |
1198 | break; | ||
1199 | case CHIP_VEGA20: | ||
1200 | gfx_v9_4_init_lbpw(adev); | ||
1201 | break; | ||
1202 | default: | ||
1203 | break; | ||
1089 | } | 1204 | } |
1090 | 1205 | ||
1091 | return 0; | 1206 | return 0; |
@@ -1605,11 +1720,6 @@ static int gfx_v9_0_sw_init(void *handle) | |||
1605 | adev->gfx.mec.num_pipe_per_mec = 4; | 1720 | adev->gfx.mec.num_pipe_per_mec = 4; |
1606 | adev->gfx.mec.num_queue_per_pipe = 8; | 1721 | adev->gfx.mec.num_queue_per_pipe = 8; |
1607 | 1722 | ||
1608 | /* KIQ event */ | ||
1609 | r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP, GFX_9_0__SRCID__CP_IB2_INTERRUPT_PKT, &adev->gfx.kiq.irq); | ||
1610 | if (r) | ||
1611 | return r; | ||
1612 | |||
1613 | /* EOP Event */ | 1723 | /* EOP Event */ |
1614 | r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP, GFX_9_0__SRCID__CP_EOP_INTERRUPT, &adev->gfx.eop_irq); | 1724 | r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_GRBM_CP, GFX_9_0__SRCID__CP_EOP_INTERRUPT, &adev->gfx.eop_irq); |
1615 | if (r) | 1725 | if (r) |
@@ -2403,7 +2513,8 @@ static int gfx_v9_0_rlc_resume(struct amdgpu_device *adev) | |||
2403 | return r; | 2513 | return r; |
2404 | } | 2514 | } |
2405 | 2515 | ||
2406 | if (adev->asic_type == CHIP_RAVEN) { | 2516 | if (adev->asic_type == CHIP_RAVEN || |
2517 | adev->asic_type == CHIP_VEGA20) { | ||
2407 | if (amdgpu_lbpw != 0) | 2518 | if (amdgpu_lbpw != 0) |
2408 | gfx_v9_0_enable_lbpw(adev, true); | 2519 | gfx_v9_0_enable_lbpw(adev, true); |
2409 | else | 2520 | else |
@@ -3091,7 +3202,7 @@ static int gfx_v9_0_kcq_init_queue(struct amdgpu_ring *ring) | |||
3091 | struct v9_mqd *mqd = ring->mqd_ptr; | 3202 | struct v9_mqd *mqd = ring->mqd_ptr; |
3092 | int mqd_idx = ring - &adev->gfx.compute_ring[0]; | 3203 | int mqd_idx = ring - &adev->gfx.compute_ring[0]; |
3093 | 3204 | ||
3094 | if (!adev->in_gpu_reset && !adev->gfx.in_suspend) { | 3205 | if (!adev->in_gpu_reset && !adev->in_suspend) { |
3095 | memset((void *)mqd, 0, sizeof(struct v9_mqd_allocation)); | 3206 | memset((void *)mqd, 0, sizeof(struct v9_mqd_allocation)); |
3096 | ((struct v9_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF; | 3207 | ((struct v9_mqd_allocation *)mqd)->dynamic_cu_mask = 0xFFFFFFFF; |
3097 | ((struct v9_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF; | 3208 | ((struct v9_mqd_allocation *)mqd)->dynamic_rb_mask = 0xFFFFFFFF; |
@@ -3310,7 +3421,7 @@ static int gfx_v9_0_hw_fini(void *handle) | |||
3310 | /* Use deinitialize sequence from CAIL when unbinding device from driver, | 3421 | /* Use deinitialize sequence from CAIL when unbinding device from driver, |
3311 | * otherwise KIQ is hanging when binding back | 3422 | * otherwise KIQ is hanging when binding back |
3312 | */ | 3423 | */ |
3313 | if (!adev->in_gpu_reset && !adev->gfx.in_suspend) { | 3424 | if (!adev->in_gpu_reset && !adev->in_suspend) { |
3314 | mutex_lock(&adev->srbm_mutex); | 3425 | mutex_lock(&adev->srbm_mutex); |
3315 | soc15_grbm_select(adev, adev->gfx.kiq.ring.me, | 3426 | soc15_grbm_select(adev, adev->gfx.kiq.ring.me, |
3316 | adev->gfx.kiq.ring.pipe, | 3427 | adev->gfx.kiq.ring.pipe, |
@@ -3330,20 +3441,12 @@ static int gfx_v9_0_hw_fini(void *handle) | |||
3330 | 3441 | ||
3331 | static int gfx_v9_0_suspend(void *handle) | 3442 | static int gfx_v9_0_suspend(void *handle) |
3332 | { | 3443 | { |
3333 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 3444 | return gfx_v9_0_hw_fini(handle); |
3334 | |||
3335 | adev->gfx.in_suspend = true; | ||
3336 | return gfx_v9_0_hw_fini(adev); | ||
3337 | } | 3445 | } |
3338 | 3446 | ||
3339 | static int gfx_v9_0_resume(void *handle) | 3447 | static int gfx_v9_0_resume(void *handle) |
3340 | { | 3448 | { |
3341 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 3449 | return gfx_v9_0_hw_init(handle); |
3342 | int r; | ||
3343 | |||
3344 | r = gfx_v9_0_hw_init(adev); | ||
3345 | adev->gfx.in_suspend = false; | ||
3346 | return r; | ||
3347 | } | 3450 | } |
3348 | 3451 | ||
3349 | static bool gfx_v9_0_is_idle(void *handle) | 3452 | static bool gfx_v9_0_is_idle(void *handle) |
@@ -4609,68 +4712,6 @@ static int gfx_v9_0_priv_inst_irq(struct amdgpu_device *adev, | |||
4609 | return 0; | 4712 | return 0; |
4610 | } | 4713 | } |
4611 | 4714 | ||
4612 | static int gfx_v9_0_kiq_set_interrupt_state(struct amdgpu_device *adev, | ||
4613 | struct amdgpu_irq_src *src, | ||
4614 | unsigned int type, | ||
4615 | enum amdgpu_interrupt_state state) | ||
4616 | { | ||
4617 | uint32_t tmp, target; | ||
4618 | struct amdgpu_ring *ring = &(adev->gfx.kiq.ring); | ||
4619 | |||
4620 | if (ring->me == 1) | ||
4621 | target = SOC15_REG_OFFSET(GC, 0, mmCP_ME1_PIPE0_INT_CNTL); | ||
4622 | else | ||
4623 | target = SOC15_REG_OFFSET(GC, 0, mmCP_ME2_PIPE0_INT_CNTL); | ||
4624 | target += ring->pipe; | ||
4625 | |||
4626 | switch (type) { | ||
4627 | case AMDGPU_CP_KIQ_IRQ_DRIVER0: | ||
4628 | if (state == AMDGPU_IRQ_STATE_DISABLE) { | ||
4629 | tmp = RREG32_SOC15(GC, 0, mmCPC_INT_CNTL); | ||
4630 | tmp = REG_SET_FIELD(tmp, CPC_INT_CNTL, | ||
4631 | GENERIC2_INT_ENABLE, 0); | ||
4632 | WREG32_SOC15(GC, 0, mmCPC_INT_CNTL, tmp); | ||
4633 | |||
4634 | tmp = RREG32(target); | ||
4635 | tmp = REG_SET_FIELD(tmp, CP_ME2_PIPE0_INT_CNTL, | ||
4636 | GENERIC2_INT_ENABLE, 0); | ||
4637 | WREG32(target, tmp); | ||
4638 | } else { | ||
4639 | tmp = RREG32_SOC15(GC, 0, mmCPC_INT_CNTL); | ||
4640 | tmp = REG_SET_FIELD(tmp, CPC_INT_CNTL, | ||
4641 | GENERIC2_INT_ENABLE, 1); | ||
4642 | WREG32_SOC15(GC, 0, mmCPC_INT_CNTL, tmp); | ||
4643 | |||
4644 | tmp = RREG32(target); | ||
4645 | tmp = REG_SET_FIELD(tmp, CP_ME2_PIPE0_INT_CNTL, | ||
4646 | GENERIC2_INT_ENABLE, 1); | ||
4647 | WREG32(target, tmp); | ||
4648 | } | ||
4649 | break; | ||
4650 | default: | ||
4651 | BUG(); /* kiq only support GENERIC2_INT now */ | ||
4652 | break; | ||
4653 | } | ||
4654 | return 0; | ||
4655 | } | ||
4656 | |||
4657 | static int gfx_v9_0_kiq_irq(struct amdgpu_device *adev, | ||
4658 | struct amdgpu_irq_src *source, | ||
4659 | struct amdgpu_iv_entry *entry) | ||
4660 | { | ||
4661 | u8 me_id, pipe_id, queue_id; | ||
4662 | struct amdgpu_ring *ring = &(adev->gfx.kiq.ring); | ||
4663 | |||
4664 | me_id = (entry->ring_id & 0x0c) >> 2; | ||
4665 | pipe_id = (entry->ring_id & 0x03) >> 0; | ||
4666 | queue_id = (entry->ring_id & 0x70) >> 4; | ||
4667 | DRM_DEBUG("IH: CPC GENERIC2_INT, me:%d, pipe:%d, queue:%d\n", | ||
4668 | me_id, pipe_id, queue_id); | ||
4669 | |||
4670 | amdgpu_fence_process(ring); | ||
4671 | return 0; | ||
4672 | } | ||
4673 | |||
4674 | static const struct amd_ip_funcs gfx_v9_0_ip_funcs = { | 4715 | static const struct amd_ip_funcs gfx_v9_0_ip_funcs = { |
4675 | .name = "gfx_v9_0", | 4716 | .name = "gfx_v9_0", |
4676 | .early_init = gfx_v9_0_early_init, | 4717 | .early_init = gfx_v9_0_early_init, |
@@ -4819,11 +4860,6 @@ static void gfx_v9_0_set_ring_funcs(struct amdgpu_device *adev) | |||
4819 | adev->gfx.compute_ring[i].funcs = &gfx_v9_0_ring_funcs_compute; | 4860 | adev->gfx.compute_ring[i].funcs = &gfx_v9_0_ring_funcs_compute; |
4820 | } | 4861 | } |
4821 | 4862 | ||
4822 | static const struct amdgpu_irq_src_funcs gfx_v9_0_kiq_irq_funcs = { | ||
4823 | .set = gfx_v9_0_kiq_set_interrupt_state, | ||
4824 | .process = gfx_v9_0_kiq_irq, | ||
4825 | }; | ||
4826 | |||
4827 | static const struct amdgpu_irq_src_funcs gfx_v9_0_eop_irq_funcs = { | 4863 | static const struct amdgpu_irq_src_funcs gfx_v9_0_eop_irq_funcs = { |
4828 | .set = gfx_v9_0_set_eop_interrupt_state, | 4864 | .set = gfx_v9_0_set_eop_interrupt_state, |
4829 | .process = gfx_v9_0_eop_irq, | 4865 | .process = gfx_v9_0_eop_irq, |
@@ -4849,9 +4885,6 @@ static void gfx_v9_0_set_irq_funcs(struct amdgpu_device *adev) | |||
4849 | 4885 | ||
4850 | adev->gfx.priv_inst_irq.num_types = 1; | 4886 | adev->gfx.priv_inst_irq.num_types = 1; |
4851 | adev->gfx.priv_inst_irq.funcs = &gfx_v9_0_priv_inst_irq_funcs; | 4887 | adev->gfx.priv_inst_irq.funcs = &gfx_v9_0_priv_inst_irq_funcs; |
4852 | |||
4853 | adev->gfx.kiq.irq.num_types = AMDGPU_CP_KIQ_IRQ_LAST; | ||
4854 | adev->gfx.kiq.irq.funcs = &gfx_v9_0_kiq_irq_funcs; | ||
4855 | } | 4888 | } |
4856 | 4889 | ||
4857 | static void gfx_v9_0_set_rlc_funcs(struct amdgpu_device *adev) | 4890 | static void gfx_v9_0_set_rlc_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c index 9217af00bc8d..3f3fac2d50cd 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | |||
@@ -306,11 +306,8 @@ static int psp_v11_0_ring_stop(struct psp_context *psp, | |||
306 | enum psp_ring_type ring_type) | 306 | enum psp_ring_type ring_type) |
307 | { | 307 | { |
308 | int ret = 0; | 308 | int ret = 0; |
309 | struct psp_ring *ring; | ||
310 | struct amdgpu_device *adev = psp->adev; | 309 | struct amdgpu_device *adev = psp->adev; |
311 | 310 | ||
312 | ring = &psp->km_ring; | ||
313 | |||
314 | /* Write the ring destroy command to C2PMSG_64 */ | 311 | /* Write the ring destroy command to C2PMSG_64 */ |
315 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_64, GFX_CTRL_CMD_ID_DESTROY_RINGS); | 312 | WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_64, GFX_CTRL_CMD_ID_DESTROY_RINGS); |
316 | 313 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c index cd781abc4953..2d4770e173dd 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | |||
@@ -504,41 +504,6 @@ static int sdma_v2_4_rlc_resume(struct amdgpu_device *adev) | |||
504 | return 0; | 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 | * sdma_v2_4_start - setup and start the async dma engines | 509 | * sdma_v2_4_start - setup and start the async dma engines |
@@ -552,13 +517,6 @@ static int sdma_v2_4_start(struct amdgpu_device *adev) | |||
552 | { | 517 | { |
553 | int r; | 518 | int r; |
554 | 519 | ||
555 | |||
556 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { | ||
557 | r = sdma_v2_4_load_microcode(adev); | ||
558 | if (r) | ||
559 | return r; | ||
560 | } | ||
561 | |||
562 | /* halt the engine before programing */ | 520 | /* halt the engine before programing */ |
563 | sdma_v2_4_enable(adev, false); | 521 | sdma_v2_4_enable(adev, false); |
564 | 522 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c index 6d5c8ac64874..6fb3edaba0ec 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | |||
@@ -318,14 +318,13 @@ static int sdma_v3_0_init_microcode(struct amdgpu_device *adev) | |||
318 | if (adev->sdma.instance[i].feature_version >= 20) | 318 | if (adev->sdma.instance[i].feature_version >= 20) |
319 | adev->sdma.instance[i].burst_nop = true; | 319 | adev->sdma.instance[i].burst_nop = true; |
320 | 320 | ||
321 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { | 321 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i]; |
322 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i]; | 322 | info->ucode_id = AMDGPU_UCODE_ID_SDMA0 + i; |
323 | info->ucode_id = AMDGPU_UCODE_ID_SDMA0 + i; | 323 | info->fw = adev->sdma.instance[i].fw; |
324 | info->fw = adev->sdma.instance[i].fw; | 324 | header = (const struct common_firmware_header *)info->fw->data; |
325 | header = (const struct common_firmware_header *)info->fw->data; | 325 | adev->firmware.fw_size += |
326 | adev->firmware.fw_size += | 326 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); |
327 | ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); | 327 | |
328 | } | ||
329 | } | 328 | } |
330 | out: | 329 | out: |
331 | if (err) { | 330 | if (err) { |
@@ -778,42 +777,6 @@ static int sdma_v3_0_rlc_resume(struct amdgpu_device *adev) | |||
778 | } | 777 | } |
779 | 778 | ||
780 | /** | 779 | /** |
781 | * sdma_v3_0_load_microcode - load the sDMA ME ucode | ||
782 | * | ||
783 | * @adev: amdgpu_device pointer | ||
784 | * | ||
785 | * Loads the sDMA0/1 ucode. | ||
786 | * Returns 0 for success, -EINVAL if the ucode is not available. | ||
787 | */ | ||
788 | static int sdma_v3_0_load_microcode(struct amdgpu_device *adev) | ||
789 | { | ||
790 | const struct sdma_firmware_header_v1_0 *hdr; | ||
791 | const __le32 *fw_data; | ||
792 | u32 fw_size; | ||
793 | int i, j; | ||
794 | |||
795 | /* halt the MEs */ | ||
796 | sdma_v3_0_enable(adev, false); | ||
797 | |||
798 | for (i = 0; i < adev->sdma.num_instances; i++) { | ||
799 | if (!adev->sdma.instance[i].fw) | ||
800 | return -EINVAL; | ||
801 | hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma.instance[i].fw->data; | ||
802 | amdgpu_ucode_print_sdma_hdr(&hdr->header); | ||
803 | fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; | ||
804 | fw_data = (const __le32 *) | ||
805 | (adev->sdma.instance[i].fw->data + | ||
806 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | ||
807 | WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], 0); | ||
808 | for (j = 0; j < fw_size; j++) | ||
809 | WREG32(mmSDMA0_UCODE_DATA + sdma_offsets[i], le32_to_cpup(fw_data++)); | ||
810 | WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], adev->sdma.instance[i].fw_version); | ||
811 | } | ||
812 | |||
813 | return 0; | ||
814 | } | ||
815 | |||
816 | /** | ||
817 | * sdma_v3_0_start - setup and start the async dma engines | 780 | * sdma_v3_0_start - setup and start the async dma engines |
818 | * | 781 | * |
819 | * @adev: amdgpu_device pointer | 782 | * @adev: amdgpu_device pointer |
@@ -825,12 +788,6 @@ static int sdma_v3_0_start(struct amdgpu_device *adev) | |||
825 | { | 788 | { |
826 | int r; | 789 | int r; |
827 | 790 | ||
828 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) { | ||
829 | r = sdma_v3_0_load_microcode(adev); | ||
830 | if (r) | ||
831 | return r; | ||
832 | } | ||
833 | |||
834 | /* disable sdma engine before programing it */ | 791 | /* disable sdma engine before programing it */ |
835 | sdma_v3_0_ctx_switch_enable(adev, false); | 792 | sdma_v3_0_ctx_switch_enable(adev, false); |
836 | sdma_v3_0_enable(adev, false); | 793 | sdma_v3_0_enable(adev, false); |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index a3e2ed15fff2..c20d413f277c 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | |||
@@ -818,7 +818,7 @@ sdma_v4_1_update_power_gating(struct amdgpu_device *adev, bool enable) | |||
818 | uint32_t def, data; | 818 | uint32_t def, data; |
819 | 819 | ||
820 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_SDMA)) { | 820 | if (enable && (adev->pg_flags & AMD_PG_SUPPORT_SDMA)) { |
821 | /* disable idle interrupt */ | 821 | /* enable idle interrupt */ |
822 | def = data = RREG32(SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_CNTL)); | 822 | def = data = RREG32(SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_CNTL)); |
823 | data |= SDMA0_CNTL__CTXEMPTY_INT_ENABLE_MASK; | 823 | data |= SDMA0_CNTL__CTXEMPTY_INT_ENABLE_MASK; |
824 | 824 | ||
@@ -1364,6 +1364,9 @@ static int sdma_v4_0_hw_init(void *handle) | |||
1364 | int r; | 1364 | int r; |
1365 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 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 | sdma_v4_0_init_golden_registers(adev); | 1370 | sdma_v4_0_init_golden_registers(adev); |
1368 | 1371 | ||
1369 | r = sdma_v4_0_start(adev); | 1372 | r = sdma_v4_0_start(adev); |
@@ -1381,6 +1384,9 @@ static int sdma_v4_0_hw_fini(void *handle) | |||
1381 | sdma_v4_0_ctx_switch_enable(adev, false); | 1384 | sdma_v4_0_ctx_switch_enable(adev, false); |
1382 | sdma_v4_0_enable(adev, false); | 1385 | sdma_v4_0_enable(adev, false); |
1383 | 1386 | ||
1387 | if (adev->asic_type == CHIP_RAVEN && adev->powerplay.pp_funcs->set_powergating_by_smu) | ||
1388 | amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_SDMA, true); | ||
1389 | |||
1384 | return 0; | 1390 | return 0; |
1385 | } | 1391 | } |
1386 | 1392 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c index c364ef94cc36..f8408f88cd37 100644 --- a/drivers/gpu/drm/amd/amdgpu/si.c +++ b/drivers/gpu/drm/amd/amdgpu/si.c | |||
@@ -2057,13 +2057,13 @@ int si_set_ip_blocks(struct amdgpu_device *adev) | |||
2057 | amdgpu_device_ip_block_add(adev, &si_common_ip_block); | 2057 | amdgpu_device_ip_block_add(adev, &si_common_ip_block); |
2058 | amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); | 2058 | amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); |
2059 | amdgpu_device_ip_block_add(adev, &si_ih_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &si_smu_ip_block); | 2062 | amdgpu_device_ip_block_add(adev, &si_smu_ip_block); |
2061 | if (adev->enable_virtual_display) | 2063 | if (adev->enable_virtual_display) |
2062 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 2064 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
2063 | else | 2065 | else |
2064 | amdgpu_device_ip_block_add(adev, &dce_v6_0_ip_block); | 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 | /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ | 2067 | /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ |
2068 | /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ | 2068 | /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ |
2069 | break; | 2069 | break; |
@@ -2071,13 +2071,14 @@ int si_set_ip_blocks(struct amdgpu_device *adev) | |||
2071 | amdgpu_device_ip_block_add(adev, &si_common_ip_block); | 2071 | amdgpu_device_ip_block_add(adev, &si_common_ip_block); |
2072 | amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); | 2072 | amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); |
2073 | amdgpu_device_ip_block_add(adev, &si_ih_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &si_smu_ip_block); | 2076 | amdgpu_device_ip_block_add(adev, &si_smu_ip_block); |
2075 | if (adev->enable_virtual_display) | 2077 | if (adev->enable_virtual_display) |
2076 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 2078 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
2077 | else | 2079 | else |
2078 | amdgpu_device_ip_block_add(adev, &dce_v6_4_ip_block); | 2080 | amdgpu_device_ip_block_add(adev, &dce_v6_4_ip_block); |
2079 | amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); | 2081 | |
2080 | amdgpu_device_ip_block_add(adev, &si_dma_ip_block); | ||
2081 | /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ | 2082 | /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ |
2082 | /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ | 2083 | /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ |
2083 | break; | 2084 | break; |
@@ -2085,11 +2086,11 @@ int si_set_ip_blocks(struct amdgpu_device *adev) | |||
2085 | amdgpu_device_ip_block_add(adev, &si_common_ip_block); | 2086 | amdgpu_device_ip_block_add(adev, &si_common_ip_block); |
2086 | amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); | 2087 | amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); |
2087 | amdgpu_device_ip_block_add(adev, &si_ih_ip_block); | 2088 | amdgpu_device_ip_block_add(adev, &si_ih_ip_block); |
2089 | amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); | ||
2090 | amdgpu_device_ip_block_add(adev, &si_dma_ip_block); | ||
2088 | amdgpu_device_ip_block_add(adev, &si_smu_ip_block); | 2091 | amdgpu_device_ip_block_add(adev, &si_smu_ip_block); |
2089 | if (adev->enable_virtual_display) | 2092 | if (adev->enable_virtual_display) |
2090 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 2093 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
2091 | amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); | ||
2092 | amdgpu_device_ip_block_add(adev, &si_dma_ip_block); | ||
2093 | break; | 2094 | break; |
2094 | default: | 2095 | default: |
2095 | BUG(); | 2096 | BUG(); |
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dma.c b/drivers/gpu/drm/amd/amdgpu/si_dma.c index d4ceaf440f26..adbaea6da0d7 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dma.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dma.c | |||
@@ -502,12 +502,14 @@ static int si_dma_sw_init(void *handle) | |||
502 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 502 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
503 | 503 | ||
504 | /* DMA0 trap event */ | 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 | if (r) | 507 | if (r) |
507 | return r; | 508 | return r; |
508 | 509 | ||
509 | /* DMA1 trap event */ | 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 | if (r) | 513 | if (r) |
512 | return r; | 514 | return r; |
513 | 515 | ||
@@ -649,17 +651,10 @@ static int si_dma_process_trap_irq(struct amdgpu_device *adev, | |||
649 | struct amdgpu_irq_src *source, | 651 | struct amdgpu_irq_src *source, |
650 | struct amdgpu_iv_entry *entry) | 652 | struct amdgpu_iv_entry *entry) |
651 | { | 653 | { |
652 | amdgpu_fence_process(&adev->sdma.instance[0].ring); | 654 | if (entry->src_id == 224) |
653 | 655 | amdgpu_fence_process(&adev->sdma.instance[0].ring); | |
654 | return 0; | 656 | else |
655 | } | 657 | amdgpu_fence_process(&adev->sdma.instance[1].ring); |
656 | |||
657 | static int si_dma_process_trap_irq_1(struct amdgpu_device *adev, | ||
658 | struct amdgpu_irq_src *source, | ||
659 | struct amdgpu_iv_entry *entry) | ||
660 | { | ||
661 | amdgpu_fence_process(&adev->sdma.instance[1].ring); | ||
662 | |||
663 | return 0; | 658 | return 0; |
664 | } | 659 | } |
665 | 660 | ||
@@ -786,11 +781,6 @@ static const struct amdgpu_irq_src_funcs si_dma_trap_irq_funcs = { | |||
786 | .process = si_dma_process_trap_irq, | 781 | .process = si_dma_process_trap_irq, |
787 | }; | 782 | }; |
788 | 783 | ||
789 | static const struct amdgpu_irq_src_funcs si_dma_trap_irq_funcs_1 = { | ||
790 | .set = si_dma_set_trap_irq_state, | ||
791 | .process = si_dma_process_trap_irq_1, | ||
792 | }; | ||
793 | |||
794 | static const struct amdgpu_irq_src_funcs si_dma_illegal_inst_irq_funcs = { | 784 | static const struct amdgpu_irq_src_funcs si_dma_illegal_inst_irq_funcs = { |
795 | .process = si_dma_process_illegal_inst_irq, | 785 | .process = si_dma_process_illegal_inst_irq, |
796 | }; | 786 | }; |
@@ -799,7 +789,6 @@ static void si_dma_set_irq_funcs(struct amdgpu_device *adev) | |||
799 | { | 789 | { |
800 | adev->sdma.trap_irq.num_types = AMDGPU_SDMA_IRQ_LAST; | 790 | adev->sdma.trap_irq.num_types = AMDGPU_SDMA_IRQ_LAST; |
801 | adev->sdma.trap_irq.funcs = &si_dma_trap_irq_funcs; | 791 | adev->sdma.trap_irq.funcs = &si_dma_trap_irq_funcs; |
802 | adev->sdma.trap_irq_1.funcs = &si_dma_trap_irq_funcs_1; | ||
803 | adev->sdma.illegal_inst_irq.funcs = &si_dma_illegal_inst_irq_funcs; | 792 | adev->sdma.illegal_inst_irq.funcs = &si_dma_illegal_inst_irq_funcs; |
804 | } | 793 | } |
805 | 794 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c index fb26039beeba..bf5e6a413dee 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c | |||
@@ -529,6 +529,8 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) | |||
529 | amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); | 529 | amdgpu_device_ip_block_add(adev, &psp_v11_0_ip_block); |
530 | else | 530 | else |
531 | amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block); | 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 | if (!amdgpu_sriov_vf(adev)) | 534 | if (!amdgpu_sriov_vf(adev)) |
533 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 535 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
534 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | 536 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
@@ -539,8 +541,6 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) | |||
539 | #else | 541 | #else |
540 | # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." | 542 | # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." |
541 | #endif | 543 | #endif |
542 | amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block); | ||
543 | amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); | ||
544 | if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev))) { | 544 | if (!(adev->asic_type == CHIP_VEGA20 && amdgpu_sriov_vf(adev))) { |
545 | amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block); | 545 | amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block); |
546 | amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block); | 546 | amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block); |
@@ -551,6 +551,8 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) | |||
551 | amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); | 551 | amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); |
552 | amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block); | 552 | amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block); |
553 | amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 556 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
555 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | 557 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
556 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 558 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
@@ -560,8 +562,6 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) | |||
560 | #else | 562 | #else |
561 | # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." | 563 | # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." |
562 | #endif | 564 | #endif |
563 | amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block); | ||
564 | amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); | ||
565 | amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block); | 565 | amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block); |
566 | break; | 566 | break; |
567 | default: | 567 | default: |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index 8ef4a5392112..7a5b40275e8e 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | |||
@@ -274,7 +274,7 @@ err: | |||
274 | */ | 274 | */ |
275 | static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring, | 275 | static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring, |
276 | uint32_t handle, | 276 | uint32_t handle, |
277 | bool direct, struct dma_fence **fence) | 277 | struct dma_fence **fence) |
278 | { | 278 | { |
279 | const unsigned ib_size_dw = 16; | 279 | const unsigned ib_size_dw = 16; |
280 | struct amdgpu_job *job; | 280 | struct amdgpu_job *job; |
@@ -310,11 +310,7 @@ static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring, | |||
310 | for (i = ib->length_dw; i < ib_size_dw; ++i) | 310 | for (i = ib->length_dw; i < ib_size_dw; ++i) |
311 | ib->ptr[i] = 0x0; | 311 | ib->ptr[i] = 0x0; |
312 | 312 | ||
313 | if (direct) | 313 | r = amdgpu_job_submit_direct(job, ring, &f); |
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); | ||
318 | if (r) | 314 | if (r) |
319 | goto err; | 315 | goto err; |
320 | 316 | ||
@@ -345,7 +341,7 @@ static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
345 | goto error; | 341 | goto error; |
346 | } | 342 | } |
347 | 343 | ||
348 | r = uvd_v6_0_enc_get_destroy_msg(ring, 1, true, &fence); | 344 | r = uvd_v6_0_enc_get_destroy_msg(ring, 1, &fence); |
349 | if (r) { | 345 | if (r) { |
350 | DRM_ERROR("amdgpu: failed to get destroy ib (%ld).\n", r); | 346 | DRM_ERROR("amdgpu: failed to get destroy ib (%ld).\n", r); |
351 | goto error; | 347 | goto error; |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c index a289f6a20b6b..58b39afcfb86 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | |||
@@ -280,8 +280,8 @@ err: | |||
280 | * | 280 | * |
281 | * Close up a stream for HW test or if userspace failed to do so | 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, | 283 | static int uvd_v7_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, |
284 | bool direct, struct dma_fence **fence) | 284 | struct dma_fence **fence) |
285 | { | 285 | { |
286 | const unsigned ib_size_dw = 16; | 286 | const unsigned ib_size_dw = 16; |
287 | struct amdgpu_job *job; | 287 | struct amdgpu_job *job; |
@@ -317,11 +317,7 @@ int uvd_v7_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, | |||
317 | for (i = ib->length_dw; i < ib_size_dw; ++i) | 317 | for (i = ib->length_dw; i < ib_size_dw; ++i) |
318 | ib->ptr[i] = 0x0; | 318 | ib->ptr[i] = 0x0; |
319 | 319 | ||
320 | if (direct) | 320 | r = amdgpu_job_submit_direct(job, ring, &f); |
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); | ||
325 | if (r) | 321 | if (r) |
326 | goto err; | 322 | goto err; |
327 | 323 | ||
@@ -352,7 +348,7 @@ static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
352 | goto error; | 348 | goto error; |
353 | } | 349 | } |
354 | 350 | ||
355 | r = uvd_v7_0_enc_get_destroy_msg(ring, 1, true, &fence); | 351 | r = uvd_v7_0_enc_get_destroy_msg(ring, 1, &fence); |
356 | if (r) { | 352 | if (r) { |
357 | DRM_ERROR("amdgpu: (%d)failed to get destroy ib (%ld).\n", ring->me, r); | 353 | DRM_ERROR("amdgpu: (%d)failed to get destroy ib (%ld).\n", ring->me, r); |
358 | goto error; | 354 | goto error; |
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c index 63d7f97e81b7..e9282415c24f 100644 --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | |||
@@ -278,6 +278,7 @@ static void vcn_v1_0_mc_resume_spg_mode(struct amdgpu_device *adev) | |||
278 | uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->vcn.fw->size + 4); | 278 | uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->vcn.fw->size + 4); |
279 | uint32_t offset; | 279 | uint32_t offset; |
280 | 280 | ||
281 | /* cache window 0: fw */ | ||
281 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { | 282 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { |
282 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, | 283 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, |
283 | (adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].tmr_mc_addr_lo)); | 284 | (adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].tmr_mc_addr_lo)); |
@@ -297,20 +298,21 @@ static void vcn_v1_0_mc_resume_spg_mode(struct amdgpu_device *adev) | |||
297 | 298 | ||
298 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE0, size); | 299 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE0, size); |
299 | 300 | ||
301 | /* cache window 1: stack */ | ||
300 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW, | 302 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW, |
301 | lower_32_bits(adev->vcn.gpu_addr + offset)); | 303 | lower_32_bits(adev->vcn.gpu_addr + offset)); |
302 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH, | 304 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH, |
303 | upper_32_bits(adev->vcn.gpu_addr + offset)); | 305 | upper_32_bits(adev->vcn.gpu_addr + offset)); |
304 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_OFFSET1, 0); | 306 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_OFFSET1, 0); |
305 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_VCN_HEAP_SIZE); | 307 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_VCN_STACK_SIZE); |
306 | 308 | ||
309 | /* cache window 2: context */ | ||
307 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW, | 310 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW, |
308 | lower_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE)); | 311 | lower_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_STACK_SIZE)); |
309 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH, | 312 | WREG32_SOC15(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH, |
310 | upper_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE)); | 313 | upper_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_STACK_SIZE)); |
311 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_OFFSET2, 0); | 314 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_OFFSET2, 0); |
312 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, | 315 | WREG32_SOC15(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, AMDGPU_VCN_CONTEXT_SIZE); |
313 | AMDGPU_VCN_STACK_SIZE + (AMDGPU_VCN_SESSION_SIZE * 40)); | ||
314 | 316 | ||
315 | WREG32_SOC15(UVD, 0, mmUVD_UDEC_ADDR_CONFIG, | 317 | WREG32_SOC15(UVD, 0, mmUVD_UDEC_ADDR_CONFIG, |
316 | adev->gfx.config.gb_addr_config); | 318 | adev->gfx.config.gb_addr_config); |
@@ -325,6 +327,7 @@ static void vcn_v1_0_mc_resume_dpg_mode(struct amdgpu_device *adev) | |||
325 | uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->vcn.fw->size + 4); | 327 | uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->vcn.fw->size + 4); |
326 | uint32_t offset; | 328 | uint32_t offset; |
327 | 329 | ||
330 | /* cache window 0: fw */ | ||
328 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { | 331 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { |
329 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, | 332 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE_64BIT_BAR_LOW, |
330 | (adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].tmr_mc_addr_lo), | 333 | (adev->firmware.ucode[AMDGPU_UCODE_ID_VCN].tmr_mc_addr_lo), |
@@ -347,24 +350,25 @@ static void vcn_v1_0_mc_resume_dpg_mode(struct amdgpu_device *adev) | |||
347 | 350 | ||
348 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE0, size, 0xFFFFFFFF, 0); | 351 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE0, size, 0xFFFFFFFF, 0); |
349 | 352 | ||
353 | /* cache window 1: stack */ | ||
350 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW, | 354 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_LOW, |
351 | lower_32_bits(adev->vcn.gpu_addr + offset), 0xFFFFFFFF, 0); | 355 | lower_32_bits(adev->vcn.gpu_addr + offset), 0xFFFFFFFF, 0); |
352 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH, | 356 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE1_64BIT_BAR_HIGH, |
353 | upper_32_bits(adev->vcn.gpu_addr + offset), 0xFFFFFFFF, 0); | 357 | upper_32_bits(adev->vcn.gpu_addr + offset), 0xFFFFFFFF, 0); |
354 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET1, 0, | 358 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET1, 0, |
355 | 0xFFFFFFFF, 0); | 359 | 0xFFFFFFFF, 0); |
356 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_VCN_HEAP_SIZE, | 360 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE1, AMDGPU_VCN_STACK_SIZE, |
357 | 0xFFFFFFFF, 0); | 361 | 0xFFFFFFFF, 0); |
358 | 362 | ||
363 | /* cache window 2: context */ | ||
359 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW, | 364 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_LOW, |
360 | lower_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE), | 365 | lower_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_STACK_SIZE), |
361 | 0xFFFFFFFF, 0); | 366 | 0xFFFFFFFF, 0); |
362 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH, | 367 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_LMI_VCPU_CACHE2_64BIT_BAR_HIGH, |
363 | upper_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_HEAP_SIZE), | 368 | upper_32_bits(adev->vcn.gpu_addr + offset + AMDGPU_VCN_STACK_SIZE), |
364 | 0xFFFFFFFF, 0); | 369 | 0xFFFFFFFF, 0); |
365 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET2, 0, 0xFFFFFFFF, 0); | 370 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_OFFSET2, 0, 0xFFFFFFFF, 0); |
366 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, | 371 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_VCPU_CACHE_SIZE2, AMDGPU_VCN_CONTEXT_SIZE, |
367 | AMDGPU_VCN_STACK_SIZE + (AMDGPU_VCN_SESSION_SIZE * 40), | ||
368 | 0xFFFFFFFF, 0); | 372 | 0xFFFFFFFF, 0); |
369 | 373 | ||
370 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_UDEC_ADDR_CONFIG, | 374 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_UDEC_ADDR_CONFIG, |
@@ -601,8 +605,6 @@ static void vcn_v1_0_clock_gating_dpg_mode(struct amdgpu_device *adev, uint8_t s | |||
601 | reg_data = 0 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; | 605 | reg_data = 0 << UVD_CGC_CTRL__DYN_CLOCK_MODE__SHIFT; |
602 | reg_data |= 1 << UVD_CGC_CTRL__CLK_GATE_DLY_TIMER__SHIFT; | 606 | reg_data |= 1 << UVD_CGC_CTRL__CLK_GATE_DLY_TIMER__SHIFT; |
603 | reg_data |= 4 << UVD_CGC_CTRL__CLK_OFF_DELAY__SHIFT; | 607 | reg_data |= 4 << UVD_CGC_CTRL__CLK_OFF_DELAY__SHIFT; |
604 | WREG32_SOC15_DPG_MODE(UVD, 0, mmUVD_CGC_CTRL, reg_data, 0xFFFFFFFF, sram_sel); | ||
605 | |||
606 | reg_data &= ~(UVD_CGC_CTRL__UDEC_RE_MODE_MASK | | 608 | reg_data &= ~(UVD_CGC_CTRL__UDEC_RE_MODE_MASK | |
607 | UVD_CGC_CTRL__UDEC_CM_MODE_MASK | | 609 | UVD_CGC_CTRL__UDEC_CM_MODE_MASK | |
608 | UVD_CGC_CTRL__UDEC_IT_MODE_MASK | | 610 | UVD_CGC_CTRL__UDEC_IT_MODE_MASK | |
@@ -812,12 +814,12 @@ static int vcn_v1_0_start_spg_mode(struct amdgpu_device *adev) | |||
812 | 814 | ||
813 | for (j = 0; j < 100; ++j) { | 815 | for (j = 0; j < 100; ++j) { |
814 | status = RREG32_SOC15(UVD, 0, mmUVD_STATUS); | 816 | status = RREG32_SOC15(UVD, 0, mmUVD_STATUS); |
815 | if (status & 2) | 817 | if (status & UVD_STATUS__IDLE) |
816 | break; | 818 | break; |
817 | mdelay(10); | 819 | mdelay(10); |
818 | } | 820 | } |
819 | r = 0; | 821 | r = 0; |
820 | if (status & 2) | 822 | if (status & UVD_STATUS__IDLE) |
821 | break; | 823 | break; |
822 | 824 | ||
823 | DRM_ERROR("VCN decode not responding, trying to reset the VCPU!!!\n"); | 825 | DRM_ERROR("VCN decode not responding, trying to reset the VCPU!!!\n"); |
@@ -875,6 +877,8 @@ static int vcn_v1_0_start_spg_mode(struct amdgpu_device *adev) | |||
875 | /* Initialize the ring buffer's read and write pointers */ | 877 | /* Initialize the ring buffer's read and write pointers */ |
876 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR, 0); | 878 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR, 0); |
877 | 879 | ||
880 | WREG32_SOC15(UVD, 0, mmUVD_SCRATCH2, 0); | ||
881 | |||
878 | ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR); | 882 | ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR); |
879 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, | 883 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, |
880 | lower_32_bits(ring->wptr)); | 884 | lower_32_bits(ring->wptr)); |
@@ -898,12 +902,13 @@ static int vcn_v1_0_start_spg_mode(struct amdgpu_device *adev) | |||
898 | 902 | ||
899 | ring = &adev->vcn.ring_jpeg; | 903 | ring = &adev->vcn.ring_jpeg; |
900 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_VMID, 0); | 904 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_VMID, 0); |
901 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, (0x00000001L | 0x00000002L)); | 905 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, UVD_JRBC_RB_CNTL__RB_NO_FETCH_MASK | |
906 | UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK); | ||
902 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_LOW, lower_32_bits(ring->gpu_addr)); | 907 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_LOW, lower_32_bits(ring->gpu_addr)); |
903 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_HIGH, upper_32_bits(ring->gpu_addr)); | 908 | WREG32_SOC15(UVD, 0, mmUVD_LMI_JRBC_RB_64BIT_BAR_HIGH, upper_32_bits(ring->gpu_addr)); |
904 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_RPTR, 0); | 909 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_RPTR, 0); |
905 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR, 0); | 910 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR, 0); |
906 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, 0x00000002L); | 911 | WREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_CNTL, UVD_JRBC_RB_CNTL__RB_RPTR_WR_EN_MASK); |
907 | 912 | ||
908 | /* initialize wptr */ | 913 | /* initialize wptr */ |
909 | ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR); | 914 | ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_JRBC_RB_WPTR); |
@@ -1051,6 +1056,8 @@ static int vcn_v1_0_start_dpg_mode(struct amdgpu_device *adev) | |||
1051 | /* Initialize the ring buffer's read and write pointers */ | 1056 | /* Initialize the ring buffer's read and write pointers */ |
1052 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR, 0); | 1057 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR, 0); |
1053 | 1058 | ||
1059 | WREG32_SOC15(UVD, 0, mmUVD_SCRATCH2, 0); | ||
1060 | |||
1054 | ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR); | 1061 | ring->wptr = RREG32_SOC15(UVD, 0, mmUVD_RBC_RB_RPTR); |
1055 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, | 1062 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, |
1056 | lower_32_bits(ring->wptr)); | 1063 | lower_32_bits(ring->wptr)); |
@@ -1120,8 +1127,9 @@ static int vcn_v1_0_stop_dpg_mode(struct amdgpu_device *adev) | |||
1120 | { | 1127 | { |
1121 | int ret_code; | 1128 | int ret_code; |
1122 | 1129 | ||
1123 | /* Wait for power status to be 1 */ | 1130 | /* Wait for power status to be UVD_POWER_STATUS__UVD_POWER_STATUS_TILES_OFF */ |
1124 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, 0x1, | 1131 | SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS, |
1132 | UVD_POWER_STATUS__UVD_POWER_STATUS_TILES_OFF, | ||
1125 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); | 1133 | UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); |
1126 | 1134 | ||
1127 | /* disable dynamic power gating mode */ | 1135 | /* disable dynamic power gating mode */ |
@@ -1147,7 +1155,7 @@ static bool vcn_v1_0_is_idle(void *handle) | |||
1147 | { | 1155 | { |
1148 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1156 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1149 | 1157 | ||
1150 | return (RREG32_SOC15(VCN, 0, mmUVD_STATUS) == 0x2); | 1158 | return (RREG32_SOC15(VCN, 0, mmUVD_STATUS) == UVD_STATUS__IDLE); |
1151 | } | 1159 | } |
1152 | 1160 | ||
1153 | static int vcn_v1_0_wait_for_idle(void *handle) | 1161 | static int vcn_v1_0_wait_for_idle(void *handle) |
@@ -1155,7 +1163,8 @@ static int vcn_v1_0_wait_for_idle(void *handle) | |||
1155 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1163 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1156 | int ret = 0; | 1164 | int ret = 0; |
1157 | 1165 | ||
1158 | SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_STATUS, 0x2, 0x2, ret); | 1166 | SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_STATUS, UVD_STATUS__IDLE, |
1167 | UVD_STATUS__IDLE, ret); | ||
1159 | 1168 | ||
1160 | return ret; | 1169 | return ret; |
1161 | } | 1170 | } |
@@ -1217,6 +1226,10 @@ static void vcn_v1_0_dec_ring_set_wptr(struct amdgpu_ring *ring) | |||
1217 | { | 1226 | { |
1218 | struct amdgpu_device *adev = ring->adev; | 1227 | struct amdgpu_device *adev = ring->adev; |
1219 | 1228 | ||
1229 | if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) | ||
1230 | WREG32_SOC15(UVD, 0, mmUVD_SCRATCH2, | ||
1231 | lower_32_bits(ring->wptr) | 0x80000000); | ||
1232 | |||
1220 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr)); | 1233 | WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR, lower_32_bits(ring->wptr)); |
1221 | } | 1234 | } |
1222 | 1235 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 88b57a5e9489..07880d35e9de 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c | |||
@@ -1596,16 +1596,18 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1596 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); | 1596 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1597 | amdgpu_device_ip_block_add(adev, &gmc_v7_4_ip_block); | 1597 | amdgpu_device_ip_block_add(adev, &gmc_v7_4_ip_block); |
1598 | amdgpu_device_ip_block_add(adev, &iceland_ih_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 1601 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
1600 | if (adev->enable_virtual_display) | 1602 | if (adev->enable_virtual_display) |
1601 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 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 | break; | 1604 | break; |
1605 | case CHIP_FIJI: | 1605 | case CHIP_FIJI: |
1606 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); | 1606 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1607 | amdgpu_device_ip_block_add(adev, &gmc_v8_5_ip_block); | 1607 | amdgpu_device_ip_block_add(adev, &gmc_v8_5_ip_block); |
1608 | amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 1611 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
1610 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | 1612 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
1611 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 1613 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
@@ -1615,8 +1617,6 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1615 | #endif | 1617 | #endif |
1616 | else | 1618 | else |
1617 | amdgpu_device_ip_block_add(adev, &dce_v10_1_ip_block); | 1619 | amdgpu_device_ip_block_add(adev, &dce_v10_1_ip_block); |
1618 | amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); | ||
1619 | amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); | ||
1620 | if (!amdgpu_sriov_vf(adev)) { | 1620 | if (!amdgpu_sriov_vf(adev)) { |
1621 | amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block); | 1621 | amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block); |
1622 | amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block); | 1622 | amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block); |
@@ -1626,6 +1626,8 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1626 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); | 1626 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1627 | amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); | 1627 | amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); |
1628 | amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 1631 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
1630 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | 1632 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
1631 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 1633 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
@@ -1635,8 +1637,6 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1635 | #endif | 1637 | #endif |
1636 | else | 1638 | else |
1637 | amdgpu_device_ip_block_add(adev, &dce_v10_0_ip_block); | 1639 | amdgpu_device_ip_block_add(adev, &dce_v10_0_ip_block); |
1638 | amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); | ||
1639 | amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); | ||
1640 | if (!amdgpu_sriov_vf(adev)) { | 1640 | if (!amdgpu_sriov_vf(adev)) { |
1641 | amdgpu_device_ip_block_add(adev, &uvd_v5_0_ip_block); | 1641 | amdgpu_device_ip_block_add(adev, &uvd_v5_0_ip_block); |
1642 | amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block); | 1642 | amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block); |
@@ -1649,6 +1649,8 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1649 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); | 1649 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1650 | amdgpu_device_ip_block_add(adev, &gmc_v8_1_ip_block); | 1650 | amdgpu_device_ip_block_add(adev, &gmc_v8_1_ip_block); |
1651 | amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 1654 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
1653 | if (adev->enable_virtual_display) | 1655 | if (adev->enable_virtual_display) |
1654 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 1656 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
@@ -1658,8 +1660,6 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1658 | #endif | 1660 | #endif |
1659 | else | 1661 | else |
1660 | amdgpu_device_ip_block_add(adev, &dce_v11_2_ip_block); | 1662 | amdgpu_device_ip_block_add(adev, &dce_v11_2_ip_block); |
1661 | amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); | ||
1662 | amdgpu_device_ip_block_add(adev, &sdma_v3_1_ip_block); | ||
1663 | amdgpu_device_ip_block_add(adev, &uvd_v6_3_ip_block); | 1663 | amdgpu_device_ip_block_add(adev, &uvd_v6_3_ip_block); |
1664 | amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block); | 1664 | amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block); |
1665 | break; | 1665 | break; |
@@ -1667,6 +1667,8 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1667 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); | 1667 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1668 | amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); | 1668 | amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); |
1669 | amdgpu_device_ip_block_add(adev, &cz_ih_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 1672 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
1671 | if (adev->enable_virtual_display) | 1673 | if (adev->enable_virtual_display) |
1672 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 1674 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
@@ -1676,8 +1678,6 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1676 | #endif | 1678 | #endif |
1677 | else | 1679 | else |
1678 | amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block); | 1680 | amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block); |
1679 | amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); | ||
1680 | amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); | ||
1681 | amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block); | 1681 | amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block); |
1682 | amdgpu_device_ip_block_add(adev, &vce_v3_1_ip_block); | 1682 | amdgpu_device_ip_block_add(adev, &vce_v3_1_ip_block); |
1683 | #if defined(CONFIG_DRM_AMD_ACP) | 1683 | #if defined(CONFIG_DRM_AMD_ACP) |
@@ -1688,6 +1688,8 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1688 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); | 1688 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1689 | amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); | 1689 | amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); |
1690 | amdgpu_device_ip_block_add(adev, &cz_ih_ip_block); | 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 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); | 1693 | amdgpu_device_ip_block_add(adev, &pp_smu_ip_block); |
1692 | if (adev->enable_virtual_display) | 1694 | if (adev->enable_virtual_display) |
1693 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); | 1695 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
@@ -1697,8 +1699,6 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1697 | #endif | 1699 | #endif |
1698 | else | 1700 | else |
1699 | amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block); | 1701 | amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block); |
1700 | amdgpu_device_ip_block_add(adev, &gfx_v8_1_ip_block); | ||
1701 | amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); | ||
1702 | amdgpu_device_ip_block_add(adev, &uvd_v6_2_ip_block); | 1702 | amdgpu_device_ip_block_add(adev, &uvd_v6_2_ip_block); |
1703 | amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block); | 1703 | amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block); |
1704 | #if defined(CONFIG_DRM_AMD_ACP) | 1704 | #if defined(CONFIG_DRM_AMD_ACP) |
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index d6af31ccf0ee..a3b933967171 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | |||
@@ -358,8 +358,8 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm, | |||
358 | struct queue *q, | 358 | struct queue *q, |
359 | struct qcm_process_device *qpd) | 359 | struct qcm_process_device *qpd) |
360 | { | 360 | { |
361 | int retval; | ||
362 | struct mqd_manager *mqd_mgr; | 361 | struct mqd_manager *mqd_mgr; |
362 | int retval; | ||
363 | 363 | ||
364 | mqd_mgr = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE); | 364 | mqd_mgr = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE); |
365 | if (!mqd_mgr) | 365 | if (!mqd_mgr) |
@@ -387,8 +387,12 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm, | |||
387 | if (!q->properties.is_active) | 387 | if (!q->properties.is_active) |
388 | return 0; | 388 | return 0; |
389 | 389 | ||
390 | retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, q->queue, | 390 | if (WARN(q->process->mm != current->mm, |
391 | &q->properties, q->process->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 | if (retval) | 396 | if (retval) |
393 | goto out_uninit_mqd; | 397 | goto out_uninit_mqd; |
394 | 398 | ||
@@ -545,9 +549,15 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q) | |||
545 | retval = map_queues_cpsch(dqm); | 549 | retval = map_queues_cpsch(dqm); |
546 | else if (q->properties.is_active && | 550 | else if (q->properties.is_active && |
547 | (q->properties.type == KFD_QUEUE_TYPE_COMPUTE || | 551 | (q->properties.type == KFD_QUEUE_TYPE_COMPUTE || |
548 | q->properties.type == KFD_QUEUE_TYPE_SDMA)) | 552 | q->properties.type == KFD_QUEUE_TYPE_SDMA)) { |
549 | retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, q->queue, | 553 | if (WARN(q->process->mm != current->mm, |
550 | &q->properties, q->process->mm); | 554 | "should only run in user thread")) |
555 | retval = -EFAULT; | ||
556 | else | ||
557 | retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, | ||
558 | q->pipe, q->queue, | ||
559 | &q->properties, current->mm); | ||
560 | } | ||
551 | 561 | ||
552 | out_unlock: | 562 | out_unlock: |
553 | dqm_unlock(dqm); | 563 | dqm_unlock(dqm); |
@@ -653,6 +663,7 @@ out: | |||
653 | static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, | 663 | static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, |
654 | struct qcm_process_device *qpd) | 664 | struct qcm_process_device *qpd) |
655 | { | 665 | { |
666 | struct mm_struct *mm = NULL; | ||
656 | struct queue *q; | 667 | struct queue *q; |
657 | struct mqd_manager *mqd_mgr; | 668 | struct mqd_manager *mqd_mgr; |
658 | struct kfd_process_device *pdd; | 669 | struct kfd_process_device *pdd; |
@@ -686,6 +697,15 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, | |||
686 | kfd_flush_tlb(pdd); | 697 | kfd_flush_tlb(pdd); |
687 | } | 698 | } |
688 | 699 | ||
700 | /* Take a safe reference to the mm_struct, which may otherwise | ||
701 | * disappear even while the kfd_process is still referenced. | ||
702 | */ | ||
703 | mm = get_task_mm(pdd->process->lead_thread); | ||
704 | if (!mm) { | ||
705 | retval = -EFAULT; | ||
706 | goto out; | ||
707 | } | ||
708 | |||
689 | /* activate all active queues on the qpd */ | 709 | /* activate all active queues on the qpd */ |
690 | list_for_each_entry(q, &qpd->queues_list, list) { | 710 | list_for_each_entry(q, &qpd->queues_list, list) { |
691 | if (!q->properties.is_evicted) | 711 | if (!q->properties.is_evicted) |
@@ -700,14 +720,15 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, | |||
700 | q->properties.is_evicted = false; | 720 | q->properties.is_evicted = false; |
701 | q->properties.is_active = true; | 721 | q->properties.is_active = true; |
702 | retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, | 722 | retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, |
703 | q->queue, &q->properties, | 723 | q->queue, &q->properties, mm); |
704 | q->process->mm); | ||
705 | if (retval) | 724 | if (retval) |
706 | goto out; | 725 | goto out; |
707 | dqm->queue_count++; | 726 | dqm->queue_count++; |
708 | } | 727 | } |
709 | qpd->evicted = 0; | 728 | qpd->evicted = 0; |
710 | out: | 729 | out: |
730 | if (mm) | ||
731 | mmput(mm); | ||
711 | dqm_unlock(dqm); | 732 | dqm_unlock(dqm); |
712 | return retval; | 733 | return retval; |
713 | } | 734 | } |
@@ -1343,9 +1364,6 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm, | |||
1343 | { | 1364 | { |
1344 | int retval; | 1365 | int retval; |
1345 | struct mqd_manager *mqd_mgr; | 1366 | struct mqd_manager *mqd_mgr; |
1346 | bool preempt_all_queues; | ||
1347 | |||
1348 | preempt_all_queues = false; | ||
1349 | 1367 | ||
1350 | retval = 0; | 1368 | retval = 0; |
1351 | 1369 | ||
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 6a2342d72742..e224f23e2215 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |||
@@ -4740,12 +4740,18 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) | |||
4740 | } | 4740 | } |
4741 | spin_unlock_irqrestore(&adev->ddev->event_lock, flags); | 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 | if (wait_for_vblank) | 4744 | if (wait_for_vblank) |
4747 | drm_atomic_helper_wait_for_flip_done(dev, state); | 4745 | drm_atomic_helper_wait_for_flip_done(dev, state); |
4748 | 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); | ||
4754 | |||
4749 | drm_atomic_helper_cleanup_planes(dev, state); | 4755 | drm_atomic_helper_cleanup_planes(dev, state); |
4750 | 4756 | ||
4751 | /* | 4757 | /* |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c index a910f01838ab..a212178f2edc 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c | |||
@@ -36,17 +36,13 @@ | |||
36 | * Private declarations. | 36 | * Private declarations. |
37 | *****************************************************************************/ | 37 | *****************************************************************************/ |
38 | 38 | ||
39 | struct handler_common_data { | 39 | struct amdgpu_dm_irq_handler_data { |
40 | struct list_head list; | 40 | struct list_head list; |
41 | interrupt_handler handler; | 41 | interrupt_handler handler; |
42 | void *handler_arg; | 42 | void *handler_arg; |
43 | 43 | ||
44 | /* DM which this handler belongs to */ | 44 | /* DM which this handler belongs to */ |
45 | struct amdgpu_display_manager *dm; | 45 | struct amdgpu_display_manager *dm; |
46 | }; | ||
47 | |||
48 | struct amdgpu_dm_irq_handler_data { | ||
49 | struct handler_common_data hcd; | ||
50 | /* DAL irq source which registered for this interrupt. */ | 46 | /* DAL irq source which registered for this interrupt. */ |
51 | enum dc_irq_source irq_source; | 47 | enum dc_irq_source irq_source; |
52 | }; | 48 | }; |
@@ -61,7 +57,7 @@ struct amdgpu_dm_irq_handler_data { | |||
61 | * Private functions. | 57 | * Private functions. |
62 | *****************************************************************************/ | 58 | *****************************************************************************/ |
63 | 59 | ||
64 | static void init_handler_common_data(struct handler_common_data *hcd, | 60 | static void init_handler_common_data(struct amdgpu_dm_irq_handler_data *hcd, |
65 | void (*ih)(void *), | 61 | void (*ih)(void *), |
66 | void *args, | 62 | void *args, |
67 | struct amdgpu_display_manager *dm) | 63 | struct amdgpu_display_manager *dm) |
@@ -85,11 +81,9 @@ static void dm_irq_work_func(struct work_struct *work) | |||
85 | struct amdgpu_dm_irq_handler_data *handler_data; | 81 | struct amdgpu_dm_irq_handler_data *handler_data; |
86 | 82 | ||
87 | list_for_each(entry, handler_list) { | 83 | list_for_each(entry, handler_list) { |
88 | handler_data = | 84 | handler_data = list_entry(entry, |
89 | list_entry( | 85 | struct amdgpu_dm_irq_handler_data, |
90 | entry, | 86 | list); |
91 | struct amdgpu_dm_irq_handler_data, | ||
92 | hcd.list); | ||
93 | 87 | ||
94 | DRM_DEBUG_KMS("DM_IRQ: work_func: for dal_src=%d\n", | 88 | DRM_DEBUG_KMS("DM_IRQ: work_func: for dal_src=%d\n", |
95 | handler_data->irq_source); | 89 | handler_data->irq_source); |
@@ -97,7 +91,7 @@ static void dm_irq_work_func(struct work_struct *work) | |||
97 | DRM_DEBUG_KMS("DM_IRQ: schedule_work: for dal_src=%d\n", | 91 | DRM_DEBUG_KMS("DM_IRQ: schedule_work: for dal_src=%d\n", |
98 | handler_data->irq_source); | 92 | handler_data->irq_source); |
99 | 93 | ||
100 | handler_data->hcd.handler(handler_data->hcd.handler_arg); | 94 | handler_data->handler(handler_data->handler_arg); |
101 | } | 95 | } |
102 | 96 | ||
103 | /* Call a DAL subcomponent which registered for interrupt notification | 97 | /* Call a DAL subcomponent which registered for interrupt notification |
@@ -137,11 +131,11 @@ static struct list_head *remove_irq_handler(struct amdgpu_device *adev, | |||
137 | list_for_each_safe(entry, tmp, hnd_list) { | 131 | list_for_each_safe(entry, tmp, hnd_list) { |
138 | 132 | ||
139 | handler = list_entry(entry, struct amdgpu_dm_irq_handler_data, | 133 | handler = list_entry(entry, struct amdgpu_dm_irq_handler_data, |
140 | hcd.list); | 134 | list); |
141 | 135 | ||
142 | if (ih == handler) { | 136 | if (ih == handler) { |
143 | /* Found our handler. Remove it from the list. */ | 137 | /* Found our handler. Remove it from the list. */ |
144 | list_del(&handler->hcd.list); | 138 | list_del(&handler->list); |
145 | handler_removed = true; | 139 | handler_removed = true; |
146 | break; | 140 | break; |
147 | } | 141 | } |
@@ -230,8 +224,7 @@ void *amdgpu_dm_irq_register_interrupt(struct amdgpu_device *adev, | |||
230 | 224 | ||
231 | memset(handler_data, 0, sizeof(*handler_data)); | 225 | memset(handler_data, 0, sizeof(*handler_data)); |
232 | 226 | ||
233 | init_handler_common_data(&handler_data->hcd, ih, handler_args, | 227 | init_handler_common_data(handler_data, ih, handler_args, &adev->dm); |
234 | &adev->dm); | ||
235 | 228 | ||
236 | irq_source = int_params->irq_source; | 229 | irq_source = int_params->irq_source; |
237 | 230 | ||
@@ -250,7 +243,7 @@ void *amdgpu_dm_irq_register_interrupt(struct amdgpu_device *adev, | |||
250 | break; | 243 | break; |
251 | } | 244 | } |
252 | 245 | ||
253 | list_add_tail(&handler_data->hcd.list, hnd_list); | 246 | list_add_tail(&handler_data->list, hnd_list); |
254 | 247 | ||
255 | DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags); | 248 | DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags); |
256 | 249 | ||
@@ -462,15 +455,13 @@ static void amdgpu_dm_irq_immediate_work(struct amdgpu_device *adev, | |||
462 | entry, | 455 | entry, |
463 | &adev->dm.irq_handler_list_high_tab[irq_source]) { | 456 | &adev->dm.irq_handler_list_high_tab[irq_source]) { |
464 | 457 | ||
465 | handler_data = | 458 | handler_data = list_entry(entry, |
466 | list_entry( | 459 | struct amdgpu_dm_irq_handler_data, |
467 | entry, | 460 | list); |
468 | struct amdgpu_dm_irq_handler_data, | ||
469 | hcd.list); | ||
470 | 461 | ||
471 | /* Call a subcomponent which registered for immediate | 462 | /* Call a subcomponent which registered for immediate |
472 | * interrupt notification */ | 463 | * interrupt notification */ |
473 | handler_data->hcd.handler(handler_data->hcd.handler_arg); | 464 | handler_data->handler(handler_data->handler_arg); |
474 | } | 465 | } |
475 | 466 | ||
476 | DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags); | 467 | DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags); |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 76fe5a9af3bf..7c491c91465f 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #define DC_LOGGER \ | 60 | #define DC_LOGGER \ |
61 | dc->ctx->logger | 61 | dc->ctx->logger |
62 | 62 | ||
63 | const static char DC_BUILD_ID[] = "production-build"; | ||
63 | 64 | ||
64 | /******************************************************************************* | 65 | /******************************************************************************* |
65 | * Private functions | 66 | * Private functions |
@@ -758,6 +759,8 @@ struct dc *dc_create(const struct dc_init_data *init_params) | |||
758 | 759 | ||
759 | dc->config = init_params->flags; | 760 | dc->config = init_params->flags; |
760 | 761 | ||
762 | dc->build_id = DC_BUILD_ID; | ||
763 | |||
761 | DC_LOG_DC("Display Core initialized\n"); | 764 | DC_LOG_DC("Display Core initialized\n"); |
762 | 765 | ||
763 | 766 | ||
@@ -1110,32 +1113,6 @@ static bool is_surface_in_context( | |||
1110 | return false; | 1113 | return false; |
1111 | } | 1114 | } |
1112 | 1115 | ||
1113 | static unsigned int pixel_format_to_bpp(enum surface_pixel_format format) | ||
1114 | { | ||
1115 | switch (format) { | ||
1116 | case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr: | ||
1117 | case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb: | ||
1118 | return 12; | ||
1119 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555: | ||
1120 | case SURFACE_PIXEL_FORMAT_GRPH_RGB565: | ||
1121 | case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr: | ||
1122 | case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb: | ||
1123 | return 16; | ||
1124 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888: | ||
1125 | case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888: | ||
1126 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010: | ||
1127 | case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010: | ||
1128 | return 32; | ||
1129 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616: | ||
1130 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F: | ||
1131 | case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F: | ||
1132 | return 64; | ||
1133 | default: | ||
1134 | ASSERT_CRITICAL(false); | ||
1135 | return -1; | ||
1136 | } | ||
1137 | } | ||
1138 | |||
1139 | static enum surface_update_type get_plane_info_update_type(const struct dc_surface_update *u) | 1116 | static enum surface_update_type get_plane_info_update_type(const struct dc_surface_update *u) |
1140 | { | 1117 | { |
1141 | union surface_update_flags *update_flags = &u->surface->update_flags; | 1118 | union surface_update_flags *update_flags = &u->surface->update_flags; |
@@ -1169,8 +1146,8 @@ static enum surface_update_type get_plane_info_update_type(const struct dc_surfa | |||
1169 | || u->plane_info->dcc.grph.meta_pitch != u->surface->dcc.grph.meta_pitch) | 1146 | || u->plane_info->dcc.grph.meta_pitch != u->surface->dcc.grph.meta_pitch) |
1170 | update_flags->bits.dcc_change = 1; | 1147 | update_flags->bits.dcc_change = 1; |
1171 | 1148 | ||
1172 | if (pixel_format_to_bpp(u->plane_info->format) != | 1149 | if (resource_pixel_format_to_bpp(u->plane_info->format) != |
1173 | pixel_format_to_bpp(u->surface->format)) | 1150 | resource_pixel_format_to_bpp(u->surface->format)) |
1174 | /* different bytes per element will require full bandwidth | 1151 | /* different bytes per element will require full bandwidth |
1175 | * and DML calculation | 1152 | * and DML calculation |
1176 | */ | 1153 | */ |
@@ -1859,3 +1836,16 @@ void dc_link_remove_remote_sink(struct dc_link *link, struct dc_sink *sink) | |||
1859 | } | 1836 | } |
1860 | } | 1837 | } |
1861 | } | 1838 | } |
1839 | |||
1840 | void get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info) | ||
1841 | { | ||
1842 | info->displayClock = (unsigned int)state->bw.dcn.clk.dispclk_khz; | ||
1843 | info->engineClock = (unsigned int)state->bw.dcn.clk.dcfclk_khz; | ||
1844 | info->memoryClock = (unsigned int)state->bw.dcn.clk.dramclk_khz; | ||
1845 | info->maxSupportedDppClock = (unsigned int)state->bw.dcn.clk.max_supported_dppclk_khz; | ||
1846 | info->dppClock = (unsigned int)state->bw.dcn.clk.dppclk_khz; | ||
1847 | info->socClock = (unsigned int)state->bw.dcn.clk.socclk_khz; | ||
1848 | info->dcfClockDeepSleep = (unsigned int)state->bw.dcn.clk.dcfclk_deep_sleep_khz; | ||
1849 | info->fClock = (unsigned int)state->bw.dcn.clk.fclk_khz; | ||
1850 | info->phyClock = (unsigned int)state->bw.dcn.clk.phyclk_khz; | ||
1851 | } \ No newline at end of file | ||
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index 2d6a4300bfa4..b6fe29b9fb65 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c | |||
@@ -1975,6 +1975,9 @@ static void calculate_phy_pix_clks(struct dc_stream_state *stream) | |||
1975 | else | 1975 | else |
1976 | stream->phy_pix_clk = | 1976 | stream->phy_pix_clk = |
1977 | stream->timing.pix_clk_khz; | 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 | enum dc_status resource_map_pool_resources( | 1983 | enum dc_status resource_map_pool_resources( |
@@ -2096,6 +2099,14 @@ enum dc_status dc_validate_global_state( | |||
2096 | if (pipe_ctx->stream != stream) | 2099 | if (pipe_ctx->stream != stream) |
2097 | continue; | 2100 | continue; |
2098 | 2101 | ||
2102 | if (dc->res_pool->funcs->get_default_swizzle_mode && | ||
2103 | pipe_ctx->plane_state && | ||
2104 | pipe_ctx->plane_state->tiling_info.gfx9.swizzle == DC_SW_UNKNOWN) { | ||
2105 | result = dc->res_pool->funcs->get_default_swizzle_mode(pipe_ctx->plane_state); | ||
2106 | if (result != DC_OK) | ||
2107 | return result; | ||
2108 | } | ||
2109 | |||
2099 | /* Switch to dp clock source only if there is | 2110 | /* Switch to dp clock source only if there is |
2100 | * no non dp stream that shares the same timing | 2111 | * no non dp stream that shares the same timing |
2101 | * with the dp stream. | 2112 | * with the dp stream. |
@@ -2885,3 +2896,32 @@ enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *pla | |||
2885 | 2896 | ||
2886 | return res; | 2897 | return res; |
2887 | } | 2898 | } |
2899 | |||
2900 | unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format) | ||
2901 | { | ||
2902 | switch (format) { | ||
2903 | case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS: | ||
2904 | return 8; | ||
2905 | case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr: | ||
2906 | case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb: | ||
2907 | return 12; | ||
2908 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555: | ||
2909 | case SURFACE_PIXEL_FORMAT_GRPH_RGB565: | ||
2910 | case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr: | ||
2911 | case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb: | ||
2912 | return 16; | ||
2913 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888: | ||
2914 | case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888: | ||
2915 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010: | ||
2916 | case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010: | ||
2917 | case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS: | ||
2918 | return 32; | ||
2919 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616: | ||
2920 | case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F: | ||
2921 | case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F: | ||
2922 | return 64; | ||
2923 | default: | ||
2924 | ASSERT_CRITICAL(false); | ||
2925 | return -1; | ||
2926 | } | ||
2927 | } | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 11ea2a226952..199527171100 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h | |||
@@ -38,13 +38,12 @@ | |||
38 | #include "inc/compressor.h" | 38 | #include "inc/compressor.h" |
39 | #include "dml/display_mode_lib.h" | 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 | #define MAX_SURFACES 3 | 43 | #define MAX_SURFACES 3 |
44 | #define MAX_STREAMS 6 | 44 | #define MAX_STREAMS 6 |
45 | #define MAX_SINKS_PER_LINK 4 | 45 | #define MAX_SINKS_PER_LINK 4 |
46 | 46 | ||
47 | |||
48 | /******************************************************************************* | 47 | /******************************************************************************* |
49 | * Display Core Interfaces | 48 | * Display Core Interfaces |
50 | ******************************************************************************/ | 49 | ******************************************************************************/ |
@@ -208,6 +207,7 @@ struct dc_clocks { | |||
208 | int dcfclk_deep_sleep_khz; | 207 | int dcfclk_deep_sleep_khz; |
209 | int fclk_khz; | 208 | int fclk_khz; |
210 | int phyclk_khz; | 209 | int phyclk_khz; |
210 | int dramclk_khz; | ||
211 | }; | 211 | }; |
212 | 212 | ||
213 | struct dc_debug_options { | 213 | struct dc_debug_options { |
@@ -315,6 +315,8 @@ struct dc { | |||
315 | struct compressor *fbc_compressor; | 315 | struct compressor *fbc_compressor; |
316 | 316 | ||
317 | struct dc_debug_data debug_data; | 317 | struct dc_debug_data debug_data; |
318 | |||
319 | const char *build_id; | ||
318 | }; | 320 | }; |
319 | 321 | ||
320 | enum frame_buffer_mode { | 322 | enum frame_buffer_mode { |
@@ -599,6 +601,8 @@ struct dc_validation_set { | |||
599 | 601 | ||
600 | enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state); | 602 | enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state); |
601 | 603 | ||
604 | void get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info); | ||
605 | |||
602 | enum dc_status dc_validate_global_state( | 606 | enum dc_status dc_validate_global_state( |
603 | struct dc *dc, | 607 | struct dc *dc, |
604 | struct dc_state *new_ctx); | 608 | struct dc_state *new_ctx); |
diff --git a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h index 57f57cf0fe2a..7825e4b5e97c 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h | |||
@@ -289,7 +289,8 @@ enum swizzle_mode_values { | |||
289 | DC_SW_VAR_S_X = 29, | 289 | DC_SW_VAR_S_X = 29, |
290 | DC_SW_VAR_D_X = 30, | 290 | DC_SW_VAR_D_X = 30, |
291 | DC_SW_VAR_R_X = 31, | 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 | union dc_tiling_info { | 296 | union dc_tiling_info { |
diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h b/drivers/gpu/drm/amd/display/dc/dc_types.h index 4fb62780a696..6e12d640d020 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_types.h | |||
@@ -659,4 +659,16 @@ enum i2c_mot_mode { | |||
659 | I2C_MOT_FALSE | 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 | #endif /* DC_TYPES_H_ */ | 674 | #endif /* DC_TYPES_H_ */ |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c index 3f5b2e6f7553..aaeb7faac0c4 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c | |||
@@ -312,7 +312,7 @@ static void process_channel_reply( | |||
312 | 312 | ||
313 | /* in case HPD is LOW, exit AUX transaction */ | 313 | /* in case HPD is LOW, exit AUX transaction */ |
314 | if ((sw_status & AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK)) { | 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 | return; | 316 | return; |
317 | } | 317 | } |
318 | 318 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c index d42afa081452..d89a097ba936 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c | |||
@@ -664,6 +664,11 @@ static void dce_update_clocks(struct dccg *dccg, | |||
664 | bool safe_to_lower) | 664 | bool safe_to_lower) |
665 | { | 665 | { |
666 | struct dm_pp_power_level_change_request level_change_req; | 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 | level_change_req.power_level = dce_get_required_clocks_state(dccg, new_clocks); | 673 | level_change_req.power_level = dce_get_required_clocks_state(dccg, new_clocks); |
669 | /* get max clock state from PPLIB */ | 674 | /* get max clock state from PPLIB */ |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c b/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c index 4942590e8b9c..366bc8c2c643 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c | |||
@@ -662,21 +662,10 @@ bool dce110_link_encoder_validate_dp_output( | |||
662 | const struct dce110_link_encoder *enc110, | 662 | const struct dce110_link_encoder *enc110, |
663 | const struct dc_crtc_timing *crtc_timing) | 663 | const struct dc_crtc_timing *crtc_timing) |
664 | { | 664 | { |
665 | /* default RGB only */ | 665 | if (crtc_timing->pixel_encoding == PIXEL_ENCODING_YCBCR420) |
666 | if (crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) | 666 | return false; |
667 | return true; | ||
668 | |||
669 | if (enc110->base.features.flags.bits.IS_YCBCR_CAPABLE) | ||
670 | return true; | ||
671 | |||
672 | /* for DCE 8.x or later DP Y-only feature, | ||
673 | * we need ASIC cap + FeatureSupportDPYonly, not support 666 */ | ||
674 | if (crtc_timing->flags.Y_ONLY && | ||
675 | enc110->base.features.flags.bits.IS_YCBCR_CAPABLE && | ||
676 | crtc_timing->display_color_depth != COLOR_DEPTH_666) | ||
677 | return true; | ||
678 | 667 | ||
679 | return false; | 668 | return true; |
680 | } | 669 | } |
681 | 670 | ||
682 | void dce110_link_encoder_construct( | 671 | void dce110_link_encoder_construct( |
diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c index b1cc38827f09..14754a87156c 100644 --- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | |||
@@ -551,8 +551,7 @@ static const struct encoder_feature_support link_enc_feature = { | |||
551 | .max_hdmi_deep_color = COLOR_DEPTH_121212, | 551 | .max_hdmi_deep_color = COLOR_DEPTH_121212, |
552 | .max_hdmi_pixel_clock = 300000, | 552 | .max_hdmi_pixel_clock = 300000, |
553 | .flags.bits.IS_HBR2_CAPABLE = true, | 553 | .flags.bits.IS_HBR2_CAPABLE = true, |
554 | .flags.bits.IS_TPS3_CAPABLE = true, | 554 | .flags.bits.IS_TPS3_CAPABLE = true |
555 | .flags.bits.IS_YCBCR_CAPABLE = true | ||
556 | }; | 555 | }; |
557 | 556 | ||
558 | struct link_encoder *dce100_link_encoder_create( | 557 | struct link_encoder *dce100_link_encoder_create( |
@@ -690,7 +689,9 @@ static void destruct(struct dce110_resource_pool *pool) | |||
690 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); | 689 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); |
691 | pool->base.timing_generators[i] = NULL; | 690 | pool->base.timing_generators[i] = NULL; |
692 | } | 691 | } |
692 | } | ||
693 | 693 | ||
694 | for (i = 0; i < pool->base.res_cap->num_ddc; i++) { | ||
694 | if (pool->base.engines[i] != NULL) | 695 | if (pool->base.engines[i] != NULL) |
695 | dce110_engine_destroy(&pool->base.engines[i]); | 696 | dce110_engine_destroy(&pool->base.engines[i]); |
696 | if (pool->base.hw_i2cs[i] != NULL) { | 697 | if (pool->base.hw_i2cs[i] != NULL) { |
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c index b44cc7042249..de190935f0a4 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | |||
@@ -570,8 +570,7 @@ static const struct encoder_feature_support link_enc_feature = { | |||
570 | .max_hdmi_deep_color = COLOR_DEPTH_121212, | 570 | .max_hdmi_deep_color = COLOR_DEPTH_121212, |
571 | .max_hdmi_pixel_clock = 594000, | 571 | .max_hdmi_pixel_clock = 594000, |
572 | .flags.bits.IS_HBR2_CAPABLE = true, | 572 | .flags.bits.IS_HBR2_CAPABLE = true, |
573 | .flags.bits.IS_TPS3_CAPABLE = true, | 573 | .flags.bits.IS_TPS3_CAPABLE = true |
574 | .flags.bits.IS_YCBCR_CAPABLE = true | ||
575 | }; | 574 | }; |
576 | 575 | ||
577 | static struct link_encoder *dce110_link_encoder_create( | 576 | static struct link_encoder *dce110_link_encoder_create( |
@@ -720,7 +719,9 @@ static void destruct(struct dce110_resource_pool *pool) | |||
720 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); | 719 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); |
721 | pool->base.timing_generators[i] = NULL; | 720 | pool->base.timing_generators[i] = NULL; |
722 | } | 721 | } |
722 | } | ||
723 | 723 | ||
724 | for (i = 0; i < pool->base.res_cap->num_ddc; i++) { | ||
724 | if (pool->base.engines[i] != NULL) | 725 | if (pool->base.engines[i] != NULL) |
725 | dce110_engine_destroy(&pool->base.engines[i]); | 726 | dce110_engine_destroy(&pool->base.engines[i]); |
726 | if (pool->base.hw_i2cs[i] != NULL) { | 727 | if (pool->base.hw_i2cs[i] != NULL) { |
diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c index 0f8332ea1160..3ce79c208ddf 100644 --- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c | |||
@@ -555,8 +555,7 @@ static const struct encoder_feature_support link_enc_feature = { | |||
555 | .flags.bits.IS_HBR2_CAPABLE = true, | 555 | .flags.bits.IS_HBR2_CAPABLE = true, |
556 | .flags.bits.IS_HBR3_CAPABLE = true, | 556 | .flags.bits.IS_HBR3_CAPABLE = true, |
557 | .flags.bits.IS_TPS3_CAPABLE = true, | 557 | .flags.bits.IS_TPS3_CAPABLE = true, |
558 | .flags.bits.IS_TPS4_CAPABLE = true, | 558 | .flags.bits.IS_TPS4_CAPABLE = true |
559 | .flags.bits.IS_YCBCR_CAPABLE = true | ||
560 | }; | 559 | }; |
561 | 560 | ||
562 | struct link_encoder *dce112_link_encoder_create( | 561 | struct link_encoder *dce112_link_encoder_create( |
@@ -694,9 +693,6 @@ static void destruct(struct dce110_resource_pool *pool) | |||
694 | if (pool->base.opps[i] != NULL) | 693 | if (pool->base.opps[i] != NULL) |
695 | dce110_opp_destroy(&pool->base.opps[i]); | 694 | dce110_opp_destroy(&pool->base.opps[i]); |
696 | 695 | ||
697 | if (pool->base.engines[i] != NULL) | ||
698 | dce110_engine_destroy(&pool->base.engines[i]); | ||
699 | |||
700 | if (pool->base.transforms[i] != NULL) | 696 | if (pool->base.transforms[i] != NULL) |
701 | dce112_transform_destroy(&pool->base.transforms[i]); | 697 | dce112_transform_destroy(&pool->base.transforms[i]); |
702 | 698 | ||
@@ -712,6 +708,11 @@ static void destruct(struct dce110_resource_pool *pool) | |||
712 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); | 708 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); |
713 | pool->base.timing_generators[i] = NULL; | 709 | pool->base.timing_generators[i] = NULL; |
714 | } | 710 | } |
711 | } | ||
712 | |||
713 | for (i = 0; i < pool->base.res_cap->num_ddc; i++) { | ||
714 | if (pool->base.engines[i] != NULL) | ||
715 | dce110_engine_destroy(&pool->base.engines[i]); | ||
715 | if (pool->base.hw_i2cs[i] != NULL) { | 716 | if (pool->base.hw_i2cs[i] != NULL) { |
716 | kfree(pool->base.hw_i2cs[i]); | 717 | kfree(pool->base.hw_i2cs[i]); |
717 | pool->base.hw_i2cs[i] = NULL; | 718 | pool->base.hw_i2cs[i] = NULL; |
diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c index 59055801af44..79ab5f9f9115 100644 --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | |||
@@ -533,7 +533,9 @@ static void destruct(struct dce110_resource_pool *pool) | |||
533 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); | 533 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); |
534 | pool->base.timing_generators[i] = NULL; | 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 | if (pool->base.engines[i] != NULL) | 539 | if (pool->base.engines[i] != NULL) |
538 | dce110_engine_destroy(&pool->base.engines[i]); | 540 | dce110_engine_destroy(&pool->base.engines[i]); |
539 | if (pool->base.hw_i2cs[i] != NULL) { | 541 | if (pool->base.hw_i2cs[i] != NULL) { |
@@ -609,7 +611,6 @@ static const struct encoder_feature_support link_enc_feature = { | |||
609 | .flags.bits.IS_HBR3_CAPABLE = true, | 611 | .flags.bits.IS_HBR3_CAPABLE = true, |
610 | .flags.bits.IS_TPS3_CAPABLE = true, | 612 | .flags.bits.IS_TPS3_CAPABLE = true, |
611 | .flags.bits.IS_TPS4_CAPABLE = true, | 613 | .flags.bits.IS_TPS4_CAPABLE = true, |
612 | .flags.bits.IS_YCBCR_CAPABLE = true | ||
613 | }; | 614 | }; |
614 | 615 | ||
615 | static struct link_encoder *dce120_link_encoder_create( | 616 | static struct link_encoder *dce120_link_encoder_create( |
diff --git a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c index 1dc590ccc5f9..d68f951f9869 100644 --- a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c | |||
@@ -650,8 +650,7 @@ static const struct encoder_feature_support link_enc_feature = { | |||
650 | .max_hdmi_deep_color = COLOR_DEPTH_121212, | 650 | .max_hdmi_deep_color = COLOR_DEPTH_121212, |
651 | .max_hdmi_pixel_clock = 297000, | 651 | .max_hdmi_pixel_clock = 297000, |
652 | .flags.bits.IS_HBR2_CAPABLE = true, | 652 | .flags.bits.IS_HBR2_CAPABLE = true, |
653 | .flags.bits.IS_TPS3_CAPABLE = true, | 653 | .flags.bits.IS_TPS3_CAPABLE = true |
654 | .flags.bits.IS_YCBCR_CAPABLE = true | ||
655 | }; | 654 | }; |
656 | 655 | ||
657 | struct link_encoder *dce80_link_encoder_create( | 656 | struct link_encoder *dce80_link_encoder_create( |
@@ -739,7 +738,9 @@ static void destruct(struct dce110_resource_pool *pool) | |||
739 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); | 738 | kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); |
740 | pool->base.timing_generators[i] = NULL; | 739 | pool->base.timing_generators[i] = NULL; |
741 | } | 740 | } |
741 | } | ||
742 | 742 | ||
743 | for (i = 0; i < pool->base.res_cap->num_ddc; i++) { | ||
743 | if (pool->base.engines[i] != NULL) | 744 | if (pool->base.engines[i] != NULL) |
744 | dce110_engine_destroy(&pool->base.engines[i]); | 745 | dce110_engine_destroy(&pool->base.engines[i]); |
745 | if (pool->base.hw_i2cs[i] != NULL) { | 746 | if (pool->base.hw_i2cs[i] != NULL) { |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c index 1ea91e153d3a..4254e7e1a509 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.c | |||
@@ -87,6 +87,23 @@ void hubbub1_wm_read_state(struct hubbub *hubbub, | |||
87 | s->dram_clk_chanage = REG_READ(DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_D); | 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 | bool hubbub1_verify_allow_pstate_change_high( | 107 | bool hubbub1_verify_allow_pstate_change_high( |
91 | struct hubbub *hubbub) | 108 | struct hubbub *hubbub) |
92 | { | 109 | { |
@@ -116,7 +133,43 @@ bool hubbub1_verify_allow_pstate_change_high( | |||
116 | forced_pstate_allow = false; | 133 | forced_pstate_allow = false; |
117 | } | 134 | } |
118 | 135 | ||
119 | /* RV1: | 136 | /* RV2: |
137 | * dchubbubdebugind, at: 0xB | ||
138 | * description | ||
139 | * 0: Pipe0 Plane0 Allow Pstate Change | ||
140 | * 1: Pipe0 Plane1 Allow Pstate Change | ||
141 | * 2: Pipe0 Cursor0 Allow Pstate Change | ||
142 | * 3: Pipe0 Cursor1 Allow Pstate Change | ||
143 | * 4: Pipe1 Plane0 Allow Pstate Change | ||
144 | * 5: Pipe1 Plane1 Allow Pstate Change | ||
145 | * 6: Pipe1 Cursor0 Allow Pstate Change | ||
146 | * 7: Pipe1 Cursor1 Allow Pstate Change | ||
147 | * 8: Pipe2 Plane0 Allow Pstate Change | ||
148 | * 9: Pipe2 Plane1 Allow Pstate Change | ||
149 | * 10: Pipe2 Cursor0 Allow Pstate Change | ||
150 | * 11: Pipe2 Cursor1 Allow Pstate Change | ||
151 | * 12: Pipe3 Plane0 Allow Pstate Change | ||
152 | * 13: Pipe3 Plane1 Allow Pstate Change | ||
153 | * 14: Pipe3 Cursor0 Allow Pstate Change | ||
154 | * 15: Pipe3 Cursor1 Allow Pstate Change | ||
155 | * 16: Pipe4 Plane0 Allow Pstate Change | ||
156 | * 17: Pipe4 Plane1 Allow Pstate Change | ||
157 | * 18: Pipe4 Cursor0 Allow Pstate Change | ||
158 | * 19: Pipe4 Cursor1 Allow Pstate Change | ||
159 | * 20: Pipe5 Plane0 Allow Pstate Change | ||
160 | * 21: Pipe5 Plane1 Allow Pstate Change | ||
161 | * 22: Pipe5 Cursor0 Allow Pstate Change | ||
162 | * 23: Pipe5 Cursor1 Allow Pstate Change | ||
163 | * 24: Pipe6 Plane0 Allow Pstate Change | ||
164 | * 25: Pipe6 Plane1 Allow Pstate Change | ||
165 | * 26: Pipe6 Cursor0 Allow Pstate Change | ||
166 | * 27: Pipe6 Cursor1 Allow Pstate Change | ||
167 | * 28: WB0 Allow Pstate Change | ||
168 | * 29: WB1 Allow Pstate Change | ||
169 | * 30: Arbiter's allow_pstate_change | ||
170 | * 31: SOC pstate change request" | ||
171 | * | ||
172 | * RV1: | ||
120 | * dchubbubdebugind, at: 0x7 | 173 | * dchubbubdebugind, at: 0x7 |
121 | * description "3-0: Pipe0 cursor0 QOS | 174 | * description "3-0: Pipe0 cursor0 QOS |
122 | * 7-4: Pipe1 cursor0 QOS | 175 | * 7-4: Pipe1 cursor0 QOS |
@@ -140,7 +193,6 @@ bool hubbub1_verify_allow_pstate_change_high( | |||
140 | * 31: SOC pstate change request | 193 | * 31: SOC pstate change request |
141 | */ | 194 | */ |
142 | 195 | ||
143 | |||
144 | REG_WRITE(DCHUBBUB_TEST_DEBUG_INDEX, hubbub->debug_test_index_pstate); | 196 | REG_WRITE(DCHUBBUB_TEST_DEBUG_INDEX, hubbub->debug_test_index_pstate); |
145 | 197 | ||
146 | for (i = 0; i < pstate_wait_timeout_us; i++) { | 198 | for (i = 0; i < pstate_wait_timeout_us; i++) { |
@@ -802,5 +854,9 @@ void hubbub1_construct(struct hubbub *hubbub, | |||
802 | hubbub->masks = hubbub_mask; | 854 | hubbub->masks = hubbub_mask; |
803 | 855 | ||
804 | hubbub->debug_test_index_pstate = 0x7; | 856 | hubbub->debug_test_index_pstate = 0x7; |
857 | #if defined(CONFIG_DRM_AMD_DC_DCN1_01) | ||
858 | if (ctx->dce_version == DCN_VERSION_1_01) | ||
859 | hubbub->debug_test_index_pstate = 0xB; | ||
860 | #endif | ||
805 | } | 861 | } |
806 | 862 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h index d6e596eef4c5..d0f03d152913 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubbub.h | |||
@@ -203,6 +203,10 @@ void hubbub1_program_watermarks( | |||
203 | unsigned int refclk_mhz, | 203 | unsigned int refclk_mhz, |
204 | bool safe_to_lower); | 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 | void hubbub1_toggle_watermark_change_req( | 210 | void hubbub1_toggle_watermark_change_req( |
207 | struct hubbub *hubbub); | 211 | struct hubbub *hubbub); |
208 | 212 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index a881ff5559ec..193184affefb 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | |||
@@ -997,7 +997,21 @@ static void dcn10_init_hw(struct dc *dc) | |||
997 | } else { | 997 | } else { |
998 | 998 | ||
999 | if (!dcb->funcs->is_accelerated_mode(dcb)) { | 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 | bios_golden_init(dc); | 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 | disable_vga(dc->hwseq); | 1015 | disable_vga(dc->hwseq); |
1002 | } | 1016 | } |
1003 | 1017 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.c index 6f675206a136..ba6a8686062f 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.c | |||
@@ -606,22 +606,10 @@ bool dcn10_link_encoder_validate_dp_output( | |||
606 | const struct dcn10_link_encoder *enc10, | 606 | const struct dcn10_link_encoder *enc10, |
607 | const struct dc_crtc_timing *crtc_timing) | 607 | const struct dc_crtc_timing *crtc_timing) |
608 | { | 608 | { |
609 | /* default RGB only */ | 609 | if (crtc_timing->pixel_encoding == PIXEL_ENCODING_YCBCR420) |
610 | if (crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) | 610 | return false; |
611 | return true; | ||
612 | |||
613 | if (enc10->base.features.flags.bits.IS_YCBCR_CAPABLE) | ||
614 | return true; | ||
615 | |||
616 | /* for DCE 8.x or later DP Y-only feature, | ||
617 | * we need ASIC cap + FeatureSupportDPYonly, not support 666 | ||
618 | */ | ||
619 | if (crtc_timing->flags.Y_ONLY && | ||
620 | enc10->base.features.flags.bits.IS_YCBCR_CAPABLE && | ||
621 | crtc_timing->display_color_depth != COLOR_DEPTH_666) | ||
622 | return true; | ||
623 | 611 | ||
624 | return false; | 612 | return true; |
625 | } | 613 | } |
626 | 614 | ||
627 | void dcn10_link_encoder_construct( | 615 | void dcn10_link_encoder_construct( |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c index 411f89218e01..54626682bab2 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c | |||
@@ -98,7 +98,6 @@ static uint32_t get_start_vline(struct timing_generator *optc, const struct dc_c | |||
98 | struct dc_crtc_timing patched_crtc_timing; | 98 | struct dc_crtc_timing patched_crtc_timing; |
99 | int vesa_sync_start; | 99 | int vesa_sync_start; |
100 | int asic_blank_end; | 100 | int asic_blank_end; |
101 | int interlace_factor; | ||
102 | int vertical_line_start; | 101 | int vertical_line_start; |
103 | 102 | ||
104 | patched_crtc_timing = *dc_crtc_timing; | 103 | patched_crtc_timing = *dc_crtc_timing; |
@@ -112,16 +111,13 @@ static uint32_t get_start_vline(struct timing_generator *optc, const struct dc_c | |||
112 | vesa_sync_start - | 111 | vesa_sync_start - |
113 | patched_crtc_timing.h_border_left; | 112 | patched_crtc_timing.h_border_left; |
114 | 113 | ||
115 | interlace_factor = patched_crtc_timing.flags.INTERLACE ? 2 : 1; | ||
116 | |||
117 | vesa_sync_start = patched_crtc_timing.v_addressable + | 114 | vesa_sync_start = patched_crtc_timing.v_addressable + |
118 | patched_crtc_timing.v_border_bottom + | 115 | patched_crtc_timing.v_border_bottom + |
119 | patched_crtc_timing.v_front_porch; | 116 | patched_crtc_timing.v_front_porch; |
120 | 117 | ||
121 | asic_blank_end = (patched_crtc_timing.v_total - | 118 | asic_blank_end = (patched_crtc_timing.v_total - |
122 | vesa_sync_start - | 119 | vesa_sync_start - |
123 | patched_crtc_timing.v_border_top) | 120 | patched_crtc_timing.v_border_top); |
124 | * interlace_factor; | ||
125 | 121 | ||
126 | vertical_line_start = asic_blank_end - optc->dlg_otg_param.vstartup_start + 1; | 122 | vertical_line_start = asic_blank_end - optc->dlg_otg_param.vstartup_start + 1; |
127 | if (vertical_line_start < 0) { | 123 | if (vertical_line_start < 0) { |
@@ -154,7 +150,7 @@ void optc1_program_vline_interrupt( | |||
154 | req_delta_lines--; | 150 | req_delta_lines--; |
155 | 151 | ||
156 | if (req_delta_lines > vsync_line) | 152 | if (req_delta_lines > vsync_line) |
157 | start_line = dc_crtc_timing->v_total - (req_delta_lines - vsync_line) - 1; | 153 | start_line = dc_crtc_timing->v_total - (req_delta_lines - vsync_line) + 2; |
158 | else | 154 | else |
159 | start_line = vsync_line - req_delta_lines; | 155 | start_line = vsync_line - req_delta_lines; |
160 | 156 | ||
@@ -186,7 +182,6 @@ void optc1_program_timing( | |||
186 | uint32_t v_sync_end; | 182 | uint32_t v_sync_end; |
187 | uint32_t v_init, v_fp2; | 183 | uint32_t v_init, v_fp2; |
188 | uint32_t h_sync_polarity, v_sync_polarity; | 184 | uint32_t h_sync_polarity, v_sync_polarity; |
189 | uint32_t interlace_factor; | ||
190 | uint32_t start_point = 0; | 185 | uint32_t start_point = 0; |
191 | uint32_t field_num = 0; | 186 | uint32_t field_num = 0; |
192 | uint32_t h_div_2; | 187 | uint32_t h_div_2; |
@@ -237,16 +232,8 @@ void optc1_program_timing( | |||
237 | REG_UPDATE(OTG_H_SYNC_A_CNTL, | 232 | REG_UPDATE(OTG_H_SYNC_A_CNTL, |
238 | OTG_H_SYNC_A_POL, h_sync_polarity); | 233 | OTG_H_SYNC_A_POL, h_sync_polarity); |
239 | 234 | ||
240 | /* Load vertical timing */ | 235 | v_total = patched_crtc_timing.v_total - 1; |
241 | 236 | ||
242 | /* CRTC_V_TOTAL = v_total - 1 */ | ||
243 | if (patched_crtc_timing.flags.INTERLACE) { | ||
244 | interlace_factor = 2; | ||
245 | v_total = 2 * patched_crtc_timing.v_total; | ||
246 | } else { | ||
247 | interlace_factor = 1; | ||
248 | v_total = patched_crtc_timing.v_total - 1; | ||
249 | } | ||
250 | REG_SET(OTG_V_TOTAL, 0, | 237 | REG_SET(OTG_V_TOTAL, 0, |
251 | OTG_V_TOTAL, v_total); | 238 | OTG_V_TOTAL, v_total); |
252 | 239 | ||
@@ -259,7 +246,7 @@ void optc1_program_timing( | |||
259 | OTG_V_TOTAL_MIN, v_total); | 246 | OTG_V_TOTAL_MIN, v_total); |
260 | 247 | ||
261 | /* v_sync_start = 0, v_sync_end = v_sync_width */ | 248 | /* v_sync_start = 0, v_sync_end = v_sync_width */ |
262 | v_sync_end = patched_crtc_timing.v_sync_width * interlace_factor; | 249 | v_sync_end = patched_crtc_timing.v_sync_width; |
263 | 250 | ||
264 | REG_UPDATE_2(OTG_V_SYNC_A, | 251 | REG_UPDATE_2(OTG_V_SYNC_A, |
265 | OTG_V_SYNC_A_START, 0, | 252 | OTG_V_SYNC_A_START, 0, |
@@ -271,15 +258,13 @@ void optc1_program_timing( | |||
271 | 258 | ||
272 | asic_blank_end = (patched_crtc_timing.v_total - | 259 | asic_blank_end = (patched_crtc_timing.v_total - |
273 | vesa_sync_start - | 260 | vesa_sync_start - |
274 | patched_crtc_timing.v_border_top) | 261 | patched_crtc_timing.v_border_top); |
275 | * interlace_factor; | ||
276 | 262 | ||
277 | /* v_blank_start = v_blank_end + v_active */ | 263 | /* v_blank_start = v_blank_end + v_active */ |
278 | asic_blank_start = asic_blank_end + | 264 | asic_blank_start = asic_blank_end + |
279 | (patched_crtc_timing.v_border_top + | 265 | (patched_crtc_timing.v_border_top + |
280 | patched_crtc_timing.v_addressable + | 266 | patched_crtc_timing.v_addressable + |
281 | patched_crtc_timing.v_border_bottom) | 267 | patched_crtc_timing.v_border_bottom); |
282 | * interlace_factor; | ||
283 | 268 | ||
284 | REG_UPDATE_2(OTG_V_BLANK_START_END, | 269 | REG_UPDATE_2(OTG_V_BLANK_START_END, |
285 | OTG_V_BLANK_START, asic_blank_start, | 270 | OTG_V_BLANK_START, asic_blank_start, |
@@ -301,7 +286,7 @@ void optc1_program_timing( | |||
301 | 0 : 1; | 286 | 0 : 1; |
302 | 287 | ||
303 | REG_UPDATE(OTG_V_SYNC_A_CNTL, | 288 | REG_UPDATE(OTG_V_SYNC_A_CNTL, |
304 | OTG_V_SYNC_A_POL, v_sync_polarity); | 289 | OTG_V_SYNC_A_POL, v_sync_polarity); |
305 | 290 | ||
306 | v_init = asic_blank_start; | 291 | v_init = asic_blank_start; |
307 | if (optc->dlg_otg_param.signal == SIGNAL_TYPE_DISPLAY_PORT || | 292 | if (optc->dlg_otg_param.signal == SIGNAL_TYPE_DISPLAY_PORT || |
@@ -532,7 +517,6 @@ bool optc1_validate_timing( | |||
532 | struct timing_generator *optc, | 517 | struct timing_generator *optc, |
533 | const struct dc_crtc_timing *timing) | 518 | const struct dc_crtc_timing *timing) |
534 | { | 519 | { |
535 | uint32_t interlace_factor; | ||
536 | uint32_t v_blank; | 520 | uint32_t v_blank; |
537 | uint32_t h_blank; | 521 | uint32_t h_blank; |
538 | uint32_t min_v_blank; | 522 | uint32_t min_v_blank; |
@@ -540,10 +524,8 @@ bool optc1_validate_timing( | |||
540 | 524 | ||
541 | ASSERT(timing != NULL); | 525 | ASSERT(timing != NULL); |
542 | 526 | ||
543 | interlace_factor = timing->flags.INTERLACE ? 2 : 1; | ||
544 | v_blank = (timing->v_total - timing->v_addressable - | 527 | v_blank = (timing->v_total - timing->v_addressable - |
545 | timing->v_border_top - timing->v_border_bottom) * | 528 | timing->v_border_top - timing->v_border_bottom); |
546 | interlace_factor; | ||
547 | 529 | ||
548 | h_blank = (timing->h_total - timing->h_addressable - | 530 | h_blank = (timing->h_total - timing->h_addressable - |
549 | timing->h_border_right - | 531 | timing->h_border_right - |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c index cb1b134b8fcb..a71453a15ae3 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | |||
@@ -507,6 +507,18 @@ static const struct resource_caps res_cap = { | |||
507 | .num_ddc = 4, | 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 | static const struct dc_debug_options debug_defaults_drv = { | 522 | static const struct dc_debug_options debug_defaults_drv = { |
511 | .sanity_checks = true, | 523 | .sanity_checks = true, |
512 | .disable_dmcu = true, | 524 | .disable_dmcu = true, |
@@ -711,8 +723,7 @@ static const struct encoder_feature_support link_enc_feature = { | |||
711 | .flags.bits.IS_HBR2_CAPABLE = true, | 723 | .flags.bits.IS_HBR2_CAPABLE = true, |
712 | .flags.bits.IS_HBR3_CAPABLE = true, | 724 | .flags.bits.IS_HBR3_CAPABLE = true, |
713 | .flags.bits.IS_TPS3_CAPABLE = true, | 725 | .flags.bits.IS_TPS3_CAPABLE = true, |
714 | .flags.bits.IS_TPS4_CAPABLE = true, | 726 | .flags.bits.IS_TPS4_CAPABLE = true |
715 | .flags.bits.IS_YCBCR_CAPABLE = true | ||
716 | }; | 727 | }; |
717 | 728 | ||
718 | struct link_encoder *dcn10_link_encoder_create( | 729 | struct link_encoder *dcn10_link_encoder_create( |
@@ -897,7 +908,9 @@ static void destruct(struct dcn10_resource_pool *pool) | |||
897 | kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i])); | 908 | kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i])); |
898 | pool->base.timing_generators[i] = NULL; | 909 | pool->base.timing_generators[i] = NULL; |
899 | } | 910 | } |
911 | } | ||
900 | 912 | ||
913 | for (i = 0; i < pool->base.res_cap->num_ddc; i++) { | ||
901 | if (pool->base.engines[i] != NULL) | 914 | if (pool->base.engines[i] != NULL) |
902 | pool->base.engines[i]->funcs->destroy_engine(&pool->base.engines[i]); | 915 | pool->base.engines[i]->funcs->destroy_engine(&pool->base.engines[i]); |
903 | if (pool->base.hw_i2cs[i] != NULL) { | 916 | if (pool->base.hw_i2cs[i] != NULL) { |
@@ -1119,6 +1132,24 @@ static enum dc_status dcn10_validate_plane(const struct dc_plane_state *plane_st | |||
1119 | return DC_OK; | 1132 | return DC_OK; |
1120 | } | 1133 | } |
1121 | 1134 | ||
1135 | static enum dc_status dcn10_get_default_swizzle_mode(struct dc_plane_state *plane_state) | ||
1136 | { | ||
1137 | enum dc_status result = DC_OK; | ||
1138 | |||
1139 | enum surface_pixel_format surf_pix_format = plane_state->format; | ||
1140 | unsigned int bpp = resource_pixel_format_to_bpp(surf_pix_format); | ||
1141 | |||
1142 | enum swizzle_mode_values swizzle = DC_SW_LINEAR; | ||
1143 | |||
1144 | if (bpp == 64) | ||
1145 | swizzle = DC_SW_64KB_D; | ||
1146 | else | ||
1147 | swizzle = DC_SW_64KB_S; | ||
1148 | |||
1149 | plane_state->tiling_info.gfx9.swizzle = swizzle; | ||
1150 | return result; | ||
1151 | } | ||
1152 | |||
1122 | static const struct dc_cap_funcs cap_funcs = { | 1153 | static const struct dc_cap_funcs cap_funcs = { |
1123 | .get_dcc_compression_cap = dcn10_get_dcc_compression_cap | 1154 | .get_dcc_compression_cap = dcn10_get_dcc_compression_cap |
1124 | }; | 1155 | }; |
@@ -1129,7 +1160,8 @@ static const struct resource_funcs dcn10_res_pool_funcs = { | |||
1129 | .validate_bandwidth = dcn_validate_bandwidth, | 1160 | .validate_bandwidth = dcn_validate_bandwidth, |
1130 | .acquire_idle_pipe_for_layer = dcn10_acquire_idle_pipe_for_layer, | 1161 | .acquire_idle_pipe_for_layer = dcn10_acquire_idle_pipe_for_layer, |
1131 | .validate_plane = dcn10_validate_plane, | 1162 | .validate_plane = dcn10_validate_plane, |
1132 | .add_stream_to_ctx = dcn10_add_stream_to_ctx | 1163 | .add_stream_to_ctx = dcn10_add_stream_to_ctx, |
1164 | .get_default_swizzle_mode = dcn10_get_default_swizzle_mode | ||
1133 | }; | 1165 | }; |
1134 | 1166 | ||
1135 | static uint32_t read_pipe_fuses(struct dc_context *ctx) | 1167 | static uint32_t read_pipe_fuses(struct dc_context *ctx) |
@@ -1152,7 +1184,12 @@ static bool construct( | |||
1152 | 1184 | ||
1153 | ctx->dc_bios->regs = &bios_regs; | 1185 | ctx->dc_bios->regs = &bios_regs; |
1154 | 1186 | ||
1155 | pool->base.res_cap = &res_cap; | 1187 | #if defined(CONFIG_DRM_AMD_DC_DCN1_01) |
1188 | if (ctx->dce_version == DCN_VERSION_1_01) | ||
1189 | pool->base.res_cap = &rv2_res_cap; | ||
1190 | else | ||
1191 | #endif | ||
1192 | pool->base.res_cap = &res_cap; | ||
1156 | pool->base.funcs = &dcn10_res_pool_funcs; | 1193 | pool->base.funcs = &dcn10_res_pool_funcs; |
1157 | 1194 | ||
1158 | /* | 1195 | /* |
diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c b/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c index 8eee8ace1259..59c3ed43d609 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c | |||
@@ -346,7 +346,7 @@ static void process_channel_reply( | |||
346 | 346 | ||
347 | /* in case HPD is LOW, exit AUX transaction */ | 347 | /* in case HPD is LOW, exit AUX transaction */ |
348 | if ((sw_status & AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK)) { | 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 | return; | 350 | return; |
351 | } | 351 | } |
352 | 352 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h index 831a1bdf622c..c1976c175b57 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h +++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h | |||
@@ -120,6 +120,9 @@ struct resource_funcs { | |||
120 | struct dc *dc, | 120 | struct dc *dc, |
121 | struct dc_state *new_ctx, | 121 | struct dc_state *new_ctx, |
122 | struct dc_stream_state *stream); | 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 | struct audio_support{ | 128 | struct audio_support{ |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h b/drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h index 58818920ed41..e28e9770e0a3 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h | |||
@@ -58,7 +58,6 @@ struct encoder_feature_support { | |||
58 | uint32_t IS_HBR3_CAPABLE:1; | 58 | uint32_t IS_HBR3_CAPABLE:1; |
59 | uint32_t IS_TPS3_CAPABLE:1; | 59 | uint32_t IS_TPS3_CAPABLE:1; |
60 | uint32_t IS_TPS4_CAPABLE:1; | 60 | uint32_t IS_TPS4_CAPABLE:1; |
61 | uint32_t IS_YCBCR_CAPABLE:1; | ||
62 | uint32_t HDMI_6GB_EN:1; | 61 | uint32_t HDMI_6GB_EN:1; |
63 | } bits; | 62 | } bits; |
64 | uint32_t raw; | 63 | uint32_t raw; |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/resource.h b/drivers/gpu/drm/amd/display/dc/inc/resource.h index 76d00c6dbca9..33b99e3ab10d 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/resource.h +++ b/drivers/gpu/drm/amd/display/dc/inc/resource.h | |||
@@ -172,4 +172,7 @@ void update_audio_usage( | |||
172 | const struct resource_pool *pool, | 172 | const struct resource_pool *pool, |
173 | struct audio *audio, | 173 | struct audio *audio, |
174 | bool acquired); | 174 | bool acquired); |
175 | |||
176 | unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format); | ||
177 | |||
175 | #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */ | 178 | #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */ |
diff --git a/drivers/gpu/drm/amd/display/include/signal_types.h b/drivers/gpu/drm/amd/display/include/signal_types.h index 03476b142d8e..f56d2891475f 100644 --- a/drivers/gpu/drm/amd/display/include/signal_types.h +++ b/drivers/gpu/drm/amd/display/include/signal_types.h | |||
@@ -102,4 +102,9 @@ static inline bool dc_is_audio_capable_signal(enum signal_type signal) | |||
102 | dc_is_hdmi_signal(signal)); | 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 | #endif | 110 | #endif |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_offset.h b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_offset.h index 4ce090db7ef7..529b37db274c 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_offset.h +++ b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_offset.h | |||
@@ -2449,6 +2449,8 @@ | |||
2449 | #define mmCP_ECC_FIRSTOCCURRENCE_RING2_BASE_IDX 0 | 2449 | #define mmCP_ECC_FIRSTOCCURRENCE_RING2_BASE_IDX 0 |
2450 | #define mmGB_EDC_MODE 0x107e | 2450 | #define mmGB_EDC_MODE 0x107e |
2451 | #define mmGB_EDC_MODE_BASE_IDX 0 | 2451 | #define mmGB_EDC_MODE_BASE_IDX 0 |
2452 | #define mmCP_DEBUG 0x107f | ||
2453 | #define mmCP_DEBUG_BASE_IDX 0 | ||
2452 | #define mmCP_CPF_DEBUG 0x1080 | 2454 | #define mmCP_CPF_DEBUG 0x1080 |
2453 | #define mmCP_PQ_WPTR_POLL_CNTL 0x1083 | 2455 | #define mmCP_PQ_WPTR_POLL_CNTL 0x1083 |
2454 | #define mmCP_PQ_WPTR_POLL_CNTL_BASE_IDX 0 | 2456 | #define mmCP_PQ_WPTR_POLL_CNTL_BASE_IDX 0 |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_offset.h b/drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_offset.h index efd2704d0f8f..0d6891095f62 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_offset.h +++ b/drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_offset.h | |||
@@ -175,4 +175,7 @@ | |||
175 | #define mmSMUSVI0_PLANE0_CURRENTVID_BASE_IDX 0 | 175 | #define mmSMUSVI0_PLANE0_CURRENTVID_BASE_IDX 0 |
176 | #define mmSMUSVI0_PLANE0_CURRENTVID 0x0013 | 176 | #define mmSMUSVI0_PLANE0_CURRENTVID 0x0013 |
177 | 177 | ||
178 | #define mmSMUSVI0_TEL_PLANE0_BASE_IDX 0 | ||
179 | #define mmSMUSVI0_TEL_PLANE0 0x0004 | ||
180 | |||
178 | #endif | 181 | #endif |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_sh_mask.h b/drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_sh_mask.h index 2487ab9621e9..b1d9d8be1119 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_sh_mask.h +++ b/drivers/gpu/drm/amd/include/asic_reg/smuio/smuio_9_0_sh_mask.h | |||
@@ -258,4 +258,7 @@ | |||
258 | #define SMUSVI0_PLANE0_CURRENTVID__CURRENT_SVI0_PLANE0_VID__SHIFT 0x18 | 258 | #define SMUSVI0_PLANE0_CURRENTVID__CURRENT_SVI0_PLANE0_VID__SHIFT 0x18 |
259 | #define SMUSVI0_PLANE0_CURRENTVID__CURRENT_SVI0_PLANE0_VID_MASK 0xFF000000L | 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 | #endif | 264 | #endif |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_offset.h b/drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_offset.h index 510ec3c70626..a9eb57a53e59 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_offset.h +++ b/drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_offset.h | |||
@@ -26,6 +26,18 @@ | |||
26 | #define mmCG_MULT_THERMAL_STATUS 0x005f | 26 | #define mmCG_MULT_THERMAL_STATUS 0x005f |
27 | #define mmCG_MULT_THERMAL_STATUS_BASE_IDX 0 | 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 | #define mmTHM_THERMAL_INT_ENA 0x000a | 41 | #define mmTHM_THERMAL_INT_ENA 0x000a |
30 | #define mmTHM_THERMAL_INT_ENA_BASE_IDX 0 | 42 | #define mmTHM_THERMAL_INT_ENA_BASE_IDX 0 |
31 | #define mmTHM_THERMAL_INT_CTRL 0x000b | 43 | #define mmTHM_THERMAL_INT_CTRL 0x000b |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_sh_mask.h b/drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_sh_mask.h index f69533fa6abf..d130d92aee19 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_sh_mask.h +++ b/drivers/gpu/drm/amd/include/asic_reg/thm/thm_11_0_2_sh_mask.h | |||
@@ -28,6 +28,16 @@ | |||
28 | #define CG_MULT_THERMAL_STATUS__CTF_TEMP__SHIFT 0x9 | 28 | #define CG_MULT_THERMAL_STATUS__CTF_TEMP__SHIFT 0x9 |
29 | #define CG_MULT_THERMAL_STATUS__ASIC_MAX_TEMP_MASK 0x000001FFL | 29 | #define CG_MULT_THERMAL_STATUS__ASIC_MAX_TEMP_MASK 0x000001FFL |
30 | #define CG_MULT_THERMAL_STATUS__CTF_TEMP_MASK 0x0003FE00L | 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 | //THM_THERMAL_INT_ENA | 42 | //THM_THERMAL_INT_ENA |
33 | #define THM_THERMAL_INT_ENA__THERM_INTH_SET__SHIFT 0x0 | 43 | #define THM_THERMAL_INT_ENA__THERM_INTH_SET__SHIFT 0x0 |
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h index bd7404532029..980e696989b1 100644 --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h | |||
@@ -114,6 +114,8 @@ enum amd_pp_sensors { | |||
114 | AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK, | 114 | AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK, |
115 | AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK, | 115 | AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK, |
116 | AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK, | 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 | enum amd_pp_task { | 121 | enum amd_pp_task { |
@@ -228,6 +230,7 @@ struct amd_pm_funcs { | |||
228 | enum amd_dpm_forced_level (*get_performance_level)(void *handle); | 230 | enum amd_dpm_forced_level (*get_performance_level)(void *handle); |
229 | enum amd_pm_state_type (*get_current_power_state)(void *handle); | 231 | enum amd_pm_state_type (*get_current_power_state)(void *handle); |
230 | int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm); | 232 | int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm); |
233 | int (*set_fan_speed_rpm)(void *handle, uint32_t rpm); | ||
231 | int (*get_pp_num_states)(void *handle, struct pp_states_info *data); | 234 | int (*get_pp_num_states)(void *handle, struct pp_states_info *data); |
232 | int (*get_pp_table)(void *handle, char **table); | 235 | int (*get_pp_table)(void *handle, char **table); |
233 | int (*set_pp_table)(void *handle, const char *buf, size_t size); | 236 | int (*set_pp_table)(void *handle, const char *buf, size_t size); |
@@ -272,6 +275,7 @@ struct amd_pm_funcs { | |||
272 | int (*get_display_mode_validation_clocks)(void *handle, | 275 | int (*get_display_mode_validation_clocks)(void *handle, |
273 | struct amd_pp_simple_clock_info *clocks); | 276 | struct amd_pp_simple_clock_info *clocks); |
274 | int (*notify_smu_enable_pwe)(void *handle); | 277 | int (*notify_smu_enable_pwe)(void *handle); |
278 | int (*enable_mgpu_fan_boost)(void *handle); | ||
275 | }; | 279 | }; |
276 | 280 | ||
277 | #endif | 281 | #endif |
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c index da4ebff5b74d..75b56ae032ce 100644 --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c | |||
@@ -109,11 +109,8 @@ static int pp_sw_fini(void *handle) | |||
109 | 109 | ||
110 | hwmgr_sw_fini(hwmgr); | 110 | hwmgr_sw_fini(hwmgr); |
111 | 111 | ||
112 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { | 112 | release_firmware(adev->pm.fw); |
113 | release_firmware(adev->pm.fw); | 113 | adev->pm.fw = NULL; |
114 | adev->pm.fw = NULL; | ||
115 | amdgpu_ucode_fini_bo(adev); | ||
116 | } | ||
117 | 114 | ||
118 | return 0; | 115 | return 0; |
119 | } | 116 | } |
@@ -124,9 +121,6 @@ static int pp_hw_init(void *handle) | |||
124 | struct amdgpu_device *adev = handle; | 121 | struct amdgpu_device *adev = handle; |
125 | struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; | 122 | struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; |
126 | 123 | ||
127 | if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) | ||
128 | amdgpu_ucode_init_bo(adev); | ||
129 | |||
130 | ret = hwmgr_hw_init(hwmgr); | 124 | ret = hwmgr_hw_init(hwmgr); |
131 | 125 | ||
132 | if (ret) | 126 | if (ret) |
@@ -273,8 +267,23 @@ const struct amdgpu_ip_block_version pp_smu_ip_block = | |||
273 | .funcs = &pp_ip_funcs, | 267 | .funcs = &pp_ip_funcs, |
274 | }; | 268 | }; |
275 | 269 | ||
270 | /* This interface only be supported On Vi, | ||
271 | * because only smu7/8 can help to load gfx/sdma fw, | ||
272 | * smu need to be enabled before load other ip's fw. | ||
273 | * so call start smu to load smu7 fw and other ip's fw | ||
274 | */ | ||
276 | static int pp_dpm_load_fw(void *handle) | 275 | static int pp_dpm_load_fw(void *handle) |
277 | { | 276 | { |
277 | struct pp_hwmgr *hwmgr = handle; | ||
278 | |||
279 | if (!hwmgr || !hwmgr->smumgr_funcs || !hwmgr->smumgr_funcs->start_smu) | ||
280 | return -EINVAL; | ||
281 | |||
282 | if (hwmgr->smumgr_funcs->start_smu(hwmgr)) { | ||
283 | pr_err("fw load failed\n"); | ||
284 | return -EINVAL; | ||
285 | } | ||
286 | |||
278 | return 0; | 287 | return 0; |
279 | } | 288 | } |
280 | 289 | ||
@@ -576,6 +585,24 @@ static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm) | |||
576 | return ret; | 585 | return ret; |
577 | } | 586 | } |
578 | 587 | ||
588 | static int pp_dpm_set_fan_speed_rpm(void *handle, uint32_t rpm) | ||
589 | { | ||
590 | struct pp_hwmgr *hwmgr = handle; | ||
591 | int ret = 0; | ||
592 | |||
593 | if (!hwmgr || !hwmgr->pm_en) | ||
594 | return -EINVAL; | ||
595 | |||
596 | if (hwmgr->hwmgr_func->set_fan_speed_rpm == NULL) { | ||
597 | pr_info("%s was not implemented.\n", __func__); | ||
598 | return 0; | ||
599 | } | ||
600 | mutex_lock(&hwmgr->smu_lock); | ||
601 | ret = hwmgr->hwmgr_func->set_fan_speed_rpm(hwmgr, rpm); | ||
602 | mutex_unlock(&hwmgr->smu_lock); | ||
603 | return ret; | ||
604 | } | ||
605 | |||
579 | static int pp_dpm_get_pp_num_states(void *handle, | 606 | static int pp_dpm_get_pp_num_states(void *handle, |
580 | struct pp_states_info *data) | 607 | struct pp_states_info *data) |
581 | { | 608 | { |
@@ -813,6 +840,12 @@ static int pp_dpm_read_sensor(void *handle, int idx, | |||
813 | case AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK: | 840 | case AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK: |
814 | *((uint32_t *)value) = hwmgr->pstate_mclk; | 841 | *((uint32_t *)value) = hwmgr->pstate_mclk; |
815 | return 0; | 842 | return 0; |
843 | case AMDGPU_PP_SENSOR_MIN_FAN_RPM: | ||
844 | *((uint32_t *)value) = hwmgr->thermal_controller.fanInfo.ulMinRPM; | ||
845 | return 0; | ||
846 | case AMDGPU_PP_SENSOR_MAX_FAN_RPM: | ||
847 | *((uint32_t *)value) = hwmgr->thermal_controller.fanInfo.ulMaxRPM; | ||
848 | return 0; | ||
816 | default: | 849 | default: |
817 | mutex_lock(&hwmgr->smu_lock); | 850 | mutex_lock(&hwmgr->smu_lock); |
818 | ret = hwmgr->hwmgr_func->read_sensor(hwmgr, idx, value, size); | 851 | ret = hwmgr->hwmgr_func->read_sensor(hwmgr, idx, value, size); |
@@ -1196,6 +1229,21 @@ static void pp_dpm_powergate_acp(void *handle, bool gate) | |||
1196 | hwmgr->hwmgr_func->powergate_acp(hwmgr, gate); | 1229 | hwmgr->hwmgr_func->powergate_acp(hwmgr, gate); |
1197 | } | 1230 | } |
1198 | 1231 | ||
1232 | static void pp_dpm_powergate_sdma(void *handle, bool gate) | ||
1233 | { | ||
1234 | struct pp_hwmgr *hwmgr = handle; | ||
1235 | |||
1236 | if (!hwmgr) | ||
1237 | return; | ||
1238 | |||
1239 | if (hwmgr->hwmgr_func->powergate_sdma == NULL) { | ||
1240 | pr_info("%s was not implemented.\n", __func__); | ||
1241 | return; | ||
1242 | } | ||
1243 | |||
1244 | hwmgr->hwmgr_func->powergate_sdma(hwmgr, gate); | ||
1245 | } | ||
1246 | |||
1199 | static int pp_set_powergating_by_smu(void *handle, | 1247 | static int pp_set_powergating_by_smu(void *handle, |
1200 | uint32_t block_type, bool gate) | 1248 | uint32_t block_type, bool gate) |
1201 | { | 1249 | { |
@@ -1218,6 +1266,9 @@ static int pp_set_powergating_by_smu(void *handle, | |||
1218 | case AMD_IP_BLOCK_TYPE_ACP: | 1266 | case AMD_IP_BLOCK_TYPE_ACP: |
1219 | pp_dpm_powergate_acp(handle, gate); | 1267 | pp_dpm_powergate_acp(handle, gate); |
1220 | break; | 1268 | break; |
1269 | case AMD_IP_BLOCK_TYPE_SDMA: | ||
1270 | pp_dpm_powergate_sdma(handle, gate); | ||
1271 | break; | ||
1221 | default: | 1272 | default: |
1222 | break; | 1273 | break; |
1223 | } | 1274 | } |
@@ -1243,6 +1294,24 @@ static int pp_notify_smu_enable_pwe(void *handle) | |||
1243 | return 0; | 1294 | return 0; |
1244 | } | 1295 | } |
1245 | 1296 | ||
1297 | static int pp_enable_mgpu_fan_boost(void *handle) | ||
1298 | { | ||
1299 | struct pp_hwmgr *hwmgr = handle; | ||
1300 | |||
1301 | if (!hwmgr || !hwmgr->pm_en) | ||
1302 | return -EINVAL; | ||
1303 | |||
1304 | if (hwmgr->hwmgr_func->enable_mgpu_fan_boost == NULL) { | ||
1305 | return 0; | ||
1306 | } | ||
1307 | |||
1308 | mutex_lock(&hwmgr->smu_lock); | ||
1309 | hwmgr->hwmgr_func->enable_mgpu_fan_boost(hwmgr); | ||
1310 | mutex_unlock(&hwmgr->smu_lock); | ||
1311 | |||
1312 | return 0; | ||
1313 | } | ||
1314 | |||
1246 | static const struct amd_pm_funcs pp_dpm_funcs = { | 1315 | static const struct amd_pm_funcs pp_dpm_funcs = { |
1247 | .load_firmware = pp_dpm_load_fw, | 1316 | .load_firmware = pp_dpm_load_fw, |
1248 | .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete, | 1317 | .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete, |
@@ -1255,6 +1324,7 @@ static const struct amd_pm_funcs pp_dpm_funcs = { | |||
1255 | .set_fan_speed_percent = pp_dpm_set_fan_speed_percent, | 1324 | .set_fan_speed_percent = pp_dpm_set_fan_speed_percent, |
1256 | .get_fan_speed_percent = pp_dpm_get_fan_speed_percent, | 1325 | .get_fan_speed_percent = pp_dpm_get_fan_speed_percent, |
1257 | .get_fan_speed_rpm = pp_dpm_get_fan_speed_rpm, | 1326 | .get_fan_speed_rpm = pp_dpm_get_fan_speed_rpm, |
1327 | .set_fan_speed_rpm = pp_dpm_set_fan_speed_rpm, | ||
1258 | .get_pp_num_states = pp_dpm_get_pp_num_states, | 1328 | .get_pp_num_states = pp_dpm_get_pp_num_states, |
1259 | .get_pp_table = pp_dpm_get_pp_table, | 1329 | .get_pp_table = pp_dpm_get_pp_table, |
1260 | .set_pp_table = pp_dpm_set_pp_table, | 1330 | .set_pp_table = pp_dpm_set_pp_table, |
@@ -1287,4 +1357,5 @@ static const struct amd_pm_funcs pp_dpm_funcs = { | |||
1287 | .display_clock_voltage_request = pp_display_clock_voltage_request, | 1357 | .display_clock_voltage_request = pp_display_clock_voltage_request, |
1288 | .get_display_mode_validation_clocks = pp_get_display_mode_validation_clocks, | 1358 | .get_display_mode_validation_clocks = pp_get_display_mode_validation_clocks, |
1289 | .notify_smu_enable_pwe = pp_notify_smu_enable_pwe, | 1359 | .notify_smu_enable_pwe = pp_notify_smu_enable_pwe, |
1360 | .enable_mgpu_fan_boost = pp_enable_mgpu_fan_boost, | ||
1290 | }; | 1361 | }; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c index 7500a3e61dba..47ac92369739 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | |||
@@ -89,7 +89,6 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr) | |||
89 | hwmgr_init_default_caps(hwmgr); | 89 | hwmgr_init_default_caps(hwmgr); |
90 | hwmgr_set_user_specify_caps(hwmgr); | 90 | hwmgr_set_user_specify_caps(hwmgr); |
91 | hwmgr->fan_ctrl_is_in_default_mode = true; | 91 | hwmgr->fan_ctrl_is_in_default_mode = true; |
92 | hwmgr->reload_fw = 1; | ||
93 | hwmgr_init_workload_prority(hwmgr); | 92 | hwmgr_init_workload_prority(hwmgr); |
94 | 93 | ||
95 | switch (hwmgr->chip_family) { | 94 | switch (hwmgr->chip_family) { |
@@ -209,17 +208,6 @@ int hwmgr_hw_init(struct pp_hwmgr *hwmgr) | |||
209 | { | 208 | { |
210 | int ret = 0; | 209 | int ret = 0; |
211 | 210 | ||
212 | if (!hwmgr || !hwmgr->smumgr_funcs) | ||
213 | return -EINVAL; | ||
214 | |||
215 | if (hwmgr->smumgr_funcs->start_smu) { | ||
216 | ret = hwmgr->smumgr_funcs->start_smu(hwmgr); | ||
217 | if (ret) { | ||
218 | pr_err("smc start failed\n"); | ||
219 | return -EINVAL; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | if (!hwmgr->pm_en) | 211 | if (!hwmgr->pm_en) |
224 | return 0; | 212 | return 0; |
225 | 213 | ||
@@ -320,13 +308,6 @@ int hwmgr_resume(struct pp_hwmgr *hwmgr) | |||
320 | if (!hwmgr) | 308 | if (!hwmgr) |
321 | return -EINVAL; | 309 | return -EINVAL; |
322 | 310 | ||
323 | if (hwmgr->smumgr_funcs && hwmgr->smumgr_funcs->start_smu) { | ||
324 | if (hwmgr->smumgr_funcs->start_smu(hwmgr)) { | ||
325 | pr_err("smc start failed\n"); | ||
326 | return -EINVAL; | ||
327 | } | ||
328 | } | ||
329 | |||
330 | if (!hwmgr->pm_en) | 311 | if (!hwmgr->pm_en) |
331 | return 0; | 312 | return 0; |
332 | 313 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c index 5d1dae25a466..dd18cb710391 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | |||
@@ -1153,6 +1153,14 @@ static int smu10_powergate_mmhub(struct pp_hwmgr *hwmgr) | |||
1153 | return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_PowerGateMmHub); | 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 | static void smu10_powergate_vcn(struct pp_hwmgr *hwmgr, bool bgate) | 1164 | static void smu10_powergate_vcn(struct pp_hwmgr *hwmgr, bool bgate) |
1157 | { | 1165 | { |
1158 | if (bgate) { | 1166 | if (bgate) { |
@@ -1208,6 +1216,7 @@ static const struct pp_hwmgr_func smu10_hwmgr_funcs = { | |||
1208 | .smus_notify_pwe = smu10_smus_notify_pwe, | 1216 | .smus_notify_pwe = smu10_smus_notify_pwe, |
1209 | .display_clock_voltage_request = smu10_display_clock_voltage_request, | 1217 | .display_clock_voltage_request = smu10_display_clock_voltage_request, |
1210 | .powergate_gfx = smu10_gfx_off_control, | 1218 | .powergate_gfx = smu10_gfx_off_control, |
1219 | .powergate_sdma = smu10_powergate_sdma, | ||
1211 | }; | 1220 | }; |
1212 | 1221 | ||
1213 | int smu10_init_function_pointers(struct pp_hwmgr *hwmgr) | 1222 | int smu10_init_function_pointers(struct pp_hwmgr *hwmgr) |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c index 44527755e747..5bdc0df5a9f4 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c | |||
@@ -260,6 +260,7 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed) | |||
260 | if (hwmgr->thermal_controller.fanInfo.bNoFan || | 260 | if (hwmgr->thermal_controller.fanInfo.bNoFan || |
261 | (hwmgr->thermal_controller.fanInfo. | 261 | (hwmgr->thermal_controller.fanInfo. |
262 | ucTachometerPulsesPerRevolution == 0) || | 262 | ucTachometerPulsesPerRevolution == 0) || |
263 | speed == 0 || | ||
263 | (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || | 264 | (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || |
264 | (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) | 265 | (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) |
265 | return 0; | 266 | return 0; |
@@ -272,7 +273,7 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed) | |||
272 | tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); | 273 | tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); |
273 | 274 | ||
274 | PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, | 275 | PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, |
275 | CG_TACH_STATUS, TACH_PERIOD, tach_period); | 276 | CG_TACH_CTRL, TARGET_PERIOD, tach_period); |
276 | 277 | ||
277 | return smu7_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM); | 278 | return smu7_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM); |
278 | } | 279 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c index 53cf787560f7..fef111ddb736 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu8_hwmgr.c | |||
@@ -1228,14 +1228,17 @@ static int smu8_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | |||
1228 | 1228 | ||
1229 | static int smu8_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr) | 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 | return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_UVDPowerOFF); | 1233 | return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_UVDPowerOFF); |
1234 | } | ||
1233 | return 0; | 1235 | return 0; |
1234 | } | 1236 | } |
1235 | 1237 | ||
1236 | static int smu8_dpm_powerup_uvd(struct pp_hwmgr *hwmgr) | 1238 | static int smu8_dpm_powerup_uvd(struct pp_hwmgr *hwmgr) |
1237 | { | 1239 | { |
1238 | if (PP_CAP(PHM_PlatformCaps_UVDPowerGating)) { | 1240 | if (PP_CAP(PHM_PlatformCaps_UVDPowerGating)) { |
1241 | smu8_nbdpm_pstate_enable_disable(hwmgr, false, true); | ||
1239 | return smum_send_msg_to_smc_with_parameter( | 1242 | return smum_send_msg_to_smc_with_parameter( |
1240 | hwmgr, | 1243 | hwmgr, |
1241 | PPSMC_MSG_UVDPowerON, | 1244 | PPSMC_MSG_UVDPowerON, |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c index 8ad4e6960efd..4714b5b59825 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.c | |||
@@ -39,6 +39,50 @@ uint16_t convert_to_vddc(uint8_t vid) | |||
39 | return (uint16_t) ((6200 - (vid * 25)) / VOLTAGE_SCALE); | 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 | uint32_t phm_set_field_to_u32(u32 offset, u32 original_data, u32 field, u32 size) | 86 | uint32_t phm_set_field_to_u32(u32 offset, u32 original_data, u32 field, u32 size) |
43 | { | 87 | { |
44 | u32 mask = 0; | 88 | u32 mask = 0; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h index 5454289d5226..ad33983a8064 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu_helper.h | |||
@@ -47,6 +47,18 @@ struct watermarks { | |||
47 | uint32_t padding[7]; | 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 | extern int phm_wait_for_register_unequal(struct pp_hwmgr *hwmgr, | 62 | extern int phm_wait_for_register_unequal(struct pp_hwmgr *hwmgr, |
51 | uint32_t index, | 63 | uint32_t index, |
52 | uint32_t value, uint32_t mask); | 64 | uint32_t value, uint32_t mask); |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c index 16b1a9cf6cf0..b8747a5c9204 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c | |||
@@ -451,23 +451,23 @@ static int get_tdp_table( | |||
451 | le16_to_cpu(power_tune_table_v2->usLoadLineResistance); | 451 | le16_to_cpu(power_tune_table_v2->usLoadLineResistance); |
452 | } else { | 452 | } else { |
453 | power_tune_table_v3 = (ATOM_Vega10_PowerTune_Table_V3 *)table; | 453 | power_tune_table_v3 = (ATOM_Vega10_PowerTune_Table_V3 *)table; |
454 | tdp_table->usMaximumPowerDeliveryLimit = power_tune_table_v3->usSocketPowerLimit; | 454 | tdp_table->usMaximumPowerDeliveryLimit = le16_to_cpu(power_tune_table_v3->usSocketPowerLimit); |
455 | tdp_table->usTDC = power_tune_table_v3->usTdcLimit; | 455 | tdp_table->usTDC = le16_to_cpu(power_tune_table_v3->usTdcLimit); |
456 | tdp_table->usEDCLimit = power_tune_table_v3->usEdcLimit; | 456 | tdp_table->usEDCLimit = le16_to_cpu(power_tune_table_v3->usEdcLimit); |
457 | tdp_table->usSoftwareShutdownTemp = power_tune_table_v3->usSoftwareShutdownTemp; | 457 | tdp_table->usSoftwareShutdownTemp = le16_to_cpu(power_tune_table_v3->usSoftwareShutdownTemp); |
458 | tdp_table->usTemperatureLimitTedge = power_tune_table_v3->usTemperatureLimitTedge; | 458 | tdp_table->usTemperatureLimitTedge = le16_to_cpu(power_tune_table_v3->usTemperatureLimitTedge); |
459 | tdp_table->usTemperatureLimitHotspot = power_tune_table_v3->usTemperatureLimitHotSpot; | 459 | tdp_table->usTemperatureLimitHotspot = le16_to_cpu(power_tune_table_v3->usTemperatureLimitHotSpot); |
460 | tdp_table->usTemperatureLimitLiquid1 = power_tune_table_v3->usTemperatureLimitLiquid1; | 460 | tdp_table->usTemperatureLimitLiquid1 = le16_to_cpu(power_tune_table_v3->usTemperatureLimitLiquid1); |
461 | tdp_table->usTemperatureLimitLiquid2 = power_tune_table_v3->usTemperatureLimitLiquid2; | 461 | tdp_table->usTemperatureLimitLiquid2 = le16_to_cpu(power_tune_table_v3->usTemperatureLimitLiquid2); |
462 | tdp_table->usTemperatureLimitHBM = power_tune_table_v3->usTemperatureLimitHBM; | 462 | tdp_table->usTemperatureLimitHBM = le16_to_cpu(power_tune_table_v3->usTemperatureLimitHBM); |
463 | tdp_table->usTemperatureLimitVrVddc = power_tune_table_v3->usTemperatureLimitVrSoc; | 463 | tdp_table->usTemperatureLimitVrVddc = le16_to_cpu(power_tune_table_v3->usTemperatureLimitVrSoc); |
464 | tdp_table->usTemperatureLimitVrMvdd = power_tune_table_v3->usTemperatureLimitVrMem; | 464 | tdp_table->usTemperatureLimitVrMvdd = le16_to_cpu(power_tune_table_v3->usTemperatureLimitVrMem); |
465 | tdp_table->usTemperatureLimitPlx = power_tune_table_v3->usTemperatureLimitPlx; | 465 | tdp_table->usTemperatureLimitPlx = le16_to_cpu(power_tune_table_v3->usTemperatureLimitPlx); |
466 | tdp_table->ucLiquid1_I2C_address = power_tune_table_v3->ucLiquid1_I2C_address; | 466 | tdp_table->ucLiquid1_I2C_address = power_tune_table_v3->ucLiquid1_I2C_address; |
467 | tdp_table->ucLiquid2_I2C_address = power_tune_table_v3->ucLiquid2_I2C_address; | 467 | tdp_table->ucLiquid2_I2C_address = power_tune_table_v3->ucLiquid2_I2C_address; |
468 | tdp_table->usBoostStartTemperature = power_tune_table_v3->usBoostStartTemperature; | 468 | tdp_table->usBoostStartTemperature = le16_to_cpu(power_tune_table_v3->usBoostStartTemperature); |
469 | tdp_table->usBoostStopTemperature = power_tune_table_v3->usBoostStopTemperature; | 469 | tdp_table->usBoostStopTemperature = le16_to_cpu(power_tune_table_v3->usBoostStopTemperature); |
470 | tdp_table->ulBoostClock = power_tune_table_v3->ulBoostClock; | 470 | tdp_table->ulBoostClock = le32_to_cpu(power_tune_table_v3->ulBoostClock); |
471 | 471 | ||
472 | get_scl_sda_value(power_tune_table_v3->ucLiquid_I2C_Line, &scl, &sda); | 472 | get_scl_sda_value(power_tune_table_v3->ucLiquid_I2C_Line, &scl, &sda); |
473 | 473 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c index 407762b36901..3f807d6c95ce 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c | |||
@@ -312,6 +312,7 @@ int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed) | |||
312 | int result = 0; | 312 | int result = 0; |
313 | 313 | ||
314 | if (hwmgr->thermal_controller.fanInfo.bNoFan || | 314 | if (hwmgr->thermal_controller.fanInfo.bNoFan || |
315 | speed == 0 || | ||
315 | (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || | 316 | (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || |
316 | (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) | 317 | (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) |
317 | return -1; | 318 | return -1; |
@@ -322,9 +323,9 @@ int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed) | |||
322 | if (!result) { | 323 | if (!result) { |
323 | crystal_clock_freq = amdgpu_asic_get_xclk((struct amdgpu_device *)hwmgr->adev); | 324 | crystal_clock_freq = amdgpu_asic_get_xclk((struct amdgpu_device *)hwmgr->adev); |
324 | tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); | 325 | tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); |
325 | WREG32_SOC15(THM, 0, mmCG_TACH_STATUS, | 326 | WREG32_SOC15(THM, 0, mmCG_TACH_CTRL, |
326 | REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_STATUS), | 327 | REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL), |
327 | CG_TACH_STATUS, TACH_PERIOD, | 328 | CG_TACH_CTRL, TARGET_PERIOD, |
328 | tach_period)); | 329 | tach_period)); |
329 | } | 330 | } |
330 | return vega10_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM); | 331 | return vega10_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM); |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c index cb3a5b1737c8..9817f7a5ed29 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_processpptables.c | |||
@@ -99,50 +99,6 @@ static int set_platform_caps(struct pp_hwmgr *hwmgr, uint32_t powerplay_caps) | |||
99 | return 0; | 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 | static int append_vbios_pptable(struct pp_hwmgr *hwmgr, PPTable_t *ppsmc_pptable) | 102 | static int append_vbios_pptable(struct pp_hwmgr *hwmgr, PPTable_t *ppsmc_pptable) |
147 | { | 103 | { |
148 | struct pp_atomfwctrl_smc_dpm_parameters smc_dpm_table; | 104 | struct pp_atomfwctrl_smc_dpm_parameters smc_dpm_table; |
@@ -250,14 +206,22 @@ static int init_powerplay_table_information( | |||
250 | 206 | ||
251 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl); | 207 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl); |
252 | 208 | ||
253 | if (powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_GFXCLKFMAX] > VEGA12_ENGINECLOCK_HARDMAX) | 209 | if (le32_to_cpu(powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_GFXCLKFMAX]) > VEGA12_ENGINECLOCK_HARDMAX) |
254 | hwmgr->platform_descriptor.overdriveLimit.engineClock = VEGA12_ENGINECLOCK_HARDMAX; | 210 | hwmgr->platform_descriptor.overdriveLimit.engineClock = VEGA12_ENGINECLOCK_HARDMAX; |
255 | else | 211 | else |
256 | hwmgr->platform_descriptor.overdriveLimit.engineClock = powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_GFXCLKFMAX]; | 212 | hwmgr->platform_descriptor.overdriveLimit.engineClock = |
257 | hwmgr->platform_descriptor.overdriveLimit.memoryClock = powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_UCLKFMAX]; | 213 | le32_to_cpu(powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_GFXCLKFMAX]); |
258 | 214 | hwmgr->platform_descriptor.overdriveLimit.memoryClock = | |
259 | copy_overdrive_settings_limits_array(hwmgr, &pptable_information->od_settings_max, powerplay_table->ODSettingsMax); | 215 | le32_to_cpu(powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_UCLKFMAX]); |
260 | copy_overdrive_settings_limits_array(hwmgr, &pptable_information->od_settings_min, powerplay_table->ODSettingsMin); | 216 | |
217 | phm_copy_overdrive_settings_limits_array(hwmgr, | ||
218 | &pptable_information->od_settings_max, | ||
219 | powerplay_table->ODSettingsMax, | ||
220 | ATOM_VEGA12_ODSETTING_COUNT); | ||
221 | phm_copy_overdrive_settings_limits_array(hwmgr, | ||
222 | &pptable_information->od_settings_min, | ||
223 | powerplay_table->ODSettingsMin, | ||
224 | ATOM_VEGA12_ODSETTING_COUNT); | ||
261 | 225 | ||
262 | /* hwmgr->platformDescriptor.minOverdriveVDDC = 0; | 226 | /* hwmgr->platformDescriptor.minOverdriveVDDC = 0; |
263 | hwmgr->platformDescriptor.maxOverdriveVDDC = 0; | 227 | hwmgr->platformDescriptor.maxOverdriveVDDC = 0; |
@@ -267,15 +231,15 @@ static int init_powerplay_table_information( | |||
267 | && hwmgr->platform_descriptor.overdriveLimit.memoryClock > 0) | 231 | && hwmgr->platform_descriptor.overdriveLimit.memoryClock > 0) |
268 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_ACOverdriveSupport); | 232 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_ACOverdriveSupport); |
269 | 233 | ||
270 | pptable_information->us_small_power_limit1 = powerplay_table->usSmallPowerLimit1; | 234 | pptable_information->us_small_power_limit1 = le16_to_cpu(powerplay_table->usSmallPowerLimit1); |
271 | pptable_information->us_small_power_limit2 = powerplay_table->usSmallPowerLimit2; | 235 | pptable_information->us_small_power_limit2 = le16_to_cpu(powerplay_table->usSmallPowerLimit2); |
272 | pptable_information->us_boost_power_limit = powerplay_table->usBoostPowerLimit; | 236 | pptable_information->us_boost_power_limit = le16_to_cpu(powerplay_table->usBoostPowerLimit); |
273 | pptable_information->us_od_turbo_power_limit = powerplay_table->usODTurboPowerLimit; | 237 | pptable_information->us_od_turbo_power_limit = le16_to_cpu(powerplay_table->usODTurboPowerLimit); |
274 | pptable_information->us_od_powersave_power_limit = powerplay_table->usODPowerSavePowerLimit; | 238 | pptable_information->us_od_powersave_power_limit = le16_to_cpu(powerplay_table->usODPowerSavePowerLimit); |
275 | 239 | ||
276 | pptable_information->us_software_shutdown_temp = powerplay_table->usSoftwareShutdownTemp; | 240 | pptable_information->us_software_shutdown_temp = le16_to_cpu(powerplay_table->usSoftwareShutdownTemp); |
277 | 241 | ||
278 | hwmgr->platform_descriptor.TDPODLimit = (uint16_t)powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_POWERPERCENTAGE]; | 242 | hwmgr->platform_descriptor.TDPODLimit = le32_to_cpu(powerplay_table->ODSettingsMax[ATOM_VEGA12_ODSETTING_POWERPERCENTAGE]); |
279 | 243 | ||
280 | disable_power_control = 0; | 244 | disable_power_control = 0; |
281 | if (!disable_power_control) { | 245 | if (!disable_power_control) { |
@@ -285,8 +249,8 @@ static int init_powerplay_table_information( | |||
285 | PHM_PlatformCaps_PowerControl); | 249 | PHM_PlatformCaps_PowerControl); |
286 | } | 250 | } |
287 | 251 | ||
288 | copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_max, powerplay_table->PowerSavingClockMax); | 252 | phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_max, powerplay_table->PowerSavingClockMax, ATOM_VEGA12_PPCLOCK_COUNT); |
289 | copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_min, powerplay_table->PowerSavingClockMin); | 253 | phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_min, powerplay_table->PowerSavingClockMin, ATOM_VEGA12_PPCLOCK_COUNT); |
290 | 254 | ||
291 | pptable_information->smc_pptable = (PPTable_t *)kmalloc(sizeof(PPTable_t), GFP_KERNEL); | 255 | pptable_information->smc_pptable = (PPTable_t *)kmalloc(sizeof(PPTable_t), GFP_KERNEL); |
292 | if (pptable_information->smc_pptable == NULL) | 256 | if (pptable_information->smc_pptable == NULL) |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c index 2a554f9edcda..958af7b48827 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | |||
@@ -46,6 +46,9 @@ | |||
46 | #include "ppinterrupt.h" | 46 | #include "ppinterrupt.h" |
47 | #include "pp_overdriver.h" | 47 | #include "pp_overdriver.h" |
48 | #include "pp_thermal.h" | 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 | static void vega20_set_default_registry_data(struct pp_hwmgr *hwmgr) | 53 | static void vega20_set_default_registry_data(struct pp_hwmgr *hwmgr) |
51 | { | 54 | { |
@@ -1474,6 +1477,19 @@ static int vega20_init_max_sustainable_clocks(struct pp_hwmgr *hwmgr) | |||
1474 | return 0; | 1477 | return 0; |
1475 | } | 1478 | } |
1476 | 1479 | ||
1480 | static int vega20_enable_mgpu_fan_boost(struct pp_hwmgr *hwmgr) | ||
1481 | { | ||
1482 | int result; | ||
1483 | |||
1484 | result = smum_send_msg_to_smc(hwmgr, | ||
1485 | PPSMC_MSG_SetMGpuFanBoostLimitRpm); | ||
1486 | PP_ASSERT_WITH_CODE(!result, | ||
1487 | "[EnableMgpuFan] Failed to enable mgpu fan boost!", | ||
1488 | return result); | ||
1489 | |||
1490 | return 0; | ||
1491 | } | ||
1492 | |||
1477 | static void vega20_init_powergate_state(struct pp_hwmgr *hwmgr) | 1493 | static void vega20_init_powergate_state(struct pp_hwmgr *hwmgr) |
1478 | { | 1494 | { |
1479 | struct vega20_hwmgr *data = | 1495 | struct vega20_hwmgr *data = |
@@ -1544,6 +1560,14 @@ static int vega20_enable_dpm_tasks(struct pp_hwmgr *hwmgr) | |||
1544 | "[EnableDPMTasks] Failed to populate umdpstate clocks!", | 1560 | "[EnableDPMTasks] Failed to populate umdpstate clocks!", |
1545 | return result); | 1561 | return result); |
1546 | 1562 | ||
1563 | result = smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_GetPptLimit, | ||
1564 | POWER_SOURCE_AC << 16); | ||
1565 | PP_ASSERT_WITH_CODE(!result, | ||
1566 | "[GetPptLimit] get default PPT limit failed!", | ||
1567 | return result); | ||
1568 | hwmgr->power_limit = | ||
1569 | hwmgr->default_power_limit = smum_get_argument(hwmgr); | ||
1570 | |||
1547 | return 0; | 1571 | return 0; |
1548 | } | 1572 | } |
1549 | 1573 | ||
@@ -1907,6 +1931,8 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx, | |||
1907 | void *value, int *size) | 1931 | void *value, int *size) |
1908 | { | 1932 | { |
1909 | struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); | 1933 | struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); |
1934 | struct amdgpu_device *adev = hwmgr->adev; | ||
1935 | uint32_t val_vid; | ||
1910 | int ret = 0; | 1936 | int ret = 0; |
1911 | 1937 | ||
1912 | switch (idx) { | 1938 | switch (idx) { |
@@ -1941,6 +1967,13 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx, | |||
1941 | *size = 16; | 1967 | *size = 16; |
1942 | ret = vega20_get_gpu_power(hwmgr, (uint32_t *)value); | 1968 | ret = vega20_get_gpu_power(hwmgr, (uint32_t *)value); |
1943 | break; | 1969 | break; |
1970 | case AMDGPU_PP_SENSOR_VDDGFX: | ||
1971 | val_vid = (RREG32_SOC15(SMUIO, 0, mmSMUSVI0_TEL_PLANE0) & | ||
1972 | SMUSVI0_TEL_PLANE0__SVI0_PLANE0_VDDCOR_MASK) >> | ||
1973 | SMUSVI0_TEL_PLANE0__SVI0_PLANE0_VDDCOR__SHIFT; | ||
1974 | *((uint32_t *)value) = | ||
1975 | (uint32_t)convert_to_vddc((uint8_t)val_vid); | ||
1976 | break; | ||
1944 | case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK: | 1977 | case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK: |
1945 | ret = vega20_get_enabled_smc_features(hwmgr, (uint64_t *)value); | 1978 | ret = vega20_get_enabled_smc_features(hwmgr, (uint64_t *)value); |
1946 | if (!ret) | 1979 | if (!ret) |
@@ -2269,6 +2302,25 @@ static uint32_t vega20_get_fan_control_mode(struct pp_hwmgr *hwmgr) | |||
2269 | return AMD_FAN_CTRL_AUTO; | 2302 | return AMD_FAN_CTRL_AUTO; |
2270 | } | 2303 | } |
2271 | 2304 | ||
2305 | static void vega20_set_fan_control_mode(struct pp_hwmgr *hwmgr, uint32_t mode) | ||
2306 | { | ||
2307 | switch (mode) { | ||
2308 | case AMD_FAN_CTRL_NONE: | ||
2309 | vega20_fan_ctrl_set_fan_speed_percent(hwmgr, 100); | ||
2310 | break; | ||
2311 | case AMD_FAN_CTRL_MANUAL: | ||
2312 | if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) | ||
2313 | vega20_fan_ctrl_stop_smc_fan_control(hwmgr); | ||
2314 | break; | ||
2315 | case AMD_FAN_CTRL_AUTO: | ||
2316 | if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) | ||
2317 | vega20_fan_ctrl_start_smc_fan_control(hwmgr); | ||
2318 | break; | ||
2319 | default: | ||
2320 | break; | ||
2321 | } | ||
2322 | } | ||
2323 | |||
2272 | static int vega20_get_dal_power_level(struct pp_hwmgr *hwmgr, | 2324 | static int vega20_get_dal_power_level(struct pp_hwmgr *hwmgr, |
2273 | struct amd_pp_simple_clock_info *info) | 2325 | struct amd_pp_simple_clock_info *info) |
2274 | { | 2326 | { |
@@ -3165,7 +3217,7 @@ static int vega20_get_power_profile_mode(struct pp_hwmgr *hwmgr, char *buf) | |||
3165 | "[GetPowerProfile] Failed to get activity monitor!", | 3217 | "[GetPowerProfile] Failed to get activity monitor!", |
3166 | return result); | 3218 | return result); |
3167 | 3219 | ||
3168 | size += sprintf(buf + size, "%2d(%14s%s)\n", | 3220 | size += sprintf(buf + size, "%2d %14s%s:\n", |
3169 | i, profile_name[i], (i == hwmgr->power_profile_mode) ? "*" : " "); | 3221 | i, profile_name[i], (i == hwmgr->power_profile_mode) ? "*" : " "); |
3170 | 3222 | ||
3171 | size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", | 3223 | size += sprintf(buf + size, "%19s %d(%13s) %7d %7d %7d %7d %7d %7d %7d %7d %7d\n", |
@@ -3432,15 +3484,25 @@ static const struct pp_hwmgr_func vega20_hwmgr_funcs = { | |||
3432 | .disable_smc_firmware_ctf = | 3484 | .disable_smc_firmware_ctf = |
3433 | vega20_thermal_disable_alert, | 3485 | vega20_thermal_disable_alert, |
3434 | /* fan control related */ | 3486 | /* fan control related */ |
3487 | .get_fan_speed_percent = | ||
3488 | vega20_fan_ctrl_get_fan_speed_percent, | ||
3489 | .set_fan_speed_percent = | ||
3490 | vega20_fan_ctrl_set_fan_speed_percent, | ||
3435 | .get_fan_speed_info = | 3491 | .get_fan_speed_info = |
3436 | vega20_fan_ctrl_get_fan_speed_info, | 3492 | vega20_fan_ctrl_get_fan_speed_info, |
3437 | .get_fan_speed_rpm = | 3493 | .get_fan_speed_rpm = |
3438 | vega20_fan_ctrl_get_fan_speed_rpm, | 3494 | vega20_fan_ctrl_get_fan_speed_rpm, |
3495 | .set_fan_speed_rpm = | ||
3496 | vega20_fan_ctrl_set_fan_speed_rpm, | ||
3439 | .get_fan_control_mode = | 3497 | .get_fan_control_mode = |
3440 | vega20_get_fan_control_mode, | 3498 | vega20_get_fan_control_mode, |
3499 | .set_fan_control_mode = | ||
3500 | vega20_set_fan_control_mode, | ||
3441 | /* smu memory related */ | 3501 | /* smu memory related */ |
3442 | .notify_cac_buffer_info = | 3502 | .notify_cac_buffer_info = |
3443 | vega20_notify_cac_buffer_info, | 3503 | vega20_notify_cac_buffer_info, |
3504 | .enable_mgpu_fan_boost = | ||
3505 | vega20_enable_mgpu_fan_boost, | ||
3444 | }; | 3506 | }; |
3445 | 3507 | ||
3446 | int vega20_hwmgr_init(struct pp_hwmgr *hwmgr) | 3508 | int vega20_hwmgr_init(struct pp_hwmgr *hwmgr) |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_processpptables.c index 5f1f7a32ac24..32fe38452094 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_processpptables.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_processpptables.c | |||
@@ -661,50 +661,6 @@ static int set_platform_caps(struct pp_hwmgr *hwmgr, uint32_t powerplay_caps) | |||
661 | return 0; | 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 | static int copy_overdrive_feature_capabilities_array( | 664 | static int copy_overdrive_feature_capabilities_array( |
709 | struct pp_hwmgr *hwmgr, | 665 | struct pp_hwmgr *hwmgr, |
710 | uint8_t **pptable_info_array, | 666 | uint8_t **pptable_info_array, |
@@ -721,7 +677,7 @@ static int copy_overdrive_feature_capabilities_array( | |||
721 | return -ENOMEM; | 677 | return -ENOMEM; |
722 | 678 | ||
723 | for (i = 0; i < od_feature_count; i++) { | 679 | for (i = 0; i < od_feature_count; i++) { |
724 | table[i] = pptable_array[i]; | 680 | table[i] = le32_to_cpu(pptable_array[i]); |
725 | if (table[i]) | 681 | if (table[i]) |
726 | od_supported = true; | 682 | od_supported = true; |
727 | } | 683 | } |
@@ -834,6 +790,8 @@ static int init_powerplay_table_information( | |||
834 | 790 | ||
835 | hwmgr->thermal_controller.ucType = powerplay_table->ucThermalControllerType; | 791 | hwmgr->thermal_controller.ucType = powerplay_table->ucThermalControllerType; |
836 | pptable_information->uc_thermal_controller_type = powerplay_table->ucThermalControllerType; | 792 | pptable_information->uc_thermal_controller_type = powerplay_table->ucThermalControllerType; |
793 | hwmgr->thermal_controller.fanInfo.ulMinRPM = 0; | ||
794 | hwmgr->thermal_controller.fanInfo.ulMaxRPM = powerplay_table->smcPPTable.FanMaximumRpm; | ||
837 | 795 | ||
838 | set_hw_cap(hwmgr, | 796 | set_hw_cap(hwmgr, |
839 | ATOM_VEGA20_PP_THERMALCONTROLLER_NONE != hwmgr->thermal_controller.ucType, | 797 | ATOM_VEGA20_PP_THERMALCONTROLLER_NONE != hwmgr->thermal_controller.ucType, |
@@ -842,34 +800,40 @@ static int init_powerplay_table_information( | |||
842 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl); | 800 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_MicrocodeFanControl); |
843 | 801 | ||
844 | if (powerplay_table->OverDrive8Table.ucODTableRevision == 1) { | 802 | if (powerplay_table->OverDrive8Table.ucODTableRevision == 1) { |
845 | od_feature_count = (powerplay_table->OverDrive8Table.ODFeatureCount > ATOM_VEGA20_ODFEATURE_COUNT) ? | 803 | od_feature_count = |
846 | ATOM_VEGA20_ODFEATURE_COUNT : powerplay_table->OverDrive8Table.ODFeatureCount; | 804 | (le32_to_cpu(powerplay_table->OverDrive8Table.ODFeatureCount) > |
847 | od_setting_count = (powerplay_table->OverDrive8Table.ODSettingCount > ATOM_VEGA20_ODSETTING_COUNT) ? | 805 | ATOM_VEGA20_ODFEATURE_COUNT) ? |
848 | ATOM_VEGA20_ODSETTING_COUNT : powerplay_table->OverDrive8Table.ODSettingCount; | 806 | ATOM_VEGA20_ODFEATURE_COUNT : |
807 | le32_to_cpu(powerplay_table->OverDrive8Table.ODFeatureCount); | ||
808 | od_setting_count = | ||
809 | (le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingCount) > | ||
810 | ATOM_VEGA20_ODSETTING_COUNT) ? | ||
811 | ATOM_VEGA20_ODSETTING_COUNT : | ||
812 | le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingCount); | ||
849 | 813 | ||
850 | copy_overdrive_feature_capabilities_array(hwmgr, | 814 | copy_overdrive_feature_capabilities_array(hwmgr, |
851 | &pptable_information->od_feature_capabilities, | 815 | &pptable_information->od_feature_capabilities, |
852 | powerplay_table->OverDrive8Table.ODFeatureCapabilities, | 816 | powerplay_table->OverDrive8Table.ODFeatureCapabilities, |
853 | od_feature_count); | 817 | od_feature_count); |
854 | copy_overdrive_settings_limits_array(hwmgr, | 818 | phm_copy_overdrive_settings_limits_array(hwmgr, |
855 | &pptable_information->od_settings_max, | 819 | &pptable_information->od_settings_max, |
856 | powerplay_table->OverDrive8Table.ODSettingsMax, | 820 | powerplay_table->OverDrive8Table.ODSettingsMax, |
857 | od_setting_count); | 821 | od_setting_count); |
858 | copy_overdrive_settings_limits_array(hwmgr, | 822 | phm_copy_overdrive_settings_limits_array(hwmgr, |
859 | &pptable_information->od_settings_min, | 823 | &pptable_information->od_settings_min, |
860 | powerplay_table->OverDrive8Table.ODSettingsMin, | 824 | powerplay_table->OverDrive8Table.ODSettingsMin, |
861 | od_setting_count); | 825 | od_setting_count); |
862 | } | 826 | } |
863 | 827 | ||
864 | pptable_information->us_small_power_limit1 = powerplay_table->usSmallPowerLimit1; | 828 | pptable_information->us_small_power_limit1 = le16_to_cpu(powerplay_table->usSmallPowerLimit1); |
865 | pptable_information->us_small_power_limit2 = powerplay_table->usSmallPowerLimit2; | 829 | pptable_information->us_small_power_limit2 = le16_to_cpu(powerplay_table->usSmallPowerLimit2); |
866 | pptable_information->us_boost_power_limit = powerplay_table->usBoostPowerLimit; | 830 | pptable_information->us_boost_power_limit = le16_to_cpu(powerplay_table->usBoostPowerLimit); |
867 | pptable_information->us_od_turbo_power_limit = powerplay_table->usODTurboPowerLimit; | 831 | pptable_information->us_od_turbo_power_limit = le16_to_cpu(powerplay_table->usODTurboPowerLimit); |
868 | pptable_information->us_od_powersave_power_limit = powerplay_table->usODPowerSavePowerLimit; | 832 | pptable_information->us_od_powersave_power_limit = le16_to_cpu(powerplay_table->usODPowerSavePowerLimit); |
869 | 833 | ||
870 | pptable_information->us_software_shutdown_temp = powerplay_table->usSoftwareShutdownTemp; | 834 | pptable_information->us_software_shutdown_temp = le16_to_cpu(powerplay_table->usSoftwareShutdownTemp); |
871 | 835 | ||
872 | hwmgr->platform_descriptor.TDPODLimit = (uint16_t)powerplay_table->OverDrive8Table.ODSettingsMax[ATOM_VEGA20_ODSETTING_POWERPERCENTAGE]; | 836 | hwmgr->platform_descriptor.TDPODLimit = le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingsMax[ATOM_VEGA20_ODSETTING_POWERPERCENTAGE]); |
873 | 837 | ||
874 | disable_power_control = 0; | 838 | disable_power_control = 0; |
875 | if (!disable_power_control && hwmgr->platform_descriptor.TDPODLimit) | 839 | if (!disable_power_control && hwmgr->platform_descriptor.TDPODLimit) |
@@ -877,13 +841,16 @@ static int init_powerplay_table_information( | |||
877 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PowerControl); | 841 | phm_cap_set(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_PowerControl); |
878 | 842 | ||
879 | if (powerplay_table->PowerSavingClockTable.ucTableRevision == 1) { | 843 | if (powerplay_table->PowerSavingClockTable.ucTableRevision == 1) { |
880 | power_saving_clock_count = (powerplay_table->PowerSavingClockTable.PowerSavingClockCount >= ATOM_VEGA20_PPCLOCK_COUNT) ? | 844 | power_saving_clock_count = |
881 | ATOM_VEGA20_PPCLOCK_COUNT : powerplay_table->PowerSavingClockTable.PowerSavingClockCount; | 845 | (le32_to_cpu(powerplay_table->PowerSavingClockTable.PowerSavingClockCount) >= |
882 | copy_clock_limits_array(hwmgr, | 846 | ATOM_VEGA20_PPCLOCK_COUNT) ? |
847 | ATOM_VEGA20_PPCLOCK_COUNT : | ||
848 | le32_to_cpu(powerplay_table->PowerSavingClockTable.PowerSavingClockCount); | ||
849 | phm_copy_clock_limits_array(hwmgr, | ||
883 | &pptable_information->power_saving_clock_max, | 850 | &pptable_information->power_saving_clock_max, |
884 | powerplay_table->PowerSavingClockTable.PowerSavingClockMax, | 851 | powerplay_table->PowerSavingClockTable.PowerSavingClockMax, |
885 | power_saving_clock_count); | 852 | power_saving_clock_count); |
886 | copy_clock_limits_array(hwmgr, | 853 | phm_copy_clock_limits_array(hwmgr, |
887 | &pptable_information->power_saving_clock_min, | 854 | &pptable_information->power_saving_clock_min, |
888 | powerplay_table->PowerSavingClockTable.PowerSavingClockMin, | 855 | powerplay_table->PowerSavingClockTable.PowerSavingClockMin, |
889 | power_saving_clock_count); | 856 | power_saving_clock_count); |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c index 1c951a5d827d..ede54e87e287 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c | |||
@@ -29,6 +29,78 @@ | |||
29 | #include "soc15_common.h" | 29 | #include "soc15_common.h" |
30 | #include "pp_debug.h" | 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 | static int vega20_get_current_rpm(struct pp_hwmgr *hwmgr, uint32_t *current_rpm) | 104 | static int vega20_get_current_rpm(struct pp_hwmgr *hwmgr, uint32_t *current_rpm) |
33 | { | 105 | { |
34 | int ret = 0; | 106 | int ret = 0; |
@@ -42,12 +114,62 @@ static int vega20_get_current_rpm(struct pp_hwmgr *hwmgr, uint32_t *current_rpm) | |||
42 | return 0; | 114 | return 0; |
43 | } | 115 | } |
44 | 116 | ||
117 | int vega20_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, | ||
118 | uint32_t *speed) | ||
119 | { | ||
120 | struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); | ||
121 | PPTable_t *pp_table = &(data->smc_state_table.pp_table); | ||
122 | uint32_t current_rpm, percent = 0; | ||
123 | int ret = 0; | ||
124 | |||
125 | ret = vega20_get_current_rpm(hwmgr, ¤t_rpm); | ||
126 | if (ret) | ||
127 | return ret; | ||
128 | |||
129 | percent = current_rpm * 100 / pp_table->FanMaximumRpm; | ||
130 | |||
131 | *speed = percent > 100 ? 100 : percent; | ||
132 | |||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | int vega20_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, | ||
137 | uint32_t speed) | ||
138 | { | ||
139 | struct amdgpu_device *adev = hwmgr->adev; | ||
140 | uint32_t duty100; | ||
141 | uint32_t duty; | ||
142 | uint64_t tmp64; | ||
143 | |||
144 | if (speed > 100) | ||
145 | speed = 100; | ||
146 | |||
147 | if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) | ||
148 | vega20_fan_ctrl_stop_smc_fan_control(hwmgr); | ||
149 | |||
150 | duty100 = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL1), | ||
151 | CG_FDO_CTRL1, FMAX_DUTY100); | ||
152 | |||
153 | if (duty100 == 0) | ||
154 | return -EINVAL; | ||
155 | |||
156 | tmp64 = (uint64_t)speed * duty100; | ||
157 | do_div(tmp64, 100); | ||
158 | duty = (uint32_t)tmp64; | ||
159 | |||
160 | WREG32_SOC15(THM, 0, mmCG_FDO_CTRL0, | ||
161 | REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL0), | ||
162 | CG_FDO_CTRL0, FDO_STATIC_DUTY, duty)); | ||
163 | |||
164 | return vega20_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC); | ||
165 | } | ||
166 | |||
45 | int vega20_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, | 167 | int vega20_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, |
46 | struct phm_fan_speed_info *fan_speed_info) | 168 | struct phm_fan_speed_info *fan_speed_info) |
47 | { | 169 | { |
48 | memset(fan_speed_info, 0, sizeof(*fan_speed_info)); | 170 | memset(fan_speed_info, 0, sizeof(*fan_speed_info)); |
49 | fan_speed_info->supports_percent_read = false; | 171 | fan_speed_info->supports_percent_read = true; |
50 | fan_speed_info->supports_percent_write = false; | 172 | fan_speed_info->supports_percent_write = true; |
51 | fan_speed_info->supports_rpm_read = true; | 173 | fan_speed_info->supports_rpm_read = true; |
52 | fan_speed_info->supports_rpm_write = true; | 174 | fan_speed_info->supports_rpm_write = true; |
53 | 175 | ||
@@ -61,6 +183,31 @@ int vega20_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed) | |||
61 | return vega20_get_current_rpm(hwmgr, speed); | 183 | return vega20_get_current_rpm(hwmgr, speed); |
62 | } | 184 | } |
63 | 185 | ||
186 | int vega20_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed) | ||
187 | { | ||
188 | struct amdgpu_device *adev = hwmgr->adev; | ||
189 | uint32_t tach_period, crystal_clock_freq; | ||
190 | int result = 0; | ||
191 | |||
192 | if (!speed) | ||
193 | return -EINVAL; | ||
194 | |||
195 | if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) { | ||
196 | result = vega20_fan_ctrl_stop_smc_fan_control(hwmgr); | ||
197 | if (result) | ||
198 | return result; | ||
199 | } | ||
200 | |||
201 | crystal_clock_freq = amdgpu_asic_get_xclk((struct amdgpu_device *)hwmgr->adev); | ||
202 | tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); | ||
203 | WREG32_SOC15(THM, 0, mmCG_TACH_CTRL, | ||
204 | REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL), | ||
205 | CG_TACH_CTRL, TARGET_PERIOD, | ||
206 | tach_period)); | ||
207 | |||
208 | return vega20_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM); | ||
209 | } | ||
210 | |||
64 | /** | 211 | /** |
65 | * Reads the remote temperature from the SIslands thermal controller. | 212 | * Reads the remote temperature from the SIslands thermal controller. |
66 | * | 213 | * |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.h index 2a6d49fec4e0..2d1769bbd24e 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.h | |||
@@ -50,15 +50,22 @@ struct vega20_temperature { | |||
50 | #define FDO_PWM_MODE_STATIC_RPM 5 | 50 | #define FDO_PWM_MODE_STATIC_RPM 5 |
51 | 51 | ||
52 | extern int vega20_thermal_get_temperature(struct pp_hwmgr *hwmgr); | 52 | extern int vega20_thermal_get_temperature(struct pp_hwmgr *hwmgr); |
53 | extern int vega20_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr); | ||
54 | extern int vega20_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, | 53 | extern int vega20_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, |
55 | struct phm_fan_speed_info *fan_speed_info); | 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 | extern int vega20_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, | 55 | extern int vega20_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, |
58 | uint32_t *speed); | 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 | extern int vega20_thermal_disable_alert(struct pp_hwmgr *hwmgr); | 65 | extern int vega20_thermal_disable_alert(struct pp_hwmgr *hwmgr); |
60 | extern int vega20_start_thermal_controller(struct pp_hwmgr *hwmgr, | 66 | extern int vega20_start_thermal_controller(struct pp_hwmgr *hwmgr, |
61 | struct PP_TemperatureRange *range); | 67 | struct PP_TemperatureRange *range); |
68 | extern int vega20_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr); | ||
62 | 69 | ||
63 | #endif | 70 | #endif |
64 | 71 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h index a6d92128b19c..e5a60aa44b5d 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | |||
@@ -328,6 +328,8 @@ struct pp_hwmgr_func { | |||
328 | int (*set_power_limit)(struct pp_hwmgr *hwmgr, uint32_t n); | 328 | int (*set_power_limit)(struct pp_hwmgr *hwmgr, uint32_t n); |
329 | int (*powergate_mmhub)(struct pp_hwmgr *hwmgr); | 329 | int (*powergate_mmhub)(struct pp_hwmgr *hwmgr); |
330 | int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); | 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 | struct pp_table_func { | 335 | struct pp_table_func { |
@@ -732,7 +734,6 @@ struct pp_hwmgr { | |||
732 | void *smu_backend; | 734 | void *smu_backend; |
733 | const struct pp_smumgr_func *smumgr_funcs; | 735 | const struct pp_smumgr_func *smumgr_funcs; |
734 | bool is_kicker; | 736 | bool is_kicker; |
735 | bool reload_fw; | ||
736 | 737 | ||
737 | enum PP_DAL_POWERLEVEL dal_power_level; | 738 | enum PP_DAL_POWERLEVEL dal_power_level; |
738 | struct phm_dynamic_state_info dyn_state; | 739 | struct phm_dynamic_state_info dyn_state; |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h index 71191deb4e76..a002021414ff 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h +++ b/drivers/gpu/drm/amd/powerplay/inc/smu11_driver_if.h | |||
@@ -269,6 +269,12 @@ typedef enum { | |||
269 | } PPCLK_e; | 269 | } PPCLK_e; |
270 | 270 | ||
271 | typedef enum { | 271 | typedef enum { |
272 | POWER_SOURCE_AC, | ||
273 | POWER_SOURCE_DC, | ||
274 | POWER_SOURCE_COUNT, | ||
275 | } POWER_SOURCE_e; | ||
276 | |||
277 | typedef enum { | ||
272 | VOLTAGE_MODE_AVFS = 0, | 278 | VOLTAGE_MODE_AVFS = 0, |
273 | VOLTAGE_MODE_AVFS_SS, | 279 | VOLTAGE_MODE_AVFS_SS, |
274 | VOLTAGE_MODE_SS, | 280 | VOLTAGE_MODE_SS, |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c index 18643e06bc6f..669bd0c2a16c 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c | |||
@@ -2269,11 +2269,13 @@ static uint32_t ci_get_offsetof(uint32_t type, uint32_t member) | |||
2269 | case DRAM_LOG_BUFF_SIZE: | 2269 | case DRAM_LOG_BUFF_SIZE: |
2270 | return offsetof(SMU7_SoftRegisters, DRAM_LOG_BUFF_SIZE); | 2270 | return offsetof(SMU7_SoftRegisters, DRAM_LOG_BUFF_SIZE); |
2271 | } | 2271 | } |
2272 | break; | ||
2272 | case SMU_Discrete_DpmTable: | 2273 | case SMU_Discrete_DpmTable: |
2273 | switch (member) { | 2274 | switch (member) { |
2274 | case LowSclkInterruptThreshold: | 2275 | case LowSclkInterruptThreshold: |
2275 | return offsetof(SMU7_Discrete_DpmTable, LowSclkInterruptT); | 2276 | return offsetof(SMU7_Discrete_DpmTable, LowSclkInterruptT); |
2276 | } | 2277 | } |
2278 | break; | ||
2277 | } | 2279 | } |
2278 | pr_debug("can't get the offset of type %x member %x\n", type, member); | 2280 | pr_debug("can't get the offset of type %x member %x\n", type, member); |
2279 | return 0; | 2281 | return 0; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c index ec14798e87b6..bc8375cbf297 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c | |||
@@ -302,16 +302,6 @@ static int fiji_start_smu(struct pp_hwmgr *hwmgr) | |||
302 | hwmgr->avfs_supported = false; | 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 | /* Setup SoftRegsStart here for register lookup in case | 305 | /* Setup SoftRegsStart here for register lookup in case |
316 | * DummyBackEnd is used and ProcessFirmwareHeader is not executed | 306 | * DummyBackEnd is used and ProcessFirmwareHeader is not executed |
317 | */ | 307 | */ |
@@ -2331,6 +2321,7 @@ static uint32_t fiji_get_offsetof(uint32_t type, uint32_t member) | |||
2331 | case DRAM_LOG_BUFF_SIZE: | 2321 | case DRAM_LOG_BUFF_SIZE: |
2332 | return offsetof(SMU73_SoftRegisters, DRAM_LOG_BUFF_SIZE); | 2322 | return offsetof(SMU73_SoftRegisters, DRAM_LOG_BUFF_SIZE); |
2333 | } | 2323 | } |
2324 | break; | ||
2334 | case SMU_Discrete_DpmTable: | 2325 | case SMU_Discrete_DpmTable: |
2335 | switch (member) { | 2326 | switch (member) { |
2336 | case UvdBootLevel: | 2327 | case UvdBootLevel: |
@@ -2340,6 +2331,7 @@ static uint32_t fiji_get_offsetof(uint32_t type, uint32_t member) | |||
2340 | case LowSclkInterruptThreshold: | 2331 | case LowSclkInterruptThreshold: |
2341 | return offsetof(SMU73_Discrete_DpmTable, LowSclkInterruptThreshold); | 2332 | return offsetof(SMU73_Discrete_DpmTable, LowSclkInterruptThreshold); |
2342 | } | 2333 | } |
2334 | break; | ||
2343 | } | 2335 | } |
2344 | pr_warn("can't get the offset of type %x member %x\n", type, member); | 2336 | pr_warn("can't get the offset of type %x member %x\n", type, member); |
2345 | return 0; | 2337 | return 0; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c index 73aa368a454e..375ccf6ff5f2 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c | |||
@@ -232,26 +232,25 @@ static int iceland_request_smu_load_specific_fw(struct pp_hwmgr *hwmgr, | |||
232 | 232 | ||
233 | static int iceland_start_smu(struct pp_hwmgr *hwmgr) | 233 | static int iceland_start_smu(struct pp_hwmgr *hwmgr) |
234 | { | 234 | { |
235 | struct iceland_smumgr *priv = hwmgr->smu_backend; | ||
235 | int result; | 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 | if (!smu7_is_smc_ram_running(hwmgr)) { | 238 | if (!smu7_is_smc_ram_running(hwmgr)) { |
245 | pr_info("smu not running, upload firmware again \n"); | ||
246 | result = iceland_smu_upload_firmware_image(hwmgr); | 239 | result = iceland_smu_upload_firmware_image(hwmgr); |
247 | if (result) | 240 | if (result) |
248 | return result; | 241 | return result; |
249 | 242 | ||
250 | result = iceland_smu_start_smc(hwmgr); | 243 | iceland_smu_start_smc(hwmgr); |
251 | if (result) | ||
252 | return result; | ||
253 | } | 244 | } |
254 | 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); | ||
253 | |||
255 | result = smu7_request_smu_load_fw(hwmgr); | 254 | result = smu7_request_smu_load_fw(hwmgr); |
256 | 255 | ||
257 | return result; | 256 | return result; |
@@ -2237,11 +2236,13 @@ static uint32_t iceland_get_offsetof(uint32_t type, uint32_t member) | |||
2237 | case DRAM_LOG_BUFF_SIZE: | 2236 | case DRAM_LOG_BUFF_SIZE: |
2238 | return offsetof(SMU71_SoftRegisters, DRAM_LOG_BUFF_SIZE); | 2237 | return offsetof(SMU71_SoftRegisters, DRAM_LOG_BUFF_SIZE); |
2239 | } | 2238 | } |
2239 | break; | ||
2240 | case SMU_Discrete_DpmTable: | 2240 | case SMU_Discrete_DpmTable: |
2241 | switch (member) { | 2241 | switch (member) { |
2242 | case LowSclkInterruptThreshold: | 2242 | case LowSclkInterruptThreshold: |
2243 | return offsetof(SMU71_Discrete_DpmTable, LowSclkInterruptThreshold); | 2243 | return offsetof(SMU71_Discrete_DpmTable, LowSclkInterruptThreshold); |
2244 | } | 2244 | } |
2245 | break; | ||
2245 | } | 2246 | } |
2246 | pr_warn("can't get the offset of type %x member %x\n", type, member); | 2247 | pr_warn("can't get the offset of type %x member %x\n", type, member); |
2247 | return 0; | 2248 | return 0; |
@@ -2662,7 +2663,7 @@ const struct pp_smumgr_func iceland_smu_funcs = { | |||
2662 | .smu_fini = &smu7_smu_fini, | 2663 | .smu_fini = &smu7_smu_fini, |
2663 | .start_smu = &iceland_start_smu, | 2664 | .start_smu = &iceland_start_smu, |
2664 | .check_fw_load_finish = &smu7_check_fw_load_finish, | 2665 | .check_fw_load_finish = &smu7_check_fw_load_finish, |
2665 | .request_smu_load_fw = &smu7_reload_firmware, | 2666 | .request_smu_load_fw = &smu7_request_smu_load_fw, |
2666 | .request_smu_load_specific_fw = &iceland_request_smu_load_specific_fw, | 2667 | .request_smu_load_specific_fw = &iceland_request_smu_load_specific_fw, |
2667 | .send_msg_to_smc = &smu7_send_msg_to_smc, | 2668 | .send_msg_to_smc = &smu7_send_msg_to_smc, |
2668 | .send_msg_to_smc_with_parameter = &smu7_send_msg_to_smc_with_parameter, | 2669 | .send_msg_to_smc_with_parameter = &smu7_send_msg_to_smc_with_parameter, |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu10_smumgr.c index 6f961dec2088..d0eb8ab50148 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu10_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu10_smumgr.c | |||
@@ -186,40 +186,12 @@ static int smu10_verify_smc_interface(struct pp_hwmgr *hwmgr) | |||
186 | return 0; | 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 | static int smu10_smu_fini(struct pp_hwmgr *hwmgr) | 189 | static int smu10_smu_fini(struct pp_hwmgr *hwmgr) |
216 | { | 190 | { |
217 | struct smu10_smumgr *priv = | 191 | struct smu10_smumgr *priv = |
218 | (struct smu10_smumgr *)(hwmgr->smu_backend); | 192 | (struct smu10_smumgr *)(hwmgr->smu_backend); |
219 | 193 | ||
220 | if (priv) { | 194 | if (priv) { |
221 | smu10_smc_disable_sdma(hwmgr); | ||
222 | smu10_smc_disable_vcn(hwmgr); | ||
223 | amdgpu_bo_free_kernel(&priv->smu_tables.entry[SMU10_WMTABLE].handle, | 195 | amdgpu_bo_free_kernel(&priv->smu_tables.entry[SMU10_WMTABLE].handle, |
224 | &priv->smu_tables.entry[SMU10_WMTABLE].mc_addr, | 196 | &priv->smu_tables.entry[SMU10_WMTABLE].mc_addr, |
225 | &priv->smu_tables.entry[SMU10_WMTABLE].table); | 197 | &priv->smu_tables.entry[SMU10_WMTABLE].table); |
@@ -243,8 +215,7 @@ static int smu10_start_smu(struct pp_hwmgr *hwmgr) | |||
243 | 215 | ||
244 | if (smu10_verify_smc_interface(hwmgr)) | 216 | if (smu10_verify_smc_interface(hwmgr)) |
245 | return -EINVAL; | 217 | return -EINVAL; |
246 | smu10_smc_enable_sdma(hwmgr); | 218 | |
247 | smu10_smc_enable_vcn(hwmgr); | ||
248 | return 0; | 219 | return 0; |
249 | } | 220 | } |
250 | 221 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c index 186dafc7f166..3f51d545e8ff 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c | |||
@@ -302,44 +302,6 @@ int smu7_write_smc_sram_dword(struct pp_hwmgr *hwmgr, uint32_t smc_addr, uint32_ | |||
302 | return 0; | 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 | static int smu7_populate_single_firmware_entry(struct pp_hwmgr *hwmgr, | 305 | static int smu7_populate_single_firmware_entry(struct pp_hwmgr *hwmgr, |
344 | uint32_t fw_type, | 306 | uint32_t fw_type, |
345 | struct SMU_Entry *entry) | 307 | struct SMU_Entry *entry) |
@@ -381,10 +343,7 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr) | |||
381 | uint32_t fw_to_load; | 343 | uint32_t fw_to_load; |
382 | int r = 0; | 344 | int r = 0; |
383 | 345 | ||
384 | if (!hwmgr->reload_fw) { | 346 | amdgpu_ucode_init_bo(hwmgr->adev); |
385 | pr_info("skip reloading...\n"); | ||
386 | return 0; | ||
387 | } | ||
388 | 347 | ||
389 | if (smu_data->soft_regs_start) | 348 | if (smu_data->soft_regs_start) |
390 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, | 349 | cgs_write_ind_register(hwmgr->device, CGS_IND_REG__SMC, |
@@ -467,10 +426,13 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr) | |||
467 | smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_HI, upper_32_bits(smu_data->header_buffer.mc_addr)); | 426 | smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_HI, upper_32_bits(smu_data->header_buffer.mc_addr)); |
468 | smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_LO, lower_32_bits(smu_data->header_buffer.mc_addr)); | 427 | smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_LO, lower_32_bits(smu_data->header_buffer.mc_addr)); |
469 | 428 | ||
470 | if (smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_LoadUcodes, fw_to_load)) | 429 | smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_LoadUcodes, fw_to_load); |
471 | pr_err("Fail to Request SMU Load uCode"); | ||
472 | 430 | ||
473 | return r; | 431 | r = smu7_check_fw_load_finish(hwmgr, fw_to_load); |
432 | if (!r) | ||
433 | return 0; | ||
434 | |||
435 | pr_err("SMU load firmware failed\n"); | ||
474 | 436 | ||
475 | failed: | 437 | failed: |
476 | kfree(smu_data->toc); | 438 | kfree(smu_data->toc); |
@@ -482,13 +444,12 @@ failed: | |||
482 | int smu7_check_fw_load_finish(struct pp_hwmgr *hwmgr, uint32_t fw_type) | 444 | int smu7_check_fw_load_finish(struct pp_hwmgr *hwmgr, uint32_t fw_type) |
483 | { | 445 | { |
484 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend); | 446 | struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend); |
485 | uint32_t fw_mask = smu7_get_mask_for_firmware_type(fw_type); | ||
486 | uint32_t ret; | 447 | uint32_t ret; |
487 | 448 | ||
488 | ret = phm_wait_on_indirect_register(hwmgr, mmSMC_IND_INDEX_11, | 449 | ret = phm_wait_on_indirect_register(hwmgr, mmSMC_IND_INDEX_11, |
489 | smu_data->soft_regs_start + smum_get_offsetof(hwmgr, | 450 | smu_data->soft_regs_start + smum_get_offsetof(hwmgr, |
490 | SMU_SoftRegisters, UcodeLoadStatus), | 451 | SMU_SoftRegisters, UcodeLoadStatus), |
491 | fw_mask, fw_mask); | 452 | fw_type, fw_type); |
492 | return ret; | 453 | return ret; |
493 | } | 454 | } |
494 | 455 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c index a74c5be1ec18..f836d30fdd44 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c | |||
@@ -658,11 +658,10 @@ static int smu8_request_smu_load_fw(struct pp_hwmgr *hwmgr) | |||
658 | { | 658 | { |
659 | struct smu8_smumgr *smu8_smu = hwmgr->smu_backend; | 659 | struct smu8_smumgr *smu8_smu = hwmgr->smu_backend; |
660 | uint32_t smc_address; | 660 | uint32_t smc_address; |
661 | uint32_t fw_to_check = 0; | ||
662 | int ret; | ||
661 | 663 | ||
662 | if (!hwmgr->reload_fw) { | 664 | amdgpu_ucode_init_bo(hwmgr->adev); |
663 | pr_info("skip reloading...\n"); | ||
664 | return 0; | ||
665 | } | ||
666 | 665 | ||
667 | smu8_smu_populate_firmware_entries(hwmgr); | 666 | smu8_smu_populate_firmware_entries(hwmgr); |
668 | 667 | ||
@@ -689,28 +688,9 @@ static int smu8_request_smu_load_fw(struct pp_hwmgr *hwmgr) | |||
689 | smu8_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_ExecuteJob, | 688 | smu8_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_ExecuteJob, |
690 | smu8_smu->toc_entry_power_profiling_index); | 689 | smu8_smu->toc_entry_power_profiling_index); |
691 | 690 | ||
692 | return smu8_send_msg_to_smc_with_parameter(hwmgr, | 691 | smu8_send_msg_to_smc_with_parameter(hwmgr, |
693 | PPSMC_MSG_ExecuteJob, | 692 | PPSMC_MSG_ExecuteJob, |
694 | smu8_smu->toc_entry_initialize_index); | 693 | smu8_smu->toc_entry_initialize_index); |
695 | } | ||
696 | |||
697 | static int smu8_start_smu(struct pp_hwmgr *hwmgr) | ||
698 | { | ||
699 | int ret = 0; | ||
700 | uint32_t fw_to_check = 0; | ||
701 | struct amdgpu_device *adev = hwmgr->adev; | ||
702 | |||
703 | uint32_t index = SMN_MP1_SRAM_START_ADDR + | ||
704 | SMU8_FIRMWARE_HEADER_LOCATION + | ||
705 | offsetof(struct SMU8_Firmware_Header, Version); | ||
706 | |||
707 | |||
708 | if (hwmgr == NULL || hwmgr->device == NULL) | ||
709 | return -EINVAL; | ||
710 | |||
711 | cgs_write_register(hwmgr->device, mmMP0PUB_IND_INDEX, index); | ||
712 | hwmgr->smu_version = cgs_read_register(hwmgr->device, mmMP0PUB_IND_DATA); | ||
713 | adev->pm.fw_version = hwmgr->smu_version >> 8; | ||
714 | 694 | ||
715 | fw_to_check = UCODE_ID_RLC_G_MASK | | 695 | fw_to_check = UCODE_ID_RLC_G_MASK | |
716 | UCODE_ID_SDMA0_MASK | | 696 | UCODE_ID_SDMA0_MASK | |
@@ -724,8 +704,6 @@ static int smu8_start_smu(struct pp_hwmgr *hwmgr) | |||
724 | if (hwmgr->chip_id == CHIP_STONEY) | 704 | if (hwmgr->chip_id == CHIP_STONEY) |
725 | fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); | 705 | fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); |
726 | 706 | ||
727 | smu8_request_smu_load_fw(hwmgr); | ||
728 | |||
729 | ret = smu8_check_fw_load_finish(hwmgr, fw_to_check); | 707 | ret = smu8_check_fw_load_finish(hwmgr, fw_to_check); |
730 | if (ret) { | 708 | if (ret) { |
731 | pr_err("SMU firmware load failed\n"); | 709 | pr_err("SMU firmware load failed\n"); |
@@ -733,10 +711,31 @@ static int smu8_start_smu(struct pp_hwmgr *hwmgr) | |||
733 | } | 711 | } |
734 | 712 | ||
735 | ret = smu8_load_mec_firmware(hwmgr); | 713 | ret = smu8_load_mec_firmware(hwmgr); |
736 | if (ret) | 714 | if (ret) { |
737 | pr_err("Mec Firmware load failed\n"); | 715 | pr_err("Mec Firmware load failed\n"); |
716 | return ret; | ||
717 | } | ||
738 | 718 | ||
739 | return ret; | 719 | return 0; |
720 | } | ||
721 | |||
722 | static int smu8_start_smu(struct pp_hwmgr *hwmgr) | ||
723 | { | ||
724 | struct amdgpu_device *adev = hwmgr->adev; | ||
725 | |||
726 | uint32_t index = SMN_MP1_SRAM_START_ADDR + | ||
727 | SMU8_FIRMWARE_HEADER_LOCATION + | ||
728 | offsetof(struct SMU8_Firmware_Header, Version); | ||
729 | |||
730 | |||
731 | if (hwmgr == NULL || hwmgr->device == NULL) | ||
732 | return -EINVAL; | ||
733 | |||
734 | cgs_write_register(hwmgr->device, mmMP0PUB_IND_INDEX, index); | ||
735 | hwmgr->smu_version = cgs_read_register(hwmgr->device, mmMP0PUB_IND_DATA); | ||
736 | adev->pm.fw_version = hwmgr->smu_version >> 8; | ||
737 | |||
738 | return smu8_request_smu_load_fw(hwmgr); | ||
740 | } | 739 | } |
741 | 740 | ||
742 | static int smu8_smu_init(struct pp_hwmgr *hwmgr) | 741 | static int smu8_smu_init(struct pp_hwmgr *hwmgr) |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c index ae8378ed32ee..3ed6c5f1e5cf 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c | |||
@@ -192,6 +192,7 @@ static int tonga_start_in_non_protection_mode(struct pp_hwmgr *hwmgr) | |||
192 | 192 | ||
193 | static int tonga_start_smu(struct pp_hwmgr *hwmgr) | 193 | static int tonga_start_smu(struct pp_hwmgr *hwmgr) |
194 | { | 194 | { |
195 | struct tonga_smumgr *priv = hwmgr->smu_backend; | ||
195 | int result; | 196 | int result; |
196 | 197 | ||
197 | /* Only start SMC if SMC RAM is not running */ | 198 | /* Only start SMC if SMC RAM is not running */ |
@@ -209,6 +210,14 @@ static int tonga_start_smu(struct pp_hwmgr *hwmgr) | |||
209 | } | 210 | } |
210 | } | 211 | } |
211 | 212 | ||
213 | /* Setup SoftRegsStart here to visit the register UcodeLoadStatus | ||
214 | * to check fw loading state | ||
215 | */ | ||
216 | smu7_read_smc_sram_dword(hwmgr, | ||
217 | SMU72_FIRMWARE_HEADER_LOCATION + | ||
218 | offsetof(SMU72_Firmware_Header, SoftRegisters), | ||
219 | &(priv->smu7_data.soft_regs_start), 0x40000); | ||
220 | |||
212 | result = smu7_request_smu_load_fw(hwmgr); | 221 | result = smu7_request_smu_load_fw(hwmgr); |
213 | 222 | ||
214 | return result; | 223 | return result; |
@@ -2619,6 +2628,7 @@ static uint32_t tonga_get_offsetof(uint32_t type, uint32_t member) | |||
2619 | case DRAM_LOG_BUFF_SIZE: | 2628 | case DRAM_LOG_BUFF_SIZE: |
2620 | return offsetof(SMU72_SoftRegisters, DRAM_LOG_BUFF_SIZE); | 2629 | return offsetof(SMU72_SoftRegisters, DRAM_LOG_BUFF_SIZE); |
2621 | } | 2630 | } |
2631 | break; | ||
2622 | case SMU_Discrete_DpmTable: | 2632 | case SMU_Discrete_DpmTable: |
2623 | switch (member) { | 2633 | switch (member) { |
2624 | case UvdBootLevel: | 2634 | case UvdBootLevel: |
@@ -2628,6 +2638,7 @@ static uint32_t tonga_get_offsetof(uint32_t type, uint32_t member) | |||
2628 | case LowSclkInterruptThreshold: | 2638 | case LowSclkInterruptThreshold: |
2629 | return offsetof(SMU72_Discrete_DpmTable, LowSclkInterruptThreshold); | 2639 | return offsetof(SMU72_Discrete_DpmTable, LowSclkInterruptThreshold); |
2630 | } | 2640 | } |
2641 | break; | ||
2631 | } | 2642 | } |
2632 | pr_warn("can't get the offset of type %x member %x\n", type, member); | 2643 | pr_warn("can't get the offset of type %x member %x\n", type, member); |
2633 | return 0; | 2644 | return 0; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c index 3d415fabbd93..9f71512b2510 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c | |||
@@ -2185,6 +2185,7 @@ static uint32_t vegam_get_offsetof(uint32_t type, uint32_t member) | |||
2185 | case DRAM_LOG_BUFF_SIZE: | 2185 | case DRAM_LOG_BUFF_SIZE: |
2186 | return offsetof(SMU75_SoftRegisters, DRAM_LOG_BUFF_SIZE); | 2186 | return offsetof(SMU75_SoftRegisters, DRAM_LOG_BUFF_SIZE); |
2187 | } | 2187 | } |
2188 | break; | ||
2188 | case SMU_Discrete_DpmTable: | 2189 | case SMU_Discrete_DpmTable: |
2189 | switch (member) { | 2190 | switch (member) { |
2190 | case UvdBootLevel: | 2191 | case UvdBootLevel: |
@@ -2194,6 +2195,7 @@ static uint32_t vegam_get_offsetof(uint32_t type, uint32_t member) | |||
2194 | case LowSclkInterruptThreshold: | 2195 | case LowSclkInterruptThreshold: |
2195 | return offsetof(SMU75_Discrete_DpmTable, LowSclkInterruptThreshold); | 2196 | return offsetof(SMU75_Discrete_DpmTable, LowSclkInterruptThreshold); |
2196 | } | 2197 | } |
2198 | break; | ||
2197 | } | 2199 | } |
2198 | pr_warn("can't get the offset of type %x member %x\n", type, member); | 2200 | pr_warn("can't get the offset of type %x member %x\n", type, member); |
2199 | return 0; | 2201 | return 0; |
diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c index 54324330b91f..f471537c852f 100644 --- a/drivers/gpu/drm/radeon/evergreen_cs.c +++ b/drivers/gpu/drm/radeon/evergreen_cs.c | |||
@@ -2416,7 +2416,7 @@ static int evergreen_packet3_check(struct radeon_cs_parser *p, | |||
2416 | size = radeon_get_ib_value(p, idx+1+(i*8)+1); | 2416 | size = radeon_get_ib_value(p, idx+1+(i*8)+1); |
2417 | if (p->rdev && (size + offset) > radeon_bo_size(reloc->robj)) { | 2417 | if (p->rdev && (size + offset) > radeon_bo_size(reloc->robj)) { |
2418 | /* force size to size of the buffer */ | 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 | ib[idx+1+(i*8)+1] = radeon_bo_size(reloc->robj) - offset; | 2420 | ib[idx+1+(i*8)+1] = radeon_bo_size(reloc->robj) - offset; |
2421 | } | 2421 | } |
2422 | 2422 | ||
diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 4e5e95c0cab5..3e22a54a99c2 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c | |||
@@ -467,8 +467,7 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity) | |||
467 | struct dma_fence *fence; | 467 | struct dma_fence *fence; |
468 | struct drm_sched_rq *rq; | 468 | struct drm_sched_rq *rq; |
469 | 469 | ||
470 | if (!spsc_queue_count(&entity->job_queue) == 0 || | 470 | if (spsc_queue_count(&entity->job_queue) || entity->num_rq_list <= 1) |
471 | entity->num_rq_list <= 1) | ||
472 | return; | 471 | return; |
473 | 472 | ||
474 | fence = READ_ONCE(entity->last_scheduled); | 473 | fence = READ_ONCE(entity->last_scheduled); |
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index b2a33bf1ef10..26b889f86670 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -247,20 +247,6 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, | |||
247 | } | 247 | } |
248 | EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); | 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 | void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) | 250 | void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) |
265 | { | 251 | { |
266 | unsigned i; | 252 | unsigned i; |
@@ -276,8 +262,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) | |||
276 | reservation_object_assert_held(pos->last->resv); | 262 | reservation_object_assert_held(pos->last->resv); |
277 | 263 | ||
278 | man = &pos->first->bdev->man[TTM_PL_TT]; | 264 | man = &pos->first->bdev->man[TTM_PL_TT]; |
279 | ttm_list_move_bulk_tail(&man->lru[i], &pos->first->lru, | 265 | list_bulk_move_tail(&man->lru[i], &pos->first->lru, |
280 | &pos->last->lru); | 266 | &pos->last->lru); |
281 | } | 267 | } |
282 | 268 | ||
283 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { | 269 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { |
@@ -291,8 +277,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) | |||
291 | reservation_object_assert_held(pos->last->resv); | 277 | reservation_object_assert_held(pos->last->resv); |
292 | 278 | ||
293 | man = &pos->first->bdev->man[TTM_PL_VRAM]; | 279 | man = &pos->first->bdev->man[TTM_PL_VRAM]; |
294 | ttm_list_move_bulk_tail(&man->lru[i], &pos->first->lru, | 280 | list_bulk_move_tail(&man->lru[i], &pos->first->lru, |
295 | &pos->last->lru); | 281 | &pos->last->lru); |
296 | } | 282 | } |
297 | 283 | ||
298 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { | 284 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { |
@@ -306,8 +292,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) | |||
306 | reservation_object_assert_held(pos->last->resv); | 292 | reservation_object_assert_held(pos->last->resv); |
307 | 293 | ||
308 | lru = &pos->first->bdev->glob->swap_lru[i]; | 294 | lru = &pos->first->bdev->glob->swap_lru[i]; |
309 | ttm_list_move_bulk_tail(lru, &pos->first->swap, | 295 | list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap); |
310 | &pos->last->swap); | ||
311 | } | 296 | } |
312 | } | 297 | } |
313 | EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail); | 298 | EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail); |