public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Eric Piel <eric.piel@tremplin-utc.net>
Cc: linux-kernel@vger.kernel.org, pavel@suse.cz,
	burman.yan@gmail.com, pau@eslack.org
Subject: Re: [PATCH] LIS3LV02Dx Accelerometer driver (take 4)
Date: Tue, 21 Oct 2008 15:21:42 -0700	[thread overview]
Message-ID: <20081021152142.9a535e0e.akpm@linux-foundation.org> (raw)
In-Reply-To: <48FE5416.9070402@tremplin-utc.net>

On Wed, 22 Oct 2008 00:13:42 +0200
Eric Piel <eric.piel@tremplin-utc.net> wrote:

> Andrew Morton schreef:
> >> +static void lis3lv02d_poweroff_timeout(unsigned long data)
> >> +{
> >> +	struct acpi_lis3lv02d *dev = (void *)data;
> >> +
> >> +	up(&dev->poff_sem);
> >> +	lis3lv02d_poweroff(dev->device->handle);
> >> +	down(&dev->poff_sem);
> > 
> > eek, no, we cannot down a semaphore from a timer handler!  It will lead
> > to might_sleep() warnings, scheduling-in-atomic warnings and kernel
> > deadlocks.
> Ooh... What happened is that I wrote the other functions first. They
> indirectly use acpi_evaluate_integer(), which can sleep. So I avoided
> spin_locks, and decided to use a semaphore. But now there is a semaphore
> in a timer (which is not allowed to sleep).
> 
> It seems the semaphore usage is compulsory due to acpi, so I'm planning
> to change the timer into a scheduled work on a workqueue (with
> queue_delayed_work(),  and cancel_delayed_work_sync()). This workqueue
> could be the same as the one for the joystick input. Does that look the
> right way to do it?

yep, that's generally a safe transformation.

You might also be able to use keventd, via scheule_delayed_work().

  reply	other threads:[~2008-10-21 22:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-18 19:05 [PATCH] LIS3LV02Dx Accelerometer driver (take 4) Eric Piel
2008-10-19 16:34 ` Jonathan Cameron
2008-10-19 23:07   ` Eric Piel
2008-10-20 13:32     ` Jonathan Cameron
2008-10-21  8:38 ` Pavel Machek
2008-10-21 18:42   ` Andrew Morton
2008-10-22 10:27     ` Pavel Machek
2008-10-22 11:34       ` Eric Piel
2008-10-22 11:58         ` Pavel Machek
2008-10-21 18:41 ` Andrew Morton
2008-10-21 18:53   ` Randy Dunlap
2008-10-21 20:48     ` Eric Piel
2008-10-21 22:13   ` Eric Piel
2008-10-21 22:21     ` Andrew Morton [this message]
2008-10-22 15:20 ` Pavel Machek
2008-10-22 18:51   ` Len Brown
2008-10-23  8:11     ` Eric Piel
2008-10-23  8:24       ` Pavel Machek

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=20081021152142.9a535e0e.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=burman.yan@gmail.com \
    --cc=eric.piel@tremplin-utc.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pau@eslack.org \
    --cc=pavel@suse.cz \
    /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