From patchwork Sat Jun 27 03:02:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 50390 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 7C939228FD for ; Sat, 27 Jun 2015 03:03:12 +0000 (UTC) Received: by laer2 with SMTP id r2sf31260694lae.3 for ; Fri, 26 Jun 2015 20:03:11 -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=nawTKunrOGrZCH6lCfgepSMCp+57piw3AfndzQ9aQYc=; b=NHBc8jmHj6cgT2ECnl3qDVZ51IWr2cLR3EJ0s7hmbuCvwfHBdc/82rpUADmD1aLHtx /kAzlRoF0paXkuEsgXPqltyKXToGxVvue1aD7ui/8zZpjOxoT/isbi/56n0djFEByOUk HP82k+roIK0wAL0TDv/LqQtQ1pC5LSgLWOAzwEsKA31W8AAi6MMv26fBecdlo26iPX72 SPG5M9nvKoug574Lw6Lchwyy0BEwvW8DhKZ8TxQsfBtmxcYa4U2GL+TD7cJNtIs8jHd6 qrYrMygtMt/CNEZuApz5tHzSe0RCkE87IiXhMMpG/h0z48qo7AgHDtLaiatfycJ4/ufj qnxw== X-Gm-Message-State: ALoCoQmH7h6PB7dwUjGuI6h7AZrD8TmWmmBL1HeVRE2t24+f2515CXfyLJCUow81mNZsq+K63GYo X-Received: by 10.152.120.69 with SMTP id la5mr2569269lab.7.1435374191010; Fri, 26 Jun 2015 20:03:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.2 with SMTP id t2ls605197laz.8.gmail; Fri, 26 Jun 2015 20:03:10 -0700 (PDT) X-Received: by 10.152.19.198 with SMTP id h6mr4351664lae.26.1435374190797; Fri, 26 Jun 2015 20:03:10 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id bx11si28973686lbb.141.2015.06.26.20.03.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2015 20:03:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lagx9 with SMTP id x9so74573034lag.1 for ; Fri, 26 Jun 2015 20:03:10 -0700 (PDT) X-Received: by 10.152.26.163 with SMTP id m3mr4342761lag.86.1435374190698; Fri, 26 Jun 2015 20:03:10 -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 hn6csp295215lbb; Fri, 26 Jun 2015 20:03:09 -0700 (PDT) X-Received: by 10.70.101.39 with SMTP id fd7mr9382763pdb.9.1435374178341; Fri, 26 Jun 2015 20:02:58 -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.57; Fri, 26 Jun 2015 20:02:58 -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 S1751710AbbF0DC4 (ORCPT + 11 others); Fri, 26 Jun 2015 23:02:56 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:34462 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751720AbbF0DCz (ORCPT ); Fri, 26 Jun 2015 23:02:55 -0400 Received: by pdbep18 with SMTP id ep18so63070409pdb.1 for ; Fri, 26 Jun 2015 20:02:55 -0700 (PDT) X-Received: by 10.70.131.232 with SMTP id op8mr9136042pdb.156.1435374175166; Fri, 26 Jun 2015 20:02:55 -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.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jun 2015 20:02:54 -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 07/16] arm: domain: Synchronize CPU device runtime PM usage with idle state Date: Fri, 26 Jun 2015 21:02:27 -0600 Message-Id: <1435374156-19214-8-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.48 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: , When a CPU is running, the runtime PM usage count should be incremented and decremented when the CPU is powers down. To ensure that this happens correctly, increment the runtime usage from that CPU. Signed-off-by: Lina Iyer --- arch/arm/kernel/domains.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/arm/kernel/domains.c b/arch/arm/kernel/domains.c index a27f825..59b0180 100644 --- a/arch/arm/kernel/domains.c +++ b/arch/arm/kernel/domains.c @@ -33,6 +33,14 @@ static int arm_pd_power_up(struct generic_pm_domain *genpd) return 0; } +static void run_cpu(void *unused) +{ + struct device *cpu_dev = get_cpu_device(smp_processor_id()); + + /* We are running, increment the usage count */ + pm_runtime_get_noresume(cpu_dev); +} + static int arm_domain_cpu_init(void) { int cpuid, ret = 0; @@ -50,13 +58,27 @@ static int arm_domain_cpu_init(void) if (cpu_online(cpuid)) { pm_runtime_set_active(cpu_dev); - pm_runtime_get_noresume(cpu_dev); + /* + * Execute the below on that 'cpu' to ensure that the reference + * counting is correct. Its possible that while this code is + * executing, the 'cpu' may be powerd down, but we may incorrectly + * increment the usage. By executing the get_cpu on the 'cpu', + * we can ensure that the 'cpu' and its usage count are matched. + */ + smp_call_function_single(cpuid, run_cpu, NULL, true); } else { pm_runtime_set_suspended(cpu_dev); } pm_runtime_irq_safe(cpu_dev); pm_runtime_enable(cpu_dev); + /* + * We attempt to attach the device to genpd again. We would + * have failed in our earlier attempt to attach to the domain + * provider as the CPU device would not have been IRQ safe, + * while the domain is defined as IRQ safe. IRQ safe domains + * can only have IRQ safe devices. + */ ret = genpd_dev_pm_attach(cpu_dev); if (ret) { dev_warn(cpu_dev, "%s: Unable to attach to power-domain: %d\n", __func__, ret);