From patchwork Wed Dec 11 15:43:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 181265 Delivered-To: patches@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp701539ile; Wed, 11 Dec 2019 07:43:52 -0800 (PST) X-Received: by 2002:ac2:5635:: with SMTP id b21mr2589612lff.127.1576079032597; Wed, 11 Dec 2019 07:43:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576079032; cv=none; d=google.com; s=arc-20160816; b=n4PhxtZgsAVCtm9Ylv6fMo/5osKH7LmiCqMzG9mXfX6ZJRdhsZ/qeyK27G0qsv9ieQ bpSKzlNtY489W83nhBt7XlV3YYxtIYWLMv2qm3690EVDKwUAsJLCo3ewFEMp0/2EwWDD pC+maDivpo9nQM7H2CQZz4K/uFYsJX7zDEqIGQYMj+LRLDvkWJPc7qs7/pyWM2aJMHpK 422e4Ir11pz1f79wuPCSaJSxBNwC8Y2ilcB8ylQqbpZJSH8QtPxOEzpLPSbAFIwVpyW6 oYphYiHmC/Bvhvw7XJnzVmpGJdsh5gYLXUnYdOFNJ5k63WcHjJwQxwyFfUKN4hgk/ev8 HcFw== 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=46fQcaYRZVJGONWzkSKPwKhP/wuZIGStJprSOcfe334=; b=F7WYz9zCJDQRA7FdfQCB6qGQOo+Z3KrfbmcyCcWXwJByU2KecV35LiNsvjEH/tGYIN J5PgjlRbYe/C7tJix/8iTmpHwkhIxiRwvU1gaHMMQsjrDX6SLY7toHHCnJpJc6DL+XFx MLsY+NDJoiB2NPs3gen8RFjgDG6yFSRQvG+CpzWeaf6Zyj81d2peb47yOuTSsPkKtI2z Xcv3UrtcxBz67qgFxTCp3plCWWebispPFQwFUNrNs6dRL57H/+wMcgGZh3HNmmwEb3W8 3xxFDwPZgwbr4s0Hr6gehVj554TWfnNmBb+Zh1HjPJGaIxiGbPFtnuWmMDI3K7pxafy5 Yq4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zcVsfgmb; 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 x21sor1658222lji.44.2019.12.11.07.43.52 for (Google Transport Security); Wed, 11 Dec 2019 07:43:52 -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=zcVsfgmb; 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=46fQcaYRZVJGONWzkSKPwKhP/wuZIGStJprSOcfe334=; b=zcVsfgmbomRQuy8rc/lQGcTMLcfThl+n7UWlp4kXd00250zpeWcVglLPs5vVtxbHiA MStdCliToDc21B16LC3rUFLv9V4D2lPn2NiGHf51l8fuBArM9o3WbINapyKCElF4lLrz qY+SsGpOx7kmMLn4AJLHq52jc2Zvz5F9naiyeNkU0AjWzJ3IQ048sI8oHf++ia88BoOd f8YyxpzoGt/jfKR61R9Lg9T5Jh3zIUmgPnBwGUwCCUzWHmeP+786WMwqcKvNL2813ApA bHz14WRPnG8bkLdQ71opOq2TPJAs/3SfQaLV3Z80xNJMf99BU8GpsZ8m0CHOBXp05Ngk AOmA== 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=46fQcaYRZVJGONWzkSKPwKhP/wuZIGStJprSOcfe334=; b=D4JqN7eRU3SxO03uY7G/7ZVo+1cUtReVVs1sjjZx/xPrThtiaww/d/qvASoFr7In1e YeaFvlm1xw4/y1LaYsQspFy4BDH4/54Tk8oEQ8t/eQ61coKdOi4vYrkAboQP+9p1ZLga mguEOnq/P8gHPhrBypkAAw+90JJyPuJdxmqhdaDD0yJzWF6K2KJX9iKKRczwnqdSGa7j 0V0h3xlAxT7T7clO1FijWwrNNqXPepEz/Nx5opjeEvec0tRrRynsYcxIlfyVkPjBd/CT eHZ6dnox8UUfTyKmGCdqaWvRlAw+4qyZjST+OJnaOKiYQ0cOUAC5BZ+RQyLTwLuZneTM bGYw== X-Gm-Message-State: APjAAAXoM1XvdM5O6DWKvlB5TIwuBEvy4+M5woDDaiUez+uVEFpPSk0T h2JgMJioblC09poHKLhhgKotXTsU X-Google-Smtp-Source: APXvYqyBnDelMMLa2yqKqTKQABkrz/d0cAklTqaTVvb1gl+L1svnMBI59J/g1AHwehWqOsVxBQl8ww== X-Received: by 2002:a2e:8eda:: with SMTP id e26mr2480158ljl.65.1576079032149; Wed, 11 Dec 2019 07:43:52 -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 b14sm1389608lff.68.2019.12.11.07.43.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 07:43:51 -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 v4 01/14] cpuidle: psci: Align psci_power_state count with idle state count Date: Wed, 11 Dec 2019 16:43:30 +0100 Message-Id: <20191211154343.29765-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191211154343.29765-1-ulf.hansson@linaro.org> References: <20191211154343.29765-1-ulf.hansson@linaro.org> From: Sudeep Holla Instead of allocating 'n-1' states in psci_power_state to manage 'n' idle states which include "ARM WFI" state, it would be simpler to have 1:1 mapping between psci_power_state and cpuidle driver states. ARM WFI state(i.e. idx == 0) is handled specially in the generic macro CPU_PM_CPU_IDLE_ENTER_PARAM and hence state[-1] is not possible. However for sake of code readability, it is better to have 1:1 mapping and not use [idx - 1] to access psci_power_state corresponding to driver cpuidle state for idx. psci_power_state[0] is default initialised to 0 and is never accessed while entering WFI state. Reported-by: Ulf Hansson Signed-off-by: Sudeep Holla Reviewed-by: Ulf Hansson --- Changes in v4: - None. --- drivers/cpuidle/cpuidle-psci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index f3c1a2396f98..361985f52ddd 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -30,7 +30,7 @@ static int psci_enter_idle_state(struct cpuidle_device *dev, u32 *state = __this_cpu_read(psci_power_state); return CPU_PM_CPU_IDLE_ENTER_PARAM(psci_cpu_suspend_enter, - idx, state[idx - 1]); + idx, state[idx]); } static struct cpuidle_driver psci_idle_driver __initdata = { @@ -89,12 +89,14 @@ static int __init psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) if (!count) return -ENODEV; + count++; /* Add WFI state too */ psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL); if (!psci_states) return -ENOMEM; - for (i = 0; i < count; i++) { - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + for (i = 1; i < count; i++) { + state_node = of_parse_phandle(cpu_node, "cpu-idle-states", + i - 1); ret = psci_dt_parse_state_node(state_node, &psci_states[i]); of_node_put(state_node);