From: Eugene Surovegin <ebs@ebshome.net>
To: David Hawkins <dwh@ovro.caltech.edu>
Cc: linuxppc-embedded@ozlabs.org
Subject: Re: Yosemite/440EP is there a global interrupt enable mask?
Date: Wed, 25 Jan 2006 12:13:20 -0800 [thread overview]
Message-ID: <20060125201320.GB19460@gate.ebshome.net> (raw)
In-Reply-To: <43D7D5A1.70704@ovro.caltech.edu>
On Wed, Jan 25, 2006 at 11:46:41AM -0800, David Hawkins wrote:
> Hi Eugene,
>
> >>Now while looking at some of the other drivers, I noticed the use
> >>of the following syntax:
> >>
> >> unsigned long flags;
> >> local_irq_save(flags);
> >>
> >> ... mfdcr, mtdcr, etc operations ...
> >>
> >> local_irq_restore(flags);
> >>
> >>which is treating the operations on the DCRs as a critical section.
> >>
> >>I should probably be doing the same when I enable the external IRQs
> >>and modify the GPIO registers.
> >
> >You have to use locks if you access GPIO registers, because other bits
> >can be used by other device drivers, although there is no drivers in
> >the official tree which use GPIO (I have tons of them in my private
> >tree and I added global "gpio_lock" to serialize GPIO access).
>
> What kind of global lock; a spinlock?
yes, spinlock.
> What is the advantage of say using the gpio_lock, rather than
> the irq_save/restore sequence above - which is what is used in
> the emac and usb code?
emac doesn't use GPIO registers :). Also, if there is no IRQ code
accesses GPIO registers, you don't need IRQ disabling lock, and
spin_lock effectively becomes just a preemption lock. Personally, I use
spinlocks just out of habit, I think it's a good style, even if you
know your chip doesn't support SMP (but some day might :).
> >DCRs are a little different, there are separate DCR for different
> >peripherals, so generally, you don't have to use locks, because those
> >DCR accesses are implicitly bound to particular device anyway and
> >device "owns" them.
>
> Right, but I was accessing the DCR for the UIC status register,
> which, I assume, is also used by the Linux IRQ handling subsystem.
DO NOT access UIC registers directly. DO NOT.
> Well, ok perhaps that is not a good example, I have not tested
> whether the IRQ handler in the example code I posted needs to
> clear the UIC1_SR bit, or whether the Linux IRQ handling code
> already takes care of it. I suspect the latter, since the IRQ
> could be shared, and Linux needs to go through and call all
> handlers on that IRQ line.
>
> But in a debug context of reading those registers, I would
> expect some form of lock holding would be recommended.
> Do you happen to know if the Linux IRQ handling code uses a
> lock?
4xx IRQ code takes care of all this. You don't need to mess with UIC
registers. 4xx PIC code doesn't use locks because it's being called
from special context (IRQs disabled), 4xx doesn't support SMP and PIC
code "owns" those DCRs.
> I'm just learning, so feel free to enlighten me.
>
> What drivers do you have in your 'private' tree that you might
> be willing to share?
Nothing that can be of interest for a general public. They are
board-specific (lots of bit-banging SPI stuff). All other drivers I
wrote are already in public tree.
--
Eugene
next prev parent reply other threads:[~2006-01-25 20:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-17 0:45 [Patch 3/3] Add Yellowstone Platform defconfig John Otken
2006-01-24 18:08 ` Yosemite/440EP why are readl()/ioread32() setup to read little-endian? David Hawkins
2006-01-24 19:07 ` Yosemite/440EP is there a global interrupt enable mask? David Hawkins
2006-01-25 10:28 ` Stefan Roese
2006-01-25 18:30 ` David Hawkins
2006-01-25 18:55 ` Eugene Surovegin
2006-01-25 19:46 ` David Hawkins
2006-01-25 20:13 ` Eugene Surovegin [this message]
2006-01-25 20:34 ` David Hawkins
2006-01-25 9:57 ` Yosemite/440EP why are readl()/ioread32() setup to read little-endian? Stefan Roese
2006-01-25 18:26 ` David Hawkins
2006-01-25 18:51 ` Eugene Surovegin
2006-01-25 19:36 ` David Hawkins
2006-01-25 19:48 ` Eugene Surovegin
2006-01-26 10:20 ` Stefan Roese
2006-01-27 0:10 ` David Hawkins
2006-01-27 23:29 ` David Hawkins
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=20060125201320.GB19460@gate.ebshome.net \
--to=ebs@ebshome.net \
--cc=dwh@ovro.caltech.edu \
--cc=linuxppc-embedded@ozlabs.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).