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: 9301955 X-Patchwork-Delegate: agross@codeaurora.org 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 553E960757 for ; Fri, 26 Aug 2016 20:18:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4714F2963A for ; Fri, 26 Aug 2016 20:18:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C02729652; Fri, 26 Aug 2016 20:18:35 +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 C98472963A for ; Fri, 26 Aug 2016 20:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753891AbcHZUSd (ORCPT ); Fri, 26 Aug 2016 16:18:33 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:35511 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752977AbcHZUSa (ORCPT ); Fri, 26 Aug 2016 16:18:30 -0400 Received: by mail-pf0-f182.google.com with SMTP id x72so31716913pfd.2 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=LMQ3FOqS/W1h6Q1xzq0LSNSSsAmILyvVFVTKD+uohriTaAp9sIH46aj0vcvjSfHw5v kq//peAovRzY4U0vaHLG8UYOZJOShGKDRrHHqtbseZ/rY6Px5F/ML+ffgIMQ5TRiFaaP Z5JMxaf8w68yNHkN/XWeMGftsay4G8eYkDhzK+LujFWjrAsSMM1IsDNIkeB4KzoMC/1W Mt0we4kFXM7pl+IZpq9ddBIftQMbM28V5VW5Ljc7f1/8c3s5p4QgcEG63/5SeQmjYbOa yuCEacIgv+w0KkQsO0V4+w09nhAP06xpLDbiw3Xg79jdkXhP1rXOlxOH/8rBGiwRx17k U1Iw== X-Gm-Message-State: AE9vXwNlPk3QvIgLjfAT2B5l3RvhQRIVOeZYezD12Cbw5m04IXHrzDZXSys7vHfPB1tbrp03 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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; }