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

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>

authored by

Christian König and committed by
Alex Deucher
c4120d55 f06505b8

+17 -8
+7 -8
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
··· 92 92 MODULE_FIRMWARE(FIRMWARE_POLARIS10); 93 93 MODULE_FIRMWARE(FIRMWARE_POLARIS11); 94 94 95 - static void amdgpu_uvd_note_usage(struct amdgpu_device *adev); 96 95 static void amdgpu_uvd_idle_work_handler(struct work_struct *work); 97 96 98 97 int amdgpu_uvd_sw_init(struct amdgpu_device *adev) ··· 344 345 uint32_t handle = atomic_read(&adev->uvd.handles[i]); 345 346 if (handle != 0 && adev->uvd.filp[i] == filp) { 346 347 struct fence *fence; 347 - 348 - amdgpu_uvd_note_usage(adev); 349 348 350 349 r = amdgpu_uvd_get_destroy_msg(ring, handle, 351 350 false, &fence); ··· 910 913 return -EINVAL; 911 914 } 912 915 913 - amdgpu_uvd_note_usage(ctx.parser->adev); 914 - 915 916 return 0; 916 917 } 917 918 ··· 1109 1114 } 1110 1115 } 1111 1116 1112 - static void amdgpu_uvd_note_usage(struct amdgpu_device *adev) 1117 + void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring) 1113 1118 { 1119 + struct amdgpu_device *adev = ring->adev; 1114 1120 bool set_clocks = !cancel_delayed_work_sync(&adev->uvd.idle_work); 1115 - set_clocks &= schedule_delayed_work(&adev->uvd.idle_work, 1116 - UVD_IDLE_TIMEOUT); 1117 1121 1118 1122 if (set_clocks) { 1119 1123 if (adev->pm.dpm_enabled) { ··· 1121 1127 amdgpu_asic_set_uvd_clocks(adev, 53300, 40000); 1122 1128 } 1123 1129 } 1130 + } 1131 + 1132 + void amdgpu_uvd_ring_end_use(struct amdgpu_ring *ring) 1133 + { 1134 + schedule_delayed_work(&ring->adev->uvd.idle_work, UVD_IDLE_TIMEOUT); 1124 1135 }
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
··· 35 35 void amdgpu_uvd_free_handles(struct amdgpu_device *adev, 36 36 struct drm_file *filp); 37 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 41 #endif
+2
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
··· 797 797 .test_ib = uvd_v4_2_ring_test_ib, 798 798 .insert_nop = amdgpu_ring_insert_nop, 799 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 804 static void uvd_v4_2_set_ring_funcs(struct amdgpu_device *adev)
+2
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
··· 848 848 .test_ib = uvd_v5_0_ring_test_ib, 849 849 .insert_nop = amdgpu_ring_insert_nop, 850 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 855 static void uvd_v5_0_set_ring_funcs(struct amdgpu_device *adev)
+4
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
··· 1019 1019 .test_ib = uvd_v6_0_ring_test_ib, 1020 1020 .insert_nop = amdgpu_ring_insert_nop, 1021 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 1026 static const struct amdgpu_ring_funcs uvd_v6_0_ring_vm_funcs = { ··· 1038 1036 .test_ib = uvd_v6_0_ring_test_ib, 1039 1037 .insert_nop = amdgpu_ring_insert_nop, 1040 1038 .pad_ib = amdgpu_ring_generic_pad_ib, 1039 + .begin_use = amdgpu_uvd_ring_begin_use, 1040 + .end_use = amdgpu_uvd_ring_end_use, 1041 1041 }; 1042 1042 1043 1043 static void uvd_v6_0_set_ring_funcs(struct amdgpu_device *adev)