Commit ab440d3e authored by Oded Gabbay's avatar Oded Gabbay

habanalabs: abort reset on invalid request

Hard-reset is mutually exclusive with reset-on-device-release.
Therefore, if such a request arrives to the reset function, abort
the reset and return an error to the callee.
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent a1b838ad
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright 2016-2019 HabanaLabs, Ltd. * Copyright 2016-2021 HabanaLabs, Ltd.
* All Rights Reserved. * All Rights Reserved.
*/ */
...@@ -1020,8 +1020,8 @@ static void handle_reset_trigger(struct hl_device *hdev, u32 flags) ...@@ -1020,8 +1020,8 @@ static void handle_reset_trigger(struct hl_device *hdev, u32 flags)
*/ */
int hl_device_reset(struct hl_device *hdev, u32 flags) int hl_device_reset(struct hl_device *hdev, u32 flags)
{ {
u64 idle_mask[HL_BUSY_ENGINES_MASK_EXT_SIZE] = {0};
bool hard_reset, from_hard_reset_thread, fw_reset, hard_instead_soft = false; bool hard_reset, from_hard_reset_thread, fw_reset, hard_instead_soft = false;
u64 idle_mask[HL_BUSY_ENGINES_MASK_EXT_SIZE] = {0};
int i, rc; int i, rc;
if (!hdev->init_done) { if (!hdev->init_done) {
...@@ -1039,11 +1039,13 @@ int hl_device_reset(struct hl_device *hdev, u32 flags) ...@@ -1039,11 +1039,13 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
hard_reset = true; hard_reset = true;
} }
if (hdev->reset_upon_device_release && if (hdev->reset_upon_device_release && (flags & HL_DRV_RESET_DEV_RELEASE)) {
(flags & HL_DRV_RESET_DEV_RELEASE)) { if (hard_reset) {
dev_dbg(hdev->dev, dev_crit(hdev->dev,
"Perform %s-reset upon device release\n", "Aborting reset because hard-reset is mutually exclusive with reset-on-device-release\n");
hard_reset ? "hard" : "soft"); return -EINVAL;
}
goto do_reset; goto do_reset;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment