Skip to contentSkip to conversation

accel/ivpu: Fix NOC firewall interrupt handling

PATCH Applied Jacek Lawrynowicz 2 participants 5 messages Oct 17, 2024 – Oct 30, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 accel/ivpu: Fix NOC firewall interrupt handling

From: Andrzej Kacprowski <[email protected]>

The NOC firewall interrupt means that the HW prevented unauthorized access to a protected resource, so there is no need to trigger device reset in such case.

To facilitate security testing add firewall_irq_counter debugfs file that tracks firewall interrupts.

Fixes 8a27ad81f7d3 ("accel/ivpu: Split IP and buttress code")
Cc <[email protected]> # v6.11+
---
 drivers/accel/ivpu/ivpu_debugfs.c | 9 +++++++++
 drivers/accel/ivpu/ivpu_hw.c      | 1 +
 drivers/accel/ivpu/ivpu_hw.h      | 1 +
 drivers/accel/ivpu/ivpu_hw_ip.c   | 5 ++++-
 4 files changed, 15 insertions(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_debugfs.c +9 -0
index 8958145c49adb..8180b95ed69dc 100644
@@ -116,6 +116,14 @@ static int reset_pending_show(struct seq_file *s, void *v)
 	return 0;
 }
 
+static int firewall_irq_counter_show(struct seq_file *s, void *v)
+{
+	struct ivpu_device *vdev = seq_to_ivpu(s);
+
+	seq_printf(s, "%d\n", atomic_read(&vdev->hw->firewall_irq_counter));
+	return 0;
+}
+
 static const struct drm_debugfs_info vdev_debugfs_list[] = {
 	{"bo_list", bo_list_show, 0},
 	{"fw_name", fw_name_show, 0},
@@ -125,6 +133,7 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = {
 	{"last_bootmode", last_bootmode_show, 0},
 	{"reset_counter", reset_counter_show, 0},
 	{"reset_pending", reset_pending_show, 0},
+	{"firewall_irq_counter", firewall_irq_counter_show, 0},
 };
 
 static int dvfs_mode_get(void *data, u64 *dvfs_mode)
drivers/accel/ivpu/ivpu_hw.c +1 -0
index 09ada8b500b99..4e1054f3466e8 100644
@@ -252,6 +252,7 @@ int ivpu_hw_init(struct ivpu_device *vdev)
 	platform_init(vdev);
 	wa_init(vdev);
 	timeouts_init(vdev);
+	atomic_set(&vdev->hw->firewall_irq_counter, 0);
 
 	return 0;
 }
drivers/accel/ivpu/ivpu_hw.h +1 -0
index dc5518248c405..fc4dbfc980c81 100644
@@ -51,6 +51,7 @@ struct ivpu_hw_info {
 	int dma_bits;
 	ktime_t d0i3_entry_host_ts;
 	u64 d0i3_entry_vpu_ts;
+	atomic_t firewall_irq_counter;
 };
 
 int ivpu_hw_init(struct ivpu_device *vdev);
drivers/accel/ivpu/ivpu_hw_ip.c +4 -1
index b9b16f4041434..029dd065614b2 100644
@@ -1073,7 +1073,10 @@ static void irq_wdt_mss_handler(struct ivpu_device *vdev)
 
 static void irq_noc_firewall_handler(struct ivpu_device *vdev)
 {
-	ivpu_pm_trigger_recovery(vdev, "NOC Firewall IRQ");
+	atomic_inc(&vdev->hw->firewall_irq_counter);
+
+	ivpu_dbg(vdev, IRQ, "NOC Firewall interrupt detected, counter %d\n",
+		 atomic_read(&vdev->hw->firewall_irq_counter));
 }
 
 /* Handler for IRQs from NPU core */
Signature · 1 line
2.45.1
#1 lore raw
Quoted 65 lines · Jacek Lawrynowicz

From: Andrzej Kacprowski <[email protected]>

The NOC firewall interrupt means that the HW prevented unauthorized access to a protected resource, so there is no need to trigger device reset in such case.

To facilitate security testing add firewall_irq_counter debugfs file that tracks firewall interrupts.

Fixes 8a27ad81f7d3 ("accel/ivpu: Split IP and buttress code")
Cc <[email protected]> # v6.11+
---
  drivers/accel/ivpu/ivpu_debugfs.c | 9 +++++++++
  drivers/accel/ivpu/ivpu_hw.c      | 1 +
  drivers/accel/ivpu/ivpu_hw.h      | 1 +
  drivers/accel/ivpu/ivpu_hw_ip.c   | 5 ++++-
  4 files changed, 15 insertions(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_debugfs.c +9 -0
index 8958145c49adb..8180b95ed69dc 100644
@@ -116,6 +116,14 @@ static int reset_pending_show(struct seq_file *s, void *v)
  	return 0;
  }
 
+static int firewall_irq_counter_show(struct seq_file *s, void *v)
+{
+	struct ivpu_device *vdev = seq_to_ivpu(s);
+
+	seq_printf(s, "%d\n", atomic_read(&vdev->hw->firewall_irq_counter));
+	return 0;
+}
+
  static const struct drm_debugfs_info vdev_debugfs_list[] = {
  	{"bo_list", bo_list_show, 0},
  	{"fw_name", fw_name_show, 0},
@@ -125,6 +133,7 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = {
  	{"last_bootmode", last_bootmode_show, 0},
  	{"reset_counter", reset_counter_show, 0},
  	{"reset_pending", reset_pending_show, 0},
+	{"firewall_irq_counter", firewall_irq_counter_show, 0},
  };
 
  static int dvfs_mode_get(void *data, u64 *dvfs_mode)
drivers/accel/ivpu/ivpu_hw.c +1 -0
index 09ada8b500b99..4e1054f3466e8 100644
@@ -252,6 +252,7 @@ int ivpu_hw_init(struct ivpu_device *vdev)
  	platform_init(vdev);
  	wa_init(vdev);
  	timeouts_init(vdev);
+	atomic_set(&vdev->hw->firewall_irq_counter, 0);
 
  	return 0;
  }
drivers/accel/ivpu/ivpu_hw.h +0 -0
index dc5518248c405..fc4dbfc980c81 100644

drivers/accel/ivpu/ivpu_hw.h struct ivpu_hw_info { · line 54

Quoted 4 lines
drivers/accel/ivpu/ivpu_hw.h +1 -0
@@ -51,6 +51,7 @@ struct ivpu_hw_info {
  	int dma_bits;
  	ktime_t d0i3_entry_host_ts;
  	u64 d0i3_entry_vpu_ts;
+	atomic_t firewall_irq_counter;

Why atomic?

Quoted 19 lines
drivers/accel/ivpu/ivpu_hw.h +0 -0
  };
 
  int ivpu_hw_init(struct ivpu_device *vdev);
drivers/accel/ivpu/ivpu_hw_ip.c +4 -1
index b9b16f4041434..029dd065614b2 100644
@@ -1073,7 +1073,10 @@ static void irq_wdt_mss_handler(struct ivpu_device *vdev)
 
  static void irq_noc_firewall_handler(struct ivpu_device *vdev)
  {
-	ivpu_pm_trigger_recovery(vdev, "NOC Firewall IRQ");
+	atomic_inc(&vdev->hw->firewall_irq_counter);
+
+	ivpu_dbg(vdev, IRQ, "NOC Firewall interrupt detected, counter %d\n",
+		 atomic_read(&vdev->hw->firewall_irq_counter));
  }
 
  /* Handler for IRQs from NPU core */
#2 lore raw

Hi,

Quoted 61 lines · Jeffrey Hugo
Quoted 60 lines · Jacek Lawrynowicz

From: Andrzej Kacprowski <[email protected]>

The NOC firewall interrupt means that the HW prevented unauthorized access to a protected resource, so there is no need to trigger device reset in such case.

To facilitate security testing add firewall_irq_counter debugfs file that tracks firewall interrupts.

Fixes 8a27ad81f7d3 ("accel/ivpu: Split IP and buttress code")
Cc <[email protected]> # v6.11+

---
  drivers/accel/ivpu/ivpu_debugfs.c | 9 +++++++++
  drivers/accel/ivpu/ivpu_hw.c      | 1 +
  drivers/accel/ivpu/ivpu_hw.h      | 1 +
  drivers/accel/ivpu/ivpu_hw_ip.c   | 5 ++++-

  4 files changed, 15 insertions(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_debugfs.c +8 -0
index 8958145c49adb..8180b95ed69dc 100644
@@ -116,6 +116,14 @@ static int reset_pending_show(struct seq_file *s, void *v)
       return 0;
   }
   +static int firewall_irq_counter_show(struct seq_file *s, void *v)
+{
+    struct ivpu_device *vdev = seq_to_ivpu(s);
+
+    seq_printf(s, "%d\n", atomic_read(&vdev->hw->firewall_irq_counter));
+    return 0;
+}
+
   static const struct drm_debugfs_info vdev_debugfs_list[] = {
       {"bo_list", bo_list_show, 0},
       {"fw_name", fw_name_show, 0},
@@ -125,6 +133,7 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = {
       {"last_bootmode", last_bootmode_show, 0},
       {"reset_counter", reset_counter_show, 0},
       {"reset_pending", reset_pending_show, 0},
+    {"firewall_irq_counter", firewall_irq_counter_show, 0},
   };
     static int dvfs_mode_get(void *data, u64 *dvfs_mode)
drivers/accel/ivpu/ivpu_hw.c +1 -0
index 09ada8b500b99..4e1054f3466e8 100644
@@ -252,6 +252,7 @@ int ivpu_hw_init(struct ivpu_device *vdev)
       platform_init(vdev);
       wa_init(vdev);
       timeouts_init(vdev);
+    atomic_set(&vdev->hw->firewall_irq_counter, 0);
         return 0;
   }
drivers/accel/ivpu/ivpu_hw.h +0 -1
index dc5518248c405..fc4dbfc980c81 100644
--- a/drivers/accel/ivpu/ivpu_hw.h
Quoted 8 lines

drivers/accel/ivpu/ivpu_hw.h struct ivpu_hw_info { · line 54

Quoted 6 lines

+++ b/drivers/accel/ivpu/ivpu_hw.h

drivers/accel/ivpu/ivpu_hw.h +1 -0
@@ -51,6 +51,7 @@ struct ivpu_hw_info {
       int dma_bits;
       ktime_t d0i3_entry_host_ts;
       u64 d0i3_entry_vpu_ts;
+    atomic_t firewall_irq_counter;

Why atomic?

So we don't have to worry about synchronization and barriers.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Jacek Lawrynowicz
Quoted 6 lines · Jacek Lawrynowicz

From: Andrzej Kacprowski <[email protected]>

The NOC firewall interrupt means that the HW prevented unauthorized access to a protected resource, so there is no need to trigger device reset in such case.

Quoted 8 lines

To facilitate security testing add firewall_irq_counter debugfs file that tracks firewall interrupts.

Fixes 8a27ad81f7d3 ("accel/ivpu: Split IP and buttress code")
Cc <[email protected]> # v6.11+
author Applied
#4 lore raw
In reply to Jacek Lawrynowicz

Applied to drm-misc-fixes

Quoted 88 lines · Jacek Lawrynowicz

From: Andrzej Kacprowski <[email protected]>

The NOC firewall interrupt means that the HW prevented unauthorized access to a protected resource, so there is no need to trigger device reset in such case.

To facilitate security testing add firewall_irq_counter debugfs file that tracks firewall interrupts.

Fixes 8a27ad81f7d3 ("accel/ivpu: Split IP and buttress code")
Cc <[email protected]> # v6.11+
---
 drivers/accel/ivpu/ivpu_debugfs.c | 9 +++++++++
 drivers/accel/ivpu/ivpu_hw.c      | 1 +
 drivers/accel/ivpu/ivpu_hw.h      | 1 +
 drivers/accel/ivpu/ivpu_hw_ip.c   | 5 ++++-
 4 files changed, 15 insertions(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_debugfs.c +9 -0
index 8958145c49adb..8180b95ed69dc 100644
@@ -116,6 +116,14 @@ static int reset_pending_show(struct seq_file *s, void *v)
 	return 0;
 }
 
+static int firewall_irq_counter_show(struct seq_file *s, void *v)
+{
+	struct ivpu_device *vdev = seq_to_ivpu(s);
+
+	seq_printf(s, "%d\n", atomic_read(&vdev->hw->firewall_irq_counter));
+	return 0;
+}
+
 static const struct drm_debugfs_info vdev_debugfs_list[] = {
 	{"bo_list", bo_list_show, 0},
 	{"fw_name", fw_name_show, 0},
@@ -125,6 +133,7 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = {
 	{"last_bootmode", last_bootmode_show, 0},
 	{"reset_counter", reset_counter_show, 0},
 	{"reset_pending", reset_pending_show, 0},
+	{"firewall_irq_counter", firewall_irq_counter_show, 0},
 };
 
 static int dvfs_mode_get(void *data, u64 *dvfs_mode)
drivers/accel/ivpu/ivpu_hw.c +1 -0
index 09ada8b500b99..4e1054f3466e8 100644
@@ -252,6 +252,7 @@ int ivpu_hw_init(struct ivpu_device *vdev)
 	platform_init(vdev);
 	wa_init(vdev);
 	timeouts_init(vdev);
+	atomic_set(&vdev->hw->firewall_irq_counter, 0);
 
 	return 0;
 }
drivers/accel/ivpu/ivpu_hw.h +1 -0
index dc5518248c405..fc4dbfc980c81 100644
@@ -51,6 +51,7 @@ struct ivpu_hw_info {
 	int dma_bits;
 	ktime_t d0i3_entry_host_ts;
 	u64 d0i3_entry_vpu_ts;
+	atomic_t firewall_irq_counter;
 };
 
 int ivpu_hw_init(struct ivpu_device *vdev);
drivers/accel/ivpu/ivpu_hw_ip.c +4 -1
index b9b16f4041434..029dd065614b2 100644
@@ -1073,7 +1073,10 @@ static void irq_wdt_mss_handler(struct ivpu_device *vdev)
 
 static void irq_noc_firewall_handler(struct ivpu_device *vdev)
 {
-	ivpu_pm_trigger_recovery(vdev, "NOC Firewall IRQ");
+	atomic_inc(&vdev->hw->firewall_irq_counter);
+
+	ivpu_dbg(vdev, IRQ, "NOC Firewall interrupt detected, counter %d\n",
+		 atomic_read(&vdev->hw->firewall_irq_counter));
 }
 
 /* Handler for IRQs from NPU core */