Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Banajit Goswami <bgoswami@quicinc.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org,
	linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Subject: Re: [PATCH 2/4] reset: add GPIO-based reset controller
Date: Thu, 4 Jan 2024 11:30:39 -0500	[thread overview]
Message-ID: <2be19fbf-4c73-4594-be42-31587dc7b747@seco.com> (raw)
In-Reply-To: <fcbae47b-3b28-42f0-b93f-f83932025dc1@linaro.org>

On 1/4/24 11:08, Krzysztof Kozlowski wrote:
> On 04/01/2024 17:04, Sean Anderson wrote:
>> On 1/4/24 03:57, Krzysztof Kozlowski wrote:
>>> On 28/12/2023 17:05, Sean Anderson wrote:
>>>> On 12/22/23 10:01, Krzysztof Kozlowski wrote:
>>>>> Add simple driver to control GPIO-based resets using the reset
>>>>> controller API for the cases when the GPIOs are shared and reset should
>>>>> be coordinated.  The driver is expected to be used by reset core
>>>>> framework for ad-hoc reset controllers.
>>>>
>>>> How do we handle power sequencing? Often GPIOs need some pre/post delay in
>>>> order to ensure proper power sequencing. For regular reset drivers, this is
>>>> internal to the driver.
>>>
>>> It's not part of this patchset. Power sequencing is an old topic and
>>> generic solutions were failing, rejected, did not solve the problems,
>>> etc (choose your reason).
>>>
>>> Delays are device specific, so they go to drivers (depending on the
>>> compatible). Complex power sequencing is way too much for simplified
>>> reset-framework handling, so anyway it is expected you do it in your driver.
>> 
>> Well, the reason to bring it up is twofold:
>> 
>> - Traditionally, drivers expect the reset controller to handle all
>>   necessary delays. For example, reset-k210 includes a 10us delay
>>   between asserting and deasserting the reset. There's a similar thing
>>   in reset-imx7, and several other reset drivers.
>> - We would need to add custom assert/deassert delays to every driver
>>   using this interface. These are not always added, since any given
>>   device may require delays which can be inferred from its compatible.
>>   However, an integrated system may require delays to be different from
>>   what any individual device requires.
>> 
>>>>
>>>> Maybe something like
>>>>
>>>> my-device {
>>>> 	reset-gpios = <&gpio 555 GPIO_ACTIVE_LOW>;
>>>>         reset-gpios-post-deassert-us = <100>;
>>>
>>> Feel free to add it later. This patchset, and actually all patches
>>> should, solves one problem while allowing you to extend it later.
>> 
>> Yes, but we should try to avoid creating problems for ourselves in the
>> future.
>> 
>>> If there is a architectural problem in my approach not allowing you to
>>> extend it later, then we should discuss it.
>> 
>> Well, I brought up just such an architectural issue below...
> 
> Sorry, but where the issue? You did not present any arguments stating
> that it is not possible to add your feature.
> 
> What is the problem to parse that property?
> 
>> 
>>>> };
>>>>
>>>> Of course, this is a bit ambiguous if you have multiple devices using the same
>>>> GPIO with different delays.
>> 
>> This is the most concerning one to me.
>> 
>>>> Maybe we take the max? But the driver below seems
>>>> to only have access to one device. Which I suppose begs the question: how do
>>>> we know when it's safe to deassert the reset (e.g. we've gotten to the point
>>>> where all devices using this reset gpio have gotten far enough to detect that
>>>> they use it)?
>>>
>>> The driver (reset consumer) knows when it is safe or not. You must
>>> implement proper reset handling in your driver.
>> 
>> The driver has no idea whether it is safe or not. It just calls
>> reset_assert/deassert at the appropriate time, and the reset
>> framework/controller is supposed to coordinate things so e.g. the device
>> doesn't get reset multiple times as multiple drivers all probe.
> 
> 
> Sorry, then I don't get what you refer to. The driver calls deassert
> when it is safe for it to do it, so the driver *knows*. Now, you claim
> that driver does not know that... core also does not know, so no one knows.

Yes! That is the problem with this design. Someone has to coordinate the
reset, and it can't be the driver. But the core also doesn't have enough
information. So no one can do it.

For example, say we want to share a reset GPIO between two devices. Each
device has the following constraints:

device post-assert delay post-deassert delay
====== ================= ===================
A                  500us                 1ms
B                    1ms               300us

If we leave things up to the drivers, then whoever probes first will get
to decide the reset sequence.

So if we choose the post-assert delay to be 1ms and the post-deassert
delay to be 1ms then everyone is happy. How can we make sure the reset
controller enforces this? Well, we can do the above thing and specify
something like

A {
    reset-gpios = <&gpio 555 GPIO_ACTIVE_LOW>;
    reset-gpios-post-assert-us = <1000>;
    reset-gpios-post-deassert-us = <1000>;
};

B {
    reset-gpios = <&gpio 555 GPIO_ACTIVE_LOW>;
};

But what if B gets probed first? Then we will have to also specify the
delays on B as well. I'm not a big fan of this because

- We have to specify (identical) delays in every consumer (instead of
  having a central place to put the delays)
- Having the delays depend on the probe order (if one of the consumers'
  delays don't match) will result in bugs for board maintainers. Maybe
  we should just warn in that case and that is enough?
- Actually, the same problem exists for reset-gpios (e.g. if one driver
  specifies ACTIVE_HIGH and another specifies ACTIVE_LOW).

Maybe the delays should go instead on the gpio controller? So something
like (taking inspiration from gpio-hog):

gpio {
	gpio-controller;
	#gpio-cells = <2>;

	my-reset {
		gpio-reset;
		gpio = <555 GPIO_ACTIVE_LOW>;
		post-assert-us = <1000>;
		post-deassert-us = <1000>;
	};
};

> Hm, wait, now maybe I understand your concern. Did you read the
> patchset? This is for the coordinated, shared, non-exclusive reset by
> design.  And as stated during previous discussions: that's the driver's
> job to be sure it is called like that.

Well, one of the major advantages of moving GPIO resets to a reset
controller is that the reset framework can coordinate things if we want.
This is a rather natural extension of this patchset IMO. Even if you are
not adding this functionality now, it is good not to make it difficult
for future work.

--Sean

  reply	other threads:[~2024-01-04 16:30 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22 15:01 [PATCH 0/4] reset: gpio: ASoC: shared GPIO resets Krzysztof Kozlowski
2023-12-22 15:01 ` [PATCH 1/4] reset: instantiate reset GPIO controller for shared reset-gpios Krzysztof Kozlowski
2023-12-22 17:31   ` Bartosz Golaszewski
2023-12-27 12:35     ` Krzysztof Kozlowski
2023-12-27 19:13       ` Bartosz Golaszewski
2023-12-22 15:01 ` [PATCH 2/4] reset: add GPIO-based reset controller Krzysztof Kozlowski
2023-12-22 15:08   ` Krzysztof Kozlowski
2023-12-28 16:05   ` Sean Anderson
2024-01-04  8:57     ` Krzysztof Kozlowski
2024-01-04 16:04       ` Sean Anderson
2024-01-04 16:08         ` Krzysztof Kozlowski
2024-01-04 16:30           ` Sean Anderson [this message]
2024-01-04 19:08             ` Krzysztof Kozlowski
2024-01-05 14:31               ` Philipp Zabel
2024-01-09  9:41                 ` Krzysztof Kozlowski
2024-01-09 15:51                   ` Sean Anderson
2024-01-05 14:33               ` Mark Brown
2024-01-06 15:32                 ` Krzysztof Kozlowski
2024-01-04 16:11         ` Krzysztof Kozlowski
2023-12-22 15:01 ` [PATCH 3/4] ASoC: dt-bindings: qcom,wsa8840: Add reset-gpios for shared line Krzysztof Kozlowski
2023-12-22 15:16   ` Krzysztof Kozlowski
2023-12-22 16:18   ` Rob Herring
2023-12-22 15:01 ` [PATCH 4/4] ASoC: codecs: wsa884x: Allow sharing reset GPIO Krzysztof Kozlowski
2023-12-22 15:22   ` Krzysztof Kozlowski
2023-12-22 15:09 ` [PATCH 0/4] reset: gpio: ASoC: shared GPIO resets Krzysztof Kozlowski
2023-12-22 15:18 ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2024-02-29 17:26 [PATCH 2/4] reset: add GPIO-based reset controller Tim Harvey
2024-02-29 17:45 ` Krzysztof Kozlowski

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=2be19fbf-4c73-4594-be42-31587dc7b747@seco.com \
    --to=sean.anderson@seco.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=andersson@kernel.org \
    --cc=bgoswami@quicinc.com \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.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