From: Ingo Oeser <ioe-lkml@rameria.de>
To: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Cc: Alan <alan@lxorguk.ukuu.org.uk>,
Christoph Hellwig <hch@infradead.org>,
Arjan van de Ven <arjan@infradead.org>,
mingo@redhat.com, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [patch 0/2] semaphores: add down_interruptible_timeout() and asm-generic/semaphore.h
Date: Tue, 27 Feb 2007 21:45:26 +0100 [thread overview]
Message-ID: <200702272145.28803.ioe-lkml@rameria.de> (raw)
In-Reply-To: <200702261757.11968.inaky@linux.intel.com>
Hi Inaky,
On Tuesday, 27. February 2007, Inaky Perez-Gonzalez wrote:
> On Monday 26 February 2007 18:18, Alan wrote:
> > > Yeah, I need semaphore. This is a hw register that says when the hw
> > > is ready to accept a new command. Code that wants to send commands has
> > > to down the semaphore and then send it. When hw is ready to get a new
> > > command, it sends and IRQ and the IRQ up()s the semaphore.
> >
> > So you need a mutex not a semaphore
>
> Theoretically I could use a mutex. Practically it would trigger ugly
> complications. Only the owner can unlock a mutex (for example), so
> I could not unlock from an IRQ handler -- not to mention that the
> semantic rules outlined in Documentation/mutex-design.txt explicitly
> forbid IRQ usage.
>
> And then, this is what semaphores where designed for, as gates :)
> for once that I get to use a semaphore properly...
But they are not required for that :-)
I would suggest to use an irq-safe spinlock for the hardware access
and a status indicator (ready for command), if this is really just a command register.
If the status indicator is updated (in IRQ) and read under spinlock, that is safe.
If that command sending is speed critical, please try a FIFO and batch that stuff.
Timeout based locking mechanisms are flawed, because they introduce the hard to find
timing sensitive bugs.
Please try sth. different (e.g. like suggested above).
Semaphores aren't good "busy/ready flags", as you might have already noticed.
Many Thanks and Best Regards
Ingo Oeser, the down{_interruptible,}_timeout() implementation of Linux :-)
next prev parent reply other threads:[~2007-02-27 20:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-27 0:13 inaky
2007-02-27 0:13 ` [patch 1/2] semaphores: Add down_interruptible_timeout() inaky
2007-02-27 0:13 ` [patch 2/2] semaphores: all arches use include/asm-generic/semaphore.h inaky
2007-02-27 0:33 ` [patch 0/2] semaphores: add down_interruptible_timeout() and asm-generic/semaphore.h Christoph Hellwig
2007-02-27 0:54 ` Inaky Perez-Gonzalez
2007-02-27 2:18 ` Alan
2007-02-27 1:57 ` Inaky Perez-Gonzalez
2007-02-27 20:45 ` Ingo Oeser [this message]
2007-03-03 1:17 ` Inaky Perez-Gonzalez
2007-02-27 20:24 ` Andrew Morton
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=200702272145.28803.ioe-lkml@rameria.de \
--to=ioe-lkml@rameria.de \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arjan@infradead.org \
--cc=hch@infradead.org \
--cc=inaky@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
/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
all inboxes | Powered by JetHome®