From patchwork Wed Jan 7 23:51:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 5589131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 549669F443 for ; Wed, 7 Jan 2015 23:56:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 465CB2037F for ; Wed, 7 Jan 2015 23:56:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 39DBD2037B for ; Wed, 7 Jan 2015 23:56:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y90Pg-0006XP-31; Wed, 07 Jan 2015 23:53:20 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y90O8-0005Ud-LS for linux-arm-kernel@lists.infradead.org; Wed, 07 Jan 2015 23:51:46 +0000 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NHT00G06ZLJ5P60@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 08 Jan 2015 08:51:20 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.116]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 3A.51.18484.776CDA45; Thu, 08 Jan 2015 08:51:19 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-7e-54adc677ad29 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 2C.15.09430.776CDA45; Thu, 08 Jan 2015 08:51:19 +0900 (KST) Received: from chan.10.32.193.11 ([10.252.81.195]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NHT00HMNZLJWE60@mmp1.samsung.com>; Thu, 08 Jan 2015 08:51:19 +0900 (KST) From: Chanwoo Choi To: myungjoo.ham@samsung.com, kgene@kernel.org Subject: [PATCHv7 02/10] devfreq: event: Add the list of supported devfreq-event type Date: Thu, 08 Jan 2015 08:51:09 +0900 Message-id: <1420674677-3077-3-git-send-email-cw00.choi@samsung.com> X-Mailer: git-send-email 1.8.5.5 In-reply-to: <1420674677-3077-1-git-send-email-cw00.choi@samsung.com> References: <1420674677-3077-1-git-send-email-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRmVeSWpSXmKPExsWyRsSkRLf82NoQg62/zCwer1nMZLFxxnpW i+tfnrNaTLo/gcXi9QtDi/7Hr5ktzja9YbfY9Pgaq8XlXXPYLD73HmG0mHF+H5PF0usXmSxu N65gs3i84i27ReveI+wWq3b9YXQQ8Fgzbw2jx85Zd9k9Fu95yeSxaVUnm8fmJfUefVtWMXp8 3iQXwB7FZZOSmpNZllqkb5fAlfFz/y72gv0mFUseBjQwntTuYuTkkBAwkVi2+A47hC0mceHe erYuRi4OIYGljBL3181jhCm6//IyK0RiEaPE6qNXmSGcJiaJqYtngLWzCWhJ7H9xgw3EFhHQ k+g8tgcszizwh0miaRMLiC0sEC7xZuJKJhCbRUBVom3RdDCbV8BFYvXG16wQ2xQkli2fCWZz CrhKLN28kBnEFgKqednzixFksYTAS3aJc1cWM0IMEpD4NvkQ0AIOoISsxKYDzBBzJCUOrrjB MoFReAEjwypG0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yMzZXEeZXs20KEBNITS1KzU1MLUotg +pg4OKUaGJdctSoTrWSbP+uNSPiTo/GvylKt+2IucK+uO1qpvP3Z25SnswuTDlnFxz8L94k4 GWOSXrJBgK/V/lzen5fd4n+CJywV8DuyRmIe166IeUmcR73+HVyf9Hf7+n9WPxonC+xb+bpy zqzrJR3+dUvMPybXF/IedP4/U3j30zcOIeHht7cVznKp/KfEUpyRaKjFXFScCAA1VFpj7QIA AA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150107_155144_903330_28DA71DB X-CRM114-Status: GOOD ( 20.37 ) X-Spam-Score: -5.0 (-----) Cc: mark.rutland@arm.com, k.kozlowski@samsung.com, linux-samsung-soc@vger.kernel.org, b.zolnierkie@samsung.com, linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, tomasz.figa@gmail.com, linux-kernel@vger.kernel.org, inki.dae@samsung.com, cw00.choi@samsung.com, kyungmin.park@samsung.com, robh+dt@kernel.org, a.kesavan@samsung.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 This patch adds the list of supported devfreq-event type as following. Each devfreq-event device driver would support the various devfreq-event type for devfreq governor at the same time. - DEVFREQ_EVENT_TYPE_RAW_DATA - DEVFREQ_EVENT_TYPE_UTILIZATION - DEVFREQ_EVENT_TYPE_BANDWIDTH - DEVFREQ_EVENT_TYPE_LATENCY Cc: MyungJoo Ham Cc: Kyungmin Park Signed-off-by: Chanwoo Choi --- drivers/devfreq/devfreq-event.c | 58 ++++++++++++++++++++++++++++++++++++----- include/linux/devfreq-event.h | 25 +++++++++++++++--- 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/drivers/devfreq/devfreq-event.c b/drivers/devfreq/devfreq-event.c index 81448ba..64c1764 100644 --- a/drivers/devfreq/devfreq-event.c +++ b/drivers/devfreq/devfreq-event.c @@ -20,6 +20,9 @@ #include #include +#define EVENT_TYPE_RAW_DATA_MAX ULONG_MAX +#define EVENT_TYPE_UTILIZATION_MAX 100 + static struct class *devfreq_event_class; /* The list of all devfreq event list */ @@ -132,7 +135,8 @@ EXPORT_SYMBOL_GPL(devfreq_event_is_enabled); * Note that this function set the event to the devfreq-event device to start * for getting the event data which could be various event type. */ -int devfreq_event_set_event(struct devfreq_event_dev *edev) +int devfreq_event_set_event(struct devfreq_event_dev *edev, + enum devfreq_event_type type) { int ret; @@ -146,7 +150,15 @@ int devfreq_event_set_event(struct devfreq_event_dev *edev) return -EPERM; mutex_lock(&edev->lock); - ret = edev->desc->ops->set_event(edev); + + if ((edev->desc->type & type) == 0) { + dev_err(&edev->dev, "unsupported devfreq-event type\n"); + mutex_unlock(&edev->lock); + return -EINVAL; + } + + ret = edev->desc->ops->set_event(edev, type); + mutex_unlock(&edev->lock); return ret; @@ -162,6 +174,7 @@ EXPORT_SYMBOL_GPL(devfreq_event_set_event); * after stoping the progress of whole sequence of devfreq-event dev. */ int devfreq_event_get_event(struct devfreq_event_dev *edev, + enum devfreq_event_type type, struct devfreq_event_data *edata) { int ret; @@ -175,18 +188,49 @@ int devfreq_event_get_event(struct devfreq_event_dev *edev, if (!devfreq_event_is_enabled(edev)) return -EINVAL; + mutex_lock(&edev->lock); + + if ((edev->desc->type & type) == 0) { + dev_err(&edev->dev, "unsupported devfreq-event type\n"); + return -EINVAL; + } + edata->event = edata->total_event = 0; + ret = edev->desc->ops->get_event(edev, type, edata); + if (ret < 0 + || edata->total_event <= 0 + || edata->event > edata->total_event) { + edata->event = edata->total_event = 0; + mutex_unlock(&edev->lock); + return -EINVAL; + } - mutex_lock(&edev->lock); - ret = edev->desc->ops->get_event(edev, edata); - mutex_unlock(&edev->lock); + switch (type) { + case DEVFREQ_EVENT_TYPE_RAW_DATA: + case DEVFREQ_EVENT_TYPE_BANDWIDTH: + case DEVFREQ_EVENT_TYPE_LATENCY: + if ((edata->event > EVENT_TYPE_RAW_DATA_MAX) || + (edata->total_event > EVENT_TYPE_RAW_DATA_MAX)) { + edata->event = edata->total_event = 0; + ret = -EINVAL; + } + break; + case DEVFREQ_EVENT_TYPE_UTILIZATION: + edata->total_event = EVENT_TYPE_UTILIZATION_MAX; - if ((edata->total_event <= 0) - || (edata->event > edata->total_event)) { + if (edata->event > EVENT_TYPE_UTILIZATION_MAX) { + edata->event = edata->total_event = 0; + ret = -EINVAL; + } + break; + default: edata->event = edata->total_event = 0; ret = -EINVAL; + break; } + mutex_unlock(&edev->lock); + return ret; } EXPORT_SYMBOL_GPL(devfreq_event_get_event); diff --git a/include/linux/devfreq-event.h b/include/linux/devfreq-event.h index b7363f5..13a5703 100644 --- a/include/linux/devfreq-event.h +++ b/include/linux/devfreq-event.h @@ -36,6 +36,14 @@ struct devfreq_event_dev { const struct devfreq_event_desc *desc; }; +/* The supported type by devfreq-event device */ +enum devfreq_event_type { + DEVFREQ_EVENT_TYPE_RAW_DATA = BIT(0), + DEVFREQ_EVENT_TYPE_UTILIZATION = BIT(1), + DEVFREQ_EVENT_TYPE_BANDWIDTH = BIT(2), + DEVFREQ_EVENT_TYPE_LATENCY = BIT(3), +}; + /** * struct devfreq_event_data - the devfreq-event data * @@ -69,8 +77,10 @@ struct devfreq_event_ops { int (*reset)(struct devfreq_event_dev *edev); /* Mandatory functions */ - int (*set_event)(struct devfreq_event_dev *edev); + int (*set_event)(struct devfreq_event_dev *edev, + enum devfreq_event_type type); int (*get_event)(struct devfreq_event_dev *edev, + enum devfreq_event_type type, struct devfreq_event_data *edata); }; @@ -79,6 +89,10 @@ struct devfreq_event_ops { * * @name : the name of devfreq-event device. * @driver_data : the private data for devfreq-event driver. + * @event_type : the supported devfreq-event type among as following + * - DEVFREQ_EVENT_TYPE_UTILIZATION + * - DEVFREQ_EVENT_TYPE_BANDWIDTH + * - DEVFREQ_EVENT_TYPE_LATENCY * @ops : the operation to control devfreq-event device. * * Each devfreq-event device is described with a this structure. @@ -87,6 +101,7 @@ struct devfreq_event_ops { struct devfreq_event_desc { const char *name; void *driver_data; + enum devfreq_event_type type; struct devfreq_event_ops *ops; }; @@ -95,8 +110,10 @@ struct devfreq_event_desc { extern int devfreq_event_enable_edev(struct devfreq_event_dev *edev); extern int devfreq_event_disable_edev(struct devfreq_event_dev *edev); extern bool devfreq_event_is_enabled(struct devfreq_event_dev *edev); -extern int devfreq_event_set_event(struct devfreq_event_dev *edev); +extern int devfreq_event_set_event(struct devfreq_event_dev *edev, + enum devfreq_event_type type); extern int devfreq_event_get_event(struct devfreq_event_dev *edev, + enum devfreq_event_type type, struct devfreq_event_data *edata); extern int devfreq_event_reset_event(struct devfreq_event_dev *edev); extern void *devfreq_event_get_drvdata(struct devfreq_event_dev *edev); @@ -123,12 +140,14 @@ static inline bool devfreq_event_is_enabled(struct devfreq_event_dev *edev) return false; } -static inline int devfreq_event_set_event(struct devfreq_event_dev *edev) +static inline int devfreq_event_set_event(struct devfreq_event_dev *edev, + enum devfreq_event_type type) { return -EINVAL; } static inline int devfreq_event_get_event(struct devfreq_event_dev *edev, + enum devfreq_event_type type, struct devfreq_event_data *edata) { return -EINVAL;