From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: [RFC][PATCH 2/3] PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily Date: Tue, 13 May 2014 17:43:55 +0200 Message-ID: <1652919.R3bbdKUH5p@vostro.rjw.lan> References: Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7Bit Return-path: Received: from v094114.home.net.pl ([79.96.170.134]:59519 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753266AbaEMP1J (ORCPT ); Tue, 13 May 2014 11:27:09 -0400 In-Reply-To: Sender: linux-acpi-owner@vger.kernel.org List-Id: linux-acpi@vger.kernel.org To: Alan Stern Cc: Linux PM list , ACPI Devel Maling List , Aaron Lu , Mika Westerberg , Linux Kernel Mailing List , Kevin Hilman , Ulf Hansson On Tuesday, May 13, 2014 11:12:28 AM Alan Stern wrote: > On Tue, 13 May 2014, Rafael J. Wysocki wrote: > > > > > + dev->power.direct_complete = ret > 0 && state.event == PM_EVENT_SUSPEND > > > > + && pm_runtime_suspended(dev); > > > > > > Shouldn't the flag be set under the spinlock? > > > > I guess you're worried about runtime PM flags being modified in parallel to > > this? But we've just done the barrier a while ago, so is that still a concern > > here? > > A wakeup request from the hardware could cause a runtime resume to > occur at this time. The barrier wouldn't prevent that. > > It's unlikely, I agree, but not impossible. Yeah, I didn't think about that. But that also can occur in __device_suspend(), after we've checked the flag and decided not to invoke the ->suspend() callback, right? So moving the check in there doesn't help much I'd say. It closes the race window, but that's it. That means that the whole approach based on ->prepare() is problematic unless we somehow mix it with disabling runtime PM. Rafael