nv50.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * NVIDIA nv50-family (ION/MCP79) display engine diagnostics.
  3. *
  4. * The hardware cursor is deliberately NOT driven on this family. What was
  5. * learned while trying (ASUS AT3IONT-I, C79/ION, VBIOS-owned display):
  6. *
  7. * - the VBIOS never hands the engine over: INTR_1 bit 8 stays set and
  8. * 0x6194e8 reads 0x803, so nothing has "stolen" the display;
  9. * - EVO DMA channels accept DMA_CB and the USER_PUT doorbell, but never
  10. * fetch (USER_GET stays) until the display is taken over the way nouveau
  11. * does in nv50_disp_init -- which includes re-programming the whole mode;
  12. * - the cursor control/offset registers (0x610a58/0x610a9c) are engine-only
  13. * mirrors: plain writes do not stick, and the PIO method interface
  14. * (0x610300/0x610304) does not execute them either;
  15. * - once an EVO channel has run a batch it cannot be restarted (its busy
  16. * bit stays set), so even a takeover yields a single attempt per boot.
  17. *
  18. * The software cursor has none of these problems. This module only probes
  19. * the engine state at boot (serial / `make netmon`) so the situation stays
  20. * visible for future work.
  21. */
  22. #include "nv50.h"
  23. #include "nvidia.h"
  24. #include "serial.h"
  25. #define NV_PDISP_OBJECTS 0x610010
  26. #define NV_PDISP_INTR_1 0x610024
  27. #define NV_PDISP_PIO_CTRL 0x610300
  28. #define NV_PDISP_CURSOR_CTRL2(i) (0x610270 + (i) * 0x10)
  29. #define NV_PDISP_EVO_CTRL(i) (0x610200 + (i) * 0x10)
  30. #define NV_PDISP_EVO_DMA_CB(i) (0x610204 + (i) * 0x10)
  31. #define NV_PDISP_VBIOS_HANDOFF 0x6194e8
  32. static unsigned int nv_mmio;
  33. static unsigned int mmio_rd(unsigned int ofs)
  34. {
  35. return *(volatile unsigned int *)(nv_mmio + ofs);
  36. }
  37. static void log_hex(const char *s, unsigned int v)
  38. {
  39. serial_puts(SERIAL_COM1, s);
  40. serial_puthex(SERIAL_COM1, v);
  41. }
  42. /* Count the capability shadow/active register differences (the 0x6101XX
  43. * "main control area that enables things" is all-zero while its 0x61XXXX
  44. * shadow reads 0xFFFFFFFF on this VBIOS). */
  45. static unsigned int caps_diff(void)
  46. {
  47. unsigned int i, d = 0;
  48. if (mmio_rd(0x614004) != mmio_rd(0x610184))
  49. d++;
  50. for (i = 0; i < 2; i++) {
  51. if (mmio_rd(0x616100 + i * 0x800) != mmio_rd(0x610190 + i * 0x10))
  52. d++;
  53. if (mmio_rd(0x616104 + i * 0x800) != mmio_rd(0x610194 + i * 0x10))
  54. d++;
  55. if (mmio_rd(0x616108 + i * 0x800) != mmio_rd(0x610198 + i * 0x10))
  56. d++;
  57. if (mmio_rd(0x61610c + i * 0x800) != mmio_rd(0x61019c + i * 0x10))
  58. d++;
  59. }
  60. for (i = 0; i < 3; i++)
  61. if (mmio_rd(0x61a000 + i * 0x800) != mmio_rd(0x6101d0 + i * 4))
  62. d++;
  63. for (i = 0; i < 2; i++)
  64. if (mmio_rd(0x61c000 + i * 0x800) != mmio_rd(0x6101e0 + i * 4))
  65. d++;
  66. for (i = 0; i < 3; i++)
  67. if (mmio_rd(0x61e000 + i * 0x800) != mmio_rd(0x6101f0 + i * 4))
  68. d++;
  69. return d;
  70. }
  71. void nv50_probe(void)
  72. {
  73. unsigned int i;
  74. if (!nvidia_available())
  75. return;
  76. nv_mmio = nvidia_bar0();
  77. log_hex("nv50: pdobj ", mmio_rd(NV_PDISP_OBJECTS));
  78. log_hex(" cursor2 ", mmio_rd(NV_PDISP_CURSOR_CTRL2(0)));
  79. log_hex("/", mmio_rd(NV_PDISP_CURSOR_CTRL2(1)));
  80. log_hex(" pio ", mmio_rd(NV_PDISP_PIO_CTRL));
  81. log_hex(" intr1 ", mmio_rd(NV_PDISP_INTR_1));
  82. log_hex(" vbios ", mmio_rd(NV_PDISP_VBIOS_HANDOFF));
  83. serial_puts(SERIAL_COM1, " caps ");
  84. serial_putdec(SERIAL_COM1, caps_diff());
  85. serial_puts(SERIAL_COM1, "\n");
  86. for (i = 0; i < 8; i++) {
  87. unsigned int ctl = mmio_rd(NV_PDISP_EVO_CTRL(i));
  88. unsigned int cb = mmio_rd(NV_PDISP_EVO_DMA_CB(i));
  89. if (!ctl && !cb)
  90. continue;
  91. serial_puts(SERIAL_COM1, "nv50: evo");
  92. serial_putdec(SERIAL_COM1, i);
  93. log_hex(" ctrl ", ctl);
  94. log_hex(" cb ", cb);
  95. serial_puts(SERIAL_COM1, "\n");
  96. }
  97. }