From patchwork Tue Oct 29 16:44:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 178032 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp51691ill; Tue, 29 Oct 2019 09:44:45 -0700 (PDT) X-Received: by 2002:a19:ec16:: with SMTP id b22mr2642506lfa.74.1572367485597; Tue, 29 Oct 2019 09:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572367485; cv=none; d=google.com; s=arc-20160816; b=ATUvs6laXWo0WnoR8DHLt7wObyOuBz8GpmSTANugUgl8IsdZxJf9B4HF2HT2qT7FbE sK/ptGRSc+istj1bjajKd+uC57wjmoqTTi01HKvYFi7X/W5vXd6051nhohRGa4NhoadP rT5QB52AYm95VTNcxjYveGf5iV/JpwntEVVt8tah2f16ImFuCcs1zksG9GSKZMJrydMv /Wai9sdi3f4cK+6tCL2U1OLJn6iz9bcbV9hhrs9RjPObc/mEjckwaUwZUJwC5n6xhdAm Ufz0UHrn6pXnsNyktVH5vX8y6B2Lw0PeWC5zpqk0/3lDOtc/M/n0JShAZD08GamvjSyR 1S1w== 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=bWmI0Xiuvq89sgTizuBFylB3C9/WTB7ILCq148rwhZk=; b=xxB5gU3YLSD+2u81uO2Wj7iD8V5IYKaLZ6rNAIQZWFKKoGB0tIDaR+/E5lW4Jd6Sgp JTNV7DPpqz9jYW6JiTO4WHiT3bGvApVKEcv5931ldviTIiaV5tCr0jtgdnsmpW9AnVW3 vWf++6r/BV7HS/tqAZiHsdfhPucoxZNPUPd5hSy/vjyv3HfMA6Ph/IAOwo2MQPloqmlS nuxJad7/EtgWAeJeLyTdqmeExyqH0aF5+ENEVKuXPa6ZFzVRbI1Yfyjz1f/zzeZ0Wzwe UzugHSa4t+tlcy4rAAhMR0mdga/ZJNlXJmIvePqQaqKdEgsBFFI+pvk203lZ7IlRdU8b k/Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nGhuDYkf; 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 d12sor3599547ljj.30.2019.10.29.09.44.45 for (Google Transport Security); Tue, 29 Oct 2019 09:44:45 -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=nGhuDYkf; 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=bWmI0Xiuvq89sgTizuBFylB3C9/WTB7ILCq148rwhZk=; b=nGhuDYkfvkQnrZTY/TN3SJPYAaq6N0hugnaQQTvYzRjyoPirGxoPyytewdnMuFCFij DaKmL0IiI3Qljq5CIImb9zhUYVW5VW+op923nnammGE5rv2FOHsLNPRmSR5VSjEBxWTZ +oyoY/dWhez06dxKGThbrMguGRiBM7sr5gIaMs4iiiLuPwmPqMDG6CWDzEBWGB0x0Ha1 In+/km5T6X+Vcwoxcv0M++rn5YHmiXagng2jm6Cu5K0cpWPMP5hz4j2QblIRc92btI15 4916IppXqRFSp/7tSoPmztteLkZaZyI8t2KNAKLsXA/ULl2xQ7yG8pW90jbbx1HmvIqH BLRA== 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=bWmI0Xiuvq89sgTizuBFylB3C9/WTB7ILCq148rwhZk=; b=R3oj71dLyc64JtNfRqGg6ItnG7Y4elKA1N/HkG27VEbGEJKDREwqh7jd+cis5+y9XF g9rcQySfsNE0F5IsBKfltZqEi5iGD1eYyE36yfm+xlbISDQLpoiU1kWM2KRe2BADqo8G 7U2WIsVwk/ti9DAopfJiakZKr3nA28qbzuX5I3mequcrIkUOi5SgydyA5oRtYKjlGH8u uPbLk22sY3qC0F0CCOAfaRBlhQrHlHRoVzcblK5L/MFQd9wJCXq/zBjlRyhmbSPrXH1h dEllelljpP62hwxE5rmvh3o2rJ9uCwLDIN6Jx1VoTZLZIPeEqVEbB4TVKLtpXp0jc54l xxzQ== X-Gm-Message-State: APjAAAXvdwrV0+lHZsNxS2dUYSBGP/ZFVvl9zZ8+jPc+L5x25USraguW 6zppGYe6OnTkT/prZthfM6u5AthRmkBk1Q== X-Google-Smtp-Source: APXvYqxiw4yXF19S009oKLq+GuUCc8WXW014siinCqLOYELILmRXWbsHObr2NPT+v/kN830ot6hPPw== X-Received: by 2002:a2e:9a9a:: with SMTP id p26mr3283051lji.164.1572367485207; Tue, 29 Oct 2019 09:44:45 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 09:44:44 -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 01/13] cpuidle: psci: Align psci_power_state count with idle state count Date: Tue, 29 Oct 2019 17:44:26 +0100 Message-Id: <20191029164438.17012-2-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> 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 v2: - Added tags. --- 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);