Skip to contentSkip to conversation

accel/ivpu: Fix DCT active percent format

PATCH In review Karol Wachowski 2 participants 3 messages Oct 1, 2025 – Oct 2, 2025

Subsystems (2)
lore
Share & tools
lore

Karol Wachowski

author maintainer
#0 lore raw

PATCH 1/1 accel/ivpu: Fix DCT active percent format

The pcode MAILBOX STATUS register PARAM2 field expects DCT active percent in U1.7 value format. Convert percentage value to this format before writing to the register.

Fixes a19bffb10c46 ("accel/ivpu: Implement DCT handling")
---
 drivers/accel/ivpu/ivpu_hw_btrs.c | 2 +-
 drivers/accel/ivpu/ivpu_hw_btrs.h | 2 +-
 drivers/accel/ivpu/ivpu_pm.c      | 9 +++++++--
 3 files changed, 9 insertions(+), 4 deletions(-)
drivers/accel/ivpu/ivpu_hw_btrs.c +1 -1
index afdb3b2aa72a..aa33f562d29c 100644
@@ -752,7 +752,7 @@ int ivpu_hw_btrs_dct_get_request(struct ivpu_device *vdev, bool *enable)
 	}
 }
 
-void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u32 active_percent)
+void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u8 active_percent)
 {
 	u32 val = 0;
 	u32 cmd = enable ? DCT_ENABLE : DCT_DISABLE;
drivers/accel/ivpu/ivpu_hw_btrs.h +1 -1
index 032c384ac3d4..c4c10e22f30f 100644
@@ -36,7 +36,7 @@ u32 ivpu_hw_btrs_dpu_freq_get(struct ivpu_device *vdev);
 bool ivpu_hw_btrs_irq_handler_mtl(struct ivpu_device *vdev, int irq);
 bool ivpu_hw_btrs_irq_handler_lnl(struct ivpu_device *vdev, int irq);
 int ivpu_hw_btrs_dct_get_request(struct ivpu_device *vdev, bool *enable);
-void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u32 active_percent);
+void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u8 active_percent);
 u32 ivpu_hw_btrs_telemetry_offset_get(struct ivpu_device *vdev);
 u32 ivpu_hw_btrs_telemetry_size_get(struct ivpu_device *vdev);
 u32 ivpu_hw_btrs_telemetry_enable_get(struct ivpu_device *vdev);
drivers/accel/ivpu/ivpu_pm.c +7 -2
index 7514f580eef4..63c95307faa1 100644
@@ -502,6 +502,11 @@ void ivpu_pm_irq_dct_work_fn(struct work_struct *work)
 	else
 		ret = ivpu_pm_dct_disable(vdev);
 
-	if (!ret)
-		ivpu_hw_btrs_dct_set_status(vdev, enable, vdev->pm->dct_active_percent);
+	if (!ret) {
+		/* Convert percent to U1.7 format */
+		u8 val = DIV_ROUND_CLOSEST(vdev->pm->dct_active_percent * 128, 100);
+
+		ivpu_hw_btrs_dct_set_status(vdev, enable, val);
+	}
+
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 56 lines · Karol Wachowski

The pcode MAILBOX STATUS register PARAM2 field expects DCT active percent in U1.7 value format. Convert percentage value to this format before writing to the register.

Fixes a19bffb10c46 ("accel/ivpu: Implement DCT handling")
---
  drivers/accel/ivpu/ivpu_hw_btrs.c | 2 +-
  drivers/accel/ivpu/ivpu_hw_btrs.h | 2 +-
  drivers/accel/ivpu/ivpu_pm.c      | 9 +++++++--
  3 files changed, 9 insertions(+), 4 deletions(-)
drivers/accel/ivpu/ivpu_hw_btrs.c +1 -1
index afdb3b2aa72a..aa33f562d29c 100644
@@ -752,7 +752,7 @@ int ivpu_hw_btrs_dct_get_request(struct ivpu_device *vdev, bool *enable)
  	}
  }
 
-void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u32 active_percent)
+void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u8 active_percent)
  {
  	u32 val = 0;
  	u32 cmd = enable ? DCT_ENABLE : DCT_DISABLE;
drivers/accel/ivpu/ivpu_hw_btrs.h +1 -1
index 032c384ac3d4..c4c10e22f30f 100644
@@ -36,7 +36,7 @@ u32 ivpu_hw_btrs_dpu_freq_get(struct ivpu_device *vdev);
  bool ivpu_hw_btrs_irq_handler_mtl(struct ivpu_device *vdev, int irq);
  bool ivpu_hw_btrs_irq_handler_lnl(struct ivpu_device *vdev, int irq);
  int ivpu_hw_btrs_dct_get_request(struct ivpu_device *vdev, bool *enable);
-void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u32 active_percent);
+void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u8 active_percent);
  u32 ivpu_hw_btrs_telemetry_offset_get(struct ivpu_device *vdev);
  u32 ivpu_hw_btrs_telemetry_size_get(struct ivpu_device *vdev);
  u32 ivpu_hw_btrs_telemetry_enable_get(struct ivpu_device *vdev);
drivers/accel/ivpu/ivpu_pm.c +7 -2
index 7514f580eef4..63c95307faa1 100644
@@ -502,6 +502,11 @@ void ivpu_pm_irq_dct_work_fn(struct work_struct *work)
  	else
  		ret = ivpu_pm_dct_disable(vdev);
 
-	if (!ret)
-		ivpu_hw_btrs_dct_set_status(vdev, enable, vdev->pm->dct_active_percent);
+	if (!ret) {
+		/* Convert percent to U1.7 format */
+		u8 val = DIV_ROUND_CLOSEST(vdev->pm->dct_active_percent * 128, 100);
+
+		ivpu_hw_btrs_dct_set_status(vdev, enable, val);
+	}
+
  }
author maintainer Applied
#2 lore raw

Applied to drm-misc-next

Quoted 69 lines · Lizhi Hou
Quoted 66 lines · Karol Wachowski

The pcode MAILBOX STATUS register PARAM2 field expects DCT active percent in U1.7 value format. Convert percentage value to this format before writing to the register.

Fixes a19bffb10c46 ("accel/ivpu: Implement DCT handling")

---
  drivers/accel/ivpu/ivpu_hw_btrs.c | 2 +-
  drivers/accel/ivpu/ivpu_hw_btrs.h | 2 +-
  drivers/accel/ivpu/ivpu_pm.c      | 9 +++++++--

  3 files changed, 9 insertions(+), 4 deletions(-)
drivers/accel/ivpu/ivpu_hw_btrs.c +0 -0
index afdb3b2aa72a..aa33f562d29c 100644
@@ -752,7 +752,7 @@ int ivpu_hw_btrs_dct_get_request(struct
 ivpu_device *vdev, bool *enable)
       }
   }

  -void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u32 active_percent)
+void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u8 active_percent)
  {
      u32 val = 0;
      u32 cmd = enable ? DCT_ENABLE : DCT_DISABLE;

drivers/accel/ivpu/ivpu_hw_btrs.h +0 -0
index 032c384ac3d4..c4c10e22f30f 100644
@@ -36,7 +36,7 @@ u32 ivpu_hw_btrs_dpu_freq_get(struct ivpu_device
 *vdev);
   bool ivpu_hw_btrs_irq_handler_mtl(struct ivpu_device *vdev, int irq);
   bool ivpu_hw_btrs_irq_handler_lnl(struct ivpu_device *vdev, int irq);

  int ivpu_hw_btrs_dct_get_request(struct ivpu_device *vdev, bool *enable);
-void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u32 active_percent);
+void ivpu_hw_btrs_dct_set_status(struct ivpu_device *vdev, bool enable, u8 active_percent);
  u32 ivpu_hw_btrs_telemetry_offset_get(struct ivpu_device *vdev); u32 ivpu_hw_btrs_telemetry_size_get(struct ivpu_device *vdev); u32 ivpu_hw_btrs_telemetry_enable_get(struct ivpu_device *vdev);

drivers/accel/ivpu/ivpu_pm.c +0 -0
index 7514f580eef4..63c95307faa1 100644
@@ -502,6 +502,11 @@ void ivpu_pm_irq_dct_work_fn(struct work_struct
 *work)

      else
          ret = ivpu_pm_dct_disable(vdev);
  -    if (!ret)
-        ivpu_hw_btrs_dct_set_status(vdev, enable, vdev->pm->dct_active_percent);
+    if (!ret) {
+        /* Convert percent to U1.7 format */
+        u8 val = DIV_ROUND_CLOSEST(vdev->pm->dct_active_percent * 128, 100);

drivers/accel/ivpu/ivpu_pm.c +4 -0
+
+        ivpu_hw_btrs_dct_set_status(vdev, enable, val);
+    }
+

  }