LKML Archive on
help / color / mirror / Atom feed
* [PATCH] habanalabs: context cleanup cosmetics
@ 2021-10-13  8:33 Oded Gabbay
  0 siblings, 0 replies; only message in thread
From: Oded Gabbay @ 2021-10-13  8:33 UTC (permalink / raw)
  To: linux-kernel; +Cc: Omer Shpigelman

From: Omer Shpigelman <>

No need to check the return value if the following action is the same for
both cases. In addition, now that hl_ctx_free() doesn't print if the
context is not released, its name can be misleading as the context might
stay alive after it is executed with no indication for that.
Hence we can discard it and simply put the refcount.

Signed-off-by: Omer Shpigelman <>
Reviewed-by: Oded Gabbay <>
Signed-off-by: Oded Gabbay <>
 drivers/misc/habanalabs/common/context.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/misc/habanalabs/common/context.c b/drivers/misc/habanalabs/common/context.c
index 22978303ad63..d0aaccd4df2c 100644
--- a/drivers/misc/habanalabs/common/context.c
+++ b/drivers/misc/habanalabs/common/context.c
@@ -181,12 +181,6 @@ int hl_ctx_create(struct hl_device *hdev, struct hl_fpriv *hpriv)
 	return rc;
-void hl_ctx_free(struct hl_device *hdev, struct hl_ctx *ctx)
-	if (kref_put(&ctx->refcount, hl_ctx_do_release) == 1)
-		return;
 int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)
 	int rc = 0;
@@ -392,7 +386,7 @@ void hl_ctx_mgr_fini(struct hl_device *hdev, struct hl_ctx_mgr *mgr)
 	idp = &mgr->ctx_handles;
 	idr_for_each_entry(idp, ctx, id)
-		hl_ctx_free(hdev, ctx);
+		kref_put(&ctx->refcount, hl_ctx_do_release);

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-13  8:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13  8:33 [PATCH] habanalabs: context cleanup cosmetics Oded Gabbay

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).