Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758331AbYAEUTF (ORCPT ); Sat, 5 Jan 2008 15:19:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758027AbYAEUSO (ORCPT ); Sat, 5 Jan 2008 15:18:14 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:57597 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757543AbYAEUSL (ORCPT ); Sat, 5 Jan 2008 15:18:11 -0500 From: "Rafael J. Wysocki" To: Alan Stern Subject: Re: [PATCH] PM: Acquire device locks on suspend Date: Sat, 5 Jan 2008 21:19:47 +0100 User-Agent: KMail/1.9.6 (enterprise 20070904.708012) Cc: Greg KH , Andrew Morton , Len Brown , Ingo Molnar , ACPI Devel Maling List , LKML , pm list References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801052119.48542.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2013 Lines: 59 On Saturday, 5 of January 2008, Alan Stern wrote: > On Sat, 5 Jan 2008, Rafael J. Wysocki wrote: > > > Greg, Andrew, > > > > The appended patch is a replacement for > > gregkh-driver-pm-acquire-device-locks-prior-to-suspending.patch that deadlocked > > suspend and hibernation on some systems. > > > > Please consider for applying. > > This warning message: > > > @@ -905,6 +915,13 @@ void device_del(struct device * dev) > > struct device * parent = dev->parent; > > struct class_interface *class_intf; > > > > + if (pm_sleep_lock()) { > > + dev_warn(dev, "Illegal %s during suspend\n", __FUNCTION__); > > + dump_stack(); > > + } else { > > will unavoidably be triggered by this code: Ah, my fault, sorry. > > +void device_pm_destroy_suspended(struct device *dev) > > +{ > > + pr_debug("PM: Removing suspended device %s:%s\n", > > + dev->bus ? dev->bus->name : "No Bus", > > + kobject_name(&dev->kobj)); > > + mutex_lock(&dpm_list_mtx); > > + list_del_init(&dev->power.entry); > > + mutex_unlock(&dpm_list_mtx); > > + up(&dev->sem); > > + device_unregister(dev); > > +} > > since the call to device_del() will occur while the pm_sleep_rwsem is > still locked for writing. That's why I suggested not unregistering > these devices until after everything else has been resumed and the > rwsem has been dropped. Hmm, well. I'll go back to the previous version, then. Sorry for the mess. > Another thing to watch out for: Just in case somebody ends up calling > destroy_suspended_device(dev) from within dev's own resume method, you > should interchange the resume_device() and the list_move_tail() > calls in dpm_resume(). However, if we unregister them all at once after releasing pm_sleep_rwsem, that shouldn't be necessary, right? Rafael -- 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/