aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
diff options
context:
space:
mode:
authorYintian Tao <yttao@amd.com>2019-04-09 08:33:20 -0400
committerAlex Deucher <alexander.deucher@amd.com>2019-04-10 14:53:27 -0400
commitbb5a2bdf36a8df79e1437b443299b7fe1ea3abfc (patch)
tree74af2ad9ead13464b323b6c22d95453af597dd87 /drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
parentb0960c3592a39f1cc6fcab1793158f3850f72c77 (diff)
drm/amdgpu: support dpm level modification under virtualization v3
Under vega10 virtualuzation, smu ip block will not be added. Therefore, we need add pp clk query and force dpm level function at amdgpu_virt_ops to support the feature. v2: add get_pp_clk existence check and use kzalloc to allocate buf v3: return -ENOMEM for allocation failure and correct the coding style Signed-off-by: Yintian Tao <yttao@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 462a04e0f5e6..7e7f9ed89ee1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -375,4 +375,53 @@ void amdgpu_virt_init_data_exchange(struct amdgpu_device *adev)
375 } 375 }
376} 376}
377 377
378static uint32_t parse_clk(char *buf, bool min)
379{
380 char *ptr = buf;
381 uint32_t clk = 0;
382
383 do {
384 ptr = strchr(ptr, ':');
385 if (!ptr)
386 break;
387 ptr+=2;
388 clk = simple_strtoul(ptr, NULL, 10);
389 } while (!min);
390
391 return clk * 100;
392}
393
394uint32_t amdgpu_virt_get_sclk(struct amdgpu_device *adev, bool lowest)
395{
396 char *buf = NULL;
397 uint32_t clk = 0;
398
399 buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
400 if (!buf)
401 return -ENOMEM;
402
403 adev->virt.ops->get_pp_clk(adev, PP_SCLK, buf);
404 clk = parse_clk(buf, lowest);
405
406 kfree(buf);
407
408 return clk;
409}
410
411uint32_t amdgpu_virt_get_mclk(struct amdgpu_device *adev, bool lowest)
412{
413 char *buf = NULL;
414 uint32_t clk = 0;
415
416 buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
417 if (!buf)
418 return -ENOMEM;
419
420 adev->virt.ops->get_pp_clk(adev, PP_MCLK, buf);
421 clk = parse_clk(buf, lowest);
422
423 kfree(buf);
424
425 return clk;
426}
378 427