From: Roy Pledge <Roy.Pledge@freescale.com>
To: <linuxppc-dev@lists.ozlabs.org>, <scottwood@freescale.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 07/11] soc/bman: Add debugfs support for the BMan driver
Date: Thu, 9 Jul 2015 16:21:58 -0400 [thread overview]
Message-ID: <1436473322-21247-8-git-send-email-Roy.Pledge@freescale.com> (raw)
In-Reply-To: <1436473322-21247-1-git-send-email-Roy.Pledge@freescale.com>
From: Geoff Thorpe <Geoff.Thorpe@freescale.com>
Add debugfs support for querying the state of hardware based
Buffer Manager pools used in DPAA 1.0.
Signed-off-by: Geoff Thorpe <Geoff.Thorpe@freescale.com>
Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com>
Signed-off-by: Roy Pledge <Roy.Pledge@freescale.com>
---
drivers/soc/fsl/qbman/Kconfig | 7 ++
drivers/soc/fsl/qbman/Makefile | 1 +
drivers/soc/fsl/qbman/bman-debugfs.c | 117 ++++++++++++++++++++++++++++++++++
drivers/soc/fsl/qbman/bman_api.c | 19 ++++++
drivers/soc/fsl/qbman/dpaa_sys.h | 7 +-
5 files changed, 145 insertions(+), 6 deletions(-)
create mode 100644 drivers/soc/fsl/qbman/bman-debugfs.c
diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
index 8259eb8..35947e7 100644
--- a/drivers/soc/fsl/qbman/Kconfig
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -75,6 +75,13 @@ config FSL_BMAN_TEST_THRESH
"drainer" thread, and the other threads that they observe exactly
the depletion state changes that are expected.
+config FSL_BMAN_DEBUGFS
+ tristate "BMan debugfs support"
+ depends on DEBUG_FS
+ default n
+ help
+ BMan debugfs support
+
config FSL_QMAN
tristate "QMan device management"
default n
diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile
index 82f5482..2b53fbc 100644
--- a/drivers/soc/fsl/qbman/Makefile
+++ b/drivers/soc/fsl/qbman/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o
bman-test-y = bman_test.o
bman-test-$(CONFIG_FSL_BMAN_TEST_API) += bman_test_api.o
bman-test-$(CONFIG_FSL_BMAN_TEST_THRESH) += bman_test_thresh.o
+obj-$(CONFIG_FSL_BMAN_DEBUGFS) += bman-debugfs.o
obj-$(CONFIG_FSL_QMAN) += qman_api.o qman_utils.o qman_driver.o
obj-$(CONFIG_FSL_QMAN_CONFIG) += qman.o qman_portal.o
diff --git a/drivers/soc/fsl/qbman/bman-debugfs.c b/drivers/soc/fsl/qbman/bman-debugfs.c
new file mode 100644
index 0000000..b384f47
--- /dev/null
+++ b/drivers/soc/fsl/qbman/bman-debugfs.c
@@ -0,0 +1,117 @@
+/* Copyright 2010 - 2015 Freescale Semiconductor, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bman_priv.h"
+
+static struct dentry *dfs_root; /* debugfs root directory */
+
+/* Query Buffer Pool State */
+
+static int query_bp_state_show(struct seq_file *file, void *offset)
+{
+ int ret;
+ struct bm_pool_state state;
+ int i, j;
+ u32 mask;
+
+ memset(&state, 0, sizeof(state));
+ ret = bman_query_pools(&state);
+ if (ret) {
+ seq_printf(file, "Error %d\n", ret);
+ return ret;
+ }
+
+ seq_puts(file, "bp_id free_buffers_avail bp_depleted\n");
+ for (i = 0; i < 2; i++) {
+ mask = 0x80000000;
+ for (j = 0; j < 32; j++) {
+ seq_printf(file,
+ " %-2u %-3s %-3s\n",
+ (i * 32) + j,
+ state.as.state.__state[i] & mask ? "no" : "yes",
+ state.ds.state.__state[i] & mask ? "yes" : "no");
+ mask >>= 1;
+ }
+ }
+
+ return 0;
+}
+
+static int query_bp_state_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, query_bp_state_show, NULL);
+}
+
+static const struct file_operations query_bp_state_fops = {
+ .owner = THIS_MODULE,
+ .open = query_bp_state_open,
+ .read = seq_read,
+ .release = single_release,
+};
+
+static int __init bman_debugfs_init(void)
+{
+ int ret = 0;
+ struct dentry *d;
+
+ dfs_root = debugfs_create_dir("bman", NULL);
+ if (dfs_root == NULL) {
+ pr_err("Cannot create dir\n");
+ return -ENOMEM;
+ }
+
+ d = debugfs_create_file("query_bp_state",
+ S_IRUGO,
+ dfs_root,
+ NULL,
+ &query_bp_state_fops);
+ if (d == NULL) {
+ ret = -ENOMEM;
+ pr_err("Cannot create query_bp_state\n");
+ goto _return;
+ }
+
+ return 0;
+
+_return:
+ debugfs_remove_recursive(dfs_root);
+
+ return ret;
+}
+
+static void __exit bman_debugfs_exit(void)
+{
+ debugfs_remove_recursive(dfs_root);
+}
+
+module_init(bman_debugfs_init);
+module_exit(bman_debugfs_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/soc/fsl/qbman/bman_api.c b/drivers/soc/fsl/qbman/bman_api.c
index fe1c593..781d969 100644
--- a/drivers/soc/fsl/qbman/bman_api.c
+++ b/drivers/soc/fsl/qbman/bman_api.c
@@ -1012,6 +1012,25 @@ int bman_flush_stockpile(struct bman_pool *pool, u32 flags)
}
EXPORT_SYMBOL(bman_flush_stockpile);
+int bman_query_pools(struct bm_pool_state *state)
+{
+ struct bman_portal *p = get_affine_portal();
+ struct bm_mc_result *mcr;
+ __maybe_unused unsigned long irqflags;
+
+ PORTAL_IRQ_LOCK(p, irqflags);
+ bm_mc_start(&p->p);
+ bm_mc_commit(&p->p, BM_MCC_VERB_CMD_QUERY);
+ while (!(mcr = bm_mc_result(&p->p)))
+ cpu_relax();
+ DPA_ASSERT((mcr->verb & BM_MCR_VERB_CMD_MASK) == BM_MCR_VERB_CMD_QUERY);
+ *state = mcr->query;
+ PORTAL_IRQ_UNLOCK(p, irqflags);
+ put_affine_portal();
+ return 0;
+}
+EXPORT_SYMBOL(bman_query_pools);
+
#ifdef CONFIG_FSL_BMAN
u32 bman_query_free_buffers(struct bman_pool *pool)
{
diff --git a/drivers/soc/fsl/qbman/dpaa_sys.h b/drivers/soc/fsl/qbman/dpaa_sys.h
index c8d7aad..31ff7a8 100644
--- a/drivers/soc/fsl/qbman/dpaa_sys.h
+++ b/drivers/soc/fsl/qbman/dpaa_sys.h
@@ -38,6 +38,7 @@
#include <linux/of_irq.h>
#include <linux/of_reserved_mem.h>
#include <linux/kthread.h>
+#include <linux/debugfs.h>
#include <linux/platform_device.h>
#include <linux/ctype.h>
@@ -76,9 +77,7 @@ int dpaa_resource_reserve(struct dpaa_resource *alloc, u32 base, u32 num);
#define DPA_PORTAL_CE 0
#define DPA_PORTAL_CI 1
-/***********************/
/* Misc inline assists */
-/***********************/
/* TODO: NB, we currently assume that hwsync() and lwsync() imply compiler
* barriers and that dcb*() won't fall victim to compiler or execution
@@ -187,9 +186,7 @@ static inline void copy_bytes(void *dest, const void *src, size_t sz)
#define copy_bytes memcpy
#endif
-/************/
/* RB-trees */
-/************/
/* We encapsulate RB-trees so that its easier to use non-linux forms in
* non-linux systems. This also encapsulates the extra plumbing that linux code
@@ -245,9 +242,7 @@ static inline type *name##_find(struct dpa_rbtree *tree, u32 val) \
return NULL; \
}
-/************/
/* Bootargs */
-/************/
/* QMan has "qportals=" and BMan has "bportals=", they use the same syntax
* though; a comma-separated list of items, each item being a cpu index and/or a
--
1.7.9.5
next prev parent reply other threads:[~2015-07-09 20:37 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-09 20:21 [PATCH 00/11] Freescale DPAA QBMan Drivers Roy Pledge
2015-07-09 20:21 ` [PATCH 01/11] powerpc: re-add devm_ioremap_prot() Roy Pledge
2015-07-09 20:21 ` [PATCH 02/11] soc/fsl: Introduce DPAA BMan device management driver Roy Pledge
2015-07-10 8:38 ` Paul Bolle
2015-07-10 17:31 ` Scott Wood
2015-07-10 18:29 ` Roy Pledge
2015-07-10 18:50 ` Scott Wood
2015-07-22 16:15 ` Horia Geantă
2015-07-10 11:36 ` Paul Bolle
2015-07-10 17:33 ` Scott Wood
2015-07-10 20:57 ` Roy Pledge
2015-07-10 21:12 ` Scott Wood
2015-07-09 20:21 ` [PATCH 03/11] soc/fsl: Introduce the DPAA BMan portal driver Roy Pledge
2015-07-10 13:32 ` Paul Bolle
2015-07-10 15:19 ` Roy Pledge
2015-07-10 16:47 ` Paul Bolle
2015-07-09 20:21 ` [PATCH 04/11] soc/fsl: Introduce drivers for the DPAA QMan Roy Pledge
2015-07-11 10:34 ` Paul Bolle
2015-07-09 20:21 ` [PATCH 05/11] soc/bman: Add self-tester for BMan driver Roy Pledge
2015-07-09 20:21 ` [PATCH 06/11] soc/qman: Add self-tester for QMan driver Roy Pledge
2015-07-09 20:21 ` Roy Pledge [this message]
2015-07-09 20:21 ` [PATCH 08/11] soc/qman: Add debugfs support for the " Roy Pledge
2015-07-09 20:22 ` [PATCH 09/11] soc/bman: Add HOTPLUG_CPU support to the BMan driver Roy Pledge
2015-07-09 20:22 ` [PATCH 10/11] soc/qman: Add HOTPLUG_CPU support to the QMan driver Roy Pledge
2015-07-09 20:22 ` [PATCH 11/11] soc/qman: add qman_delete_cgr_safe() Roy Pledge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436473322-21247-8-git-send-email-Roy.Pledge@freescale.com \
--to=roy.pledge@freescale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=scottwood@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).