diff mbox series

[12/12] accel/habanalabs: release user interfaces earlier in device fini

Message ID 20230711111226.163670-12-ogabbay@kernel.org (mailing list archive)
State New, archived
Headers show
Series [01/12] accel/habanalabs/gaudi2: un-secure register for engine cores interrupt | expand

Commit Message

Oded Gabbay July 11, 2023, 11:12 a.m. UTC
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 mbox series

Patch

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");
 }