From patchwork Tue Mar 24 09:54:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 46232 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 88B76214B0 for ; Tue, 24 Mar 2015 09:54:14 +0000 (UTC) Received: by labgq15 with SMTP id gq15sf31420564lab.0 for ; Tue, 24 Mar 2015 02:54:13 -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=bLebe56SCZNZqn5auOmVzC2nN3SEXdO8JKi2VGD15TA=; b=YI6hW6jJKo9YY2Lnnxmxd8fe3p+yDWgllIY7nt0VS4arrIZSFXY6qUDkHhNGZ3LN03 OiBUBuRCgy2mJCaE5fMezn2sw01awOc4Y0/iUiAqmclOoVF3E1hHnZkoG+nlaKroojz0 QB5L/wtEP/kG2eeHXr4zei3CUCZThB9xOvM29TnR0llG7ZlYfbwFjRM8dYNQK6Elz0mP r2bliy70axJ2M4dUGRHKbr0V0VwcrG7Q+TEe+Hxo1DRjvajYyFCUvJq/AJo6Ti5AKrlk GJQLuFOrHlyo27m+/BTrF3Uese3oCwl/PsVkcQDobF5FMT/UwYNoz3Oh6vm1yfdPlUZI WpGA== X-Gm-Message-State: ALoCoQnWACjW77wKTcbAgQeDtM/zrt+zH/fn+IJfubTMoYFp+iQGooD7kTbZp/dIJ4lvJi4z9VII X-Received: by 10.112.118.203 with SMTP id ko11mr652166lbb.15.1427190853488; Tue, 24 Mar 2015 02:54:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.225.163 with SMTP id rl3ls241277lac.83.gmail; Tue, 24 Mar 2015 02:54:13 -0700 (PDT) X-Received: by 10.112.92.66 with SMTP id ck2mr2894867lbb.105.1427190853344; Tue, 24 Mar 2015 02:54:13 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id ds4si2650730lac.34.2015.03.24.02.54.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Mar 2015 02:54:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbsy1 with SMTP id sy1so137002908lbb.1 for ; Tue, 24 Mar 2015 02:54:13 -0700 (PDT) X-Received: by 10.152.178.197 with SMTP id da5mr3150791lac.56.1427190853185; Tue, 24 Mar 2015 02:54:13 -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 k9csp1340855lbq; Tue, 24 Mar 2015 02:54:12 -0700 (PDT) X-Received: by 10.68.110.195 with SMTP id ic3mr6273319pbb.124.1427190850983; Tue, 24 Mar 2015 02:54:10 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gs2si4815362pac.152.2015.03.24.02.54.09; Tue, 24 Mar 2015 02:54:10 -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 S1752192AbbCXJyI (ORCPT + 5 others); Tue, 24 Mar 2015 05:54:08 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:33400 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752073AbbCXJyH (ORCPT ); Tue, 24 Mar 2015 05:54:07 -0400 Received: by wixw10 with SMTP id w10so49814427wix.0 for ; Tue, 24 Mar 2015 02:54:05 -0700 (PDT) X-Received: by 10.194.86.135 with SMTP id p7mr6248054wjz.89.1427190845613; Tue, 24 Mar 2015 02:54:05 -0700 (PDT) Received: from mai.lan (135-224-190-109.dsl.ovh.fr. [109.190.224.135]) by mx.google.com with ESMTPSA id ey10sm10328649wib.2.2015.03.24.02.54.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Mar 2015 02:54:04 -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 V5 1/2] ARM: cpuidle: Register per cpuidle device Date: Tue, 24 Mar 2015 10:54:01 +0100 Message-Id: <1427190842-30675-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20150323225828.GC15435@e102568-lin.cambridge.arm.com> References: <20150323225828.GC15435@e102568-lin.cambridge.arm.com> 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.177 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: , If the cpuidle init cpu operation returns -ENXIO, therefore reporting HW failure or misconfiguration, the CPUidle driver skips the respective cpuidle device initialization because the associated platform back-end HW 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 | 45 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index 1c94b88..545069d 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,57 @@ 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); + + /* + * Skip the cpuidle device initialization if the reported + * failure is a HW misconfiguration/breakage (-ENXIO). + */ + 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);