From patchwork Thu Feb 27 12:45:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 183948 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4469120ile; Thu, 27 Feb 2020 04:46:24 -0800 (PST) X-Received: by 2002:a2e:22c5:: with SMTP id i188mr2845563lji.34.1582807583999; Thu, 27 Feb 2020 04:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582807583; cv=none; d=google.com; s=arc-20160816; b=sKGmk/s/ktTmla4zyUC9uO7SNr8uoWgA7gdIsSdmpffYCu8Wb+57tgEseRESd4yXkm g5MOAPaQRTNTqaSdMPRJIgEuNqzS5R9wJOUO0NEMC8+lH5UlSSZ03DasdpFqE4qOw6/T 3cVJfkExrQ7Kj0jg52Bg+VwlRRj7smmw8EGyKchEVmUFc2tHImrKdcEkJfrdFbx8D2L0 Ah+RDnll29UtayEeaQj6VujfD7zHYD2icwGt4Ob5nDEMY+Lt9ZOv8Z1469uNFtn0ae+8 g8Hovh7DWOR4MzgK4WgIhTceAB7A/Iw0iEfh1xXhkP0N5qfiG1SoefDuedm6Q6sdTz+H 1LKg== 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=ZPYRIg41YwW5y7gzBIFCCQYc7BuElmJfratXvS9/RTU=; b=w/tbOw1sNjYTKsPbDQFVayqX96q17rsYKd41KDXkKo3xSqi8ktJ2C8JR6bs9R34Fh1 s7+W0n4fqIsYtPlnj/nwF0LsXO0lYKZPNTcWD8d/Xh9OsgH6SItj1mr2Wd0aseiMpQSj 9hIvtUJXCodwEjtSBxFXXDkuL3Q1nEnS5CHHYthxuFJp3OB66a3WSviTq9FTu2MzJgMy QJdxSpAa3XUBX7K9NcYqBjsbkeyg8Et+carEJ6aOfy+5L+OmmjPuziFeBEWxNXFqEQ/4 jYsYEzhE89lywH7OnBRN69n4ZC13XguIw2MGFexvmmBWTQEC1h93imunO+RI6LUKQaYW ZJEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GRMBtDnu; 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 y206sor748743lfc.7.2020.02.27.04.46.22 for (Google Transport Security); Thu, 27 Feb 2020 04:46: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=GRMBtDnu; 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=ZPYRIg41YwW5y7gzBIFCCQYc7BuElmJfratXvS9/RTU=; b=GRMBtDnuFIHhKQLNR5bYnf0YeAvzu8Lkr45VhsfqrQDfegayFVkGEDHxmkTQbBM127 d0GGkdb82XKNRJ+F0B/Y7uK2QtkhbkfZmBzDRNEW6o1VKKoUgSaYFLuKaD6kIzusy/rg VlObzJ6OLnbrt7IhkbLN+nAxe8wDM2LT2gZCSH+4Pib6NlW6ItxKWAWYb2xtBk5FDUQT KJMjc+wYUwfzW8jO13sOV78g6kTWdJn2sAcNBULDQIhQ5JwOsvghkPFsog4VDoMa2+3T 6TmnBYL2K1XcXcMwVwiBUOdbZUS2b4DvOfXDcQ1w17MtSe8UwPRJgNyllErCUf8gBaZw iXKg== 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=ZPYRIg41YwW5y7gzBIFCCQYc7BuElmJfratXvS9/RTU=; b=Scc/Sp6llQNddXxz0NOyqILII0DdRzbs27Av6Jpkk8ZUE4PN8xqRJMSpJVd7XwBl5K WUBuONkLdJnjnscU1g9TRU9yISiKzcQJg48FANglPgS53OV/rQYH+kL/Mw79pt8HYLbv 2nTwK25HUSlb3CYXcPC+kAs4b98BA6cip8W0ormhY8wSiIfQg1BNF+K+0tZ3x/mleeqQ T170hXtcaULLkfhXWrnOMWmgXZ5a/vPrQ12VkyurHUjwHAheAPjhr4F3fL6jdJi2Enbj tDbS+4ZAJGANuQcwvohRZdN1SrPkKauIdtvPpdbvsMtJcWCRP4XqKyq7dWwAIO9Kr1hz OCmg== X-Gm-Message-State: ANhLgQ0O+TVoPz9hGTkcbE+94/w9Y5fVdf51KWXnidXtjGiH2imSj368 zs31VcyntxlQsTQp+aIU8dmfjTua X-Google-Smtp-Source: ADFU+vvy3xadzFJgMR579KvBJp97cg/u1LNr5iTXRd789EXBWJ1RL/VY1A+sJYMUch7iOHDB2kfK+w== X-Received: by 2002:a19:6445:: with SMTP id b5mr2044742lfj.187.1582807582480; Thu, 27 Feb 2020 04:46: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 l16sm2669334lfh.74.2020.02.27.04.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 04:46:20 -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 3/4] cpuidle: psci: Split psci_dt_cpu_init_idle() Date: Thu, 27 Feb 2020 13:45:50 +0100 Message-Id: <20200227124551.31860-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200227124551.31860-1-ulf.hansson@linaro.org> References: <20200227124551.31860-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 --- drivers/cpuidle/cpuidle-psci.c | 49 +++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 19 deletions(-) -- 2.20.1 diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c index edd7a54ef0d3..7b459f987c50 100644 --- a/drivers/cpuidle/cpuidle-psci.c +++ b/drivers/cpuidle/cpuidle-psci.c @@ -160,6 +160,32 @@ 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(data->dev)) + return PTR_ERR(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. + */ + if (data->dev) { + 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 +219,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;