From: Oded Gabbay <ogabbay@kernel.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 3/7] habanalabs: re-init completion object upon retry
Date: Thu, 1 Jul 2021 14:27:13 +0300 [thread overview]
Message-ID: <20210701112717.9540-3-ogabbay@kernel.org> (raw)
In-Reply-To: <20210701112717.9540-1-ogabbay@kernel.org>
In case user interrupt arrived but the completion value is less than
the target value, we want to retry the wait.
However, before the retry we must reinitialize the completion object,
under spin-lock, so the wait function won't exit immediately because
the completion object is already completed (from the previous
interrupt).
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
drivers/misc/habanalabs/common/command_submission.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/habanalabs/common/command_submission.c b/drivers/misc/habanalabs/common/command_submission.c
index 80c60fb41bbc..12f20446e99a 100644
--- a/drivers/misc/habanalabs/common/command_submission.c
+++ b/drivers/misc/habanalabs/common/command_submission.c
@@ -2046,7 +2046,8 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
goto unlock_and_free_fence;
}
- if (copy_from_user(&completion_value, u64_to_user_ptr(user_address), 4)) {
+ if (copy_from_user(&completion_value, u64_to_user_ptr(user_address),
+ 4)) {
dev_err(hdev->dev,
"Failed to copy completion value from user\n");
rc = -EFAULT;
@@ -2077,18 +2078,28 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
* If comparison fails, keep waiting until timeout expires
*/
if (completion_rc > 0) {
+ spin_lock(&interrupt->wait_list_lock);
+
if (copy_from_user(&completion_value,
u64_to_user_ptr(user_address), 4)) {
+
+ spin_unlock(&interrupt->wait_list_lock);
+
dev_err(hdev->dev,
"Failed to copy completion value from user\n");
rc = -EFAULT;
+
goto remove_pending_user_interrupt;
}
if (completion_value >= target_value) {
+ spin_unlock(&interrupt->wait_list_lock);
*status = CS_WAIT_STATUS_COMPLETED;
} else {
+ reinit_completion(&pend->fence.completion);
timeout = completion_rc;
+
+ spin_unlock(&interrupt->wait_list_lock);
goto wait_again;
}
} else {
--
2.25.1
next prev parent reply other threads:[~2021-07-01 11:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-01 11:27 [PATCH 1/7] habanalabs: update firmware header files Oded Gabbay
2021-07-01 11:27 ` [PATCH 2/7] habanalabs: rename enum vm_type_t to vm_type Oded Gabbay
2021-07-01 11:27 ` Oded Gabbay [this message]
2021-07-01 11:27 ` [PATCH 4/7] habanalabs: release pending user interrupts on device fini Oded Gabbay
2021-07-01 11:27 ` [PATCH 5/7] habanalabs: handle case of interruptable wait Oded Gabbay
2021-07-01 11:27 ` [PATCH 6/7] habanalabs: user mappings can be 64-bit Oded Gabbay
2021-07-01 11:27 ` [PATCH 7/7] habanalabs: allow disabling huge page use 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=20210701112717.9540-3-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