From patchwork Fri Jun 26 23:53:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Turquette X-Patchwork-Id: 6683661 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C72C3C05AC for ; Fri, 26 Jun 2015 23:55:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1C7520692 for ; Fri, 26 Jun 2015 23:55:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D790A206A2 for ; Fri, 26 Jun 2015 23:54:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932178AbbFZXy1 (ORCPT ); Fri, 26 Jun 2015 19:54:27 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:34788 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755195AbbFZXyK (ORCPT ); Fri, 26 Jun 2015 19:54:10 -0400 Received: by pdbep18 with SMTP id ep18so61247925pdb.1 for ; Fri, 26 Jun 2015 16:54:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=stQ/PnWieQPD2c8VK8x6TCvv/FQJKYLU2L9ZLX5wNII=; b=ltXDOFmDc6O1i3fKUxRjqsj7Q//6B24rG9z0GB5qY2woE2LBRjQ97npEiWt259zPBm GNW/BAg8b/mobPEKe1sgDa7gn56Kg3eyvU1/SU07lqIYrvweRdiraictcu6TC16d71qr Deah4g1ZEnOtMs3q+w/SO95huW06O21TghyeQGyOhGrbVnon5r3xmnHQ0HViitvNyM0V tGRlmTfc5xqE+o8GrWIAycpikCYInBsZnTqRcIVQ0oU/a/yeKWPZbr2OQ41S4Ul8XlI1 xVtzvCd4+qbqUAiVIjagx3p5cSxKEeYdeBS85Pvqt17Jl+uFTHvqfyVYOJBTiHFveWhq NfhQ== X-Gm-Message-State: ALoCoQm6U+g8DLNBiIdWgkfRA8DikUfZMIVgpKihJoztywEJ/dCCE4IfYmbZCn4KAi2PT7kN7IPx X-Received: by 10.68.190.41 with SMTP id gn9mr7883753pbc.113.1435362849737; Fri, 26 Jun 2015 16:54:09 -0700 (PDT) Received: from quantum.home (pool-71-119-96-202.lsanca.fios.verizon.net. [71.119.96.202]) by mx.google.com with ESMTPSA id wh6sm34425418pbc.96.2015.06.26.16.54.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jun 2015 16:54:08 -0700 (PDT) From: Michael Turquette X-Google-Original-From: Michael Turquette To: peterz@infradead.org, mingo@kernel.org Cc: linux-kernel@vger.kernel.org, preeti@linux.vnet.ibm.com, Morten.Rasmussen@arm.com, riel@redhat.com, efault@gmx.de, nicolas.pitre@linaro.org, daniel.lezcano@linaro.org, dietmar.eggemann@arm.com, vincent.guittot@linaro.org, amit.kucheria@linaro.org, juri.lelli@arm.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, ashwin.chaugule@linaro.org, alex.shi@linaro.org, linux-pm@vger.kernel.org, abelvesa@gmail.com, pebolle@tiscali.nl, Michael Turquette , "Rafael J. Wysocki" Subject: [PATCH v3 2/4] cpufreq: introduce cpufreq_driver_might_sleep Date: Fri, 26 Jun 2015 16:53:42 -0700 Message-Id: <1435362824-26734-3-git-send-email-mturquette@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435362824-26734-1-git-send-email-mturquette@linaro.org> References: <1435362824-26734-1-git-send-email-mturquette@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Michael Turquette Some architectures and platforms perform CPU frequency transitions through a non-blocking method, while some might block or sleep. This distinction is important when trying to change frequency from interrupt context or in any other non-interruptable context, such as from the Linux scheduler. Describe this distinction with a cpufreq driver flag, CPUFREQ_DRIVER_WILL_NOT_SLEEP. The default is to not have this flag set, thus erring on the side of caution. cpufreq_driver_might_sleep() is also introduced in this patch. Setting the above flag will allow this function to return false. Cc: Rafael J. Wysocki Cc: Viresh Kumar Signed-off-by: Michael Turquette --- drivers/cpufreq/cpufreq.c | 6 ++++++ include/linux/cpufreq.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 28e59a4..e5296c0 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -112,6 +112,12 @@ bool have_governor_per_policy(void) } EXPORT_SYMBOL_GPL(have_governor_per_policy); +bool cpufreq_driver_might_sleep(void) +{ + return !(cpufreq_driver->flags & CPUFREQ_DRIVER_WILL_NOT_SLEEP); +} +EXPORT_SYMBOL_GPL(cpufreq_driver_might_sleep); + struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) { if (have_governor_per_policy()) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 2ee4888..1f2c9a1 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -157,6 +157,7 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_update_policy(unsigned int cpu); bool have_governor_per_policy(void); +bool cpufreq_driver_might_sleep(void); struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy); #else static inline unsigned int cpufreq_get(unsigned int cpu) @@ -314,6 +315,14 @@ struct cpufreq_driver { */ #define CPUFREQ_NEED_INITIAL_FREQ_CHECK (1 << 5) +/* + * Set by drivers that will never block or sleep during their frequency + * transition. Used to indicate when it is safe to call cpufreq_driver_target + * from non-interruptable context. Drivers must opt-in to this flag, as the + * safe default is that they might sleep. + */ +#define CPUFREQ_DRIVER_WILL_NOT_SLEEP (1 << 6) + int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);