From patchwork Thu Jul 18 23:43:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13736785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED270C3DA61 for ; Thu, 18 Jul 2024 23:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Faj5QcK3We3F3NVuTbRR7vS8a3eBKTUsob4pR7kBr7Q=; b=adyQoke78Rv/F/rHBv8J65DLz7 kazaRGTHoiOig7WLyHE3PMm9IftGFej+wSrJ/CBPo3aJg0WJ6fot6DNmD6r+1t62zWkANPXFsqVhz MX52t0Rn9psUXFAmWVkol5dg78JYd2sI3EM5LQdwqDW/EVB+tLXtntgkhWKbZxglUIddZQ9EYdb/g ysmsvRRcLYh4S8RkzDAuRhifPWbJGqo+PwELevXgkytuIws+uhVRriQxeqH63oto8xFBhX6K8fwTs ei8YAO4qV1THcZP3WSfHATLWow99VemaTAKLz3qG1xQzSxOyi7C1/uIeJIbbRJ6BlqbnVgIwfAOo/ kFp26qmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUann-000000011W5-2X9N; Thu, 18 Jul 2024 23:44:47 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUamY-0000000114z-0Af1 for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 23:43:31 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52e9f788e7bso1317870e87.0 for ; Thu, 18 Jul 2024 16:43:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721346208; x=1721951008; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Faj5QcK3We3F3NVuTbRR7vS8a3eBKTUsob4pR7kBr7Q=; b=hSP5p0kcE66hhs92/Vub+oYT88j3fSDffkfiVIHoExw/ED+6SGafy0XWMFSgYQqzO1 3N5TgQ3xv/hFT91QvM+Yz0vkUsfFsERlNGXOannwcJyB0Dk94qGTFa/J45YKe24vnPo9 jSgnshnffxXH5L+tlfUiWUiXied8vd7c6ijLIaTNhbXvEP1i15S8/3++/nWX4sZloceI DPd4N5dlDbhdnoYl6JphUNeIU1PdbkQ0wn3k+jwXxfTUgHvMmsxF1RV0FeSmxOitiN+6 mOmpEm6QC8ZPR2vdT6QmBg8EUN51EkurfyPgfEwMzlQNzj7VWyb94m/mVjgTvArlV92L Bbbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721346208; x=1721951008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Faj5QcK3We3F3NVuTbRR7vS8a3eBKTUsob4pR7kBr7Q=; b=rhgkEEK9xRmAFfA1AQqoTYx5mvcutUwvyLF3ibxTcixZgcaWRw9LPqfuSj03dG0JXA uQ8AlV4G64HaS79UQDlQ+zbhDnIbN8S8dea5I/FCzPFnCIxXkU7u3w8lFjOAbYIq8FTv 0l8dkhzQk6MyRQ71QkEJzgYc15rJvHeJ7wb2bo9X+9zvJcish1qZmj2zKjZlzVOqXHTE Q49XJhwiF3jRGLMDC1LMvNkes3t0+kyR0jrBAbaDdVI1t2QxnTknF09gXxv1Z+IWWs5u WF8QoM6kB9FVwK0QQE3MqOK83VwkHWd1V94CnNis4qIzwLlTXzzW11TzrjDt8UhEPuDs eqRw== X-Forwarded-Encrypted: i=1; AJvYcCVBUBO8D7OrWMw2wn9NQMp4UmHIU2JTWDQTaZ+yG5mD5iaf8voMQhLofSQY6//7HJOa7RAjG5wOFoYTl4TWz3ybmUEetnHdTdiWDIUM03o7evGXON4= X-Gm-Message-State: AOJu0Yw1rgf3taWZvSnR2KcZ5zjAqze3Oq4Q6qAbnq+fPeN/D1LwTPpl IkoN98Um++A2VxQJ31llNx3CiU0eUDCsEdSvvMqUvRjOwDjrdFEbGNu48nhDrQs= X-Google-Smtp-Source: AGHT+IHK7FOzBoV+1FS5of2LM4i6O9EZB5TaiB2xWzxT7vDsImay40B6se0ysI9gGqmvrwlYKjDpPA== X-Received: by 2002:a05:6512:234b:b0:52e:9cf0:69cf with SMTP id 2adb3069b0e04-52eeaea73bdmr3196721e87.62.1721346208245; Thu, 18 Jul 2024 16:43:28 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52ef556b4fbsm22491e87.139.2024.07.18.16.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 16:43:27 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Prasad Sodagudi , Thierry Reding , Jonathan Hunter , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] pmdomain: core: Manage the default required OPP from a separate function Date: Fri, 19 Jul 2024 01:43:16 +0200 Message-Id: <20240718234319.356451-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718234319.356451-1-ulf.hansson@linaro.org> References: <20240718234319.356451-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240718_164330_109370_2917383E X-CRM114-Status: GOOD ( 17.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To improve the readability of the code in __genpd_dev_pm_attach(), let's move out the required OPP handling into a separate function. Signed-off-by: Ulf Hansson --- Changes in v2: - None. --- drivers/pmdomain/core.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 623d15b68707..930cd5382032 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -2774,12 +2774,34 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } +static int genpd_set_required_opp(struct device *dev, unsigned int index) +{ + int ret, pstate; + + /* Set the default performance state */ + pstate = of_get_required_opp_performance_state(dev->of_node, index); + if (pstate < 0 && pstate != -ENODEV && pstate != -EOPNOTSUPP) { + ret = pstate; + goto err; + } else if (pstate > 0) { + ret = dev_pm_genpd_set_performance_state(dev, pstate); + if (ret) + goto err; + dev_gpd_data(dev)->default_pstate = pstate; + } + + return 0; +err: + dev_err(dev, "failed to set required performance state for power-domain %s: %d\n", + dev_to_genpd(dev)->name, ret); + return ret; +} + static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, unsigned int index, bool power_on) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; - int pstate; int ret; ret = of_parse_phandle_with_args(dev->of_node, "power-domains", @@ -2808,17 +2830,9 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, dev->pm_domain->detach = genpd_dev_pm_detach; dev->pm_domain->sync = genpd_dev_pm_sync; - /* Set the default performance state */ - pstate = of_get_required_opp_performance_state(dev->of_node, index); - if (pstate < 0 && pstate != -ENODEV && pstate != -EOPNOTSUPP) { - ret = pstate; + ret = genpd_set_required_opp(dev, index); + if (ret) goto err; - } else if (pstate > 0) { - ret = dev_pm_genpd_set_performance_state(dev, pstate); - if (ret) - goto err; - dev_gpd_data(dev)->default_pstate = pstate; - } if (power_on) { genpd_lock(pd); @@ -2840,8 +2854,6 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, return 1; err: - dev_err(dev, "failed to set required performance state for power-domain %s: %d\n", - pd->name, ret); genpd_remove_device(pd, dev); return ret; }