Linux Audio

Check our new training course

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