From patchwork Sat Jun 27 03:02:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 50391 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2E925228FD for ; Sat, 27 Jun 2015 03:03:15 +0000 (UTC) Received: by lagh6 with SMTP id h6sf31274107lag.0 for ; Fri, 26 Jun 2015 20:03: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=ivV/46/QdbqJIe+Vj9bLlqyK9Bed0ROdQwSBSlCkTzI=; b=ZrAVEW0p2QBg8Di3ZxHnxE22Fpe6SVKXpFFwquofI3SFF9ZWG0KPkW/QhmPaeILRV2 lAB3MoI21vBEzVU1A0M3zS/gaFSZsavfq3HeSn+THcRCv4zcfSAOi00bUg0bUYXCFmwK f1y2NYLOTwsjPpzFPih0O6D68g8r1FBYCR0u/pCbObx0XKYaqOaqDG28fYUb7bPgF3MJ rmsNG3b/9e03jUUV9mHRHvrFSQo7MCpUzPnzOorQVh6M1WzicahF5IwknqLYAd0Y09uQ tc6R6OHYu47PZRTUehqFEnwFlybTwBkgZVB4nsuye69XF6GboWKKtsfYIilMzmESHpxp XAOQ== X-Gm-Message-State: ALoCoQk/aP/2PrbfTTdnXoYlIAYZK/g6TzIDE3HLwq8/+AlWYqdx8EAow/3QFlkf3+vgZzFwwfD8 X-Received: by 10.112.188.233 with SMTP id gd9mr3192206lbc.12.1435374193346; Fri, 26 Jun 2015 20:03:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.184.168 with SMTP id ev8ls569741lac.44.gmail; Fri, 26 Jun 2015 20:03:13 -0700 (PDT) X-Received: by 10.112.137.232 with SMTP id ql8mr4283573lbb.121.1435374193188; Fri, 26 Jun 2015 20:03:13 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id yh3si2037614lab.144.2015.06.26.20.03.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2015 20:03:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lagx9 with SMTP id x9so74573490lag.1 for ; Fri, 26 Jun 2015 20:03:13 -0700 (PDT) X-Received: by 10.112.126.101 with SMTP id mx5mr4387976lbb.35.1435374193092; Fri, 26 Jun 2015 20:03: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.108.230 with SMTP id hn6csp295231lbb; Fri, 26 Jun 2015 20:03:12 -0700 (PDT) X-Received: by 10.70.38.105 with SMTP id f9mr9456353pdk.14.1435374179420; Fri, 26 Jun 2015 20:02:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay3si53186466pbc.54.2015.06.26.20.02.58; Fri, 26 Jun 2015 20:02:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751698AbbF0DC5 (ORCPT + 11 others); Fri, 26 Jun 2015 23:02:57 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:35888 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbbF0DC5 (ORCPT ); Fri, 26 Jun 2015 23:02:57 -0400 Received: by pdcu2 with SMTP id u2so84846735pdc.3 for ; Fri, 26 Jun 2015 20:02:56 -0700 (PDT) X-Received: by 10.66.146.226 with SMTP id tf2mr9541300pab.4.1435374176749; Fri, 26 Jun 2015 20:02:56 -0700 (PDT) Received: from ubuntu.localdomain (c-24-8-37-141.hsd1.co.comcast.net. [24.8.37.141]) by mx.google.com with ESMTPSA id j7sm34787756pdp.83.2015.06.26.20.02.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jun 2015 20:02:56 -0700 (PDT) From: Lina Iyer To: rjw@rjwysocki.net, ulf.hansson@linaro.org, khilman@linaro.org Cc: geert@linux-m68k.org, k.kozlowski@samsung.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, msivasub@codeaurora.org, agross@codeaurora.org, Lina Iyer Subject: [PATCH RFC v2 08/16] arm: domain: Handle CPU online reference counting Date: Fri, 26 Jun 2015 21:02:28 -0600 Message-Id: <1435374156-19214-9-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435374156-19214-1-git-send-email-lina.iyer@linaro.org> References: <1435374156-19214-1-git-send-email-lina.iyer@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lina.iyer@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.215.51 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: , Ensure that the CPU device usage count is incremented for a CPU that just came online. CPUs coming online do not follow the same code path as CPUs warm booting back to CPUIdle. Register for hotplug notifier and ensure the reference count is incremented correctly. Signed-off-by: Lina Iyer --- arch/arm/kernel/domains.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/arch/arm/kernel/domains.c b/arch/arm/kernel/domains.c index 59b0180..680c3fb 100644 --- a/arch/arm/kernel/domains.c +++ b/arch/arm/kernel/domains.c @@ -41,10 +41,49 @@ static void run_cpu(void *unused) pm_runtime_get_noresume(cpu_dev); } +static int cpu_online_notifier(struct notifier_block *n, + unsigned long action, void *hcpu) +{ + int cpu = (unsigned long)hcpu; + struct device *dev = get_cpu_device(cpu); + + switch (action) { + case CPU_STARTING: + case CPU_STARTING_FROZEN: + /* + * Attach the cpu to its domain if the cpu is coming up + * for the first time. + * Called from the cpu that is coming up. + */ + pm_runtime_set_active(dev); + pm_runtime_get_noresume(dev); + break; + + default: + return NOTIFY_DONE; + } + + return NOTIFY_OK; +} + +static struct notifier_block hotplug_notifier = { + .notifier_call = cpu_online_notifier, +}; + static int arm_domain_cpu_init(void) { int cpuid, ret = 0; + /* + * Register for hotplug notifier, because not all CPUs + * may be online at this time. Also, hotplug entry path is not + * the same as warm boot. So the reference counting would have + * to be adjusted here accordingly. + * Register early, incase, a core comes online, + * while we are executing this. + */ + register_cpu_notifier(&hotplug_notifier); + /* Find any CPU nodes with a phandle to this power domain */ for_each_possible_cpu(cpuid) { struct device *cpu_dev;