Skip to content

Commit f13108f

Browse files
trusinowiczsgruszka
authored andcommitted
accel/ivpu: Add dvfs_mode file to debugfs
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 <[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 9692b1d commit f13108f

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

drivers/accel/ivpu/ivpu_debugfs.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,31 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = {
115115
{"reset_pending", reset_pending_show, 0},
116116
};
117117

118+
static ssize_t
119+
dvfs_mode_fops_write(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
120+
{
121+
struct ivpu_device *vdev = file->private_data;
122+
struct ivpu_fw_info *fw = vdev->fw;
123+
u32 dvfs_mode;
124+
int ret;
125+
126+
ret = kstrtou32_from_user(user_buf, size, 0, &dvfs_mode);
127+
if (ret < 0)
128+
return ret;
129+
130+
fw->dvfs_mode = dvfs_mode;
131+
132+
ivpu_pm_schedule_recovery(vdev);
133+
134+
return size;
135+
}
136+
137+
static const struct file_operations dvfs_mode_fops = {
138+
.owner = THIS_MODULE,
139+
.open = simple_open,
140+
.write = dvfs_mode_fops_write,
141+
};
142+
118143
static int fw_log_show(struct seq_file *s, void *v)
119144
{
120145
struct ivpu_device *vdev = s->private;
@@ -280,6 +305,9 @@ void ivpu_debugfs_init(struct ivpu_device *vdev)
280305
debugfs_create_file("force_recovery", 0200, debugfs_root, vdev,
281306
&ivpu_force_recovery_fops);
282307

308+
debugfs_create_file("dvfs_mode", 0200, debugfs_root, vdev,
309+
&dvfs_mode_fops);
310+
283311
debugfs_create_file("fw_log", 0644, debugfs_root, vdev,
284312
&fw_log_fops);
285313
debugfs_create_file("fw_trace_destination_mask", 0200, debugfs_root, vdev,

drivers/accel/ivpu/ivpu_fw.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ static int ivpu_fw_parse(struct ivpu_device *vdev)
182182
fw->trace_destination_mask = VPU_TRACE_DESTINATION_VERBOSE_TRACING;
183183
fw->trace_hw_component_mask = -1;
184184

185+
fw->dvfs_mode = 0;
186+
185187
ivpu_dbg(vdev, FW_BOOT, "Size: file %lu image %u runtime %u shavenn %u\n",
186188
fw->file->size, fw->image_size, fw->runtime_size, fw->shave_nn_size);
187189
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_
422424
boot_params->punit_telemetry_sram_size);
423425
ivpu_dbg(vdev, FW_BOOT, "boot_params.vpu_telemetry_enable = 0x%x\n",
424426
boot_params->vpu_telemetry_enable);
427+
ivpu_dbg(vdev, FW_BOOT, "boot_params.dvfs_mode = %u\n",
428+
boot_params->dvfs_mode);
425429
}
426430

427431
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
492496
boot_params->punit_telemetry_sram_base = ivpu_hw_reg_telemetry_offset_get(vdev);
493497
boot_params->punit_telemetry_sram_size = ivpu_hw_reg_telemetry_size_get(vdev);
494498
boot_params->vpu_telemetry_enable = ivpu_hw_reg_telemetry_enable_get(vdev);
499+
boot_params->dvfs_mode = vdev->fw->dvfs_mode;
495500

496501
wmb(); /* Flush WC buffers after writing bootparams */
497502

drivers/accel/ivpu/ivpu_fw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct ivpu_fw_info {
2727
u32 trace_level;
2828
u32 trace_destination_mask;
2929
u64 trace_hw_component_mask;
30+
u32 dvfs_mode;
3031
};
3132

3233
int ivpu_fw_init(struct ivpu_device *vdev);

0 commit comments

Comments
 (0)