Skip to contentSkip to conversation

accel/habanalabs: unsecure TSB_CFG_MTRR regs

PATCH New Oded Gabbay 1 participant 3 messages May 28, 2023

Subsystems (2)
lore
Share & tools
lore

Oded Gabbay

author maintainer
#0 lore raw

PATCH 1/3 accel/habanalabs: unsecure TSB_CFG_MTRR regs

From: Ofir Bitton <[email protected]>

In order to utilize Engine Barrier padding, user must have access to this register set.

---
 drivers/accel/habanalabs/gaudi2/gaudi2_security.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/accel/habanalabs/gaudi2/gaudi2_security.c +4 -0
index fadb870ff4c0..2742b1f801eb 100644
@@ -1534,6 +1534,10 @@ static const u32 gaudi2_pb_dcr0_tpc0_unsecured_regs[] = {
 	mmDCORE0_TPC0_CFG_QM_KERNEL_CONFIG,
 	mmDCORE0_TPC0_CFG_QM_KERNEL_ID,
 	mmDCORE0_TPC0_CFG_QM_POWER_LOOP,
+	mmDCORE0_TPC0_CFG_TSB_CFG_MTRR_2_0,
+	mmDCORE0_TPC0_CFG_TSB_CFG_MTRR_2_1,
+	mmDCORE0_TPC0_CFG_TSB_CFG_MTRR_2_2,
+	mmDCORE0_TPC0_CFG_TSB_CFG_MTRR_2_3,
 	mmDCORE0_TPC0_CFG_LUT_FUNC32_BASE2_ADDR_LO,
 	mmDCORE0_TPC0_CFG_LUT_FUNC32_BASE2_ADDR_HI,
 	mmDCORE0_TPC0_CFG_LUT_FUNC64_BASE2_ADDR_LO,
Signature · 1 line
2.40.1
author maintainer
#1 lore raw

PATCH 2/3 accel/habanalabs: add event queue extra validation

From: Ofir Bitton <[email protected]>

In order to increase reliability of the event queue interface, we apply to Gaudi2 the same mechanism we have in Gaudi1. The extra validation is basically checking that the received event index matches the expected index.

---
 drivers/accel/habanalabs/common/irq.c    | 2 +-
 drivers/accel/habanalabs/gaudi2/gaudi2.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/accel/habanalabs/common/irq.c +1 -1
index c67895b1cdeb..b1010d206c2e 100644
@@ -430,7 +430,7 @@ irqreturn_t hl_irq_handler_eq(int irq, void *arg)
 		cur_eqe_index = FIELD_GET(EQ_CTL_INDEX_MASK, cur_eqe);
 		if ((hdev->event_queue.check_eqe_index) &&
 				(((eq->prev_eqe_index + 1) & EQ_CTL_INDEX_MASK) != cur_eqe_index)) {
-			dev_dbg(hdev->dev,
+			dev_err(hdev->dev,
 				"EQE %#x in queue is ready but index does not match %d!=%d",
 				cur_eqe,
 				((eq->prev_eqe_index + 1) & EQ_CTL_INDEX_MASK),
drivers/accel/habanalabs/gaudi2/gaudi2.c +6 -0
index 0d41adf4792c..20c4583f12b0 100644
@@ -3619,6 +3619,12 @@ static int gaudi2_sw_init(struct hl_device *hdev)
 
 	prop->supports_compute_reset = true;
 
+	/* Event queue sanity check added in FW version 1.11 */
+	if (hl_is_fw_sw_ver_below(hdev, 1, 11))
+		hdev->event_queue.check_eqe_index = false;
+	else
+		hdev->event_queue.check_eqe_index = true;
+
 	hdev->asic_funcs->set_pci_memory_regions(hdev);
 
 	rc = gaudi2_special_blocks_iterator_config(hdev);
Signature · 1 line
2.40.1
author maintainer
#2 lore raw

PATCH 3/3 accel/habanalabs: refactor error info reset

In reply to Oded Gabbay

From: Dani Liberman <[email protected]>

Moved error info reset code to single function for future use from other places in the driver.

---
 drivers/accel/habanalabs/common/device.c         | 8 ++++++++
 drivers/accel/habanalabs/common/habanalabs.h     | 1 +
 drivers/accel/habanalabs/common/habanalabs_drv.c | 5 +----
 3 files changed, 10 insertions(+), 4 deletions(-)
drivers/accel/habanalabs/common/device.c +8 -0
index ea02f2cfdf81..b97339d1f7c6 100644
@@ -2689,3 +2689,11 @@ void hl_handle_fw_err(struct hl_device *hdev, struct hl_info_fw_err_info *info)
 	if (info->event_mask)
 		*info->event_mask |= HL_NOTIFIER_EVENT_CRITICL_FW_ERR;
 }
+
+void hl_enable_err_info_capture(struct hl_error_info *captured_err_info)
+{
+	vfree(captured_err_info->page_fault_info.user_mappings);
+	memset(captured_err_info, 0, sizeof(struct hl_error_info));
+	atomic_set(&captured_err_info->cs_timeout.write_enable, 1);
+	captured_err_info->undef_opcode.write_enable = true;
+}
drivers/accel/habanalabs/common/habanalabs.h +1 -0
index c5aa33eaa826..d92ba2e30e31 100644
@@ -3944,6 +3944,7 @@ void hl_handle_page_fault(struct hl_device *hdev, u64 addr, u16 eng_id, bool is_
 				u64 *event_mask);
 void hl_handle_critical_hw_err(struct hl_device *hdev, u16 event_id, u64 *event_mask);
 void hl_handle_fw_err(struct hl_device *hdev, struct hl_info_fw_err_info *info);
+void hl_enable_err_info_capture(struct hl_error_info *captured_err_info);
 
 #ifdef CONFIG_DEBUG_FS
 
drivers/accel/habanalabs/common/habanalabs_drv.c +1 -4
index 446f444a1c7e..7263e84c1a4d 100644
@@ -219,10 +219,7 @@ int hl_device_open(struct inode *inode, struct file *filp)
 
 	hl_debugfs_add_file(hpriv);
 
-	vfree(hdev->captured_err_info.page_fault_info.user_mappings);
-	memset(&hdev->captured_err_info, 0, sizeof(hdev->captured_err_info));
-	atomic_set(&hdev->captured_err_info.cs_timeout.write_enable, 1);
-	hdev->captured_err_info.undef_opcode.write_enable = true;
+	hl_enable_err_info_capture(&hdev->captured_err_info);
 
 	hdev->open_counter++;
 	hdev->last_successful_open_jif = jiffies;
Signature · 1 line
2.40.1