Skip to contentSkip to conversation

accel/ivpu: Refactor priority_bands_show for readability

PATCH In review Karol Wachowski 2 participants 3 messages Sep 15, 2025 – Sep 18, 2025

Subsystems (2)
lore
Share & tools
lore

Karol Wachowski

author maintainer
#0 lore raw

PATCH 1/1 accel/ivpu: Refactor priority_bands_show for readability

From: Jacek Lawrynowicz <[email protected]>

Reduce code duplication and improve the overall readability of the debugfs output for job scheduling priority bands.

Additionally fix clang-tidy warning about missing default case in the switch statement.

---
 drivers/accel/ivpu/ivpu_debugfs.c | 38 ++++++++++++-------------------
 1 file changed, 14 insertions(+), 24 deletions(-)
drivers/accel/ivpu/ivpu_debugfs.c +14 -24
index cd24ccd20ba6..3bd85ee6c26b 100644
@@ -398,35 +398,25 @@ static int dct_active_set(void *data, u64 active_percent)
 
 DEFINE_DEBUGFS_ATTRIBUTE(ivpu_dct_fops, dct_active_get, dct_active_set, "%llu\n");
 
+static void print_priority_band(struct seq_file *s, struct ivpu_hw_info *hw,
+				int band, const char *name)
+{
+	seq_printf(s, "%-9s: grace_period %9u process_grace_period %9u process_quantum %9u\n",
+		   name,
+		   hw->hws.grace_period[band],
+		   hw->hws.process_grace_period[band],
+		   hw->hws.process_quantum[band]);
+}
+
 static int priority_bands_show(struct seq_file *s, void *v)
 {
 	struct ivpu_device *vdev = s->private;
 	struct ivpu_hw_info *hw = vdev->hw;
 
-	for (int band = VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE;
-	     band < VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT; band++) {
-		switch (band) {
-		case VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE:
-			seq_puts(s, "Idle:     ");
-			break;
-
-		case VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL:
-			seq_puts(s, "Normal:   ");
-			break;
-
-		case VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS:
-			seq_puts(s, "Focus:    ");
-			break;
-
-		case VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME:
-			seq_puts(s, "Realtime: ");
-			break;
-		}
-
-		seq_printf(s, "grace_period %9u process_grace_period %9u process_quantum %9u\n",
-			   hw->hws.grace_period[band], hw->hws.process_grace_period[band],
-			   hw->hws.process_quantum[band]);
-	}
+	print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE, "Idle");
+	print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL, "Normal");
+	print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS, "Focus");
+	print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME, "Realtime");
 
 	return 0;
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 68 lines · Karol Wachowski

From: Jacek Lawrynowicz <[email protected]>

Reduce code duplication and improve the overall readability of the debugfs output for job scheduling priority bands.

Additionally fix clang-tidy warning about missing default case in the switch statement.

---
  drivers/accel/ivpu/ivpu_debugfs.c | 38 ++++++++++++-------------------
  1 file changed, 14 insertions(+), 24 deletions(-)
drivers/accel/ivpu/ivpu_debugfs.c +14 -24
index cd24ccd20ba6..3bd85ee6c26b 100644
@@ -398,35 +398,25 @@ static int dct_active_set(void *data, u64 active_percent)
 
  DEFINE_DEBUGFS_ATTRIBUTE(ivpu_dct_fops, dct_active_get, dct_active_set, "%llu\n");
 
+static void print_priority_band(struct seq_file *s, struct ivpu_hw_info *hw,
+				int band, const char *name)
+{
+	seq_printf(s, "%-9s: grace_period %9u process_grace_period %9u process_quantum %9u\n",
+		   name,
+		   hw->hws.grace_period[band],
+		   hw->hws.process_grace_period[band],
+		   hw->hws.process_quantum[band]);
+}
+
  static int priority_bands_show(struct seq_file *s, void *v)
  {
  	struct ivpu_device *vdev = s->private;
  	struct ivpu_hw_info *hw = vdev->hw;
 
-	for (int band = VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE;
-	     band < VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT; band++) {
-		switch (band) {
-		case VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE:
-			seq_puts(s, "Idle:     ");
-			break;
-
-		case VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL:
-			seq_puts(s, "Normal:   ");
-			break;
-
-		case VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS:
-			seq_puts(s, "Focus:    ");
-			break;
-
-		case VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME:
-			seq_puts(s, "Realtime: ");
-			break;
-		}
-
-		seq_printf(s, "grace_period %9u process_grace_period %9u process_quantum %9u\n",
-			   hw->hws.grace_period[band], hw->hws.process_grace_period[band],
-			   hw->hws.process_quantum[band]);
-	}
+	print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE, "Idle");
+	print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL, "Normal");
+	print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS, "Focus");
+	print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME, "Realtime");
 
  	return 0;
  }
author maintainer Applied
#2 lore raw

Applied to drm-misc-next

Quoted 79 lines · Lizhi Hou
Quoted 76 lines · Karol Wachowski

From: Jacek Lawrynowicz <[email protected]>

Reduce code duplication and improve the overall readability of the debugfs
output for job scheduling priority bands.

Additionally fix clang-tidy warning about missing default case in the switch statement.

---
  drivers/accel/ivpu/ivpu_debugfs.c | 38 ++++++++++++-------------------

  1 file changed, 14 insertions(+), 24 deletions(-)
drivers/accel/ivpu/ivpu_debugfs.c +0 -0
index cd24ccd20ba6..3bd85ee6c26b 100644
@@ -398,35 +398,25 @@ static int dct_active_set(void *data, u64
 active_percent)
     DEFINE_DEBUGFS_ATTRIBUTE(ivpu_dct_fops, dct_active_get,
 dct_active_set, "%llu\n");

  +static void print_priority_band(struct seq_file *s, struct ivpu_hw_info *hw,
+                int band, const char *name)
+{
+    seq_printf(s, "%-9s: grace_period %9u process_grace_period %9u process_quantum %9u\n",
+           name,
+           hw->hws.grace_period[band],
+           hw->hws.process_grace_period[band],
+           hw->hws.process_quantum[band]);

drivers/accel/ivpu/ivpu_debugfs.c +2 -0
+}
+

  static int priority_bands_show(struct seq_file *s, void *v) {
      struct ivpu_device *vdev = s->private;
      struct ivpu_hw_info *hw = vdev->hw;
  -    for (int band = VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE; -         band < VPU_JOB_SCHEDULING_PRIORITY_BAND_COUNT; band++) { -        switch (band) {
-        case VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE:
-            seq_puts(s, "Idle:     ");
-            break;

drivers/accel/ivpu/ivpu_debugfs.c +0 -15
-
-        case VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL:
-            seq_puts(s, "Normal:   ");
-            break;
-
-        case VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS:
-            seq_puts(s, "Focus:    ");
-            break;
-
-        case VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME:
-            seq_puts(s, "Realtime: ");
-            break;
-        }
-
-        seq_printf(s, "grace_period %9u process_grace_period %9u

process_quantum %9u\n",
-               hw->hws.grace_period[band], hw->hws.process_grace_period[band],
-               hw->hws.process_quantum[band]); -    }
+    print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_IDLE, "Idle"); +    print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_NORMAL, "Normal"); +    print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_FOCUS, "Focus"); +    print_priority_band(s, hw, VPU_JOB_SCHEDULING_PRIORITY_BAND_REALTIME, "Realtime"); return 0;
  }