Skip to contentSkip to conversation

accel/ivpu: Changes for 6.15

PATCH Applied Jacek Lawrynowicz 2 participants 16 messages Jan 29, 2025 – Feb 3, 2025

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

cover accel/ivpu: Changes for 6.15

Most notable is the addition of hardware fault injection support which allows to test error handling paths in the driver.

Jacek Lawrynowicz (2):
accel/ivpu: Add support for hardware fault injection accel/ivpu: Update last_busy in IRQ handler

Karol Wachowski (3):
accel/ivpu: Fix missing MMU events if file_priv is unbound accel/ivpu: Turn on HWS by default on all platforms accel/ivpu: Move recovery work to system_unbound_wq

Tomasz Rusinowicz (1):
accel/ivpu: Enable recovery and adjust timeouts for fpga

 drivers/accel/ivpu/ivpu_debugfs.c   |  5 +++
 drivers/accel/ivpu/ivpu_fw.c        | 10 +----
 drivers/accel/ivpu/ivpu_hw.c        | 33 +++++++++++----
 drivers/accel/ivpu/ivpu_hw_ip.c     |  4 +-
 drivers/accel/ivpu/ivpu_hw_reg_io.h | 64 +++++++++++++++++------------
 drivers/accel/ivpu/ivpu_job.c       |  8 +++-
 drivers/accel/ivpu/ivpu_pm.c        |  7 +---
 7 files changed, 78 insertions(+), 53 deletions(-)

--
2.45.1

#1 lore raw

PATCH 1/6 accel/ivpu: Add support for hardware fault injection

This commit introduces the capability to simulate hardware faults for testing purposes. The new fail_hw fault can be injected in ivpu_hw_reg_poll_fld(), which is used in various parts of the driver to wait for the hardware to reach a specific state. This allows to test failures during NPU boot and shutdown, IPC message handling and more.

Fault injection can be enabled using debugfs or a module parameter.

---
 drivers/accel/ivpu/ivpu_debugfs.c   |  5 +++
 drivers/accel/ivpu/ivpu_hw.c        | 14 +++++++
 drivers/accel/ivpu/ivpu_hw_ip.c     |  4 +-
 drivers/accel/ivpu/ivpu_hw_reg_io.h | 64 +++++++++++++++++------------
 4 files changed, 58 insertions(+), 29 deletions(-)
drivers/accel/ivpu/ivpu_debugfs.c +5 -0
index 8180b95ed69dc..e79715c53f2a0 100644
@@ -4,6 +4,7 @@
  */
 
 #include <linux/debugfs.h>
+#include <linux/fault-inject.h>
 
 #include <drm/drm_debugfs.h>
 #include <drm/drm_file.h>
@@ -430,4 +431,8 @@ void ivpu_debugfs_init(struct ivpu_device *vdev)
 				    debugfs_root, vdev, &fw_profiling_freq_fops);
 		debugfs_create_file("dct", 0644, debugfs_root, vdev, &ivpu_dct_fops);
 	}
+
+#ifdef CONFIG_FAULT_INJECTION
+	fault_create_debugfs_attr("fail_hw", debugfs_root, &ivpu_hw_failure);
+#endif
 }
drivers/accel/ivpu/ivpu_hw.c +14 -0
index e332f19ab51de..8099ab047bfe6 100644
@@ -9,6 +9,15 @@
 #include "ivpu_hw_ip.h"
 
 #include <linux/dmi.h>
+#include <linux/fault-inject.h>
+
+#ifdef CONFIG_FAULT_INJECTION
+DECLARE_FAULT_ATTR(ivpu_hw_failure);
+
+static char *ivpu_fail_hw;
+module_param_named_unsafe(fail_hw, ivpu_fail_hw, charp, 0444);
+MODULE_PARM_DESC(fail_hw, "<interval>,<probability>,<space>,<times>");
+#endif
 
 static char *platform_to_str(u32 platform)
 {
@@ -247,6 +256,11 @@ int ivpu_hw_init(struct ivpu_device *vdev)
 	timeouts_init(vdev);
 	atomic_set(&vdev->hw->firewall_irq_counter, 0);
 
+#ifdef CONFIG_FAULT_INJECTION
+	if (ivpu_fail_hw)
+		setup_fault_attr(&ivpu_hw_failure, ivpu_fail_hw);
+#endif
+
 	return 0;
 }
 
drivers/accel/ivpu/ivpu_hw_ip.c +2 -2
index 029dd065614b2..823f6a57dc546 100644
@@ -968,14 +968,14 @@ void ivpu_hw_ip_wdt_disable(struct ivpu_device *vdev)
 
 static u32 ipc_rx_count_get_37xx(struct ivpu_device *vdev)
 {
-	u32 count = REGV_RD32_SILENT(VPU_37XX_HOST_SS_TIM_IPC_FIFO_STAT);
+	u32 count = readl(vdev->regv + VPU_37XX_HOST_SS_TIM_IPC_FIFO_STAT);
 
 	return REG_GET_FLD(VPU_37XX_HOST_SS_TIM_IPC_FIFO_STAT, FILL_LEVEL, count);
 }
 
 static u32 ipc_rx_count_get_40xx(struct ivpu_device *vdev)
 {
-	u32 count = REGV_RD32_SILENT(VPU_40XX_HOST_SS_TIM_IPC_FIFO_STAT);
+	u32 count = readl(vdev->regv + VPU_40XX_HOST_SS_TIM_IPC_FIFO_STAT);
 
 	return REG_GET_FLD(VPU_40XX_HOST_SS_TIM_IPC_FIFO_STAT, FILL_LEVEL, count);
 }
drivers/accel/ivpu/ivpu_hw_reg_io.h +37 -27

87 lines not on this page · raw message

Signature · 1 line
2.45.1
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] accel/ivpu: Add support for hardware fault injection

Quoted 1 line · Jacek Lawrynowicz

This commit introduces the capability to simulate hardware faults for

Nit - "This commit" is redundant.

Quoted 9 lines

testing purposes. The new fail_hw fault can be injected in ivpu_hw_reg_poll_fld(), which is used in various parts of the driver to wait for the hardware to reach a specific state. This allows to test failures during NPU boot and shutdown, IPC message handling and more.

Fault injection can be enabled using debugfs or a module parameter.

#3 lore raw

Re: [PATCH 1/6] accel/ivpu: Add support for hardware fault injection

Quoted 4 lines · Jeffrey Hugo
Quoted 1 line · Jacek Lawrynowicz

This commit introduces the capability to simulate hardware faults for

Nit - "This commit" is redundant.

Sure, removed.

#4 lore raw

PATCH 2/6 accel/ivpu: Update last_busy in IRQ handler

In reply to Jacek Lawrynowicz

Call pm_runtime_mark_last_busy() in top half of IRQ handler to prevent device from being runtime suspended before bottom half is executed on a workqueue.

---
 drivers/accel/ivpu/ivpu_hw.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/accel/ivpu/ivpu_hw.c +6 -3
index 8099ab047bfe6..4199f0bbb435b 100644
@@ -10,6 +10,7 @@
 
 #include <linux/dmi.h>
 #include <linux/fault-inject.h>
+#include <linux/pm_runtime.h>
 
 #ifdef CONFIG_FAULT_INJECTION
 DECLARE_FAULT_ATTR(ivpu_hw_failure);
@@ -331,7 +332,9 @@ irqreturn_t ivpu_hw_irq_handler(int irq, void *ptr)
 	/* Re-enable global interrupts to re-trigger MSI for pending interrupts */
 	ivpu_hw_btrs_global_int_enable(vdev);
 
-	if (ip_handled || btrs_handled)
-		return IRQ_HANDLED;
-	return IRQ_NONE;
+	if (!ip_handled && !btrs_handled)
+		return IRQ_NONE;
+
+	pm_runtime_mark_last_busy(vdev->drm.dev);
+	return IRQ_HANDLED;
 }
Signature · 1 line
2.45.1
#6 lore raw

PATCH 3/6 accel/ivpu: Fix missing MMU events if file_priv is unbound

In reply to Jacek Lawrynowicz

From: Karol Wachowski <[email protected]>

Move the ivpu_mmu_discard_events() function to the common portion of the abort work function. This ensures it is called only once, even if there are no faulty contexts in context_xa, to guarantee that MMU events are discarded and new events are not missed.

---
 drivers/accel/ivpu/ivpu_job.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_job.c +7 -1
index 3c162ac41a1dc..c1013f511efa6 100644
@@ -375,7 +375,6 @@ void ivpu_context_abort_locked(struct ivpu_file_priv *file_priv)
 		ivpu_jsm_context_release(vdev, file_priv->ctx.id);
 
 	ivpu_mmu_disable_ssid_events(vdev, file_priv->ctx.id);
-	ivpu_mmu_discard_events(vdev);
 
 	file_priv->aborted = true;
 }
@@ -980,6 +979,13 @@ void ivpu_context_abort_work_fn(struct work_struct *work)
 	}
 	mutex_unlock(&vdev->context_list_lock);
 
+	/*
+	 * We will not receive new MMU event interrupts until existing events are discarded
+	 * however, we want to discard these events only after aborting the faulty context
+	 * to avoid generating new faults from that context
+	 */
+	ivpu_mmu_discard_events(vdev);
+
 	if (vdev->fw->sched_mode != VPU_SCHEDULING_MODE_HW)
 		return;
 
Signature · 1 line
2.45.1
Reviewed-by on v1 3/6
#7 lore raw

Re: [PATCH 3/6] accel/ivpu: Fix missing MMU events if file_priv is unbound

Quoted 10 lines · Jacek Lawrynowicz

From: Karol Wachowski <[email protected]>

Move the ivpu_mmu_discard_events() function to the common portion of the abort work function. This ensures it is called only once, even if there are no faulty contexts in context_xa, to guarantee that MMU events are discarded and new events are not missed.

#8 lore raw

PATCH 4/6 accel/ivpu: Turn on HWS by default on all platforms

In reply to Jacek Lawrynowicz

From: Karol Wachowski <[email protected]>

Hardware scheduling (HWS) is supposed to be supported on all existing platform with recent FW including pre-silicon ones. Turn on HWS by default.

---
 drivers/accel/ivpu/ivpu_fw.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/accel/ivpu/ivpu_fw.c +1 -9
index 6cf1fb826d1ba..cfe8f79ec5a6f 100644
@@ -148,15 +148,7 @@ ivpu_fw_sched_mode_select(struct ivpu_device *vdev, const struct vpu_firmware_he
 	if (IVPU_FW_CHECK_API_VER_LT(vdev, fw_hdr, JSM, 3, 24))
 		return VPU_SCHEDULING_MODE_OS;
 
-	switch (ivpu_device_id(vdev)) {
-	case PCI_DEVICE_ID_MTL:
-	case PCI_DEVICE_ID_ARL:
-	case PCI_DEVICE_ID_LNL:
-	case PCI_DEVICE_ID_PTL_P:
-		return VPU_SCHEDULING_MODE_HW;
-	default:
-		return VPU_SCHEDULING_MODE_OS;
-	}
+	return VPU_SCHEDULING_MODE_HW;
 }
 
 static int ivpu_fw_parse(struct ivpu_device *vdev)
Signature · 1 line
2.45.1
#9 lore raw

Re: [PATCH 4/6] accel/ivpu: Turn on HWS by default on all platforms

Quoted 5 lines · Jacek Lawrynowicz

From: Karol Wachowski <[email protected]>

Hardware scheduling (HWS) is supposed to be supported on all existing platform with recent FW including pre-silicon ones. Turn on HWS by default.

Is there released firmware which does not have this enabled/supported? Should this be a "on by default, if FW VER > X"?

-Jeff

#10 lore raw

Re: [PATCH 4/6] accel/ivpu: Turn on HWS by default on all platforms

Yes and there is a check for FW version in ivpu_fw_sched_mode_select() that verifies this. It is just above the changed lines from this patch.

Quoted 10 lines · Jeffrey Hugo
Quoted 5 lines · Jacek Lawrynowicz

From: Karol Wachowski <[email protected]>

Hardware scheduling (HWS) is supposed to be supported on all existing platform with recent FW including pre-silicon ones. Turn on HWS by default.

Is there released firmware which does not have this enabled/supported? Should this be a "on by default, if FW VER > X"?

-Jeff

#11 lore raw

PATCH 5/6 accel/ivpu: Enable recovery and adjust timeouts for fpga

In reply to Jacek Lawrynowicz

From: Tomasz Rusinowicz <[email protected]>

Recovery now works on fpga. JSM state dump timeout needs to be really long for the new fpga model releases.

Enable punit on fpga.

---
 drivers/accel/ivpu/ivpu_hw.c | 10 +++++-----
 drivers/accel/ivpu/ivpu_pm.c |  5 -----
 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/accel/ivpu/ivpu_hw.c +5 -5
index 4199f0bbb435b..2057907c5aa6a 100644
@@ -58,7 +58,7 @@ static void platform_init(struct ivpu_device *vdev)
 
 static void wa_init(struct ivpu_device *vdev)
 {
-	vdev->wa.punit_disabled = ivpu_is_fpga(vdev);
+	vdev->wa.punit_disabled = false;
 	vdev->wa.clear_runtime_mem = false;
 
 	if (ivpu_hw_btrs_gen(vdev) == IVPU_HW_BTRS_MTL)
@@ -87,12 +87,12 @@ static void timeouts_init(struct ivpu_device *vdev)
 		vdev->timeout.autosuspend = -1;
 		vdev->timeout.d0i3_entry_msg = -1;
 	} else if (ivpu_is_fpga(vdev)) {
-		vdev->timeout.boot = 100000;
-		vdev->timeout.jsm = 50000;
-		vdev->timeout.tdr = 2000000;
+		vdev->timeout.boot = 50;
+		vdev->timeout.jsm = 15000;
+		vdev->timeout.tdr = 30000;
 		vdev->timeout.autosuspend = -1;
 		vdev->timeout.d0i3_entry_msg = 500;
-		vdev->timeout.state_dump_msg = 10;
+		vdev->timeout.state_dump_msg = 10000;
 	} else if (ivpu_is_simics(vdev)) {
 		vdev->timeout.boot = 50;
 		vdev->timeout.jsm = 500;
drivers/accel/ivpu/ivpu_pm.c +0 -5
index f41b3bfe40af4..8f6222d157204 100644
@@ -161,11 +161,6 @@ void ivpu_pm_trigger_recovery(struct ivpu_device *vdev, const char *reason)
 		return;
 	}
 
-	if (ivpu_is_fpga(vdev)) {
-		ivpu_err(vdev, "Recovery not available on FPGA\n");
-		return;
-	}
-
 	/* Trigger recovery if it's not in progress */
 	if (atomic_cmpxchg(&vdev->pm->reset_pending, 0, 1) == 0) {
 		ivpu_hw_diagnose_failure(vdev);
Signature · 1 line
2.45.1
Reviewed-by on v1 5/6
#12 lore raw

Re: [PATCH 5/6] accel/ivpu: Enable recovery and adjust timeouts for fpga

Quoted 10 lines · Jacek Lawrynowicz

From: Tomasz Rusinowicz <[email protected]>

Recovery now works on fpga. JSM state dump timeout needs to be really long for the new fpga model releases.

Enable punit on fpga.

#13 lore raw

PATCH 6/6 accel/ivpu: Move recovery work to system_unbound_wq

In reply to Jacek Lawrynowicz

From: Karol Wachowski <[email protected]>

Recovery work doesn't need to be bound to any specific CPU, so move it to unbound workqueue to improve execution time and system latency.

---
 drivers/accel/ivpu/ivpu_pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_pm.c +1 -1
index 8f6222d157204..d3db944ad8643 100644
@@ -165,7 +165,7 @@ void ivpu_pm_trigger_recovery(struct ivpu_device *vdev, const char *reason)
 	if (atomic_cmpxchg(&vdev->pm->reset_pending, 0, 1) == 0) {
 		ivpu_hw_diagnose_failure(vdev);
 		ivpu_hw_irq_disable(vdev); /* Disable IRQ early to protect from IRQ storm */
-		queue_work(system_long_wq, &vdev->pm->recovery_work);
+		queue_work(system_unbound_wq, &vdev->pm->recovery_work);
 	}
 }
 
Signature · 1 line
2.45.1
Reviewed-by on v1 6/6
#14 lore raw

Re: [PATCH 6/6] accel/ivpu: Move recovery work to system_unbound_wq

Quoted 8 lines · Jacek Lawrynowicz

From: Karol Wachowski <[email protected]>

Recovery work doesn't need to be bound to any specific CPU, so move it to unbound workqueue to improve execution time and system latency.

author Applied
#15 lore raw
In reply to Jacek Lawrynowicz

Applied to drm-misc-next

Quoted 26 lines · Jacek Lawrynowicz

Most notable is the addition of hardware fault injection support which allows to test error handling paths in the driver.

Jacek Lawrynowicz (2):
accel/ivpu: Add support for hardware fault injection accel/ivpu: Update last_busy in IRQ handler

Karol Wachowski (3):
accel/ivpu: Fix missing MMU events if file_priv is unbound accel/ivpu: Turn on HWS by default on all platforms accel/ivpu: Move recovery work to system_unbound_wq

Tomasz Rusinowicz (1):
accel/ivpu: Enable recovery and adjust timeouts for fpga

 drivers/accel/ivpu/ivpu_debugfs.c   |  5 +++
 drivers/accel/ivpu/ivpu_fw.c        | 10 +----
 drivers/accel/ivpu/ivpu_hw.c        | 33 +++++++++++----
 drivers/accel/ivpu/ivpu_hw_ip.c     |  4 +-
 drivers/accel/ivpu/ivpu_hw_reg_io.h | 64 +++++++++++++++++------------
 drivers/accel/ivpu/ivpu_job.c       |  8 +++-
 drivers/accel/ivpu/ivpu_pm.c        |  7 +---
 7 files changed, 78 insertions(+), 53 deletions(-)

--
2.45.1