Re: [PATCH 09/11] accel/ivpu/40xx: Capture D0i3 entry host and device timestamps

2023-10-27 Thread Jeffrey Hugo

On 10/25/2023 3:43 AM, Stanislaw Gruszka wrote:

From: Andrzej Kacprowski 

The driver needs to capture the D0i3 entry timestamp to
calculate D0i3 residency time.

The D0i3 residency time and the VPU timestamp are passed
to the firmware at D0i3 exit (warm boot).

Signed-off-by: Andrzej Kacprowski 
Reviewed-by: Stanislaw Gruszka 
Signed-off-by: Stanislaw Gruszka 


Feels like this should be applied before patch 8, otherwise this fixes a 
bug introduced by patch 8.


Reviewed-by: Jeffrey Hugo 


[PATCH 09/11] accel/ivpu/40xx: Capture D0i3 entry host and device timestamps

2023-10-25 Thread Stanislaw Gruszka
From: Andrzej Kacprowski 

The driver needs to capture the D0i3 entry timestamp to
calculate D0i3 residency time.

The D0i3 residency time and the VPU timestamp are passed
to the firmware at D0i3 exit (warm boot).

Signed-off-by: Andrzej Kacprowski 
Reviewed-by: Stanislaw Gruszka 
Signed-off-by: Stanislaw Gruszka 
---
 drivers/accel/ivpu/ivpu_hw_40xx.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/accel/ivpu/ivpu_hw_40xx.c 
b/drivers/accel/ivpu/ivpu_hw_40xx.c
index 5876cfd9dd40..d8df2addd18a 100644
--- a/drivers/accel/ivpu/ivpu_hw_40xx.c
+++ b/drivers/accel/ivpu/ivpu_hw_40xx.c
@@ -909,10 +909,18 @@ static bool ivpu_hw_40xx_is_idle(struct ivpu_device *vdev)
   REG_TEST_FLD(VPU_40XX_BUTTRESS_VPU_STATUS, IDLE, val);
 }
 
+static void ivpu_hw_40xx_save_d0i3_entry_timestamp(struct ivpu_device *vdev)
+{
+   vdev->hw->d0i3_entry_host_ts = ktime_get_boottime();
+   vdev->hw->d0i3_entry_vpu_ts = 
REGV_RD64(VPU_40XX_CPU_SS_TIM_PERF_EXT_FREE_CNT);
+}
+
 static int ivpu_hw_40xx_power_down(struct ivpu_device *vdev)
 {
int ret = 0;
 
+   ivpu_hw_40xx_save_d0i3_entry_timestamp(vdev);
+
if (!ivpu_hw_40xx_is_idle(vdev) && ivpu_hw_40xx_ip_reset(vdev))
ivpu_warn(vdev, "Failed to reset the VPU\n");
 
-- 
2.25.1