debug_hw_1x06.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Copyright (C) 2010 Google, Inc.
  3. * Author: Erik Gilling <konkers@android.com>
  4. *
  5. * Copyright (C) 2011-2017 NVIDIA Corporation
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #include "../dev.h"
  18. #include "../debug.h"
  19. #include "../cdma.h"
  20. #include "../channel.h"
  21. static void host1x_debug_show_channel_cdma(struct host1x *host,
  22. struct host1x_channel *ch,
  23. struct output *o)
  24. {
  25. struct host1x_cdma *cdma = &ch->cdma;
  26. u32 dmaput, dmaget, dmactrl;
  27. u32 offset, class;
  28. u32 ch_stat;
  29. dmaput = host1x_ch_readl(ch, HOST1X_CHANNEL_DMAPUT);
  30. dmaget = host1x_ch_readl(ch, HOST1X_CHANNEL_DMAGET);
  31. dmactrl = host1x_ch_readl(ch, HOST1X_CHANNEL_DMACTRL);
  32. offset = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDP_OFFSET);
  33. class = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDP_CLASS);
  34. ch_stat = host1x_ch_readl(ch, HOST1X_CHANNEL_CHANNELSTAT);
  35. host1x_debug_output(o, "%u-%s: ", ch->id, dev_name(ch->dev));
  36. if (dmactrl & HOST1X_CHANNEL_DMACTRL_DMASTOP ||
  37. !ch->cdma.push_buffer.mapped) {
  38. host1x_debug_output(o, "inactive\n\n");
  39. return;
  40. }
  41. if (class == HOST1X_CLASS_HOST1X && offset == HOST1X_UCLASS_WAIT_SYNCPT)
  42. host1x_debug_output(o, "waiting on syncpt\n");
  43. else
  44. host1x_debug_output(o, "active class %02x, offset %04x\n",
  45. class, offset);
  46. host1x_debug_output(o, "DMAPUT %08x, DMAGET %08x, DMACTL %08x\n",
  47. dmaput, dmaget, dmactrl);
  48. host1x_debug_output(o, "CHANNELSTAT %02x\n", ch_stat);
  49. show_channel_gathers(o, cdma);
  50. host1x_debug_output(o, "\n");
  51. }
  52. static void host1x_debug_show_channel_fifo(struct host1x *host,
  53. struct host1x_channel *ch,
  54. struct output *o)
  55. {
  56. u32 val, rd_ptr, wr_ptr, start, end;
  57. unsigned int data_count = 0;
  58. host1x_debug_output(o, "%u: fifo:\n", ch->id);
  59. val = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDFIFO_STAT);
  60. host1x_debug_output(o, "CMDFIFO_STAT %08x\n", val);
  61. if (val & HOST1X_CHANNEL_CMDFIFO_STAT_EMPTY) {
  62. host1x_debug_output(o, "[empty]\n");
  63. return;
  64. }
  65. val = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDFIFO_RDATA);
  66. host1x_debug_output(o, "CMDFIFO_RDATA %08x\n", val);
  67. /* Peek pointer values are invalid during SLCG, so disable it */
  68. host1x_hypervisor_writel(host, 0x1, HOST1X_HV_ICG_EN_OVERRIDE);
  69. val = 0;
  70. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_ENABLE;
  71. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_CHANNEL(ch->id);
  72. host1x_hypervisor_writel(host, val, HOST1X_HV_CMDFIFO_PEEK_CTRL);
  73. val = host1x_hypervisor_readl(host, HOST1X_HV_CMDFIFO_PEEK_PTRS);
  74. rd_ptr = HOST1X_HV_CMDFIFO_PEEK_PTRS_RD_PTR_V(val);
  75. wr_ptr = HOST1X_HV_CMDFIFO_PEEK_PTRS_WR_PTR_V(val);
  76. val = host1x_hypervisor_readl(host, HOST1X_HV_CMDFIFO_SETUP(ch->id));
  77. start = HOST1X_HV_CMDFIFO_SETUP_BASE_V(val);
  78. end = HOST1X_HV_CMDFIFO_SETUP_LIMIT_V(val);
  79. do {
  80. val = 0;
  81. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_ENABLE;
  82. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_CHANNEL(ch->id);
  83. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_ADDR(rd_ptr);
  84. host1x_hypervisor_writel(host, val,
  85. HOST1X_HV_CMDFIFO_PEEK_CTRL);
  86. val = host1x_hypervisor_readl(host,
  87. HOST1X_HV_CMDFIFO_PEEK_READ);
  88. if (!data_count) {
  89. host1x_debug_output(o, "%03x 0x%08x: ",
  90. rd_ptr - start, val);
  91. data_count = show_channel_command(o, val);
  92. } else {
  93. host1x_debug_cont(o, "%08x%s", val,
  94. data_count > 1 ? ", " : "])\n");
  95. data_count--;
  96. }
  97. if (rd_ptr == end)
  98. rd_ptr = start;
  99. else
  100. rd_ptr++;
  101. } while (rd_ptr != wr_ptr);
  102. if (data_count)
  103. host1x_debug_cont(o, ", ...])\n");
  104. host1x_debug_output(o, "\n");
  105. host1x_hypervisor_writel(host, 0x0, HOST1X_HV_CMDFIFO_PEEK_CTRL);
  106. host1x_hypervisor_writel(host, 0x0, HOST1X_HV_ICG_EN_OVERRIDE);
  107. }
  108. static void host1x_debug_show_mlocks(struct host1x *host, struct output *o)
  109. {
  110. /* TODO */
  111. }