All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oded Gabbay <ogabbay@kernel.org>
To: dri-devel@lists.freedesktop.org
Cc: Dafna Hirschfeld <dhirschfeld@habana.ai>
Subject: [PATCH 3/6] accel/habanalabs: check return value of add_va_block_locked
Date: Thu, 23 Mar 2023 13:35:22 +0200	[thread overview]
Message-ID: <20230323113525.959176-3-ogabbay@kernel.org> (raw)
In-Reply-To: <20230323113525.959176-1-ogabbay@kernel.org>

From: Dafna Hirschfeld <dhirschfeld@habana.ai>

since the function might fail and we should propagate the failure.

Signed-off-by: Dafna Hirschfeld <dhirschfeld@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
 drivers/accel/habanalabs/common/memory.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/accel/habanalabs/common/memory.c b/drivers/accel/habanalabs/common/memory.c
index 17b79d717896..a7b6a273ce21 100644
--- a/drivers/accel/habanalabs/common/memory.c
+++ b/drivers/accel/habanalabs/common/memory.c
@@ -605,6 +605,7 @@ static u64 get_va_block(struct hl_device *hdev,
 	bool is_align_pow_2  = is_power_of_2(va_range->page_size);
 	bool is_hint_dram_addr = hl_is_dram_va(hdev, hint_addr);
 	bool force_hint = flags & HL_MEM_FORCE_HINT;
+	int rc;
 
 	if (is_align_pow_2)
 		align_mask = ~((u64)va_block_align - 1);
@@ -722,9 +723,13 @@ static u64 get_va_block(struct hl_device *hdev,
 		kfree(new_va_block);
 	}
 
-	if (add_prev)
-		add_va_block_locked(hdev, &va_range->list, prev_start,
-				prev_end);
+	if (add_prev) {
+		rc = add_va_block_locked(hdev, &va_range->list, prev_start, prev_end);
+		if (rc) {
+			reserved_valid_start = 0;
+			goto out;
+		}
+	}
 
 	print_va_list_locked(hdev, &va_range->list);
 out:
-- 
2.40.0


  parent reply	other threads:[~2023-03-23 11:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 11:35 [PATCH 1/6] accel/habanalabs: unmap mapped memory when TLB inv fails Oded Gabbay
2023-03-23 11:35 ` [PATCH 2/6] accel/habanalabs: print event type when device is disabled Oded Gabbay
2023-03-24  8:19   ` Stanislaw Gruszka
2023-03-23 11:35 ` Oded Gabbay [this message]
2023-03-24  8:28   ` [PATCH 3/6] accel/habanalabs: check return value of add_va_block_locked Stanislaw Gruszka
2023-03-23 11:35 ` [PATCH 4/6] accel/habanalabs: change COMMS warning messages to error level Oded Gabbay
2023-03-24  8:28   ` Stanislaw Gruszka
2023-03-23 11:35 ` [PATCH 5/6] accel/habanalabs: remove duplicated disable pci msg Oded Gabbay
2023-03-24  8:31   ` Stanislaw Gruszka
2023-03-23 11:35 ` [PATCH 6/6] accel/habanalabs: send disable pci when compute ctx is active Oded Gabbay
2023-03-24  8:31   ` Stanislaw Gruszka
2023-03-24  8:18 ` [PATCH 1/6] accel/habanalabs: unmap mapped memory when TLB inv fails Stanislaw Gruszka

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=20230323113525.959176-3-ogabbay@kernel.org \
    --to=ogabbay@kernel.org \
    --cc=dhirschfeld@habana.ai \
    --cc=dri-devel@lists.freedesktop.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.