mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ricard Wanderlof <ricardw@axis.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Waqar Hameed <waqar.hameed@axis.com>,
	Mark Brown <broonie@kernel.org>, <kernel@axis.com>,
	<linux-kernel@vger.kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH v2] regmap: Add debugfs file for forcing field writes
Date: Tue, 13 Jun 2023 17:15:10 +0200 (CEST)	[thread overview]
Message-ID: <5b20509c-e4d5-21f8-fc20-4d02b9abd87d@axis.com> (raw)
In-Reply-To: <2023061322-garter-linseed-6dfe@gregkh>


On Tue, 13 Jun 2023, Greg Kroah-Hartman wrote:

> On Tue, Jun 13, 2023 at 01:42:27PM +0200, Waqar Hameed wrote:
> > `_regmap_update_bits()` checks if the current register value differs
> > from the new value, and only writes to the register if they differ. When
> >
> > +	/*
> > +	 * This could interfere with driver operation. Therefore, don't provide
> > +	 * any real compile time configuration option for this feature. One will
> > +	 * have to modify the source code directly in order to use it.
> > +	 */
> > +#undef REGMAP_ALLOW_FORCE_WRITE_FIELD_DEBUGFS
> > +#ifdef REGMAP_ALLOW_FORCE_WRITE_FIELD_DEBUGFS
> > +	debugfs_create_bool("force_write_field", 0600, map->debugfs,
> > +			    &map->force_write_field);
> > +#endif
> 
> Please no, that means this will never ever ever get used, and if it
> happens to break the build or runtime, no one will ever notice it.
> 
> If you need this for your device/tree/distro, great, just keep it as an
> out-of-tree patch with the huge header "NEVER ENABLE THIS IN A REAL
> SYSTEM" or something like that.

The ordinary only-write-if-bits-have-changed behavior of 
_regmap_update_bits would seem to be mostly an optimization to minimize 
the number of writes to a device. The way it is normally used in the code, 
it's not easy to predict when it in fact will result in a write, because 
the whole idea of a function like this is that a driver doesn't have to 
keep track of which bits are actually set or not, or else the function 
would not be useful in the first place.

I can understand that enabling a write-always behavior results in a 
different behavior on the associated bus (e.g. I2C), but in the end it 
shouldn't affect the functionality of the peripheral device any more than 
rearranging driver code to perform regmap writes in a different order, 
which might also lead to fewer or more bus writes.

It seems I'm clearly in the wrong here, so there must be some scenario 
I've missed. It just doesn't seem that dangerous; it's a debug 
functionality after all.

/Ricard
-- 
Ricard Wolf Wanderlof                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

  reply	other threads:[~2023-06-13 15:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13 11:42 Waqar Hameed
2023-06-13 15:02 ` Greg Kroah-Hartman
2023-06-13 15:15   ` Ricard Wanderlof [this message]
2023-06-13 15:47     ` Mark Brown
2023-06-13 15:39   ` Mark Brown
2023-06-13 16:18 ` Mark Brown

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=5b20509c-e4d5-21f8-fc20-4d02b9abd87d@axis.com \
    --to=ricardw@axis.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=waqar.hameed@axis.com \
    /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

all inboxes | Powered by JetHome®