diff options
author | Christian König <christian.koenig@amd.com> | 2016-07-20 08:11:26 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-07-29 14:37:02 -0400 |
commit | c4120d55ffa44746584a8a1e5b00cb7eafc006ff (patch) | |
tree | dec6c56127a8eb837f22f4bd76d62d70cade570e | |
parent | f06505b8d27119202d76aeb1b80b2ca352c9567e (diff) |
drm/amdgpu: use begin/end_use for UVD power/clock gating
This fixes turning power and clock on when it is actually needed.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 15 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 4 |
5 files changed, 17 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c index b1bbe50f93e1..bfb3c274d7f0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | |||
@@ -92,7 +92,6 @@ MODULE_FIRMWARE(FIRMWARE_STONEY); | |||
92 | MODULE_FIRMWARE(FIRMWARE_POLARIS10); | 92 | MODULE_FIRMWARE(FIRMWARE_POLARIS10); |
93 | MODULE_FIRMWARE(FIRMWARE_POLARIS11); | 93 | MODULE_FIRMWARE(FIRMWARE_POLARIS11); |
94 | 94 | ||
95 | static void amdgpu_uvd_note_usage(struct amdgpu_device *adev); | ||
96 | static void amdgpu_uvd_idle_work_handler(struct work_struct *work); | 95 | static void amdgpu_uvd_idle_work_handler(struct work_struct *work); |
97 | 96 | ||
98 | int amdgpu_uvd_sw_init(struct amdgpu_device *adev) | 97 | int amdgpu_uvd_sw_init(struct amdgpu_device *adev) |
@@ -346,8 +345,6 @@ void amdgpu_uvd_free_handles(struct amdgpu_device *adev, struct drm_file *filp) | |||
346 | if (handle != 0 && adev->uvd.filp[i] == filp) { | 345 | if (handle != 0 && adev->uvd.filp[i] == filp) { |
347 | struct fence *fence; | 346 | struct fence *fence; |
348 | 347 | ||
349 | amdgpu_uvd_note_usage(adev); | ||
350 | |||
351 | r = amdgpu_uvd_get_destroy_msg(ring, handle, | 348 | r = amdgpu_uvd_get_destroy_msg(ring, handle, |
352 | false, &fence); | 349 | false, &fence); |
353 | if (r) { | 350 | if (r) { |
@@ -913,8 +910,6 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) | |||
913 | return -EINVAL; | 910 | return -EINVAL; |
914 | } | 911 | } |
915 | 912 | ||
916 | amdgpu_uvd_note_usage(ctx.parser->adev); | ||
917 | |||
918 | return 0; | 913 | return 0; |
919 | } | 914 | } |
920 | 915 | ||
@@ -1114,11 +1109,10 @@ static void amdgpu_uvd_idle_work_handler(struct work_struct *work) | |||
1114 | } | 1109 | } |
1115 | } | 1110 | } |
1116 | 1111 | ||
1117 | static void amdgpu_uvd_note_usage(struct amdgpu_device *adev) | 1112 | void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring) |
1118 | { | 1113 | { |
1114 | struct amdgpu_device *adev = ring->adev; | ||
1119 | bool set_clocks = !cancel_delayed_work_sync(&adev->uvd.idle_work); | 1115 | bool set_clocks = !cancel_delayed_work_sync(&adev->uvd.idle_work); |
1120 | set_clocks &= schedule_delayed_work(&adev->uvd.idle_work, | ||
1121 | UVD_IDLE_TIMEOUT); | ||
1122 | 1116 | ||
1123 | if (set_clocks) { | 1117 | if (set_clocks) { |
1124 | if (adev->pm.dpm_enabled) { | 1118 | if (adev->pm.dpm_enabled) { |
@@ -1128,3 +1122,8 @@ static void amdgpu_uvd_note_usage(struct amdgpu_device *adev) | |||
1128 | } | 1122 | } |
1129 | } | 1123 | } |
1130 | } | 1124 | } |
1125 | |||
1126 | void amdgpu_uvd_ring_end_use(struct amdgpu_ring *ring) | ||
1127 | { | ||
1128 | schedule_delayed_work(&ring->adev->uvd.idle_work, UVD_IDLE_TIMEOUT); | ||
1129 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h index 9a3b449081a7..5bad3712a56e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | |||
@@ -35,5 +35,7 @@ int amdgpu_uvd_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, | |||
35 | void amdgpu_uvd_free_handles(struct amdgpu_device *adev, | 35 | void amdgpu_uvd_free_handles(struct amdgpu_device *adev, |
36 | struct drm_file *filp); | 36 | struct drm_file *filp); |
37 | int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx); | 37 | int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx); |
38 | void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring); | ||
39 | void amdgpu_uvd_ring_end_use(struct amdgpu_ring *ring); | ||
38 | 40 | ||
39 | #endif | 41 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c index 416c8567d3ed..862d6cf89c1a 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | |||
@@ -797,6 +797,8 @@ static const struct amdgpu_ring_funcs uvd_v4_2_ring_funcs = { | |||
797 | .test_ib = uvd_v4_2_ring_test_ib, | 797 | .test_ib = uvd_v4_2_ring_test_ib, |
798 | .insert_nop = amdgpu_ring_insert_nop, | 798 | .insert_nop = amdgpu_ring_insert_nop, |
799 | .pad_ib = amdgpu_ring_generic_pad_ib, | 799 | .pad_ib = amdgpu_ring_generic_pad_ib, |
800 | .begin_use = amdgpu_uvd_ring_begin_use, | ||
801 | .end_use = amdgpu_uvd_ring_end_use, | ||
800 | }; | 802 | }; |
801 | 803 | ||
802 | static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev) | 804 | static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c index dd636c4c4b08..f585247a356f 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | |||
@@ -848,6 +848,8 @@ static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = { | |||
848 | .test_ib = uvd_v5_0_ring_test_ib, | 848 | .test_ib = uvd_v5_0_ring_test_ib, |
849 | .insert_nop = amdgpu_ring_insert_nop, | 849 | .insert_nop = amdgpu_ring_insert_nop, |
850 | .pad_ib = amdgpu_ring_generic_pad_ib, | 850 | .pad_ib = amdgpu_ring_generic_pad_ib, |
851 | .begin_use = amdgpu_uvd_ring_begin_use, | ||
852 | .end_use = amdgpu_uvd_ring_end_use, | ||
851 | }; | 853 | }; |
852 | 854 | ||
853 | static void uvd_v5_0_set_ring_funcs(struct amdgpu_device *adev) | 855 | static void uvd_v5_0_set_ring_funcs(struct amdgpu_device *adev) |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index 358608ea4cfd..8e985de62780 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | |||
@@ -1019,6 +1019,8 @@ static const struct amdgpu_ring_funcs uvd_v6_0_ring_phys_funcs = { | |||
1019 | .test_ib = uvd_v6_0_ring_test_ib, | 1019 | .test_ib = uvd_v6_0_ring_test_ib, |
1020 | .insert_nop = amdgpu_ring_insert_nop, | 1020 | .insert_nop = amdgpu_ring_insert_nop, |
1021 | .pad_ib = amdgpu_ring_generic_pad_ib, | 1021 | .pad_ib = amdgpu_ring_generic_pad_ib, |
1022 | .begin_use = amdgpu_uvd_ring_begin_use, | ||
1023 | .end_use = amdgpu_uvd_ring_end_use, | ||
1022 | }; | 1024 | }; |
1023 | 1025 | ||
1024 | static const struct amdgpu_ring_funcs uvd_v6_0_ring_vm_funcs = { | 1026 | static const struct amdgpu_ring_funcs uvd_v6_0_ring_vm_funcs = { |
@@ -1036,6 +1038,8 @@ static const struct amdgpu_ring_funcs uvd_v6_0_ring_vm_funcs = { | |||
1036 | .test_ib = uvd_v6_0_ring_test_ib, | 1038 | .test_ib = uvd_v6_0_ring_test_ib, |
1037 | .insert_nop = amdgpu_ring_insert_nop, | 1039 | .insert_nop = amdgpu_ring_insert_nop, |
1038 | .pad_ib = amdgpu_ring_generic_pad_ib, | 1040 | .pad_ib = amdgpu_ring_generic_pad_ib, |
1041 | .begin_use = amdgpu_uvd_ring_begin_use, | ||
1042 | .end_use = amdgpu_uvd_ring_end_use, | ||
1039 | }; | 1043 | }; |
1040 | 1044 | ||
1041 | static void uvd_v6_0_set_ring_funcs(struct amdgpu_device *adev) | 1045 | static void uvd_v6_0_set_ring_funcs(struct amdgpu_device *adev) |