1
0
Fork 0
Commit Graph

32 Commits (ff610a1d55da22bf95bbc6a8b193e052169b34b7)

Author SHA1 Message Date
Mark Brown 60f7110e36 Linux 3.9-rc7
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (GNU/Linux)
 
 iQEcBAABAgAGBQJRa02/AAoJEHm+PkMAQRiGDRoH/08Cu2LpmX4VN+YMC3BkGWxn
 4oOHGqdN0hrIQ4TysC43QNL6g7QJUnIR6fChn7pRJ6a8ljdzKjDHr/tZSIPJE3Ns
 UAGIDaaQWnZvGmHPzpbo4gmdMOTxg9xmpgac6Qpk6QowPIPc6fhl6AichP9OdH2G
 Fp6Irfznn5ZCBldJYg2+umoHyFTZARCxtdOKmmUnB7zH0GaX5ZRf/R6nmZEPlxE+
 5qJC1yxRxJE+I7gjNRFovxaLPuAmjPy5j6NJuGP8rR6epkhcJ2EVHSliI3KDKAO6
 D3Fy9T5qHv2A2gvSxtC0m5/1WrutXZqxZ/DOB/uv9U7vqomiIs/EsHIuvc9qFBY=
 =NrST
 -----END PGP SIGNATURE-----

Merge tag 'v3.9-rc7' into regmap-cache

Linux 3.9-rc7
2013-04-16 16:02:41 +01:00
Mark Brown f8bd822cbf regmap: cache: Factor out block sync
The idea of holding blocks of registers in device format is shared between
at least rbtree and lzo cache formats so split out the loop that does the
sync from the rbtree code so optimisations on it can be reused.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
2013-03-30 13:52:25 +00:00
Mark Brown 78493f2d7b regmap: cache: Factor out reg_present support from rbtree cache
The idea of maintaining a bitmap of present registers is something that
can usefully be used by other cache types that maintain blocks of cached
registers so move the code out of the rbtree cache and into the generic
regcache code.

Refactor the interface slightly as we go to wrap the set bit and enlarge
bitmap operations (since we never do one without the other) and make it
more robust for reads of uncached registers by bounds checking before we
look at the bitmap.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
2013-03-30 13:49:17 +00:00
Mark Brown 137b833457 regmap: cache: Use raw I/O to sync rbtrees if we can
This will bring no meaningful benefit by itself, it is done as a separate
commit to aid bisection if there are problems with the following commits
adding support for coalescing adjacent writes.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-27 13:03:41 +00:00
Dimitris Papastamos 0c7ed8563a regmap: Cut down on the average # of nodes in the rbtree cache
This patch aims to bring down the average number of nodes
in the rbtree cache and increase the average number of registers
per node.  This should improve general lookup and traversal times.
This is achieved by setting the minimum size of a block within the
rbnode to the size of the rbnode itself.  This will essentially
cache possibly non-existent registers so to combat this scenario,
we keep a separate bitmap in memory which keeps track of which register
exists.  The memory overhead of this change is likely in the order of
~5-10%, possibly less depending on the register file layout.  On my test
system with a bitmap of ~4300 bits and a relatively sparse register
layout, the memory requirements for the entire cache did not increase
(the cutting down of nodes which was about 50% of the original number
compensated the situation).

A second patch that can be built on top of this can look at the
ratio `sizeof(*rbnode) / map->cache_word_size' in order to suitably
adjust the block length of each block.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-26 21:38:15 +00:00
Lars-Peter Clausen 8abac3ba51 regmap: cache Fix regcache-rbtree sync
The last register block, which falls into the specified range, is not handled
correctly. The formula which calculates the number of register which should be
synced is inverse (and off by one). E.g. if all registers in that block should
be synced only one is synced, and if only one should be synced all (but one) are
synced. To calculate the number of registers that need to be synced we need to
subtract the number of the first register in the block from the max register
number and add one. This patch updates the code accordingly.

The issue was introduced in commit ac8d91c ("regmap: Supply ranges to the sync
operations").

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@vger.kernel.org
2013-03-13 19:07:19 +00:00
Dimitris Papastamos a42277c739 regmap: rbtree Expose total memory consumption in the rbtree debugfs entry
Provide a feel of how much overhead the rbtree cache adds to
the game.

[Slightly reworded output in debugfs -- broonie]

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-13 11:13:48 +00:00
Mark Brown 879082c9fe regmap: cache: Pass the map rather than the word size when updating values
It's more idiomatic to pass the map structure around and this means we
can use other bits of information from the map.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:30:27 +08:00
Mark Brown 66baf40757 regmap: rbtree: Don't bother checking for noop updates
If we're updating a value in place it's more work to read the value and
compare the value with what we're about to set than it is to just write
the value into the cache; there are no further operations after writing
in the code even though there's an early return here.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2013-03-04 10:30:27 +08:00
Stephen Warren f01ee60fff regmap: implement register striding
regmap_config.reg_stride is introduced. All extant register addresses
are a multiple of this value. Users of serial-oriented regmap busses will
typically set this to 1. Users of the MMIO regmap bus will typically set
this based on the value size of their registers, in bytes, so 4 for a
32-bit register.

Throughout the regmap code, actual register addresses are used. Wherever
the register address is used to index some array of values, the address
is divided by the stride to determine the index, or vice-versa. Error-
checking is added to all entry-points for register address data to ensure
that register addresses actually satisfy the specified stride. The MMIO
bus ensures that the specified stride is large enough for the register
size.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-04-10 11:01:18 +01:00
Mark Brown c0cc6fe1d0 Merge branches 'regmap-core', 'regmap-mmio' and 'regmap-naming' into regmap-stride 2012-04-10 11:01:07 +01:00
Linus Torvalds f4e52e7ffd regmap: A couple of small fixes for 3.4
Two more small fixes:
 - Now we have users for it that aren't running Android it turns out that
   regcache_sync_region() is much more useful to drivers if it's exported
   for use by modules.  Who knew?
 - Make sure we don't divide by zero when doing debugfs dumps of rbtrees,
   not visible up until now because everything was providing at least
   some cache on startup.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJPfMvJAAoJEBus8iNuMP3d43YQAI8IJqPoAqK2eKjQlYNRzP3O
 hWgA6oU56Yqg0PZKKTbWKkul2j9onRV7UrCsXrKo9gCVFNAROkMh9q8uZxzf7yl1
 AlOsoKDH/ijYhuAkbLri5tWc8vw5SZS/rSXx6BnVAIPgDjaCEoJcd6swJTfieuyz
 slN+y3Y3FDk7zIefkcAlMpUR5ks+jAHOHhk/Kwe5+xP3xk/09acuiNogpPYRH4Fp
 2tV9Qr9cSrDKIX8eLkR/AkRkmESMIzkpEopQY4vpYO+GiEwyKGdGjMTqkgjQ7PSk
 jL1lp36CAeVuR7Bp3OFT7bilXZKTrkOiwkC2ctFmyjYK+VO4HWBeOeMmoZvTBRCO
 +RXAZVN0zFyxPuH6ZJqOuQpCyoY0JBZPZulwRrXGsQpQOoITuEt9yJpLfDSj6hYd
 Pj8NLHT10n8DBnLk8nXuxT0mNgGDBTNOVCpVblmfm2CLcEGOQsAzWCgCKjkehCUJ
 O3I/3ZHzs1tvCZNcmt5HH8d8D+iMtkOS8bSHTHvZ2ADjSXWGPgXYlUwObYH6kV9N
 nMYi8Q6r8skkESL1jaE12XMZxGm07emIyUh+9hfM0lLGEC/cPff2gXwKhtZMDQfE
 XELx3e/EbyqNsNqFd71v9XpGyJA9si7JvPY/ZSei/CTqToIEAsX/BwGMKGAWnrNy
 ARlp9oaM6BOOg+i2Ddrg
 =qm1Q
 -----END PGP SIGNATURE-----

Merge tag 'regmap-3.4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap

Pull two more small regmap fixes from Mark Brown:
 - Now we have users for it that aren't running Android it turns out
   that regcache_sync_region() is much more useful to drivers if it's
   exported for use by modules.  Who knew?
 - Make sure we don't divide by zero when doing debugfs dumps of
   rbtrees, not visible up until now because everything was providing at
   least some cache on startup.

* tag 'regmap-3.4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
  regmap: prevent division by zero in rbtree_show
  regmap: Export regcache_sync_region()
2012-04-07 09:56:00 -07:00
Stephen Warren bacdbe0773 regmap: introduce fast_io busses, and use a spinlock for them
Some bus types have very fast IO. For these, acquiring a mutex for every
IO operation is a significant overhead. Allow busses to indicate their IO
is fast, and enhance regmap to use a spinlock for those busses.

[Currently limited to native endian registers -- broonie]

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-04-06 10:47:34 +01:00
Stephen Warren c04c1b9ee8 regmap: prevent division by zero in rbtree_show
If there are no nodes in the cache, nodes will be 0, so calculating
"registers / nodes" will cause division by zero.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@vger.kernel.org
2012-04-04 23:22:15 +01:00
Lars-Peter Clausen 4b4e9e43fd regmap: rbtree: Fix register default look-up in sync
The code currently passes the register offset in the current block to
regcache_lookup_reg. This works fine as long as there is only one block and with
base register of 0, but in all other cases it will look-up the default for a
wrong register, which can cause unnecessary register writes. This patch fixes
it by passing the actual register number to regcache_lookup_reg.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: <stable@vger.kernel.org>
2012-04-01 11:47:13 +01:00
Linus Torvalds 250f6715a4 The following text was taken from the original review request:
"[RFC PATCH 0/2] audit of linux/device.h users in include/*"
 		https://lkml.org/lkml/2012/3/4/159
 --
 
 Nearly every subsystem has some kind of header with a proto like:
 
 	void foo(struct device *dev);
 
 and yet there is no reason for most of these guys to care about the
 sub fields within the device struct.  This allows us to significantly
 reduce the scope of headers including headers.  For this instance, a
 reduction of about 40% is achieved by replacing the include with the
 simple fact that the device is some kind of a struct.
 
 Unlike the much larger module.h cleanup, this one is simply two
 commits.  One to fix the implicit <linux/device.h> users, and then
 one to delete the device.h includes from the linux/include/ dir
 wherever possible.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJPbNxLAAoJEOvOhAQsB9HWR6QQAMRUZ94O2069/nW9h4TO/xTr
 Hq/80lo/TBBiRmob3iWBP76lzgeeMPPVEX1I6N7YYlhL3IL7HsaJH1DvpIPPHXQP
 GFKcBsZ5ZLV8c4CBDSr+/HFNdhXc0bw0awBjBvR7gAsWuZpNFn4WbhizJi4vWAoE
 4ydhPu55G1G8TkBtYLJQ8xavxsmiNBSDhd2i+0vn6EVpgmXynjOMG8qXyaS97Jvg
 pZLwnN5Wu21coj6+xH3QUKCl1mJ+KGyamWX5gFBVIfsDB3k5H4neijVm7t1en4b0
 cWxmXeR/JE3VLEl/17yN2dodD8qw1QzmTWzz1vmwJl2zK+rRRAByBrL0DP7QCwCZ
 ppeJbdhkMBwqjtknwrmMwsuAzUdJd79GXA+6Vm+xSEkr6FEPK1M0kGbvaqV9Usgd
 ohMewewbO6ddgR9eF7Kw2FAwo0hwkPNEplXIym9rZzFG1h+T0STGSHvkn7LV765E
 ul1FapSV3GCxEVRwWTwD28FLU2+0zlkOZ5sxXwNPTT96cNmW+R7TGuslZKNaMNjX
 q7eBZxo8DtVt/jqJTntR8bs8052c8g1Ac1IKmlW8VSmFwT1M6VBGRn1/JWAhuUgv
 dBK/FF+I1GJTAJWIhaFcKXLHvmV9uhS6JaIhLMDOetoOkpqSptJ42hDG+89WkFRk
 o55GQ5TFdoOpqxVzGbvE
 =3j4+
 -----END PGP SIGNATURE-----

Merge tag 'device-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux

Pull <linux/device.h> avoidance patches from Paul Gortmaker:
 "Nearly every subsystem has some kind of header with a proto like:

	void foo(struct device *dev);

  and yet there is no reason for most of these guys to care about the
  sub fields within the device struct.  This allows us to significantly
  reduce the scope of headers including headers.  For this instance, a
  reduction of about 40% is achieved by replacing the include with the
  simple fact that the device is some kind of a struct.

  Unlike the much larger module.h cleanup, this one is simply two
  commits.  One to fix the implicit <linux/device.h> users, and then one
  to delete the device.h includes from the linux/include/ dir wherever
  possible."

* tag 'device-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux:
  device.h: audit and cleanup users in main include dir
  device.h: cleanup users outside of linux/include (C files)
2012-03-24 10:41:37 -07:00
Mark Brown 4a6be7bb74 Merge remote-tracking branches 'regmap/topic/patch' and 'regmap/topic/sync' into regmap-next 2012-03-14 13:14:24 +00:00
Paul Gortmaker 51990e8254 device.h: cleanup users outside of linux/include (C files)
For files that are actively using linux/device.h, make sure
that they call it out.  This will allow us to clean up some
of the implicit uses of linux/device.h within include/*
without introducing build regressions.

Yes, this was created by "cheating" -- i.e. the headers were
cleaned up, and then the fallout was found and fixed, and then
the two commits were reordered.  This ensures we don't introduce
build regressions into the git history.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2012-03-11 14:27:37 -04:00
Mark Brown f9353e70bc regmap: Fix rbtree block base in sync
Otherwise we'll end up running with bogus register numbers.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-03-05 23:49:24 +00:00
Mark Brown 994f5db65e regcache: Make sure we sync register 0 in an rbtree cache
Most of the current users have register 0 as a volatile register or don't
have a register 0 so it's not been apparent that it's not getting synced.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-03-05 23:48:50 +00:00
Mark Brown ac8d91c801 regmap: Supply ranges to the sync operations
In order to allow us to support partial sync operations add minimum and
maximum register arguments to the sync operation and update the rbtree
and lzo caches to use this new information. The LZO implementation is
obviously not good, we could exit the iteration earlier, but there may
be room for more wide reaching optimisation there.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-02-24 14:52:40 +00:00
Mark Brown cce585ce1e regmap: Fix rbtreee build when not using debugfs
The debugfs functions don't stub themselves out quite so well as might
be desirable so provide functions which do do this stubbing.

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-11-22 11:43:01 +00:00
Mark Brown bad2ab4b6d regmap: Provide debugfs dump of the rbtree cache data
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>
2011-11-21 19:50:10 +00:00
Lars-Peter Clausen 462a185c5c regmap: Do not call regcache_exit from regcache_rbtree_init error path
Calling regcache_exit from regcache_rbtree_init is first of all a layering
violation and secondly will cause double frees. regcache_exit will free buffers
allocated by the core, but the core will also free the same buffers when the
cacheops init callback returns an error. Thus we end up with a double free.
Fix this by not calling regcache_exit but only free those buffers which, have
been allocated in this function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-11-15 19:22:59 +00:00
Mark Brown b03622a80d regmap: Ensure rbtree syncs registers set to zero properly
Simplify the check for registers set at their default value by avoiding
picking a default value in the case where we don't have one. Instead we
only compare the current value to the current value when we looked one
up. This fixes the case where we don't have a default stored but the value
was set to zero when that isn't the chip default.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
2011-10-10 10:26:48 +01:00
Mark Brown e42c5a9a42 regmap: Allow rbtree to cache zero default values
Ensure that when we start up in cache only mode we can store defaults of
zero, otherwise if the hardware is unavailable we won't be able to read.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
2011-10-10 10:25:00 +01:00
Mark Brown 6e6ace00a0 regmap: Return a sensible error code if we fail to read the cache
If a register isn't cached then let callers know that so they can fall
back or error handle appropriately.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
2011-10-10 10:24:03 +01:00
Dimitris Papastamos 13753a9088 regmap: Lock the sync path, ensure we use the lockless _regmap_write()
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-09-30 13:57:47 +01:00
Lars-Peter Clausen 3405addd22 regmap: rbtree-cache: Move cached rbnode handling into lookup function
Move the handling of the cached rbnode into regcache_rbtree_lookup. This allows
us to remove of some duplicated code sections in regcache_rbtree_read and
regcache_rbtree_write.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-09-28 13:18:22 +01:00
Lars-Peter Clausen c5713004b3 regmap: regcache_rbtree_{set,get}_register: Use regcache_{set,get}_val
Use regcache_{set,get}_val in regcache_rbtree_{set,get}_register instead of
re-implementing its functionality.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-09-28 13:18:11 +01:00
Dimitris Papastamos 25ed1156dd regmap: Remove redundant member `word_size' from regcache_rbtree_node
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-09-27 13:27:09 +01:00
Dimitris Papastamos 28644c809f regmap: Add the rbtree cache support
This patch adds support for the rbtree cache compression type.

Each rbnode manages a variable length block of registers.  There can be no
two nodes with overlapping blocks.  Each block has a base register and a
currently top register, all the other registers, if any, lie in between these
two and in ascending order.

The reasoning behind the construction of this rbtree is simple.  In the
snd_soc_rbtree_cache_init() function, we iterate over the register defaults
provided by the regcache core.  For each register value that is non-zero we
insert it in the rbtree.  In order to determine in which rbnode we need
to add the register, we first look if there is another register already
added that is adjacent to the one we are about to add.  If that is the case
we append it in that rbnode block, otherwise we create a new rbnode
with a single register in its block and add it to the tree.

There are various optimizations across the implementation to speed up lookups
by caching the most recently used rbnode.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-09-19 19:06:33 +01:00