mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: Jerome Brunet <jbrunet@baylibre.com>
To: Philipp Zabel <p.zabel@pengutronix.de>,
	Dan Robertson <dan@dlrobertson.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Kevin Hilman <khilman@baylibre.com>
Cc: linux-amlogic@lists.infradead.org, linux-usb@vger.kernel.org,
	aouledameur@baylibre.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/1] usb: dwc3: meson-g12a: fix shared reset control use
Date: Tue, 25 Aug 2020 16:20:59 +0200	[thread overview]
Message-ID: <1j5z964xis.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <18105405541cbc32cecaff181e1427f5434fafc3.camel@pengutronix.de>


On Tue 25 Aug 2020 at 12:20, Philipp Zabel <p.zabel@pengutronix.de> wrote:

> On Mon, 2020-08-24 at 16:26 +0200, Jerome Brunet wrote:
> [...]
>> In practice, I think your proposition would work since the drivers
>> sharing this USB reset line are likely to be probed/suspended/resumed at
>> the same time but ...
>> 
>> If we imagine a situation where 2 device share a reset line, 1 go in
>> suspend, the other does not - if the first device as control of the
>> reset, it could trigger it and break the 2nd device. Same goes for
>> probe/remove()
>> 
>> I agree it could be seen as unlikely but leaving such race condition
>> open looks dangerous to me.
>
> You are right, this is not good enough.
>
>> > Is this something that would be feasible for your combination of
>> > drivers? Otherwise it is be unclear to me under which condition a driver
>> > should be allowed to call the proposed reset_control_clear().
>> 
>> I was thinking of reset_control_clear() as the counter part of
>> reset_control_reset().
>
> I'm not particularly fond of reset_control_clear as a name, because it
> is very close to "clearing a reset bit" which usually would deassert a
> reset line (or the inverse).

It was merely a suggestion :) any other name you prefer is fine by me

>
>> When a reset_control_reset() has been called once, "triggered_count" is
>> incremented which signals that the ressource under the reset is
>> "in_use" and the reset should not be done again.
>
> "triggered_count" would then have to be renamed to something like
> "trigger_requested_count", or "use_count". I wonder it might be possible
> to merge this with "deassert_count" as they'd share the same semantics
> (while the count is > 0, the reset line must stay deasserted).

Sure. Could investigate this as a 2nd step ?
I'd like to bring a solution for our meson-usb use case quickly - even
with the revert suggested, we are having an ugly warning around suspend

>
>> reset_control_clear()
>> would be the way to state that the ressource is no longer used and, that
>> from the caller perspective, the reset can fired again if necessary.
>> 
>> If we take the probe / suspend / resume example:
>> * 1st device using the shared will actually trigger it (as it is now)
>> * following device just increase triggered_count
>> 
>> If all devices go to suspend (calling reset_control_clear()) then
>> triggered_count will reach zero, allowing the first device resuming to
>> trigger the reset again ... this is important since it might not be the
>> one which would have got the exclusive control
>> 
>> If any device don't go to suspend, meaning the ressource under reset
>> keep on being used, no reset will performed. With exlusive control,
>> there is a risk that the resuming device resets something already in use.
>>
>> Regarding the condition, on shared resets, call reset_control_reset()
>> should be balanced reset_control_clear() - no clear before reset.
>
> Martin, is this something that would be useful for the current users of
> the shared reset trigger functionality (phy-meson-gxl-usb2 and phy-
> meson8b-usb2 with reset-meson)?

I'm not Martin but these devices are the origin of the request/suggestion.

>
> regards
> Philipp


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2020-08-25 14:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13 16:05 [PATCH 0/1] " Dan Robertson
2020-07-13 16:05 ` [PATCH 1/1] " Dan Robertson
2020-07-18  8:47   ` Neil Armstrong
2020-07-18 22:57     ` Dan Robertson
2020-08-19 15:03   ` Jerome Brunet
2020-08-20 18:02     ` Kevin Hilman
2020-08-20 18:27       ` Jerome Brunet
2020-08-20 18:49         ` Kevin Hilman
2020-08-20 18:44     ` Dan Robertson
2020-08-24  8:14       ` Jerome Brunet
2020-08-24 10:24     ` Philipp Zabel
2020-08-24 14:26       ` Jerome Brunet
2020-08-25 10:20         ` Philipp Zabel
2020-08-25 14:20           ` Jerome Brunet [this message]
2020-08-26  8:14             ` Philipp Zabel
2020-08-26  8:34               ` Jerome Brunet
2020-08-29 15:25           ` Martin Blumenstingl
2020-09-02 14:13             ` Amjad Ouled-Ameur
2020-09-07  8:31               ` Jerome Brunet
2020-09-07  8:33                 ` Amjad Ouled-Ameur
2020-07-14  6:56 ` [PATCH 0/1] " Anand Moon
2020-07-14 13:30   ` Dan Robertson
2020-07-14 15:27     ` Anand Moon
2020-07-15  2:58       ` Dan Robertson
2020-07-15 16:23         ` Anand Moon
2020-07-17  9:01           ` Anand Moon
2020-07-17 16:38             ` Anand Moon
2020-07-18  6:31               ` Anand Moon
2020-07-18  8:46                 ` Neil Armstrong
2020-07-18  9:54                   ` Anand Moon
2020-08-17 17:48 ` patchwork-bot+linux-amlogic

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=1j5z964xis.fsf@starbuckisacylon.baylibre.com \
    --to=jbrunet@baylibre.com \
    --cc=aouledameur@baylibre.com \
    --cc=dan@dlrobertson.com \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=narmstrong@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    /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®