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: 6684611 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 B92539F399 for ; Sat, 27 Jun 2015 03:09:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECE5920639 for ; Sat, 27 Jun 2015 03:09: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 151F32060D for ; Sat, 27 Jun 2015 03:09:00 +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 1Z8gRK-0000j4-9Z; Sat, 27 Jun 2015 03:05:58 +0000 Received: from mail-pa0-f51.google.com ([209.85.220.51]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z8gOj-0006vc-W8 for linux-arm-kernel@lists.infradead.org; Sat, 27 Jun 2015 03:03:19 +0000 Received: by pabvl15 with SMTP id vl15so77503243pab.1 for ; Fri, 26 Jun 2015 20:02:56 -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=7Q3ZYCYR+nlOrfCtb9wcm7wAwGpDVGRiC5iRGxpkLhk=; b=JmmRY8MgKF8X43HfimNNNyO//ILe3/w7E5cYYK///x83ycNtfvjWEgjIyQEzPWq8sM HavCmlo3EwHHOzQ7RU6bovam5Kx9GQSIOUQFLm+T/a2MaJZ+hNkCzGvHuBizWv6UGlRr jBaroK6PZAi3iGex3vn31EXu8lYMeQDDMXKOz3Q9cTNdSwmM5Cfqnc3GLotNyIvjArbX 3rFoQlYeD7Vj/BoRTIPW1J+G4lJmWH+kQhj6PBmvUL70ey+UHsrcQseQa1ZGAlrerkm/ W2JLRZ2BCIuQ6XyNmCpRaWqwHPu3AeMrZPEsC+IvLTsQtXhEBhlaPu3VXBs9utN7YjxW Pyog== X-Gm-Message-State: ALoCoQkcflKr1/WYzmWoqntzxUiaed6L8W9ZrSNin5p3+1htxE6irZ3MHxwx19M1qMtIsdCeouXD 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150626_200318_094306_F0994977 X-CRM114-Status: GOOD ( 14.47 ) 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 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;