accel/ivpu: Add dvfs_mode file to debugfs
authorTomasz Rusinowicz <tomasz.rusinowicz@intel.com>
Sat, 28 Oct 2023 13:34:07 +0000 (15:34 +0200)
committerStanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Mon, 30 Oct 2023 10:06:09 +0000 (11:06 +0100)
Add new debugfs file to set dvfs_mode FW boot parameter and restart
the FW to allow experimenting with DVFS (dynamic voltage & frequency
scaling).

Signed-off-by: Tomasz Rusinowicz <tomasz.rusinowicz@intel.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231028133415.1169975-4-stanislaw.gruszka@linux.intel.com
drivers/accel/ivpu/ivpu_debugfs.c
drivers/accel/ivpu/ivpu_fw.c
drivers/accel/ivpu/ivpu_fw.h

index ea453b985b49137a8e35f73b980f74d162890ba9..6e0d5682302417b7fb988821aff05c926b013fee 100644 (file)
@@ -115,6 +115,31 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = {
        {"reset_pending", reset_pending_show, 0},
 };
 
+static ssize_t
+dvfs_mode_fops_write(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
+{
+       struct ivpu_device *vdev = file->private_data;
+       struct ivpu_fw_info *fw = vdev->fw;
+       u32 dvfs_mode;
+       int ret;
+
+       ret = kstrtou32_from_user(user_buf, size, 0, &dvfs_mode);
+       if (ret < 0)
+               return ret;
+
+       fw->dvfs_mode = dvfs_mode;
+
+       ivpu_pm_schedule_recovery(vdev);
+
+       return size;
+}
+
+static const struct file_operations dvfs_mode_fops = {
+       .owner = THIS_MODULE,
+       .open = simple_open,
+       .write = dvfs_mode_fops_write,
+};
+
 static int fw_log_show(struct seq_file *s, void *v)
 {
        struct ivpu_device *vdev = s->private;
@@ -280,6 +305,9 @@ void ivpu_debugfs_init(struct ivpu_device *vdev)
        debugfs_create_file("force_recovery", 0200, debugfs_root, vdev,
                            &ivpu_force_recovery_fops);
 
+       debugfs_create_file("dvfs_mode", 0200, debugfs_root, vdev,
+                           &dvfs_mode_fops);
+
        debugfs_create_file("fw_log", 0644, debugfs_root, vdev,
                            &fw_log_fops);
        debugfs_create_file("fw_trace_destination_mask", 0200, debugfs_root, vdev,
index 6142b09cf55a47b652b555f8739d6521fe64159d..b81827540db94b8467173a28a54160af8ad71c90 100644 (file)
@@ -182,6 +182,8 @@ static int ivpu_fw_parse(struct ivpu_device *vdev)
        fw->trace_destination_mask = VPU_TRACE_DESTINATION_VERBOSE_TRACING;
        fw->trace_hw_component_mask = -1;
 
+       fw->dvfs_mode = 0;
+
        ivpu_dbg(vdev, FW_BOOT, "Size: file %lu image %u runtime %u shavenn %u\n",
                 fw->file->size, fw->image_size, fw->runtime_size, fw->shave_nn_size);
        ivpu_dbg(vdev, FW_BOOT, "Address: runtime 0x%llx, load 0x%llx, entry point 0x%llx\n",
@@ -422,6 +424,8 @@ static void ivpu_fw_boot_params_print(struct ivpu_device *vdev, struct vpu_boot_
                 boot_params->punit_telemetry_sram_size);
        ivpu_dbg(vdev, FW_BOOT, "boot_params.vpu_telemetry_enable = 0x%x\n",
                 boot_params->vpu_telemetry_enable);
+       ivpu_dbg(vdev, FW_BOOT, "boot_params.dvfs_mode = %u\n",
+                boot_params->dvfs_mode);
 }
 
 void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params *boot_params)
@@ -492,6 +496,7 @@ void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params
        boot_params->punit_telemetry_sram_base = ivpu_hw_reg_telemetry_offset_get(vdev);
        boot_params->punit_telemetry_sram_size = ivpu_hw_reg_telemetry_size_get(vdev);
        boot_params->vpu_telemetry_enable = ivpu_hw_reg_telemetry_enable_get(vdev);
+       boot_params->dvfs_mode = vdev->fw->dvfs_mode;
 
        wmb(); /* Flush WC buffers after writing bootparams */
 
index 10ae2847f0ef3cab0e9c4436f1f4d4e9a6584531..66b60fa161b522150abddbfa20c9ddd207fd5ada 100644 (file)
@@ -27,6 +27,7 @@ struct ivpu_fw_info {
        u32 trace_level;
        u32 trace_destination_mask;
        u64 trace_hw_component_mask;
+       u32 dvfs_mode;
 };
 
 int ivpu_fw_init(struct ivpu_device *vdev);