linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regmap: debugfs: Replace code by already existing function
@ 2019-03-19  9:41 Lucas Tanure
  2019-03-19  9:41 ` [PATCH 2/2] regmap: debugfs: Jump to the next readable register Lucas Tanure
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Tanure @ 2019-03-19  9:41 UTC (permalink / raw)
  To: Mark Brown
  Cc: patches, Charles Keepax, Greg Kroah-Hartman, linux-kernel, Lucas Tanure

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
---
 drivers/base/regmap/regmap-debugfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 6d3dc1429ae57..9b3f49ffc4a5f 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -214,10 +214,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
 	start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
 
 	for (i = start_reg; i <= to; i += map->reg_stride) {
-		if (!regmap_readable(map, i) && !regmap_cached(map, i))
-			continue;
-
-		if (regmap_precious(map, i))
+		if (!regmap_printable(map, i))
 			continue;
 
 		/* If we're in the region the user is trying to read */
-- 
2.21.0


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

* [PATCH 2/2] regmap: debugfs: Jump to the next readable register
  2019-03-19  9:41 [PATCH 1/2] regmap: debugfs: Replace code by already existing function Lucas Tanure
@ 2019-03-19  9:41 ` Lucas Tanure
  2019-03-19 11:14   ` Charles Keepax
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Tanure @ 2019-03-19  9:41 UTC (permalink / raw)
  To: Mark Brown
  Cc: patches, Charles Keepax, Greg Kroah-Hartman, linux-kernel, Lucas Tanure

Improve the speed of the loop jumping to the next
available register

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
---
 drivers/base/regmap/regmap-debugfs.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 9b3f49ffc4a5f..b5b1cf5aa1f96 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -190,6 +190,28 @@ static inline void regmap_calc_tot_len(struct regmap *map,
 	}
 }
 
+static int regmap_next_readable_reg(struct regmap *map, int reg)
+{
+	struct regmap_debugfs_off_cache *c;
+	int ret = -EINVAL;
+
+	if (regmap_printable(map, reg + map->reg_stride)) {
+		ret = reg + map->reg_stride;
+	} else {
+		mutex_lock(&map->cache_lock);
+		list_for_each_entry(c, &map->debugfs_off_cache, list) {
+			if (reg > c->max_reg)
+				continue;
+			if (reg < c->base_reg) {
+				ret = c->base_reg;
+				break;
+			}
+		}
+		mutex_unlock(&map->cache_lock);
+	}
+	return ret;
+}
+
 static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
 				   unsigned int to, char __user *user_buf,
 				   size_t count, loff_t *ppos)
@@ -213,9 +235,8 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
 	/* Work out which register we're starting at */
 	start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
 
-	for (i = start_reg; i <= to; i += map->reg_stride) {
-		if (!regmap_printable(map, i))
-			continue;
+	for (i = start_reg; i >= 0 && i <= to;
+	     i = regmap_next_readable_reg(map, i)) {
 
 		/* If we're in the region the user is trying to read */
 		if (p >= *ppos) {
-- 
2.21.0


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

* Re: [PATCH 2/2] regmap: debugfs: Jump to the next readable register
  2019-03-19  9:41 ` [PATCH 2/2] regmap: debugfs: Jump to the next readable register Lucas Tanure
@ 2019-03-19 11:14   ` Charles Keepax
  0 siblings, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2019-03-19 11:14 UTC (permalink / raw)
  To: Lucas Tanure; +Cc: Mark Brown, patches, Greg Kroah-Hartman, linux-kernel

On Tue, Mar 19, 2019 at 09:41:33AM +0000, Lucas Tanure wrote:
> Improve the speed of the loop jumping to the next
> available register
> 
> Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>

A very brief look shows a pretty reasonable speed up on the
massive wm5110 register map.

First regmap cat on wm5110:
 pre-patch:
  real    2m40.865s
  sys     2m21.104s

 post-patch:
  real    2m16.550s
  sys     2m5.799s

Repeat cat on wm5110:
 pre-patch:
  real    2m5.635s
  sys     2m0.030s

 post-patch:
  real    1m45.539s
  sys     1m44.552s

Thanks,
Charles

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

end of thread, other threads:[~2019-03-19 11:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19  9:41 [PATCH 1/2] regmap: debugfs: Replace code by already existing function Lucas Tanure
2019-03-19  9:41 ` [PATCH 2/2] regmap: debugfs: Jump to the next readable register Lucas Tanure
2019-03-19 11:14   ` Charles Keepax

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).