summaryrefslogtreecommitdiffstats
path: root/drivers/misc/habanalabs/habanalabs_drv.c
diff options
context:
space:
mode:
authorOded Gabbay <oded.gabbay@gmail.com>2019-02-15 23:39:24 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-18 09:46:46 +0100
commitc216477363a37a7d0a388315a2eb6c1bd965bdb8 (patch)
tree908c21b4d3e5b7b1ac735f08a3bce586262d6030 /drivers/misc/habanalabs/habanalabs_drv.c
parenthabanalabs: implement INFO IOCTL (diff)
downloadlinux-c216477363a37a7d0a388315a2eb6c1bd965bdb8.tar.xz
linux-c216477363a37a7d0a388315a2eb6c1bd965bdb8.zip
habanalabs: add debugfs support
This patch adds debugfs support to the driver. It allows the user-space to display information that is contained in the internal structures of the driver, such as: - active command submissions - active user virtual memory mappings - number of allocated command buffers It also enables the user to perform reads and writes through Goya's PCI bars. Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/habanalabs/habanalabs_drv.c')
-rw-r--r--drivers/misc/habanalabs/habanalabs_drv.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/misc/habanalabs/habanalabs_drv.c b/drivers/misc/habanalabs/habanalabs_drv.c
index 436ccae0989d..bd8994621e37 100644
--- a/drivers/misc/habanalabs/habanalabs_drv.c
+++ b/drivers/misc/habanalabs/habanalabs_drv.c
@@ -146,6 +146,8 @@ int hl_device_open(struct inode *inode, struct file *filp)
*/
hl_device_set_frequency(hdev, PLL_HIGH);
+ hl_debugfs_add_file(hpriv);
+
return 0;
out_err:
@@ -413,17 +415,20 @@ static int __init hl_init(void)
goto remove_major;
}
+ hl_debugfs_init();
+
rc = pci_register_driver(&hl_pci_driver);
if (rc) {
pr_err("failed to register pci device\n");
- goto remove_class;
+ goto remove_debugfs;
}
pr_debug("driver loaded\n");
return 0;
-remove_class:
+remove_debugfs:
+ hl_debugfs_fini();
class_destroy(hl_class);
remove_major:
unregister_chrdev_region(MKDEV(hl_major, 0), HL_MAX_MINORS);
@@ -437,6 +442,13 @@ static void __exit hl_exit(void)
{
pci_unregister_driver(&hl_pci_driver);
+ /*
+ * Removing debugfs must be after all devices or simulator devices
+ * have been removed because otherwise we get a bug in the
+ * debugfs module for referencing NULL objects
+ */
+ hl_debugfs_fini();
+
class_destroy(hl_class);
unregister_chrdev_region(MKDEV(hl_major, 0), HL_MAX_MINORS);