From patchwork Thu Oct 10 11:39:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 175756 Delivered-To: patches@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2163052ill; Thu, 10 Oct 2019 04:41:52 -0700 (PDT) X-Received: by 2002:a2e:b4f7:: with SMTP id s23mr5770302ljm.111.1570707623470; Thu, 10 Oct 2019 04:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570707623; cv=none; d=google.com; s=arc-20160816; b=BtJatG8PHDVTcU8Tx6qEzSOJDPpw5PNB5I4u8QMDxwLpbEHYU+AKbsQ3pHHbaYQ6uX th+N99jTFz13hM0lyHkFt/h+7ZwRc4C2Z4iA984qPXf32QuvgrO23H8QCGN/Er/XRL7V S17QkWjWCy+JVnYu5zm5dPxploz/AsvTuRXxQsTrGZJCm8Xmb8fzFzfpjEeF0q8iLeJl RTJ5CxeU2tkwAyhfal8hOMM8hBcNSdRSrtBCsOqg8UVGf4J2z6Xq+7MGrFPXzIHEvv6q /XAJoYmkZHHBCRr5FL2i1ZC+hWql98BZQBXWZ9O4E2DZ9hoeNjeD3z9sJC1IInbf4+dQ 0r4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xwB/tavfIMYf7rxHdkrDdviMkDSYXD3kklyLW60B66Q=; b=q6Ad0UAsMOpYLbeP7uKwTM4QEpsuNHn6eQz9Fq7mfn3CMPREc40D7R4pTEpjSb66aG hZ9o8Y3sBrR6HBe9kxoO/orRQ04UP+FCtI7aao5BkU0SJ3u4RhqSLfYgDQwgUiw/hPXM DkhmPpNs5nNYjz1IP5VvELUzSrg42TJpvIYyrlcqQl/6oRbSA9DYBuglgN4uPvHc04rY rBT9wKD63DAPI0eSfSnY7tSxq+qLrnT02RUbYk5SJhiw52x3QQO5fNfIxAESU2Tmcgrj zV5iUqO3iHo9zViOVeGKA7joZYgKOfkcGlh5Q0K2EuUpssDUUQ9rS8TzDVxa5D4FiVu7 /pLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y5fnfZfz; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m10sor3309382ljg.4.2019.10.10.04.40.22 for (Google Transport Security); Thu, 10 Oct 2019 04:40:23 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y5fnfZfz; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=xwB/tavfIMYf7rxHdkrDdviMkDSYXD3kklyLW60B66Q=; b=y5fnfZfzF20HGrbuklXhoX4IRAb3sw2pVHlyIgINlkZsqTCt4OVzOnIglZ5AC79CtD DsNOJpfSilfGfXZtv/tEgCB3gQiuhIGvs1zshF7zwNcTf2qOF8Fc/rMwNcZXiZTL+kw6 Yzr2TdiZrnORg1wGpq19yH9Xcs0CIUPV2lm1fsXVYSjXlq+ZlST41yjYA2oN1KG7fjS6 5gBBGJP6W0zkh27WfEp5bCy2cXFBBYwBVSQxDFzIbvzoUWu2TihJdw0pV2UQGtwkzvsY tHxQK36pjsfWSB57iJO/4O/taNsevtQefN+dNqFOeyJ3soL1660gFAXKDgtQIhwhU66S B0UQ== 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=xwB/tavfIMYf7rxHdkrDdviMkDSYXD3kklyLW60B66Q=; b=nMmCoCFB6v8kr6aQHGxgLUgz2UP5C6jpzwaEeKyOjs4v6cd1H2ytUk4WzVGOjRMj8h RDMzY4tiB29x0H9c8UeMBiftmiJdtHzkYY2svWwWtTYWONk/ch4yGgGw7Tt3WRFOUOR3 0gkg0u8RX1n2ZVu2yvxG88C2u+6/TY6GUh68lXQeN3iRaWp4zqprJ6CSxinTDTBBGkqt pO8cWrkfY1XfQ7WFyygIavNCjHgYMeSsW7+8Y0qjaQkWSq3Xvy+QTeR61l71+VVTb8CT 7DoYLTAA5bGnjDisMkxQIsy1l7kPis+eGsxlAMn7P0sQDtdnJajL4ECpV/aZ7OEeAj8v 2a9g== X-Gm-Message-State: APjAAAWMU8s1f4oFcc4pmRbqBWk72BUYWMzr2+YT+rQGEkZdfzUTwg19 e2Vx45N+gKoSGISt4u4vKvtgURSyY7txPg== X-Google-Smtp-Source: APXvYqx9XzUujAF/LwxrlZOzoBs1q0AvlrOroFuQxRIn7MA18US1H4Ia1dTMLsrPBuGfqUBKeebXeA== X-Received: by 2002:a2e:9f4d:: with SMTP id v13mr6239064ljk.226.1570707622756; Thu, 10 Oct 2019 04:40:22 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id p3sm1168937ljn.78.2019.10.10.04.40.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 04:40:22 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Daniel Lezcano , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Lina Iyer , linux-pm@vger.kernel.org Cc: Rob Herring , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 11/13] cpuidle: psci: Attach CPU devices to their PM domains Date: Thu, 10 Oct 2019 13:39:35 +0200 Message-Id: <20191010113937.15962-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010113937.15962-1-ulf.hansson@linaro.org> References: <20191010113937.15962-1-ulf.hansson@linaro.org> In order to enable a CPU to be power managed through its PM domain, let's try to attach it by calling psci_dt_attach_cpu() during the cpuidle initialization. psci_dt_attach_cpu() returns a pointer to the attached struct device, which later should be used for runtime PM, hence we need to store it somewhere. Rather than adding yet another per CPU variable, let's create a per CPU struct to collect the relevant per CPU variables. Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index a16467daf99d..1510422c7a53 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -23,7 +23,12 @@ #include "cpuidle-psci.h" #include "dt_idle_states.h" -static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +struct psci_cpuidle_data { + u32 *psci_states; + struct device *dev; +}; + +static DEFINE_PER_CPU_READ_MOSTLY(struct psci_cpuidle_data, psci_cpuidle_data); static DEFINE_PER_CPU(u32, domain_state); void psci_set_domain_state(u32 state) @@ -45,7 +50,7 @@ static int psci_enter_idle_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, int idx) { int ret; - u32 *states = __this_cpu_read(psci_power_state); + u32 *states = __this_cpu_read(psci_cpuidle_data.psci_states); u32 state = psci_get_domain_state(); if (!state && idx) @@ -103,7 +108,9 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, { int i, ret = 0; u32 *psci_states; + struct device *dev; struct device_node *state_node; + struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); psci_states = kcalloc(state_nodes, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) @@ -128,8 +135,16 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, goto free_mem; } - /* Idle states parsed correctly, initialize per-cpu pointer */ - per_cpu(psci_power_state, cpu) = psci_states; + dev = psci_dt_attach_cpu(cpu); + if (IS_ERR(dev)) { + ret = PTR_ERR(dev); + goto free_mem; + } + + data->dev = dev; + + /* Idle states parsed correctly, store them in the per-cpu struct. */ + data->psci_states = psci_states; return 0; free_mem: