From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Svyatoslav Ryhel <clamor95@gmail.com>,
Andi Shyti <andi.shyti@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>, Wolfram Sang <wsa@kernel.org>,
linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] i2c: Add GPIO-based hotplug gate
Date: Tue, 15 Aug 2023 07:20:35 +0200 [thread overview]
Message-ID: <c577a92a-d1e4-df7e-250c-33d47b4d5bcb@linaro.org> (raw)
In-Reply-To: <ZNVcEfNjo0ZZlhIp@qmqm.qmqm.pl>
On 10/08/2023 23:52, Michał Mirosław wrote:
>>>>>>>> Shared IRQ with devm is a recipe for disaster. Are you sure this is a
>>>>>>>> shared one? You have a remove() function which also points that it is
>>>>>>>> not safe. You can:
>>>>>>>> 1. investigate to be sure it is 100% safe (please document why do you
>>>>>>>> think it is safe)
> [...]
>>>> True, therefore non-devm interrupts are recommended also in such case.
>>>> Maybe one of my solutions is actually not recommended.
>>>>
>>>> However if done right, driver with non-shared interrupts, is expected to
>>>> disable interrupts in remove(), thus there is no risk. We have big
>>>> discussions in the past about it, so feel free to dig through LKML to
>>>> read more about. Anyway shared and devm is a clear no go.
>>>
>>> Can you share pointers to some of those discussions? Quick search
>>> about devm_request_irq() and friends found only a thread from 2013
>>
>> Just look at CONFIG_DEBUG_SHIRQ. Some things lore points:
>> https://lore.kernel.org/all/1592130544-19759-2-git-send-email-krzk@kernel.org/
>> https://lore.kernel.org/all/20200616103956.GL4447@sirena.org.uk/
>>
>> I think pretty clear:
>> https://lore.kernel.org/all/87mu52ca4b.fsf@nanos.tec.linutronix.de/
>> https://lore.kernel.org/all/CA+h21hrxQ1fRahyQGFS42Xuop_Q2petE=No1dft4nVb-ijUu2g@mail.gmail.com/
>>
>> Also:
>> https://lore.kernel.org/all/651c9a33-71e6-c042-58e2-6ad501e984cd@pengutronix.de/
>> https://lore.kernel.org/all/36AC4067-78C6-4986-8B97-591F93E266D8@gmail.com/
> [...]
>
> Thanks! It all looks like a proof by example [1]: a broken driver [2]
> was converted to devres [3] and allowed a shared interrupt [4] and now is
> used to back an argument that devres and/or shared IRQs are bad. I have
> a hard time accepting this line of reasoning.
>
> So: sure, if you disable device's clock, you should first disable the
> interrupt handler one way or another, and if you request a shared interrupt
> then you have to write the handler expecting spurious invocations anytime
> between entry to register_irq() and return from free_irq() (BTW, DEBUG_SHIRQ
> is here to help test exactly this). And, when used correctly, devres can
> release you from having to write remove() and error paths (but I guess it
> might be a challenge to find a single driver that is a complete, good and
> complex-enough example).
>
> Coming back from the digression: I gathered following items from the
> review of the i2c-hotplug-gpio driver:
>
> 1. TODO: register i2c_hotplug_deactivate(priv) using
> devm_add_action_or_reset() before registering the IRQ handler
> and remove remove();
>
> 2. shared IRQ: it is expected to be an edge-triggered, rarely
> signalled interrupt and the handler will work fine if called
> spuriously; it is not required to be shared for my Transformer,
> but I can't say much about other hardware. Would a comment help?
We have way too lengthy discussion and now we are circling back. Can you
refer to the first email I wrote?
"You can:
1. investigate to be sure it is 100% safe (please document why do you
think it is safe)
2. drop devm
3. drop shared flag."
Best regards,
Krzysztof
next prev parent reply other threads:[~2023-08-15 5:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-29 16:08 [PATCH v3 0/2] GPIO-based hotplug i2c bus Svyatoslav Ryhel
2023-07-29 16:08 ` [PATCH v3 1/2] dt-bindings: i2c: add binding for i2c-hotplug-gpio Svyatoslav Ryhel
2023-08-05 19:23 ` Krzysztof Kozlowski
2023-08-11 17:37 ` Rob Herring
2023-08-12 21:46 ` Michał Mirosław
2023-08-15 20:00 ` Wolfram Sang
2023-07-29 16:08 ` [PATCH v3 2/2] i2c: Add GPIO-based hotplug gate Svyatoslav Ryhel
2023-07-30 20:25 ` Andi Shyti
2023-07-30 22:11 ` Michał Mirosław
2023-07-31 23:01 ` Michał Mirosław
2023-08-04 23:45 ` Andi Shyti
2023-08-10 22:55 ` Michał Mirosław
2023-07-30 20:30 ` Krzysztof Kozlowski
2023-07-30 21:55 ` Michał Mirosław
2023-07-31 6:58 ` Krzysztof Kozlowski
2023-07-31 8:49 ` Michał Mirosław
2023-07-31 12:59 ` Krzysztof Kozlowski
2023-07-31 22:50 ` Michał Mirosław
2023-08-05 19:17 ` Krzysztof Kozlowski
2023-08-10 21:52 ` Michał Mirosław
2023-08-15 5:20 ` Krzysztof Kozlowski [this message]
2023-07-30 17:49 ` [PATCH v3 0/2] GPIO-based hotplug i2c bus Andi Shyti
2023-07-30 18:21 ` Svyatoslav Ryhel
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=c577a92a-d1e4-df7e-250c-33d47b4d5bcb@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=andi.shyti@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=robh+dt@kernel.org \
--cc=wsa@kernel.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;
as well as URLs for NNTP newsgroup(s).