Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753807AbYJUWOB (ORCPT ); Tue, 21 Oct 2008 18:14:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751720AbYJUWNx (ORCPT ); Tue, 21 Oct 2008 18:13:53 -0400 Received: from mailservice.tudelft.nl ([130.161.131.5]:30700 "EHLO mailservice.tudelft.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751703AbYJUWNw (ORCPT ); Tue, 21 Oct 2008 18:13:52 -0400 X-Spam-Flag: NO X-Spam-Score: -9.389 Message-ID: <48FE5416.9070402@tremplin-utc.net> Date: Wed, 22 Oct 2008 00:13:42 +0200 From: Eric Piel User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.17) Gecko/20080929 Mandriva/2.0.0.17-2mdv2009.0 (2009.0) Thunderbird/2.0.0.17 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: Andrew Morton Cc: linux-kernel@vger.kernel.org, pavel@suse.cz, burman.yan@gmail.com, pau@eslack.org Subject: Re: [PATCH] LIS3LV02Dx Accelerometer driver (take 4) References: <48FA3368.1040605@tremplin-utc.net> <20081021114121.5144841c.akpm@linux-foundation.org> In-Reply-To: <20081021114121.5144841c.akpm@linux-foundation.org> Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1209 Lines: 29 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/