Skip to content

Commit 397f3a7

Browse files
kwachowsgregkh
authored andcommitted
accel/ivpu: Add debugfs interface for setting HWS priority bands
[ Upstream commit 320323d ] 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] Stable-dep-of: a47e36d ("accel/ivpu: Trigger device recovery on engine reset/resume failure") Signed-off-by: Sasha Levin <[email protected]>
1 parent d803023 commit 397f3a7

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
@@ -423,6 +423,88 @@ static int dct_active_set(void *data, u64 active_percent)
423423

424424
DEFINE_DEBUGFS_ATTRIBUTE(ivpu_dct_fops, dct_active_get, dct_active_set, "%llu\n");
425425

426+
static int priority_bands_show(struct seq_file *s, void *v)
427+
{
428+
struct ivpu_device *vdev = s->private;
429+
struct ivpu_hw_info *hw = vdev->hw;
430+
431+
for (int band = VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE;
432+
band < VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT; band++) {
433+
switch (band) {
434+
case VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE:
435+
seq_puts(s, "Idle: ");
436+
break;
437+
438+
case VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL:
439+
seq_puts(s, "Normal: ");
440+
break;
441+
442+
case VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS:
443+
seq_puts(s, "Focus: ");
444+
break;
445+
446+
case VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME:
447+
seq_puts(s, "Realtime: ");
448+
break;
449+
}
450+
451+
seq_printf(s, "grace_period %9u process_grace_period %9u process_quantum %9u\n",
452+
hw->hws.grace_period[band], hw->hws.process_grace_period[band],
453+
hw->hws.process_quantum[band]);
454+
}
455+
456+
return 0;
457+
}
458+
459+
static int priority_bands_fops_open(struct inode *inode, struct file *file)
460+
{
461+
return single_open(file, priority_bands_show, inode->i_private);
462+
}
463+
464+
static ssize_t
465+
priority_bands_fops_write(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
466+
{
467+
struct seq_file *s = file->private_data;
468+
struct ivpu_device *vdev = s->private;
469+
char buf[64];
470+
u32 grace_period;
471+
u32 process_grace_period;
472+
u32 process_quantum;
473+
u32 band;
474+
int ret;
475+
476+
if (size >= sizeof(buf))
477+
return -EINVAL;
478+
479+
ret = simple_write_to_buffer(buf, sizeof(buf) - 1, pos, user_buf, size);
480+
if (ret < 0)
481+
return ret;
482+
483+
buf[size] = '\0';
484+
ret = sscanf(buf, "%u %u %u %u", &band, &grace_period, &process_grace_period,
485+
&process_quantum);
486+
if (ret != 4)
487+
return -EINVAL;
488+
489+
if (band >= VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT)
490+
return -EINVAL;
491+
492+
vdev->hw->hws.grace_period[band] = grace_period;
493+
vdev->hw->hws.process_grace_period[band] = process_grace_period;
494+
vdev->hw->hws.process_quantum[band] = process_quantum;
495+
496+
return size;
497+
}
498+
499+
static const struct file_operations ivpu_hws_priority_bands_fops = {
500+
.owner = THIS_MODULE,
501+
.open = priority_bands_fops_open,
502+
.write = priority_bands_fops_write,
503+
.read = seq_read,
504+
.llseek = seq_lseek,
505+
.release = single_release,
506+
};
507+
426508
void ivpu_debugfs_init(struct ivpu_device *vdev)
427509
{
428510
struct dentry *debugfs_root = vdev->drm.debugfs_root;
@@ -445,6 +527,8 @@ void ivpu_debugfs_init(struct ivpu_device *vdev)
445527
&fw_trace_hw_comp_mask_fops);
446528
debugfs_create_file("fw_trace_level", 0200, debugfs_root, vdev,
447529
&fw_trace_level_fops);
530+
debugfs_create_file("hws_priority_bands", 0200, debugfs_root, vdev,
531+
&ivpu_hws_priority_bands_fops);
448532

449533
debugfs_create_file("reset_engine", 0200, debugfs_root, vdev,
450534
&ivpu_reset_engine_fops);

drivers/accel/ivpu/ivpu_hw.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,26 @@ static void timeouts_init(struct ivpu_device *vdev)
110110
}
111111
}
112112

113+
static void priority_bands_init(struct ivpu_device *vdev)
114+
{
115+
/* Idle */
116+
vdev->hw->hws.grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE] = 0;
117+
vdev->hw->hws.process_grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE] = 50000;
118+
vdev->hw->hws.process_quantum[VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE] = 160000;
119+
/* Normal */
120+
vdev->hw->hws.grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL] = 50000;
121+
vdev->hw->hws.process_grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL] = 50000;
122+
vdev->hw->hws.process_quantum[VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL] = 300000;
123+
/* Focus */
124+
vdev->hw->hws.grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS] = 50000;
125+
vdev->hw->hws.process_grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS] = 50000;
126+
vdev->hw->hws.process_quantum[VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS] = 200000;
127+
/* Realtime */
128+
vdev->hw->hws.grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME] = 0;
129+
vdev->hw->hws.process_grace_period[VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME] = 50000;
130+
vdev->hw->hws.process_quantum[VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME] = 200000;
131+
}
132+
113133
static void memory_ranges_init(struct ivpu_device *vdev)
114134
{
115135
if (ivpu_hw_ip_gen(vdev) == IVPU_HW_IP_37XX) {
@@ -248,6 +268,7 @@ int ivpu_hw_init(struct ivpu_device *vdev)
248268
{
249269
ivpu_hw_btrs_info_init(vdev);
250270
ivpu_hw_btrs_freq_ratios_init(vdev);
271+
priority_bands_init(vdev);
251272
memory_ranges_init(vdev);
252273
platform_init(vdev);
253274
wa_init(vdev);

drivers/accel/ivpu/ivpu_hw.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ struct ivpu_hw_info {
4545
u8 pn_ratio;
4646
u32 profiling_freq;
4747
} pll;
48+
struct {
49+
u32 grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
50+
u32 process_quantum[VPU_HWS_NUM_PRIORITY_BANDS];
51+
u32 process_grace_period[VPU_HWS_NUM_PRIORITY_BANDS];
52+
} hws;
4853
u32 tile_fuse;
4954
u32 sku;
5055
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
{
@@ -409,26 +410,18 @@ int ivpu_jsm_hws_setup_priority_bands(struct ivpu_device *vdev)
409410
{
410411
struct vpu_jsm_msg req = { .type = VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP };
411412
struct vpu_jsm_msg resp;
413+
struct ivpu_hw_info *hw = vdev->hw;
414+
struct vpu_ipc_msg_payload_hws_priority_band_setup *setup =
415+
&req.payload.hws_priority_band_setup;
412416
int ret;
413417

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

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

0 commit comments

Comments
 (0)