mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: Doug Anderson <dianders@chromium.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org, Dmitry Osipenko <digetx@gmail.com>,
	Stephen Boyd <swboyd@chromium.org>
Subject: Re: [PATCH 6/6] regulator: core: simplify lock_two()
Date: Mon, 28 Aug 2023 22:26:54 +0200	[thread overview]
Message-ID: <ZO0DDkNUZ4FwYTrz@qmqm.qmqm.pl> (raw)
In-Reply-To: <CAD=FV=XbfBf9y1sdt9T=81cTCRcRUbVqo3oKrHvBQZC+hHQpCQ@mail.gmail.com>

On Mon, Aug 21, 2023 at 09:51:08AM -0700, Doug Anderson wrote:
> Hi,
> 
> On Sat, Aug 19, 2023 at 3:46 PM Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
> >
> > Make regulator_lock_two() shorter by observing that we have only two
> > locks and when swapped earlier the retry code becomes identical to the
> > normal (optimistic) path.
> >
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > ---
> >  drivers/regulator/core.c | 28 ++++++++++------------------
> >  1 file changed, 10 insertions(+), 18 deletions(-)
> 
> This is quite nearly a direct revert of commit 37473397b852
> ("regulator: core: Make regulator_lock_two() logic easier to follow"),
> which was requested by Stephen in:
> 
> https://lore.kernel.org/r/CAE-0n53Eb1BeDPmjBycXUaQAF4ppiAM6UDWje_jiB9GAmR8MMw@mail.gmail.com
> 
> I don't personally have a strong opinion, but do prefer not to flip-flop. ;-)

Indeed they are quite similar. I did remove a bit more code than that,
though: in this case there is no early success return before the loop.

Instead of saying:

lock A
lock B
if ok return
if that failed, loop:
  unlock A
  lock B harder
  lock A
  if ok return
  swap A <-> B
  lock B

Now it's:

lock A
loop forever:
  lock B
  if ok, return
  unlock A
  swap them
  lock A harder

With the same condition 'A held' at the start of an iteration.

Best Regards
Michał Mirosław

  reply	other threads:[~2023-08-28 20:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-19 22:46 [PATCH v2 0/6] regulator: core: locking fixes and cleanups Michał Mirosław
2023-08-19 22:46 ` [PATCH 1/6] regulator: core: simplify regulator_lock_nested() Michał Mirosław
2023-08-21 16:50   ` Doug Anderson
2023-08-19 22:46 ` [PATCH 2/6] regulator: core: skip nesting lock for -EDEADLK Michał Mirosław
2023-08-21 16:50   ` Doug Anderson
2023-08-19 22:46 ` [PATCH 3/6] regulator: core: simplify nested locking Michał Mirosław
2023-08-21 16:50   ` Doug Anderson
2023-08-28 21:01     ` Michał Mirosław
2023-08-19 22:46 ` [PATCH 4/6] regulator: core: remove `goto`s from resolve_supply() Michał Mirosław
2023-08-21 16:50   ` Doug Anderson
2023-08-19 22:46 ` [PATCH 5/6] regulator: core: propagate error out ouf regulator_lock_two() Michał Mirosław
2023-08-21 16:50   ` Doug Anderson
2023-08-19 22:46 ` [PATCH 6/6] regulator: core: simplify lock_two() Michał Mirosław
2023-08-21 16:51   ` Doug Anderson
2023-08-28 20:26     ` Michał Mirosław [this message]
2023-08-29 20:52       ` Stephen Boyd
2023-08-29 21:25         ` Michał Mirosław
2023-08-29 22:57           ` Stephen Boyd
2023-08-30 17:25             ` Michał Mirosław
2023-08-30 18:53               ` Stephen Boyd

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=ZO0DDkNUZ4FwYTrz@qmqm.qmqm.pl \
    --to=mirq-linux@rere.qmqm.pl \
    --cc=broonie@kernel.org \
    --cc=dianders@chromium.org \
    --cc=digetx@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swboyd@chromium.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

all inboxes | Powered by JetHome®