From patchwork Tue Oct 29 16:44:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 178040 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp51992ill; Tue, 29 Oct 2019 09:44:59 -0700 (PDT) X-Received: by 2002:a05:651c:8b:: with SMTP id 11mr3310683ljq.98.1572367499000; Tue, 29 Oct 2019 09:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572367498; cv=none; d=google.com; s=arc-20160816; b=QIHaSjRixj5MwTeDNWCMF8ZjlQ19wauzQuLOM3cO4m0knwmTLMDgv2kgbYxDdYaGxS qWXBi253VywWUadGlfXWPDUncU70NxoFK3ZBx+Lvj5oB0UqHDfNuc0msoBC33RFZlEpu A7IrTWREgzQaY5rzRoyDnIiYasR72H5vsdfFntzxbUooTnnMoH2hRpMfMU9jgkxrfVGw H3xNx3T25Vyf/Xdty/JUToyvuIFxVbn/1Y815/MVc0JHjjVyhJzmyZxkFKy6mbWXbWTI ASTbimICF/YLwgFnX2WU4uRLIi9hd5Y6O7SfhFcsP9RcufFbeN9KgefJLf1aJAn9d+Da wqrg== 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=vOTQa6UzVCEIiTs5syxBeghS5mOeakZSLZW0GE/rgZA=; b=jiZL/oonrGuhEAQIgEBa7wnChRErL85tPd89Oy1fC8ksyFTEPVMQuBfYn/YjZ5m98F sHueLEvz0YqzqOBP1amuPLxcRhYhpyAk/85PLdF9bKrGzqnwTDa0+gxpxLdoo+4PknB+ 1F7CvdNW6zw2W/dbff8u589oRr1Lj9AdTEzjMXkey5/T199SsD2tlCyo5JB9ZE6ke3IR 2SAxVKiEqAfpVxf07/03EiscLd/ueVLlJLDLMPatqu9l7lMRDpLYAzouFKAy5W9bm+67 /BgPNsALQ/iui06xlJyqh6DIx0c+N0rqBxT/NR2YAYAaBQz6vUWAAoVKhjQ9GxMFuLI5 /tZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z8D6HMBX; 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 r197sor3974847lff.41.2019.10.29.09.44.58 for (Google Transport Security); Tue, 29 Oct 2019 09:44:58 -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=z8D6HMBX; 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=vOTQa6UzVCEIiTs5syxBeghS5mOeakZSLZW0GE/rgZA=; b=z8D6HMBXssHVDql8bLgtR21ZuCihMSUrMxv2eBZ40PvewQtBvycZT+f6DhSg4lOPiH 7X6DV43O6E661txvqWeXUWoySBr10Ft01XAmu1gP2suZk6RSa72qHIJlGIHMvm9PG/Sz VYV8bUCAYhqleRebOWTeJnJZvkyLOlkQ++cuaphGdxEwLiXzanV7i4N3AicqdXk0jh5M lYyDE2BARBRrwWZl3e/LgY/OenCQvf9S5DNlT/61rEWfrhETf7Bp9NtUscMqwO0HyaYG NkY3lp5XTuwq+hjJ90gfgvGZMhttbI3ELQivgUivPLVBXgFES08i/H+E/hmBPlDPq9m9 bcXg== 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=vOTQa6UzVCEIiTs5syxBeghS5mOeakZSLZW0GE/rgZA=; b=X6eQdwRUSl6LJaE6K3xRM/7TT2viVb8HXGLi5j4uBpqgVSiu7utZlZ+MbNqFqGwPB1 mU6LMgtFzUQmpdlS4iZCUP7T9OtRMtU8M4be6rjwPq2VqN17Gk4y7mgUwxlqZv2HXyHa 8xOxgyhHJu+a8G4tbhGebA3zLhe4L77ZziLgqK0t/Ll4uvWXcyROhBlRdlP1w1wi4HEK roB9uisKgAeq74zn/kMPyrArksZgVVJy1wNpG67U7cPlDQ9X7HPsCw+aNfqwe+cTLJI5 Vax1dAtelo4gh6eLyz3SFchgsBkAS19tkjftW6Jh63Qfn9KGhXfcOppgw3/rKKnD8BRE 7ldg== X-Gm-Message-State: APjAAAWskrz4oSwhhN7TwjtNicpFYd+c/PbHZjH3iZzm9whvaSYCGrcU fB7N5p7PZG+R1Uz7yeNTQIM6negR X-Google-Smtp-Source: APXvYqzNnr8T4A4xJlPf4SZM23Erro4aD3FFBbZzMuE+TOuRb5sHtT49+bOmhLjeNMTLoN2Ve55vSg== X-Received: by 2002:ac2:520e:: with SMTP id a14mr2981413lfl.43.1572367498613; Tue, 29 Oct 2019 09:44:58 -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 f28sm2048161lfh.35.2019.10.29.09.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 09:44:57 -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 , Andy Gross , Bjorn Andersson , Kevin Hilman , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 09/13] cpuidle: psci: Attach CPU devices to their PM domains Date: Tue, 29 Oct 2019 17:44:34 +0100 Message-Id: <20191029164438.17012-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029164438.17012-1-ulf.hansson@linaro.org> References: <20191029164438.17012-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 --- Changes in v2: - Rebased. --- 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..167249d0493f 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]); @@ -78,7 +84,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); state_count++; /* Add WFI state too */ psci_states = kcalloc(state_count, sizeof(*psci_states), GFP_KERNEL); @@ -104,8 +112,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: