LKML Archive on
help / color / mirror / Atom feed
From: Ira Snyder <>
To: Arnd Bergmann <>
	Stephen Hemminger <>,,,
	Jan-Bernd Themann <>
Subject: Re: [PATCH RFC v2] net: add PCINet driver
Date: Tue, 4 Nov 2008 14:29:27 -0800	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, Nov 04, 2008 at 09:23:03PM +0100, Arnd Bergmann wrote:

Big snip.

> > 
> > I tried to make the locking do only what was needed. I just couldn't get
> > it correct unless I used spin_lock_irqsave(). I was able to get the
> > system to deadlock otherwise. This is why I posted the driver for
> > review, I could use some help here.
> > 
> > It isn't critical anyway. You can always use spin_lock_irqsave(), it is
> > just a little slower, but it will always work :)
> I like the documenting character of the spinlock functions. E.g. if you
> use spin_lock_irq() in a function, it is obvious that interrupts are enabled,
> and if you use spin_lock() on a lock that requires disabling interrupts,
> you know that interrupts are already off.

Ok, I've started addressing your comments. I'm having trouble with the
locking again. Let me see if my understanding is correct:

spin_lock_irqsave() disables interrupts and saves the interrupt state
spin_unlock_irqrestore() MAY re-enable interrupts based on the saved

spin_lock_irq() disables interrupts, and always turns them back on when
spin_unlock_irq() is called

spin_lock_bh() disables softirqs, spin_unlock_bh() re-enables them

spin_lock() and spin_unlock() are just regular spinlocks

So, since interrupts are disabled while my interrupt handler is running,
I think I should be able to use spin_lock() and spin_unlock(), correct?

But sparse gives me the following warning:
wqt.c:185:9: warning: context imbalance in 'wqt_interrupt': wrong count at exit
wqt.c:185:9:    context 'lock': wanted 0, got 1

If I'm using spin_lock_irqsave() and spin_lock_irqrestore() I do not get
the same warnings. Therefore I must have some misunderstanding :)


  parent reply	other threads:[~2008-11-04 22:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-29 20:20 Ira Snyder
2008-10-29 20:25 ` Stephen Hemminger
2008-10-29 20:50   ` Ira Snyder
2008-10-29 20:54     ` Scott Wood
2008-10-29 21:13       ` Ira Snyder
2008-10-29 21:43         ` Matt Sealey
2008-10-29 22:22           ` Ira Snyder
2008-11-04 12:09 ` Arnd Bergmann
2008-11-04 17:34   ` Ira Snyder
2008-11-04 20:23     ` Arnd Bergmann
2008-11-04 21:25       ` Ira Snyder
2008-11-05 13:50         ` Arnd Bergmann
2008-11-05 19:32           ` Ira Snyder
2008-11-04 22:29       ` Ira Snyder [this message]
2008-11-05 13:19         ` Arnd Bergmann
2008-11-05 19:18           ` Ira Snyder

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH RFC v2] net: add PCINet driver' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).