^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * xhci-debugfs.c - xHCI debugfs interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2017 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Author: Lu Baolu <baolu.lu@linux.intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "xhci.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "xhci-debugfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) static const struct debugfs_reg32 xhci_cap_regs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) dump_register(CAPLENGTH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) dump_register(HCSPARAMS1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) dump_register(HCSPARAMS2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) dump_register(HCSPARAMS3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) dump_register(HCCPARAMS1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) dump_register(DOORBELLOFF),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) dump_register(RUNTIMEOFF),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) dump_register(HCCPARAMS2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static const struct debugfs_reg32 xhci_op_regs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) dump_register(USBCMD),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) dump_register(USBSTS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) dump_register(PAGESIZE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) dump_register(DNCTRL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) dump_register(CRCR),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) dump_register(DCBAAP_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) dump_register(DCBAAP_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) dump_register(CONFIG),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static const struct debugfs_reg32 xhci_runtime_regs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) dump_register(MFINDEX),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) dump_register(IR0_IMAN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) dump_register(IR0_IMOD),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) dump_register(IR0_ERSTSZ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) dump_register(IR0_ERSTBA_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) dump_register(IR0_ERSTBA_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) dump_register(IR0_ERDP_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) dump_register(IR0_ERDP_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static const struct debugfs_reg32 xhci_extcap_legsup[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) dump_register(EXTCAP_USBLEGSUP),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) dump_register(EXTCAP_USBLEGCTLSTS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static const struct debugfs_reg32 xhci_extcap_protocol[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) dump_register(EXTCAP_REVISION),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) dump_register(EXTCAP_NAME),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) dump_register(EXTCAP_PORTINFO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) dump_register(EXTCAP_PORTTYPE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) dump_register(EXTCAP_MANTISSA1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) dump_register(EXTCAP_MANTISSA2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) dump_register(EXTCAP_MANTISSA3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) dump_register(EXTCAP_MANTISSA4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) dump_register(EXTCAP_MANTISSA5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) dump_register(EXTCAP_MANTISSA6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static const struct debugfs_reg32 xhci_extcap_dbc[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) dump_register(EXTCAP_DBC_CAPABILITY),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) dump_register(EXTCAP_DBC_DOORBELL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) dump_register(EXTCAP_DBC_ERSTSIZE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) dump_register(EXTCAP_DBC_ERST_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) dump_register(EXTCAP_DBC_ERST_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) dump_register(EXTCAP_DBC_ERDP_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) dump_register(EXTCAP_DBC_ERDP_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) dump_register(EXTCAP_DBC_CONTROL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) dump_register(EXTCAP_DBC_STATUS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) dump_register(EXTCAP_DBC_PORTSC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) dump_register(EXTCAP_DBC_CONT_LOW),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) dump_register(EXTCAP_DBC_CONT_HIGH),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) dump_register(EXTCAP_DBC_DEVINFO1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) dump_register(EXTCAP_DBC_DEVINFO2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static struct dentry *xhci_debugfs_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static struct xhci_regset *xhci_debugfs_alloc_regset(struct xhci_hcd *xhci)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct xhci_regset *regset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) regset = kzalloc(sizeof(*regset), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (!regset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * The allocation and free of regset are executed in order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * We needn't a lock here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) INIT_LIST_HEAD(®set->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) list_add_tail(®set->list, &xhci->regset_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) return regset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static void xhci_debugfs_free_regset(struct xhci_regset *regset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (!regset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) list_del(®set->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) kfree(regset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) __printf(6, 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static void xhci_debugfs_regset(struct xhci_hcd *xhci, u32 base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) const struct debugfs_reg32 *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) size_t nregs, struct dentry *parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct xhci_regset *rgs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct debugfs_regset32 *regset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct usb_hcd *hcd = xhci_to_hcd(xhci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) rgs = xhci_debugfs_alloc_regset(xhci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (!rgs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) va_start(args, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) vsnprintf(rgs->name, sizeof(rgs->name), fmt, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) regset = &rgs->regset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) regset->regs = regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) regset->nregs = nregs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) regset->base = hcd->regs + base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) debugfs_create_regset32((const char *)rgs->name, 0444, parent, regset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static void xhci_debugfs_extcap_regset(struct xhci_hcd *xhci, int cap_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) const struct debugfs_reg32 *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) size_t n, const char *cap_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) u32 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) size_t psic, nregs = n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) void __iomem *base = &xhci->cap_regs->hc_capbase;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) offset = xhci_find_next_ext_cap(base, 0, cap_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) while (offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (cap_id == XHCI_EXT_CAPS_PROTOCOL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) psic = XHCI_EXT_PORT_PSIC(readl(base + offset + 8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) nregs = min(4 + psic, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) xhci_debugfs_regset(xhci, offset, regs, nregs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) xhci->debugfs_root, "%s:%02d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) cap_name, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) offset = xhci_find_next_ext_cap(base, offset, cap_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) index++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static int xhci_ring_enqueue_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) dma_addr_t dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct xhci_ring *ring = *(struct xhci_ring **)s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) dma = xhci_trb_virt_to_dma(ring->enq_seg, ring->enqueue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) seq_printf(s, "%pad\n", &dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) static int xhci_ring_dequeue_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) dma_addr_t dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct xhci_ring *ring = *(struct xhci_ring **)s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) dma = xhci_trb_virt_to_dma(ring->deq_seg, ring->dequeue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) seq_printf(s, "%pad\n", &dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static int xhci_ring_cycle_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct xhci_ring *ring = *(struct xhci_ring **)s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) seq_printf(s, "%d\n", ring->cycle_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) static void xhci_ring_dump_segment(struct seq_file *s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct xhci_segment *seg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) dma_addr_t dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) union xhci_trb *trb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) char str[XHCI_MSG_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) for (i = 0; i < TRBS_PER_SEGMENT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) trb = &seg->trbs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) dma = seg->dma + i * sizeof(*trb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) seq_printf(s, "%pad: %s\n", &dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) xhci_decode_trb(str, XHCI_MSG_MAX, le32_to_cpu(trb->generic.field[0]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) le32_to_cpu(trb->generic.field[1]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) le32_to_cpu(trb->generic.field[2]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) le32_to_cpu(trb->generic.field[3])));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) static int xhci_ring_trb_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) struct xhci_ring *ring = *(struct xhci_ring **)s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct xhci_segment *seg = ring->first_seg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) for (i = 0; i < ring->num_segs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) xhci_ring_dump_segment(s, seg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) seg = seg->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static struct xhci_file_map ring_files[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {"enqueue", xhci_ring_enqueue_show, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {"dequeue", xhci_ring_dequeue_show, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {"cycle", xhci_ring_cycle_show, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {"trbs", xhci_ring_trb_show, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static int xhci_ring_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) struct xhci_file_map *f_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) const char *file_name = file_dentry(file)->d_iname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) for (i = 0; i < ARRAY_SIZE(ring_files); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) f_map = &ring_files[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (strcmp(f_map->name, file_name) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return single_open(file, f_map->show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static const struct file_operations xhci_ring_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .open = xhci_ring_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static int xhci_slot_context_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct xhci_hcd *xhci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct xhci_slot_ctx *slot_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct xhci_slot_priv *priv = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct xhci_virt_device *dev = priv->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) char str[XHCI_MSG_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) slot_ctx = xhci_get_slot_ctx(xhci, dev->out_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) seq_printf(s, "%pad: %s\n", &dev->out_ctx->dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) xhci_decode_slot_context(str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) le32_to_cpu(slot_ctx->dev_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) le32_to_cpu(slot_ctx->dev_info2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) le32_to_cpu(slot_ctx->tt_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) le32_to_cpu(slot_ctx->dev_state)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) int ep_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) dma_addr_t dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct xhci_hcd *xhci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) struct xhci_ep_ctx *ep_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) struct xhci_slot_priv *priv = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) struct xhci_virt_device *dev = priv->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) char str[XHCI_MSG_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) for (ep_index = 0; ep_index < 31; ep_index++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) seq_printf(s, "%pad: %s\n", &dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) xhci_decode_ep_context(str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) le32_to_cpu(ep_ctx->ep_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) le32_to_cpu(ep_ctx->ep_info2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) le64_to_cpu(ep_ctx->deq),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) le32_to_cpu(ep_ctx->tx_info)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) static int xhci_device_name_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) struct xhci_slot_priv *priv = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) struct xhci_virt_device *dev = priv->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) seq_printf(s, "%s\n", dev_name(&dev->udev->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) static struct xhci_file_map context_files[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) {"name", xhci_device_name_show, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) {"slot-context", xhci_slot_context_show, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) {"ep-context", xhci_endpoint_context_show, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) static int xhci_context_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct xhci_file_map *f_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) const char *file_name = file_dentry(file)->d_iname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) for (i = 0; i < ARRAY_SIZE(context_files); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) f_map = &context_files[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) if (strcmp(f_map->name, file_name) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) return single_open(file, f_map->show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) static const struct file_operations xhci_context_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) .open = xhci_context_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static int xhci_portsc_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) struct xhci_port *port = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) u32 portsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) char str[XHCI_MSG_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) portsc = readl(port->addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) seq_printf(s, "%s\n", xhci_decode_portsc(str, portsc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) static int xhci_port_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) return single_open(file, xhci_portsc_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) static ssize_t xhci_port_write(struct file *file, const char __user *ubuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) struct seq_file *s = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) struct xhci_port *port = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) struct xhci_hcd *xhci = hcd_to_xhci(port->rhub->hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) char buf[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) u32 portsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) if (!strncmp(buf, "compliance", 10)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) /* If CTC is clear, compliance is enabled by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) if (!HCC2_CTC(xhci->hcc_params2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) spin_lock_irqsave(&xhci->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) /* compliance mode can only be enabled on ports in RxDetect */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) portsc = readl(port->addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) if ((portsc & PORT_PLS_MASK) != XDEV_RXDETECT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) spin_unlock_irqrestore(&xhci->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) portsc = xhci_port_state_to_neutral(portsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) portsc &= ~PORT_PLS_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) portsc |= PORT_LINK_STROBE | XDEV_COMP_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) writel(portsc, port->addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) spin_unlock_irqrestore(&xhci->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) static const struct file_operations port_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) .open = xhci_port_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) .write = xhci_port_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) static void xhci_debugfs_create_files(struct xhci_hcd *xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) struct xhci_file_map *files,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) size_t nentries, void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) struct dentry *parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) const struct file_operations *fops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) for (i = 0; i < nentries; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) debugfs_create_file(files[i].name, 0444, parent, data, fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) static struct dentry *xhci_debugfs_create_ring_dir(struct xhci_hcd *xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) struct xhci_ring **ring,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) struct dentry *parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) struct dentry *dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) dir = debugfs_create_dir(name, parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) xhci_debugfs_create_files(xhci, ring_files, ARRAY_SIZE(ring_files),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) ring, dir, &xhci_ring_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) return dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) static void xhci_debugfs_create_context_files(struct xhci_hcd *xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) struct dentry *parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) int slot_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) struct xhci_virt_device *dev = xhci->devs[slot_id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) xhci_debugfs_create_files(xhci, context_files,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) ARRAY_SIZE(context_files),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) dev->debugfs_private,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) parent, &xhci_context_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) struct xhci_virt_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) int ep_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) struct xhci_ep_priv *epriv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) struct xhci_slot_priv *spriv = dev->debugfs_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) if (!spriv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) if (spriv->eps[ep_index])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) epriv = kzalloc(sizeof(*epriv), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) if (!epriv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) epriv->show_ring = dev->eps[ep_index].ring;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) snprintf(epriv->name, sizeof(epriv->name), "ep%02d", ep_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) epriv->root = xhci_debugfs_create_ring_dir(xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) &epriv->show_ring,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) epriv->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) spriv->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) spriv->eps[ep_index] = epriv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) void xhci_debugfs_remove_endpoint(struct xhci_hcd *xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) struct xhci_virt_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) int ep_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) struct xhci_ep_priv *epriv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct xhci_slot_priv *spriv = dev->debugfs_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) if (!spriv || !spriv->eps[ep_index])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) epriv = spriv->eps[ep_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) debugfs_remove_recursive(epriv->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) spriv->eps[ep_index] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) kfree(epriv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) static int xhci_stream_id_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) struct xhci_ep_priv *epriv = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (!epriv->stream_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) seq_printf(s, "Show stream ID %d trb ring, supported [1 - %d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) epriv->stream_id, epriv->stream_info->num_streams - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) static int xhci_stream_id_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) return single_open(file, xhci_stream_id_show, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) static ssize_t xhci_stream_id_write(struct file *file, const char __user *ubuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) struct seq_file *s = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) struct xhci_ep_priv *epriv = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) u16 stream_id; /* MaxPStreams + 1 <= 16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) if (!epriv->stream_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) /* Decimal number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) ret = kstrtou16_from_user(ubuf, count, 10, &stream_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) if (stream_id == 0 || stream_id >= epriv->stream_info->num_streams)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) epriv->stream_id = stream_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) epriv->show_ring = epriv->stream_info->stream_rings[stream_id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) static const struct file_operations stream_id_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) .open = xhci_stream_id_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) .write = xhci_stream_id_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) .read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) .llseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) .release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) static int xhci_stream_context_array_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) struct xhci_ep_priv *epriv = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) struct xhci_stream_ctx *stream_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) dma_addr_t dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) if (!epriv->stream_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) seq_printf(s, "Allocated %d streams and %d stream context array entries\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) epriv->stream_info->num_streams,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) epriv->stream_info->num_stream_ctxs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) for (id = 0; id < epriv->stream_info->num_stream_ctxs; id++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) stream_ctx = epriv->stream_info->stream_ctx_array + id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) dma = epriv->stream_info->ctx_array_dma + id * 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) if (id < epriv->stream_info->num_streams)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) seq_printf(s, "%pad stream id %d deq %016llx\n", &dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) id, le64_to_cpu(stream_ctx->stream_ring));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) seq_printf(s, "%pad stream context entry not used deq %016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) &dma, le64_to_cpu(stream_ctx->stream_ring));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) DEFINE_SHOW_ATTRIBUTE(xhci_stream_context_array);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) void xhci_debugfs_create_stream_files(struct xhci_hcd *xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) struct xhci_virt_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) int ep_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) struct xhci_slot_priv *spriv = dev->debugfs_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) struct xhci_ep_priv *epriv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) if (!spriv || !spriv->eps[ep_index] ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) !dev->eps[ep_index].stream_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) epriv = spriv->eps[ep_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) epriv->stream_info = dev->eps[ep_index].stream_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) /* Show trb ring of stream ID 1 by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) epriv->stream_id = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) epriv->show_ring = epriv->stream_info->stream_rings[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) debugfs_create_file("stream_id", 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) epriv->root, epriv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) &stream_id_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) debugfs_create_file("stream_context_array", 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) epriv->root, epriv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) &xhci_stream_context_array_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) void xhci_debugfs_create_slot(struct xhci_hcd *xhci, int slot_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) struct xhci_slot_priv *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) struct xhci_virt_device *dev = xhci->devs[slot_id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) priv = kzalloc(sizeof(*priv), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) if (!priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) snprintf(priv->name, sizeof(priv->name), "%02d", slot_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) priv->root = debugfs_create_dir(priv->name, xhci->debugfs_slots);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) priv->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) dev->debugfs_private = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) xhci_debugfs_create_ring_dir(xhci, &dev->eps[0].ring,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) "ep00", priv->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) xhci_debugfs_create_context_files(xhci, priv->root, slot_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) void xhci_debugfs_remove_slot(struct xhci_hcd *xhci, int slot_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) struct xhci_slot_priv *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) struct xhci_virt_device *dev = xhci->devs[slot_id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) if (!dev || !dev->debugfs_private)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) priv = dev->debugfs_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) debugfs_remove_recursive(priv->root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) for (i = 0; i < 31; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) kfree(priv->eps[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) kfree(priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) dev->debugfs_private = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) static void xhci_debugfs_create_ports(struct xhci_hcd *xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) struct dentry *parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) unsigned int num_ports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) char port_name[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) struct xhci_port *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) struct dentry *dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) parent = debugfs_create_dir("ports", parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) while (num_ports--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) scnprintf(port_name, sizeof(port_name), "port%02d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) num_ports + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) dir = debugfs_create_dir(port_name, parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) port = &xhci->hw_ports[num_ports];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) debugfs_create_file("portsc", 0644, dir, port, &port_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) void xhci_debugfs_init(struct xhci_hcd *xhci)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) struct device *dev = xhci_to_hcd(xhci)->self.controller;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) xhci->debugfs_root = debugfs_create_dir(dev_name(dev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) xhci_debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) INIT_LIST_HEAD(&xhci->regset_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) xhci_debugfs_regset(xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) xhci_cap_regs, ARRAY_SIZE(xhci_cap_regs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) xhci->debugfs_root, "reg-cap");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) xhci_debugfs_regset(xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) xhci_op_regs, ARRAY_SIZE(xhci_op_regs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) xhci->debugfs_root, "reg-op");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) xhci_debugfs_regset(xhci,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) xhci_runtime_regs, ARRAY_SIZE(xhci_runtime_regs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) xhci->debugfs_root, "reg-runtime");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_LEGACY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) xhci_extcap_legsup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) ARRAY_SIZE(xhci_extcap_legsup),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) "reg-ext-legsup");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_PROTOCOL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) xhci_extcap_protocol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) ARRAY_SIZE(xhci_extcap_protocol),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) "reg-ext-protocol");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) xhci_debugfs_extcap_regset(xhci, XHCI_EXT_CAPS_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) xhci_extcap_dbc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) ARRAY_SIZE(xhci_extcap_dbc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) "reg-ext-dbc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) xhci_debugfs_create_ring_dir(xhci, &xhci->cmd_ring,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) "command-ring",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) xhci->debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) xhci_debugfs_create_ring_dir(xhci, &xhci->event_ring,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) "event-ring",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) xhci->debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) xhci->debugfs_slots = debugfs_create_dir("devices", xhci->debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) xhci_debugfs_create_ports(xhci, xhci->debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) void xhci_debugfs_exit(struct xhci_hcd *xhci)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) struct xhci_regset *rgs, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) debugfs_remove_recursive(xhci->debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) xhci->debugfs_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) xhci->debugfs_slots = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) list_for_each_entry_safe(rgs, tmp, &xhci->regset_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) xhci_debugfs_free_regset(rgs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) void __init xhci_debugfs_create_root(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) xhci_debugfs_root = debugfs_create_dir("xhci", usb_debug_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) void __exit xhci_debugfs_remove_root(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) debugfs_remove_recursive(xhci_debugfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) xhci_debugfs_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) }