* [PATCH] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31()
@ 2024-11-17 12:03 Christophe JAILLET
2024-11-18 9:40 ` André Draszik
2024-12-02 14:02 ` Krzysztof Kozlowski
0 siblings, 2 replies; 6+ messages in thread
From: Christophe JAILLET @ 2024-11-17 12:03 UTC (permalink / raw)
To: Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
Linus Walleij, André Draszik
Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc,
linux-gpio
chained_irq_enter(() should be paired with a corresponding
chained_irq_exit().
Here, if clk_enable() fails, a early return occurs and chained_irq_exit()
is not called.
Add a new label and a goto for fix it.
Fixes: f9c744747973 ("pinctrl: samsung: support a bus clock")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
Review with care, irq handling is sometimes tricky...
---
drivers/pinctrl/samsung/pinctrl-exynos.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index b79c211c0374..ac6dc22b37c9 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -636,7 +636,7 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc)
if (clk_enable(b->drvdata->pclk)) {
dev_err(b->gpio_chip.parent,
"unable to enable clock for pending IRQs\n");
- return;
+ goto out;
}
}
@@ -652,6 +652,7 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc)
if (eintd->nr_banks)
clk_disable(eintd->banks[0]->drvdata->pclk);
+out:
chained_irq_exit(chip, desc);
}
--
2.47.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31()
2024-11-17 12:03 [PATCH] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31() Christophe JAILLET
@ 2024-11-18 9:40 ` André Draszik
2024-11-18 17:49 ` Christophe JAILLET
2024-11-18 20:40 ` Christophe JAILLET
2024-12-02 14:02 ` Krzysztof Kozlowski
1 sibling, 2 replies; 6+ messages in thread
From: André Draszik @ 2024-11-18 9:40 UTC (permalink / raw)
To: Christophe JAILLET, Krzysztof Kozlowski, Sylwester Nawrocki,
Alim Akhtar, Linus Walleij
Cc: linux-kernel, kernel-janitors, Krzysztof Kozlowski,
linux-arm-kernel, linux-samsung-soc, linux-gpio
On Sun, 2024-11-17 at 13:03 +0100, Christophe JAILLET wrote:
> chained_irq_enter(() should be paired with a corresponding
> chained_irq_exit().
>
> Here, if clk_enable() fails, a early return occurs and chained_irq_exit()
> is not called.
>
> Add a new label and a goto for fix it.
>
> Fixes: f9c744747973 ("pinctrl: samsung: support a bus clock")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only.
>
> Review with care, irq handling is sometimes tricky...
Well spotted, thanks.
It looks like there is a similar problem in exynos_irq_request_resources()
in same file. It should likely call gpiochip_unlock_as_irq() if clk_enable()
failed.
Care to fix that as well?
That said,
Reviewed-by: André Draszik <andre.draszik@linaro.org>
Cheers,
Andre'
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31()
2024-11-18 9:40 ` André Draszik
@ 2024-11-18 17:49 ` Christophe JAILLET
2024-11-18 20:40 ` Christophe JAILLET
1 sibling, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2024-11-18 17:49 UTC (permalink / raw)
To: André Draszik, Krzysztof Kozlowski, Sylwester Nawrocki,
Alim Akhtar, Linus Walleij
Cc: linux-kernel, kernel-janitors, Krzysztof Kozlowski,
linux-arm-kernel, linux-samsung-soc, linux-gpio
Le 18/11/2024 à 10:40, André Draszik a écrit :
> On Sun, 2024-11-17 at 13:03 +0100, Christophe JAILLET wrote:
>> chained_irq_enter(() should be paired with a corresponding
>> chained_irq_exit().
>>
>> Here, if clk_enable() fails, a early return occurs and chained_irq_exit()
>> is not called.
>>
>> Add a new label and a goto for fix it.
>>
>> Fixes: f9c744747973 ("pinctrl: samsung: support a bus clock")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> Compile tested only.
>>
>> Review with care, irq handling is sometimes tricky...
>
> Well spotted, thanks.
>
> It looks like there is a similar problem in exynos_irq_request_resources()
> in same file. It should likely call gpiochip_unlock_as_irq() if clk_enable()
> failed.
Agreed.
>
> Care to fix that as well?
NP, I'll send a patch.
CJ
>
> That said,
>
> Reviewed-by: André Draszik <andre.draszik@linaro.org>
>
>
> Cheers,
> Andre'
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31()
2024-11-18 9:40 ` André Draszik
2024-11-18 17:49 ` Christophe JAILLET
@ 2024-11-18 20:40 ` Christophe JAILLET
2024-11-19 6:35 ` André Draszik
1 sibling, 1 reply; 6+ messages in thread
From: Christophe JAILLET @ 2024-11-18 20:40 UTC (permalink / raw)
To: André Draszik, Krzysztof Kozlowski, Sylwester Nawrocki,
Alim Akhtar, Linus Walleij
Cc: linux-kernel, kernel-janitors, Krzysztof Kozlowski,
linux-arm-kernel, linux-samsung-soc, linux-gpio
Le 18/11/2024 à 10:40, André Draszik a écrit :
> On Sun, 2024-11-17 at 13:03 +0100, Christophe JAILLET wrote:
>> chained_irq_enter(() should be paired with a corresponding
>> chained_irq_exit().
>>
>> Here, if clk_enable() fails, a early return occurs and chained_irq_exit()
>> is not called.
>>
>> Add a new label and a goto for fix it.
>>
>> Fixes: f9c744747973 ("pinctrl: samsung: support a bus clock")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> Compile tested only.
>>
>> Review with care, irq handling is sometimes tricky...
>
> Well spotted, thanks.
>
> It looks like there is a similar problem in exynos_irq_request_resources()
> in same file. It should likely call gpiochip_unlock_as_irq() if clk_enable()
> failed.
Also wondering if it is needed in exynos_irq_release_resources() if
clk_enable() fails and we early return.
I don't know how these callbacks are used and if we could dead-lock in
such a situation.
What do you think?
CJ
>
> Care to fix that as well?
>
> That said,
>
> Reviewed-by: André Draszik <andre.draszik@linaro.org>
>
>
> Cheers,
> Andre'
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31()
2024-11-18 20:40 ` Christophe JAILLET
@ 2024-11-19 6:35 ` André Draszik
0 siblings, 0 replies; 6+ messages in thread
From: André Draszik @ 2024-11-19 6:35 UTC (permalink / raw)
To: Christophe JAILLET, Krzysztof Kozlowski, Sylwester Nawrocki,
Alim Akhtar, Linus Walleij
Cc: linux-kernel, kernel-janitors, Krzysztof Kozlowski,
linux-arm-kernel, linux-samsung-soc, linux-gpio
Hi Christophe,
On Mon, 2024-11-18 at 21:40 +0100, Christophe JAILLET wrote:
> Also wondering if it is needed in exynos_irq_release_resources() if
> clk_enable() fails and we early return.
>
> I don't know how these callbacks are used and if we could dead-lock in
> such a situation.
>
> What do you think?
This was pointed out indeed in
https://lore.kernel.org/all/9a960401-f41f-4902-bcbd-8f30f318ba98@kernel.org/
but irq_chip::irq_release_resources() is not expected to fail.
_mask(), _unmask(), and _ack() have a similar issue. In practice, I don't
think the enable has ever failed in our usecase - it's just a simple bit
flip after all.
There are two options, update the callback signatures (and all users...), or
keep the clock on for the whole duration. Given the clock really is needed
for register access only, we didn't do the latter originally:
https://lore.kernel.org/all/0106b6f58ce19752c2c685d128e5a480103ee91c.camel@linaro.org/
Not sure what the preference would be, 2nd option is likely easier to do and
it would be surprising if _mask() etc. suddenly could fail.
Cheers,
Andre'
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31()
2024-11-17 12:03 [PATCH] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31() Christophe JAILLET
2024-11-18 9:40 ` André Draszik
@ 2024-12-02 14:02 ` Krzysztof Kozlowski
1 sibling, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-12-02 14:02 UTC (permalink / raw)
To: Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
Linus Walleij, André Draszik, Christophe JAILLET
Cc: linux-kernel, kernel-janitors, linux-arm-kernel,
linux-samsung-soc, linux-gpio
On Sun, 17 Nov 2024 13:03:32 +0100, Christophe JAILLET wrote:
> chained_irq_enter(() should be paired with a corresponding
> chained_irq_exit().
>
> Here, if clk_enable() fails, a early return occurs and chained_irq_exit()
> is not called.
>
> Add a new label and a goto for fix it.
>
> [...]
Applied, thanks!
[1/1] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31()
https://git.kernel.org/pinctrl/samsung/c/f686a2b52e9d78cf401f1b7f446bf0c3a81ebcc0
Best regards,
--
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-12-02 14:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-17 12:03 [PATCH] pinctrl: samsung: Fix irq handling if an error occurs in exynos_irq_demux_eint16_31() Christophe JAILLET
2024-11-18 9:40 ` André Draszik
2024-11-18 17:49 ` Christophe JAILLET
2024-11-18 20:40 ` Christophe JAILLET
2024-11-19 6:35 ` André Draszik
2024-12-02 14:02 ` Krzysztof Kozlowski
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®