[<prev] [next>] [day] [month] [year] [list]
Message-ID: <8qRxwIYmbvte9HM2KVfkdhwPpeZ7oY9s@localhost>
Date: Thu, 23 Jun 2022 21:54:37 +0100
From: Aidan MacDonald <aidanmacdonald.0x0@...il.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Mark Brown <broonie@...nel.org>, Andy Gross <agross@...nel.org>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Banajit Goswami <bgoswami@...eaurora.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Chanwoo Choi <cw00.choi@...sung.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
MyungJoo Ham <myungjoo.ham@...sung.com>,
Michael Walle <michael@...le.cc>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Thomas Gleixner <tglx@...utronix.de>,
Marc Zyngier <maz@...nel.org>,
Lee Jones <lee.jones@...aro.org>,
Manivannan Sadhasivam <mani@...nel.org>,
Cristian Ciocaltea <cristian.ciocaltea@...il.com>,
Chen-Yu Tsai <wens@...e.org>,
"tharvey@...eworks.com" <tharvey@...eworks.com>,
"rjones@...eworks.com" <rjones@...eworks.com>,
Matti Vaittinen <mazziesaccount@...il.com>,
"orsonzhai@...il.com" <orsonzhai@...il.com>,
"baolin.wang7@...il.com" <baolin.wang7@...il.com>,
"zhang.lyra@...il.com" <zhang.lyra@...il.com>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>,
Liam Girdwood <lgirdwood@...il.com>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
"linux-actions@...ts.infradead.org"
<linux-actions@...ts.infradead.org>,
linux-arm-msm <linux-arm-msm@...r.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
"linux-sunxi@...ts.linux.dev" <linux-sunxi@...ts.linux.dev>,
ALSA Development Mailing List <alsa-devel@...a-project.org>
Subject: Re: [PATCH 15/49] regmap-irq: Change the behavior of mask_writeonly
Andy Shevchenko <andy.shevchenko@...il.com> writes:
> On Tuesday, June 21, 2022, Aidan MacDonald <aidanmacdonald.0x0@...il.com> wrote:
>> Andy Shevchenko <andy.shevchenko@...il.com> writes:
>>
>> > On Mon, Jun 20, 2022 at 10:08 PM Aidan MacDonald
>> > <aidanmacdonald.0x0@...il.com> wrote:
>> >>
>> >> No drivers currently use mask_writeonly, and in its current form
>> >> it seems a bit misleading. When set, mask registers will be
>> >> updated with regmap_write_bits() instead of regmap_update_bits(),
>> >> but regmap_write_bits() still does a read-modify-write under the
>> >> hood. It's not a write-only operation.
>> >>
>> >> Performing a simple regmap_write() is probably more useful, since
>> >> it can be used for chips that have separate set & clear registers
>> >> for controlling mask bits. Such registers are normally volatile
>> >> and read as 0, so avoiding a register read minimizes bus traffic.
>> >
>> > Reading your explanations and the code, I would rather think about
>> > fixing the regmap_write_bits() to be writeonly op.
>>
>> That's impossible without special hardware support.
>>
>> > Otherwise it's unclear what's the difference between
>> > regmap_write_bits() vs. regmap_update_bits().
>>
>> This was not obvious to me either. They're the same except in how they
>> issue the low-level write op -- regmap_update_bits() will only do the
>> write if the new value differs from the current one. regmap_write_bits()
>> will always do a write, even if the new value is the same.
>
> Okay, it makes a lot of sense for W1C type of bits in the register.
> Also, “reading” might imply to restore last value from cache, no?
Maybe there needs to be some explanation of what the typical use case is
and why you'd choose write_bits() over update_bits(), because the more I
think about it the less clear it is. You're right that the read could be
served from a cache. But I'm not sure if a cache would be safe if even
one bit in the register is volatile, and I can't really see a use case
for write_bits() that doesn't involve volatile behavior of some sort.
In any event, I'm just going to drop this patch and the related driver
patches in favor of removing mask_writeonly entirely, since it looks
like it was never used, and after thinking about it I'm not sure what
I did helps much. If some driver needs write_bits() for mask registers
down the road it's not a big deal to add this back.
>> I think the problem is lack of documentation. I only figured this out
>> by reading the implementation.
>>
>> >> if (d->chip->mask_writeonly)
>> >> - return regmap_write_bits(d->map, reg, mask, val);
>> >> + return regmap_write(d->map, reg, val & mask);
>> >> else
>> >> return regmap_update_bits(d->map, reg, mask, val);
Powered by blists - more mailing lists