From: Oded Gabbay <ogabbay@kernel.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 09/12] habanalabs: fix update of is_in_soft_reset
Date: Mon, 11 Jul 2022 09:30:00 +0300 [thread overview]
Message-ID: <20220711063003.3182795-9-ogabbay@kernel.org> (raw)
In-Reply-To: <20220711063003.3182795-1-ogabbay@kernel.org>
reset_info.is_in_soft_reset should be updated both before in_reset
and inside the spin lock of the reset info structure.
The reasons are:
- When we are inside soft reset, it implies we are in reset. Therefore,
if someone checks if we are in soft reset, he can deduce we are
in reset, while the opposite is not correct and might be misleading.
- Both these flags are changed together so they must be changed
inside the reset info spinlock.
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
drivers/misc/habanalabs/common/device.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/misc/habanalabs/common/device.c b/drivers/misc/habanalabs/common/device.c
index 4391eb22ddb8..5bc291c11e9b 100644
--- a/drivers/misc/habanalabs/common/device.c
+++ b/drivers/misc/habanalabs/common/device.c
@@ -1346,7 +1346,14 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
spin_unlock(&hdev->reset_info.lock);
return 0;
}
+
+ /* This still allows the completion of some KDMA ops
+ * Update this before in_reset because is_in_soft_reset implies we are in reset
+ */
+ hdev->reset_info.is_in_soft_reset = !hard_reset;
+
hdev->reset_info.in_reset = 1;
+
spin_unlock(&hdev->reset_info.lock);
if (delay_reset)
@@ -1354,9 +1361,6 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
handle_reset_trigger(hdev, flags);
- /* This still allows the completion of some KDMA ops */
- hdev->reset_info.is_in_soft_reset = !hard_reset;
-
/* This also blocks future CS/VM/JOB completion operations */
hdev->disabled = true;
@@ -1565,7 +1569,7 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
}
spin_lock(&hdev->reset_info.lock);
- hdev->reset_info.is_in_soft_reset = false;
+ hdev->reset_info.is_in_soft_reset = 0;
/* Schedule hard reset only if requested and if not already in hard reset.
* We keep 'in_reset' enabled, so no other reset can go in during the hard
@@ -1612,18 +1616,22 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
out_err:
hdev->disabled = true;
- hdev->reset_info.is_in_soft_reset = false;
+
+ spin_lock(&hdev->reset_info.lock);
+ hdev->reset_info.is_in_soft_reset = 0;
if (hard_reset) {
dev_err(hdev->dev, "Failed to reset! Device is NOT usable\n");
hdev->reset_info.hard_reset_cnt++;
} else if (reset_upon_device_release) {
+ spin_unlock(&hdev->reset_info.lock);
dev_err(hdev->dev, "Failed to reset device after user release\n");
flags |= HL_DRV_RESET_HARD;
flags &= ~HL_DRV_RESET_DEV_RELEASE;
hard_reset = true;
goto again;
} else {
+ spin_unlock(&hdev->reset_info.lock);
dev_err(hdev->dev, "Failed to do soft-reset\n");
hdev->reset_info.soft_reset_cnt++;
flags |= HL_DRV_RESET_HARD;
@@ -1633,6 +1641,8 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
hdev->reset_info.in_reset = 0;
+ spin_unlock(&hdev->reset_info.lock);
+
return rc;
}
--
2.25.1
next prev parent reply other threads:[~2022-07-11 6:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 6:29 [PATCH 01/12] habanalabs: fixes to the poll-timeout macros Oded Gabbay
2022-07-11 6:29 ` [PATCH 02/12] habanalabs: add a value field to hl_fw_send_pci_access_msg() Oded Gabbay
2022-07-11 6:29 ` [PATCH 03/12] habanalabs/gaudi2: configure virtual MSI-X doorbell interface Oded Gabbay
2022-07-11 6:29 ` [PATCH 04/12] habanalabs/gaudi2: replace defines for reserved sob/mob with enums Oded Gabbay
2022-07-11 6:29 ` [PATCH 05/12] habanalabs/gaudi2: modify CS completion CQ to use virtual MSI-X doorbell Oded Gabbay
2022-07-11 6:29 ` [PATCH 06/12] habanalabs/gaudi2: modify decoder " Oded Gabbay
2022-07-11 6:29 ` [PATCH 07/12] habanalabs/gaudi2: map virtual MSI-X doorbell memory for user Oded Gabbay
2022-07-11 6:29 ` [PATCH 08/12] habanalabs: expose only valid debugfs nodes Oded Gabbay
2022-07-11 6:30 ` Oded Gabbay [this message]
2022-07-11 6:30 ` [PATCH 10/12] habanalabs: add status of reset after device release Oded Gabbay
2022-07-11 6:30 ` [PATCH 11/12] habanalabs: rename soft reset to compute reset Oded Gabbay
2022-07-11 6:30 ` [PATCH 12/12] habanalabs: move h/w dirty message to debug Oded Gabbay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220711063003.3182795-9-ogabbay@kernel.org \
--to=ogabbay@kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox