Skip to content

Commit 252776b

Browse files
sgruszkajlawryno
authored andcommitted
accel/ivpu: Fix VPU clock calculation
The driver calculates the wrong frequency because it ignores the workpoint config and this cause undesired power/performance characteristics. Fix this by using the workpoint config in the freq calculations. Fixes: 35b1376 ("accel/ivpu: Introduce a new DRM driver for Intel VPU") Co-developed-by: Andrzej Kacprowski <[email protected]> Signed-off-by: Andrzej Kacprowski <[email protected]> Signed-off-by: Stanislaw Gruszka <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Signed-off-by: Jacek Lawrynowicz <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 392b35b commit 252776b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/accel/ivpu/ivpu_hw_mtl.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#define PLL_REF_CLK_FREQ (50 * 1000000)
3131
#define PLL_SIMULATION_FREQ (10 * 1000000)
32-
#define PLL_RATIO_TO_FREQ(x) ((x) * PLL_REF_CLK_FREQ)
3332
#define PLL_DEFAULT_EPP_VALUE 0x80
3433

3534
#define TIM_SAFE_ENABLE 0xf1d0dead
@@ -789,6 +788,19 @@ static void ivpu_hw_mtl_wdt_disable(struct ivpu_device *vdev)
789788
REGV_WR32(MTL_VPU_CPU_SS_TIM_GEN_CONFIG, val);
790789
}
791790

791+
static u32 ivpu_hw_mtl_pll_to_freq(u32 ratio, u32 config)
792+
{
793+
u32 pll_clock = PLL_REF_CLK_FREQ * ratio;
794+
u32 cpu_clock;
795+
796+
if ((config & 0xff) == PLL_RATIO_4_3)
797+
cpu_clock = pll_clock * 2 / 4;
798+
else
799+
cpu_clock = pll_clock * 2 / 5;
800+
801+
return cpu_clock;
802+
}
803+
792804
/* Register indirect accesses */
793805
static u32 ivpu_hw_mtl_reg_pll_freq_get(struct ivpu_device *vdev)
794806
{
@@ -800,7 +812,7 @@ static u32 ivpu_hw_mtl_reg_pll_freq_get(struct ivpu_device *vdev)
800812
if (!ivpu_is_silicon(vdev))
801813
return PLL_SIMULATION_FREQ;
802814

803-
return PLL_RATIO_TO_FREQ(pll_curr_ratio);
815+
return ivpu_hw_mtl_pll_to_freq(pll_curr_ratio, vdev->hw->config);
804816
}
805817

806818
static u32 ivpu_hw_mtl_reg_telemetry_offset_get(struct ivpu_device *vdev)

0 commit comments

Comments
 (0)