dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Oded Gabbay <ogabbay@kernel.org>
To: dri-devel@lists.freedesktop.org
Cc: Tomer Tayar <ttayar@habana.ai>
Subject: [PATCH 12/12] accel/habanalabs: release user interfaces earlier in device fini
Date: Tue, 11 Jul 2023 14:12:26 +0300	[thread overview]
Message-ID: <20230711111226.163670-12-ogabbay@kernel.org> (raw)
In-Reply-To: <20230711111226.163670-1-ogabbay@kernel.org>

From: Tomer Tayar <ttayar@habana.ai>

Currently the sysfs/debugfs interfaces and device un-registration are
done as the last thing in hl_device_fini(), after several finalizations
and releases are done.
While a disabled flag is set at the beginning of hl_device_fini(), and
it is being checked when handling user accesses to these interfaces,
this check is not hermetic and it is better to just reverse the order
of the code in hl_device_fini().

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
 drivers/accel/habanalabs/common/device.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/accel/habanalabs/common/device.c b/drivers/accel/habanalabs/common/device.c
index c0c9e9504672..5293ac3c7988 100644
--- a/drivers/accel/habanalabs/common/device.c
+++ b/drivers/accel/habanalabs/common/device.c
@@ -2408,6 +2408,12 @@ void hl_device_fini(struct hl_device *hdev)
 
 	hdev->fw_loader.fw_comp_loaded = FW_TYPE_NONE;
 
+	/* Hide devices and sysfs/debugfs files from user */
+	cdev_sysfs_debugfs_remove(hdev);
+	drm_dev_unregister(&hdev->drm);
+
+	hl_debugfs_device_fini(hdev);
+
 	/* Release kernel context */
 	if ((hdev->kernel_ctx) && (hl_ctx_put(hdev->kernel_ctx) != 1))
 		dev_err(hdev->dev, "kernel ctx is still alive\n");
@@ -2436,12 +2442,6 @@ void hl_device_fini(struct hl_device *hdev)
 
 	device_early_fini(hdev);
 
-	/* Hide devices and sysfs/debugfs files from user */
-	cdev_sysfs_debugfs_remove(hdev);
-	drm_dev_unregister(&hdev->drm);
-
-	hl_debugfs_device_fini(hdev);
-
 	pr_info("removed device successfully\n");
 }
 
-- 
2.34.1


      parent reply	other threads:[~2023-07-11 11:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 11:12 [PATCH 01/12] accel/habanalabs/gaudi2: un-secure register for engine cores interrupt Oded Gabbay
2023-07-11 11:12 ` [PATCH 02/12] accel/habanalabs/gaudi2: unsecure tpc count registers Oded Gabbay
2023-07-11 11:12 ` [PATCH 03/12] accel/habanalabs/gaudi2: prepare to remove soft_rst_irq Oded Gabbay
2023-07-11 11:12 ` [PATCH 04/12] accel/habanalabs/gaudi2: fix missing check of kernel ctx Oded Gabbay
2023-07-12 11:58   ` Ofir Bitton
2023-07-11 11:12 ` [PATCH 05/12] accel/habanalabs: handle f/w reserved dram space request Oded Gabbay
2023-07-11 11:12 ` [PATCH 06/12] accel/habanalabs: set default device release watchdog T/O as 30 sec Oded Gabbay
2023-07-11 11:12 ` [PATCH 07/12] accel/habanalabs: add info ioctl for engine error reports Oded Gabbay
2023-07-11 11:12 ` [PATCH 08/12] accel/habanalabs: register compute device as an accel device Oded Gabbay
2023-07-11 11:12 ` [PATCH 09/12] accel/habanalabs: update sysfs-driver-habanalabs with the accel path Oded Gabbay
2023-07-11 11:12 ` [PATCH 10/12] accel/habanalabs: update debugfs-driver-habanalabs " Oded Gabbay
2023-07-11 11:12 ` [PATCH 11/12] accel/habanalabs: Move ioctls to the device specific ioctls range Oded Gabbay
2023-07-11 11:12 ` Oded Gabbay [this message]

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=20230711111226.163670-12-ogabbay@kernel.org \
    --to=ogabbay@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ttayar@habana.ai \
    /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