From patchwork Tue Jan 9 09:03:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 123814 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3776244qgn; Tue, 9 Jan 2018 01:03:47 -0800 (PST) X-Received: by 10.25.20.168 with SMTP id 40mr2280954lfu.23.1515488627241; Tue, 09 Jan 2018 01:03:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515488627; cv=none; d=google.com; s=arc-20160816; b=HKCbJyAulh7jAXJu2eTteeY3zkZSrAhiZw1uOddzfYTixbXVbHD7A3zrKGr4jo6DwL D1O6igPXUeOAMExXUgQ75dIxf+8+8hGn6SOUeeZkmuvV9kGXrc7GGi4bAmoceDeolJ6s K43MFHuRNgQrc+wFOZbaJ0NDTodTzU6bd7Mz8/NE3MnH5fEB73mKVKe+5L4fvJMl+sHP OGxegOUz9rD9OLeXyK/XLukM4Imy6+ZFxOZjnmYFUoMpcI++fSa5087Rr9enw3pZks3a SNAuq+mz2fNNnGs9fmMRuG6yB5EpbTZ2PsklU4wZdpnzlQBsQlV0KF/rr8MBFEefyzFU enQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=aJuRAQa+4CeAaJhJ4zdvpuQfIkXpH6dapqumDg+HpVk=; b=xwmz1e3rnxGxGR0FIKQ6+ZetFe5qzBqZ3aYxLS7BDN24GLYxum2cSVxvyVRXyRjoye R4k7Rx9ENWdaTRSqLcAfH2m9A/bT8NDJ/JJ5Z3KZhC9+OedTyznbMOefJEajK885ToAe xwrIIb8MXjHYdfHz4+1s2M+15kMvXOW5sBfYf7rpzhttZMFaRiJuyvZfguJB2D9oDBUG k1+NymOvhpNiqQuWOvlzw9iEoLKZ2EE32WyqJRXu41HWL0okxPPgZEOkgZ+VBExN3vQN 0DbPTI6kGPbO6UxsN0i7SzRcN3kqR9//Gp5R8F26awVE3QYI+7DlvI9WW77jgvefaEeu 2siQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j+Ifu/J2; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r16sor2239583lje.14.2018.01.09.01.03.47 for (Google Transport Security); Tue, 09 Jan 2018 01:03:47 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j+Ifu/J2; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=aJuRAQa+4CeAaJhJ4zdvpuQfIkXpH6dapqumDg+HpVk=; b=j+Ifu/J2Ruds+Q/v81HqbTvBExj8G5l//T5Us4mzmSsfmQLWDVj7tByhJz+K9RATEV jH0eiiICn44BPNw69lxCrE0DG1X0/u8JWLdpQtO+BmP8004CZEigiTR++Ugpn50Lax5k eWApdlx12vwPl0nnoq6V/ryZko1SFEtOJnS14= 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=aJuRAQa+4CeAaJhJ4zdvpuQfIkXpH6dapqumDg+HpVk=; b=jmueQa8JSWk7fZi9D/uC07MjpQSGCAXvQJqNyGeqtqI7mHxhgtPT0H5zHU6ZUETDyd zpIE9q8QjKrW1ZxzhK+9xoPahfdQefTkVk/PDbAoXG9eh1vq7SyKUdatlheYrdTa3Ep8 m2EcV3gKPClmBO8WTCuqxE8fo4ctGZA9kbIO0OuXoY+LBcSItM7fkSZ7ZiqvyF6z03A0 9+GtgFify4G4ManRg0jRcCG8IwqXmoSyoyzpKU0rogReUSksJ/WAIool8S1TUWWODC9/ dm9jjb4KyRwe61ga5+w4OgUNVwHVf+qIBH2hyxygi1HbJfymxzg3WkZ/l1flzu4cmK39 IZJw== X-Gm-Message-State: AKGB3mLiCLhsDl7xTZeYLDI4CsfVZNIz/VyUqLLyGnbpoJL6gfqoqpyN W2YyqRSdKXVs8dW8yZ9TNz6v9x5V X-Google-Smtp-Source: ACJfBouNLbcT50pDNS23Uvc1yeTXB/McRAaJQj2sycx+g2DsYNo5uO0gcH0OkxvmtQYsvRDYmp+TCA== X-Received: by 10.46.29.23 with SMTP id d23mr8314861ljd.114.1515488626913; Tue, 09 Jan 2018 01:03:46 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id f78sm2745355lje.20.2018.01.09.01.03.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 01:03:46 -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 v4 1/2] PM / core: Re-structure code for clearing the direct_complete flag Date: Tue, 9 Jan 2018 10:03:39 +0100 Message-Id: <1515488620-10575-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515488620-10575-1-git-send-email-ulf.hansson@linaro.org> References: <1515488620-10575-1-git-send-email-ulf.hansson@linaro.org> To make the code more consistent, let's clear the parent's direct_complete flag along with clearing it for suppliers, instead of as currently, when propagating the wakeup_path flag to parents. While changing this, let's take the opportunity to rename the affected internal functions, to make them self-explanatory. Like this: dpm_clear_suppliers_direct_complete -> dpm_clear_superiors_direct_complete dpm_propagate_to_parent -> dpm_propagate_wakeup_to_parent Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index ebcec7e..720e36e 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1660,7 +1660,7 @@ static int legacy_suspend(struct device *dev, pm_message_t state, return error; } -static void dpm_propagate_to_parent(struct device *dev) +static void dpm_propagate_wakeup_to_parent(struct device *dev) { struct device *parent = dev->parent; @@ -1669,18 +1669,23 @@ static void dpm_propagate_to_parent(struct device *dev) spin_lock_irq(&parent->power.lock); - parent->power.direct_complete = false; if (dev->power.wakeup_path && !parent->power.ignore_children) parent->power.wakeup_path = true; spin_unlock_irq(&parent->power.lock); } -static void dpm_clear_suppliers_direct_complete(struct device *dev) +static void dpm_clear_superiors_direct_complete(struct device *dev) { struct device_link *link; int idx; + if (dev->parent) { + spin_lock_irq(&dev->parent->power.lock); + dev->parent->power.direct_complete = false; + spin_unlock_irq(&dev->parent->power.lock); + } + idx = device_links_read_lock(); list_for_each_entry_rcu(link, &dev->links.suppliers, c_node) { @@ -1791,8 +1796,8 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) if (device_may_wakeup(dev)) dev->power.wakeup_path = true; - dpm_propagate_to_parent(dev); - dpm_clear_suppliers_direct_complete(dev); + dpm_propagate_wakeup_to_parent(dev); + dpm_clear_superiors_direct_complete(dev); } device_unlock(dev); From patchwork Tue Jan 9 09:03:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 123815 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3776267qgn; Tue, 9 Jan 2018 01:03:48 -0800 (PST) X-Received: by 10.25.44.206 with SMTP id s197mr6542941lfs.15.1515488628599; Tue, 09 Jan 2018 01:03:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515488628; cv=none; d=google.com; s=arc-20160816; b=x4/rt+54+FoTj2vpevE+Rkj8HxjbmEs1xn5HF/YMYSRnVFFwq2H526azk+0uZ1ekwf 3Nv2zIlWcM1SrxsiMDG5WZHv5dSOrv3CR0aIpFgUuxy3tQYbfLpYiBmFFWEPpHd2dKN1 Vf3XajXpgqRcZ7oAKojE+DX5w25xZ0DR7Dbx2k1s5B3Q2pi56BTQ34WylNaySEyZY+m1 4OKYA8oPotlJR0m3xiD6Xdxac4yCNJfAHzi5BEDpYtv8ZhpZdTCwAYt4h0AQ486jYsKj tjNMBJa7mcHpgEPEh9KjM1sKfuibBxEtYb/gpOvw5tX1cS0rgc5XMvv3S8QkGoMXGp3b 9M1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=tqdOjDJU2C1f2D9ygV/K9t84nXOxcCUjXW4linf6Gik=; b=zJ8okBDui+igxHcCZdQ/33canvfjUiW5rt1o/y/SNoafvzu6FIggl5EZwbMd4gJ/Ly TR2KWLeSHEjfKIde8u0dE+0TxOFHZRJxSAoWVVFBcRAHOMSUG+3ki96MZOnDbk+PbDBE pLwo5WuFUw8jRA36iecFig2ILjDuNMLH+lFcQbwV1o5b6QaDO+F+BeTbOEg+2eiOisng Ttfyh88oRKEaKwkYC/KGVufPKOt9plPHjTrAzIQd4r4f0vyp7MG/NwaTFV30QJwcJq9Y sqTETgU+PtBtdiZI69drswo1jyIuNhFetV4H0GJ3HMrnAyjQJ6t9nRwV9H0Ug0gdCPtu P4kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cRLyNc3v; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n71sor2311147lja.74.2018.01.09.01.03.48 for (Google Transport Security); Tue, 09 Jan 2018 01:03:48 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cRLyNc3v; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=tqdOjDJU2C1f2D9ygV/K9t84nXOxcCUjXW4linf6Gik=; b=cRLyNc3vCgqSjl59dsfJbPw2JrR0IE4obbGyMPLNKwyDSNQ6Ug8ZsEcfaadMvO/2eD l0Qusg6lwNsr2Dqx5uDMSg6w8OwT8Ny34e8MT/xaBerNBWoejCkNNwU5gsBzT9xAcVfx DtUQuhmodZyjIz/jO1QboX8uv22+CH+/ih5Og= 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=tqdOjDJU2C1f2D9ygV/K9t84nXOxcCUjXW4linf6Gik=; b=YR7xIoD/RJwvrr2dIqtPAy1c9DTvQbUk125iSTQ1OebjnFnxqhtVSagXBzeJABx8bC wXEgX2nVLyq0+/f1Yz8Lv0h/J152KgpB19u20QGisLLQOVRJcCq95L2GEYgiBzvHgqAq Gdj5jybSKAScm1J52R/HRQtM7iW628TjPRIBwf5M1hbz/L1f9krBnbNjhXPSOag7Awsr 2gmyuLvn2uLZa1kQvDzYbnA+smD9tvMx0DQFoOY7qWwmzJO8yC+BA3hcWPj4Tee5jW86 64aZLabSpiR96BZZL6hU3RHftTKdiEymOyeRflQ22SOdSjLVtjqraIv/mISMAyQ6d5ub jkeQ== X-Gm-Message-State: AKGB3mIMqbWTuGGC02pB2D4Rs1RAPfxSOzq+tNBT8t2Wt0DHtn6V2Bco TrQGQy/SK91En4TsaEwSIBp9NxFB X-Google-Smtp-Source: ACJfBovpAjvAAdXffBG+L+HsuSsx+kav+sGg+VLLAWWDe5FQ23Q4wwW4UbWI7horLKuYq5ph7Uq9qQ== X-Received: by 10.46.59.12 with SMTP id i12mr8227440lja.88.1515488628278; Tue, 09 Jan 2018 01:03:48 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id f78sm2745355lje.20.2018.01.09.01.03.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 01:03:47 -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 v4 2/2] PM / core: Propagate wakeup_path status flag in __device_suspend_late() Date: Tue, 9 Jan 2018 10:03:40 +0100 Message-Id: <1515488620-10575-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515488620-10575-1-git-send-email-ulf.hansson@linaro.org> References: <1515488620-10575-1-git-send-email-ulf.hansson@linaro.org> Currently the wakeup_path status flag becomes propagated from a child device to its parent device at __device_suspend(). This allows a driver dealing with a parent device to act on the flag from its ->suspend() callback. However, in situations when the wakeup_path status flag needs to be set from a ->suspend_late() callback, its value doesn't get propagated to the parent by the PM core. Let's address this limitation, by also propagating the flag at __device_suspend_late(). Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 720e36e..02a497e 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1447,6 +1447,21 @@ int dpm_suspend_noirq(pm_message_t state) return ret; } +static void dpm_propagate_wakeup_to_parent(struct device *dev) +{ + struct device *parent = dev->parent; + + if (!parent) + return; + + spin_lock_irq(&parent->power.lock); + + if (dev->power.wakeup_path && !parent->power.ignore_children) + parent->power.wakeup_path = true; + + spin_unlock_irq(&parent->power.lock); +} + static pm_callback_t dpm_subsys_suspend_late_cb(struct device *dev, pm_message_t state, const char **info_p) @@ -1527,6 +1542,7 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as async_error = error; goto Complete; } + dpm_propagate_wakeup_to_parent(dev); Skip: dev->power.is_late_suspended = true; @@ -1660,21 +1676,6 @@ static int legacy_suspend(struct device *dev, pm_message_t state, return error; } -static void dpm_propagate_wakeup_to_parent(struct device *dev) -{ - struct device *parent = dev->parent; - - if (!parent) - return; - - spin_lock_irq(&parent->power.lock); - - if (dev->power.wakeup_path && !parent->power.ignore_children) - parent->power.wakeup_path = true; - - spin_unlock_irq(&parent->power.lock); -} - static void dpm_clear_superiors_direct_complete(struct device *dev) { struct device_link *link;