linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] ARM: at91/tclib: mask interruptions at shutdown and probe
Date: Wed, 20 Aug 2014 09:31:13 +0200	[thread overview]
Message-ID: <20140820073111.GH13793@ulmo> (raw)
In-Reply-To: <20140820010130.10974326@bbrezillon>

On Wed, Aug 20, 2014 at 01:01:30AM +0200, Boris BREZILLON wrote:
> Hi Jean-Christophe,
> 
> On Wed, 20 Aug 2014 06:11:17 +0800
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> 
> > Hi,
> > 
> > 	This is a bit weird as the clock of the TC should be off and the irq free
> > 
> > 	so this should never happened we need to investigate more why this append
> 
> I may have found the source of this bug.
> 
> As Gael stated, when you're kexec-ing a new kernel your previous kernel
> could be using the tbc_clksrc driver (and especially the clkevent
> device). Thus the kernel might have planned a timer event and then been
> asked to shutdown the machine (requested by the kexec code).
> In this case the AIC interrupt connected to the TC Block is disabled
> but not the interrupts within the TCB IP (IDR registers), possibly
> leaving a pending interrupt before booting the new kernel.
> 
> When the tcb_clksrc driver is loaded by the new kernel it enables the
> interrupt line by calling setup_irq [1] while the clockevent device is
> not registered yet [2]. Thus the event_handler is still NULL when the
> AIC line connected to the TCB is unmasked. Remember that an interrupt
> is still pending on this HW block, which will lead to an immediate call
> to the ch2_irq handler, which tries to call the event_handler, which in
> turns is NULL because clkevent device registration has not taken place
> at this moment => Kernel panic.
> ITOH, we can't register the clkevent device before the irq handler is
> set up, because we should be ready to handle clkevent request at the
> time clockevents_config_and_register is called.
> 
> This leaves two solution:
>  1) disable the TCB irqs (using TCB IDR registers) before calling
>  setup_irq in the tcb_clksrc driver
>  2) disable the TCB irqs at the tclib level (as proposed by Gael)
> 
> I prefer solution #2 because it fixes the bug for all TCB users (not
> just the tcb_clksrc driver).

Wouldn't a more proper fix be to only enable the IRQ (setup_irq()) once
everything has properly been set up? That's certainly how all other
drivers are doing this. Generally I think it's best to assume that an
interrupt can fire at any point after it's been enabled, so everything
should be set up prior to enabling it.

Also, does anyone know why this driver uses setup_irq() rather than the
more idiomatic request_irq()?

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140820/67449f7a/attachment.sig>

  reply	other threads:[~2014-08-20  7:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19 22:07 [PATCH 0/3] ARM: at91/tclib: fix segmentation fault Gaël PORTAY
2014-08-19 22:07 ` [PATCH 1/3] ARM: at91/tclib: prefer using of devm_* functions Gaël PORTAY
2014-08-20  8:19   ` Boris BREZILLON
2014-08-19 22:07 ` [PATCH 2/3] ARM: at91/tclib: move initialization from alloc to probe Gaël PORTAY
2014-08-20  7:39   ` Thierry Reding
2014-08-20  8:16   ` Boris BREZILLON
2014-08-19 22:07 ` [PATCH 3/3] ARM: at91/tclib: mask interruptions at shutdown and probe Gaël PORTAY
2014-08-19 22:11   ` Jean-Christophe PLAGNIOL-VILLARD
2014-08-19 23:01     ` Boris BREZILLON
2014-08-20  7:31       ` Thierry Reding [this message]
2014-08-20  8:14         ` Boris BREZILLON
2014-08-20  8:28           ` Thierry Reding
2014-08-20  9:06             ` Boris BREZILLON
2014-08-20  9:48               ` Thierry Reding
2014-08-20 10:07                 ` Boris BREZILLON
2014-08-21  3:32   ` Arnd Bergmann

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=20140820073111.GH13793@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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).