diff options
author | Rex Zhu <Rex.Zhu@amd.com> | 2018-08-14 01:32:30 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-08-27 12:11:00 -0400 |
commit | 1112a46b48b74766bd957742c853c8a582a81991 (patch) | |
tree | d51b76c2c7c51f44fc8beadbce30695f3ede2527 /drivers/gpu/drm/amd/amdgpu | |
parent | 8ab5617279507044682248f47c3afa9f753d8fe3 (diff) |
drm/amdgpu: Refine function name and function args
There are no any logical changes here.
1. change function names:
amdgpu_device_ip_late_set_pg/cg_state to
amdgpu_device_set_pg/cg_state.
2. add a function argument cg/pg_state, so
we can enable/disable cg/pg through those functions
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 0b4815c1e181..04fbc63a83b7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -1690,24 +1690,26 @@ static bool amdgpu_device_check_vram_lost(struct amdgpu_device *adev) | |||
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | /** | 1692 | /** |
1693 | * amdgpu_device_ip_late_set_cg_state - late init for clockgating | 1693 | * amdgpu_device_set_cg_state - set clockgating for amdgpu device |
1694 | * | 1694 | * |
1695 | * @adev: amdgpu_device pointer | 1695 | * @adev: amdgpu_device pointer |
1696 | * | 1696 | * |
1697 | * Late initialization pass enabling clockgating for hardware IPs. | ||
1698 | * The list of all the hardware IPs that make up the asic is walked and the | 1697 | * The list of all the hardware IPs that make up the asic is walked and the |
1699 | * set_clockgating_state callbacks are run. This stage is run late | 1698 | * set_clockgating_state callbacks are run. |
1700 | * in the init process. | 1699 | * Late initialization pass enabling clockgating for hardware IPs. |
1700 | * Fini or suspend, pass disabling clockgating for hardware IPs. | ||
1701 | * Returns 0 on success, negative error code on failure. | 1701 | * Returns 0 on success, negative error code on failure. |
1702 | */ | 1702 | */ |
1703 | static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev) | 1703 | static int amdgpu_device_set_cg_state(struct amdgpu_device *adev, |
1704 | enum amd_clockgating_state state) | ||
1704 | { | 1705 | { |
1705 | int i = 0, r; | 1706 | int i, j, r; |
1706 | 1707 | ||
1707 | if (amdgpu_emu_mode == 1) | 1708 | if (amdgpu_emu_mode == 1) |
1708 | return 0; | 1709 | return 0; |
1709 | 1710 | ||
1710 | for (i = 0; i < adev->num_ip_blocks; i++) { | 1711 | for (j = 0; j < adev->num_ip_blocks; j++) { |
1712 | i = state == AMD_CG_STATE_GATE ? j : adev->num_ip_blocks - j - 1; | ||
1711 | if (!adev->ip_blocks[i].status.valid) | 1713 | if (!adev->ip_blocks[i].status.valid) |
1712 | continue; | 1714 | continue; |
1713 | /* skip CG for VCE/UVD, it's handled specially */ | 1715 | /* skip CG for VCE/UVD, it's handled specially */ |
@@ -1717,7 +1719,7 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev) | |||
1717 | adev->ip_blocks[i].version->funcs->set_clockgating_state) { | 1719 | adev->ip_blocks[i].version->funcs->set_clockgating_state) { |
1718 | /* enable clockgating to save power */ | 1720 | /* enable clockgating to save power */ |
1719 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, | 1721 | r = adev->ip_blocks[i].version->funcs->set_clockgating_state((void *)adev, |
1720 | AMD_CG_STATE_GATE); | 1722 | state); |
1721 | if (r) { | 1723 | if (r) { |
1722 | DRM_ERROR("set_clockgating_state(gate) of IP block <%s> failed %d\n", | 1724 | DRM_ERROR("set_clockgating_state(gate) of IP block <%s> failed %d\n", |
1723 | adev->ip_blocks[i].version->funcs->name, r); | 1725 | adev->ip_blocks[i].version->funcs->name, r); |
@@ -1729,14 +1731,15 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev) | |||
1729 | return 0; | 1731 | return 0; |
1730 | } | 1732 | } |
1731 | 1733 | ||
1732 | static int amdgpu_device_ip_late_set_pg_state(struct amdgpu_device *adev) | 1734 | static int amdgpu_device_set_pg_state(struct amdgpu_device *adev, enum amd_powergating_state state) |
1733 | { | 1735 | { |
1734 | int i = 0, r; | 1736 | int i, j, r; |
1735 | 1737 | ||
1736 | if (amdgpu_emu_mode == 1) | 1738 | if (amdgpu_emu_mode == 1) |
1737 | return 0; | 1739 | return 0; |
1738 | 1740 | ||
1739 | for (i = 0; i < adev->num_ip_blocks; i++) { | 1741 | for (j = 0; j < adev->num_ip_blocks; j++) { |
1742 | i = state == AMD_PG_STATE_GATE ? j : adev->num_ip_blocks - j - 1; | ||
1740 | if (!adev->ip_blocks[i].status.valid) | 1743 | if (!adev->ip_blocks[i].status.valid) |
1741 | continue; | 1744 | continue; |
1742 | /* skip CG for VCE/UVD, it's handled specially */ | 1745 | /* skip CG for VCE/UVD, it's handled specially */ |
@@ -1746,7 +1749,7 @@ static int amdgpu_device_ip_late_set_pg_state(struct amdgpu_device *adev) | |||
1746 | adev->ip_blocks[i].version->funcs->set_powergating_state) { | 1749 | adev->ip_blocks[i].version->funcs->set_powergating_state) { |
1747 | /* enable powergating to save power */ | 1750 | /* enable powergating to save power */ |
1748 | r = adev->ip_blocks[i].version->funcs->set_powergating_state((void *)adev, | 1751 | r = adev->ip_blocks[i].version->funcs->set_powergating_state((void *)adev, |
1749 | AMD_PG_STATE_GATE); | 1752 | state); |
1750 | if (r) { | 1753 | if (r) { |
1751 | DRM_ERROR("set_powergating_state(gate) of IP block <%s> failed %d\n", | 1754 | DRM_ERROR("set_powergating_state(gate) of IP block <%s> failed %d\n", |
1752 | adev->ip_blocks[i].version->funcs->name, r); | 1755 | adev->ip_blocks[i].version->funcs->name, r); |
@@ -1787,8 +1790,8 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev) | |||
1787 | } | 1790 | } |
1788 | } | 1791 | } |
1789 | 1792 | ||
1790 | amdgpu_device_ip_late_set_cg_state(adev); | 1793 | amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE); |
1791 | amdgpu_device_ip_late_set_pg_state(adev); | 1794 | amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE); |
1792 | 1795 | ||
1793 | queue_delayed_work(system_wq, &adev->late_init_work, | 1796 | queue_delayed_work(system_wq, &adev->late_init_work, |
1794 | msecs_to_jiffies(AMDGPU_RESUME_MS)); | 1797 | msecs_to_jiffies(AMDGPU_RESUME_MS)); |
@@ -1906,13 +1909,9 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) | |||
1906 | } | 1909 | } |
1907 | 1910 | ||
1908 | /** | 1911 | /** |
1909 | * amdgpu_device_ip_late_init_func_handler - work handler for clockgating | 1912 | * amdgpu_device_ip_late_init_func_handler - work handler for ib test |
1910 | * | ||
1911 | * @work: work_struct | ||
1912 | * | 1913 | * |
1913 | * Work handler for amdgpu_device_ip_late_set_cg_state. We put the | 1914 | * @work: work_struct. |
1914 | * clockgating setup into a worker thread to speed up driver init and | ||
1915 | * resume from suspend. | ||
1916 | */ | 1915 | */ |
1917 | static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work) | 1916 | static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work) |
1918 | { | 1917 | { |