From patchwork Tue Mar 3 20:35:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 184152 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4079675ile; Tue, 3 Mar 2020 12:36:22 -0800 (PST) X-Received: by 2002:a2e:7816:: with SMTP id t22mr3512089ljc.160.1583267782597; Tue, 03 Mar 2020 12:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583267782; cv=none; d=google.com; s=arc-20160816; b=DDrnKFg5VBJaNSCyeAHw6GpPemNMzmlc7m4x33mfYSG8LOGaFjKCt14obvU2MRk6OP ddO0TEwYhqQ5CFgMw6N+hNvX2NWzVe2PvloTsKAipAY9GBnil7zDsIIyDw1SC+g0gDVR zIC1HkjiFnUfFpTseC/4s4dL0NzVS34nTKVk5tw4cnthzrNMgMNWGK9vmRa8vwsPbfFD /PHngrxHzmnYsBpEdF7MrIkdKpvjImnLzffKcve/KKhdzCwxuiymJ/E2z9aofR7tnzXg 7IWQfMNdnog2TL1WSK2eWoqoByUA9n0XnEJpQbyBFLSerQ9r7WaaUj5zMNC/JUPVsQBo 8Umg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=p6OxZjqO84dNl99kuVPctKqSI5SbottYVoqCuAlbKlY=; b=ohHpQutQQpvrC4fy0wgFKPAJsvaz6GjJIIdJq/MG++8mmG5RZzWKZnusS8Dy91VXDF tVfNXCDSZsUsTNwcUFXCG2wg4Y/H/7XmV4GqQ8NIckt2nlxC5nwFYfqRlPQft9hQL8Ik BCEoP7iXZJ5bBNe9XlU9+svxvZh8QDUH1Rb7lPqLmDT6u4y6KUr5zLd1NwSgv9jfV1ij IE/aERlJQaEJUYNFQQZHx2D04sNA5GsNl4b70dhqeFY/V+nCcCe4T+yTbTipS53+DIMV rIyHRCzBkurwcVGg0Qt6MhTrEQn0OlDt9V9ZGNTb2uu3lXcQZujYDQZQqKnhdszAb+sq 4/9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xL/TeD7x"; 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 y19sor2380702ljh.7.2020.03.03.12.36.22 for (Google Transport Security); Tue, 03 Mar 2020 12:36:22 -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="xL/TeD7x"; 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 :mime-version:content-transfer-encoding; bh=p6OxZjqO84dNl99kuVPctKqSI5SbottYVoqCuAlbKlY=; b=xL/TeD7xGicYVnZjuz5GIxiYOxPH4BTrkcynvaLMauv1NyLuQtHbfACxUi7y3w5VfQ qBbXxi4obb7qT3QVorg9XjxXG+W3XJDgFKvEyveWOQocNLnkXALY3aR32yqG94pKZUcl jvMUa1LO/S2GhGsGYyNUD7RNYW0GsGmvPnh8kgxFn3DJtqGTbL/8DIO7DmaU6bUOjp1F fTQqat4KxMdVagRi9hGOUlLG1rfyN7y91LriVd0D7hbvBNI8ld0LNRkEVNm4gCaDCH4a zqhfX0P+cUgzYVj/+MXpoRIcT9EC9DS1X9VkqHvJsWqk/Rh/DkmZ5Twp6fCLT3AIL8jA iJKQ== 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=p6OxZjqO84dNl99kuVPctKqSI5SbottYVoqCuAlbKlY=; b=peD5qCej6544GYxmJSBFSdLyEPE6RjYBPimIZGLGHW0L0iLPArKA6xmRBe3xxpHBvF xs61MLBWD8tlucDzSAudyBUYislqHw9bp29DwsNnLiwUljFEoS3hvtLlWVCp2G5PGP/I jJuuDjL3uTdU7pNOPwAfoZB1e25VPvrO0WMjEa4KMiSle7xG9osfadUtwLodcwxpttzT tPn0b0JciMqPVJlnX7/OUeKvC89SmAgThiwCWgyO6JmhgUjrOzkyDB4BwKEMvhgNyIGG 6GnvPLwVSf9dIA+d0xbEIMC95L3Roy8nydLHx5vA7Pe8O7lWNZG0V3MHhl3OwizNjM95 4DVQ== X-Gm-Message-State: ANhLgQ2RugkXT4tdukHdz3zoEPd180iiOG9xW8X0Kju8b+su1vBAgqQe cReWPPMWi7gEOmhoR/ZnQWtW3fep X-Google-Smtp-Source: ADFU+vu6WzpHn5qg+aeDQWydbv05vDibX4pkN4lVrelM0STP1h+Lc44f+lGs0T4jy2FAanBW1AKICA== X-Received: by 2002:a2e:3a13:: with SMTP id h19mr1138741lja.16.1583267782135; Tue, 03 Mar 2020 12:36:22 -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 t195sm1339532lff.0.2020.03.03.12.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 12:36:21 -0800 (PST) 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 v2 3/4] cpuidle: psci: Split psci_dt_cpu_init_idle() Date: Tue, 3 Mar 2020 21:35:58 +0100 Message-Id: <20200303203559.23995-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200303203559.23995-1-ulf.hansson@linaro.org> References: <20200303203559.23995-1-ulf.hansson@linaro.org> MIME-Version: 1.0 To make the code a bit more readable, but also to prepare some code to be re-used, let's move the OSI specific initialization out of the psci_dt_cpu_init_idle() and into a separate function. Fixes: a65a397f2451 ("cpuidle: psci: Add support for PM domains by using genpd") Signed-off-by: Ulf Hansson --- Changes in v2: - Adopted suggestions from Stephen to use IS_ERR_OR_NULL and PTR_ERR_OR_ZERO, which further clarified the code. --- drivers/cpuidle/cpuidle-psci.c | 46 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 19 deletions(-) -- 2.20.1 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;