mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: jeffy <jeffy.chen@rock-chips.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, briannorris@chromium.org,
	dianders@chromium.org, tfiga@chromium.org
Subject: Re: [PATCH v2] genirq: Check irq disabled & masked states in irq_shutdown
Date: Sat, 27 May 2017 18:09:29 +0800	[thread overview]
Message-ID: <59295059.7070509@rock-chips.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1705270955110.2329@nanos>

Hi Thomas,

On 05/27/2017 04:30 PM, Thomas Gleixner wrote:
> On Sat, 27 May 2017, Jeffy Chen wrote:
>
>> If a irq is already disabled & masked, free_irq may cause a unbalanced
>> irq shutdown/disable/mask, for example:
>
> No, it's not. irq_shutdown/disable/mask are low level access functions
> which can be invoked at any given time.
>
> The only interface which has refcounting is disable/enable_irq().
but i think it still be good trying to make them balance, at least for 
irq enable/disable :)
>
>> devm_request_irq->irq_startup->irq_enable
>> disable_irq					<-- disabled and masked
>> devm_free_irq->irq_shutdown			<-- try to disable it again
>>
>> This would confuse some pinctrl drivers which would control clk in
>> irq_enable/irq_disable, for example pinctrl-rockchip/pinctrl-nomadik.
>>
>> This patch add a state check in irq_shutdown to prevent that.
>
> Please read Documentation/process/SubmittingPatches and search for "this
> patch".
oops
>
>> diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
>> index 686be4b..816da03 100644
>> --- a/kernel/irq/chip.c
>> +++ b/kernel/irq/chip.c
>> @@ -206,14 +206,20 @@ int irq_startup(struct irq_desc *desc, bool resend)
>>
>>   void irq_shutdown(struct irq_desc *desc)
>>   {
>> -	irq_state_set_disabled(desc);
>>   	desc->depth = 1;
>> +
>> +	if (unlikely(irqd_irq_disabled(&desc->irq_data) &&
>> +		irqd_irq_masked(&desc->irq_data)))
>> +		goto out;
>
> This is just wrong.
>
> It's perfectly legit to call disable_irq() and then free_irq(). Still
> free_irq() has to be able to invoke chip->irq_shutdown(). Preventing that
> will leave some interrupt chips in a half initialized state.
right, irq_shutdown is not just to disable irq, may also do some 
cleanups. will upload new patch.
>
> The irq core does not guarntee that the unmask/mask enable/disable
> startup/shutdown callbacks are perfectly balanced. irq_shutdown() is only
> one place where this can happen. This needs more thought than this 'works
> for me' hackery.
>
> Thanks,
>
> 	tglx
>
>
>

  reply	other threads:[~2017-05-27 10:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-27  4:52 Jeffy Chen
2017-05-27  8:30 ` Thomas Gleixner
2017-05-27 10:09   ` jeffy [this message]
2017-05-27 10:51     ` Thomas Gleixner

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=59295059.7070509@rock-chips.com \
    --to=jeffy.chen@rock-chips.com \
    --cc=briannorris@chromium.org \
    --cc=dianders@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tfiga@chromium.org \
    --cc=tglx@linutronix.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®