Skip to content

Commit 3de6d95

Browse files
Andrzej Kacprowskisgruszka
authored andcommitted
accel/ivpu: Pass D0i3 residency time to the VPU firmware
The firmware needs to know the time spent in D0i3/D3 to calculate telemetry data. The D0i3/D3 residency time is calculated by the driver and passed to the firmware in the boot parameters. The driver also passes VPU perf counter value captured right before entering D0i3 - this allows the VPU firmware to generate monotonic timestamps for the logs. Signed-off-by: Andrzej Kacprowski <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Signed-off-by: Stanislaw Gruszka <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent db37a5b commit 3de6d95

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

drivers/accel/ivpu/ivpu_fw.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,27 @@ static void ivpu_fw_boot_params_print(struct ivpu_device *vdev, struct vpu_boot_
426426
boot_params->vpu_telemetry_enable);
427427
ivpu_dbg(vdev, FW_BOOT, "boot_params.dvfs_mode = %u\n",
428428
boot_params->dvfs_mode);
429+
ivpu_dbg(vdev, FW_BOOT, "boot_params.d0i3_residency_time_us = %lld\n",
430+
boot_params->d0i3_residency_time_us);
431+
ivpu_dbg(vdev, FW_BOOT, "boot_params.d0i3_entry_vpu_ts = %llu\n",
432+
boot_params->d0i3_entry_vpu_ts);
429433
}
430434

431435
void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params *boot_params)
432436
{
433437
struct ivpu_bo *ipc_mem_rx = vdev->ipc->mem_rx;
434438

435-
/* In case of warm boot we only have to reset the entrypoint addr */
439+
/* In case of warm boot only update variable params */
436440
if (!ivpu_fw_is_cold_boot(vdev)) {
441+
boot_params->d0i3_residency_time_us =
442+
ktime_us_delta(ktime_get_boottime(), vdev->hw->d0i3_entry_host_ts);
443+
boot_params->d0i3_entry_vpu_ts = vdev->hw->d0i3_entry_vpu_ts;
444+
445+
ivpu_dbg(vdev, FW_BOOT, "boot_params.d0i3_residency_time_us = %lld\n",
446+
boot_params->d0i3_residency_time_us);
447+
ivpu_dbg(vdev, FW_BOOT, "boot_params.d0i3_entry_vpu_ts = %llu\n",
448+
boot_params->d0i3_entry_vpu_ts);
449+
437450
boot_params->save_restore_ret_address = 0;
438451
vdev->pm->is_warmboot = true;
439452
return;
@@ -497,6 +510,8 @@ void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params
497510
boot_params->punit_telemetry_sram_size = ivpu_hw_reg_telemetry_size_get(vdev);
498511
boot_params->vpu_telemetry_enable = ivpu_hw_reg_telemetry_enable_get(vdev);
499512
boot_params->dvfs_mode = vdev->fw->dvfs_mode;
513+
boot_params->d0i3_residency_time_us = 0;
514+
boot_params->d0i3_entry_vpu_ts = 0;
500515

501516
wmb(); /* Flush WC buffers after writing bootparams */
502517

drivers/accel/ivpu/ivpu_hw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ struct ivpu_hw_info {
5757
u32 sku;
5858
u16 config;
5959
int dma_bits;
60+
ktime_t d0i3_entry_host_ts;
61+
u64 d0i3_entry_vpu_ts;
6062
};
6163

6264
extern const struct ivpu_hw_ops ivpu_hw_37xx_ops;

drivers/accel/ivpu/ivpu_hw_37xx.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,18 @@ static bool ivpu_hw_37xx_is_idle(struct ivpu_device *vdev)
714714
REG_TEST_FLD(VPU_37XX_BUTTRESS_VPU_STATUS, IDLE, val);
715715
}
716716

717+
static void ivpu_hw_37xx_save_d0i3_entry_timestamp(struct ivpu_device *vdev)
718+
{
719+
vdev->hw->d0i3_entry_host_ts = ktime_get_boottime();
720+
vdev->hw->d0i3_entry_vpu_ts = REGV_RD64(VPU_37XX_CPU_SS_TIM_PERF_FREE_CNT);
721+
}
722+
717723
static int ivpu_hw_37xx_power_down(struct ivpu_device *vdev)
718724
{
719725
int ret = 0;
720726

727+
ivpu_hw_37xx_save_d0i3_entry_timestamp(vdev);
728+
721729
if (!ivpu_hw_37xx_is_idle(vdev) && ivpu_hw_37xx_reset(vdev))
722730
ivpu_err(vdev, "Failed to reset the VPU\n");
723731

drivers/accel/ivpu/ivpu_hw_37xx_reg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@
240240
#define VPU_37XX_CPU_SS_TIM_GEN_CONFIG 0x06021008u
241241
#define VPU_37XX_CPU_SS_TIM_GEN_CONFIG_WDOG_TO_INT_CLR_MASK BIT_MASK(9)
242242

243+
#define VPU_37XX_CPU_SS_TIM_PERF_FREE_CNT 0x06029000u
244+
243245
#define VPU_37XX_CPU_SS_DOORBELL_0 0x06300000u
244246
#define VPU_37XX_CPU_SS_DOORBELL_0_SET_MASK BIT_MASK(0)
245247

0 commit comments

Comments
 (0)