From patchwork Fri Nov 15 06:01:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 3186821 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B52FC045B for ; Fri, 15 Nov 2013 06:02:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC6A220872 for ; Fri, 15 Nov 2013 06:02:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF35020867 for ; Fri, 15 Nov 2013 06:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752653Ab3KOGBo (ORCPT ); Fri, 15 Nov 2013 01:01:44 -0500 Received: from mga03.intel.com ([143.182.124.21]:17510 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751472Ab3KOGBn (ORCPT ); Fri, 15 Nov 2013 01:01:43 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga101.ch.intel.com with ESMTP; 14 Nov 2013 22:01:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.93,704,1378882800"; d="scan'208";a="428053601" Received: from tlan1-mobl2.sh.intel.com (HELO localhost) ([10.239.193.154]) by fmsmga001.fm.intel.com with ESMTP; 14 Nov 2013 22:01:33 -0800 From: Lan Tianyu To: rjw@rjwysocki.net, viresh.kumar@linaro.org Cc: Lan Tianyu , cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system syspend/resume Date: Fri, 15 Nov 2013 14:01:34 +0800 Message-Id: <1384495294-10565-1-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.2.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, governor of nonboot cpus will be put to EXIT when system syspend. Since all these cpus will be unplugged and the governor usage_count decreases to zero. The governor data and its sysfs interfaces will be freed or released. This makes user config of these governors loss during suspend and resume. This doesn't happen on the governor covering boot cpu because it isn't unplugged during system suspend. To fix this issue, skipping governor exit during system suspend and check policy governor data to determine whether the governor is really needed to be initialized when do init. If not, return EALREADY to indicate the governor has been initialized and should do nothing. __cpufreq_governor() convert EALREADY to 0 as return value for INIT event since governor is still under INIT state and can do START operation. Signed-off-by: Lan Tianyu --- drivers/cpufreq/cpufreq.c | 5 ++++- drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 02d534d..38f2e4a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1239,7 +1239,7 @@ static int __cpufreq_remove_dev_finish(struct device *dev, /* If cpu is last user of policy, free policy */ if (cpus == 1) { - if (has_target()) { + if (has_target() && !frozen) { ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); if (ret) { @@ -1822,6 +1822,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret)) module_put(policy->governor->owner); + if ((event == CPUFREQ_GOV_POLICY_INIT) && ret == -EALREADY) + ret = 0; + return ret; } diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 0806c31..ddb93af 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -204,9 +204,20 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, switch (event) { case CPUFREQ_GOV_POLICY_INIT: + /* + * In order to keep governor data across suspend/resume, + * Governor doesn't exit when suspend and will be + * reinitialized when resume. Here check policy governor + * data to determine whether the governor has been exited. + * If not, return EALREADY. + */ if (have_governor_per_policy()) { - WARN_ON(dbs_data); + if (dbs_data) + return -EALREADY; } else if (dbs_data) { + if (policy->governor_data == dbs_data) + return -EALREADY; + dbs_data->usage_count++; policy->governor_data = dbs_data; return 0;