From patchwork Thu Jan 19 02:51:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhangqing X-Patchwork-Id: 9525123 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 D139F60113 for ; Thu, 19 Jan 2017 02:51:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D64562860D for ; Thu, 19 Jan 2017 02:51:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CACB02862E; Thu, 19 Jan 2017 02:51:10 +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=-6.9 required=2.0 tests=BAYES_00,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 7E3862860D for ; Thu, 19 Jan 2017 02:51:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751739AbdASCvE (ORCPT ); Wed, 18 Jan 2017 21:51:04 -0500 Received: from regular1.263xmail.com ([211.150.99.140]:38958 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728AbdASCvD (ORCPT ); Wed, 18 Jan 2017 21:51:03 -0500 Received: from zhangqing?rock-chips.com (unknown [192.168.167.230]) by regular1.263xmail.com (Postfix) with ESMTP id 58F3A4BA2; Thu, 19 Jan 2017 10:50:47 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 036473EA; Thu, 19 Jan 2017 10:50:42 +0800 (CST) X-RL-SENDER: zhangqing@rock-chips.com X-FST-TO: xf@rock-chips.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: zhangqing@rock-chips.com X-UNIQUE-TAG: <73fad8338cc14034a2f98d2f8b484db0> X-ATTACHMENT-NUM: 0 X-SENDER: zhangqing@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 25133DL3KAV; Thu, 19 Jan 2017 10:50:46 +0800 (CST) From: Elaine Zhang To: xf@rock-chips.com, heiko@sntech.de, rjw@rjwysocki.net, khilman@kernel.org, ulf.hansson@linaro.org, pavel@ucw.cz, len.brown@intel.com Cc: gregkh@linuxfoundation.org, linux-pm@vger.kernel.org, huangtao@rock-chips.com, xxx@rock-chips.com, wxt@rock-chips.com, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Elaine Zhang Subject: [PATCH v1] PM / Domains: Keep the pd status during system PM phases Date: Thu, 19 Jan 2017 10:51:13 +0800 Message-Id: <1484794273-30103-1-git-send-email-zhangqing@rock-chips.com> X-Mailer: git-send-email 1.9.1 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 If a PM domain is powered off before system suspend, we hope do nothing in system runtime suspend noirq phase and system runtime resume noirq phase. This modify is to slove system resume issue for RK3399. RK3399 SOC pd_gpu have voltage domain vdd_gpu, so we must follow open vdd_gpu and power on pd_gpu, power off pd_gpu and disable vdd_gpu. Fix up in runtime resume noirq phase power on all PDs. Signed-off-by: Elaine Zhang --- drivers/base/power/domain.c | 10 +++++++--- include/linux/pm_domain.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 5711708532db..d1ee63e9ee23 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -842,8 +842,10 @@ static int pm_genpd_prepare(struct device *dev) genpd_lock(genpd); - if (genpd->prepared_count++ == 0) + if (genpd->prepared_count++ == 0) { genpd->suspended_count = 0; + genpd->suspend_power_off = genpd->status == GPD_STATE_POWER_OFF; + } genpd_unlock(genpd); @@ -877,7 +879,8 @@ static int pm_genpd_suspend_noirq(struct device *dev) if (IS_ERR(genpd)) return -EINVAL; - if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev)) + if (genpd->suspend_power_off || + dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev)) return 0; if (genpd->dev_ops.stop && genpd->dev_ops.start) { @@ -914,7 +917,8 @@ static int pm_genpd_resume_noirq(struct device *dev) if (IS_ERR(genpd)) return -EINVAL; - if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev)) + if (genpd->suspend_power_off || + dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev)) return 0; /* diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 81ece61075df..9c0dc364f089 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -62,6 +62,7 @@ struct generic_pm_domain { unsigned int device_count; /* Number of devices */ unsigned int suspended_count; /* System suspend device counter */ unsigned int prepared_count; /* Suspend counter of prepared devices */ + bool suspend_power_off; /* Power status before system suspend */ int (*power_off)(struct generic_pm_domain *domain); int (*power_on)(struct generic_pm_domain *domain); struct gpd_dev_ops dev_ops;