From patchwork Fri Sep 13 12:59:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20053 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7F733202E6 for ; Fri, 13 Sep 2013 12:59:56 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id x20sf1178881qcv.7 for ; Fri, 13 Sep 2013 05:59:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=n6xAThOKwZ+IJ7U3sY/E4EvjF4W41swbgZJSy3eONA0=; b=KHpZEbZhxuccfHKvAVtRaxvfTspGMHiip709dTIqejMIEti7K4bchkP/ACu592ee9x J/aFHlcG6hAMDl1b9EmbhCUDMhT9n4N/JAqkxvn+fWMrIO2crY79D9rAJIk4LJQ1st/b vMz6LUfgKkLdDObsLOvq/Sx+8l1H7BYSJMytyLInIZP821qVI4cXDnmgfDJMKVUSSzCf KXauvH2mzw5GqTTK/43mluk6zaps7dxb8lULyOvMEVTWWv74zy8ag/e0pPs6SPTIDvY4 6eA6WRCXqEZ1l3xYtSXG6fNFvfq2GDI4NcnIUtkhFVPo8RfEWDY9QJxPqo1e4i6YezZ3 vZNQ== X-Gm-Message-State: ALoCoQlBIMMBoegaQQ0bt6q+1zk1FAb2pbY/XBYOfENYR/Q+yP2h+TQVxD0L81a6/4GQXvxkSSph X-Received: by 10.236.189.37 with SMTP id b25mr654849yhn.48.1379077196254; Fri, 13 Sep 2013 05:59:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.16.200 with SMTP id i8ls1151707qed.65.gmail; Fri, 13 Sep 2013 05:59:56 -0700 (PDT) X-Received: by 10.220.13.20 with SMTP id z20mr11946282vcz.0.1379077196021; Fri, 13 Sep 2013 05:59:56 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id ll17si482212vec.84.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:59:56 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ib11so892661vcb.14 for ; Fri, 13 Sep 2013 05:59:56 -0700 (PDT) X-Received: by 10.220.244.132 with SMTP id lq4mr200339vcb.31.1379077195899; Fri, 13 Sep 2013 05:59:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp79226vcz; Fri, 13 Sep 2013 05:59:55 -0700 (PDT) X-Received: by 10.68.95.4 with SMTP id dg4mr13459740pbb.34.1379077195006; Fri, 13 Sep 2013 05:59:55 -0700 (PDT) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by mx.google.com with ESMTPS id dj4si7409443pbc.44.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:59:55 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.48 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.48; Received: by mail-pa0-f48.google.com with SMTP id kp13so2496866pab.35 for ; Fri, 13 Sep 2013 05:59:54 -0700 (PDT) X-Received: by 10.68.253.161 with SMTP id ab1mr13304130pbd.76.1379077194556; Fri, 13 Sep 2013 05:59:54 -0700 (PDT) Received: from localhost ([122.167.78.148]) by mx.google.com with ESMTPSA id fa4sm17937901pab.17.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 05:59:54 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 1/2] cpufreq: Create cpufreq_transition_complete() Date: Fri, 13 Sep 2013 18:29:38 +0530 Message-Id: <3909d90dbf22749188b27d080a52775b92da6f71.1379062834.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Following patch "cpufreq: make sure frequency transitions are serialized" guarantees that we don't have any races while changing cpu frequency or sending notifications. It handled a special case with CPUFREQ_ASYNC_NOTIFICATION flag for drivers that don't complete their freq change from ->target() and exynos5440 driver is well adopted to it as well.. There is one more driver powernow-k8 that has similar implementation, schedules a work for doing transitions. All is good if that work function does notifications on every call to it and so the transition_ongoing count stays stable. But there are chances that the work function may return without actually doing the notifications, in which case transition_ongoing count will not be set to zero and so no transitions would be possible after that. This patch adds another routine cpufreq_transition_complete() which would be used by powernow-k8 (or even exynos5440 if required), that will be used to mark end of transition in such cases. Later patch will change powernow-k8 to use this routine. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 25 +++++++++++++------------ include/linux/cpufreq.h | 7 +++++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index f8b0889..cf283f3 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -265,6 +265,16 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) } #endif +void cpufreq_transition_complete(struct cpufreq_policy *policy) +{ + unsigned long flags; + + write_lock_irqsave(&cpufreq_driver_lock, flags); + policy->transition_ongoing--; + write_unlock_irqrestore(&cpufreq_driver_lock, flags); +} +EXPORT_SYMBOL_GPL(cpufreq_transition_complete); + static void __cpufreq_notify_transition(struct cpufreq_policy *policy, struct cpufreq_freqs *freqs, unsigned int state) { @@ -350,16 +360,12 @@ void cpufreq_notify_transition(struct cpufreq_policy *policy, if ((cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION) && (state == CPUFREQ_POSTCHANGE)) { - unsigned long flags; - /* * Some drivers don't send POSTCHANGE notification from their * ->target() but from some kind of bottom half and so we are * ending transaction here.. */ - write_lock_irqsave(&cpufreq_driver_lock, flags); - policy->transition_ongoing--; - write_unlock_irqrestore(&cpufreq_driver_lock, flags); + cpufreq_transition_complete(policy); } } EXPORT_SYMBOL_GPL(cpufreq_notify_transition); @@ -1430,9 +1436,7 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, if (cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION) return; - write_lock_irqsave(&cpufreq_driver_lock, flags); - policy->transition_ongoing--; - write_unlock_irqrestore(&cpufreq_driver_lock, flags); + cpufreq_transition_complete(policy); } /** @@ -1754,10 +1758,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, && (retval == -EINPROGRESS)) return retval; - write_lock_irqsave(&cpufreq_driver_lock, flags); - policy->transition_ongoing--; - write_unlock_irqrestore(&cpufreq_driver_lock, flags); - + cpufreq_transition_complete(policy); return retval; } EXPORT_SYMBOL_GPL(__cpufreq_driver_target); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index c770bc0..10ab22d 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -231,6 +231,13 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); const char *cpufreq_get_current_driver(void); +/* + * Only for drivers which have CPUFREQ_ASYNC_NOTIFICATION flag set and they need + * to mark transaction over before starting any notifications, otherwise the + * POSTCHANGE notification already does this. + */ +void cpufreq_transition_complete(struct cpufreq_policy *policy); + static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) {