mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Richard <thomas.richard@bootlin.com>
To: Peter Rosin <peda@axentia.se>
Cc: linux-kernel@vger.kernel.org, gregory.clement@bootlin.com,
	theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com,
	u-kumar1@ti.com, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 1/2] mux: add mux_chip_resume() function
Date: Wed, 4 Sep 2024 11:18:13 +0200	[thread overview]
Message-ID: <f5067055-1470-4386-8839-b4ec2527872e@bootlin.com> (raw)
In-Reply-To: <94069d56-0981-2d69-65c2-901a05758806@axentia.se>

On 9/3/24 15:22, Peter Rosin wrote:
> Hi!
> 
> Sorry for being unresponsive. And for first writing this in the older v4
> thread instead of here.
> 
> 2024-06-13 at 15:07, Thomas Richard wrote:
>> The mux_chip_resume() function restores a mux_chip using the cached state
>> of each mux.
>>
>> Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
>> ---
>>  drivers/mux/core.c         | 29 +++++++++++++++++++++++++++++
>>  include/linux/mux/driver.h |  1 +
>>  2 files changed, 30 insertions(+)
>>
>> diff --git a/drivers/mux/core.c b/drivers/mux/core.c
>> index 78c0022697ec..0858cacae845 100644
>> --- a/drivers/mux/core.c
>> +++ b/drivers/mux/core.c
>> @@ -215,6 +215,35 @@ void mux_chip_free(struct mux_chip *mux_chip)
>>  }
>>  EXPORT_SYMBOL_GPL(mux_chip_free);
>>  
>> +/**
>> + * mux_chip_resume() - restores the mux-chip state
>> + * @mux_chip: The mux-chip to resume.
>> + *
>> + * Restores the mux-chip state.
>> + *
>> + * Return: Zero on success or a negative errno on error.
>> + */
>> +int mux_chip_resume(struct mux_chip *mux_chip)
>> +{
>> +	int ret, i;
>> +
>> +	for (i = 0; i < mux_chip->controllers; ++i) {
>> +		struct mux_control *mux = &mux_chip->mux[i];
>> +
>> +		if (mux->cached_state == MUX_CACHE_UNKNOWN)
>> +			continue;
>> +
>> +		ret = mux_control_set(mux, mux->cached_state);
> 
> mux_control_set() is an internal helper. It is called from
> __mux_control_select() and mux_control_deselect() (and on init...)
> 
> In all those cases, there is no race to reach the mux_control_set()
> function, by means of the mux->lock semaphore (or the mux not being
> "published" yet).
> 
> I fail to see how resume is safe when mux->lock is ignored?

I think I should use mux_control_select() to use the lock.
If I ignore the lock, I could have a cache coherence issue.

I'll send a new version which use mux_control_select().
But if I use mux_control_select(), I have to clean the cache before to
call it, if not nothing happen [1].

[1]
https://elixir.bootlin.com/linux/v6.11-rc6/source/drivers/mux/core.c#L319

Regards,

Thomas


  reply	other threads:[~2024-09-04  9:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 13:07 [PATCH 0/2] Add resume support for the mux mmio driver Thomas Richard
2024-06-13 13:07 ` [PATCH 1/2] mux: add mux_chip_resume() function Thomas Richard
2024-09-03 13:22   ` Peter Rosin
2024-09-04  9:18     ` Thomas Richard [this message]
2024-09-04  9:32       ` Peter Rosin
2024-09-04 11:29         ` Thomas Richard
2024-09-04 12:52           ` Peter Rosin
2024-09-04 16:07             ` Thomas Richard
2024-09-05  8:28               ` Peter Rosin
2024-09-06 16:17                 ` Thomas Richard
2024-09-07  9:16                   ` Peter Rosin
2024-06-13 13:07 ` [PATCH 2/2] mux: mmio: add resume support Thomas Richard
2024-08-20  9:32 ` [PATCH 0/2] Add resume support for the mux mmio driver Thomas Richard
2024-09-03 12:39 ` Thomas Richard
2024-09-03 12:56   ` Greg KH

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=f5067055-1470-4386-8839-b4ec2527872e@bootlin.com \
    --to=thomas.richard@bootlin.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.clement@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=theo.lebrun@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=u-kumar1@ti.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®