Re: [PATCH] rtc: Make rtc_update_irq callable with irqs enabled

From: Andrew Morton
Date: Thu Apr 09 2009 - 18:42:42 EST


On Tue, 7 Apr 2009 01:50:31 +0900
Atsushi Nemoto <anemo@xxxxxxxxxxxxx> wrote:

> The rtc_update_irq() might be called with irqs enabled, if a interrupt
> handler was registered without IRQF_DISABLED.

Why? What are the consequences of not merging the patch? Is it a
bugfix? If so, what are the user-visible effects of the bug?

See, I need to decide if this patch is needed in 2.6.30 (and earlier),
but the changelog doesn't include enough info to make that decision.

> Use spin_lock_irqsave/spin_unlock_irqrestore instead of
> spin_lock/spin_unlock.
>
> Signed-off-by: Atsushi Nemoto <anemo@xxxxxxxxxxxxx>
> ---
> drivers/rtc/interface.c | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
> index 4348c4b..a8641f7 100644
> --- a/drivers/rtc/interface.c
> +++ b/drivers/rtc/interface.c
> @@ -376,14 +376,16 @@ EXPORT_SYMBOL_GPL(rtc_update_irq_enable);
> void rtc_update_irq(struct rtc_device *rtc,
> unsigned long num, unsigned long events)
> {
> - spin_lock(&rtc->irq_lock);
> + unsigned long flags;
> +
> + spin_lock_irqsave(&rtc->irq_lock, flags);
> rtc->irq_data = (rtc->irq_data + (num << 8)) | events;
> - spin_unlock(&rtc->irq_lock);
> + spin_unlock_irqrestore(&rtc->irq_lock, flags);
>
> - spin_lock(&rtc->irq_task_lock);
> + spin_lock_irqsave(&rtc->irq_task_lock, flags);
> if (rtc->irq_task)
> rtc->irq_task->func(rtc->irq_task->private_data);
> - spin_unlock(&rtc->irq_task_lock);
> + spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
>
> wake_up_interruptible(&rtc->irq_queue);
> kill_fasync(&rtc->async_queue, SIGIO, POLL_IN);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/