.. | .. |
---|
110 | 110 | kfree(regset); |
---|
111 | 111 | } |
---|
112 | 112 | |
---|
| 113 | +__printf(6, 7) |
---|
113 | 114 | static void xhci_debugfs_regset(struct xhci_hcd *xhci, u32 base, |
---|
114 | 115 | const struct debugfs_reg32 *regs, |
---|
115 | 116 | size_t nregs, struct dentry *parent, |
---|
.. | .. |
---|
132 | 133 | regset->regs = regs; |
---|
133 | 134 | regset->nregs = nregs; |
---|
134 | 135 | regset->base = hcd->regs + base; |
---|
| 136 | + regset->dev = hcd->self.controller; |
---|
135 | 137 | |
---|
136 | 138 | debugfs_create_regset32((const char *)rgs->name, 0444, parent, regset); |
---|
137 | 139 | } |
---|
.. | .. |
---|
197 | 199 | int i; |
---|
198 | 200 | dma_addr_t dma; |
---|
199 | 201 | union xhci_trb *trb; |
---|
| 202 | + char str[XHCI_MSG_MAX]; |
---|
200 | 203 | |
---|
201 | 204 | for (i = 0; i < TRBS_PER_SEGMENT; i++) { |
---|
202 | 205 | trb = &seg->trbs[i]; |
---|
203 | 206 | dma = seg->dma + i * sizeof(*trb); |
---|
204 | 207 | seq_printf(s, "%pad: %s\n", &dma, |
---|
205 | | - xhci_decode_trb(le32_to_cpu(trb->generic.field[0]), |
---|
| 208 | + xhci_decode_trb(str, XHCI_MSG_MAX, le32_to_cpu(trb->generic.field[0]), |
---|
206 | 209 | le32_to_cpu(trb->generic.field[1]), |
---|
207 | 210 | le32_to_cpu(trb->generic.field[2]), |
---|
208 | 211 | le32_to_cpu(trb->generic.field[3]))); |
---|
.. | .. |
---|
259 | 262 | struct xhci_slot_ctx *slot_ctx; |
---|
260 | 263 | struct xhci_slot_priv *priv = s->private; |
---|
261 | 264 | struct xhci_virt_device *dev = priv->dev; |
---|
| 265 | + char str[XHCI_MSG_MAX]; |
---|
262 | 266 | |
---|
263 | 267 | xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus)); |
---|
264 | 268 | slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx); |
---|
265 | 269 | seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma, |
---|
266 | | - xhci_decode_slot_context(le32_to_cpu(slot_ctx->dev_info), |
---|
| 270 | + xhci_decode_slot_context(str, |
---|
| 271 | + le32_to_cpu(slot_ctx->dev_info), |
---|
267 | 272 | le32_to_cpu(slot_ctx->dev_info2), |
---|
268 | 273 | le32_to_cpu(slot_ctx->tt_info), |
---|
269 | 274 | le32_to_cpu(slot_ctx->dev_state))); |
---|
.. | .. |
---|
279 | 284 | struct xhci_ep_ctx *ep_ctx; |
---|
280 | 285 | struct xhci_slot_priv *priv = s->private; |
---|
281 | 286 | struct xhci_virt_device *dev = priv->dev; |
---|
| 287 | + char str[XHCI_MSG_MAX]; |
---|
282 | 288 | |
---|
283 | 289 | xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus)); |
---|
284 | 290 | |
---|
.. | .. |
---|
286 | 292 | ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index); |
---|
287 | 293 | dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params); |
---|
288 | 294 | seq_printf(s, "%pad: %s\n", &dma, |
---|
289 | | - xhci_decode_ep_context(le32_to_cpu(ep_ctx->ep_info), |
---|
| 295 | + xhci_decode_ep_context(str, |
---|
| 296 | + le32_to_cpu(ep_ctx->ep_info), |
---|
290 | 297 | le32_to_cpu(ep_ctx->ep_info2), |
---|
291 | 298 | le64_to_cpu(ep_ctx->deq), |
---|
292 | 299 | le32_to_cpu(ep_ctx->tx_info))); |
---|
.. | .. |
---|
340 | 347 | { |
---|
341 | 348 | struct xhci_port *port = s->private; |
---|
342 | 349 | u32 portsc; |
---|
| 350 | + char str[XHCI_MSG_MAX]; |
---|
343 | 351 | |
---|
344 | 352 | portsc = readl(port->addr); |
---|
345 | | - seq_printf(s, "%s\n", xhci_decode_portsc(portsc)); |
---|
| 353 | + seq_printf(s, "%s\n", xhci_decode_portsc(str, portsc)); |
---|
346 | 354 | |
---|
347 | 355 | return 0; |
---|
348 | 356 | } |
---|
.. | .. |
---|
450 | 458 | if (!epriv) |
---|
451 | 459 | return; |
---|
452 | 460 | |
---|
| 461 | + epriv->show_ring = dev->eps[ep_index].ring; |
---|
| 462 | + |
---|
453 | 463 | snprintf(epriv->name, sizeof(epriv->name), "ep%02d", ep_index); |
---|
454 | 464 | epriv->root = xhci_debugfs_create_ring_dir(xhci, |
---|
455 | | - &dev->eps[ep_index].ring, |
---|
| 465 | + &epriv->show_ring, |
---|
456 | 466 | epriv->name, |
---|
457 | 467 | spriv->root); |
---|
458 | 468 | spriv->eps[ep_index] = epriv; |
---|
.. | .. |
---|
474 | 484 | kfree(epriv); |
---|
475 | 485 | } |
---|
476 | 486 | |
---|
| 487 | +static int xhci_stream_id_show(struct seq_file *s, void *unused) |
---|
| 488 | +{ |
---|
| 489 | + struct xhci_ep_priv *epriv = s->private; |
---|
| 490 | + |
---|
| 491 | + if (!epriv->stream_info) |
---|
| 492 | + return -EPERM; |
---|
| 493 | + |
---|
| 494 | + seq_printf(s, "Show stream ID %d trb ring, supported [1 - %d]\n", |
---|
| 495 | + epriv->stream_id, epriv->stream_info->num_streams - 1); |
---|
| 496 | + |
---|
| 497 | + return 0; |
---|
| 498 | +} |
---|
| 499 | + |
---|
| 500 | +static int xhci_stream_id_open(struct inode *inode, struct file *file) |
---|
| 501 | +{ |
---|
| 502 | + return single_open(file, xhci_stream_id_show, inode->i_private); |
---|
| 503 | +} |
---|
| 504 | + |
---|
| 505 | +static ssize_t xhci_stream_id_write(struct file *file, const char __user *ubuf, |
---|
| 506 | + size_t count, loff_t *ppos) |
---|
| 507 | +{ |
---|
| 508 | + struct seq_file *s = file->private_data; |
---|
| 509 | + struct xhci_ep_priv *epriv = s->private; |
---|
| 510 | + int ret; |
---|
| 511 | + u16 stream_id; /* MaxPStreams + 1 <= 16 */ |
---|
| 512 | + |
---|
| 513 | + if (!epriv->stream_info) |
---|
| 514 | + return -EPERM; |
---|
| 515 | + |
---|
| 516 | + /* Decimal number */ |
---|
| 517 | + ret = kstrtou16_from_user(ubuf, count, 10, &stream_id); |
---|
| 518 | + if (ret) |
---|
| 519 | + return ret; |
---|
| 520 | + |
---|
| 521 | + if (stream_id == 0 || stream_id >= epriv->stream_info->num_streams) |
---|
| 522 | + return -EINVAL; |
---|
| 523 | + |
---|
| 524 | + epriv->stream_id = stream_id; |
---|
| 525 | + epriv->show_ring = epriv->stream_info->stream_rings[stream_id]; |
---|
| 526 | + |
---|
| 527 | + return count; |
---|
| 528 | +} |
---|
| 529 | + |
---|
| 530 | +static const struct file_operations stream_id_fops = { |
---|
| 531 | + .open = xhci_stream_id_open, |
---|
| 532 | + .write = xhci_stream_id_write, |
---|
| 533 | + .read = seq_read, |
---|
| 534 | + .llseek = seq_lseek, |
---|
| 535 | + .release = single_release, |
---|
| 536 | +}; |
---|
| 537 | + |
---|
| 538 | +static int xhci_stream_context_array_show(struct seq_file *s, void *unused) |
---|
| 539 | +{ |
---|
| 540 | + struct xhci_ep_priv *epriv = s->private; |
---|
| 541 | + struct xhci_stream_ctx *stream_ctx; |
---|
| 542 | + dma_addr_t dma; |
---|
| 543 | + int id; |
---|
| 544 | + |
---|
| 545 | + if (!epriv->stream_info) |
---|
| 546 | + return -EPERM; |
---|
| 547 | + |
---|
| 548 | + seq_printf(s, "Allocated %d streams and %d stream context array entries\n", |
---|
| 549 | + epriv->stream_info->num_streams, |
---|
| 550 | + epriv->stream_info->num_stream_ctxs); |
---|
| 551 | + |
---|
| 552 | + for (id = 0; id < epriv->stream_info->num_stream_ctxs; id++) { |
---|
| 553 | + stream_ctx = epriv->stream_info->stream_ctx_array + id; |
---|
| 554 | + dma = epriv->stream_info->ctx_array_dma + id * 16; |
---|
| 555 | + if (id < epriv->stream_info->num_streams) |
---|
| 556 | + seq_printf(s, "%pad stream id %d deq %016llx\n", &dma, |
---|
| 557 | + id, le64_to_cpu(stream_ctx->stream_ring)); |
---|
| 558 | + else |
---|
| 559 | + seq_printf(s, "%pad stream context entry not used deq %016llx\n", |
---|
| 560 | + &dma, le64_to_cpu(stream_ctx->stream_ring)); |
---|
| 561 | + } |
---|
| 562 | + |
---|
| 563 | + return 0; |
---|
| 564 | +} |
---|
| 565 | +DEFINE_SHOW_ATTRIBUTE(xhci_stream_context_array); |
---|
| 566 | + |
---|
| 567 | +void xhci_debugfs_create_stream_files(struct xhci_hcd *xhci, |
---|
| 568 | + struct xhci_virt_device *dev, |
---|
| 569 | + int ep_index) |
---|
| 570 | +{ |
---|
| 571 | + struct xhci_slot_priv *spriv = dev->debugfs_private; |
---|
| 572 | + struct xhci_ep_priv *epriv; |
---|
| 573 | + |
---|
| 574 | + if (!spriv || !spriv->eps[ep_index] || |
---|
| 575 | + !dev->eps[ep_index].stream_info) |
---|
| 576 | + return; |
---|
| 577 | + |
---|
| 578 | + epriv = spriv->eps[ep_index]; |
---|
| 579 | + epriv->stream_info = dev->eps[ep_index].stream_info; |
---|
| 580 | + |
---|
| 581 | + /* Show trb ring of stream ID 1 by default */ |
---|
| 582 | + epriv->stream_id = 1; |
---|
| 583 | + epriv->show_ring = epriv->stream_info->stream_rings[1]; |
---|
| 584 | + debugfs_create_file("stream_id", 0644, |
---|
| 585 | + epriv->root, epriv, |
---|
| 586 | + &stream_id_fops); |
---|
| 587 | + debugfs_create_file("stream_context_array", 0444, |
---|
| 588 | + epriv->root, epriv, |
---|
| 589 | + &xhci_stream_context_array_fops); |
---|
| 590 | +} |
---|
| 591 | + |
---|
477 | 592 | void xhci_debugfs_create_slot(struct xhci_hcd *xhci, int slot_id) |
---|
478 | 593 | { |
---|
479 | 594 | struct xhci_slot_priv *priv; |
---|