From patchwork Mon Dec 30 14:43:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 182615 Delivered-To: patches@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp6422087ild; Mon, 30 Dec 2019 06:44:10 -0800 (PST) X-Received: by 2002:a05:651c:111a:: with SMTP id d26mr35085289ljo.153.1577717050474; Mon, 30 Dec 2019 06:44:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577717050; cv=none; d=google.com; s=arc-20160816; b=EbekAn1xlfxxL6zEDTvT87B2gWRkNdbNAnIX0t2LT8P/FeP6YHBEUNDw2vUg/uwbcX 0MVpQHMNyECxRU8GHOgcRwqDlNZv72su4/Ru7NL52kU//PA9+mCDo6Ub7C0ogdcOh6ii 9it/mS3+L7YYXl0AhFECRgxY7m+eKv3XODAh2I174nvWUxpU48KI2Zr8D8gOaKpBExdX q3bojMcjYvrKB6k8H2qoaiyizDTgQKXLfvqilzEsaFTyTnXmh6W72hq1Xd82oqXvpVfd HGWhgPjdZbom9xhNdesZToN90O92SofDMGtNeuUNTH/0ZLOhBgu84fdA8HXUvR05WiS0 38tA== 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=yJwsi3DMV/pwzB8sWAmHjBjjwOzOWtOVx10q5OKc/Qg=; b=atdoFNYllxEpEA2uXNMZkKUvfAqHDW/HTh4TzndEGjloBZqRcxVAhIUnr55iFhrnSQ J9Fcr4+/cy8sDk3V/01B2JrGgvjXSV0bS27UsLm1howkCD8gOGQYZoSuqDojTkJlYXBy tu7e3gXcFtaXpkGuo8SENTmDXTeX1YpRiVTistBkhL0B8p4CpD/EX5h50djYt+KfXT7r Yr1hnR0PrajY/dkdrTfGpmkB0jZay9SViL2shSWspwOy+k1MQcfS19koyTy/JqvvcKuf 8Rujxu1raY6ODWq4A4SWCv5fuOeS7Zplq45FlVcnaTa09FuFmCgvKVjA0pg4wVywJrpO QIFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VLgbT14a; 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 s20sor11101131ljs.24.2019.12.30.06.44.10 for (Google Transport Security); Mon, 30 Dec 2019 06:44:10 -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=VLgbT14a; 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=yJwsi3DMV/pwzB8sWAmHjBjjwOzOWtOVx10q5OKc/Qg=; b=VLgbT14aKbIweXjePyokMcXGIZ6qb6kWlnLdbU2O9QNBikijGUeMsDJ5BerDOGJVyP hT/gOq3EcoVXwl4kpM8e3733iP90YILT3RaXDUM2AuU9KGQt4qYTgy6f6jabQM8o6m0z f2Dw+FKT/VwRq6dj/Q+Mb4OPmk5DBWeU3Am8tGUkQkau5kdcLudikh879SjNbyZlbktm lKJi0S1dkLtuKh4sR51iIzOPusJcnwu9cu+P1Mbyr5xhvb7FvMb2wY+1GVhDzNKRCsz4 LDcl7o0n0E5yYOD6GEMWIYriiQq1ppx9SFRSm2kbu+C3hWO2xWy6bgqtGzmp6tbF8BLn M+Kw== 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=yJwsi3DMV/pwzB8sWAmHjBjjwOzOWtOVx10q5OKc/Qg=; b=sf1aZSNVY025Z0gBlOc9HZDVkE0ANp7XrsZJAITnWnMy+YekcPv0S3qxDJiUqbBK2n Vk/49P8pSH8rhc3sFDQPs7Nc8KnJW96WvEQXD+oPYNVqjHvRocb4DDXSdTLxfcbavuqD 29wFKBWlZN58BlLy35nB14lUfPVzgSKUNerVhX/STHrFO9YPug0hc5Yb+Hr0ysO43xxv n80kSmomiIAffrQCS6hTszMlRgHdHXLU1kT6E0Jx4tDwATA+iqNK0LnK5Tz/BK5bf9h7 BweULIkuTrcOP1UlneLL0H95xDp/mjBKL4j9h3Jo6kXnRx3EeY6qwdLOQtyTFcRNgSUZ xmXg== X-Gm-Message-State: APjAAAVfTYV9FeQo71QsOv3c0NDqlTlLBZyYDmW37DMv1/wvWG8a0QE5 j6EWwIWbWAl3zG+jIMnwv/LiWkvb X-Google-Smtp-Source: APXvYqwN0EAf9bCeoE9MhNqvKtGj6Kuzpeq236RUFu+VyIzagp3j7CmYdCtkZY/sNNfmqJXTyE+Ieg== X-Received: by 2002:a2e:9e43:: with SMTP id g3mr23393509ljk.37.1577717050174; Mon, 30 Dec 2019 06:44:10 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 06:44:09 -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 01/15] cpuidle: psci: Align psci_power_state count with idle state count Date: Mon, 30 Dec 2019 15:43:48 +0100 Message-Id: <20191230144402.30195-2-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> 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 v5: - 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);