summaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorOded Gabbay <ogabbay@kernel.org>2022-07-07 11:39:19 +0300
committerOded Gabbay <ogabbay@kernel.org>2022-07-12 09:09:31 +0300
commitbd4a338886a8cc5809f45d569df395acb846ce8e (patch)
tree0b11e7b35f5536011d64d78b8c13602f200f6e7c /drivers/misc
parent08f0aa9548fd624f7ad5ae1135423706b5e9fa6a (diff)
downloadlinux-bd4a338886a8cc5809f45d569df395acb846ce8e.tar.bz2
habanalabs: fix update of is_in_soft_reset
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>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/habanalabs/common/device.c20
1 files 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 @@ do_reset:
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 @@ do_reset:
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 @@ kill_processes:
}
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 @@ kill_processes:
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 @@ out_err:
hdev->reset_info.in_reset = 0;
+ spin_unlock(&hdev->reset_info.lock);
+
return rc;
}