From patchwork Tue Mar 10 10:40:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11429097 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7905B139A for ; Tue, 10 Mar 2020 10:40:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58D1524649 for ; Tue, 10 Mar 2020 10:40:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XmPV7pmf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgCJKkc (ORCPT ); Tue, 10 Mar 2020 06:40:32 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45924 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbgCJKkc (ORCPT ); Tue, 10 Mar 2020 06:40:32 -0400 Received: by mail-lj1-f193.google.com with SMTP id e18so13490963ljn.12 for ; Tue, 10 Mar 2020 03:40:30 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=VOmLbFg4f7m0VWnyO1xDaH/AZNMu+kPMNjgBVvsbMM4=; b=XmPV7pmfeVwv3eR7FYLArkOxNj27Kv2v7Sx7iRQrmZdzWxfxlm1/2+6ROU4I24Rih4 sfMG2dff10ReM0skBVyIR8ywsuBgmcvdt12e2ZCTI4Qo81wWI1tCCP6jUdZkGjLPQ50P C2QGEB9K3G/dqaRMfDNWxuHMFPrymb3R5agvF0Agm+VQuOdUfUNHoEj/9ksEQ9gUlLxo gzqwva0Zs4/SDsB2Rmj4itCDw/94E8QchLWRxf8WuPigcg2aybGDW82RNXqaWGSTHjDk n8qThSPy6zFIN95KirHptSJJ8TZgWB1sm61UPdbxfwz5KxBBZLhuMi4nL8GQ5ebHturv M2nQ== 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:mime-version:content-transfer-encoding; bh=VOmLbFg4f7m0VWnyO1xDaH/AZNMu+kPMNjgBVvsbMM4=; b=QkMrrAjoncvV+Ox4Dj9AUMrTCSrbLaGCpc09/mL9pSPSRFieQQfxLhikWePJnD8Umm JNnKynkKbBFRH2e0J+dJQFVSfeGIFwt/maFv9VzSUZciVs4ymP+cnRjs8X1JZMj7fQoW MI1ftt76klu7IwdkgPD+yIx2xaBrqLL9CNiBur4nXHXzV0drKNnEmefvnbnc4ee0dHiB AFbqb3vCbOCK82FvYhVbYiukeFJoUzMNHHT1ZPUwwMheY2tqVF2yKpjn3/5brMdJbj+5 8qDWmMe6uV5zboEEbQLUhi8sxbX8gTOsOIUTHI5Z7akJdyDVR7SEUdbwWS11u4dsadFs +lrA== X-Gm-Message-State: ANhLgQ1q7xcg5PQ1aSDY1iUbaINUOfxrBwXd0PWtl0Hm9m8Myulz+8n9 xAujmGej+lPcTWQESskFnmuCqw== X-Google-Smtp-Source: ADFU+vt0BFBJbAznVQSE1PNl5MnrDZymFS2judAVRaRDmr4mbgXWDTWu7QcpSCh+5klHcSq6m8dkfw== X-Received: by 2002:a2e:8654:: with SMTP id i20mr12334652ljj.248.1583836829816; Tue, 10 Mar 2020 03:40:29 -0700 (PDT) Received: from uffe-XPS13.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j6sm3414632lfb.13.2020.03.10.03.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 03:40:28 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org Subject: [PATCH v3 1/2] PM / Domains: Allow no domain-idle-states DT property in genpd when parsing Date: Tue, 10 Mar 2020 11:40:23 +0100 Message-Id: <20200310104023.4018-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <0002-cpuidle-psci-Split-psci_dt_cpu_init_idle.patch> References: <0002-cpuidle-psci-Split-psci_dt_cpu_init_idle.patch> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Commit 2c361684803e ("PM / Domains: Don't treat zero found compatible idle states as an error"), moved of_genpd_parse_idle_states() towards allowing none compatible idle state to be found for the device node, rather than returning an error code. However, it didn't consider that the "domain-idle-states" DT property may be missing as it's optional, which makes of_count_phandle_with_args() to return -ENOENT. Let's fix this to make the behaviour consistent. Reported-by: Benjamin Gaignard Fixes: 2c361684803e ("PM / Domains: Don't treat zero found compatible idle states as an error") Cc: Reviewed-by: Sudeep Holla Signed-off-by: Ulf Hansson --- Changes in v3: - Resending with reviewed-tags added. --- drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 959d6d5eb000..0a01df608849 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2653,7 +2653,7 @@ static int genpd_iterate_idle_states(struct device_node *dn, ret = of_count_phandle_with_args(dn, "domain-idle-states", NULL); if (ret <= 0) - return ret; + return ret == -ENOENT ? 0 : ret; /* Loop over the phandles until all the requested entry is found */ of_for_each_phandle(&it, ret, dn, "domain-idle-states", NULL, 0) { From patchwork Tue Mar 10 10:40:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11429103 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C3D8139A for ; Tue, 10 Mar 2020 10:40:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C98124649 for ; Tue, 10 Mar 2020 10:40:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nc6/NWC0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726202AbgCJKko (ORCPT ); Tue, 10 Mar 2020 06:40:44 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:43987 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbgCJKko (ORCPT ); Tue, 10 Mar 2020 06:40:44 -0400 Received: by mail-lj1-f194.google.com with SMTP id r7so13494236ljp.10 for ; Tue, 10 Mar 2020 03:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6pxlLk38rJ+HhQrbDG9StMgSzEGNLqFsirKScynCScU=; b=nc6/NWC0ZnA3EHC5pXdWeUncJizYLSupGGwOcnk1c26mwggUrbQlWG54DY4FknvUYC 28jVQAIJIwqs8DWroIOThx0+dpmmj9ek3g7+J7ZWSAEJAKnjaEuEu0hL1in+KrU4I2Cj 6EoKk8Z2W08D0X5hLNTyxIPOnrkzo2mxdpjQabpM/cozVARF9SSCYuukC6rnk6NPDafV WXiPDg3mmSwA2N6t5wckhRmEi1FF+EFsr03KtdQ+hOPcjc/Agv4GfUakYa+50CUuMlEc 541J2z+kFc8ewkil29Pgiqwh5Yynam9/Aigi50NWSaFUYN/1Nzj5TaoYkStWR2ciEepb q00w== 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:mime-version :content-transfer-encoding; bh=6pxlLk38rJ+HhQrbDG9StMgSzEGNLqFsirKScynCScU=; b=WKNe874E0XiaBHI/PQB1d5vG+lw39gfdI9LBohoY9ZTJ2hyuJt3G0FEYcvYXkMNG4f DVv2boCt5oJOoDFeC9kodH1mETBwWQKWtb/5suTX+UZ6s2E7/JVbX36kFgsO1rdyOuLB fe2FSroSHnHcf/+PPkcfhIlMnWTsgExlbQSqLGqyVqPSO0FoNlw1jtAsf/YDG1uRDSQu rUlAIGBfHTqhmcIwR5vy5ZTTQ+10hIwIourTZ1Exp9y6Jk31PWOhlgJy6J5DppNxe4ga acI0Dm/RjJxEBTGfCJF1bxgVKITHK1fppy0RY4qDtXHLj/+q9PJszrahJjSDQkO17H7H gjFA== X-Gm-Message-State: ANhLgQ1+5w5TA2DQiVMoZ0rLYjqSHzWcFtM1h+b4CXDyMgXIc/cgWaqr 35WQR6LmTQulctnp6R9xSr/jOA== X-Google-Smtp-Source: ADFU+vtyugMzukSnO3/aD1ZXvAqRaTZfqRTHJXjr2Xlk1nBcgblQDVHM7XoSCktNZFEhOicuiCITog== X-Received: by 2002:a2e:8802:: with SMTP id x2mr8541132ljh.291.1583836842549; Tue, 10 Mar 2020 03:40:42 -0700 (PDT) Received: from uffe-XPS13.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e2sm21511582ljp.55.2020.03.10.03.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 03:40:41 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/2] cpuidle: psci: Split psci_dt_cpu_init_idle() Date: Tue, 10 Mar 2020 11:40:39 +0100 Message-Id: <20200310104039.4066-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org To make the code a bit more readable, let's move the OSI specific initialization out of the psci_dt_cpu_init_idle() and into a separate function. Reviewed-by: Sudeep Holla Signed-off-by: Ulf Hansson --- Changes in v3: - Resending with reviewed-tags added and dropped fixes tag. --- drivers/cpuidle/cpuidle-psci.c | 46 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index edd7a54ef0d3..bae9140a65a5 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -160,6 +160,29 @@ int __init psci_dt_parse_state_node(struct device_node *np, u32 *state) return 0; } +static int __init psci_dt_cpu_init_topology(struct cpuidle_driver *drv, + struct psci_cpuidle_data *data, + unsigned int state_count, int cpu) +{ + /* Currently limit the hierarchical topology to be used in OSI mode. */ + if (!psci_has_osi_support()) + return 0; + + data->dev = psci_dt_attach_cpu(cpu); + if (IS_ERR_OR_NULL(data->dev)) + return PTR_ERR_OR_ZERO(data->dev); + + /* + * Using the deepest state for the CPU to trigger a potential selection + * of a shared state for the domain, assumes the domain states are all + * deeper states. + */ + drv->states[state_count - 1].enter = psci_enter_domain_idle_state; + psci_cpuidle_use_cpuhp = true; + + return 0; +} + static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, struct device_node *cpu_node, unsigned int state_count, int cpu) @@ -193,25 +216,10 @@ static int __init psci_dt_cpu_init_idle(struct cpuidle_driver *drv, goto free_mem; } - /* Currently limit the hierarchical topology to be used in OSI mode. */ - if (psci_has_osi_support()) { - data->dev = psci_dt_attach_cpu(cpu); - if (IS_ERR(data->dev)) { - ret = PTR_ERR(data->dev); - goto free_mem; - } - - /* - * Using the deepest state for the CPU to trigger a potential - * selection of a shared state for the domain, assumes the - * domain states are all deeper states. - */ - if (data->dev) { - drv->states[state_count - 1].enter = - psci_enter_domain_idle_state; - psci_cpuidle_use_cpuhp = true; - } - } + /* Initialize optional data, used for the hierarchical topology. */ + ret = psci_dt_cpu_init_topology(drv, data, state_count, cpu); + if (ret < 0) + goto free_mem; /* Idle states parsed correctly, store them in the per-cpu struct. */ data->psci_states = psci_states;