From patchwork Fri Dec 29 11:37:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10137003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E9BC96037D for ; Fri, 29 Dec 2017 11:37:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8DDE2DF14 for ; Fri, 29 Dec 2017 11:37:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE15A2DF17; Fri, 29 Dec 2017 11:37:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 821DD2DF14 for ; Fri, 29 Dec 2017 11:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755567AbdL2LhV (ORCPT ); Fri, 29 Dec 2017 06:37:21 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:37306 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755564AbdL2LhU (ORCPT ); Fri, 29 Dec 2017 06:37:20 -0500 Received: by mail-lf0-f65.google.com with SMTP id f3so11720598lfe.4 for ; Fri, 29 Dec 2017 03:37:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oW3rET3KLR2qx3Z+Qyo47ErWsC0L9XLCU7bkqm0PBv0=; b=EBJk72+ipL/Z/EOn/tiROsKxaFJwmuojXo+hQ+vtLcftA6T9CAplI3IzrwPfvToRt9 uB2MFbgei73ZPlC6uuhMdmHgM8QE0gsCk8Cj6NP2zCRkvomc+wfHo45LfaEPpkdJQM8I 7QW6bzSolV/1gphQWAuIw07G2calo8q3FnoLY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oW3rET3KLR2qx3Z+Qyo47ErWsC0L9XLCU7bkqm0PBv0=; b=K+goMmgDFCtHazFUFja5E0Kwfhd8kJRlHwJdtTaKzc7hwLtRKEEQjxBRDKLCJsabif EXypaJDKIqjTK9fgqVDiN5ECfNipZgCAUI3sqtOBiZaCEPxwEMaNINCec2uzwIWvx+wd WrwZefJB4twCWEI4Y6CzTq4bRiXRHZxKSwrD+tk3+PeIXxUhNIVxsrXD7IVatt+M0bxl e7HVAWxYyD9tFBTtQ3oLmR4LUz/kzCXPauNAm1qVzbJG1gfONL5RASrxOssVp9YuKRH2 4J+SwmSxaeVxKgRP1oqfsK+/YSQc7KquzCr/nLVbEF96C0kiuXzzh9kwng9rX4sqMyuf X/Tw== X-Gm-Message-State: AKGB3mJNnj5FwqOzyFgWrrUIarHC0LqRRks2jypl3+89zKCdOoRGemkI 6yP4kIa3rfD6bYfMOnLxjv3LNA== X-Google-Smtp-Source: ACJfBos8XqndgB6w6r0c3xPQ+z0z52+qRe4uRK50XcM5HaeCuolDo2YjEX4DYZP8rfHFZQCoBlRUJQ== X-Received: by 10.46.21.87 with SMTP id 23mr19867373ljv.107.1514547438860; Fri, 29 Dec 2017 03:37:18 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id r74sm7280469ljb.28.2017.12.29.03.37.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 03:37:18 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Kevin Hilman , Viresh Kumar , Geert Uytterhoeven , Simon Horman , Niklas Soderlund , Vincent Guittot , linux-renesas-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 1/4] PM / core: Assign the wakeup_path status flag in __device_prepare() Date: Fri, 29 Dec 2017 12:37:00 +0100 Message-Id: <1514547423-18965-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514547423-18965-1-git-send-email-ulf.hansson@linaro.org> References: <1514547423-18965-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The PM core in the device_prepare() phase, resets the wakeup_path status flag to the value of device_may_wakeup(). This means if a ->prepare() or a ->suspend() callback for the device would update the device's wakeup setting, this doesn't become reflected in the wakeup_path status flag. In general this isn't a problem, because wakeup settings are not supposed to be changed (via for example calling device_set_wakeup_enable()) during any system wide suspend/resume phase. Nevertheless there are some users, which can be considered as legacy, that don't conform to this behaviour. These legacy cases should be corrected, however until that is done, let's address the issue from the PM core, by moving the assignment of the wakeup_path status flag to the __device_suspend() phase and after the ->suspend() callback has been invoked. Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 6e8cc5d..810e5fb 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1620,6 +1620,8 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) End: if (!error) { dev->power.is_suspended = true; + if (device_may_wakeup(dev)) + dev->power.wakeup_path = true; dpm_propagate_to_parent(dev); dpm_clear_suppliers_direct_complete(dev); } @@ -1744,7 +1746,7 @@ static int device_prepare(struct device *dev, pm_message_t state) device_lock(dev); - dev->power.wakeup_path = device_may_wakeup(dev); + dev->power.wakeup_path = false; if (dev->power.no_pm_callbacks) { ret = 1; /* Let device go direct_complete */