Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758115AbYAGVcY (ORCPT ); Mon, 7 Jan 2008 16:32:24 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754132AbYAGVcP (ORCPT ); Mon, 7 Jan 2008 16:32:15 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:40030 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753078AbYAGVcO (ORCPT ); Mon, 7 Jan 2008 16:32:14 -0500 Date: Mon, 7 Jan 2008 16:32:13 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Rafael J. Wysocki" cc: Johannes Berg , Greg KH , Andrew Morton , Len Brown , Ingo Molnar , ACPI Devel Maling List , LKML , pm list Subject: Re: [PATCH] PM: Acquire device locks on suspend In-Reply-To: <200801072137.43401.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: 1879 Lines: 45 On Mon, 7 Jan 2008, Rafael J. Wysocki wrote: > > > Do you mean it might have been released already by another thread > > > calling device_pm_destroy_suspended() on the same device? > > > > I was thinking that it might be called before lock_all_devices(). > > I've added pm_sleep_start_end_mtx and the locking dance in > device_pm_destroy_suspended() specifically to prevent this from happening. Yes, I see. What about the fact that device_suspend() locks pm_sleep_start_end_mtx first and pm_sleep_rwsem second, whereas device_pm_destroy_suspended() locks pm_sleep_start_end_mtx while holding pm_sleep_rwsem? That should produce a lockdep warning. > > However let's ignore that possibility and simplify the discussion by > > assuming that destroy_suspended_device() is never called except by a > > suspend or resume method for that device or one of its ancestors. > > It may also be called by one of the CPU hotplug notifiers. This suggests another approach, simpler but not as general. So far all the problems we've seen have been associated with those CPU notifiers. Suppose the notifications about CPUs that failed to come back up were delayed until after the resume was complete? Drivers like msr would then have to check in their resume handler whether the CPU was actually up, but no other changes would be needed. In this way we could fix the immediate problem. It wouldn't help with other sorts of devices that need to be unregistered during a suspend, though. > Okay, well, now I'm leaning towards the asynchronous approach. > > I'll prepare a new patch and send it later today. Okay. 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/