From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>, Jonathan Cameron <jic23@kernel.org>
Cc: Crestez Dan Leonard <leonard.crestez@intel.com>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Hartmut Knaack <knaack.h@gmx.de>,
Daniel Baluta <daniel.baluta@intel.com>
Subject: Re: [PATCH 1/5] max44000: Initial commit
Date: Mon, 18 Apr 2016 12:59:01 +0200 [thread overview]
Message-ID: <5714BDF5.8080305@metafoo.de> (raw)
In-Reply-To: <20160418103212.GQ3217@sirena.org.uk>
[-- Attachment #1: Type: text/plain, Size: 1971 bytes --]
On 04/18/2016 12:32 PM, Mark Brown wrote:
[...]
>>>> This always seems like a good idea, but tends to cause issues.
>>>> FLAT is really only meant for very high performance devices, you
>>>> are probably better with something else here. If you are doing this
>>>> deliberately to make the below writes actually occur, then please
>>>> add a comment here.
>
>>> I used REGCACHE_FLAT because my device has a very small number of
>>> registers and I assume it uses less memory. Honestly it would make
>>> sense for regmap to include a REGCACHE_AUTO cache_type and pick the
>>> cache implementation automatically based on number of registers.
>
>> I've fallen for that one in the past as well. AUTO would indeed
>> be good if it was easy to do.
>
> It's extremely easy to do. Unless you've got a good reason to do
> anything else you should always be using an rbtree. The core would
> never select anything else.
Just to add some technical background, maybe that helps to clear things up.
The rbtree does not have a one node for each register, it has one node for
each continuous register region. You can think of the rbtree regmap as a
tree with a flat cache at each node. If there is only one continuous region
there will only be one node and the behavior is very similar to the flat cache.
The memory overhead is the size of single node, which is usually negligible.
For register reads and writes there is a slight overhead of looking up the
node. But since the rbtree caches the node that was looked up last the
overhead is just checking if the current node is still the correct one
(which it will be since there is only one node). This check is about 4-5 hw
instructions which is completely negligible to the time it takes to execute
the SPI or I2C transfer. The only place where flat makes sense is where the
hardware register access itself only takes a few CPU cycles and where the
overhead of the lookup is noticeable.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-04-18 10:59 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 16:21 [PATCH 0/5] Support for max44000 Ambient and Infrared Proximity Sensor Crestez Dan Leonard
2016-04-07 16:21 ` [PATCH 1/5] max44000: Initial commit Crestez Dan Leonard
2016-04-07 19:48 ` Peter Meerwald-Stadler
2016-04-10 13:12 ` Jonathan Cameron
2016-04-11 15:08 ` Crestez Dan Leonard
2016-04-17 8:36 ` Jonathan Cameron
2016-04-18 10:32 ` Mark Brown
2016-04-18 10:59 ` Lars-Peter Clausen [this message]
2016-04-18 12:15 ` Crestez Dan Leonard
2016-04-18 12:34 ` Mark Brown
[not found] ` <57153733.1070605@kernel.org>
2016-04-19 9:06 ` Mark Brown
2016-04-18 19:38 ` Jonathan Cameron
2016-04-07 16:21 ` [PATCH 2/5] max44000: Initial support for proximity reading Crestez Dan Leonard
2016-04-10 13:14 ` Jonathan Cameron
2016-04-07 16:21 ` [PATCH 3/5] max44000: Support controlling LED current output Crestez Dan Leonard
2016-04-10 13:16 ` Jonathan Cameron
2016-04-07 16:21 ` [PATCH 4/5] max44000: Expose ambient sensor scaling Crestez Dan Leonard
2016-04-10 13:20 ` Jonathan Cameron
2016-04-07 16:21 ` [PATCH 5/5] max44000: Initial triggered buffer support Crestez Dan Leonard
2016-04-07 19:59 ` Peter Meerwald-Stadler
2016-04-11 16:11 ` Crestez Dan Leonard
2016-04-17 8:41 ` Jonathan Cameron
2016-04-07 21:56 ` kbuild test robot
2016-04-10 13:24 ` Jonathan Cameron
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=5714BDF5.8080305@metafoo.de \
--to=lars@metafoo.de \
--cc=broonie@kernel.org \
--cc=daniel.baluta@intel.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=leonard.crestez@intel.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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).