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: 184347 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp552540ile; Tue, 10 Mar 2020 03:40:43 -0700 (PDT) X-Received: by 2002:a19:c34e:: with SMTP id t75mr11720101lff.197.1583836843164; Tue, 10 Mar 2020 03:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583836843; cv=none; d=google.com; s=arc-20160816; b=AAcKGd2stJsHDvNdyVt42JMul3dzHHWz1ZW8OHi4oQY8zkDPhee5a8D/yU2v10Qzwv +iRNWeM6u7yjNzewmRACwgjcXIL+y+1S6WV6QM+IceiT74yQTFO2N+Sqiey+TLUQ6bHr iUoXgGUX+MfcJoimtpJt1rEXicJr6G1gmnBO19ag8yo+2CYkZ4/hLUpiV1EEFVSegjWf n120G9APDA1w9m2Sel/Li3JkeTI5I8bknx8npkSmvesgCBk/knN6SZYu/zReQJnXWqx1 uTvLnN1g+aux3Di4/JY8kRWIIJrhVzzvcmMpSh50heJ+zjUpsD6Ofc3UhSrMNtAtxwM+ CnQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=6pxlLk38rJ+HhQrbDG9StMgSzEGNLqFsirKScynCScU=; b=O17IH9zFmZPSfsqW3hcyJBWlRZ5pAQL3RJ6LVwiefLpcWTQok2iai2TJ4Xy7XOFQHk cwLO1kN5qDsUcHVqxfKEqVkfATERN5efSP+sE6qR/kLHJLfaid+ZUtafohMw4mSINROR 5axfbZSxkbxVzgrHrh7hejfNmwZJWO9ol9yyIcIvA073tMB24WLiOLqny56AJ6X1XPoS jJFB0iqTKyQ+jBH2W0wfSwiHmY4tXkTdNoZOKBAGXQK8MMJZVRGmAKR4SQlp3quonmzx 6J19u0uVUISyP8hJYpehfcIKy9g9GZkarUtJY5/QbijjXgiZrTR0Q7H5FEgn2ayw0iBP 3Zwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nc6/NWC0"; 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 m22sor3320888ljb.33.2020.03.10.03.40.42 for (Google Transport Security); Tue, 10 Mar 2020 03:40:43 -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="nc6/NWC0"; 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: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=JzMhooe1EujIMD/LqhNLZX/tEJdXf7R5VP5j4zbocYXB38Q4F2RikHPMe/q1DHKvyx JVdPY8l8DA8Bevmd0R0pHEJvPVElMU6k5C/D6PoOcl2RQxeqOi6+EGvZyUYKz67VqUk3 WwwW1HvIJjkLPMI9ALjyy7bCzE5i/nSEbP2qsJuVPbGG3tT9xw2uV+LyWeww3LH8tCrr QZVcOow0JiKSaxt1ChRfnbI/eGc+OupSiNtk4OSqe9Dli2wiIUptCGQCYULLYEENzmM0 akCZFNd1XZbFlJJKmrZAYq0DJMM+Ftxu/51Ffs5q46FJOaYQ1AsJbe0imFjVtaBe2HjT hEdQ== X-Gm-Message-State: ANhLgQ3yNvjDA4qxJ9pSzG228Y+jaEBvCp9Kz6YsZFNxmVq1v/aLJh4p dbcrUaZw5GIJMkJ1EY5+3gVOknJL 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) Return-Path: 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 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(-) -- 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;