[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6bc3120a-81dd-3b6c-d246-559a3c072969@axentia.se>
Date: Fri, 21 Apr 2017 16:55:18 +0200
From: Peter Rosin <peda@...ntia.se>
To: Philipp Zabel <p.zabel@...gutronix.de>
CC: Mark Rutland <mark.rutland@....com>, <devicetree@...r.kernel.org>,
Lars-Peter Clausen <lars@...afoo.de>, <kernel@...gutronix.de>,
Wolfram Sang <wsa@...-dreams.de>, <linux-iio@...r.kernel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jonathan Corbet <corbet@....net>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Rob Herring <robh+dt@...nel.org>, <linux-i2c@...r.kernel.org>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Hartmut Knaack <knaack.h@....de>,
Colin Ian King <colin.king@...onical.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Jonathan Cameron <jic23@...nel.org>
Subject: Re: [PATCH v13 03/10] mux: minimal mux subsystem and gpio-based mux
controller
On 2017-04-21 16:41, Philipp Zabel wrote:
> On Fri, 2017-04-21 at 16:32 +0200, Peter Rosin wrote:
>> On 2017-04-21 16:23, Philipp Zabel wrote:
>>> On Thu, 2017-04-13 at 18:43 +0200, Peter Rosin wrote:
>>> [...]
>>>> +int mux_chip_register(struct mux_chip *mux_chip)
>>>> +{
>>>> + int i;
>>>> + int ret;
>>>> +
>>>> + for (i = 0; i < mux_chip->controllers; ++i) {
>>>> + struct mux_control *mux = &mux_chip->mux[i];
>>>> +
>>>> + if (mux->idle_state == mux->cached_state)
>>>> + continue;
>>>
>>> I think this should be changed to
>>>
>>> - if (mux->idle_state == mux->cached_state)
>>> + if (mux->idle_state == mux->cached_state ||
>>> + mux->idle_state == MUX_IDLE_AS_IS)
>>> continue;
>>>
>>> or the following mux_control_set will be called with state ==
>>> MUX_IDLE_AS_IS. Alternatively, mux_control_set should return when passed
>>> this value.
>>
>> That cannot happen because ->cached_state is initialized to -1
>> in mux_chip_alloc, so should always be == MUX_IDLE_AS_IS when
>> registering. And drivers are not supposed to touch ->cached_state.
>> I.e., ->cached_state is "owned" by the core.
>
> So this was caused by me filling cached_state from register reads in the
> mmio driver. Makes me wonder why I am not allowed to do this, though, if
> I am able to read back the initial state?
You gain fairly little by reading back the original state. If the mux
should idle-as-is, you can avoid a maximum of one mux update if the first
consumer happens to starts by requesting the previously active state.
Similarly, if the mux should idle in a specific state, you can avoid a
maximum of one mux update.
In both cases it costs one unconditional read of the mux state.
Sure, in some cases reads are cheaper than writes, but I didn't think
support for seeding the cache was worth it. Is it worth it?
Cheers,
peda
Powered by blists - more mailing lists