From patchwork Wed Nov 27 10:29:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 180280 Delivered-To: patches@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp5914281ilf; Wed, 27 Nov 2019 02:29:19 -0800 (PST) X-Received: by 2002:a2e:7405:: with SMTP id p5mr14779363ljc.34.1574850559286; Wed, 27 Nov 2019 02:29:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574850559; cv=none; d=google.com; s=arc-20160816; b=Uui1kG7Nt3UZq5SFjebYUdLrKJu5/BnKBL84Hd5L6lUwP4pt7D+W1gnSfW9fo+JdxG mBi2bKQQelBNaw6kuZfrcb9VBdYyMVNYC/AT3sIrSnrCFBxKZ+O/RFvlJATJ7tX1nvkj HHtLQEEhNVEK8GelsAW5/jlFFbTeR+axE/W7bSq8vKv2QtY4HqzspdFCasbOg9cia0gH woY3aEl3sOk9y9zriO3GtOqeIOtbxYf+ZAGUZZDpE9OjRapdTQCMe4J+hbIeAGNQjVRp xmKusH6fvNuXzMB4LZB1PphZaIYuJRX3Y9b9Ik+kaZ5kzkVpD/rwnh3Y09+51HUKzmGH kZog== 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=75TMc1cT7FH1sabSgSiOxKjblChN2q0Nv5wC1JCjNcA=; b=w5mxcf7LWvg2FeGGrCSbfHjJ1xrNNGVGK9T5RdKjV1BxA0oWxUivLvHzUyDWEzSZhh gWJftciQNyvLrOOM7Wan3wBn1VMEifVG9lfAV94+t3kOsLcwDNSTsALC1uQGDQmOifYW qqBveip8QBfycQCSzuwIf+mePZayJqK8Du9abFPIoiYuuNW0M6g/TJVXyu5wV3Cj54np p1js4IHVrRb2Bz4aNfBo2YqcGNgnw3Wqd84H9Lhnp0USkkdYPTUFtdLm064jtblGmcq1 0v2wL83vQTnxM3pNyRA0CbGh39ILUGPGJfcbqe+0/aelSFycqGotvORS481qjKmbglel oiZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yfkFQHGS; 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 p19sor7981916lji.41.2019.11.27.02.29.19 for (Google Transport Security); Wed, 27 Nov 2019 02:29:19 -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=yfkFQHGS; 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=75TMc1cT7FH1sabSgSiOxKjblChN2q0Nv5wC1JCjNcA=; b=yfkFQHGSTi+m76i8sYvYqdEiuggix6PnBHJpJpmRd1TB3+HBk28IT3r3QivTmsosW3 P5rPoeO+FgUBK3MOmVvO1JUHb3eLFY79MhHRnE+icFW+jjT2WL7HFRR4tp1G8qN/A2sn IIk4sfepSYFdvVBdNHNiNtnCUlt8z8lm4+AI1Ls/4Cvp4dN4v5vpvGLeGmY3v9m51pCV 1RtoYLhYErI+uFTBrPbHuDMbEngyxAmo7PHnH4UB7Eu/VvccG3FfcCkbWvfKNP5FdLhC 1DlAD7Zg1BdRyBzmBv/jdXinAsrYRjK3KNI+WtKDTJtemO4A9AWbEjfPE5iReHNipErB ByLQ== 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=75TMc1cT7FH1sabSgSiOxKjblChN2q0Nv5wC1JCjNcA=; b=RKKebYorAN7huOzeOjwKiQo981Z3h3FNHiIpckjZ6IJ1fK4hAYvXjzPDETMDRZw3li Mw4wcwgUwx4L3CBSGIxF4driTAA5vNV4FOm8co4RZ5PlM2v5HMW1fXNMEbELbqaT6GUn 2t8+ySvSF+Gq6Mxnd4oyiK71LMSrPlo5+ZLNznFHAIfDm4fsthljYdMpqGkMzIR3yJ+7 Ok+zeetg5/zPZJ0Mmzbjos0Mo1DrMzhywHFDZdzPyezUTmldNgQ/e6O2LEQJ1oHzuc2f SvxKPStKg6KpFKFsTEXLGS1oQSSVFNcy1ZbPrhGTQ/Sek845vXDQOuZvtgUesZq/bSmS GViA== X-Gm-Message-State: APjAAAUqjgxPrgvIlaTEIi/+XWKf+zTgKDrl1QBTZHf1JN4D5EeVh/4U YwTS+NpLQJKTzIa/6/f/pDEt872W X-Google-Smtp-Source: APXvYqyU1IApp4NI9wl22/OIUXj5aD2EpYZqlLflyJ4cORj4qNdhYEZOz8nnWtIV00rgXD1rv0nt9g== X-Received: by 2002:a2e:b818:: with SMTP id u24mr15059006ljo.33.1574850558878; Wed, 27 Nov 2019 02:29:18 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t9sm6868260ljj.19.2019.11.27.02.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 02:29:18 -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 v3 01/13] cpuidle: psci: Align psci_power_state count with idle state count Date: Wed, 27 Nov 2019 11:29:02 +0100 Message-Id: <20191127102914.18729-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191127102914.18729-1-ulf.hansson@linaro.org> References: <20191127102914.18729-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 v3: - 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);