debug_hw_1x06.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2010 Google, Inc.
  4. * Author: Erik Gilling <konkers@android.com>
  5. *
  6. * Copyright (C) 2011-2017 NVIDIA Corporation
  7. */
  8. #include "../dev.h"
  9. #include "../debug.h"
  10. #include "../cdma.h"
  11. #include "../channel.h"
  12. static void host1x_debug_show_channel_cdma(struct host1x *host,
  13. struct host1x_channel *ch,
  14. struct output *o)
  15. {
  16. struct host1x_cdma *cdma = &ch->cdma;
  17. dma_addr_t dmastart = 0, dmaend = 0;
  18. u32 dmaput, dmaget, dmactrl;
  19. u32 offset, class;
  20. u32 ch_stat;
  21. #if defined(CONFIG_ARCH_DMA_ADDR_T_64BIT) && HOST1X_HW >= 6
  22. dmastart = host1x_ch_readl(ch, HOST1X_CHANNEL_DMASTART_HI);
  23. dmastart <<= 32;
  24. #endif
  25. dmastart |= host1x_ch_readl(ch, HOST1X_CHANNEL_DMASTART);
  26. #if defined(CONFIG_ARCH_DMA_ADDR_T_64BIT) && HOST1X_HW >= 6
  27. dmaend = host1x_ch_readl(ch, HOST1X_CHANNEL_DMAEND_HI);
  28. dmaend <<= 32;
  29. #endif
  30. dmaend |= host1x_ch_readl(ch, HOST1X_CHANNEL_DMAEND);
  31. dmaput = host1x_ch_readl(ch, HOST1X_CHANNEL_DMAPUT);
  32. dmaget = host1x_ch_readl(ch, HOST1X_CHANNEL_DMAGET);
  33. dmactrl = host1x_ch_readl(ch, HOST1X_CHANNEL_DMACTRL);
  34. offset = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDP_OFFSET);
  35. class = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDP_CLASS);
  36. ch_stat = host1x_ch_readl(ch, HOST1X_CHANNEL_CHANNELSTAT);
  37. host1x_debug_output(o, "%u-%s: ", ch->id, dev_name(ch->dev));
  38. if (dmactrl & HOST1X_CHANNEL_DMACTRL_DMASTOP ||
  39. !ch->cdma.push_buffer.mapped) {
  40. host1x_debug_output(o, "inactive\n\n");
  41. return;
  42. }
  43. if (class == HOST1X_CLASS_HOST1X && offset == HOST1X_UCLASS_WAIT_SYNCPT)
  44. host1x_debug_output(o, "waiting on syncpt\n");
  45. else
  46. host1x_debug_output(o, "active class %02x, offset %04x\n",
  47. class, offset);
  48. host1x_debug_output(o, "DMASTART %pad, DMAEND %pad\n", &dmastart, &dmaend);
  49. host1x_debug_output(o, "DMAPUT %08x DMAGET %08x DMACTL %08x\n",
  50. dmaput, dmaget, dmactrl);
  51. host1x_debug_output(o, "CHANNELSTAT %02x\n", ch_stat);
  52. show_channel_gathers(o, cdma);
  53. host1x_debug_output(o, "\n");
  54. }
  55. static void host1x_debug_show_channel_fifo(struct host1x *host,
  56. struct host1x_channel *ch,
  57. struct output *o)
  58. {
  59. #if HOST1X_HW <= 6
  60. u32 rd_ptr, wr_ptr, start, end;
  61. u32 payload = INVALID_PAYLOAD;
  62. unsigned int data_count = 0;
  63. #endif
  64. u32 val;
  65. host1x_debug_output(o, "%u: fifo:\n", ch->id);
  66. val = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDFIFO_STAT);
  67. host1x_debug_output(o, "CMDFIFO_STAT %08x\n", val);
  68. if (val & HOST1X_CHANNEL_CMDFIFO_STAT_EMPTY) {
  69. host1x_debug_output(o, "[empty]\n");
  70. return;
  71. }
  72. val = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDFIFO_RDATA);
  73. host1x_debug_output(o, "CMDFIFO_RDATA %08x\n", val);
  74. #if HOST1X_HW <= 6
  75. /* Peek pointer values are invalid during SLCG, so disable it */
  76. host1x_hypervisor_writel(host, 0x1, HOST1X_HV_ICG_EN_OVERRIDE);
  77. val = 0;
  78. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_ENABLE;
  79. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_CHANNEL(ch->id);
  80. host1x_hypervisor_writel(host, val, HOST1X_HV_CMDFIFO_PEEK_CTRL);
  81. val = host1x_hypervisor_readl(host, HOST1X_HV_CMDFIFO_PEEK_PTRS);
  82. rd_ptr = HOST1X_HV_CMDFIFO_PEEK_PTRS_RD_PTR_V(val);
  83. wr_ptr = HOST1X_HV_CMDFIFO_PEEK_PTRS_WR_PTR_V(val);
  84. val = host1x_hypervisor_readl(host, HOST1X_HV_CMDFIFO_SETUP(ch->id));
  85. start = HOST1X_HV_CMDFIFO_SETUP_BASE_V(val);
  86. end = HOST1X_HV_CMDFIFO_SETUP_LIMIT_V(val);
  87. do {
  88. val = 0;
  89. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_ENABLE;
  90. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_CHANNEL(ch->id);
  91. val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_ADDR(rd_ptr);
  92. host1x_hypervisor_writel(host, val,
  93. HOST1X_HV_CMDFIFO_PEEK_CTRL);
  94. val = host1x_hypervisor_readl(host,
  95. HOST1X_HV_CMDFIFO_PEEK_READ);
  96. if (!data_count) {
  97. host1x_debug_output(o, "%03x 0x%08x: ",
  98. rd_ptr - start, val);
  99. data_count = show_channel_command(o, val, &payload);
  100. } else {
  101. host1x_debug_cont(o, "%08x%s", val,
  102. data_count > 1 ? ", " : "])\n");
  103. data_count--;
  104. }
  105. if (rd_ptr == end)
  106. rd_ptr = start;
  107. else
  108. rd_ptr++;
  109. } while (rd_ptr != wr_ptr);
  110. if (data_count)
  111. host1x_debug_cont(o, ", ...])\n");
  112. host1x_debug_output(o, "\n");
  113. host1x_hypervisor_writel(host, 0x0, HOST1X_HV_CMDFIFO_PEEK_CTRL);
  114. host1x_hypervisor_writel(host, 0x0, HOST1X_HV_ICG_EN_OVERRIDE);
  115. #endif
  116. }
  117. static void host1x_debug_show_mlocks(struct host1x *host, struct output *o)
  118. {
  119. /* TODO */
  120. }