lkml.org 
[lkml]   [2008]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] LIS3LV02Dx Accelerometer driver (take 4)
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?

Eric


\
 
 \ /
  Last update: 2008-10-22 00:17    [W:0.144 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site