From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754919AbdKKAlz (ORCPT ); Fri, 10 Nov 2017 19:41:55 -0500 Received: from mail-ot0-f194.google.com ([74.125.82.194]:46674 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754524AbdKKAlw (ORCPT ); Fri, 10 Nov 2017 19:41:52 -0500 X-Google-Smtp-Source: AGs4zMZbsOo3GIBwODNt6/9ER1zWmRnWSTJJmdY4CCkWleo5CAN74RtO80pZ+nAVdMx9EoxMetLhpB6OEn/PfJMsL8Y= MIME-Version: 1.0 In-Reply-To: References: <3806130.B2KCK0tvef@aspire.rjw.lan> <16592954.7Zo1mAdIIH@aspire.rjw.lan> <6330680.LdxjlP4uri@aspire.rjw.lan> <2932219.eEdIVn6WWf@aspire.rjw.lan> From: "Rafael J. Wysocki" Date: Sat, 11 Nov 2017 01:41:51 +0100 X-Google-Sender-Auth: KjzHVpINZc-D76QMa1W3jlr_kc8 Message-ID: Subject: Re: [PATCH v2 1/6] PM / core: Add LEAVE_SUSPENDED driver flag To: "Rafael J. Wysocki" Cc: Ulf Hansson , "Rafael J. Wysocki" , Linux PM , Bjorn Helgaas , Alan Stern , Greg Kroah-Hartman , LKML , Linux ACPI , Linux PCI , Linux Documentation , Mika Westerberg , Andy Shevchenko , Kevin Hilman Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 11, 2017 at 12:45 AM, Rafael J. Wysocki wrote: > On Fri, Nov 10, 2017 at 10:09 AM, Ulf Hansson wrote: >> On 8 November 2017 at 14:25, Rafael J. Wysocki wrote: >>> From: Rafael J. Wysocki >>> >>> Define and document a new driver flag, DPM_FLAG_LEAVE_SUSPENDED, to >>> instruct the PM core and middle-layer (bus type, PM domain, etc.) >>> code that it is desirable to leave the device in runtime suspend >>> after system-wide transitions to the working state (for example, >>> the device may be slow to resume and it may be better to avoid >>> resuming it right away). >>> >>> Generally, the middle-layer code involved in the handling of the >>> device is expected to indicate to the PM core whether or not the >>> device may be left in suspend with the help of the device's >>> power.may_skip_resume status bit. That has to happen in the "noirq" >>> phase of the preceding system suspend (or analogous) transition. >>> The middle layer is then responsible for handling the device as >>> appropriate in its "noirq" resume callback which is executed >>> regardless of whether or not the device may be left suspended, but >>> the other resume callbacks (except for ->complete) will be skipped >>> automatically by the core if the device really can be left in >>> suspend. >> >> I don't understand the reason to why you need to skip invoking resume >> callbacks to achieve this behavior, could you elaborate on that? > > The reason why it is done this way is because that takes less code and > is easier (or at least less error-prone, because it avoids repeating > patterns in middle layers). Actually, it also is a matter of correctness, at least to some extent. Namely, if the parent or any supplier of the device has power.must_resume clear in dpm_noirq_resume_devices(), then the device should not be touched during the whole system resume transition (because the access may very well go through the suspended parent or supplier) and the most straightforward way to make that happen is to avoid running the code that may touch the device. [Arguably, if middle layers were made responsible for handling that, they would need to do pretty much the same thing and so there is no reason for not doing it in the core.] Allowing the "noirq" callback from middle layers to run in that case is a stretch already, but since genpd needs that, well, tough nuggets. All of that said, if there is a middle layer wanting to set power.skip_resume and needing to do something different for the resume callbacks, then this piece can be moved from the core to the middle layers at any time later. So far there's none, though. At least not in this patch series. Thanks, Rafael