xhci-dbg.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /*
  2. * xHCI host controller driver
  3. *
  4. * Copyright (C) 2008 Intel Corp.
  5. *
  6. * Author: Sarah Sharp
  7. * Some code borrowed from the Linux EHCI driver.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  15. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  16. * for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software Foundation,
  20. * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include "xhci.h"
  23. #define XHCI_INIT_VALUE 0x0
  24. /* Add verbose debugging later, just print everything for now */
  25. void xhci_dbg_regs(struct xhci_hcd *xhci)
  26. {
  27. u32 temp;
  28. xhci_dbg(xhci, "// xHCI capability registers at %p:\n",
  29. xhci->cap_regs);
  30. temp = xhci_readl(xhci, &xhci->cap_regs->hc_capbase);
  31. xhci_dbg(xhci, "// @%p = 0x%x (CAPLENGTH AND HCIVERSION)\n",
  32. &xhci->cap_regs->hc_capbase, temp);
  33. xhci_dbg(xhci, "// CAPLENGTH: 0x%x\n",
  34. (unsigned int) HC_LENGTH(temp));
  35. #if 0
  36. xhci_dbg(xhci, "// HCIVERSION: 0x%x\n",
  37. (unsigned int) HC_VERSION(temp));
  38. #endif
  39. xhci_dbg(xhci, "// xHCI operational registers at %p:\n", xhci->op_regs);
  40. temp = xhci_readl(xhci, &xhci->cap_regs->run_regs_off);
  41. xhci_dbg(xhci, "// @%p = 0x%x RTSOFF\n",
  42. &xhci->cap_regs->run_regs_off,
  43. (unsigned int) temp & RTSOFF_MASK);
  44. xhci_dbg(xhci, "// xHCI runtime registers at %p:\n", xhci->run_regs);
  45. temp = xhci_readl(xhci, &xhci->cap_regs->db_off);
  46. xhci_dbg(xhci, "// @%p = 0x%x DBOFF\n", &xhci->cap_regs->db_off, temp);
  47. xhci_dbg(xhci, "// Doorbell array at %p:\n", xhci->dba);
  48. }
  49. static void xhci_print_cap_regs(struct xhci_hcd *xhci)
  50. {
  51. u32 temp;
  52. xhci_dbg(xhci, "xHCI capability registers at %p:\n", xhci->cap_regs);
  53. temp = xhci_readl(xhci, &xhci->cap_regs->hc_capbase);
  54. xhci_dbg(xhci, "CAPLENGTH AND HCIVERSION 0x%x:\n",
  55. (unsigned int) temp);
  56. xhci_dbg(xhci, "CAPLENGTH: 0x%x\n",
  57. (unsigned int) HC_LENGTH(temp));
  58. xhci_dbg(xhci, "HCIVERSION: 0x%x\n",
  59. (unsigned int) HC_VERSION(temp));
  60. temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params1);
  61. xhci_dbg(xhci, "HCSPARAMS 1: 0x%x\n",
  62. (unsigned int) temp);
  63. xhci_dbg(xhci, " Max device slots: %u\n",
  64. (unsigned int) HCS_MAX_SLOTS(temp));
  65. xhci_dbg(xhci, " Max interrupters: %u\n",
  66. (unsigned int) HCS_MAX_INTRS(temp));
  67. xhci_dbg(xhci, " Max ports: %u\n",
  68. (unsigned int) HCS_MAX_PORTS(temp));
  69. temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params2);
  70. xhci_dbg(xhci, "HCSPARAMS 2: 0x%x\n",
  71. (unsigned int) temp);
  72. xhci_dbg(xhci, " Isoc scheduling threshold: %u\n",
  73. (unsigned int) HCS_IST(temp));
  74. xhci_dbg(xhci, " Maximum allowed segments in event ring: %u\n",
  75. (unsigned int) HCS_ERST_MAX(temp));
  76. temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params3);
  77. xhci_dbg(xhci, "HCSPARAMS 3 0x%x:\n",
  78. (unsigned int) temp);
  79. xhci_dbg(xhci, " Worst case U1 device exit latency: %u\n",
  80. (unsigned int) HCS_U1_LATENCY(temp));
  81. xhci_dbg(xhci, " Worst case U2 device exit latency: %u\n",
  82. (unsigned int) HCS_U2_LATENCY(temp));
  83. temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
  84. xhci_dbg(xhci, "HCC PARAMS 0x%x:\n", (unsigned int) temp);
  85. xhci_dbg(xhci, " HC generates %s bit addresses\n",
  86. HCC_64BIT_ADDR(temp) ? "64" : "32");
  87. /* FIXME */
  88. xhci_dbg(xhci, " FIXME: more HCCPARAMS debugging\n");
  89. temp = xhci_readl(xhci, &xhci->cap_regs->run_regs_off);
  90. xhci_dbg(xhci, "RTSOFF 0x%x:\n", temp & RTSOFF_MASK);
  91. }
  92. static void xhci_print_command_reg(struct xhci_hcd *xhci)
  93. {
  94. u32 temp;
  95. temp = xhci_readl(xhci, &xhci->op_regs->command);
  96. xhci_dbg(xhci, "USBCMD 0x%x:\n", temp);
  97. xhci_dbg(xhci, " HC is %s\n",
  98. (temp & CMD_RUN) ? "running" : "being stopped");
  99. xhci_dbg(xhci, " HC has %sfinished hard reset\n",
  100. (temp & CMD_RESET) ? "not " : "");
  101. xhci_dbg(xhci, " Event Interrupts %s\n",
  102. (temp & CMD_EIE) ? "enabled " : "disabled");
  103. xhci_dbg(xhci, " Host System Error Interrupts %s\n",
  104. (temp & CMD_EIE) ? "enabled " : "disabled");
  105. xhci_dbg(xhci, " HC has %sfinished light reset\n",
  106. (temp & CMD_LRESET) ? "not " : "");
  107. }
  108. static void xhci_print_status(struct xhci_hcd *xhci)
  109. {
  110. u32 temp;
  111. temp = xhci_readl(xhci, &xhci->op_regs->status);
  112. xhci_dbg(xhci, "USBSTS 0x%x:\n", temp);
  113. xhci_dbg(xhci, " Event ring is %sempty\n",
  114. (temp & STS_EINT) ? "not " : "");
  115. xhci_dbg(xhci, " %sHost System Error\n",
  116. (temp & STS_FATAL) ? "WARNING: " : "No ");
  117. xhci_dbg(xhci, " HC is %s\n",
  118. (temp & STS_HALT) ? "halted" : "running");
  119. }
  120. static void xhci_print_op_regs(struct xhci_hcd *xhci)
  121. {
  122. xhci_dbg(xhci, "xHCI operational registers at %p:\n", xhci->op_regs);
  123. xhci_print_command_reg(xhci);
  124. xhci_print_status(xhci);
  125. }
  126. static void xhci_print_ports(struct xhci_hcd *xhci)
  127. {
  128. u32 __iomem *addr;
  129. int i, j;
  130. int ports;
  131. char *names[NUM_PORT_REGS] = {
  132. "status",
  133. "power",
  134. "link",
  135. "reserved",
  136. };
  137. ports = HCS_MAX_PORTS(xhci->hcs_params1);
  138. addr = &xhci->op_regs->port_status_base;
  139. for (i = 0; i < ports; i++) {
  140. for (j = 0; j < NUM_PORT_REGS; ++j) {
  141. xhci_dbg(xhci, "%p port %s reg = 0x%x\n",
  142. addr, names[j],
  143. (unsigned int) xhci_readl(xhci, addr));
  144. addr++;
  145. }
  146. }
  147. }
  148. void xhci_print_ir_set(struct xhci_hcd *xhci, int set_num)
  149. {
  150. struct xhci_intr_reg __iomem *ir_set = &xhci->run_regs->ir_set[set_num];
  151. void __iomem *addr;
  152. u32 temp;
  153. u64 temp_64;
  154. addr = &ir_set->irq_pending;
  155. temp = xhci_readl(xhci, addr);
  156. if (temp == XHCI_INIT_VALUE)
  157. return;
  158. xhci_dbg(xhci, " %p: ir_set[%i]\n", ir_set, set_num);
  159. xhci_dbg(xhci, " %p: ir_set.pending = 0x%x\n", addr,
  160. (unsigned int)temp);
  161. addr = &ir_set->irq_control;
  162. temp = xhci_readl(xhci, addr);
  163. xhci_dbg(xhci, " %p: ir_set.control = 0x%x\n", addr,
  164. (unsigned int)temp);
  165. addr = &ir_set->erst_size;
  166. temp = xhci_readl(xhci, addr);
  167. xhci_dbg(xhci, " %p: ir_set.erst_size = 0x%x\n", addr,
  168. (unsigned int)temp);
  169. addr = &ir_set->rsvd;
  170. temp = xhci_readl(xhci, addr);
  171. if (temp != XHCI_INIT_VALUE)
  172. xhci_dbg(xhci, " WARN: %p: ir_set.rsvd = 0x%x\n",
  173. addr, (unsigned int)temp);
  174. addr = &ir_set->erst_base;
  175. temp_64 = xhci_read_64(xhci, addr);
  176. xhci_dbg(xhci, " %p: ir_set.erst_base = @%08llx\n",
  177. addr, temp_64);
  178. addr = &ir_set->erst_dequeue;
  179. temp_64 = xhci_read_64(xhci, addr);
  180. xhci_dbg(xhci, " %p: ir_set.erst_dequeue = @%08llx\n",
  181. addr, temp_64);
  182. }
  183. void xhci_print_run_regs(struct xhci_hcd *xhci)
  184. {
  185. u32 temp;
  186. int i;
  187. xhci_dbg(xhci, "xHCI runtime registers at %p:\n", xhci->run_regs);
  188. temp = xhci_readl(xhci, &xhci->run_regs->microframe_index);
  189. xhci_dbg(xhci, " %p: Microframe index = 0x%x\n",
  190. &xhci->run_regs->microframe_index,
  191. (unsigned int) temp);
  192. for (i = 0; i < 7; ++i) {
  193. temp = xhci_readl(xhci, &xhci->run_regs->rsvd[i]);
  194. if (temp != XHCI_INIT_VALUE)
  195. xhci_dbg(xhci, " WARN: %p: Rsvd[%i] = 0x%x\n",
  196. &xhci->run_regs->rsvd[i],
  197. i, (unsigned int) temp);
  198. }
  199. }
  200. void xhci_print_registers(struct xhci_hcd *xhci)
  201. {
  202. xhci_print_cap_regs(xhci);
  203. xhci_print_op_regs(xhci);
  204. xhci_print_ports(xhci);
  205. }
  206. void xhci_print_trb_offsets(struct xhci_hcd *xhci, union xhci_trb *trb)
  207. {
  208. int i;
  209. for (i = 0; i < 4; ++i)
  210. xhci_dbg(xhci, "Offset 0x%x = 0x%x\n",
  211. i*4, trb->generic.field[i]);
  212. }
  213. /**
  214. * Debug a transfer request block (TRB).
  215. */
  216. void xhci_debug_trb(struct xhci_hcd *xhci, union xhci_trb *trb)
  217. {
  218. u64 address;
  219. u32 type = xhci_readl(xhci, &trb->link.control) & TRB_TYPE_BITMASK;
  220. switch (type) {
  221. case TRB_TYPE(TRB_LINK):
  222. xhci_dbg(xhci, "Link TRB:\n");
  223. xhci_print_trb_offsets(xhci, trb);
  224. address = trb->link.segment_ptr;
  225. xhci_dbg(xhci, "Next ring segment DMA address = 0x%llx\n", address);
  226. xhci_dbg(xhci, "Interrupter target = 0x%x\n",
  227. GET_INTR_TARGET(trb->link.intr_target));
  228. xhci_dbg(xhci, "Cycle bit = %u\n",
  229. (unsigned int) (trb->link.control & TRB_CYCLE));
  230. xhci_dbg(xhci, "Toggle cycle bit = %u\n",
  231. (unsigned int) (trb->link.control & LINK_TOGGLE));
  232. xhci_dbg(xhci, "No Snoop bit = %u\n",
  233. (unsigned int) (trb->link.control & TRB_NO_SNOOP));
  234. break;
  235. case TRB_TYPE(TRB_TRANSFER):
  236. address = trb->trans_event.buffer;
  237. /*
  238. * FIXME: look at flags to figure out if it's an address or if
  239. * the data is directly in the buffer field.
  240. */
  241. xhci_dbg(xhci, "DMA address or buffer contents= %llu\n", address);
  242. break;
  243. case TRB_TYPE(TRB_COMPLETION):
  244. address = trb->event_cmd.cmd_trb;
  245. xhci_dbg(xhci, "Command TRB pointer = %llu\n", address);
  246. xhci_dbg(xhci, "Completion status = %u\n",
  247. (unsigned int) GET_COMP_CODE(trb->event_cmd.status));
  248. xhci_dbg(xhci, "Flags = 0x%x\n", (unsigned int) trb->event_cmd.flags);
  249. break;
  250. default:
  251. xhci_dbg(xhci, "Unknown TRB with TRB type ID %u\n",
  252. (unsigned int) type>>10);
  253. xhci_print_trb_offsets(xhci, trb);
  254. break;
  255. }
  256. }
  257. /**
  258. * Debug a segment with an xHCI ring.
  259. *
  260. * @return The Link TRB of the segment, or NULL if there is no Link TRB
  261. * (which is a bug, since all segments must have a Link TRB).
  262. *
  263. * Prints out all TRBs in the segment, even those after the Link TRB.
  264. *
  265. * XXX: should we print out TRBs that the HC owns? As long as we don't
  266. * write, that should be fine... We shouldn't expect that the memory pointed to
  267. * by the TRB is valid at all. Do we care about ones the HC owns? Probably,
  268. * for HC debugging.
  269. */
  270. void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg)
  271. {
  272. int i;
  273. u32 addr = (u32) seg->dma;
  274. union xhci_trb *trb = seg->trbs;
  275. for (i = 0; i < TRBS_PER_SEGMENT; ++i) {
  276. trb = &seg->trbs[i];
  277. xhci_dbg(xhci, "@%08x %08x %08x %08x %08x\n", addr,
  278. lower_32_bits(trb->link.segment_ptr),
  279. upper_32_bits(trb->link.segment_ptr),
  280. (unsigned int) trb->link.intr_target,
  281. (unsigned int) trb->link.control);
  282. addr += sizeof(*trb);
  283. }
  284. }
  285. void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring)
  286. {
  287. xhci_dbg(xhci, "Ring deq = %p (virt), 0x%llx (dma)\n",
  288. ring->dequeue,
  289. (unsigned long long)xhci_trb_virt_to_dma(ring->deq_seg,
  290. ring->dequeue));
  291. xhci_dbg(xhci, "Ring deq updated %u times\n",
  292. ring->deq_updates);
  293. xhci_dbg(xhci, "Ring enq = %p (virt), 0x%llx (dma)\n",
  294. ring->enqueue,
  295. (unsigned long long)xhci_trb_virt_to_dma(ring->enq_seg,
  296. ring->enqueue));
  297. xhci_dbg(xhci, "Ring enq updated %u times\n",
  298. ring->enq_updates);
  299. }
  300. /**
  301. * Debugging for an xHCI ring, which is a queue broken into multiple segments.
  302. *
  303. * Print out each segment in the ring. Check that the DMA address in
  304. * each link segment actually matches the segment's stored DMA address.
  305. * Check that the link end bit is only set at the end of the ring.
  306. * Check that the dequeue and enqueue pointers point to real data in this ring
  307. * (not some other ring).
  308. */
  309. void xhci_debug_ring(struct xhci_hcd *xhci, struct xhci_ring *ring)
  310. {
  311. /* FIXME: Throw an error if any segment doesn't have a Link TRB */
  312. struct xhci_segment *seg;
  313. struct xhci_segment *first_seg = ring->first_seg;
  314. xhci_debug_segment(xhci, first_seg);
  315. if (!ring->enq_updates && !ring->deq_updates) {
  316. xhci_dbg(xhci, " Ring has not been updated\n");
  317. return;
  318. }
  319. for (seg = first_seg->next; seg != first_seg; seg = seg->next)
  320. xhci_debug_segment(xhci, seg);
  321. }
  322. void xhci_dbg_ep_rings(struct xhci_hcd *xhci,
  323. unsigned int slot_id, unsigned int ep_index,
  324. struct xhci_virt_ep *ep)
  325. {
  326. int i;
  327. struct xhci_ring *ring;
  328. if (ep->ep_state & EP_HAS_STREAMS) {
  329. for (i = 1; i < ep->stream_info->num_streams; i++) {
  330. ring = ep->stream_info->stream_rings[i];
  331. xhci_dbg(xhci, "Dev %d endpoint %d stream ID %d:\n",
  332. slot_id, ep_index, i);
  333. xhci_debug_segment(xhci, ring->deq_seg);
  334. }
  335. } else {
  336. ring = ep->ring;
  337. if (!ring)
  338. return;
  339. xhci_dbg(xhci, "Dev %d endpoint ring %d:\n",
  340. slot_id, ep_index);
  341. xhci_debug_segment(xhci, ring->deq_seg);
  342. }
  343. }
  344. void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst)
  345. {
  346. u32 addr = (u32) erst->erst_dma_addr;
  347. int i;
  348. struct xhci_erst_entry *entry;
  349. for (i = 0; i < erst->num_entries; ++i) {
  350. entry = &erst->entries[i];
  351. xhci_dbg(xhci, "@%08x %08x %08x %08x %08x\n",
  352. (unsigned int) addr,
  353. lower_32_bits(entry->seg_addr),
  354. upper_32_bits(entry->seg_addr),
  355. (unsigned int) entry->seg_size,
  356. (unsigned int) entry->rsvd);
  357. addr += sizeof(*entry);
  358. }
  359. }
  360. void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci)
  361. {
  362. u64 val;
  363. val = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
  364. xhci_dbg(xhci, "// xHC command ring deq ptr low bits + flags = @%08x\n",
  365. lower_32_bits(val));
  366. xhci_dbg(xhci, "// xHC command ring deq ptr high bits = @%08x\n",
  367. upper_32_bits(val));
  368. }
  369. /* Print the last 32 bytes for 64-byte contexts */
  370. static void dbg_rsvd64(struct xhci_hcd *xhci, u64 *ctx, dma_addr_t dma)
  371. {
  372. int i;
  373. for (i = 0; i < 4; ++i) {
  374. xhci_dbg(xhci, "@%p (virt) @%08llx "
  375. "(dma) %#08llx - rsvd64[%d]\n",
  376. &ctx[4 + i], (unsigned long long)dma,
  377. ctx[4 + i], i);
  378. dma += 8;
  379. }
  380. }
  381. char *xhci_get_slot_state(struct xhci_hcd *xhci,
  382. struct xhci_container_ctx *ctx)
  383. {
  384. struct xhci_slot_ctx *slot_ctx = xhci_get_slot_ctx(xhci, ctx);
  385. switch (GET_SLOT_STATE(slot_ctx->dev_state)) {
  386. case 0:
  387. return "enabled/disabled";
  388. case 1:
  389. return "default";
  390. case 2:
  391. return "addressed";
  392. case 3:
  393. return "configured";
  394. default:
  395. return "reserved";
  396. }
  397. }
  398. static void xhci_dbg_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx)
  399. {
  400. /* Fields are 32 bits wide, DMA addresses are in bytes */
  401. int field_size = 32 / 8;
  402. int i;
  403. struct xhci_slot_ctx *slot_ctx = xhci_get_slot_ctx(xhci, ctx);
  404. dma_addr_t dma = ctx->dma +
  405. ((unsigned long)slot_ctx - (unsigned long)ctx->bytes);
  406. int csz = HCC_64BYTE_CONTEXT(xhci->hcc_params);
  407. xhci_dbg(xhci, "Slot Context:\n");
  408. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - dev_info\n",
  409. &slot_ctx->dev_info,
  410. (unsigned long long)dma, slot_ctx->dev_info);
  411. dma += field_size;
  412. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - dev_info2\n",
  413. &slot_ctx->dev_info2,
  414. (unsigned long long)dma, slot_ctx->dev_info2);
  415. dma += field_size;
  416. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - tt_info\n",
  417. &slot_ctx->tt_info,
  418. (unsigned long long)dma, slot_ctx->tt_info);
  419. dma += field_size;
  420. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - dev_state\n",
  421. &slot_ctx->dev_state,
  422. (unsigned long long)dma, slot_ctx->dev_state);
  423. dma += field_size;
  424. for (i = 0; i < 4; ++i) {
  425. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - rsvd[%d]\n",
  426. &slot_ctx->reserved[i], (unsigned long long)dma,
  427. slot_ctx->reserved[i], i);
  428. dma += field_size;
  429. }
  430. if (csz)
  431. dbg_rsvd64(xhci, (u64 *)slot_ctx, dma);
  432. }
  433. static void xhci_dbg_ep_ctx(struct xhci_hcd *xhci,
  434. struct xhci_container_ctx *ctx,
  435. unsigned int last_ep)
  436. {
  437. int i, j;
  438. int last_ep_ctx = 31;
  439. /* Fields are 32 bits wide, DMA addresses are in bytes */
  440. int field_size = 32 / 8;
  441. int csz = HCC_64BYTE_CONTEXT(xhci->hcc_params);
  442. if (last_ep < 31)
  443. last_ep_ctx = last_ep + 1;
  444. for (i = 0; i < last_ep_ctx; ++i) {
  445. struct xhci_ep_ctx *ep_ctx = xhci_get_ep_ctx(xhci, ctx, i);
  446. dma_addr_t dma = ctx->dma +
  447. ((unsigned long)ep_ctx - (unsigned long)ctx->bytes);
  448. xhci_dbg(xhci, "Endpoint %02d Context:\n", i);
  449. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - ep_info\n",
  450. &ep_ctx->ep_info,
  451. (unsigned long long)dma, ep_ctx->ep_info);
  452. dma += field_size;
  453. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - ep_info2\n",
  454. &ep_ctx->ep_info2,
  455. (unsigned long long)dma, ep_ctx->ep_info2);
  456. dma += field_size;
  457. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08llx - deq\n",
  458. &ep_ctx->deq,
  459. (unsigned long long)dma, ep_ctx->deq);
  460. dma += 2*field_size;
  461. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - tx_info\n",
  462. &ep_ctx->tx_info,
  463. (unsigned long long)dma, ep_ctx->tx_info);
  464. dma += field_size;
  465. for (j = 0; j < 3; ++j) {
  466. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - rsvd[%d]\n",
  467. &ep_ctx->reserved[j],
  468. (unsigned long long)dma,
  469. ep_ctx->reserved[j], j);
  470. dma += field_size;
  471. }
  472. if (csz)
  473. dbg_rsvd64(xhci, (u64 *)ep_ctx, dma);
  474. }
  475. }
  476. void xhci_dbg_ctx(struct xhci_hcd *xhci,
  477. struct xhci_container_ctx *ctx,
  478. unsigned int last_ep)
  479. {
  480. int i;
  481. /* Fields are 32 bits wide, DMA addresses are in bytes */
  482. int field_size = 32 / 8;
  483. struct xhci_slot_ctx *slot_ctx;
  484. dma_addr_t dma = ctx->dma;
  485. int csz = HCC_64BYTE_CONTEXT(xhci->hcc_params);
  486. if (ctx->type == XHCI_CTX_TYPE_INPUT) {
  487. struct xhci_input_control_ctx *ctrl_ctx =
  488. xhci_get_input_control_ctx(xhci, ctx);
  489. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - drop flags\n",
  490. &ctrl_ctx->drop_flags, (unsigned long long)dma,
  491. ctrl_ctx->drop_flags);
  492. dma += field_size;
  493. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - add flags\n",
  494. &ctrl_ctx->add_flags, (unsigned long long)dma,
  495. ctrl_ctx->add_flags);
  496. dma += field_size;
  497. for (i = 0; i < 6; ++i) {
  498. xhci_dbg(xhci, "@%p (virt) @%08llx (dma) %#08x - rsvd2[%d]\n",
  499. &ctrl_ctx->rsvd2[i], (unsigned long long)dma,
  500. ctrl_ctx->rsvd2[i], i);
  501. dma += field_size;
  502. }
  503. if (csz)
  504. dbg_rsvd64(xhci, (u64 *)ctrl_ctx, dma);
  505. }
  506. slot_ctx = xhci_get_slot_ctx(xhci, ctx);
  507. xhci_dbg_slot_ctx(xhci, ctx);
  508. xhci_dbg_ep_ctx(xhci, ctx, last_ep);
  509. }