]> git.baikalelectronics.ru Git - kernel.git/commitdiff
habanalabs/gaudi: invoke device reset from one code block
authorTal Cohen <talcohen@habana.ai>
Wed, 8 Jun 2022 13:02:09 +0000 (16:02 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Tue, 12 Jul 2022 06:09:22 +0000 (09:09 +0300)
In order to prepare the driver code for device reset event
notification, change the event handler function flow to call
device reset from one code block.

In addition, the commit fixes an issue that reset was performed
w/o checking the 'hard_reset_on_fw_event' state and w/o setting
the HL_DRV_RESET_DELAY flag.

Signed-off-by: Tal Cohen <talcohen@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/gaudi/gaudi.c

index ec9f0a93cbe2657e4fffcb025d7072283d52a51b..8f37297b2c3bfadc77de4b5fc0390c2424e96a58 100644 (file)
@@ -7795,10 +7795,10 @@ static void gaudi_handle_eqe(struct hl_device *hdev,
        struct gaudi_device *gaudi = hdev->asic_specific;
        u64 data = le64_to_cpu(eq_entry->data[0]), event_mask = 0;
        u32 ctl = le32_to_cpu(eq_entry->hdr.ctl);
-       u32 fw_fatal_err_flag = 0;
+       u32 fw_fatal_err_flag = 0, flags = 0;
        u16 event_type = ((ctl & EQ_CTL_EVENT_TYPE_MASK)
                        >> EQ_CTL_EVENT_TYPE_SHIFT);
-       bool reset_required;
+       bool reset_required, reset_direct = false;
        u8 cause;
        int rc;
 
@@ -7886,7 +7886,8 @@ static void gaudi_handle_eqe(struct hl_device *hdev,
                        dev_err(hdev->dev, "reset required due to %s\n",
                                gaudi_irq_map_table[event_type].name);
 
-                       hl_device_reset(hdev, 0);
+                       reset_direct = true;
+                       goto reset_device;
                } else {
                        hl_fw_unmask_irq(hdev, event_type);
                }
@@ -7908,7 +7909,8 @@ static void gaudi_handle_eqe(struct hl_device *hdev,
                        dev_err(hdev->dev, "reset required due to %s\n",
                                gaudi_irq_map_table[event_type].name);
 
-                       hl_device_reset(hdev, 0);
+                       reset_direct = true;
+                       goto reset_device;
                } else {
                        hl_fw_unmask_irq(hdev, event_type);
                }
@@ -8050,12 +8052,17 @@ static void gaudi_handle_eqe(struct hl_device *hdev,
        return;
 
 reset_device:
-       if (hdev->asic_prop.fw_security_enabled)
-               hl_device_reset(hdev, HL_DRV_RESET_HARD
-                                       | HL_DRV_RESET_BYPASS_REQ_TO_FW
-                                       | fw_fatal_err_flag);
+       reset_required = true;
+
+       if (hdev->asic_prop.fw_security_enabled && !reset_direct)
+               flags = HL_DRV_RESET_HARD | HL_DRV_RESET_BYPASS_REQ_TO_FW | fw_fatal_err_flag;
        else if (hdev->hard_reset_on_fw_events)
-               hl_device_reset(hdev, HL_DRV_RESET_HARD | HL_DRV_RESET_DELAY | fw_fatal_err_flag);
+               flags = HL_DRV_RESET_HARD | HL_DRV_RESET_DELAY | fw_fatal_err_flag;
+       else
+               reset_required = false;
+
+       if (reset_required)
+               hl_device_reset(hdev, flags);
        else
                hl_fw_unmask_irq(hdev, event_type);
 }