Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp237349imm; Wed, 30 May 2018 22:38:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI97BOsrAn47CXPoIy6uYM8YXPug4IYmeyBp/Cj8cLrQAnMz0vV1aGIvcgxTX22yn/RevOx X-Received: by 2002:a63:6e8f:: with SMTP id j137-v6mr4449931pgc.453.1527745095389; Wed, 30 May 2018 22:38:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527745095; cv=none; d=google.com; s=arc-20160816; b=TL11j2h+0gL4GUvv3kC6CzFRSib09aTfVwhz5r/mtxaQ3C/DWN8Y18d4vOROMVg9WF JpMUucBBq104Dul7woz3GbZ843rX6gmV1TOBmGrLH7fEU8307kDBFUEZ9/vLMrJfT5dY 1ffxTjn+Rhatvaj8ARt1Da0rO2ouf4gjWEHTBhFtIraLKK0XZyPz/OkbSL3y71a5300U 8o/A58CiV9dUy/3wIZWAv1LFQEQw85dLHb7I7BnrUf+bOGKOjWOTVaA5zBnGzpXMmqMw 9TpiVuKjbmfjLicPqltPtVGFWkRyEKSMLtz8Op7y/gPD/3N7T9dswdR3ShikHu8U5otq b8Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=aP1gvc1nzSbF3YV+NAz7NSjCX6NQOqj8TjnZDWqZcHo=; b=gdaZefez5DlQ2CaPWWdB+/9kN9YQQpK2R3GcOLdCa868PHv71VKo5mG5C/QqJLVtim QGURyi1rxWYCHhJzpMYhNDNXrMLiLZZSx/W0mOcYnOb0AKcZjqNxytG6XdYQRQX71wZX HGdL+xj8xXgcXwYricssIfUKL5P4kIKNCj/0xw4/EcKXr6n4RD84dQSr8F8TVCuO5b3J 55+bIC5VzuZjzdF4fm6NTzPmGPWM7nHn7Te/fHuIxp8ksiTdpsF7JpKTFNPNZ6rwQBML p1Gb0KtdFvZdFZiFLPucyxdSUYf6a8O+4zm8iHPtL/u3gmi6NjcAValSqiC9SDpqMlMB 1N8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=QZaR33A8; dkim=pass header.i=@codeaurora.org header.s=default header.b=U6DdLIqY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y11-v6si36258509plg.376.2018.05.30.22.38.01; Wed, 30 May 2018 22:38:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=QZaR33A8; dkim=pass header.i=@codeaurora.org header.s=default header.b=U6DdLIqY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753866AbeEaFhQ (ORCPT + 99 others); Thu, 31 May 2018 01:37:16 -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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 1.9.1