From patchwork Fri Aug 17 18:20:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 10791 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id F262D23E29 for ; Fri, 17 Aug 2012 18:23:29 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id BB8FEA19295 for ; Fri, 17 Aug 2012 18:23:29 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id j38so928424iad.11 for ; Fri, 17 Aug 2012 11:23:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Tx4esaY5HcioselVZrGXJBkEmAFE1RoPjMVQNLFGloI=; b=oMoZm4zX4J6Tz6u74+nu0Y9jOQo8VAUPnav6+9KLxe1eaA/4t21wnRqxZp553kWtde Ns1jHpbWbGF7+cAMLD7Y1eFVJCAsmvdwx2i7zxyWxnEYNl0GlCJ3BZjDFBTf+SqMg2n5 +1QPeqbYFR6l+sldRrZ8xnxw3l+PwPJcdejxeiNA3+1rmQ9CctHHZ/KSgw3Dx2x19rug ZzQuHXKJDQ0FzdKvGHQ4dNysH2q7L4b1Vfj0CK4C8BNBCmk8tkfvD55kYzvyIRP9Y32G X6Lh9LN7l20vw4rBHqw3MfMD0O5ObIxXF4Msqw8eQqwx5TYYZ+ek/oi2qsa7FTzlvfkw Tdgw== Received: by 10.42.84.69 with SMTP id k5mr5328392icl.5.1345227809503; Fri, 17 Aug 2012 11:23:29 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp123294igc; Fri, 17 Aug 2012 11:23:28 -0700 (PDT) Received: by 10.66.87.66 with SMTP id v2mr11218746paz.71.1345227808447; Fri, 17 Aug 2012 11:23:28 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id pp2si1745540pbc.46.2012.08.17.11.23.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Aug 2012 11:23:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by pbcmd12 with SMTP id md12so4190900pbc.37 for ; Fri, 17 Aug 2012 11:23:28 -0700 (PDT) Received: by 10.68.235.41 with SMTP id uj9mr13760601pbc.41.1345227808036; Fri, 17 Aug 2012 11:23:28 -0700 (PDT) Received: from localhost.localdomain ([115.241.125.74]) by mx.google.com with ESMTPS id uy3sm4739046pbc.29.2012.08.17.11.23.23 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Aug 2012 11:23:27 -0700 (PDT) From: Rajagopal Venkat To: mturquette@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@sisk.pl Cc: patches@linaro.org, linaro-dev@lists.linaro.org, linux-pm@vger.kernel.org, Rajagopal Venkat Subject: [PATCH 2/3][RFC] devfreq: Add suspend and resume apis Date: Fri, 17 Aug 2012 23:50:44 +0530 Message-Id: <1345227645-20703-3-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1345227645-20703-1-git-send-email-rajagopal.venkat@linaro.org> References: <1345227645-20703-1-git-send-email-rajagopal.venkat@linaro.org> X-Gm-Message-State: ALoCoQmjVqGsuyw9rrwzw13RpmGIHdjxiAlci5vd9D6ZjRrAVInlyX8wRB9gRrKmses6mL8+jujY This patch adds suspend and resume apis needed for devices which can idle. Suspend/resume apis are called from driver to suspend/resume devfreq load monitoring of that device. Signed-off-by: Rajagopal Venkat --- drivers/devfreq/devfreq.c | 30 ++++++++++++++++++++++++++++++ drivers/devfreq/governor_simpleondemand.c | 15 +++++++++++++++ include/linux/devfreq.h | 16 ++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 5aa23a8..375b5aa1 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -233,6 +233,36 @@ int devfreq_remove_device(struct devfreq *devfreq) } EXPORT_SYMBOL(devfreq_remove_device); +/** + * devfreq_suspend_device() - Suspend devfreq of a device. + * @devfreq the devfreq instance to be suspended + */ +int devfreq_suspend_device(struct devfreq *devfreq) +{ + if (!devfreq) + return -EINVAL; + + devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_SUSPEND); + + return 0; +} +EXPORT_SYMBOL(devfreq_suspend_device); + +/** + * devfreq_resume_device() - Resume devfreq of a device. + * @devfreq the devfreq instance to be resumed + */ +int devfreq_resume_device(struct devfreq *devfreq) +{ + if (!devfreq) + return -EINVAL; + + devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_RESUME); + + return 0; +} +EXPORT_SYMBOL(devfreq_resume_device); + static ssize_t show_governor(struct device *dev, struct device_attribute *attr, char *buf) { diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c index 7c70c30..95e4db9 100644 --- a/drivers/devfreq/governor_simpleondemand.c +++ b/drivers/devfreq/governor_simpleondemand.c @@ -221,6 +221,21 @@ static int devfreq_simple_ondemand_func(struct devfreq *df, ondemand_exit(df); break; + case DEVFREQ_GOV_SUSPEND: + if (delayed_work_pending(&data->work)) { + data->stop_queuing = true; + cancel_delayed_work_sync(&data->work); + } + break; + + case DEVFREQ_GOV_RESUME: + if (!delayed_work_pending(&data->work)) { + data->stop_queuing = false; + queue_delayed_work(devfreq_wq, &data->work, + msecs_to_jiffies(df->profile->polling_ms)); + } + break; + case DEVFREQ_GOV_LIMITS: if (delayed_work_pending(&data->work)) { mutex_lock(&df->lock); diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 600cc2e..7c6517f 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -56,6 +56,8 @@ struct devfreq_dev_status { #define DEVFREQ_GOV_START 0x1 #define DEVFREQ_GOV_STOP 0x2 #define DEVFREQ_GOV_LIMITS 0x3 +#define DEVFREQ_GOV_SUSPEND 0x4 +#define DEVFREQ_GOV_RESUME 0x5 /** * struct devfreq_dev_profile - Devfreq's user device profile @@ -155,6 +157,10 @@ extern struct devfreq *devfreq_add_device(struct device *dev, void *data); extern int devfreq_remove_device(struct devfreq *devfreq); +extern int devfreq_suspend_device(struct devfreq *devfreq); + +extern int devfreq_resume_device(struct devfreq *devfreq); + /* Helper functions for devfreq user device driver with OPP. */ extern struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq, u32 flags); @@ -207,6 +213,16 @@ static int devfreq_remove_device(struct devfreq *devfreq) return 0; } +static int devfreq_suspend_device(struct devfreq *devfreq) +{ + return 0; +} + +extern int devfreq_resume_device(struct devfreq *devfreq) +{ + return 0; +} + static struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq, u32 flags) {