From patchwork Fri Nov 3 14:47:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 117924 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp3402294edm; Fri, 3 Nov 2017 07:49:53 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QA+jhiWoeuZFjfTkkgVUMpo+tBtnLG4jdejvX7FDpNqVngK0H8WtZLyteEh/7yrmoREQf+ X-Received: by 10.101.81.198 with SMTP id i6mr7355049pgq.391.1509720593228; Fri, 03 Nov 2017 07:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509720593; cv=none; d=google.com; s=arc-20160816; b=wzxBvs6tzCnltpQyT4Fr8dtHPvJQyVEuvrW1xYc/zFrMnSii49/Lmmx6OzsIaWiIog HGbXdCgCsSdT4X+2nDpwfcbiTYsUq06qXHcdEWugRUfQcYzE9z6xL7XqEHyan+AT1TpC AmlEB2TJY92pMbm48iTj4PImzuD+5b8MbsT84q6B/HF52czLuTzO8Zi30Q1huhYTeJ7u aSsW9xHT1ANoWmiyq+AZ+BBrnlzEvi6p16Un1qSY6h7kFbhHw/DgdMNyh+V4cocMuogU wig5Sm776VJYmC/QdQY29bap+3D/PsKP7mVDStcItP/ntSEpw+7JflUHksokkz17wKAr ut1Q== 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:arc-authentication-results; bh=a3YFu9SiotuckYYIpgi/AN4bhAU0l7mgHPEjgCEA1wY=; b=qCR8ttJN7EqPpbi+YXGfltR+39dfShLXhe5wFFAPTuEO+W2DUKybJBjzhBD0Wd31lS twoaaN5vACLj/ZSQMJjACHMKi5oBl97D5f1UotlJfGHt4pww3ZNLR4hmUqh6kM/gCpKz FkZa9QgKmjL6XOpggm52oAczCboB0GL06MFlpWlLxC/S83+pb/Q8h4g3ROxCNoWEK+Fm 4/5AzwgQE7HoEZMIrgN8hnLHJHkNLo0Nc3QQ70p9a439U9vWngAisfv06pm0lCuC1HEw WYFwHKiG50Z+0Ehd1NvBmnGStPbVHHO/HjM2EHfPH6cwmTFniAIo3/nY5bTMD7LOpny0 a3og== ARC-Authentication-Results: i=1; mx.google.com; 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 3si4811637plx.791.2017.11.03.07.49.52; Fri, 03 Nov 2017 07:49:53 -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; 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 S933851AbdKCOtv (ORCPT + 26 others); Fri, 3 Nov 2017 10:49:51 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44564 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933744AbdKCOtg (ORCPT ); Fri, 3 Nov 2017 10:49:36 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 325651A9A; Fri, 3 Nov 2017 07:49:36 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (e107155-lin.cambridge.arm.com [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CCE413F3DF; Fri, 3 Nov 2017 07:49:33 -0700 (PDT) From: Sudeep Holla To: ALKML , LKML , DTML Cc: Sudeep Holla , Roy Franz , Harb Abdulhamid , Nishanth Menon , Arnd Bergmann , Loc Ho , Ryan Harkin , Jassi Brar , "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org Subject: [PATCH v4 20/20] cpufreq: scmi: add support for fast frequency switching Date: Fri, 3 Nov 2017 14:47:57 +0000 Message-Id: <1509720477-18936-21-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509720477-18936-1-git-send-email-sudeep.holla@arm.com> References: <1509720477-18936-1-git-send-email-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpufreq core provides option for drivers to implement fast_switch callback which is invoked for frequency switching from interrupt context. This patch adds support for fast_switch callback in SCMI cpufreq driver by making use of polling based SCMI transfer. It also sets the flag fast_switch_possible. Cc: "Rafael J. Wysocki" Cc: Viresh Kumar Cc: linux-pm@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/cpufreq/scmi-cpufreq.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.7.4 diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index b1057a13e6a7..91df5013f7b2 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -64,6 +64,19 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) return perf_ops->freq_set(handle, priv->domain_id, freq, false); } +static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy, + unsigned int target_freq) +{ + struct scmi_data *priv = policy->driver_data; + struct scmi_perf_ops *perf_ops = handle->perf_ops; + + if (!perf_ops->freq_set(handle, priv->domain_id, + target_freq * 1000, true)) + return target_freq; + + return 0; +} + static int scmi_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) { @@ -167,6 +180,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency = latency; + policy->fast_switch_possible = true; return 0; out_free_cpufreq_table: @@ -183,6 +197,7 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy) { struct scmi_data *priv = policy->driver_data; + policy->fast_switch_possible = false; cpufreq_cooling_unregister(priv->cdev); dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); kfree(priv); @@ -226,6 +241,7 @@ static struct cpufreq_driver scmi_cpufreq_driver = { .verify = cpufreq_generic_frequency_table_verify, .attr = cpufreq_generic_attr, .target_index = scmi_cpufreq_set_target, + .fast_switch = scmi_cpufreq_fast_switch, .get = scmi_cpufreq_get_rate, .init = scmi_cpufreq_init, .exit = scmi_cpufreq_exit,