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


Groups > linux.kernel > #1456492

Re: [PATCH 1/2] regmap: Add a function to check if a regmap register is cached

From Lars-Peter Clausen <lars@metafoo.de>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] regmap: Add a function to check if a regmap register is cached
Date 2016-08-04 17:40 +0200
Message-ID <s2sUx-2Lw-23@gated-at.bofh.it> (permalink)
References <s2shP-28W-3@gated-at.bofh.it> <s2shQ-28W-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 08/04/2016 04:55 PM, Cristian Birsan wrote:
> Add a function to check if a regmap register is cached. This will be used
> in debugfs to dump the cached values of write only registers.
> 
> Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
> ---
>  drivers/base/regmap/internal.h |  1 +
>  drivers/base/regmap/regmap.c   | 14 ++++++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
> index 3df9770..cae04f4 100644
> --- a/drivers/base/regmap/internal.h
> +++ b/drivers/base/regmap/internal.h
> @@ -171,6 +171,7 @@ struct regcache_ops {
>  	int (*drop)(struct regmap *map, unsigned int min, unsigned int max);
>  };
>  
> +bool regmap_cached(struct regmap *map, unsigned int reg);
>  bool regmap_writeable(struct regmap *map, unsigned int reg);
>  bool regmap_readable(struct regmap *map, unsigned int reg);
>  bool regmap_volatile(struct regmap *map, unsigned int reg);
> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
> index 4ac63c0..e07f3a9 100644
> --- a/drivers/base/regmap/regmap.c
> +++ b/drivers/base/regmap/regmap.c
> @@ -92,6 +92,20 @@ bool regmap_writeable(struct regmap *map, unsigned int reg)
>  	return true;
>  }
>  
> +bool regmap_cached(struct regmap *map, unsigned int reg)
> +{
> +	if (map->cache == REGCACHE_NONE)
> +		return false;
> +
> +	if (!map->cache_ops)
> +		return false;
> +
> +	if (map->max_register && reg > map->max_register)
> +		return false;	

There is a problem with this approach. It does not check if the register is
cached it only checks if the register is cacheable.

This works very poorly for devices with sparse register maps. Sparse
register maps do not assign a register to each register number. There are
often even large gaps in the register map and some devices use up their full
16-bit register space.

Now this change combined with the next patch will cause the register file to
contain an entry for every possible register number, even if the register
number is not assigned. Since unassigned registers are not cached
regcache_read() will return an error and the registers file will print XX
for the register value. This means for sparse register maps the registers
file will be full of thousands of such entries.

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


Thread

[PATCH 1/2] regmap: Add a function to check if a regmap register is cached Cristian Birsan <cristian.birsan@microchip.com> - 2016-08-04 17:00 +0200
  Re: [PATCH 1/2] regmap: Add a function to check if a regmap register  is cached Lars-Peter Clausen <lars@metafoo.de> - 2016-08-04 17:40 +0200
  Re: [PATCH 1/2] regmap: Add a function to check if a regmap register  is cached Mark Brown <broonie@kernel.org> - 2016-08-04 17:50 +0200
    [PATCH v2 1/2] regmap: Add a function to check if a regmap register is cached Cristian Birsan <cristian.birsan@microchip.com> - 2016-08-08 18:00 +0200
      Applied "regmap: Add a function to check if a regmap register is cached" to the regmap tree Mark Brown <broonie@kernel.org> - 2016-08-09 14:50 +0200
    [PATCH v2 2/2] regmap: debugfs: Add support for dumping write only device registers Cristian Birsan <cristian.birsan@microchip.com> - 2016-08-08 18:00 +0200
      Applied "regmap: debugfs: Add support for dumping write only device registers" to the regmap tree Mark Brown <broonie@kernel.org> - 2016-08-09 14:50 +0200
        Re: Applied "regmap: debugfs: Add support for dumping write only  device registers" to the regmap tree kbuild test robot <lkp@intel.com> - 2016-08-09 15:20 +0200
    [PATCH v2 0/2] Display regmap values in debugfs for write only registers Cristian Birsan <cristian.birsan@microchip.com> - 2016-08-08 18:00 +0200

csiph-web