All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] regmap: Do debugfs init before cache init
@ 2011-11-21 19:46 Mark Brown
  2011-11-21 19:46 ` [PATCH 2/2] regmap: Provide debugfs dump of the rbtree cache data Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2011-11-21 19:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: patches, Mark Brown

This allows caches to add custom debugfs files.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/base/regmap/regmap.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 10ecbba3..a862090 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -241,12 +241,12 @@ struct regmap *regmap_init(struct device *dev,
 		goto err_map;
 	}
 
+	regmap_debugfs_init(map);
+
 	ret = regcache_init(map, config);
 	if (ret < 0)
 		goto err_free_workbuf;
 
-	regmap_debugfs_init(map);
-
 	return map;
 
 err_free_workbuf:
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] regmap: Provide debugfs dump of the rbtree cache data
  2011-11-21 19:46 [PATCH 1/2] regmap: Do debugfs init before cache init Mark Brown
@ 2011-11-21 19:46 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2011-11-21 19:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: patches, Mark Brown

Show the register ranges we have in each rbtree node in debugfs, plus
some statistics on how big each node is and the total number of nodes.
It may also be worth collecting data on the ranges of dirty registers
to see if there's much mileage in trying to coalesce writes on sync.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/base/regmap/regcache-rbtree.c |   49 +++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index e71320f..7767cbb 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -11,7 +11,9 @@
  */
 
 #include <linux/slab.h>
+#include <linux/debugfs.h>
 #include <linux/rbtree.h>
+#include <linux/seq_file.h>
 
 #include "internal.h"
 
@@ -125,6 +127,51 @@ static int regcache_rbtree_insert(struct rb_root *root,
 	return 1;
 }
 
+#ifdef CONFIG_DEBUG_FS
+static int rbtree_show(struct seq_file *s, void *ignored)
+{
+	struct regmap *map = s->private;
+	struct regcache_rbtree_ctx *rbtree_ctx = map->cache;
+	struct regcache_rbtree_node *n;
+	struct rb_node *node;
+	unsigned int base, top;
+	int nodes = 0;
+	int registers = 0;
+
+	mutex_lock(&map->lock);
+
+	for (node = rb_first(&rbtree_ctx->root); node != NULL;
+	     node = rb_next(node)) {
+		n = container_of(node, struct regcache_rbtree_node, node);
+
+		regcache_rbtree_get_base_top_reg(n, &base, &top);
+		seq_printf(s, "%x-%x (%d)\n", base, top, top - base + 1);
+
+		nodes++;
+		registers += top - base + 1;
+	}
+
+	seq_printf(s, "%d nodes, %d registers, average %d registers\n",
+		   nodes, registers, registers / nodes);
+
+	mutex_unlock(&map->lock);
+
+	return 0;
+}
+
+static int rbtree_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, rbtree_show, inode->i_private);
+}
+
+static const struct file_operations rbtree_fops = {
+	.open		= rbtree_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+#endif
+
 static int regcache_rbtree_init(struct regmap *map)
 {
 	struct regcache_rbtree_ctx *rbtree_ctx;
@@ -147,6 +194,8 @@ static int regcache_rbtree_init(struct regmap *map)
 			goto err;
 	}
 
+	debugfs_create_file("rbtree", 0400, map->debugfs, map, &rbtree_fops);
+
 	return 0;
 
 err:
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-21 19:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-21 19:46 [PATCH 1/2] regmap: Do debugfs init before cache init Mark Brown
2011-11-21 19:46 ` [PATCH 2/2] regmap: Provide debugfs dump of the rbtree cache data Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.