From patchwork Thu Mar 10 14:08:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 624721 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2AE9FMX013934 for ; Thu, 10 Mar 2011 14:09:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752830Ab1CJOI5 (ORCPT ); Thu, 10 Mar 2011 09:08:57 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:50200 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752695Ab1CJOIm (ORCPT ); Thu, 10 Mar 2011 09:08:42 -0500 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p2AE8LCb020759 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Mar 2011 08:08:24 -0600 Received: from linfarm476.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p2AE8LaB016145; Thu, 10 Mar 2011 19:38:21 +0530 (IST) Received: from linfarm476.india.ti.com (localhost [127.0.0.1]) by linfarm476.india.ti.com (8.12.11/8.12.11) with ESMTP id p2AE8KdT024062; Thu, 10 Mar 2011 19:38:20 +0530 Received: (from a0393909@localhost) by linfarm476.india.ti.com (8.12.11/8.12.11/Submit) id p2AE8K0f024060; Thu, 10 Mar 2011 19:38:20 +0530 From: Santosh Shilimkar To: linux-omap@vger.kernel.org Cc: khilman@ti.com, rnayak@ti.com, linux-arm-kernel@lists.infradead.org, Santosh Shilimkar Subject: [PATCH v2 18/19] OMAP4: cpuidle: Add CPU hotplug notifier and prepare() hook. Date: Thu, 10 Mar 2011 19:38:14 +0530 Message-Id: <1299766095-23879-19-git-send-email-santosh.shilimkar@ti.com> X-Mailer: git-send-email 1.5.6.6 In-Reply-To: <1299766095-23879-1-git-send-email-santosh.shilimkar@ti.com> References: <1299766095-23879-1-git-send-email-santosh.shilimkar@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 10 Mar 2011 14:09:28 +0000 (UTC) diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c index daf41e1..83b7f95 100644 --- a/arch/arm/mach-omap2/cpuidle44xx.c +++ b/arch/arm/mach-omap2/cpuidle44xx.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include @@ -51,6 +53,8 @@ struct omap4_processor_cx { struct omap4_processor_cx omap4_power_states[OMAP4_MAX_STATES]; static struct powerdomain *mpu_pd, *cpu1_pd, *core_pd; +static int needs_state_data_update; +static unsigned int state_flags = CPUIDLE_FLAG_IGNORE; /* * FIXME: Full latency numbers needs to be updated as part of @@ -72,6 +76,31 @@ static struct cpuidle_params cpuidle_params_table[] = { }; /** + * omap4_prepare_idle - Update C-state parameters dynamically + * @dev: cpuidle device + * + * Called from the CPUidle framework to prepare the device + * for idle before before calling the governor's select function. + */ +static int omap4_prepare_idle(struct cpuidle_device *dev) +{ + int i, ret = 0; + + if (!needs_state_data_update) + return ret; + + /* + * Update the C-state flags based on CPU1 online + * or offline state. On OMAP4, the low power C-states + * are made available when only CPU1 is offline. + */ + for (i = OMAP4_STATE_C2; i < OMAP4_MAX_STATES; i++) + dev->states[i].flags = state_flags; + + return ret; +} + +/** * omap4_enter_idle - Programs OMAP4 to enter the specified state * @dev: cpuidle device * @state: The target state to be programmed @@ -227,6 +256,36 @@ struct cpuidle_driver omap4_idle_driver = { .owner = THIS_MODULE, }; +/* + * CPU hotplug notifier to update the C-states when + * CPU1 is offline or onine. While updating C-state flag, + * keep the cpuidle disabled. + */ +static int __cpuinit omap_cpu_hotplug_notify(struct notifier_block *self, + unsigned long action, void *unused) +{ + switch (action) { + case CPU_ONLINE: + disable_hlt(); + needs_state_data_update = 1; + state_flags = CPUIDLE_FLAG_IGNORE; + enable_hlt(); + break; + case CPU_DEAD: + disable_hlt(); + needs_state_data_update = 1; + state_flags = CPUIDLE_FLAG_TIME_VALID; + enable_hlt(); + break; + } + + return NOTIFY_OK; +} + +static struct notifier_block __refdata omap_ilde_hotplug_notifier = { + .notifier_call = omap_cpu_hotplug_notify, +}; + /** * omap4_idle_init - Init routine for OMAP4 idle * @@ -272,12 +331,17 @@ int __init omap4_idle_init(void) if (!count) return -EINVAL; dev->state_count = count; + dev->prepare = omap4_prepare_idle; if (cpuidle_register_device(dev)) { pr_err("%s: CPUidle register device failed\n", __func__); return -EIO; } + ret = register_hotcpu_notifier(&omap_ilde_hotplug_notifier); + if (ret) + return ret; + return 0; } #else