pvr_debugfs.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-License-Identifier: GPL-2.0-only OR MIT
  2. /* Copyright (c) 2023 Imagination Technologies Ltd. */
  3. #include "pvr_debugfs.h"
  4. #include "pvr_device.h"
  5. #include "pvr_fw_trace.h"
  6. #include "pvr_params.h"
  7. #include <linux/dcache.h>
  8. #include <linux/debugfs.h>
  9. #include <linux/err.h>
  10. #include <linux/kernel.h>
  11. #include <linux/types.h>
  12. #include <drm/drm_device.h>
  13. #include <drm/drm_file.h>
  14. #include <drm/drm_print.h>
  15. static const struct pvr_debugfs_entry pvr_debugfs_entries[] = {
  16. {"pvr_params", pvr_params_debugfs_init},
  17. {"pvr_fw", pvr_fw_trace_debugfs_init},
  18. };
  19. void
  20. pvr_debugfs_init(struct drm_minor *minor)
  21. {
  22. struct drm_device *drm_dev = minor->dev;
  23. struct pvr_device *pvr_dev = to_pvr_device(drm_dev);
  24. struct dentry *root = minor->debugfs_root;
  25. size_t i;
  26. for (i = 0; i < ARRAY_SIZE(pvr_debugfs_entries); ++i) {
  27. const struct pvr_debugfs_entry *entry = &pvr_debugfs_entries[i];
  28. struct dentry *dir;
  29. dir = debugfs_create_dir(entry->name, root);
  30. if (IS_ERR(dir)) {
  31. drm_warn(drm_dev,
  32. "failed to create debugfs dir '%s' (err=%d)",
  33. entry->name, (int)PTR_ERR(dir));
  34. continue;
  35. }
  36. entry->init(pvr_dev, dir);
  37. }
  38. }
  39. /*
  40. * Since all entries are created under &drm_minor->debugfs_root, there's no
  41. * need for a pvr_debugfs_fini() as DRM will clean up everything under its root
  42. * automatically.
  43. */