diff options
author | Koby Elbaz <kelbaz@habana.ai> | 2023-04-17 15:14:30 +0300 |
---|---|---|
committer | Oded Gabbay <ogabbay@kernel.org> | 2023-06-08 12:35:54 +0300 |
commit | ad8bfd3619bb096dd1929a69989120b45e3c3eee (patch) | |
tree | c4bdf1eb58f042a0847648bc91d6b61ff0959e38 /drivers/accel | |
parent | 04729b418f8b031712e6dbf5bffa7d639f8f211e (diff) | |
download | linux-stable-ad8bfd3619bb096dd1929a69989120b45e3c3eee.tar.gz linux-stable-ad8bfd3619bb096dd1929a69989120b45e3c3eee.tar.bz2 linux-stable-ad8bfd3619bb096dd1929a69989120b45e3c3eee.zip |
accel/habanalabs: minimize encapsulation signal mutex lock time
Sync Stream Encapsulated Signal Handlers can be managed from different
contexts, and as such they are protected via a spin_lock.
However, spin_lock was unnecessarily protecting a larger code section
than really needed, covering a sleepable code section as well.
Since spin_lock disables preemption, it could lead to sleeping in
atomic context.
Signed-off-by: Koby Elbaz <kelbaz@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/accel')
-rw-r--r-- | drivers/accel/habanalabs/common/command_submission.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/accel/habanalabs/common/command_submission.c b/drivers/accel/habanalabs/common/command_submission.c index af9d2e22c6e7..977cd2710686 100644 --- a/drivers/accel/habanalabs/common/command_submission.c +++ b/drivers/accel/habanalabs/common/command_submission.c @@ -2152,7 +2152,7 @@ static int cs_ioctl_unreserve_signals(struct hl_fpriv *hpriv, u32 handle_id) hdev->asic_funcs->hw_queues_unlock(hdev); rc = -EINVAL; - goto out; + goto out_unlock; } /* @@ -2167,15 +2167,21 @@ static int cs_ioctl_unreserve_signals(struct hl_fpriv *hpriv, u32 handle_id) /* Release the id and free allocated memory of the handle */ idr_remove(&mgr->handles, handle_id); + + /* unlock before calling ctx_put, where we might sleep */ + spin_unlock(&mgr->lock); hl_ctx_put(encaps_sig_hdl->ctx); kfree(encaps_sig_hdl); + goto out; } else { rc = -EINVAL; dev_err(hdev->dev, "failed to unreserve signals, cannot find handler\n"); } -out: + +out_unlock: spin_unlock(&mgr->lock); +out: return rc; } |