mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 11:33:36 -04:00
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>
This commit is contained in:
committed by
Alex Deucher
parent
b0960c3592
commit
bb5a2bdf36
@@ -375,4 +375,53 @@ void amdgpu_virt_init_data_exchange(struct amdgpu_device *adev)
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t parse_clk(char *buf, bool min)
|
||||
{
|
||||
char *ptr = buf;
|
||||
uint32_t clk = 0;
|
||||
|
||||
do {
|
||||
ptr = strchr(ptr, ':');
|
||||
if (!ptr)
|
||||
break;
|
||||
ptr+=2;
|
||||
clk = simple_strtoul(ptr, NULL, 10);
|
||||
} while (!min);
|
||||
|
||||
return clk * 100;
|
||||
}
|
||||
|
||||
uint32_t amdgpu_virt_get_sclk(struct amdgpu_device *adev, bool lowest)
|
||||
{
|
||||
char *buf = NULL;
|
||||
uint32_t clk = 0;
|
||||
|
||||
buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
adev->virt.ops->get_pp_clk(adev, PP_SCLK, buf);
|
||||
clk = parse_clk(buf, lowest);
|
||||
|
||||
kfree(buf);
|
||||
|
||||
return clk;
|
||||
}
|
||||
|
||||
uint32_t amdgpu_virt_get_mclk(struct amdgpu_device *adev, bool lowest)
|
||||
{
|
||||
char *buf = NULL;
|
||||
uint32_t clk = 0;
|
||||
|
||||
buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
adev->virt.ops->get_pp_clk(adev, PP_MCLK, buf);
|
||||
clk = parse_clk(buf, lowest);
|
||||
|
||||
kfree(buf);
|
||||
|
||||
return clk;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user