All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Cc: hch@infradead.org, arjan@infradead.org, mingo@redhat.com,
	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 12:24:46 -0800	[thread overview]
Message-ID: <20070227122446.8c64f3e7.akpm@linux-foundation.org> (raw)
In-Reply-To: <200702261654.18005.inaky@linux.intel.com>

> On Mon, 26 Feb 2007 16:54:17 -0800 Inaky Perez-Gonzalez <inaky@linux.intel.com> wrote:
> On Monday 26 February 2007 16:33, Christoph Hellwig wrote:
> > On Mon, Feb 26, 2007 at 04:13:38PM -0800, inaky@linux.intel.com wrote:
> > > Introduce down_interruptible_timeout() using timers to make the waiter
> > > stop waiting by simulating a signal (see first patch for more
> > > details). As well introduce asm-generic/semaphore.h and make other
> > > architectures use it too.
> >
> > What do you want this for?  Do you really need a full counting semaphore
> > or do you actually want a mutex?
> 
> 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. 
> 
> Now, we don't want to hang on that down() forever if the hw spaces out.
> If we get a timeout, we can try recovery actions (like resetting it,
> for sake of being polite). 
>

This is a very common pattern - for example, shoving characters down a uart
or a parport.  Nobody else has needed to invent new locking infrastructure
to do such things and I'd prefer not to do so now.

Can you not do things more conventionally within that driver?  Use
waitqueues for sleeping with timeout, use a spinlock for serialisation
against the device registers.  There are squillions of examples in
drivers/*, surely.

      parent reply	other threads:[~2007-02-27 20:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-27  0:13 [patch 0/2] semaphores: add down_interruptible_timeout() and asm-generic/semaphore.h 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
2007-03-03  1:17           ` Inaky Perez-Gonzalez
2007-02-27 20:24     ` Andrew Morton [this message]

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=20070227122446.8c64f3e7.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --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 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.