Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp587338imm; Fri, 13 Jul 2018 02:54:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdJB87bZwMM+FtHZqRBfKXRN6Fw1hgLte9d3/ZoBO5n0lY0cy+DS3wc07SPPzoLctUxPgp2 X-Received: by 2002:a62:9f16:: with SMTP id g22-v6mr6217187pfe.207.1531475669772; Fri, 13 Jul 2018 02:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531475669; cv=none; d=google.com; s=arc-20160816; b=Sq68z59LZl7s6xJxmmwCbik7MNEtflVgI/eK48e6wAjLOKBBvrhsqOg2ARlnH5j/di 5QTzoBMaDR+RLuAQghkbGa67T3VTNl/m+DkC9qPq16BOQEiTswXCRibqTPbRpXkC7BXa YArxcDaGPMSabc5IJX6uNJB1PayYXSAwvRwvntlz3W8GEZtiwCJN6JxME80+O5wKq5jX FjG+kjjy/W1eRLAQsAO8s1xv6LCnFZ25A0KOOOuvYq0rdVAd3Muh3TrEkG2VEBOrVjdE n/RF0+N09hV0pCHFIwDgjSecy9kwj1PThGo95c/Ts++pFCH4MZFw4NPutC/peIMRjRNA wf6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=gzU1MLE43Ka8Cox1VuWXeuhnSbz1RKdu+lf2HfryayY=; b=iBDgQTgiurHrcBGr3WXvLZpfEKEAx5v1VP/fZZynO7QqzmtgU/3jexwK9QPxZCd/1k TxziqoktRjyZNdemwmKeCP+k5V5G5UvQ7bRM5ZPRfH3jrQjgr6WQnbdDfRmYCU/XQyAQ zbt5XaE1KatX/OOsZmE4ecgg7q+SZl7OaTzIOs4ZhFYArGxJdgX9/SaJbEvwnGTLFILM /GseKMZX2SuqKF0HBUe3SoioQe6G5hXcpXpGr/Mn59Mi/BA2HrNDdhjILEMGiN9AG4wx PBlCCxAwQVIqPjKmyAXwkwaERKW8nJ1AMx3byjFfM6aLkcAyeZppOlaO9HKp+u/DIOmS 0axA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=THuRnKgC; dkim=pass header.i=@codeaurora.org header.s=default header.b="KTCc/1c0"; 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 i62-v6si22523358pge.93.2018.07.13.02.54.14; Fri, 13 Jul 2018 02:54:29 -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=THuRnKgC; dkim=pass header.i=@codeaurora.org header.s=default header.b="KTCc/1c0"; 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 S1729617AbeGMKHX (ORCPT + 99 others); Fri, 13 Jul 2018 06:07:23 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49354 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbeGMKHX (ORCPT ); Fri, 13 Jul 2018 06:07:23 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id F2EB660B72; Fri, 13 Jul 2018 09:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1531475608; bh=5cYhOuesC706GUAgOUXoSmE00Bwr9g+9IrGNf3kUexE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=THuRnKgCO6KQkrG8Ib+DB5LHnCIDvHi4KE8BvtbwWZHRwG+TebnWABOi7aJUnC5jH KgxzPv3rAvjYDkrUTi82dpaGdqGBGTdEomDXP06t/9OSUfjG0i57tXpCB9Hd1J+lrU VqlzgnGeRZz5flMrZKcwMdHDMQW1i258c3Mha7HA= 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 sayalil-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-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sayalil@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A602460B10; Fri, 13 Jul 2018 09:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1531475607; bh=5cYhOuesC706GUAgOUXoSmE00Bwr9g+9IrGNf3kUexE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTCc/1c00UjS9LzOidK0kklNZQGN7dL22ZLNdCJKR746Gw4ahNDZchk9h43Kf2+fO 82UeEKBfl2PhSbXgydvSU5XfdqYJKx7v0fU/LtCBmv5n+LHS0IvhrThVk/q+pWfDXl po1bvNxE7+PQ0hZe+t3BaFxl6ZCPtNeE9jemBlMo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A602460B10 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=sayalil@codeaurora.org From: Sayali Lokhande To: adrian.hunter@intel.com, ulf.hansson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, shawn.lin@rock-chips.com, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org, devicetree@vger.kernel.org, asutoshd@codeaurora.org, stummala@codeaurora.org, venkatg@codeaurora.org, vviswana@codeaurora.org, bjorn.andersson@linaro.org, riteshh@codeaurora.org, vbadigan@codeaurora.org, sayalil@codeaurora.org Subject: [PATCH RFC 1/7] devfreq: Add new flag to do simple clock scaling Date: Fri, 13 Jul 2018 15:22:57 +0530 Message-Id: <1531475583-7050-2-git-send-email-sayalil@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1531475583-7050-1-git-send-email-sayalil@codeaurora.org> References: <1531475583-7050-1-git-send-email-sayalil@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sahitya Tummala Add new flag "simple_scaling" to on demand governor so that the clocks can be scaled up only when the load is more than up threshold and can be scaled down only when the load is less than down differential data as provided within struct devfreq_simple_ondemand_data. Signed-off-by: Sahitya Tummala Signed-off-by: Venkat Gopalakrishnan Signed-off-by: Sayali Lokhande --- drivers/devfreq/governor_simpleondemand.c | 25 +++++++++++++++++++------ include/linux/devfreq.h | 4 ++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c index 28e0f2d..532801b 100644 --- a/drivers/devfreq/governor_simpleondemand.c +++ b/drivers/devfreq/governor_simpleondemand.c @@ -28,6 +28,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df, unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL; struct devfreq_simple_ondemand_data *data = df->data; unsigned long max = (df->max_freq) ? df->max_freq : UINT_MAX; + unsigned long min = (df->min_freq) ? df->min_freq : 0; err = devfreq_update_stats(df); if (err) @@ -45,18 +46,30 @@ static int devfreq_simple_ondemand_func(struct devfreq *df, dfso_upthreshold < dfso_downdifferential) return -EINVAL; - /* Assume MAX if it is going to be divided by zero */ - if (stat->total_time == 0) { - *freq = max; - return 0; - } - /* Prevent overflow */ if (stat->busy_time >= (1 << 24) || stat->total_time >= (1 << 24)) { stat->busy_time >>= 7; stat->total_time >>= 7; } + if (data && data->simple_scaling) { + if (stat->busy_time * 100 > + stat->total_time * dfso_upthreshold) + *freq = max; + else if (stat->busy_time * 100 < + stat->total_time * dfso_downdifferential) + *freq = min; + else + *freq = df->previous_freq; + return 0; + } + + /* Assume MAX if it is going to be divided by zero */ + if (stat->total_time == 0) { + *freq = max; + return 0; + } + /* Set MAX if it's busy enough */ if (stat->busy_time * 100 > stat->total_time * dfso_upthreshold) { diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 3aae5b3..2957fd8 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -236,6 +236,9 @@ extern struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, * the governor may consider slowing the frequency down. * Specify 0 to use the default. Valid value = 0 to 100. * downdifferential < upthreshold must hold. + * @simple_scaling: Setting this flag will scale the clocks up only if the + * load is above @upthreshold and will scale the clocks + * down only if the load is below @downdifferential. * * If the fed devfreq_simple_ondemand_data pointer is NULL to the governor, * the governor uses the default values. @@ -243,6 +246,7 @@ extern struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, struct devfreq_simple_ondemand_data { unsigned int upthreshold; unsigned int downdifferential; + unsigned int simple_scaling; }; #endif -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project