* [PATCH] PCI: tegra: Add debugfs support
@ 2014-07-11 7:00 Thierry Reding
[not found] ` <1405062024-2364-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Thierry Reding @ 2014-07-11 7:00 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Stephen Warren, linux-pci-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA
From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Provide a debugfs file that shows the current link status for each root
port.
Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
drivers/pci/host/pci-tegra.c | 118 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 118 insertions(+)
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 14ec5b2c69e0..49b3bd5f5926 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -25,6 +25,7 @@
*/
#include <linux/clk.h>
+#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/export.h>
#include <linux/interrupt.h>
@@ -275,6 +276,7 @@ struct tegra_pcie {
unsigned int num_supplies;
const struct tegra_pcie_soc_data *soc_data;
+ struct dentry *debugfs;
};
struct tegra_pcie_port {
@@ -1664,6 +1666,115 @@ static const struct of_device_id tegra_pcie_of_match[] = {
};
MODULE_DEVICE_TABLE(of, tegra_pcie_of_match);
+static void *tegra_pcie_ports_seq_start(struct seq_file *s, loff_t *pos)
+{
+ struct tegra_pcie *pcie = s->private;
+
+ if (list_empty(&pcie->ports))
+ return NULL;
+
+ seq_printf(s, "Index Status\n");
+
+ return seq_list_start(&pcie->ports, *pos);
+}
+
+static void *tegra_pcie_ports_seq_next(struct seq_file *s, void *v, loff_t *pos)
+{
+ struct tegra_pcie *pcie = s->private;
+
+ return seq_list_next(v, &pcie->ports, pos);
+}
+
+static void tegra_pcie_ports_seq_stop(struct seq_file *s, void *v)
+{
+}
+
+static int tegra_pcie_ports_seq_show(struct seq_file *s, void *v)
+{
+ bool up = false, active = false;
+ struct tegra_pcie_port *port;
+ unsigned int value;
+
+ port = list_entry(v, struct tegra_pcie_port, list);
+
+ value = readl(port->base + RP_VEND_XP);
+
+ if (value & RP_VEND_XP_DL_UP)
+ up = true;
+
+ value = readl(port->base + RP_LINK_CONTROL_STATUS);
+
+ if (value & RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE)
+ active = true;
+
+ seq_printf(s, "%2u ", port->index);
+
+ if (up)
+ seq_printf(s, "up");
+
+ if (active) {
+ if (up)
+ seq_printf(s, ", ");
+
+ seq_printf(s, "active");
+ }
+
+ seq_printf(s, "\n");
+ return 0;
+}
+
+static const struct seq_operations tegra_pcie_ports_seq_ops = {
+ .start = tegra_pcie_ports_seq_start,
+ .next = tegra_pcie_ports_seq_next,
+ .stop = tegra_pcie_ports_seq_stop,
+ .show = tegra_pcie_ports_seq_show,
+};
+
+static int tegra_pcie_ports_open(struct inode *inode, struct file *file)
+{
+ struct tegra_pcie *pcie = inode->i_private;
+ struct seq_file *s;
+ int err;
+
+ err = seq_open(file, &tegra_pcie_ports_seq_ops);
+ if (err)
+ return err;
+
+ s = file->private_data;
+ s->private = pcie;
+
+ return 0;
+}
+
+static const struct file_operations tegra_pcie_ports_ops = {
+ .owner = THIS_MODULE,
+ .open = tegra_pcie_ports_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
+static int tegra_pcie_debugfs_init(struct tegra_pcie *pcie)
+{
+ struct dentry *file;
+
+ pcie->debugfs = debugfs_create_dir("pcie", NULL);
+ if (!pcie->debugfs)
+ return -ENOMEM;
+
+ file = debugfs_create_file("ports", S_IFREG | S_IRUGO, pcie->debugfs,
+ pcie, &tegra_pcie_ports_ops);
+ if (!file)
+ goto remove;
+
+ return 0;
+
+remove:
+ debugfs_remove_recursive(pcie->debugfs);
+ pcie->debugfs = NULL;
+ return -ENOMEM;
+}
+
static int tegra_pcie_probe(struct platform_device *pdev)
{
const struct of_device_id *match;
@@ -1718,6 +1829,13 @@ static int tegra_pcie_probe(struct platform_device *pdev)
goto disable_msi;
}
+ if (IS_ENABLED(CONFIG_DEBUG_FS)) {
+ err = tegra_pcie_debugfs_init(pcie);
+ if (err < 0)
+ dev_err(&pdev->dev, "failed to setup debugfs: %d\n",
+ err);
+ }
+
platform_set_drvdata(pdev, pcie);
return 0;
--
2.0.1
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <1405062024-2364-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] PCI: tegra: Add debugfs support [not found] ` <1405062024-2364-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2014-07-21 15:54 ` Stephen Warren 2014-07-21 21:19 ` Thierry Reding 2014-07-22 18:35 ` Bjorn Helgaas 1 sibling, 1 reply; 4+ messages in thread From: Stephen Warren @ 2014-07-21 15:54 UTC (permalink / raw) To: Thierry Reding, Bjorn Helgaas Cc: linux-pci-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA On 07/11/2014 01:00 AM, Thierry Reding wrote: > From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > > Provide a debugfs file that shows the current link status for each root > port. Reviewed-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Does this patch conflict with or merge well with the Tegra124 PCIe driver patches, I wonder? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: tegra: Add debugfs support 2014-07-21 15:54 ` Stephen Warren @ 2014-07-21 21:19 ` Thierry Reding 0 siblings, 0 replies; 4+ messages in thread From: Thierry Reding @ 2014-07-21 21:19 UTC (permalink / raw) To: Stephen Warren; +Cc: Bjorn Helgaas, linux-pci, linux-tegra [-- Attachment #1: Type: text/plain, Size: 834 bytes --] On Mon, Jul 21, 2014 at 09:54:50AM -0600, Stephen Warren wrote: > On 07/11/2014 01:00 AM, Thierry Reding wrote: > > From: Thierry Reding <treding@nvidia.com> > > > > Provide a debugfs file that shows the current link status for each root > > port. > > Reviewed-by: Stephen Warren <swarren@nvidia.com> > > Does this patch conflict with or merge well with the Tegra124 PCIe > driver patches, I wonder? Yes. The Tegra124 PCIe patches are part of the same branch. My plan was to get this merged for 3.17 (if it's not too late yet) and then submit Tegra124 support for 3.18 soonish after 3.17 is released. I also have a bunch of patches that allow the Tegra PCIe driver to be built as a module (though that has even more cross-tree dependencies, so should probably be phased in over a couple of cycles). Thierry [-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: tegra: Add debugfs support [not found] ` <1405062024-2364-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2014-07-21 15:54 ` Stephen Warren @ 2014-07-22 18:35 ` Bjorn Helgaas 1 sibling, 0 replies; 4+ messages in thread From: Bjorn Helgaas @ 2014-07-22 18:35 UTC (permalink / raw) To: Thierry Reding Cc: Stephen Warren, linux-pci-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA On Fri, Jul 11, 2014 at 09:00:24AM +0200, Thierry Reding wrote: > From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > > Provide a debugfs file that shows the current link status for each root > port. > > Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> I applied this with Stephen's ack to my pci/host-tegra branch for v3.17. Let me know if you prefer a different merge strategy. I'll be on vacation until Aug 11, so it won't be in my first pull request, but I plan to do another for things like this. > --- > drivers/pci/host/pci-tegra.c | 118 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 118 insertions(+) > > diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c > index 14ec5b2c69e0..49b3bd5f5926 100644 > --- a/drivers/pci/host/pci-tegra.c > +++ b/drivers/pci/host/pci-tegra.c > @@ -25,6 +25,7 @@ > */ > > #include <linux/clk.h> > +#include <linux/debugfs.h> > #include <linux/delay.h> > #include <linux/export.h> > #include <linux/interrupt.h> > @@ -275,6 +276,7 @@ struct tegra_pcie { > unsigned int num_supplies; > > const struct tegra_pcie_soc_data *soc_data; > + struct dentry *debugfs; > }; > > struct tegra_pcie_port { > @@ -1664,6 +1666,115 @@ static const struct of_device_id tegra_pcie_of_match[] = { > }; > MODULE_DEVICE_TABLE(of, tegra_pcie_of_match); > > +static void *tegra_pcie_ports_seq_start(struct seq_file *s, loff_t *pos) > +{ > + struct tegra_pcie *pcie = s->private; > + > + if (list_empty(&pcie->ports)) > + return NULL; > + > + seq_printf(s, "Index Status\n"); > + > + return seq_list_start(&pcie->ports, *pos); > +} > + > +static void *tegra_pcie_ports_seq_next(struct seq_file *s, void *v, loff_t *pos) > +{ > + struct tegra_pcie *pcie = s->private; > + > + return seq_list_next(v, &pcie->ports, pos); > +} > + > +static void tegra_pcie_ports_seq_stop(struct seq_file *s, void *v) > +{ > +} > + > +static int tegra_pcie_ports_seq_show(struct seq_file *s, void *v) > +{ > + bool up = false, active = false; > + struct tegra_pcie_port *port; > + unsigned int value; > + > + port = list_entry(v, struct tegra_pcie_port, list); > + > + value = readl(port->base + RP_VEND_XP); > + > + if (value & RP_VEND_XP_DL_UP) > + up = true; > + > + value = readl(port->base + RP_LINK_CONTROL_STATUS); > + > + if (value & RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE) > + active = true; > + > + seq_printf(s, "%2u ", port->index); > + > + if (up) > + seq_printf(s, "up"); > + > + if (active) { > + if (up) > + seq_printf(s, ", "); > + > + seq_printf(s, "active"); > + } > + > + seq_printf(s, "\n"); > + return 0; > +} > + > +static const struct seq_operations tegra_pcie_ports_seq_ops = { > + .start = tegra_pcie_ports_seq_start, > + .next = tegra_pcie_ports_seq_next, > + .stop = tegra_pcie_ports_seq_stop, > + .show = tegra_pcie_ports_seq_show, > +}; > + > +static int tegra_pcie_ports_open(struct inode *inode, struct file *file) > +{ > + struct tegra_pcie *pcie = inode->i_private; > + struct seq_file *s; > + int err; > + > + err = seq_open(file, &tegra_pcie_ports_seq_ops); > + if (err) > + return err; > + > + s = file->private_data; > + s->private = pcie; > + > + return 0; > +} > + > +static const struct file_operations tegra_pcie_ports_ops = { > + .owner = THIS_MODULE, > + .open = tegra_pcie_ports_open, > + .read = seq_read, > + .llseek = seq_lseek, > + .release = seq_release, > +}; > + > +static int tegra_pcie_debugfs_init(struct tegra_pcie *pcie) > +{ > + struct dentry *file; > + > + pcie->debugfs = debugfs_create_dir("pcie", NULL); > + if (!pcie->debugfs) > + return -ENOMEM; > + > + file = debugfs_create_file("ports", S_IFREG | S_IRUGO, pcie->debugfs, > + pcie, &tegra_pcie_ports_ops); > + if (!file) > + goto remove; > + > + return 0; > + > +remove: > + debugfs_remove_recursive(pcie->debugfs); > + pcie->debugfs = NULL; > + return -ENOMEM; > +} > + > static int tegra_pcie_probe(struct platform_device *pdev) > { > const struct of_device_id *match; > @@ -1718,6 +1829,13 @@ static int tegra_pcie_probe(struct platform_device *pdev) > goto disable_msi; > } > > + if (IS_ENABLED(CONFIG_DEBUG_FS)) { > + err = tegra_pcie_debugfs_init(pcie); > + if (err < 0) > + dev_err(&pdev->dev, "failed to setup debugfs: %d\n", > + err); > + } > + > platform_set_drvdata(pdev, pcie); > return 0; > > -- > 2.0.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-22 18:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-11 7:00 [PATCH] PCI: tegra: Add debugfs support Thierry Reding
[not found] ` <1405062024-2364-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-21 15:54 ` Stephen Warren
2014-07-21 21:19 ` Thierry Reding
2014-07-22 18:35 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox