kfd_debugfs.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2016-2017 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #include <linux/debugfs.h>
  23. #include "kfd_priv.h"
  24. static struct dentry *debugfs_root;
  25. static int kfd_debugfs_open(struct inode *inode, struct file *file)
  26. {
  27. int (*show)(struct seq_file *, void *) = inode->i_private;
  28. return single_open(file, show, NULL);
  29. }
  30. static const struct file_operations kfd_debugfs_fops = {
  31. .owner = THIS_MODULE,
  32. .open = kfd_debugfs_open,
  33. .read = seq_read,
  34. .llseek = seq_lseek,
  35. .release = single_release,
  36. };
  37. void kfd_debugfs_init(void)
  38. {
  39. struct dentry *ent;
  40. debugfs_root = debugfs_create_dir("kfd", NULL);
  41. if (!debugfs_root || debugfs_root == ERR_PTR(-ENODEV)) {
  42. pr_warn("Failed to create kfd debugfs dir\n");
  43. return;
  44. }
  45. ent = debugfs_create_file("mqds", S_IFREG | 0444, debugfs_root,
  46. kfd_debugfs_mqds_by_process,
  47. &kfd_debugfs_fops);
  48. if (!ent)
  49. pr_warn("Failed to create mqds in kfd debugfs\n");
  50. ent = debugfs_create_file("hqds", S_IFREG | 0444, debugfs_root,
  51. kfd_debugfs_hqds_by_device,
  52. &kfd_debugfs_fops);
  53. if (!ent)
  54. pr_warn("Failed to create hqds in kfd debugfs\n");
  55. ent = debugfs_create_file("rls", S_IFREG | 0444, debugfs_root,
  56. kfd_debugfs_rls_by_device,
  57. &kfd_debugfs_fops);
  58. if (!ent)
  59. pr_warn("Failed to create rls in kfd debugfs\n");
  60. }
  61. void kfd_debugfs_fini(void)
  62. {
  63. debugfs_remove_recursive(debugfs_root);
  64. }