Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763764AbYBTWY0 (ORCPT ); Wed, 20 Feb 2008 17:24:26 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751190AbYBTWYR (ORCPT ); Wed, 20 Feb 2008 17:24:17 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:43730 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751030AbYBTWYQ (ORCPT ); Wed, 20 Feb 2008 17:24:16 -0500 Date: Wed, 20 Feb 2008 17:24:15 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Rafael J. Wysocki" cc: Pierre Ossman , Zdenek Kabelac , Kernel development list Subject: Re: [Bug 10030] Suspend doesn't work when SD card is inserted In-Reply-To: <200802202315.49032.rjw@sisk.pl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1457 Lines: 52 On Wed, 20 Feb 2008, Rafael J. Wysocki wrote: > Well, below is an uncompiled and untested but illustrating the idea that > might allow people not to bother with device_pm_schedule_removal() > explicitly and can fix the issue at hand. > > [There are some cases that need handling and are not covered here.] > > Please have a look. > > Thanks, > Rafael > +static struct task_struct *suspending_task; > +static DEFINE_MUTEX(suspending_task_mtx); I suspect you don't really need this mutex. > +bool in_suspend_context(void) > +{ > + bool result; > + > + mutex_lock(&suspending_task_mtx); > + result = (suspending_task == current); > + mutex_unlock(&suspending_task_mtx); > + return result; > +} If suspending_task == current then you are guaranteed to be serialized, because everything a single task does is serial. > @@ -1162,7 +1162,10 @@ void device_destroy(struct class *class, > dev = class_find_device(class, &devt, __match_devt); > if (dev) { > put_device(dev); > - device_unregister(dev); > + if (in_suspend_context()) > + device_pm_schedule_removal(dev); > + else > + device_unregister(dev); > } > } But what about device_del()? Can a similar change be made there? Alan Stern -- 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/