From patchwork Wed Jun 19 14:08:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13703853 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 6E4D7C27C53 for ; Wed, 19 Jun 2024 14:09:26 +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=j0o2btwvxJuAvs23zoxm88cS8MnRzldpGlzftLOxRCk=; b=Brn2jKwisnKFjNfMFZdCL/70Nt i82xi045q++5xTFLQFMR7OK+JxsjGsf0RwYolRSylViwXBe4QJp1PBNT8LMHQ/4wb8N2O7IFtxxu6 ZxMfXjcwFR9LTcunPKxbGu72qUZMaA0u3EBfT6xR90hTUMZ7nSzzPbW34+Ze7y1he3ig1ikECvdWO XkOJsk0//mQgTKTu6QvrRsUGdU730z0hRtr6AZvhauJGduyEa7BDv2bilBOf60GB1dPeXHEPH3SSd Wx142RvuRtbgvjJUmcwvwwTi02qf2/xleYCbi5kYVcU6tDyJlQkpSeXvPlxBc+uWDBQQ1hVGl/ARF pfUrnbaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzv-00000001R1Z-1Bsg; Wed, 19 Jun 2024 14:09:15 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzn-00000001QyV-1Qyn for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:09:09 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52c9034860dso8376140e87.2 for ; Wed, 19 Jun 2024 07:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718806146; x=1719410946; 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=j0o2btwvxJuAvs23zoxm88cS8MnRzldpGlzftLOxRCk=; b=n1xJ9kKDbGHHNKkKVdEfa7tvgalW+6HSJm1GEzPSyFcYsU6mCNIJRBLviqArVsdJfQ JpYZp7REW0WLKmA6+rjoz8NKBmEvBJ7Q8mudeiLpoFvgqs7C/2EoAD+VmGb9N6aYf63P DWq/cbnC4Ut6OmeV4lMZk6qoP2RHd0M1u/hQ3TzwYXd4lq9ZYVJjhQlVt1SwrbzbMOx1 0HqqMeae0TBeXR9hdOFkS4BxeeREhsNpSbQv6utzQJFFiOv9NAEUF8YRyQoUSCW0XRoK 5opyM9IA0tKQhKZYpW4uEdRyErr2vzsbxaSVR+RS+nElnIxW5lfWi0G057U6TeC8yXO0 42Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718806146; x=1719410946; 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=j0o2btwvxJuAvs23zoxm88cS8MnRzldpGlzftLOxRCk=; b=JhcD2DGhjsyeBy6TKOMzEImLUxoJOFuFTelKrfazx4p8IOsmqAu1oR4AtAMdkRgtan nWw2ASfS55C3EcMbgBMzSuACsZYVuHmGIuh1IwFFEoonCYAG9jbbZmP7XwW+WA0I5/UH mnuJK/lb34wjosTxwH5ZmpZBCJXtTJ92K5gZVKxFEW1ViydC91hVyjvFNqxTQElxr7l3 297Sy5MXaYUaEhMSzt49xi/znxtswSMctz8GRmwUT7AJIn/v1xheDQf/orNZMMagRijP btMtLQuJzbfO+VlSxLmv75IByZ/8i5WbCO2i5Jzpz2kK+FfQhj09PzGHQqXy7vI5gXk5 DvfQ== X-Forwarded-Encrypted: i=1; AJvYcCUHdoiuI3Qg8IJQGMmjdYzfZKBaS0LuwfiZa980NY8M7gosqp0vKJT/6/7ejXIVrJVa1tq35Cfnhuc9N9LEfHrfrVlZWHqpLeVhMLN0yDJE2v/PnvY= X-Gm-Message-State: AOJu0YxtSdTMl/pNHE/1oOJUhcbWCaD/HFN0McoFXoaBJVG9XIRJkoZu 4lQTKei98qzlCyt7yrwWPwn9iWWTkI1YFC92WakKDoD0peTZA9dzZjoMempO9rY= X-Google-Smtp-Source: AGHT+IGQ+IYY+K5JUtUrmVUaq99dM/Fd1SYa57uUXgyiboWmtgSst2pNGb8vCO3FJvkmSr34Pv77RQ== X-Received: by 2002:ac2:5f93:0:b0:52b:e7ff:32b with SMTP id 2adb3069b0e04-52ccaa32fbdmr1920541e87.23.1718806145693; Wed, 19 Jun 2024 07:09:05 -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-52ca2872241sm1787003e87.124.2024.06.19.07.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 07:09:05 -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, stable@vger.kernel.org Subject: [PATCH 1/7] OPP: Fix support for required OPPs for multiple PM domains Date: Wed, 19 Jun 2024 16:08:43 +0200 Message-Id: <20240619140849.368580-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619140849.368580-1-ulf.hansson@linaro.org> References: <20240619140849.368580-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-20240619_070907_405571_AE062B99 X-CRM114-Status: GOOD ( 19.51 ) 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 In _set_opp() we are normally bailing out when trying to set an OPP that is the current one. This make perfect sense, but becomes a problem when _set_required_opps() calls it recursively. More precisely, when a required OPP is being shared by multiple PM domains, we end up skipping to request the corresponding performance-state for all of the PM domains, but the first one. Let's fix the problem, by calling _set_opp_level() from _set_required_opps() instead. Fixes: e37440e7e2c2 ("OPP: Call dev_pm_opp_set_opp() for required OPPs") Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 47 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index cb4611fe1b5b..45eca65f27f9 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1061,6 +1061,28 @@ static int _set_opp_bw(const struct opp_table *opp_table, return 0; } +static int _set_opp_level(struct device *dev, struct opp_table *opp_table, + struct dev_pm_opp *opp) +{ + unsigned int level = 0; + int ret = 0; + + if (opp) { + if (opp->level == OPP_LEVEL_UNSET) + return 0; + + level = opp->level; + } + + /* Request a new performance state through the device's PM domain. */ + ret = dev_pm_domain_set_performance_state(dev, level); + if (ret) + dev_err(dev, "Failed to set performance state %u (%d)\n", level, + ret); + + return ret; +} + /* This is only called for PM domain for now */ static int _set_required_opps(struct device *dev, struct opp_table *opp_table, struct dev_pm_opp *opp, bool up) @@ -1091,7 +1113,8 @@ static int _set_required_opps(struct device *dev, struct opp_table *opp_table, if (devs[index]) { required_opp = opp ? opp->required_opps[index] : NULL; - ret = dev_pm_opp_set_opp(devs[index], required_opp); + ret = _set_opp_level(devs[index], opp_table, + required_opp); if (ret) return ret; } @@ -1102,28 +1125,6 @@ static int _set_required_opps(struct device *dev, struct opp_table *opp_table, return 0; } -static int _set_opp_level(struct device *dev, struct opp_table *opp_table, - struct dev_pm_opp *opp) -{ - unsigned int level = 0; - int ret = 0; - - if (opp) { - if (opp->level == OPP_LEVEL_UNSET) - return 0; - - level = opp->level; - } - - /* Request a new performance state through the device's PM domain. */ - ret = dev_pm_domain_set_performance_state(dev, level); - if (ret) - dev_err(dev, "Failed to set performance state %u (%d)\n", level, - ret); - - return ret; -} - static void _find_current_opp(struct device *dev, struct opp_table *opp_table) { struct dev_pm_opp *opp = ERR_PTR(-ENODEV);