LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Oded Gabbay <ogabbay@kernel.org> To: linux-kernel@vger.kernel.org Subject: [PATCH 3/4] habanalabs: remove unnecessary device status check Date: Fri, 20 Aug 2021 18:07:18 +0300 [thread overview] Message-ID: <20210820150719.67934-3-ogabbay@kernel.org> (raw) In-Reply-To: <20210820150719.67934-1-ogabbay@kernel.org> Checking if the device is operational when entering the function to wait for user interrupt is not something that is useful or necessary. It is not done in any other wait_for_cs ioctl path. If the device becomes non-operational during the wait, the reset function will make sure the process wait is interrupted. Instead, move the check to the beginning of hl_wait_ioctl(). It will block any attempt to wait on CS or user interrupt once the device is already marked as non-operational. Signed-off-by: Oded Gabbay <ogabbay@kernel.org> --- drivers/misc/habanalabs/common/command_submission.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/misc/habanalabs/common/command_submission.c b/drivers/misc/habanalabs/common/command_submission.c index 8a2f75de6df8..a97bb27ebb90 100644 --- a/drivers/misc/habanalabs/common/command_submission.c +++ b/drivers/misc/habanalabs/common/command_submission.c @@ -2741,10 +2741,6 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx, interrupt = &hdev->user_interrupt[interrupt_offset]; spin_lock_irqsave(&interrupt->wait_list_lock, flags); - if (!hl_device_operational(hdev, NULL)) { - rc = -EPERM; - goto unlock_and_free_fence; - } if (copy_from_user(&completion_value, u64_to_user_ptr(user_address), 4)) { @@ -2891,6 +2887,12 @@ int hl_wait_ioctl(struct hl_fpriv *hpriv, void *data) u32 flags = args->in.flags; int rc; + /* If the device is not operational, no point in waiting for any command submission or + * user interrupt + */ + if (!hl_device_operational(hpriv->hdev, NULL)) + return -EPERM; + if (flags & HL_WAIT_CS_FLAGS_INTERRUPT) rc = hl_interrupt_wait_ioctl(hpriv, data); else if (flags & HL_WAIT_CS_FLAGS_MULTI_CS) -- 2.17.1
next prev parent reply other threads:[~2021-08-20 15:07 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-20 15:07 [PATCH 1/4] habanalabs: add "in device creation" status Oded Gabbay 2021-08-20 15:07 ` [PATCH 2/4] habanalabs: disable IRQ in user interrupts spinlock Oded Gabbay 2021-08-20 15:07 ` Oded Gabbay [this message] 2021-08-20 15:07 ` [PATCH 4/4] habanalabs: never copy_from_user inside spinlock Oded Gabbay 2021-08-21 11:04 ` 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=20210820150719.67934-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: linkBe 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; as well as URLs for NNTP newsgroup(s).