From patchwork Fri Mar 3 21:48:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 9603597 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 31096602B4 for ; Fri, 3 Mar 2017 21:49:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22D4E285D2 for ; Fri, 3 Mar 2017 21:49:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 177B928614; Fri, 3 Mar 2017 21:49:12 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 82C9E285D2 for ; Fri, 3 Mar 2017 21:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=aUc9E+a74Skt9/6OlSdUL462x7N3haC0f7XzxXIe3cA=; b=Wcw6MOxBCrEpuRGZDolY7X+BbX MITDHWBvz88Sp/kle6eBJCibsFEGTmSkEFuM5+qldv+pqf0rQLWG43bfPC66joqtBEer6lmWixNRC bV6ZR2IINoNlZpL3kp0TZTKgWxFG6vxGyxo5yB0i/nmXueoZ712h37163ucPgKjJAyKY/mopgeW3H GkHoNlGjvAHRK5/Qar9eBtjZTel9OwFh3E2ctgsFhgqqDS0c2+ahkmFbzNrynYKeHXW8v8ThhS1Kt x6YJzG5C4Qlv+avBVAwcHE6Lct/Lu36ZDdI3bWTYQjH+Rw55NoTn7pc1/0RbzalIUH6rtVSbmYpHg ojuTxbQw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cjv4Y-00007j-Iq; Fri, 03 Mar 2017 21:49:10 +0000 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjv49-00004w-IF for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2017 21:48:47 +0000 Received: by mail-pg0-x235.google.com with SMTP id s67so47903741pgb.3 for ; Fri, 03 Mar 2017 13:48:25 -0800 (PST) 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=5ncIq3rOLiB5juXFGE67wrPM3sZL99bwDsgIi3smaAE=; b=UjGy1cq99ShJcycz+vs3Im0FXaLOMNhLqhp8Xpv1XHbZxoWMa7DdgaXbG6xRZ7FVft 4x0bOahvRyg009zmQah9Fq6RAaq7DmqSOccfRUtfIyUaqOCYE9teQlc6PpFK0zKsZLw7 x2pn1setm/sejj/46x1sDQO/JEu+jRv1obMFU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5ncIq3rOLiB5juXFGE67wrPM3sZL99bwDsgIi3smaAE=; b=p3YAj4MdxNnzhGACWARsGfvjOLN3+Eqri6mOZVR+jcHGuz1lYattTPayy6zfk2icdd VZQW+VKFuxKFTK/VvLHbXJN8IFEB78+L4kvXcmlNgKjM+rCQoIL8SnTh2W9qIk8DKjdA XoIADDWtdj11zv0RNZtBJ0SMGWGOE4GXMhsjR6DvXy72V5kC7CCDk3yL06uYMEhrwt72 4HK+a+g2pUrRC1Y7bL9yOMcW80aYtw0SidhbmBHrQVmsDKRb+rLqYSRIoPg3g9xBs3cq eRR/fF3DopodRLcUFut7aCxM3f1panHCax2u+NL4f9KBg4SL8CZ3Gt4960obw9ilmcxQ Nocw== X-Gm-Message-State: AMke39lSIvHeghgnjtNNJzq7hK9scZnCh7GshNyiFJi220K3NR5+REjgser7q26Ditr8bxTC X-Received: by 10.99.6.76 with SMTP id 73mr5919377pgg.83.1488577704619; Fri, 03 Mar 2017 13:48:24 -0800 (PST) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id q23sm25200585pfg.63.2017.03.03.13.48.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 13:48:23 -0800 (PST) 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 Subject: [PATCH V5 1/6] drivers: cpuidle: Read CPU's idle state from PM domain Date: Fri, 3 Mar 2017 13:48:12 -0800 Message-Id: <1488577697-127445-2-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488577697-127445-1-git-send-email-lina.iyer@linaro.org> References: <1488577697-127445-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170303_134845_632701_AEBF462F X-CRM114-Status: GOOD ( 13.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lorenzo.pieralisi@arm.com, Juri.Lelli@arm.com, linux-arm-msm@vger.kernel.org, sboyd@codeaurora.org, brendan.jackman@arm.com, sudeep.holla@arm.com, andy.gross@linaro.org, Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently CPUs idle states and idle states of its parent are represented in a flattened model by the cpu-dile-states property of the CPU node. The CPUs idle states are followed by its cluster idle states. With the introduction of CPU PM domains, the CPUs and domain idle states may be represented hierarchically as part of the domain DT definition. This would mean presenting idle state information in 2 places - CPU nodes for the CPU and the cluster's with the PM domains. Also, it makes sense to define domains around each individual CPU since each of them is a power domain in its own right. The CPU idle states can now be represented as its domain's idle state, defined by the domain-idle-states property. This avoids presenting idle states in multiple places in the DT. Modify the DT-based cpuidle driver to check for the presence of a CPU's domain and if present read the domain-idle-states of the PM domain and if the CPU's domain is absent, revert to reading in the cpu-idle-states property of the CPU DT node. Suggested-by: Sudeep Holla Signed-off-by: Lina Iyer --- drivers/cpuidle/dt_idle_states.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c index ffca4fc..4df7d45 100644 --- a/drivers/cpuidle/dt_idle_states.c +++ b/drivers/cpuidle/dt_idle_states.c @@ -98,6 +98,39 @@ static int init_state_node(struct cpuidle_state *idle_state, } /* + * Get the state node at @idx. State node may be defined as domain's idle state + * if the CPU has its own domain or defined as CPU's idle state if it doesn't + * have a domain provider. + */ +static struct device_node *get_state_node(struct device_node *cpu_node, + unsigned int idx) +{ + struct device_node *dn; + bool cpu_has_domain = false; + struct of_phandle_args args; + const char *property; + int err; + + err = of_parse_phandle_with_args(cpu_node, "power-domains", + "#power-domain-cells", 0, &args); + if (!err) { + dn = args.np; + err = of_count_phandle_with_args(dn, "domain-idle-states", + NULL); + cpu_has_domain = (err > 0); + } + + if (cpu_has_domain) { + property = "domain-idle-states"; + } else { + property = "cpu-idle-states"; + dn = cpu_node; + } + + return of_parse_phandle(dn, property, idx); +} + +/* * Check that the idle state is uniform across all CPUs in the CPUidle driver * cpumask */ @@ -118,8 +151,7 @@ static bool idle_state_valid(struct device_node *state_node, unsigned int idx, for (cpu = cpumask_next(cpumask_first(cpumask), cpumask); cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpumask)) { cpu_node = of_cpu_device_node_get(cpu); - curr_state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - idx); + curr_state_node = get_state_node(cpu_node, idx); if (state_node != curr_state_node) valid = false; @@ -176,7 +208,7 @@ int dt_init_idle_driver(struct cpuidle_driver *drv, cpu_node = of_cpu_device_node_get(cpumask_first(cpumask)); for (i = 0; ; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = get_state_node(cpu_node, i); if (!state_node) break;