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: 6684591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 149169F399 for ; Sat, 27 Jun 2015 03:08:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2FDB9204EA for ; Sat, 27 Jun 2015 03:08:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4AA8E20145 for ; Sat, 27 Jun 2015 03:07:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z8gQk-0000QK-7t; Sat, 27 Jun 2015 03:05:22 +0000 Received: from mail-pd0-f181.google.com ([209.85.192.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z8gOh-0006vX-27 for linux-arm-kernel@lists.infradead.org; Sat, 27 Jun 2015 03:03:16 +0000 Received: by pdjn11 with SMTP id n11so84891117pdj.0 for ; Fri, 26 Jun 2015 20:02:55 -0700 (PDT) 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=WqPtw85tE0Fs+6GbOlNKlrJd4wufcp1jm6GUuAEnCGY=; b=LQwD4CPAfHwjxeE/moWSvdI/ICvCtSprM4Ve3c/TQdBSV7EYYcr4SAupBQW6I8o+q7 yohV9ouKjtE03qC/EdAcmaqfr7bvkvrrNVCYjsUF1GOyDfXO4lnJYXdCjOZkDATgfVAu 5Ho7IodQLwG0Ws7MLw0A8bhOR4ITZPL2fEX9HvS4zEGrZXsiQSR8n5BS6l8pKpL2pSGd LZch8hoYs8Hk6D6EzOp7eaKecOEjDbINFkWxG99zMJ7dY18gqSYOQe0D/tgfpMm96EO5 9SAPEvluHHfZLJ5jF6/HPzmhLG5z7uIwiq0gcuxwkpeE0Kev2NEW8AlPUskJIwl3Pjjt cF4w== X-Gm-Message-State: ALoCoQlbRkevU8AbF+t3LS8QDhkrj+3M+/pO/3/lyv7Ft+QfYSPYDiYtFGC8MqQtLJV92Kl1t1sY 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150626_200315_181049_B27B71B7 X-CRM114-Status: GOOD ( 15.86 ) X-Spam-Score: -2.6 (--) Cc: k.kozlowski@samsung.com, linux-pm@vger.kernel.org, msivasub@codeaurora.org, geert@linux-m68k.org, Lina Iyer , agross@codeaurora.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);