hidma_dbg.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Qualcomm Technologies HIDMA debug file
  4. *
  5. * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
  6. */
  7. #include <linux/debugfs.h>
  8. #include <linux/device.h>
  9. #include <linux/list.h>
  10. #include <linux/pm_runtime.h>
  11. #include "hidma.h"
  12. static void hidma_ll_chstats(struct seq_file *s, void *llhndl, u32 tre_ch)
  13. {
  14. struct hidma_lldev *lldev = llhndl;
  15. struct hidma_tre *tre;
  16. u32 length;
  17. dma_addr_t src_start;
  18. dma_addr_t dest_start;
  19. u32 *tre_local;
  20. if (tre_ch >= lldev->nr_tres) {
  21. dev_err(lldev->dev, "invalid TRE number in chstats:%d", tre_ch);
  22. return;
  23. }
  24. tre = &lldev->trepool[tre_ch];
  25. seq_printf(s, "------Channel %d -----\n", tre_ch);
  26. seq_printf(s, "allocated=%d\n", atomic_read(&tre->allocated));
  27. seq_printf(s, "queued = 0x%x\n", tre->queued);
  28. seq_printf(s, "err_info = 0x%x\n", tre->err_info);
  29. seq_printf(s, "err_code = 0x%x\n", tre->err_code);
  30. seq_printf(s, "status = 0x%x\n", tre->status);
  31. seq_printf(s, "idx = 0x%x\n", tre->idx);
  32. seq_printf(s, "dma_sig = 0x%x\n", tre->dma_sig);
  33. seq_printf(s, "dev_name=%s\n", tre->dev_name);
  34. seq_printf(s, "callback=%p\n", tre->callback);
  35. seq_printf(s, "data=%p\n", tre->data);
  36. seq_printf(s, "tre_index = 0x%x\n", tre->tre_index);
  37. tre_local = &tre->tre_local[0];
  38. src_start = tre_local[HIDMA_TRE_SRC_LOW_IDX];
  39. src_start = ((u64) (tre_local[HIDMA_TRE_SRC_HI_IDX]) << 32) + src_start;
  40. dest_start = tre_local[HIDMA_TRE_DEST_LOW_IDX];
  41. dest_start += ((u64) (tre_local[HIDMA_TRE_DEST_HI_IDX]) << 32);
  42. length = tre_local[HIDMA_TRE_LEN_IDX];
  43. seq_printf(s, "src=%pap\n", &src_start);
  44. seq_printf(s, "dest=%pap\n", &dest_start);
  45. seq_printf(s, "length = 0x%x\n", length);
  46. }
  47. static void hidma_ll_devstats(struct seq_file *s, void *llhndl)
  48. {
  49. struct hidma_lldev *lldev = llhndl;
  50. seq_puts(s, "------Device -----\n");
  51. seq_printf(s, "lldev init = 0x%x\n", lldev->initialized);
  52. seq_printf(s, "trch_state = 0x%x\n", lldev->trch_state);
  53. seq_printf(s, "evch_state = 0x%x\n", lldev->evch_state);
  54. seq_printf(s, "chidx = 0x%x\n", lldev->chidx);
  55. seq_printf(s, "nr_tres = 0x%x\n", lldev->nr_tres);
  56. seq_printf(s, "trca=%p\n", lldev->trca);
  57. seq_printf(s, "tre_ring=%p\n", lldev->tre_ring);
  58. seq_printf(s, "tre_ring_handle=%pap\n", &lldev->tre_dma);
  59. seq_printf(s, "tre_ring_size = 0x%x\n", lldev->tre_ring_size);
  60. seq_printf(s, "tre_processed_off = 0x%x\n", lldev->tre_processed_off);
  61. seq_printf(s, "pending_tre_count=%d\n",
  62. atomic_read(&lldev->pending_tre_count));
  63. seq_printf(s, "evca=%p\n", lldev->evca);
  64. seq_printf(s, "evre_ring=%p\n", lldev->evre_ring);
  65. seq_printf(s, "evre_ring_handle=%pap\n", &lldev->evre_dma);
  66. seq_printf(s, "evre_ring_size = 0x%x\n", lldev->evre_ring_size);
  67. seq_printf(s, "evre_processed_off = 0x%x\n", lldev->evre_processed_off);
  68. seq_printf(s, "tre_write_offset = 0x%x\n", lldev->tre_write_offset);
  69. }
  70. /*
  71. * hidma_chan_show: display HIDMA channel statistics
  72. *
  73. * Display the statistics for the current HIDMA virtual channel device.
  74. */
  75. static int hidma_chan_show(struct seq_file *s, void *unused)
  76. {
  77. struct hidma_chan *mchan = s->private;
  78. struct hidma_desc *mdesc;
  79. struct hidma_dev *dmadev = mchan->dmadev;
  80. pm_runtime_get_sync(dmadev->ddev.dev);
  81. seq_printf(s, "paused=%u\n", mchan->paused);
  82. seq_printf(s, "dma_sig=%u\n", mchan->dma_sig);
  83. seq_puts(s, "prepared\n");
  84. list_for_each_entry(mdesc, &mchan->prepared, node)
  85. hidma_ll_chstats(s, mchan->dmadev->lldev, mdesc->tre_ch);
  86. seq_puts(s, "active\n");
  87. list_for_each_entry(mdesc, &mchan->active, node)
  88. hidma_ll_chstats(s, mchan->dmadev->lldev, mdesc->tre_ch);
  89. seq_puts(s, "completed\n");
  90. list_for_each_entry(mdesc, &mchan->completed, node)
  91. hidma_ll_chstats(s, mchan->dmadev->lldev, mdesc->tre_ch);
  92. hidma_ll_devstats(s, mchan->dmadev->lldev);
  93. pm_runtime_mark_last_busy(dmadev->ddev.dev);
  94. pm_runtime_put_autosuspend(dmadev->ddev.dev);
  95. return 0;
  96. }
  97. /*
  98. * hidma_dma_show: display HIDMA device info
  99. *
  100. * Display the info for the current HIDMA device.
  101. */
  102. static int hidma_dma_show(struct seq_file *s, void *unused)
  103. {
  104. struct hidma_dev *dmadev = s->private;
  105. resource_size_t sz;
  106. seq_printf(s, "nr_descriptors=%d\n", dmadev->nr_descriptors);
  107. seq_printf(s, "dev_trca=%p\n", &dmadev->dev_trca);
  108. seq_printf(s, "dev_trca_phys=%pa\n", &dmadev->trca_resource->start);
  109. sz = resource_size(dmadev->trca_resource);
  110. seq_printf(s, "dev_trca_size=%pa\n", &sz);
  111. seq_printf(s, "dev_evca=%p\n", &dmadev->dev_evca);
  112. seq_printf(s, "dev_evca_phys=%pa\n", &dmadev->evca_resource->start);
  113. sz = resource_size(dmadev->evca_resource);
  114. seq_printf(s, "dev_evca_size=%pa\n", &sz);
  115. return 0;
  116. }
  117. DEFINE_SHOW_ATTRIBUTE(hidma_chan);
  118. DEFINE_SHOW_ATTRIBUTE(hidma_dma);
  119. void hidma_debug_uninit(struct hidma_dev *dmadev)
  120. {
  121. debugfs_remove_recursive(dmadev->debugfs);
  122. }
  123. void hidma_debug_init(struct hidma_dev *dmadev)
  124. {
  125. int chidx = 0;
  126. struct list_head *position = NULL;
  127. struct dentry *dir;
  128. dmadev->debugfs = debugfs_create_dir(dev_name(dmadev->ddev.dev), NULL);
  129. /* walk through the virtual channel list */
  130. list_for_each(position, &dmadev->ddev.channels) {
  131. struct hidma_chan *chan;
  132. chan = list_entry(position, struct hidma_chan,
  133. chan.device_node);
  134. sprintf(chan->dbg_name, "chan%d", chidx);
  135. dir = debugfs_create_dir(chan->dbg_name,
  136. dmadev->debugfs);
  137. debugfs_create_file("stats", S_IRUGO, dir, chan,
  138. &hidma_chan_fops);
  139. chidx++;
  140. }
  141. debugfs_create_file("stats", S_IRUGO, dmadev->debugfs, dmadev,
  142. &hidma_dma_fops);
  143. }