From patchwork Mon Dec 30 14:43:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 182623 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422358ild; Mon, 30 Dec 2019 06:44:24 -0800 (PST) X-Received: by 2002:a2e:88c5:: with SMTP id a5mr39088358ljk.201.1577717064265; Mon, 30 Dec 2019 06:44:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717064; cv=none; d=google.com; s=arc-20160816; b=apGHj7ZtUqWGeeAg1nCFin4sKZ5LeIRoxqFO4zqHLzCmbd0ok7299mATsT1I2D15TV XKWK8JK3IyFzNCsP/OcMQULiNbvTLieCL9bhqh2IX4RELq+V8u4O5RtrS8QavpRd5WXF w6x1dCkdLi57EYNxbnKhAbWjiisliwfDg3yyTSslJoVv+Kg9UqUwcqFcKc1RC3C5O/8K 82wK9auSOuubE2ZJ0VmNhXlU1JE0wACbmMmP3b9E7CL2zjGGaWJPiD6VQ6VEQ7YaN8We Y1GjszEi5fKD53tEFr2Skvv9j3iG0TbMLmNtVG71MdE2uNmaMN9NhDpm/qtzijHOIj9a 2b/A== 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=F62eMHvAlv7nF3GieiDqKuJt4z4o+7t76tdVx5DtOc8=; b=FxY91FVgOZUHZf1wXJ4K4oS0DU6PO475zdKDY/XDswgYYOl3gRKCOeY/QrV67PygG1 bHzJNGtSVbNLFmlslTVGNhPFneCo3U2AKipVhTS0Qq7TVRC4QmfkkqKYgKgZXJnYkQH+ B6Gj4apwrsxiyJIJggQvqzFbiQFs9Z8OY1u91AWVtlSeyLSKsW/xK5iEgFAyl/NTAG/7 rwMJGfm6DwYpY1punyjqxrGjZ/IS2ZZlCTN650sx3gU5JcxDz7VYyAZRocxwgNXz80Um Gws2GgWx/Ysl4rSf2BrZNDGM4ARHEuh1qHVZ2MFeoyl9jMwwoEzSJagvlD9VyJlOginh DytA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xKKUKeIO; 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 v25sor15752379ljc.16.2019.12.30.06.44.23 for (Google Transport Security); Mon, 30 Dec 2019 06:44:24 -0800 (PST) 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=xKKUKeIO; 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=F62eMHvAlv7nF3GieiDqKuJt4z4o+7t76tdVx5DtOc8=; b=xKKUKeIOyuo2s2W+neuN/sbW173fQNrou3tC+j6v7Ko/GuV217MXietDZKhjA3Uskq +oGLDtucefGKWLnVAkdy0EhggOa4EVlAW3GgnRf3Q///TpMXhcvS47NgjBgaWEZcvHEa sNPyCIaZTNdpqI7KOnRBwON5a3hrpogrN9d9Ws+HKMrAubG/J+RRvvjmiuXp2X5RAeLx 6xSd9DNxkiJYPcmnO5P1a2Ljaf0kWX0Uv0AmAJhO8VjFrwyPTyVlJYM0h5cT5tIv0xYm DOGryt9AIk3n2s3w+VoyOqVcAFEb685q0iz4QCXHyot3S9+MEpZiMmxb1W2IxQea5VsV oLOg== 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=F62eMHvAlv7nF3GieiDqKuJt4z4o+7t76tdVx5DtOc8=; b=uEBdO12h9kzLRdlgfDxtJSSt5gjLozkeupd01U3vzYcoHt6AyXpZzCnkScOk8xjv1+ 1sWOFeUpeR7lW4jLu4DqiYFC4YeFFz7JRlM4X51K3jiER65sGayrKSJck7nydf6kNRWH pNWYm3uJyDtw+Ds/rFg1iDJYEB4pFppuWesaaauvtNy8PfiU8egmLH5E5yAs1qObDJCv Lq8n8B8WBJASQYogPJ9aLeTbCrIumV1VgysAyU2/SrsRhZkebrCeqlt5Ad6jDyt9YCBC 0ypkUsHPn+cdEqxKlSG8FHCkA19ExXM+a7KTDOCxVAbRoKYhweLKHIHWjvIHbKpc7HLB pOTw== X-Gm-Message-State: APjAAAV94iyiLEi43yAXcUprS5CE4USM232zTitR3O3Ac8y4u42QA5hI bB50pcKHSunpezDoriEgiD9opRdN X-Google-Smtp-Source: APXvYqx5ku6KI9MfPdQZ+SWjpmvOotL42D1PWyIwc9k7LE5GzctpSfHSXBO4s15SrZ/WJeAsBlX0Ug== X-Received: by 2002:a2e:8e22:: with SMTP id r2mr32224867ljk.51.1577717063226; Mon, 30 Dec 2019 06:44:23 -0800 (PST) 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 a21sm18744931lfg.44.2019.12.30.06.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:22 -0800 (PST) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Mark Rutland , Lina Iyer , Vincent Guittot , Stephen Boyd , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v5 09/15] cpuidle: psci: Attach CPU devices to their PM domains Date: Mon, 30 Dec 2019 15:43:56 +0100 Message-Id: <20191230144402.30195-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191230144402.30195-1-ulf.hansson@linaro.org> References: <20191230144402.30195-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 Reviewed-by: Sudeep Holla --- Changes in v5: - None. --- drivers/cpuidle/cpuidle-psci.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index 830995b8a56f..6a87848be3c3 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -20,14 +20,20 @@ #include +#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 int psci_enter_idle_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, int idx) { - u32 *state = __this_cpu_read(psci_power_state); + u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); return CPU_PM_CPU_IDLE_ENTER_PARAM(psci_cpu_suspend_enter, idx, state[idx]); @@ -79,6 +85,7 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, int i, ret = 0; u32 *psci_states; struct device_node *state_node; + struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); state_count++; /* Add WFI state too */ psci_states = kcalloc(state_count, sizeof(*psci_states), GFP_KERNEL); @@ -104,8 +111,17 @@ 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; + /* Currently limit the hierarchical topology to be used in OSI mode. */ + if (psci_has_osi_support()) { + data->dev = psci_dt_attach_cpu(cpu); + if (IS_ERR(data->dev)) { + ret = PTR_ERR(data->dev); + goto free_mem; + } + } + + /* Idle states parsed correctly, store them in the per-cpu struct. */ + data->psci_states = psci_states; return 0; free_mem: