From patchwork Thu May 31 05:36:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil P Oommen X-Patchwork-Id: 10440313 X-Patchwork-Delegate: agross@codeaurora.org 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 CFD4A602BF for ; Thu, 31 May 2018 05:37:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF2B02920D for ; Thu, 31 May 2018 05:37:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3EED29213; Thu, 31 May 2018 05:37:28 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 606322920D for ; Thu, 31 May 2018 05:37:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753809AbeEaFhP (ORCPT ); Thu, 31 May 2018 01:37:15 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36918 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751885AbeEaFhO (ORCPT ); Thu, 31 May 2018 01:37:14 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2335F60646; Thu, 31 May 2018 05:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527745034; bh=fnDDz9z6yV7ZOzGGGl/TWg1q0o3rlD5zsIFrwH5tOIo=; h=From:To:Cc:Subject:Date:From; b=QZaR33A8rJdmwGLjtjIm7M1dKwkXzHdTSJQzicszUyffPfUfuLzCLnBmkZNkZKOJO MW7oS3tsO37DsMKcYXD09oR4Igkur0gDjEDY/tmjcZRjkiNl7UvnomYRz9jmbR5GZm dle5HamOYVfpQGGqHT+y9gnSnRG8HDZemrMiSOzs= Received: from akhilpo-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: akhilpo@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 59436602A7; Thu, 31 May 2018 05:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527745033; bh=fnDDz9z6yV7ZOzGGGl/TWg1q0o3rlD5zsIFrwH5tOIo=; h=From:To:Cc:Subject:Date:From; b=U6DdLIqYiwV1uBvx3EWlwDHU2UXAispT02WugR+tDPeRTlekTNqi+rXY8Hi4GwiiR neIaEnRIIWaFPqkS2nZoBJt9ijTbKjWzAlW56v3Fv1+wjpeKCwmcwsizmFm5Uh6R1J G/9/2xhrJnifPpPRhtpxKw5KGR6RRyJ5iVQibPlg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 59436602A7 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=akhilpo@codeaurora.org From: Akhil P Oommen To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jcrouse@codeaurora.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com, linux-arm-msm@vger.kernel.org Subject: [RFC] PM / devfreq: Add support for alerts Date: Thu, 31 May 2018 11:06:59 +0530 Message-Id: <1527745019-25155-1-git-send-email-akhilpo@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, DEVFREQ reevaluates the device state periodically and/or based on the OPP list changes. Private API has to be exposed to allow the device driver to alert/notify the governor to reevaluate when a new set of data is available. This makes the governor more coupled to a particular device driver. We can improve here by exposing a DEVFREQ API to allow the device drivers to send generic alerts to the governor. Signed-off-by: Akhil P Oommen --- drivers/devfreq/devfreq.c | 21 +++++++++++++++++++++ drivers/devfreq/governor.h | 1 + include/linux/devfreq.h | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index fe2af6a..24a8046 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -1532,3 +1532,24 @@ void devm_devfreq_unregister_notifier(struct device *dev, devm_devfreq_dev_match, devfreq)); } EXPORT_SYMBOL(devm_devfreq_unregister_notifier); + +/** + * devfreq_alert_governor() - Alert governor about an event + * @devfreq: The devfreq object. + * @type: Optional alert type. + * + * This function lets the device alert the governor about an event. + * A governor may not implement or choose to completely ignore this alert. + */ +void devfreq_alert_governor(struct devfreq *devfreq, unsigned int type) +{ + /* Don't let someone change the governor until we are done here. */ + mutex_lock(&devfreq_list_lock); + + if (devfreq) + devfreq->governor->event_handler(devfreq, + DEVFREQ_GOV_ALERT, &type); + + mutex_unlock(&devfreq_list_lock); +} +EXPORT_SYMBOL(devfreq_alert_governor); diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h index cfc50a6..e5da3442 100644 --- a/drivers/devfreq/governor.h +++ b/drivers/devfreq/governor.h @@ -24,6 +24,7 @@ #define DEVFREQ_GOV_INTERVAL 0x3 #define DEVFREQ_GOV_SUSPEND 0x4 #define DEVFREQ_GOV_RESUME 0x5 +#define DEVFREQ_GOV_ALERT 0x6 /** * struct devfreq_governor - Devfreq policy governor diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 3aae5b3..740c228 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -193,6 +193,7 @@ extern struct devfreq *devm_devfreq_add_device(struct device *dev, void *data); extern void devm_devfreq_remove_device(struct device *dev, struct devfreq *devfreq); +extern void devfreq_alert_governor(struct devfreq *devfreq, unsigned int type); /* Supposed to be called by PM callbacks */ extern int devfreq_suspend_device(struct devfreq *devfreq); @@ -306,6 +307,10 @@ static inline void devm_devfreq_remove_device(struct device *dev, { } +static void devfreq_alert_governor(struct devfreq *devfreq, unsigned int type) +{ +} + static inline int devfreq_suspend_device(struct devfreq *devfreq) { return 0;