From patchwork Fri Aug 26 20:17:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 9301967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4B7660757 for ; Fri, 26 Aug 2016 20:18:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C62F92963A for ; Fri, 26 Aug 2016 20:18:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA38229651; Fri, 26 Aug 2016 20:18:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48C262963A for ; Fri, 26 Aug 2016 20:18:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754141AbcHZUSi (ORCPT ); Fri, 26 Aug 2016 16:18:38 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:34757 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751779AbcHZUS3 (ORCPT ); Fri, 26 Aug 2016 16:18:29 -0400 Received: by mail-pf0-f177.google.com with SMTP id p64so31715066pfb.1 for ; Fri, 26 Aug 2016 13:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v4giJ2zY4MiQdi5mekBGlbnd8eFD9Eif5QFU83FhFJc=; b=Gb0zwmd3Z6hheG6JPt3nuDD1vGRTI9TMzlSm9mCaV83Yo/fXN+LahNjh/kuegsus72 dbZW3r5kWywpY+GyCOlZQBWnCWXxHIY84NvUJ3SOHiP8QEJAXIYQWzr4Cunk51+O4Qp8 GrJf4/MfHtwtyL6G01y5j6+yTAvSYcHf2wI8I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v4giJ2zY4MiQdi5mekBGlbnd8eFD9Eif5QFU83FhFJc=; b=S3si5ZYCO6G2toFRa8PNqWfjQs4E/6zP0xisS4UD2x2K9sO6pN8JNrP9GgOeR7EPEr KCJK0nwB48HopgkryEHn0xhIBlPM4/QtbnbIWT+1QIKHBgljVAjpASZYPDyM4hVsdIJZ 74Vbasoi8fVbhYZIl+/sNZlDWTu3n24usuMdEhBVAmDTlBQjg5YGh/iAqYlQxIMhpZH/ HJV1rsDlbU4d6XK/j0BIFYVT5giLnjn4dgW0lPICUrNEXKnU/Vd3hwqvxWE4Nr8b5vws 82RDuYcNSQO5en5jf/EHWgIDH91fpCQOdGqlFfcklact18zST0Ybw6gsrWasZ/hQ61VI 6HTw== X-Gm-Message-State: AE9vXwMHGPFPkv0rNtaRhXxu/wGvNxxGL0jhkJNzmynhl3IzRS2AClIZSxYEKCOWJXjhX8iS X-Received: by 10.98.31.219 with SMTP id l88mr9187659pfj.155.1472242709250; Fri, 26 Aug 2016 13:18:29 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id m128sm30761463pfm.42.2016.08.26.13.18.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Aug 2016 13:18:28 -0700 (PDT) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: andy.gross@linaro.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, brendan.jackman@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, Juri.Lelli@arm.com, Lina Iyer Subject: [PATCH v5 06/16] drivers: cpu: Setup CPU devices to do runtime PM Date: Fri, 26 Aug 2016 14:17:48 -0600 Message-Id: <1472242678-33700-7-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472242678-33700-1-git-send-email-lina.iyer@linaro.org> References: <1472242678-33700-1-git-send-email-lina.iyer@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP CPU devices just like any other device, can do runtime PM. However, CPU devices may only do runtime only when IRQs are disabled. The devices must be set as IRQ safe. Cc: Kevin Hilman Cc: Rafael J. Wysocki Signed-off-by: Lina Iyer --- drivers/base/cpu.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 691eeea..c1e5e77 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "base.h" @@ -344,6 +345,21 @@ static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env) } #endif +#ifdef CONFIG_PM +static void cpu_runtime_pm_init(struct device *dev) +{ + pm_runtime_irq_safe(dev); + pm_runtime_enable(dev); + if (cpu_online(dev->id)) { + pm_runtime_get_noresume(dev); + pm_runtime_set_active(dev); + } +} +#else +static void cpu_runtime_pm_init(struct device *dev) +{ } +#endif + /* * register_cpu - Setup a sysfs device for a CPU. * @cpu - cpu->hotpluggable field set to 1 will generate a control file in @@ -376,6 +392,8 @@ int register_cpu(struct cpu *cpu, int num) if (!error) register_cpu_under_node(num, cpu_to_node(num)); + cpu_runtime_pm_init(&cpu->dev); + return error; }