Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1374113

[PATCH v3 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space

From changbin.du@intel.com
Newsgroups linux.kernel
Subject [PATCH v3 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space
Date 2016-04-08 11:50 +0200
Message-ID <rlBda-1LF-53@gated-at.bofh.it> (permalink)
References <rlBd8-1LF-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: "Du, Changbin" <changbin.du@intel.com>

For DWC3 USB controller, the Global Debug Queue/FIFO Space Available
Register(GDBGFIFOSPACE) can be used to dump FIFO/Queue available space.
This can be used to check some special issues, like whether data is
successfully copied from memory to fifo when a trb is blocked.

Signed-off-by: Du, Changbin <changbin.du@intel.com>
---
changes from v2:
  no changes

---
 drivers/usb/dwc3/core.h    |  5 +++++
 drivers/usb/dwc3/debugfs.c | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6254b2f..899cf76 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -348,6 +348,11 @@
 #define DWC3_DSTS_LOWSPEED		(2 << 0)
 #define DWC3_DSTS_FULLSPEED1		(3 << 0)
 
+/* Global Debug Queue/FIFO Space Available Register */
+#define DWC3_GDBGFIFOSPACE_NUM(x)	(((x) << 0) & 0x1F)
+#define DWC3_GDBGFIFOSPACE_TYPE(x)	(((x) << 5) & 0xE0)
+#define DWC3_GDBGFIFOSPACE_GET_SPACE(x)	(((x) >> 16) & 0xFFFF)
+
 /* Device Generic Command Register */
 #define DWC3_DGCMD_SET_LMP		0x01
 #define DWC3_DGCMD_SET_PERIODIC_PAR	0x02
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index 071b286..02eaf54 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -426,6 +426,45 @@ static const struct file_operations dwc3_mode_fops = {
 	.release		= single_release,
 };
 
+static int dwc3_fifo_show(struct seq_file *s, void *unused)
+{
+	struct dwc3		*dwc = s->private;
+	unsigned long		flags;
+	unsigned int		type, index;
+	const char		*name;
+	u32			reg;
+
+	static const char * const fifo_names[] = {
+		"TxFIFO", "RxFIFO", "TxReqQ", "RxReqQ", "RxInfoQ",
+		"DescFetchQ", "EventQ", "ProtocolStatusQ"};
+	spin_lock_irqsave(&dwc->lock, flags);
+	for (type = 0; type < 8; type++) {
+		name = fifo_names[type];
+		for (index = 0; index < 32; index++) {
+			dwc3_writel(dwc->regs, DWC3_GDBGFIFOSPACE,
+				DWC3_GDBGFIFOSPACE_NUM(index) |
+				DWC3_GDBGFIFOSPACE_TYPE(type));
+			reg = dwc3_readl(dwc->regs, DWC3_GDBGFIFOSPACE);
+			seq_printf(s, "%s%02d = %d\n", name, index,
+				DWC3_GDBGFIFOSPACE_GET_SPACE(reg));
+		}
+	}
+	spin_unlock_irqrestore(&dwc->lock, flags);
+	return 0;
+}
+
+static int dwc3_fifo_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, dwc3_fifo_show, inode->i_private);
+}
+
+static const struct file_operations dwc3_fifo_fops = {
+	.open			= dwc3_fifo_open,
+	.read			= seq_read,
+	.llseek			= seq_lseek,
+	.release		= single_release,
+};
+
 static int dwc3_testmode_show(struct seq_file *s, void *unused)
 {
 	struct dwc3		*dwc = s->private;
@@ -639,6 +678,7 @@ void dwc3_debugfs_init(struct dwc3 *dwc)
 	dwc->regset->base = dwc->regs;
 
 	debugfs_create_regset32("regdump", S_IRUGO, root, dwc->regset);
+	debugfs_create_file("fifo", S_IRUGO, root, dwc, &dwc3_fifo_fops);
 
 	if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE))
 		debugfs_create_file("mode", S_IRUGO | S_IWUSR, root,
-- 
2.5.0

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] usb: dwc3: add debugfs node to dump FIFO/Queue available space changbin.du@intel.com - 2016-04-06 10:40 +0200
  Re: [PATCH] usb: dwc3: add debugfs node to dump FIFO/Queue available  space Greg KH <gregkh@linuxfoundation.org> - 2016-04-06 11:30 +0200
    RE: [PATCH] usb: dwc3: add debugfs node to dump FIFO/Queue  available space "Du, Changbin" <changbin.du@intel.com> - 2016-04-06 13:40 +0200
      RE: [PATCH] usb: dwc3: add debugfs node to dump FIFO/Queue available space Felipe Balbi <balbi@kernel.org> - 2016-04-06 14:30 +0200
    [PATCH v2 0/3] Improvement, fix and new entry for dwc3 debugfs changbin.du@intel.com - 2016-04-06 18:00 +0200
      [PATCH v2 3/3] usb: dwc3: add debugfs node to dump FIFO/Queue available space changbin.du@intel.com - 2016-04-06 18:00 +0200
      Re: [PATCH v2 0/3] Improvement, fix and new entry for dwc3 debugfs Felipe Balbi <balbi@kernel.org> - 2016-04-07 07:10 +0200
        RE: [PATCH v2 0/3] Improvement, fix and new entry for dwc3 debugfs "Du, Changbin" <changbin.du@intel.com> - 2016-04-07 07:30 +0200
          RE: [PATCH v2 0/3] Improvement, fix and new entry for dwc3 debugfs Felipe Balbi <balbi@kernel.org> - 2016-04-07 07:30 +0200
        [PATCH v3 0/2] Add a new debugfs entry to dump FIFO/Queue available space changbin.du@intel.com - 2016-04-08 11:50 +0200
          [PATCH v3 1/2] usb: dwc3: make dwc3_debugfs_init return value be void changbin.du@intel.com - 2016-04-08 11:50 +0200
            Re: [PATCH v3 1/2] usb: dwc3: make dwc3_debugfs_init return value be void Felipe Balbi <balbi@kernel.org> - 2016-04-11 10:20 +0200
              RE: [PATCH v3 1/2] usb: dwc3: make dwc3_debugfs_init return value  be void "Du, Changbin" <changbin.du@intel.com> - 2016-04-11 13:20 +0200
                RE: [PATCH v3 1/2] usb: dwc3: make dwc3_debugfs_init return value be void Felipe Balbi <balbi@kernel.org> - 2016-04-11 13:30 +0200
                [PATCH v4 0/2] Add a new debugfs entry to dump FIFO/Queue available space changbin.du@intel.com - 2016-04-12 13:30 +0200
                [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space changbin.du@intel.com - 2016-04-12 13:30 +0200
                Re: [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue  available space Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-04-12 15:00 +0200
                RE: [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue  available space "Du, Changbin" <changbin.du@intel.com> - 2016-04-14 05:30 +0200
                Re: [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space Felipe Balbi <balbi@kernel.org> - 2016-04-14 10:10 +0200
                RE: [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue  available space "Du, Changbin" <changbin.du@intel.com> - 2016-04-14 13:20 +0200
                RE: [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space Felipe Balbi <balbi@kernel.org> - 2016-04-14 13:30 +0200
                RE: [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue  available space "Du, Changbin" <changbin.du@intel.com> - 2016-04-14 13:40 +0200
                RE: [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space Felipe Balbi <balbi@kernel.org> - 2016-04-14 13:50 +0200
                RE: [PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue  available space "Du, Changbin" <changbin.du@intel.com> - 2016-04-14 14:00 +0200
                [PATCH v4 1/2] usb: dwc3: make dwc3_debugfs_init return value be void changbin.du@intel.com - 2016-04-12 13:30 +0200
          [PATCH v3 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space changbin.du@intel.com - 2016-04-08 11:50 +0200

csiph-web