From patchwork Tue Nov 17 14:35:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 56793 Delivered-To: patches@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1975822lbb; Tue, 17 Nov 2015 06:35:49 -0800 (PST) X-Received: by 10.25.64.5 with SMTP id n5mr1374265lfa.18.1447770949179; Tue, 17 Nov 2015 06:35:49 -0800 (PST) Return-Path: Received: from mail-lb0-x234.google.com (mail-lb0-x234.google.com. [2a00:1450:4010:c04::234]) by mx.google.com with ESMTPS id uf10si11719189lbc.83.2015.11.17.06.35.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2015 06:35:49 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c04::234 as permitted sender) client-ip=2a00:1450:4010:c04::234; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c04::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dkim=pass header.i=@linaro_org.20150623.gappssmtp.com Received: by lbbkw15 with SMTP id kw15so6702375lbb.0 for ; Tue, 17 Nov 2015 06:35:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VaZiCXDlTFFe5qz9e7aWsP6YO662zqzu+Z4bFGI7h5Y=; b=SP6pyu0a3gpIodeXHvfIsq1VO2hLnoXxktJ3Sr2sXIywy1rexPT+vgp+7F3G4MWSTv mw6w6wYwkV080qZbGsiNh2BF6kUV6RnPE7QJ3yMPHtmtU/cIetL4EPdnKNvBGvszIND6 kYnfJG2xXA7/VxDu7z9HKlMUrVosFFDEjtxwEAd+HRm8xBNUhyQrFObVTZ/1Ptri2Jm0 Ytjz04Tz1iuYSAYGXNZr9tcxGsssJxZjLhs8HPOnJUi7jtou9JbNAj8bmA6PjSidUXhv S2Ww+mwJxN1sOmU6zKLhAmeXZDDqBQlvfZrzbREdFCAd6avjaK0uTIihquBbFkGvx6fL J4oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VaZiCXDlTFFe5qz9e7aWsP6YO662zqzu+Z4bFGI7h5Y=; b=QOtAuo4vRfoWyeg9j0OS+SOR6tLCqlsHx1Crfs+wU9AY11nEzN1r8D8EDrVFQHJLnY etItsYut2QeUcl4DCGj0YiiWb+ATCaz6jMbv+uNTns9OXhUfqAkX69BS4c0yWU1pQ4T3 ixvob3k6JI/wifvsLYfgaYR9OrzgCkR/uw8WYpFes7deeyJxVJdJa4PxM3eebV8pFNFy vZB/X4P7zwEDjtCitEPg0fNGysinJqP/pr+KI0VEmAJciA9ruPp8TkIvqfV2uxNn0IXp UdIL6JscgxMjo68hexdAuSr810FtGxnAUZ4m4Pp42gOSwsXrnUozUwP6SXAgMvrvouaE zfrA== X-Gm-Message-State: ALoCoQmz80KUOyoOc3a9CRbJajqzDjZbUzeJw4QBI5A+TRLXem4GuPknsZyt5hdvmyiFB29qogsv X-Received: by 10.112.130.195 with SMTP id og3mr19464670lbb.69.1447770948957; Tue, 17 Nov 2015 06:35:48 -0800 (PST) Return-Path: Received: from localhost.localdomain (c-83-233-167-104.cust.bredband2.com. [83.233.167.104]) by smtp.gmail.com with ESMTPSA id i7sm6384436lbo.39.2015.11.17.06.35.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Nov 2015 06:35:48 -0800 (PST) From: Ulf Hansson To: "Rafael J. Wysocki" , Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: Alan Stern , Kevin Hilman , Len Brown , Pavel Machek , Geert Uytterhoeven , Kuninori Morimoto , Eduardo Valentin , Ulf Hansson Subject: [PATCH 1/2] PM / Runtime: Extend the scope for pm_runtime_remove() Date: Tue, 17 Nov 2015 15:35:28 +0100 Message-Id: <1447770929-16652-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447770929-16652-1-git-send-email-ulf.hansson@linaro.org> References: <1447770929-16652-1-git-send-email-ulf.hansson@linaro.org> There are additional execution paths besides the device removal, which needs to be able to restore initial states of runtime PM. To prepare for these changes, provide a parameter to pm_runtime_remove() to allow optional disabling of runtime PM and reset the irq_safe flag. Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 2 +- drivers/base/power/power.h | 6 +++--- drivers/base/power/runtime.c | 21 +++++++++++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) -- 1.9.1 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 1710c26..6b6c79b 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -146,7 +146,7 @@ void device_pm_remove(struct device *dev) list_del_init(&dev->power.entry); mutex_unlock(&dpm_list_mtx); device_wakeup_disable(dev); - pm_runtime_remove(dev); + pm_runtime_remove(dev, true); } /** diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index 998fa6b..5057a21 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h @@ -18,7 +18,7 @@ static inline void pm_runtime_early_init(struct device *dev) } extern void pm_runtime_init(struct device *dev); -extern void pm_runtime_remove(struct device *dev); +extern void pm_runtime_remove(struct device *dev, bool disable); struct wake_irq { struct device *dev; @@ -84,7 +84,7 @@ static inline void pm_runtime_early_init(struct device *dev) } static inline void pm_runtime_init(struct device *dev) {} -static inline void pm_runtime_remove(struct device *dev) {} +static inline void pm_runtime_remove(struct device *dev, bool disable) {} static inline int dpm_sysfs_add(struct device *dev) { return 0; } static inline void dpm_sysfs_remove(struct device *dev) {} @@ -132,7 +132,7 @@ static inline void device_pm_add(struct device *dev) {} static inline void device_pm_remove(struct device *dev) { - pm_runtime_remove(dev); + pm_runtime_remove(dev, true); } static inline void device_pm_move_before(struct device *deva, diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index e1a10a0..d3031ef 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1393,15 +1393,20 @@ void pm_runtime_init(struct device *dev) * pm_runtime_remove - Prepare for removing a device from device hierarchy. * @dev: Device object being removed from device hierarchy. */ -void pm_runtime_remove(struct device *dev) +void pm_runtime_remove(struct device *dev, bool disable) { - __pm_runtime_disable(dev, false); - - /* Change the status back to 'suspended' to match the initial status. */ - if (dev->power.runtime_status == RPM_ACTIVE) - pm_runtime_set_suspended(dev); - if (dev->power.irq_safe && dev->parent) - pm_runtime_put(dev->parent); + if (disable) + __pm_runtime_disable(dev, false); + + if (!pm_runtime_enabled(dev)) { + /* Restore initial runtime PM states. */ + if (dev->power.runtime_status == RPM_ACTIVE) + pm_runtime_set_suspended(dev); + if (dev->power.irq_safe && dev->parent) { + pm_runtime_put(dev->parent); + dev->power.irq_safe = 0; + } + } } /**