[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b9183dfc-8e8a-9602-f31c-5de9e27acb88@linaro.org>
Date: Mon, 31 Jul 2023 08:58:14 +0200
From: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To: Michał Mirosław <mirq-linux@...e.qmqm.pl>,
Svyatoslav Ryhel <clamor95@...il.com>
Cc: Andi Shyti <andi.shyti@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Wolfram Sang <wsa@...nel.org>, linux-i2c@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/2] i2c: Add GPIO-based hotplug gate
On 30/07/2023 23:55, Michał Mirosław wrote:
> On Sun, Jul 30, 2023 at 10:30:56PM +0200, Krzysztof Kozlowski wrote:
>> On 29/07/2023 18:08, Svyatoslav Ryhel wrote:
>>> From: Michał Mirosław <mirq-linux@...e.qmqm.pl>
>>>
>>> Implement driver for hot-plugged I2C busses, where some devices on
>>> a bus are hot-pluggable and their presence is indicated by GPIO line.
> [...]
>>> + priv->irq = platform_get_irq(pdev, 0);
>>> + if (priv->irq < 0)
>>> + return dev_err_probe(&pdev->dev, priv->irq,
>>> + "failed to get IRQ %d\n", priv->irq);
>>> +
>>> + ret = devm_request_threaded_irq(&pdev->dev, priv->irq, NULL,
>>> + i2c_hotplug_interrupt,
>>> + IRQF_ONESHOT | IRQF_SHARED,
>>
>> 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)
>
> Could you elaborate on what is unsafe in using devm with shared
> interrupts (as compared to non-shared or not devm-managed)?
>
> The remove function is indeed reversing the order of cleanup. The
> shutdown path can be fixed by removing `remove()` and adding
> `devm_add_action_or_reset(...deactivate)` before the IRQ is registered.
Shared interrupt might be triggered easily by other device between
remove() and irq release function (devm_free_irq() or whatever it is
called).
Best regards,
Krzysztof
Powered by blists - more mailing lists