From patchwork Tue Jul 30 13:54:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 18668 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DDD5D248E6 for ; Tue, 30 Jul 2013 13:54:29 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id o19sf4906787qap.3 for ; Tue, 30 Jul 2013 06:54:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=xLL38oTqPRGKsMoKMzc6wMD+Kd7cOju6qThBBWFmSuM=; b=Y3EurF2MoXEmye/kyLTSXdO/vli3X1heDjY9R/zOQZLpH36CPApfCgg20G6h+XeCGZ 5BLtbPRVtGXT8dQR78TNt8DABP40C/7jpniOByjaeqWaxIgj7jqgGSwFs55ZkT1NPX5p ohVzpCT0rSTk/s0JVGX5DwPtuiQbZKK0UYj8Lian78/2hnd//TK5Or69yxtMoD3wHpDz QRkrNeNBGhZqYvy30anML7MMNihH/ypnEcs1OiBQRlvUyqKAFXRAfc9as9LOsIl2g/CV fx5wbQhkutFLS/TqDxoQavKEyYQlp7HjAEtYdTPomHLwlyuQsDx7diNZ1UyRdNSRWYWu KBdw== X-Received: by 10.236.150.82 with SMTP id y58mr33111018yhj.5.1375192469553; Tue, 30 Jul 2013 06:54:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.138 with SMTP id u10ls220778qef.75.gmail; Tue, 30 Jul 2013 06:54:29 -0700 (PDT) X-Received: by 10.58.69.65 with SMTP id c1mr26726811veu.88.1375192469395; Tue, 30 Jul 2013 06:54:29 -0700 (PDT) Received: from mail-vb0-f48.google.com (mail-vb0-f48.google.com [209.85.212.48]) by mx.google.com with ESMTPS id t6si10464529vdo.61.2013.07.30.06.54.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Jul 2013 06:54:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.48 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.48; Received: by mail-vb0-f48.google.com with SMTP id w16so348653vbf.21 for ; Tue, 30 Jul 2013 06:54:29 -0700 (PDT) X-Received: by 10.221.47.193 with SMTP id ut1mr9961713vcb.8.1375192469290; Tue, 30 Jul 2013 06:54:29 -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.221.11.8 with SMTP id pc8csp177468vcb; Tue, 30 Jul 2013 06:54:28 -0700 (PDT) X-Received: by 10.194.119.195 with SMTP id kw3mr46079371wjb.64.1375192468220; Tue, 30 Jul 2013 06:54:28 -0700 (PDT) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by mx.google.com with ESMTPS id z5si10737533wiw.16.2013.07.30.06.54.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Jul 2013 06:54:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.181 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=209.85.212.181; Received: by mail-wi0-f181.google.com with SMTP id en1so4299477wid.14 for ; Tue, 30 Jul 2013 06:54:27 -0700 (PDT) X-Received: by 10.180.73.68 with SMTP id j4mr1113344wiv.10.1375192467349; Tue, 30 Jul 2013 06:54:27 -0700 (PDT) Received: from mai.home (AToulouse-654-1-378-11.w86-199.abo.wanadoo.fr. [86.199.233.11]) by mx.google.com with ESMTPSA id r6sm6026572wiw.0.2013.07.30.06.54.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Jul 2013 06:54:26 -0700 (PDT) From: Daniel Lezcano To: rjw@sisk.pl, lenb@kernel.org Cc: linux-pm@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org Subject: [PATCH 1/2] cpuidle: add hotplug support to initialize the timer broadcast Date: Tue, 30 Jul 2013 15:54:27 +0200 Message-Id: <1375192468-2255-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmBppxLoi3s5yIF0tXZZa0tHHRtaYOPRflSe4mGdAL4MgXTGWwXlFto+LrGN9kfkHKCwGyd X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.48 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: , Commit 89878baa73f0f1c679355006bd8632e5d78f96c2 introduced the flag CPUIDLE_FLAG_TIMER_STOP where we specify a specific idle state stops the local timer. Commit a06df062a189a8d5588babb8bf0bb78672497798 introduced the initialization of the timer broadcast framework depending of the flag presence. If a system is booted with some cpus offline, by setting for example, maxcpus=1 in the kernel command line, and then they are set online, the timer broadcast won't be setup automatically. Fix this by adding the cpu hotplug notifier and enable/disable the timer broadcast automatically. So no need to handle that at the arch specific driver level like eg. intel_idle does. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/driver.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 3ac499d..e976994 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -147,6 +148,48 @@ static void cpuidle_setup_broadcast_timer(void *arg) } /** + * cpuidle_hotplug_notify: notifier callback when a cpu is onlined/offlined + * @n: the notifier block + * @action: an unsigned long giving the event related to the notification + * @hcpu: a void pointer but used as the cpu number which the event is related + * + * The kernel can boot with some cpus offline, we have to init the timer + * broadcast for these cpus when they are onlined. Also we have to disable + * the timer broadcast when the cpu is down. + * + * Returns NOTIFY_OK + */ +static int cpuidle_hotplug_notify(struct notifier_block *n, + unsigned long action, void *hcpu) +{ + int cpu = (unsigned long)hcpu; + struct cpuidle_driver *drv; + + drv = __cpuidle_get_cpu_driver(cpu); + if (!drv || !drv->bctimer) + goto out; + + switch (action & 0xf) { + case CPU_ONLINE: + smp_call_function_single(cpu, cpuidle_setup_broadcast_timer, + (void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, + 1); + break; + case CPU_DEAD: + smp_call_function_single(cpu, cpuidle_setup_broadcast_timer, + (void *)CLOCK_EVT_NOTIFY_BROADCAST_OFF, + 1); + break; + } +out: + return NOTIFY_OK; +} + +static struct notifier_block cpuidle_hotplug_notifier = { + .notifier_call = cpuidle_hotplug_notify, +}; + +/** * __cpuidle_driver_init - initialize the driver's internal data * @drv: a valid pointer to a struct cpuidle_driver * @@ -262,6 +305,9 @@ int cpuidle_register_driver(struct cpuidle_driver *drv) ret = __cpuidle_register_driver(drv); spin_unlock(&cpuidle_driver_lock); + if (!ret) + ret = register_cpu_notifier(&cpuidle_hotplug_notifier); + return ret; } EXPORT_SYMBOL_GPL(cpuidle_register_driver); @@ -276,6 +322,8 @@ EXPORT_SYMBOL_GPL(cpuidle_register_driver); */ void cpuidle_unregister_driver(struct cpuidle_driver *drv) { + unregister_cpu_notifier(&cpuidle_hotplug_notifier); + spin_lock(&cpuidle_driver_lock); __cpuidle_unregister_driver(drv); spin_unlock(&cpuidle_driver_lock);