All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Wan ZongShun <mcuos.com@gmail.com>
Cc: linux-spi <spi-devel-general@lists.sourceforge.net>,
	David Brownell-sourceforge <dbrownell@users.sourceforge.net>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ARM: Add spi controller driver support for NUC900
Date: Wed, 18 Nov 2009 23:49:28 -0800	[thread overview]
Message-ID: <20091118234928.8d86a9f9.akpm@linux-foundation.org> (raw)
In-Reply-To: <e68bb3470911182223r28e9bac0lf185c1443168ff52@mail.gmail.com>

On Thu, 19 Nov 2009 14:23:49 +0800 Wan ZongShun <mcuos.com@gmail.com> wrote:

> >> +static int __devexit w90p910_spi_remove(struct platform_device *dev)
> >> +{
> >> + __ __ struct w90p910_spi *hw = platform_get_drvdata(dev);
> >> +
> >> + __ __ platform_set_drvdata(dev, NULL);
> >> +
> >> + __ __ spi_unregister_master(hw->master);
> >> +
> >> + __ __ clk_disable(hw->clk);
> >> + __ __ clk_put(hw->clk);
> >
> > As far as I can tell, a hardware interrupt could still be pending, or
> > be under service while the above code is executing?
> >
> > If so, I expect bad things will happen?
> 
> Do you mean that I should put this 'free_irq()' in the front of
> w90p910_spi_remove___
> 
> such as:
> "
> free_irq(hw->irq, hw);
> 
> platform_set_drvdata(dev, NULL);
> 
> spi_unregister_master(hw->master);
> 
> clk_disable(hw->clk);
> clk_put(hw->clk);

I don't know, because I don't know what operation the hardware needs to
stop it from generating interrupts.  Perhaps that's clk_disable()?

Once you've stopped the source of interrupts then the code should wait
for the IRQ handler to complete if it's running on another CPU.  Yes,
free_irq() does that.

It's only after the clk_disable() and the free_irq() that you can
guarantee that no interrupt handler will run and attempt to access the
device and its associated data structures.

WARNING: multiple messages have this Message-ID (diff)
From: akpm@linux-foundation.org (Andrew Morton)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: Add spi controller driver support for NUC900
Date: Wed, 18 Nov 2009 23:49:28 -0800	[thread overview]
Message-ID: <20091118234928.8d86a9f9.akpm@linux-foundation.org> (raw)
In-Reply-To: <e68bb3470911182223r28e9bac0lf185c1443168ff52@mail.gmail.com>

On Thu, 19 Nov 2009 14:23:49 +0800 Wan ZongShun <mcuos.com@gmail.com> wrote:

> >> +static int __devexit w90p910_spi_remove(struct platform_device *dev)
> >> +{
> >> + __ __ struct w90p910_spi *hw = platform_get_drvdata(dev);
> >> +
> >> + __ __ platform_set_drvdata(dev, NULL);
> >> +
> >> + __ __ spi_unregister_master(hw->master);
> >> +
> >> + __ __ clk_disable(hw->clk);
> >> + __ __ clk_put(hw->clk);
> >
> > As far as I can tell, a hardware interrupt could still be pending, or
> > be under service while the above code is executing?
> >
> > If so, I expect bad things will happen?
> 
> Do you mean that I should put this 'free_irq()' in the front of
> w90p910_spi_remove___
> 
> such as:
> "
> free_irq(hw->irq, hw);
> 
> platform_set_drvdata(dev, NULL);
> 
> spi_unregister_master(hw->master);
> 
> clk_disable(hw->clk);
> clk_put(hw->clk);

I don't know, because I don't know what operation the hardware needs to
stop it from generating interrupts.  Perhaps that's clk_disable()?

Once you've stopped the source of interrupts then the code should wait
for the IRQ handler to complete if it's running on another CPU.  Yes,
free_irq() does that.

It's only after the clk_disable() and the free_irq() that you can
guarantee that no interrupt handler will run and attempt to access the
device and its associated data structures.

  reply	other threads:[~2009-11-19  7:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-17  6:48 [PATCH] ARM: Add spi controller driver support for NUC900 Wan ZongShun
2009-11-17  6:48 ` Wan ZongShun
2009-11-18 22:21 ` Andrew Morton
2009-11-18 22:21   ` Andrew Morton
2009-11-18 22:21   ` Andrew Morton
2009-11-19  6:23   ` Wan ZongShun
2009-11-19  6:23     ` Wan ZongShun
2009-11-19  7:49     ` Andrew Morton [this message]
2009-11-19  7:49       ` Andrew Morton
2009-11-19  8:40       ` Wan ZongShun
2009-11-19  8:40         ` Wan ZongShun
2009-11-19  9:02         ` Russell King - ARM Linux
2009-11-19  9:02           ` Russell King - ARM Linux
2009-11-19  9:49           ` Wan ZongShun
2009-11-19  9:49             ` Wan ZongShun
2009-11-19 22:41             ` Russell King - ARM Linux
2009-11-19 22:41               ` Russell King - ARM Linux

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=20091118234928.8d86a9f9.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dbrownell@users.sourceforge.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcuos.com@gmail.com \
    --cc=spi-devel-general@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.