From patchwork Mon Mar 23 16:50:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 46209 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 72599214B0 for ; Mon, 23 Mar 2015 16:50:34 +0000 (UTC) Received: by lams18 with SMTP id s18sf28303469lam.2 for ; Mon, 23 Mar 2015 09:50:33 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=QZuqLPz/kyR1dlHfLZ6WrcpX/fshHTPqn5BMqDLdtp0=; b=hRrZx/B9lKAU4KrwuBKsrYjgGHvVGKpgCkHa3Y4E4IQ7b7hRsihW2mMeBMiseaw4DS 1Q13AW7Oaqnv9csaCaa0Ybw4s/xyiU2f3qHO37UQ/+AyAUWrqk7GApWSGP4lOKoVEB4F znfIBqBW1PjIOlLh+bP/ecaLKM8YkreKiWucQruvVdN8CJHKlSgRSRYXcg1l9BFtNTdM kGWDzjBOQIT84SrGrWwmT5c4mgN08JQremea/PvG1Rg/UfOndZ1ZFCgBVOFqsHFFr6Yo 8do9RWnBE/1FDGJeVtU/08u7elGOstLj3CTTEKvC/hD2O/9y/4E4BJ1TxPRrmPADkxOj TiqA== X-Gm-Message-State: ALoCoQk7eG1rR4NV5/2xEw5xu+dJL5XNlzrXDlElUGyIiGE2LMrIvIxZBpCwkj7tQkpYi0hO4mi+ X-Received: by 10.152.87.141 with SMTP id ay13mr29047lab.3.1427129433403; Mon, 23 Mar 2015 09:50:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.137 with SMTP id o9ls649446lal.65.gmail; Mon, 23 Mar 2015 09:50:33 -0700 (PDT) X-Received: by 10.152.43.229 with SMTP id z5mr105690lal.48.1427129433261; Mon, 23 Mar 2015 09:50:33 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id ll8si1008059lac.95.2015.03.23.09.50.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 09:50:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbug6 with SMTP id ug6so28385510lbb.3 for ; Mon, 23 Mar 2015 09:50:33 -0700 (PDT) X-Received: by 10.112.130.195 with SMTP id og3mr48174lbb.112.1427129433128; Mon, 23 Mar 2015 09:50:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp944817lbq; Mon, 23 Mar 2015 09:50:32 -0700 (PDT) X-Received: by 10.68.225.162 with SMTP id rl2mr22385303pbc.117.1427129430831; Mon, 23 Mar 2015 09:50:30 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x14si2009302pas.1.2015.03.23.09.50.30; Mon, 23 Mar 2015 09:50:30 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752260AbbCWQu3 (ORCPT + 5 others); Mon, 23 Mar 2015 12:50:29 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:33745 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752465AbbCWQu2 (ORCPT ); Mon, 23 Mar 2015 12:50:28 -0400 Received: by wgbcc7 with SMTP id cc7so150730891wgb.0 for ; Mon, 23 Mar 2015 09:50:27 -0700 (PDT) X-Received: by 10.194.77.230 with SMTP id v6mr190306195wjw.25.1427129427167; Mon, 23 Mar 2015 09:50:27 -0700 (PDT) Received: from mai.lan (135-224-190-109.dsl.ovh.fr. [109.190.224.135]) by mx.google.com with ESMTPSA id fo8sm11920180wib.14.2015.03.23.09.50.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Mar 2015 09:50:26 -0700 (PDT) From: Daniel Lezcano To: lorenzo.pieralisi@arm.com Cc: rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin.Marinas@arm.com, robherring2@gmail.com, arnd@arndb.de, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, lina.iyer@linaro.org, sboyd@codeaurora.org Subject: [PATCH V4] ARM: cpuidle: Register per cpuidle device Date: Mon, 23 Mar 2015 17:50:24 +0100 Message-Id: <1427129424-17175-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20150323162514.GE18904@red-moon> References: <20150323162514.GE18904@red-moon> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On some platforms, the low level PM code may not be initialized correctly for a specific cpu. In this case, the EXNIO tells the cpuidle driver to not initialize the cpuidle device as the associated low level PM is not operational. That prevents the system to crash and allows to handle the error gracefully. For example, on Qcom's platform, each core has a SPM. The device associated with this SPM is initialized before the cpuidle framework. If there is an error in the initialization (eg. error in the DT), the system continues to boot but in degraded mode as some SPM may not be correctly initialized. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle-arm.c | 46 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index 1c94b88..a7a01ce 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -94,6 +95,7 @@ static int __init arm_idle_init(void) { int cpu, ret; struct cpuidle_driver *drv = &arm_idle_driver; + struct cpuidle_device *dev; /* * Initialize idle states data, starting at index 1. @@ -105,18 +107,58 @@ static int __init arm_idle_init(void) if (ret <= 0) return ret ? : -ENODEV; + ret = cpuidle_register_driver(drv); + if (ret) { + pr_err("Failed to register cpuidle driver\n"); + return ret; + } + /* * Call arch CPU operations in order to initialize * idle states suspend back-end specific data */ for_each_possible_cpu(cpu) { ret = arm_cpuidle_init(cpu); + + /* + * Do not register the cpuidle device. This situation could + * happen when the low level PM was not able to initialize + * for any reaon. + */ + if (ret == -ENXIO) + continue; + if (ret) { pr_err("CPU %d failed to init idle CPU ops\n", cpu); - return ret; + goto out_fail; + } + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) { + pr_err("Failed to allocate cpuidle device\n"); + goto out_fail; + } + dev->cpu = cpu; + + ret = cpuidle_register_device(dev); + if (ret) { + pr_err("Failed to register cpuidle device for CPU %d\n", + cpu); + kfree(dev); + goto out_fail; } } - return cpuidle_register(drv, NULL); + return 0; +out_fail: + while (--cpu >= 0) { + dev = per_cpu(cpuidle_devices, cpu); + cpuidle_unregister_device(dev); + kfree(dev); + } + + cpuidle_unregister_driver(drv); + + return ret; } device_initcall(arm_idle_init);