linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ansuel Smith <ansuelsmth@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] regmap: allow to define reg_update_bits for no bus configuration
Date: Wed, 3 Nov 2021 20:48:37 +0100	[thread overview]
Message-ID: <YYLnlbTFRUdLrmpW@Ansuel-xps.localdomain> (raw)
In-Reply-To: <YYLAXL4HjgBGuF91@sirena.org.uk>

On Wed, Nov 03, 2021 at 05:01:16PM +0000, Mark Brown wrote:
> On Tue, Nov 02, 2021 at 10:41:38PM +0100, Ansuel Smith wrote:
> 
> > @@ -3064,7 +3065,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
> >  	if (change)
> >  		*change = false;
> >  
> > -	if (regmap_volatile(map, reg) && map->reg_update_bits) {
> > +	if ((regmap_volatile(map, reg) || !map->bus) && map->reg_update_bits) {
> >  		ret = map->reg_update_bits(map->bus_context, reg, mask, val);
> >  		if (ret == 0 && change)
> >  			*change = true;
> 
> I don't understand this change.  The point of the check for volatile
> there is that if the register isn't volatile then we need to ensure that
> the cache gets updated with any change that happens so we need to go
> through paths that include cache updates.  The presence or otherwise of
> a bus does not seem at all relevant here.

I put the check there to not duplicate the code. The idea here is:
if we are doing a regmap_update_bits operation on a no bus configuration
and the function have a dedicated reg_update_bits function, use that
instead of the normal _reg_read, check and _reg_write.
To workaround the CACHE problem, I can add a check and detect if cache is
disabled and only with that option permit to add a reg_update_bits
function to the map (for no bus configuration).

Again the problem here is in situation where lock is handled outside of
the read/write and the read/modify/write operation has to be done in one
go so splitting this operation in 2 step (like it's done for
regmap_update_bits) would be problematic.

Another solution would be to expose a way to change the cache externally
to the regmap operation so that if someone require cache operation and
require also a dedicated reg_update_bits, he can do that by implementing
that in his own function.
A third solution would be check if it's possible to cache the value
externally to function... Something that calls the reg_update_bits
dedicated function and then update the cache if needed.

But do we really need to add all this complexity when we can just deny
an option with cache enabled and force to use the normal way (else part
in this function)

Hope I was able to explain better why we need this change.

-- 
	Ansuel

  reply	other threads:[~2021-11-03 19:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02 21:41 [PATCH] regmap: allow to define reg_update_bits for no bus configuration Ansuel Smith
2021-11-03 17:01 ` Mark Brown
2021-11-03 19:48   ` Ansuel Smith [this message]
2021-11-03 21:29     ` Mark Brown
2021-11-03 21:53       ` Ansuel Smith
2021-11-04 14:50         ` Mark Brown
2021-11-04 14:57           ` Ansuel Smith

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=YYLnlbTFRUdLrmpW@Ansuel-xps.localdomain \
    --to=ansuelsmth@gmail.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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).