linux/drivers/usb/host/xhci-debugfs.c

726 lines
18 KiB
C
Raw Normal View History

// SPDX-License-Identifier: GPL-2.0
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
/*
* xhci-debugfs.c - xHCI debugfs interface
*
* Copyright (C) 2017 Intel Corporation
*
* Author: Lu Baolu <baolu.lu@linux.intel.com>
*/
#include <linux/slab.h>
#include <linux/uaccess.h>
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
#include "xhci.h"
#include "xhci-debugfs.h"
static const struct debugfs_reg32 xhci_cap_regs[] = {
dump_register(CAPLENGTH),
dump_register(HCSPARAMS1),
dump_register(HCSPARAMS2),
dump_register(HCSPARAMS3),
dump_register(HCCPARAMS1),
dump_register(DOORBELLOFF),
dump_register(RUNTIMEOFF),
dump_register(HCCPARAMS2),
};
static const struct debugfs_reg32 xhci_op_regs[] = {
dump_register(USBCMD),
dump_register(USBSTS),
dump_register(PAGESIZE),
dump_register(DNCTRL),
dump_register(CRCR),
dump_register(DCBAAP_LOW),
dump_register(DCBAAP_HIGH),
dump_register(CONFIG),
};
static const struct debugfs_reg32 xhci_runtime_regs[] = {
dump_register(MFINDEX),
dump_register(IR0_IMAN),
dump_register(IR0_IMOD),
dump_register(IR0_ERSTSZ),
dump_register(IR0_ERSTBA_LOW),
dump_register(IR0_ERSTBA_HIGH),
dump_register(IR0_ERDP_LOW),
dump_register(IR0_ERDP_HIGH),
};
static const struct debugfs_reg32 xhci_extcap_legsup[] = {
dump_register(EXTCAP_USBLEGSUP),
dump_register(EXTCAP_USBLEGCTLSTS),
};
static const struct debugfs_reg32 xhci_extcap_protocol[] = {
dump_register(EXTCAP_REVISION),
dump_register(EXTCAP_NAME),
dump_register(EXTCAP_PORTINFO),
dump_register(EXTCAP_PORTTYPE),
dump_register(EXTCAP_MANTISSA1),
dump_register(EXTCAP_MANTISSA2),
dump_register(EXTCAP_MANTISSA3),
dump_register(EXTCAP_MANTISSA4),
dump_register(EXTCAP_MANTISSA5),
dump_register(EXTCAP_MANTISSA6),
};
static const struct debugfs_reg32 xhci_extcap_dbc[] = {
dump_register(EXTCAP_DBC_CAPABILITY),
dump_register(EXTCAP_DBC_DOORBELL),
dump_register(EXTCAP_DBC_ERSTSIZE),
dump_register(EXTCAP_DBC_ERST_LOW),
dump_register(EXTCAP_DBC_ERST_HIGH),
dump_register(EXTCAP_DBC_ERDP_LOW),
dump_register(EXTCAP_DBC_ERDP_HIGH),
dump_register(EXTCAP_DBC_CONTROL),
dump_register(EXTCAP_DBC_STATUS),
dump_register(EXTCAP_DBC_PORTSC),
dump_register(EXTCAP_DBC_CONT_LOW),
dump_register(EXTCAP_DBC_CONT_HIGH),
dump_register(EXTCAP_DBC_DEVINFO1),
dump_register(EXTCAP_DBC_DEVINFO2),
};
static struct dentry *xhci_debugfs_root;
static struct xhci_regset *xhci_debugfs_alloc_regset(struct xhci_hcd *xhci)
{
struct xhci_regset *regset;
regset = kzalloc(sizeof(*regset), GFP_KERNEL);
if (!regset)
return NULL;
/*
* The allocation and free of regset are executed in order.
* We needn't a lock here.
*/
INIT_LIST_HEAD(&regset->list);
list_add_tail(&regset->list, &xhci->regset_list);
return regset;
}
static void xhci_debugfs_free_regset(struct xhci_regset *regset)
{
if (!regset)
return;
list_del(&regset->list);
kfree(regset);
}
__printf(6, 7)
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
static void xhci_debugfs_regset(struct xhci_hcd *xhci, u32 base,
const struct debugfs_reg32 *regs,
size_t nregs, struct dentry *parent,
const char *fmt, ...)
{
struct xhci_regset *rgs;
va_list args;
struct debugfs_regset32 *regset;
struct usb_hcd *hcd = xhci_to_hcd(xhci);
rgs = xhci_debugfs_alloc_regset(xhci);
if (!rgs)
return;
va_start(args, fmt);
vsnprintf(rgs->name, sizeof(rgs->name), fmt, args);
va_end(args);
regset = &rgs->regset;
regset->regs = regs;
regset->nregs = nregs;
regset->base = hcd->regs + base;
debugfs_create_regset32((const char *)rgs->name, 0444, parent, regset);
}
static void xhci_debugfs_extcap_regset(struct xhci_hcd *xhci, int cap_id,
const struct debugfs_reg32 *regs,
size_t n, const char *cap_name)
{
u32 offset;
int index = 0;
size_t psic, nregs = n;
void __iomem *base = &xhci->cap_regs->hc_capbase;
offset = xhci_find_next_ext_cap(base, 0, cap_id);
while (offset) {
if (cap_id == XHCI_EXT_CAPS_PROTOCOL) {
psic = XHCI_EXT_PORT_PSIC(readl(base + offset + 8));
nregs = min(4 + psic, n);
}
xhci_debugfs_regset(xhci, offset, regs, nregs,
xhci->debugfs_root, "%s:%02d",
cap_name, index);
offset = xhci_find_next_ext_cap(base, offset, cap_id);
index++;
}
}
static int xhci_ring_enqueue_show(struct seq_file *s, void *unused)
{
dma_addr_t dma;
struct xhci_ring *ring = *(struct xhci_ring **)s->private;
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
dma = xhci_trb_virt_to_dma(ring->enq_seg, ring->enqueue);
seq_printf(s, "%pad\n", &dma);
return 0;
}
static int xhci_ring_dequeue_show(struct seq_file *s, void *unused)
{
dma_addr_t dma;
struct xhci_ring *ring = *(struct xhci_ring **)s->private;
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
dma = xhci_trb_virt_to_dma(ring->deq_seg, ring->dequeue);
seq_printf(s, "%pad\n", &dma);
return 0;
}
static int xhci_ring_cycle_show(struct seq_file *s, void *unused)
{
struct xhci_ring *ring = *(struct xhci_ring **)s->private;
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
seq_printf(s, "%d\n", ring->cycle_state);
return 0;
}
static void xhci_ring_dump_segment(struct seq_file *s,
struct xhci_segment *seg)
{
int i;
dma_addr_t dma;
union xhci_trb *trb;
char str[XHCI_MSG_MAX];
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
for (i = 0; i < TRBS_PER_SEGMENT; i++) {
trb = &seg->trbs[i];
dma = seg->dma + i * sizeof(*trb);
seq_printf(s, "%pad: %s\n", &dma,
xhci_decode_trb(str, XHCI_MSG_MAX, le32_to_cpu(trb->generic.field[0]),
le32_to_cpu(trb->generic.field[1]),
le32_to_cpu(trb->generic.field[2]),
le32_to_cpu(trb->generic.field[3])));
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
}
}
static int xhci_ring_trb_show(struct seq_file *s, void *unused)
{
int i;
xhci: Fix NULL pointer in xhci debugfs Commit dde634057da7 ("xhci: Fix use-after-free in xhci debugfs") causes a null pointer dereference while fixing xhci-debugfs usage of ring pointers that were freed during hibernate. The fix passed addresses to ring pointers instead, but forgot to do this change for the xhci_ring_trb_show function. The address of the ring pointer passed to xhci-debugfs was of a temporary ring pointer "new_ring" instead of the actual ring "ring" pointer. The temporary new_ring pointer will be set to NULL later causing the NULL pointer dereference. This issue was seen when reading xhci related files in debugfs: cat /sys/kernel/debug/usb/xhci/*/devices/*/ep*/trbs [ 184.604861] BUG: unable to handle kernel NULL pointer dereference at (null) [ 184.613776] IP: xhci_ring_trb_show+0x3a/0x890 [ 184.618733] PGD 264193067 P4D 264193067 PUD 263238067 PMD 0 [ 184.625184] Oops: 0000 [#1] SMP [ 184.726410] RIP: 0010:xhci_ring_trb_show+0x3a/0x890 [ 184.731944] RSP: 0018:ffffba8243c0fd90 EFLAGS: 00010246 [ 184.737880] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00000000000295d6 [ 184.746020] RDX: 00000000000295d5 RSI: 0000000000000001 RDI: ffff971a6418d400 [ 184.754121] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 [ 184.762222] R10: ffff971a64c98a80 R11: ffff971a62a00e40 R12: ffff971a62a85500 [ 184.770325] R13: 0000000000020000 R14: ffff971a6418d400 R15: ffff971a6418d400 [ 184.778448] FS: 00007fe725a79700(0000) GS:ffff971a6ec00000(0000) knlGS:0000000000000000 [ 184.787644] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 184.794168] CR2: 0000000000000000 CR3: 000000025f365005 CR4: 00000000003606f0 [ 184.802318] Call Trace: [ 184.805094] ? seq_read+0x281/0x3b0 [ 184.809068] seq_read+0xeb/0x3b0 [ 184.812735] full_proxy_read+0x4d/0x70 [ 184.817007] __vfs_read+0x23/0x120 [ 184.820870] vfs_read+0x91/0x130 [ 184.824538] SyS_read+0x42/0x90 [ 184.828106] entry_SYSCALL_64_fastpath+0x1a/0x7d Fixes: dde634057da7 ("xhci: Fix use-after-free in xhci debugfs") Cc: <stable@vger.kernel.org> # v4.15 Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-12 12:24:48 +00:00
struct xhci_ring *ring = *(struct xhci_ring **)s->private;
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
struct xhci_segment *seg = ring->first_seg;
for (i = 0; i < ring->num_segs; i++) {
xhci_ring_dump_segment(s, seg);
seg = seg->next;
}
return 0;
}
static struct xhci_file_map ring_files[] = {
{"enqueue", xhci_ring_enqueue_show, },
{"dequeue", xhci_ring_dequeue_show, },
{"cycle", xhci_ring_cycle_show, },
{"trbs", xhci_ring_trb_show, },
};
static int xhci_ring_open(struct inode *inode, struct file *file)
{
int i;
struct xhci_file_map *f_map;
const char *file_name = file_dentry(file)->d_iname;
for (i = 0; i < ARRAY_SIZE(ring_files); i++) {
f_map = &ring_files[i];
if (strcmp(f_map->name, file_name) == 0)
break;
}
return single_open(file, f_map->show, inode->i_private);
}
static const struct file_operations xhci_ring_fops = {
.open = xhci_ring_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int xhci_slot_context_show(struct seq_file *s, void *unused)
{
struct xhci_hcd *xhci;
struct xhci_slot_ctx *slot_ctx;
struct xhci_slot_priv *priv = s->private;
struct xhci_virt_device *dev = priv->dev;
char str[XHCI_MSG_MAX];
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx);
seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma,
xhci_decode_slot_context(str,
le32_to_cpu(slot_ctx->dev_info),
le32_to_cpu(slot_ctx->dev_info2),
le32_to_cpu(slot_ctx->tt_info),
le32_to_cpu(slot_ctx->dev_state)));
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
return 0;
}
static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
{
int ep_index;
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
dma_addr_t dma;
struct xhci_hcd *xhci;
struct xhci_ep_ctx *ep_ctx;
struct xhci_slot_priv *priv = s->private;
struct xhci_virt_device *dev = priv->dev;
char str[XHCI_MSG_MAX];
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
for (ep_index = 0; ep_index < 31; ep_index++) {
ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params);
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
seq_printf(s, "%pad: %s\n", &dma,
xhci_decode_ep_context(str,
le32_to_cpu(ep_ctx->ep_info),
le32_to_cpu(ep_ctx->ep_info2),
le64_to_cpu(ep_ctx->deq),
le32_to_cpu(ep_ctx->tx_info)));
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
}
return 0;
}
static int xhci_device_name_show(struct seq_file *s, void *unused)
{
struct xhci_slot_priv *priv = s->private;
struct xhci_virt_device *dev = priv->dev;
seq_printf(s, "%s\n", dev_name(&dev->udev->dev));
return 0;
}
static struct xhci_file_map context_files[] = {
{"name", xhci_device_name_show, },
{"slot-context", xhci_slot_context_show, },
{"ep-context", xhci_endpoint_context_show, },
};
static int xhci_context_open(struct inode *inode, struct file *file)
{
int i;
struct xhci_file_map *f_map;
const char *file_name = file_dentry(file)->d_iname;
for (i = 0; i < ARRAY_SIZE(context_files); i++) {
f_map = &context_files[i];
if (strcmp(f_map->name, file_name) == 0)
break;
}
return single_open(file, f_map->show, inode->i_private);
}
static const struct file_operations xhci_context_fops = {
.open = xhci_context_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int xhci_portsc_show(struct seq_file *s, void *unused)
{
struct xhci_port *port = s->private;
u32 portsc;
char str[XHCI_MSG_MAX];
portsc = readl(port->addr);
seq_printf(s, "%s\n", xhci_decode_portsc(str, portsc));
return 0;
}
static int xhci_port_open(struct inode *inode, struct file *file)
{
return single_open(file, xhci_portsc_show, inode->i_private);
}
static ssize_t xhci_port_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos)
{
struct seq_file *s = file->private_data;
struct xhci_port *port = s->private;
struct xhci_hcd *xhci = hcd_to_xhci(port->rhub->hcd);
char buf[32];
u32 portsc;
unsigned long flags;
if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT;
if (!strncmp(buf, "compliance", 10)) {
/* If CTC is clear, compliance is enabled by default */
if (!HCC2_CTC(xhci->hcc_params2))
return count;
spin_lock_irqsave(&xhci->lock, flags);
/* compliance mode can only be enabled on ports in RxDetect */
portsc = readl(port->addr);
if ((portsc & PORT_PLS_MASK) != XDEV_RXDETECT) {
spin_unlock_irqrestore(&xhci->lock, flags);
return -EPERM;
}
portsc = xhci_port_state_to_neutral(portsc);
portsc &= ~PORT_PLS_MASK;
portsc |= PORT_LINK_STROBE | XDEV_COMP_MODE;
writel(portsc, port->addr);
spin_unlock_irqrestore(&xhci->lock, flags);
} else {
return -EINVAL;
}
return count;
}
static const struct file_operations port_fops = {
.open = xhci_port_open,
.write = xhci_port_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
static void xhci_debugfs_create_files(struct xhci_hcd *xhci,
struct xhci_file_map *files,
size_t nentries, void *data,
struct dentry *parent,
const struct file_operations *fops)
{
int i;
for (i = 0; i < nentries; i++)
debugfs_create_file(files[i].name, 0444, parent, data, fops);
}
static struct dentry *xhci_debugfs_create_ring_dir(struct xhci_hcd *xhci,
struct xhci_ring **ring,
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
const char *name,
struct dentry *parent)
{
struct dentry *dir;
dir = debugfs_create_dir(name, parent);
xhci_debugfs_create_files(xhci, ring_files, ARRAY_SIZE(ring_files),
ring, dir, &xhci_ring_fops);
return dir;
}
static void xhci_debugfs_create_context_files(struct xhci_hcd *xhci,
struct dentry *parent,
int slot_id)
{
struct xhci_virt_device *dev = xhci->devs[slot_id];
xhci_debugfs_create_files(xhci, context_files,
ARRAY_SIZE(context_files),
dev->debugfs_private,
parent, &xhci_context_fops);
}
void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
struct xhci_virt_device *dev,
int ep_index)
{
struct xhci_ep_priv *epriv;
struct xhci_slot_priv *spriv = dev->debugfs_private;
if (!spriv)
return;
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
if (spriv->eps[ep_index])
return;
epriv = kzalloc(sizeof(*epriv), GFP_KERNEL);
if (!epriv)
return;
epriv->show_ring = dev->eps[ep_index].ring;
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
snprintf(epriv->name, sizeof(epriv->name), "ep%02d", ep_index);
epriv->root = xhci_debugfs_create_ring_dir(xhci,
&epriv->show_ring,
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
epriv->name,
spriv->root);
spriv->eps[ep_index] = epriv;
}
void xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
struct xhci_virt_device *dev,
int ep_index)
{
struct xhci_ep_priv *epriv;
struct xhci_slot_priv *spriv = dev->debugfs_private;
if (!spriv || !spriv->eps[ep_index])
return;
epriv = spriv->eps[ep_index];
debugfs_remove_recursive(epriv->root);
spriv->eps[ep_index] = NULL;
kfree(epriv);
}
static int xhci_stream_id_show(struct seq_file *s, void *unused)
{
struct xhci_ep_priv *epriv = s->private;
if (!epriv->stream_info)
return -EPERM;
seq_printf(s, "Show stream ID %d trb ring, supported [1 - %d]\n",
epriv->stream_id, epriv->stream_info->num_streams - 1);
return 0;
}
static int xhci_stream_id_open(struct inode *inode, struct file *file)
{
return single_open(file, xhci_stream_id_show, inode->i_private);
}
static ssize_t xhci_stream_id_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos)
{
struct seq_file *s = file->private_data;
struct xhci_ep_priv *epriv = s->private;
int ret;
u16 stream_id; /* MaxPStreams + 1 <= 16 */
if (!epriv->stream_info)
return -EPERM;
/* Decimal number */
ret = kstrtou16_from_user(ubuf, count, 10, &stream_id);
if (ret)
return ret;
if (stream_id == 0 || stream_id >= epriv->stream_info->num_streams)
return -EINVAL;
epriv->stream_id = stream_id;
epriv->show_ring = epriv->stream_info->stream_rings[stream_id];
return count;
}
static const struct file_operations stream_id_fops = {
.open = xhci_stream_id_open,
.write = xhci_stream_id_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int xhci_stream_context_array_show(struct seq_file *s, void *unused)
{
struct xhci_ep_priv *epriv = s->private;
struct xhci_stream_ctx *stream_ctx;
dma_addr_t dma;
int id;
if (!epriv->stream_info)
return -EPERM;
seq_printf(s, "Allocated %d streams and %d stream context array entries\n",
epriv->stream_info->num_streams,
epriv->stream_info->num_stream_ctxs);
for (id = 0; id < epriv->stream_info->num_stream_ctxs; id++) {
stream_ctx = epriv->stream_info->stream_ctx_array + id;
dma = epriv->stream_info->ctx_array_dma + id * 16;
if (id < epriv->stream_info->num_streams)
seq_printf(s, "%pad stream id %d deq %016llx\n", &dma,
id, le64_to_cpu(stream_ctx->stream_ring));
else
seq_printf(s, "%pad stream context entry not used deq %016llx\n",
&dma, le64_to_cpu(stream_ctx->stream_ring));
}
return 0;
}
DEFINE_SHOW_ATTRIBUTE(xhci_stream_context_array);
void xhci_debugfs_create_stream_files(struct xhci_hcd *xhci,
struct xhci_virt_device *dev,
int ep_index)
{
struct xhci_slot_priv *spriv = dev->debugfs_private;
struct xhci_ep_priv *epriv;
if (!spriv || !spriv->eps[ep_index] ||
!dev->eps[ep_index].stream_info)
return;
epriv = spriv->eps[ep_index];
epriv->stream_info = dev->eps[ep_index].stream_info;
/* Show trb ring of stream ID 1 by default */
epriv->stream_id = 1;
epriv->show_ring = epriv->stream_info->stream_rings[1];
debugfs_create_file("stream_id", 0644,
epriv->root, epriv,
&stream_id_fops);
debugfs_create_file("stream_context_array", 0444,
epriv->root, epriv,
&xhci_stream_context_array_fops);
}
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
void xhci_debugfs_create_slot(struct xhci_hcd *xhci, int slot_id)
{
struct xhci_slot_priv *priv;
struct xhci_virt_device *dev = xhci->devs[slot_id];
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return;
snprintf(priv->name, sizeof(priv->name), "%02d", slot_id);
priv->root = debugfs_create_dir(priv->name, xhci->debugfs_slots);
priv->dev = dev;
dev->debugfs_private = priv;
xhci_debugfs_create_ring_dir(xhci, &dev->eps[0].ring,
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
"ep00", priv->root);
xhci_debugfs_create_context_files(xhci, priv->root, slot_id);
}
void xhci_debugfs_remove_slot(struct xhci_hcd *xhci, int slot_id)
{
int i;
struct xhci_slot_priv *priv;
struct xhci_virt_device *dev = xhci->devs[slot_id];
if (!dev || !dev->debugfs_private)
return;
priv = dev->debugfs_private;
debugfs_remove_recursive(priv->root);
for (i = 0; i < 31; i++)
kfree(priv->eps[i]);
kfree(priv);
dev->debugfs_private = NULL;
}
static void xhci_debugfs_create_ports(struct xhci_hcd *xhci,
struct dentry *parent)
{
unsigned int num_ports;
char port_name[8];
struct xhci_port *port;
struct dentry *dir;
num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
parent = debugfs_create_dir("ports", parent);
while (num_ports--) {
scnprintf(port_name, sizeof(port_name), "port%02d",
num_ports + 1);
dir = debugfs_create_dir(port_name, parent);
port = &xhci->hw_ports[num_ports];
debugfs_create_file("portsc", 0644, dir, port, &port_fops);
}
}
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
void xhci_debugfs_init(struct xhci_hcd *xhci)
{
struct device *dev = xhci_to_hcd(xhci)->self.controller;
xhci->debugfs_root = debugfs_create_dir(dev_name(dev),
xhci_debugfs_root);
INIT_LIST_HEAD(&xhci->regset_list);
xhci_debugfs_regset(xhci,
0,
xhci_cap_regs, ARRAY_SIZE(xhci_cap_regs),
xhci->debugfs_root, "reg-cap");
xhci_debugfs_regset(xhci,
HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)),
xhci_op_regs, ARRAY_SIZE(xhci_op_regs),
xhci->debugfs_root, "reg-op");
xhci_debugfs_regset(xhci,
readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK,
xhci_runtime_regs, ARRAY_SIZE(xhci_runtime_regs),
xhci->debugfs_root, "reg-runtime");
xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_LEGACY,
xhci_extcap_legsup,
ARRAY_SIZE(xhci_extcap_legsup),
"reg-ext-legsup");
xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_PROTOCOL,
xhci_extcap_protocol,
ARRAY_SIZE(xhci_extcap_protocol),
"reg-ext-protocol");
xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_DEBUG,
xhci_extcap_dbc,
ARRAY_SIZE(xhci_extcap_dbc),
"reg-ext-dbc");
xhci_debugfs_create_ring_dir(xhci, &xhci->cmd_ring,
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
"command-ring",
xhci->debugfs_root);
xhci_debugfs_create_ring_dir(xhci, &xhci->event_ring,
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
"event-ring",
xhci->debugfs_root);
xhci->debugfs_slots = debugfs_create_dir("devices", xhci->debugfs_root);
xhci_debugfs_create_ports(xhci, xhci->debugfs_root);
usb: xhci: Add debugfs interface for xHCI driver This adds debugfs consumer for xHCI driver. The debugfs entries read all host registers, device/endpoint contexts, command ring, event ring and various endpoint rings. With these entries, users can check the registers and memory spaces used by a host during run time, or save all the information with a simple 'cp -r' for post-mortem programs. The file hierarchy looks like this. [root of debugfs] |__usb |____[e,u,o]hci <---------[root for other HCIs] |____xhci <---------------[root for xHCI] |______0000:00:14.0 <--------------[xHCI host name] |________reg-cap <--------[capability registers] |________reg-op <-------[operational registers] |________reg-runtime <-----------[runtime registers] |________reg-ext-#cap_name <----[extended capability regs] |________command-ring <-------[root for command ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________event-ring <---------[root for event ring] |__________cycle <------------------[ring cycle] |__________dequeue <--------[ring dequeue pointer] |__________enqueue <--------[ring enqueue pointer] |__________trbs <-------------------[ring trbs] |________devices <------------[root for devices] |__________#slot_id <-----------[root for a device] |____________name <-----------------[device name] |____________slot-context <----------------[slot context] |____________ep-context <-----------[endpoint contexts] |____________ep#ep_index <--------[root for an endpoint] |______________cycle <------------------[ring cycle] |______________dequeue <--------[ring dequeue pointer] |______________enqueue <--------[ring enqueue pointer] |______________trbs <-------------------[ring trbs] Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 08:21:39 +00:00
}
void xhci_debugfs_exit(struct xhci_hcd *xhci)
{
struct xhci_regset *rgs, *tmp;
debugfs_remove_recursive(xhci->debugfs_root);
xhci->debugfs_root = NULL;
xhci->debugfs_slots = NULL;
list_for_each_entry_safe(rgs, tmp, &xhci->regset_list, list)
xhci_debugfs_free_regset(rgs);
}
void __init xhci_debugfs_create_root(void)
{
xhci_debugfs_root = debugfs_create_dir("xhci", usb_debug_root);
}
void __exit xhci_debugfs_remove_root(void)
{
debugfs_remove_recursive(xhci_debugfs_root);
xhci_debugfs_root = NULL;
}