• R
    PM: Document rules on using pm_runtime_resume() in system suspend callbacks · 104dc5e2
    Rafael J. Wysocki 提交于
    It quite often is necessary to resume devices from runtime suspend
    during system suspend for various reasons (for example, if their
    wakeup settings need to be changed), but that requires middle-layer
    or subsystem code to follow additional rules which currently are not
    clearly documented.
    
    Namely, if a driver calls pm_runtime_resume() for the device from
    its ->suspend (or equivalent) system sleep callback, that may not
    work if the middle layer above it has updated the state of the
    device from its ->prepare or ->suspend callbacks already in an
    incompatible way.  For this reason, all middle layers must follow
    the rule that, until the ->suspend callback provided by the device's
    driver is invoked, the only way in which the device's state can be
    updated is by calling pm_runtime_resume() for it, if necessary.
    Fortunately enough, all middle layers in the code base today follow
    this rule, but it is not explicitly stated anywhere, so do that.
    
    Note that calling pm_runtime_resume() from the ->suspend callback
    of a driver will cause the ->runtime_resume callback provided by the
    middle layer to be invoked, but the rule above guarantees that this
    callback will nest properly with the middle layer's ->suspend
    callback and it will play well with the ->prepare one invoked before.
    Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
    104dc5e2
devices.rst 39.3 KB