From patchwork Fri Sep 5 17:34:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 36884 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CBACE202E4 for ; Fri, 5 Sep 2014 17:35:06 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id r2sf56541293igi.0 for ; Fri, 05 Sep 2014 10:35:06 -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:content-type :content-transfer-encoding; bh=vZLRTUPTaL6/M6XWno1tTs8WtGrOl1ML/Zi8TpfIxCg=; b=B6rfmXzgq/yQm+oAVtAG+hSRRn7Ug5MVkfgFt+T+PTeb3Ysl/Ec/dnS3x15sH5uMG6 mFhboKgMeQhktBfGakrL8ZAQFBonczE6uFp7ovWR4t9qeDQ2intWG1QvFBqCW6YqCE2X keOIIvDkXbpm32G+IuKrph8zPASpDIc/juITQrhOpOHBSN3odBD5LAXQ0PuzcOchFnzg B7lHeeLd79LQcJVDmAAkTdQvqbwmo6Z3AJi1HNDkz0Cnc7gYYGqZW1UjZ+BpX5XaQX3R +G8lPFAbxEtBuxXWGGukYmwUvaH0H7AyjJ05i12uR3IBL4BfXn/tLVEHiBiNn0N4YiOd mM2Q== X-Gm-Message-State: ALoCoQmNXVwFzUY2rrqZ9uYbGDNhORKM3g/9f8zIl+XUZRMQb+uWO/y+6JcbJ7x3gahFoHK4qL57 X-Received: by 10.42.21.209 with SMTP id l17mr7244306icb.8.1409938506370; Fri, 05 Sep 2014 10:35:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.47 with SMTP id w44ls834725qgw.95.gmail; Fri, 05 Sep 2014 10:35:06 -0700 (PDT) X-Received: by 10.52.6.138 with SMTP id b10mr1772194vda.84.1409938506145; Fri, 05 Sep 2014 10:35:06 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id x11si1808174vdg.56.2014.09.05.10.35.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 10:35:06 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id lf12so12530907vcb.6 for ; Fri, 05 Sep 2014 10:35:06 -0700 (PDT) X-Received: by 10.220.202.9 with SMTP id fc9mr2404495vcb.40.1409938506066; Fri, 05 Sep 2014 10:35:06 -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.221.45.67 with SMTP id uj3csp116242vcb; Fri, 5 Sep 2014 10:35:05 -0700 (PDT) X-Received: by 10.70.135.137 with SMTP id ps9mr23937428pdb.13.1409938500276; Fri, 05 Sep 2014 10:35:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yn9si5337604pac.118.2014.09.05.10.34.59 for ; Fri, 05 Sep 2014 10:35:00 -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 S1754213AbaIERe5 (ORCPT + 5 others); Fri, 5 Sep 2014 13:34:57 -0400 Received: from service87.mimecast.com ([91.220.42.44]:54519 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754739AbaIERey (ORCPT ); Fri, 5 Sep 2014 13:34:54 -0400 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 05 Sep 2014 18:34:52 +0100 Received: from red-moon.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 5 Sep 2014 18:34:51 +0100 From: Lorenzo Pieralisi To: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Cc: devicetree@vger.kernel.org, Lorenzo Pieralisi , Mark Rutland , Sudeep Holla , Catalin Marinas , Will Deacon , Charles Garcia Tobin , Nicolas Pitre , Rob Herring , Grant Likely , Peter De Schrijver , Santosh Shilimkar , Daniel Lezcano , Amit Kucheria , Vincent Guittot , Antti Miettinen , Stephen Boyd , Kevin Hilman , Sebastian Capella , Mark Brown , Paul Walmsley , Chander Kashyap , Geoff Levand , Bartlomiej Zolnierkiewicz , Ashwin Chaugule , Lina Iyer Subject: [PATCH v9 3/8] arm64: kernel: introduce cpu_init_idle CPU operation Date: Fri, 5 Sep 2014 18:34:52 +0100 Message-Id: <1409938498-17984-4-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409938498-17984-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1409938498-17984-1-git-send-email-lorenzo.pieralisi@arm.com> X-OriginalArrivalTime: 05 Sep 2014 17:34:51.0168 (UTC) FILETIME=[B274D200:01CFC92F] X-MC-Unique: 114090518345200701 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: lorenzo.pieralisi@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 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: , The CPUidle subsystem on ARM64 machines requires the idle states implementation back-end to initialize idle states parameter upon boot. This patch adds a hook in the CPU operations structure that should be initialized by the CPU operations back-end in order to provide a function that initializes cpu idle states. This patch also adds the infrastructure to arm64 kernel required to export the CPU operations based initialization interface, so that drivers (ie CPUidle) can use it when they are initialized at probe time. Reviewed-by: Catalin Marinas Signed-off-by: Lorenzo Pieralisi --- arch/arm64/include/asm/cpu_ops.h | 3 +++ arch/arm64/include/asm/cpuidle.h | 13 +++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/cpuidle.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 arch/arm64/include/asm/cpuidle.h create mode 100644 arch/arm64/kernel/cpuidle.c diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index d7b4b38..47dfa31 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -28,6 +28,8 @@ struct device_node; * enable-method property. * @cpu_init: Reads any data necessary for a specific enable-method from the * devicetree, for a given cpu node and proposed logical id. + * @cpu_init_idle: Reads any data necessary to initialize CPU idle states from + * devicetree, for a given cpu node and proposed logical id. * @cpu_prepare: Early one-time preparation step for a cpu. If there is a * mechanism for doing so, tests whether it is possible to boot * the given CPU. @@ -47,6 +49,7 @@ struct device_node; struct cpu_operations { const char *name; int (*cpu_init)(struct device_node *, unsigned int); + int (*cpu_init_idle)(struct device_node *, unsigned int); int (*cpu_prepare)(unsigned int); int (*cpu_boot)(unsigned int); void (*cpu_postboot)(void); diff --git a/arch/arm64/include/asm/cpuidle.h b/arch/arm64/include/asm/cpuidle.h new file mode 100644 index 0000000..b52a993 --- /dev/null +++ b/arch/arm64/include/asm/cpuidle.h @@ -0,0 +1,13 @@ +#ifndef __ASM_CPUIDLE_H +#define __ASM_CPUIDLE_H + +#ifdef CONFIG_CPU_IDLE +extern int cpu_init_idle(unsigned int cpu); +#else +static inline int cpu_init_idle(unsigned int cpu) +{ + return -EOPNOTSUPP; +} +#endif + +#endif diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 383d81d..be78980 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -27,6 +27,7 @@ arm64-obj-$(CONFIG_PERF_EVENTS) += perf_regs.o arm64-obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o arm64-obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o arm64-obj-$(CONFIG_ARM64_CPU_SUSPEND) += sleep.o suspend.o +arm64-obj-$(CONFIG_CPU_IDLE) += cpuidle.o arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o arm64-obj-$(CONFIG_KGDB) += kgdb.o arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c new file mode 100644 index 0000000..19d17f5 --- /dev/null +++ b/arch/arm64/kernel/cpuidle.c @@ -0,0 +1,31 @@ +/* + * ARM64 CPU idle arch support + * + * Copyright (C) 2014 ARM Ltd. + * Author: Lorenzo Pieralisi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include + +#include +#include + +int cpu_init_idle(unsigned int cpu) +{ + int ret = -EOPNOTSUPP; + struct device_node *cpu_node = of_cpu_device_node_get(cpu); + + if (!cpu_node) + return -ENODEV; + + if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_init_idle) + ret = cpu_ops[cpu]->cpu_init_idle(cpu_node, cpu); + + of_node_put(cpu_node); + return ret; +}