Skip to content

Commit 320323d

Browse files
kwachowsjlawryno
authored andcommitted
accel/ivpu: Add debugfs interface for setting HWS priority bands
Add debugfs interface to modify following priority bands properties: * grace period * process grace period * process quantum This allows for the adjustment of hardware scheduling algorithm parameters for each existing priority band, facilitating validation and fine-tuning. Reviewed-by: Jacek Lawrynowicz <[email protected]> Signed-off-by: Karol Wachowski <[email protected]> Signed-off-by: Jacek Lawrynowicz <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 7806bad commit 320323d

File tree

4 files changed

+121
-18
lines changed

4 files changed

+121
-18
lines changed

drivers/accel/ivpu/ivpu_debugfs.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,88 @@ static int dct_active_set(void *data, u64 active_percent)
398398

399399
DEFINE_DEBUGFS_ATTRIBUTE(ivpu_dct_fops, dct_active_get, dct_active_set, "%llu\n");
400400

401+
static int priority_bands_show(struct seq_file *s, void *v)
402+
{
403+
struct ivpu_device *vdev = s->private;
404+
struct ivpu_hw_info *hw = vdev->hw;
405+
406+
for (int band = VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE;
407+
band < VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT; band++) {
408+
switch (band) {
409+
case VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE:
410+
seq_puts(s, "Idle: ");
411+
break;
412+
413+
case VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL:
414+
seq_puts(s, "Normal: ");
415+
break;
416+
417+
case VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS:
418+
seq_puts(s, "Focus: ");
419+
break;
420+
421+
case VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME:
422+
seq_puts(s, "Realtime: ");
423+
break;
424+
}
425+
426+
seq_printf(s, "grace_period %9u process_grace_period %9u process_quantum %9u\n",
427+
hw->hws.grace_period[band], hw->hws.process_grace_period[band],
428+
hw->hws.process_quantum[band]);
429+
}
430+
431+
return 0;
432+
}
433+
434+
static int priority_bands_fops_open(struct inode *inode, struct file *file)
435+
{
436+
return single_open(file, priority_bands_show, inode->i_private);
437+
}
438+
439+
static ssize_t
440+
priority_bands_fops_write(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
441+
{
442+
struct seq_file *s = file->private_data;
443+
struct ivpu_device *vdev = s->private;
444+
char buf[64];
445+
u32 grace_period;
446+
u32 process_grace_period;
447+
u32 process_quantum;
448+
u32 band;
449+
int ret;
450+
451+
if (size >= sizeof(buf))
452+
return -EINVAL;
453+
454+
ret = simple_write_to_buffer(buf, sizeof(buf) - 1, pos, user_buf, size);
455+
if (ret < 0)
456+
return ret;
457+
458+
buf[size] = '\0';
459+
ret = sscanf(buf, "%u %u %u %u", &band, &grace_period, &process_grace_period,
460+
&process_quantum);
461+
if (ret != 4)
462+
return -EINVAL;
463+
464+
if (band >= VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT)
465+
return -EINVAL;
466+
467+
vdev->hw->hws.grace_period[band] = grace_period;
468+
vdev->hw->hws.process_grace_period[band] = process_grace_period;
469+
vdev->hw->hws.process_quantum[band] = process_quantum;
470+
471+
return size;
472+
}
473+
474+
static const struct file_operations ivpu_hws_priority_bands_fops = {
475+
.owner = THIS_MODULE,
476+
.open = priority_bands_fops_open,
477+
.write = priority_bands_fops_write,
478+
.read = seq_read,
479+
.llseek = seq_lseek,
480+
.release = single_release,
481+
};
482+
401483
void ivpu_debugfs_init(struct ivpu_device *vdev)
402484
{
403485
struct dentry *debugfs_root = vdev->drm.debugfs_root;
@@ -420,6 +502,8 @@ void ivpu_debugfs_init(struct ivpu_device *vdev)
420502
&fw_trace_hw_comp_mask_fops);
421503
debugfs_create_file("fw_trace_level", 0200, debugfs_root, vdev,
422504
&fw_trace_level_fops);
505+
debugfs_create_file("hws_priority_bands", 0200, debugfs_root, vdev,
506+
&ivpu_hws_priority_bands_fops);
423507

424508
debugfs_create_file("reset_engine", 0200, debugfs_root, vdev,
425509
&ivpu_reset_engine_fops);

drivers/accel/ivpu/ivpu_hw.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,26 @@ static void timeouts_init(struct ivpu_device *vdev)
113113
}
114114
}
115115

116+
static void priority_bands_init(struct ivpu_device *vdev)
117+
{
118+
/* Idle */
119+
vdev->hw->hws.grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE] = 0;
120+
vdev->hw->hws.process_grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE] = 50000;
121+
vdev->hw->hws.process_quantum[VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE] = 160000;
122+
/* Normal */
123+
vdev->hw->hws.grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL] = 50000;
124+
vdev->hw->hws.process_grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL] = 50000;
125+
vdev->hw->hws.process_quantum[VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL] = 300000;
126+
/* Focus */
127+
vdev->hw->hws.grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS] = 50000;
128+
vdev->hw->hws.process_grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS] = 50000;
129+
vdev->hw->hws.process_quantum[VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS] = 200000;
130+
/* Realtime */
131+
vdev->hw->hws.grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME] = 0;
132+
vdev->hw->hws.process_grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME] = 50000;
133+
vdev->hw->hws.process_quantum[VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME] = 200000;
134+
}
135+
116136
static void memory_ranges_init(struct ivpu_device *vdev)
117137
{
118138
if (ivpu_hw_ip_gen(vdev) == IVPU_HW_IP_37XX) {
@@ -251,6 +271,7 @@ int ivpu_hw_init(struct ivpu_device *vdev)
251271
{
252272
ivpu_hw_btrs_info_init(vdev);
253273
ivpu_hw_btrs_freq_ratios_init(vdev);
274+
priority_bands_init(vdev);
254275
memory_ranges_init(vdev);
255276
platform_init(vdev);
256277
wa_init(vdev);

drivers/accel/ivpu/ivpu_hw.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ struct ivpu_hw_info {
3636
u8 pn_ratio;
3737
u32 profiling_freq;
3838
} pll;
39+
struct {
40+
u32 grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
41+
u32 process_quantum[VPU_HWS_NUM_PRIORITY_BANDS];
42+
u32 process_grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
43+
} hws;
3944
u32 tile_fuse;
4045
u32 sku;
4146
u16 config;

drivers/accel/ivpu/ivpu_jsm_msg.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "ivpu_hw.h"
88
#include "ivpu_ipc.h"
99
#include "ivpu_jsm_msg.h"
10+
#include "vpu_jsm_api.h"
1011

1112
const char *ivpu_jsm_msg_type_to_str(enum vpu_ipc_msg_type type)
1213
{
@@ -407,26 +408,18 @@ int ivpu_jsm_hws_setup_priority_bands(struct ivpu_device *vdev)
407408
{
408409
struct vpu_jsm_msg req = { .type = VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP };
409410
struct vpu_jsm_msg resp;
411+
struct ivpu_hw_info *hw = vdev->hw;
412+
struct vpu_ipc_msg_payload_hws_priority_band_setup *setup =
413+
&req.payload.hws_priority_band_setup;
410414
int ret;
411415

412-
/* Idle */
413-
req.payload.hws_priority_band_setup.grace_period[0] = 0;
414-
req.payload.hws_priority_band_setup.process_grace_period[0] = 50000;
415-
req.payload.hws_priority_band_setup.process_quantum[0] = 160000;
416-
/* Normal */
417-
req.payload.hws_priority_band_setup.grace_period[1] = 50000;
418-
req.payload.hws_priority_band_setup.process_grace_period[1] = 50000;
419-
req.payload.hws_priority_band_setup.process_quantum[1] = 300000;
420-
/* Focus */
421-
req.payload.hws_priority_band_setup.grace_period[2] = 50000;
422-
req.payload.hws_priority_band_setup.process_grace_period[2] = 50000;
423-
req.payload.hws_priority_band_setup.process_quantum[2] = 200000;
424-
/* Realtime */
425-
req.payload.hws_priority_band_setup.grace_period[3] = 0;
426-
req.payload.hws_priority_band_setup.process_grace_period[3] = 50000;
427-
req.payload.hws_priority_band_setup.process_quantum[3] = 200000;
428-
429-
req.payload.hws_priority_band_setup.normal_band_percentage = 10;
416+
for (int band = VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE;
417+
band < VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT; band++) {
418+
setup->grace_period[band] = hw->hws.grace_period[band];
419+
setup->process_grace_period[band] = hw->hws.process_grace_period[band];
420+
setup->process_quantum[band] = hw->hws.process_quantum[band];
421+
}
422+
setup->normal_band_percentage = 10;
430423

431424
ret = ivpu_ipc_send_receive_internal(vdev, &req, VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP_RSP,
432425
&resp, VPU_IPC_CHAN_ASYNC_CMD, vdev->timeout.jsm);

0 commit comments

Comments
 (0)