From patchwork Wed Oct 8 07:48:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 5051951 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 12E459F295 for ; Wed, 8 Oct 2014 07:50:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 28FB92021F for ; Wed, 8 Oct 2014 07:50:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A41C920204 for ; Wed, 8 Oct 2014 07:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754594AbaJHHtb (ORCPT ); Wed, 8 Oct 2014 03:49:31 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:41043 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754522AbaJHHt3 (ORCPT ); Wed, 8 Oct 2014 03:49:29 -0400 Received: by mail-pa0-f54.google.com with SMTP id ey11so8545451pad.41 for ; Wed, 08 Oct 2014 00:49:28 -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=yykRJ4f11Z7o7P5rKGYh6DU5H3a7RuYWWHxR9iZtvWM=; b=QHUzgom/Oyw7y7x4uxq8ZlT9+oqAynbV51C8/bb5B8YJBfPvb7BTqv7N9LaUOBC4K4 SwtbwH+kfPclto5Pz61IGvn1/Cpt2SYFzC3tuJfWlY7R3Ag+UakyYKQguY8BPhO9Y3Vo 1b4et4n04AQGaizgeHQ0jt+aBjWQTFE3wVjzUx02djyaz+lw1YYquoDJ+LrHSSoM4f56 uNwwfgW4Z33qeGbHvPDX0CUxlK9deJaTni5Uc3zWQgTNa3KYbr69rGYeynxe9ZL/JgxD 09gJQTlcYFaQu1Zn4uAcqofh8RLlXPVAPE8O2UkaCUZdeELEMeIkBsYc0MlM/XVAp2KK NZsg== X-Gm-Message-State: ALoCoQms6Jh/YZm/zNCAJazP0Hjnz7OKBNKMreMxDWJX8DrqiDg1CSOHUUqo2odGoIg6fuId4uaQ X-Received: by 10.68.171.33 with SMTP id ar1mr2420235pbc.148.1412754568673; Wed, 08 Oct 2014 00:49:28 -0700 (PDT) Received: from quantum.home (pool-108-47-66-231.lsanca.fios.verizon.net. [108.47.66.231]) by mx.google.com with ESMTPSA id on3sm15663577pdb.71.2014.10.08.00.49.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Oct 2014 00:49:28 -0700 (PDT) From: Mike Turquette To: viresh.kumar@linaro.org Cc: thomas.petazzoni@free-electrons.com, rjw@rjwysocki.net, linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, shawn.guo@linaro.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, spk.linux@gmail.com, pramod.gurav@smartplayin.com, rob.herring@linaro.org, ezequiel.garcia@free-electrons.com, tawfik@marvell.com, nadavh@marvell.com, alior@marvell.com, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, vincent.guittot@linaro.org, nicolas.pitre@linaro.org, linux-kernel@vger.kernel.org, tuukka.tikkanen@linaro.org, Mike Turquette Subject: [PATCH 1/2] cpufreq: add driver flag for sleepable transitions Date: Wed, 8 Oct 2014 00:48:53 -0700 Message-Id: <1412754534-14068-2-git-send-email-mturquette@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1412754534-14068-1-git-send-email-mturquette@linaro.org> References: <1412754534-14068-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 The CPUfreq core does not differentiate between .target & .target_index callbacks that may sleep or block and callbacks that are fast and return immediately. To date this has not mattered much since the typical CPUfreq governor calls the .target callback from process context via a workqueue. When calling the .target callback from a different context, such as a scheduler load balance operation (see Morten's "energy aware scheduler" RFC[0]), this detail matters. This patch introduces a new CPUfreq driver flag for fast .target callbacks that are guaranteed to neither sleep nor block. Setting this flag allows for .target to be called from schedule() and other call sites that have interrupts disabled or other constraints. Drivers may set CPUFREQ_NO_SLEEP at driver registration-time. The default is to not have this flag set, resulting in the need to defer calls to .target and .target_index. [0] http://lkml.kernel.org/r/<1381511957-29776-7-git-send-email-morten.rasmussen@arm.com> Signed-off-by: Mike Turquette --- include/linux/cpufreq.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 138336b..9034573 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -308,6 +308,19 @@ struct cpufreq_driver { */ #define CPUFREQ_NEED_INITIAL_FREQ_CHECK (1 << 5) +/* + * Set by drivers whose .target or .target_index callback will never sleep or + * block. Setting this flag allows for more optimal code by calling .target + * from a context that otherwise would require deferring the work. + * + * An example use of this flag is when scaling cpu frequency from within a call + * to schedule() with interrupts disabled and runqueue locks held. + * + * This flag is not set by default, causing calls to .target to be done in + * process context. + */ +#define CPUFREQ_NO_SLEEP (1 << 6) + int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);