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); From patchwork Wed Jun 19 14:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13703855 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 79403C2BA15 for ; Wed, 19 Jun 2024 14:09:28 +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=u1K1pfLjx3yXde9nph0uxH/MYhA+YR/At4AWwuoRbU0=; b=x1QbrEcgF54m+C9YJj8eJyhRhE BvBuaJlFpYmpcwMy50REXz0yHV88ppqfq/SviWnonJ+c0oqhYsxIiGuEmBS0S2JKhcw+0GyyNkavC rCJxDQ98ITR0yAGlR093l+ytvgaZxoxfrYMfEYghG69+hk1Zv1I2McGjSHyPixnj5BQ/7XuYAOnDC rT+b1eWsUlqj9k0SxiHEWBGx7e7+y0kCv/vmM1ikFfpboJNq6uS7xaZSooMAc1SaYDtplz7OvVZM9 VoRQ6eCdn9i09BLX9Ourp+EbsL0jx7xL6+XjSn4Qy4BLvdB1DbhlWaJ8rvWVEzNietCOZXLcNwpR3 o1yXYxFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzw-00000001R2D-0uiv; Wed, 19 Jun 2024 14:09:16 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzr-00000001Qz7-2UiH for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:09:13 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2ebed33cb65so74413231fa.2 for ; Wed, 19 Jun 2024 07:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718806147; x=1719410947; 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=u1K1pfLjx3yXde9nph0uxH/MYhA+YR/At4AWwuoRbU0=; b=KsP9eqHoTJP++/N3tQveKVYSIBZWifML45msk8OJAC5cvIOao163hCqvEMirlt8YSM ECmF0shzhWSFq//EJktVybliV8CqEMdJVvAHRo0A64uo7V96ngD7Gfl/KFkqMMAxHK8s AzLLakx15r+OADi/YdsxoA1v07flWgGhJBSpbe22V+IiUySPwdhtpLo+hK7Gbsn5kFjX +fF8/B/ynLqYw3JSAruuzeJuPm3fB5x5YWMzNfZ6EbGDWBAzw6lZVDoMVvIkX7Sj5g89 LaIbLVQnnfeb47GO2XxlAL/7AGq3wXYorpJWQuIwFwofSmYaTWYggfqtvX5Vv5vTWmvh gHiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718806147; x=1719410947; 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=u1K1pfLjx3yXde9nph0uxH/MYhA+YR/At4AWwuoRbU0=; b=u+yqm88tDYuAabax9E8/Mw6lGcXAtA4nSJoY+ciaczLPKWm86va5J+WRAvbFr3Jzvv Wb2/Oyqjd9tKaxuD2m2b+6IPZZZL54BMCMT11dkZ+ivk9R9ocg1SYFtTEHm7Sq8CH46k CGvXK4fjuxhpe13k/mZe/MxQ8QY+D68qn5kWuWOw9WSmC8qpV4e58J4bsZfQn1Orcd1F 8Z0UyOoZ6CCyqZlMmOgNm+atj0DnS9CSBhPhWkRpnocnznqK26TL1V02V6YXFGMlHsKH MgSeZ2DY2QqeLZxssPoRpslrelNocBqDWDOSHc2I5sesotQpN7r2UIy+3//9aNORHSYX zslg== X-Forwarded-Encrypted: i=1; AJvYcCUD1kfXnaZqXHSb6ehBJqEdqjhokskJSD/CO/WW59o6Og8bBvfdBmZ4hoqnXFi9N4vH4ifoX5zuHKocSGwphbi5xJPVipKXlpoYYpunY4OSOhh8P/Y= X-Gm-Message-State: AOJu0YxgZt+Or3tfDBdgbdigurKGdSEYMFb7dbYVKYpcd8lRRspuFoDe CRtkUu5syOPed+6/gVfSN1hvzGprS15CthCrECPo/u8Fj/Sdo29zba3xC7RzbT4= X-Google-Smtp-Source: AGHT+IEVGpl8euILARdKcz9t6ynE/gJP+grfmU6GsH/Be6u3fMQfkdUuTeM52zWE+8c5drYOKvWenA== X-Received: by 2002:a19:7006:0:b0:52c:c725:9d16 with SMTP id 2adb3069b0e04-52ccaa5f3dfmr1796341e87.30.1718806147197; Wed, 19 Jun 2024 07:09:07 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 07:09:06 -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 2/7] OPP: Drop a redundant in-parameter to _set_opp_level() Date: Wed, 19 Jun 2024 16:08:44 +0200 Message-Id: <20240619140849.368580-3-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_070911_667424_CA8D6B98 X-CRM114-Status: GOOD ( 12.15 ) 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 The in-parameter "opp_table" isn't needed by _set_opp_level(). Let's therefore drop it. Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 45eca65f27f9..02ba963d11ff 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1061,8 +1061,7 @@ 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) +static int _set_opp_level(struct device *dev, struct dev_pm_opp *opp) { unsigned int level = 0; int ret = 0; @@ -1113,8 +1112,7 @@ 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 = _set_opp_level(devs[index], opp_table, - required_opp); + ret = _set_opp_level(devs[index], required_opp); if (ret) return ret; } @@ -1172,7 +1170,7 @@ static int _disable_opp_table(struct device *dev, struct opp_table *opp_table) if (opp_table->regulators) regulator_disable(opp_table->regulators[0]); - ret = _set_opp_level(dev, opp_table, NULL); + ret = _set_opp_level(dev, NULL); if (ret) goto out; @@ -1221,7 +1219,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, return ret; } - ret = _set_opp_level(dev, opp_table, opp); + ret = _set_opp_level(dev, opp); if (ret) return ret; @@ -1268,7 +1266,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, return ret; } - ret = _set_opp_level(dev, opp_table, opp); + ret = _set_opp_level(dev, opp); if (ret) return ret; From patchwork Wed Jun 19 14:08:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13703854 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 492DAC27C79 for ; Wed, 19 Jun 2024 14:09:28 +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=aJlwtJVzi6XNiVK5ZSTOV746RcDL3LF9tmFw5hjmIxo=; b=PSYd6iqUqRADBd7GMkkNunnPnO G4GmHFhbHFkUpcnQqT42pQU4AmGh0jRiQo3te0++yZVnFJ3D0JEs9Zfh8UNf5hAt6XEJ1WC3quPlM +COFqekZYzIDwKgF+Q7vS0X0u12MoOZmqtXdCIVxuHcplBwgyVwGRtyC8Dgc9EnGT+v81YAUsEluD qNn3b8t0tv9AroOw7tjb05sdBn7VzqnJsGokYc4r4jPBx+b/1gF82M5s4UvzuXZylSPNfA4D7T+jK zhnZGtItoQpo9ko6Belajd2sRKiEThrzUjlgqXQREiSpIi5LjS5tbIF0MQ+8IzK8pAhlRTMPMU6Vm thlwa+7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzx-00000001R2k-0XEB; Wed, 19 Jun 2024 14:09:17 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzs-00000001Qzt-0qkx for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:09:13 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-52b78ef397bso843544e87.0 for ; Wed, 19 Jun 2024 07:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718806150; x=1719410950; 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=aJlwtJVzi6XNiVK5ZSTOV746RcDL3LF9tmFw5hjmIxo=; b=QGiF4mGwCQHhQKfXQk1l6jpVXzfzFVSmWNKMjQHiwi9hzu6EaLXUpnaFgzypIkAz+5 etW5rI6bEQUXOu4ovyxWZ+IEFf/Z6pZqa8De1oKFUv2afmNaNgpVXzZY4BoCO5a1C09n F+lmqJx4Xq2fUPjjavLbNz6ZYHWtODU4oTzs420SasjMVi6N0PvJE6SEuZWetmUIV4cV AsG3pEkaCSFxpZXkQUOQn82v7U0RHoqktJNHRkB7ZG1FcGhGCoDdE/pqcgagL3Wa5WoT gIPUjds2k3tXQwNSySD8dKVHti5pA1cSeGhE03gzcejLLsfTzl1VDXfJwhlMSssaidoO /CVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718806150; x=1719410950; 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=aJlwtJVzi6XNiVK5ZSTOV746RcDL3LF9tmFw5hjmIxo=; b=AWLYlhxKe1KyEOvef6E0JF0aSNpm+PtqaPWu6TBZYVNtyOUEfyZPoMriXWYIIN9DeU dOP8mnmz5XD/yH3o4iPMZoLopiFDU2BDN/q2xQfP3CMZWoLnRU3gXzAIp2Nw/3SrMD2g hNRGSUgJFx8dVjePUG2ZKVljMUFvV86Z62flvlIrDIYmMbTOcPFxm6cYwhOXcvWcprbH iHNHmDI0qbd+XpHhMcjADwK0y1IuiiVth7HtFO7WkeBNuxJ/h4hhnaEWvImUJuz4EHzI 9HwjbRNe83172LDvuWpvDEGA8kHhxK8Ct3qyDfmpspA3ecK+FKGYJdljpcq4SzYECMPz AXPw== X-Forwarded-Encrypted: i=1; AJvYcCWfMKQaxUzRWoj/dbXSr+xexsSlTmfH2xyRQ1SB3H9F0NOMjpQ5mhewCF4p7nFwF2OIAERoIhaZupZDPaVvmFnfNRkY4FtQCAf9pdaZu+Lw9Dn9k04= X-Gm-Message-State: AOJu0YyjQT7oZwlUSkeOyS6d33hDeYLwjs4k8wfoKrmeHd0qvND7Vwa4 vsLAy7Zy5AWojXyqjlF3LpihjY5XOiL6GDqzWtOVQcgYXCbPpxVH8bWW+TT3DTA= X-Google-Smtp-Source: AGHT+IH8szx+wGfNF7xCKKOXXggxhUc5i6OCYEwmr+61pe4qfUaU6Uy78GSQKKnrYH7d3bzd2PkMRA== X-Received: by 2002:a05:6512:31d4:b0:52c:c64e:b902 with SMTP id 2adb3069b0e04-52cca1ea264mr869272e87.27.1718806148309; Wed, 19 Jun 2024 07:09:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 07:09:07 -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 3/7] OPP: Rework _set_required_devs() to manage a single device per call Date: Wed, 19 Jun 2024 16:08:45 +0200 Message-Id: <20240619140849.368580-4-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_070912_278510_50D27273 X-CRM114-Status: GOOD ( 30.73 ) 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 At this point there are no consumer drivers that makes use of _set_required_devs(), hence it should be straightforward to rework the code to enable it to better integrate with the genpd attach procedure. During genpd attach, one device is being attached to its PM domain. Therefore, let's also update the _set_required_devs() to work with this behaviour and instead trust callers to fill out one required_dev per call. Moving forward and as shown from a subsequent change, genpd becomes the first user of the reworked _set_required_dev(). Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 89 +++++++++++++++++++++++++++++------------- drivers/opp/opp.h | 4 +- include/linux/pm_opp.h | 10 +++-- 3 files changed, 71 insertions(+), 32 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 02ba963d11ff..bc1ed1d3d60d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2483,9 +2483,10 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, } -static int _opp_set_required_devs(struct opp_table *opp_table, - struct device *dev, - struct device **required_devs) +static int _opp_set_required_dev(struct opp_table *opp_table, + struct device *dev, + struct device *required_dev, + struct opp_table *required_opp_table) { int i; @@ -2494,36 +2495,68 @@ static int _opp_set_required_devs(struct opp_table *opp_table, return -EINVAL; } - /* Another device that shares the OPP table has set the required devs ? */ - if (opp_table->required_devs[0]) - return 0; + /* Genpd core takes care of propagation to parent genpd */ + if (opp_table->is_genpd) { + dev_err(dev, "%s: Operation not supported for genpds\n", __func__); + return -EOPNOTSUPP; + } for (i = 0; i < opp_table->required_opp_count; i++) { - /* Genpd core takes care of propagation to parent genpd */ - if (required_devs[i] && opp_table->is_genpd && - opp_table->required_opp_tables[i]->is_genpd) { - dev_err(dev, "%s: Operation not supported for genpds\n", __func__); - return -EOPNOTSUPP; - } + struct opp_table *table = opp_table->required_opp_tables[i]; + + /* + * The OPP table should be available at this point. If not, it's + * not the one we are looking for. + */ + if (IS_ERR(table)) + continue; + + /* Move to the next available index. */ + if (opp_table->required_devs[i]) + continue; - opp_table->required_devs[i] = required_devs[i]; + /* + * We need to compare the nodes for the OPP tables, rather than + * the OPP tables themselves, as we may have separate instances. + */ + if (required_opp_table->np == table->np) { + + /* Cross check the OPP tables and fix it if needed. */ + if (required_opp_table != table) { + dev_pm_opp_put_opp_table(table); + _get_opp_table_kref(required_opp_table); + opp_table->required_opp_tables[i] = required_opp_table; + } + + opp_table->required_devs[i] = required_dev; + + /* + * Add the required_dev as a user of the OPP table, so + * we can call dev_pm_opp_set_opp() on it directly. + */ + if (!_add_opp_dev(required_dev, required_opp_table)) { + dev_err(dev, "Failed to add the device to the required OPP table\n"); + return -ENOMEM; + } + + return i; + } } - return 0; + dev_err(dev, "Missing OPP table, unable to set the required dev\n"); + return -ENODEV; } -static void _opp_put_required_devs(struct opp_table *opp_table) +static void _opp_put_required_dev(struct opp_table *opp_table, + unsigned int index) { - int i; - - for (i = 0; i < opp_table->required_opp_count; i++) - opp_table->required_devs[i] = NULL; + opp_table->required_devs[index] = NULL; } static void _opp_clear_config(struct opp_config_data *data) { - if (data->flags & OPP_CONFIG_REQUIRED_DEVS) - _opp_put_required_devs(data->opp_table); + if (data->flags & OPP_CONFIG_REQUIRED_DEV) + _opp_put_required_dev(data->opp_table, data->index); else if (data->flags & OPP_CONFIG_GENPD) _opp_detach_genpd(data->opp_table); @@ -2640,7 +2673,7 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) /* Attach genpds */ if (config->genpd_names) { - if (config->required_devs) + if (config->required_dev) goto err; ret = _opp_attach_genpd(opp_table, dev, config->genpd_names, @@ -2649,13 +2682,15 @@ int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config) goto err; data->flags |= OPP_CONFIG_GENPD; - } else if (config->required_devs) { - ret = _opp_set_required_devs(opp_table, dev, - config->required_devs); - if (ret) + } else if (config->required_dev && config->required_opp_table) { + ret = _opp_set_required_dev(opp_table, dev, + config->required_dev, + config->required_opp_table); + if (ret < 0) goto err; - data->flags |= OPP_CONFIG_REQUIRED_DEVS; + data->index = ret; + data->flags |= OPP_CONFIG_REQUIRED_DEV; } ret = xa_alloc(&opp_configs, &id, data, XA_LIMIT(1, INT_MAX), diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index cff1fabd1ae3..5b5a4bd89c9e 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -35,12 +35,13 @@ extern struct list_head opp_tables; #define OPP_CONFIG_PROP_NAME BIT(3) #define OPP_CONFIG_SUPPORTED_HW BIT(4) #define OPP_CONFIG_GENPD BIT(5) -#define OPP_CONFIG_REQUIRED_DEVS BIT(6) +#define OPP_CONFIG_REQUIRED_DEV BIT(6) /** * struct opp_config_data - data for set config operations * @opp_table: OPP table * @flags: OPP config flags + * @index: The position in the array of required_devs * * This structure stores the OPP config information for each OPP table * configuration by the callers. @@ -48,6 +49,7 @@ extern struct list_head opp_tables; struct opp_config_data { struct opp_table *opp_table; unsigned int flags; + unsigned int index; }; /** diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index dd7c8441af42..2b6599f6037d 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -63,10 +63,11 @@ typedef int (*config_clks_t)(struct device *dev, struct opp_table *opp_table, * @supported_hw_count: Number of elements in the array. * @regulator_names: Array of pointers to the names of the regulator, NULL terminated. * @genpd_names: Null terminated array of pointers containing names of genpd to - * attach. Mutually exclusive with required_devs. + * attach. Mutually exclusive with required_dev. * @virt_devs: Pointer to return the array of genpd virtual devices. Mutually - * exclusive with required_devs. - * @required_devs: Required OPP devices. Mutually exclusive with genpd_names/virt_devs. + * exclusive with required_dev. + * @required_dev: Required OPP device. Mutually exclusive with genpd_names/virt_devs. + * @required_opp_table: The corresponding required OPP table for @required_dev. * * This structure contains platform specific OPP configurations for the device. */ @@ -81,7 +82,8 @@ struct dev_pm_opp_config { const char * const *regulator_names; const char * const *genpd_names; struct device ***virt_devs; - struct device **required_devs; + struct device *required_dev; + struct opp_table *required_opp_table; }; #define OPP_LEVEL_UNSET U32_MAX From patchwork Wed Jun 19 14:08:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13703857 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 A40B0C2BA15 for ; Wed, 19 Jun 2024 14:10:00 +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=CDWaPf7+TN9M1cnbl/7mu5+omOHy+MPUVcUqdXnYMd8=; b=Q5gHRD2FerodRuZecimWq01zUf XZBa9tFiEvulXhN3DArJahYl4b6qxb7HYsYAhCIkGK7Il1CD07oefl54PqQ5fp37dsz5gCmYYCuv2 1TMSaGFQ45wApPfmE3X3QFeiiZUq2QnDfrUR6eR1ddhixnhThHNWA1l++i4TJyZCqz+WG/vulSvCQ YYRYSdkvot5ytKKyXn9mT27FCwFAhwfpCgnFkYUXdKUM7a8lsFcqZb0GSlLTZOUkN/dXkSwQjru+a ZB5Ua8XQkgkV6cvKz/+ZtqymzVVoj8hqwiUXvO1RUNoy6YUgenYVQ9wAXTWF1zyloL97a6dGXbT7f rTWh4tmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw0R-00000001RLk-2SNL; Wed, 19 Jun 2024 14:09:47 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzt-00000001R0d-31Rv for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:09:15 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52bc27cfb14so8015408e87.0 for ; Wed, 19 Jun 2024 07:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718806152; x=1719410952; 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=CDWaPf7+TN9M1cnbl/7mu5+omOHy+MPUVcUqdXnYMd8=; b=LkE3QGi1kLpHZOaxxkQwUu35n0LaoNnO8kHeseL4wcO7Xg2tlhMR7INFpfxYBi+ddV +CDLUFaW4A4nXDPKZ/YHm1TXiFGz2wnykNv5sfKr2xuEKxOfl4cwa7VEk6/YkEbDjlau pYoyqlI74Df9XDijWjkknJ747Qcuwfy4G/ZD3ggDZTfT1Z/7sRm57rP75Lzh1ga9x5BP CIgfB8iVBee8mKbuxux/07/+DA8c7Jd/DwPYwlfzWzqZNqMQTBSLFeSlH/dYZrNYF0RO ka2CnyMwovoKWNt/9n4nA8hfV5fUY6l/qqDLLkYHK5iCNxvriYr5uzhZ+HleI85ACwS5 xCDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718806152; x=1719410952; 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=CDWaPf7+TN9M1cnbl/7mu5+omOHy+MPUVcUqdXnYMd8=; b=QhxRKaQ02R8UCNM9CroV4goJN0uZQMMlC8UN+Tx/mB7ca0dUWAO3ViWSwItFKWQT8k zgNcUwC3k7hbYHoXf/+uVo3mP4GFdIazjS9Mi0SBiCfR/6C3EST4iHzwbK17cGGnBx4j QPCzlCdoGomrD5aIvkFfN7gsmFHTCHYUgBYmTQO2nW3gC46w4YHzroUdE66JCP8vjp0H sQVZk9yMdOYf+9KI60LrZak5fg7ouFYN9bKalUTYtCjRVnJyuvo2o6jJy+FeEmigrWDu aztcz6yBJQvQUv/d/+4wKYVOvYl6gm+dW9aHQNHJ9Qxd7uW6OVip1PeJ0JcOlOshLVwt HQVw== X-Forwarded-Encrypted: i=1; AJvYcCUfvNm9+E0BB0LkOl0UzddEdDAY0cc4y+Wl/wjnd1oMBU2peOhiKTg4tCxHMEaeXR6AoVe0oOo08MiVZPJn0lwKI2phPjSfArWonskInfvtdlDcO5Q= X-Gm-Message-State: AOJu0YzsfAHb5Btg7iMEI/2IfDkxQkjMfxztez1NUrbDx14z2p6XUJz6 0X4ZjW/LqI5eT0RP36Hfi+9XuujaJ85neRBuXJqrnnFmZ1MggKN3pLeO8+JsOCU= X-Google-Smtp-Source: AGHT+IFbKCEpIt59r0vwx09Jj3ZBoGPhwAYQUSf6Kkwln2POjh4upJ24OJAsVYPh1tHMRchYqc0ZgA== X-Received: by 2002:a05:6512:e8c:b0:52c:aaa1:977e with SMTP id 2adb3069b0e04-52cca8b0e87mr2662675e87.0.1718806151472; Wed, 19 Jun 2024 07:09:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 07:09:11 -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 4/7] OPP: Introduce an OF helper function to inform if required-opps is used Date: Wed, 19 Jun 2024 16:08:46 +0200 Message-Id: <20240619140849.368580-5-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_070913_799998_9B10BB45 X-CRM114-Status: GOOD ( 14.56 ) 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 As being shown from a subsequent change to genpd, it's useful to understand if a device's OF node has an OPP-table described and whether it contains OPP nodes that makes use of the required-opps DT property. For this reason, let's introduce an OPP OF helper function called dev_pm_opp_of_has_required_opp(). Signed-off-by: Ulf Hansson --- drivers/opp/of.c | 32 ++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 282eb5966fd0..55c8cfef97d4 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -1443,6 +1443,38 @@ int of_get_required_opp_performance_state(struct device_node *np, int index) } EXPORT_SYMBOL_GPL(of_get_required_opp_performance_state); +/** + * dev_pm_opp_of_has_required_opp - Find out if a required-opps exists. + * @dev: The device to investigate. + * + * Returns true if the device's node has a "operating-points-v2" property and if + * the corresponding node for the opp-table describes opp nodes that uses the + * "required-opps" property. + * + * Return: True if a required-opps is present, else false. + */ +bool dev_pm_opp_of_has_required_opp(struct device *dev) +{ + struct device_node *opp_np, *np; + int count; + + opp_np = _opp_of_get_opp_desc_node(dev->of_node, 0); + if (!opp_np) + return false; + + np = of_get_next_available_child(opp_np, NULL); + of_node_put(opp_np); + if (!np) { + dev_warn(dev, "Empty OPP table\n"); + return false; + } + + count = of_count_phandle_with_args(np, "required-opps", NULL); + of_node_put(np); + + return count > 0; +} + /** * dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp * @opp: opp for which DT node has to be returned for diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 2b6599f6037d..5fade5c4de40 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -476,6 +476,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpuma struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); int of_get_required_opp_performance_state(struct device_node *np, int index); +bool dev_pm_opp_of_has_required_opp(struct device *dev); int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table); int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus); int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW, @@ -554,6 +555,11 @@ static inline int of_get_required_opp_performance_state(struct device_node *np, return -EOPNOTSUPP; } +static inline bool dev_pm_opp_of_has_required_opp(struct device *dev) +{ + return false; +} + static inline int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table) { return -EOPNOTSUPP; From patchwork Wed Jun 19 14:08:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13703856 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 CD355C27C53 for ; Wed, 19 Jun 2024 14:09: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=htFpAgDo306pFLyFNLJIsFnxeXuNDgJdkPPYgP2iQ3A=; b=TDajRC0XDD8NYOgnNhU81vL5Mq P5XOw4FcgLTtoLb0R0JYMPOnr7TT00EbdaIyj4Yke9i72mWw0VLi905vSUwD7tiVoh6fNbehJc47K erXif0n12WckgHJ6WkHsoQwMXcn1oglb1Q1vHpa3ppB5y7x7HKCs+c7rj+TIw7yVxamlgM8BQhAV+ srljho3lQd9U7PZuieLTTtNqBLVCSysFNIC+sd0667rPvyoeJsiMl/9qPuJJNT4J0x5OmGvCYQtHC QTsEFqOhwpnTaimPnPHwhX3Y0g0qe2nMXAN1+pP6+s7/sqaD/On2leIA90fOtVbyw9T7F9D+EOzIk 3CdkwVog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw0S-00000001RMR-33oi; Wed, 19 Jun 2024 14:09:48 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzx-00000001R2G-1ThI for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:09:19 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5295e488248so7162567e87.2 for ; Wed, 19 Jun 2024 07:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718806155; x=1719410955; 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=htFpAgDo306pFLyFNLJIsFnxeXuNDgJdkPPYgP2iQ3A=; b=fYMjaR1JHrWLg0KEQdk9Vlj/E8ebO3Tt5ySWKwngWzq1GZrHVpL5Cm7lMLDFgugbG9 sP7tc7OhEYxnnDg14v2BTFWvk9qqxtgl6jD6Ws/5yDIARnYR0excx7GZhAepCYpfI10Z ZPpRkWsYxnGvsBkGo3Bmio849gEzWiL7WSMViRpHkpGFf/iNHcinsgTep6NLfJt0TAW2 BwBpHORne9WyOp6zWcDALZX97CysBpVS1yPUOvki+HGMRcMtF9YNR5HLFP57tntqemz0 wWtdoW2RxnvqpKAXLLPwzShe/33n5AsiiKyJAdfE1hcLhy2aAg9d/St0xd3NQTouWlsg svAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718806155; x=1719410955; 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=htFpAgDo306pFLyFNLJIsFnxeXuNDgJdkPPYgP2iQ3A=; b=CYNgfJ2UjNg+xjS62qtawl6IltrN3l1w9sYjQtmgkWGdIqRkXFRfjV012avF/TIn8e YDyMl0arOItRuV8+mLclh0zWz2D8WImpsNSx4K2DmHCGcoWmqOBNg7csxV6PqRa7jQnD 0XDiBmENXGWRzaUzmymGob7gjKAEpXOpR5EmcACOImuxZv02QfQyUhEPhy7MQeC2jCLf +SD3Ay2gsVmHO7arPaqWAU6HVhXPFgFgWQJpYyP18JhsXlMzBbszJRTnPIkQgzyFeO/0 YKjUKxfi28Y17+UWO5GenBLvtpTW+UPkMhqJY0mpKqGvoe7HJAuS4VlXIY0MvJ1twow4 IIeA== X-Forwarded-Encrypted: i=1; AJvYcCWTl1IqGi/wykisILHturO/Xe6bVrBO1sJqtzIMZ5sKP1OWM4yvSyXrg3zhZE004airaZ0MNUHZ3QBnOeTA16mLRYWuUvI15vp2O6EXpZa4V3NxhNI= X-Gm-Message-State: AOJu0YyJneVSaAJcamUizLvGH7AKqV8J9dDSKNTJfAbdgkxcknAsb8Au vuDyF4ZVPwSpvlYe1WHUbZNeTBMBnUFYetKiTZ2HmYkFye+Rjyg86CWElEja+/g= X-Google-Smtp-Source: AGHT+IHfAlr5DrpIAaWiiNsj4x6QaAAeJHHW2gKvh16J7kuwaVsds0u8zDkuPraMr/WEHw60Qa+NSw== X-Received: by 2002:ac2:44b6:0:b0:52c:893c:6c2c with SMTP id 2adb3069b0e04-52ccaa3756amr1415929e87.40.1718806153456; Wed, 19 Jun 2024 07:09:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 07:09:13 -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 5/7] pmdomain: core: Manage the default required OPP from a separate function Date: Wed, 19 Jun 2024 16:08:47 +0200 Message-Id: <20240619140849.368580-6-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_070917_477227_3D9946DF X-CRM114-Status: GOOD ( 17.26 ) 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 --- 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 83d978743659..74ebb8a423be 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; } From patchwork Wed Jun 19 14:08:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13703859 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 B4F17C27C79 for ; Wed, 19 Jun 2024 14:10:04 +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=jH7teSUneCZWfoVt/91/lHeZpMwu3/Yn++4TJjeU7NA=; b=VKqdKYK6jKlVF0ZtVPLnBwRhWV 5pohXBa9qypDoiJxCW4aqnq+g3nhaO077f8pRO5DJcbWgaspCKw9ashATLxzkYXeMvKV4DghfSzOl BmHUgt8iuVY1beXXD7NX81Ez5p+Vm4T43u58exqrwtjYphmmCnU5Gbz79Tqq9LrmBWw4eL7p5wt8o /w2ieqyJ25rYMVDoUl8UMnRcgFT7hqGVI/MmdvbzDQfYy8tF1SSHEGsNZHUpQUYK1nW96yI0xhW1U 2PWljT/yhvY+UUojC20FUmkoP+5p4JOxGw0lgXhwXSq3z8C4zNHklyxPTTjX50/hEIzFiOfe+sBJ7 f1utoCpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw0W-00000001ROI-3Nxk; Wed, 19 Jun 2024 14:09:52 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzy-00000001R2r-2DJE for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:09:23 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52cc14815c3so2364107e87.0 for ; Wed, 19 Jun 2024 07:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718806157; x=1719410957; 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=jH7teSUneCZWfoVt/91/lHeZpMwu3/Yn++4TJjeU7NA=; b=RrDQu8uDjpuXmlENWr1qx7ODIwZrp3PwhUoQb0C4SCR/KWWNJY0D0oe1QyclfrfDw4 hFt8c3joAaZym+omIdRBfpi558oB7WsAne80aY2bfDBsyxnRghNXs2GYEJAsSxo+NKRY 2pYwaz7TZ/iQIUaoDenC0SLm6001+gHU9q7RYl9FRy9BUP+hDuSO37yvQZ0f1EqObrN+ oE3nkdBX1lxzmgPkKZXYMPAiI6n6KnN/U84C4hJCvRun3wTGg5/V3d/ncKY+ZF2F0NOL hcd/Cku01GV9mrAUzHXus86Pc7MjEim8ow9O1Gw30sTt3oYit2N86PxCNjzxlVxa3Ttz CMqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718806157; x=1719410957; 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=jH7teSUneCZWfoVt/91/lHeZpMwu3/Yn++4TJjeU7NA=; b=v35Ggvi0ZV7sJxeHstcZL5CGa5pzZNmCDDJOG/YNOI/NF9vCTnFCZAA9ibMHCUNbdI Zu4brul42tYRp/jdhpVziSKCwQYytTgAmzUUkU/WXp86gEAoSc2x/xfDCsy6uQu3PrRe 3B477k8U1djrXQLue8e7+Y8D7Sv1obRs1Gk1xReNgH4FR1FtYX2Ujnwc0KVQQgHCeKK5 mG+I5T3KebzRTRciBCAl8pzjEhtVpFODPlJPxtRJ7CsUl0eKazcbstOcTQOAbO+ie9nU PW5pGEAlK8cpMU9U0DhN+XAlqqYpA5ZKvw/vTDraMjAH7cMTlV236vqXwnFxjH8q3M9i rjRg== X-Forwarded-Encrypted: i=1; AJvYcCVdIByatOWjBxgnDLnhLWMkUE8wwu0jBHi7uRKJFcJU5hCUqJrfus+YE/Idmj5btJWJA8kuG3c6edKIqj9vZTSnU6yEpnPd+Rt20FcwJhHNplfdW8U= X-Gm-Message-State: AOJu0Yy8Cqun0IKp4yl7CT/1HzrL/+RYv3qfsAbCUnPZBHgf2jCCl697 +A1oYDzGIq9EJ1nScQsPmYylITMWZ4FEc22vV35Ne8eaB092iO85/CM2W0Nq4no= X-Google-Smtp-Source: AGHT+IGoJr5DuwJJ1A2TjVENIUslYHC6GqIXMmnq00+SVaUdczAOZsm6VolY8hrQoNfjsd/Xd4Uhig== X-Received: by 2002:a05:6512:3d0e:b0:52c:cda0:18bf with SMTP id 2adb3069b0e04-52ccda019d6mr967714e87.4.1718806156688; Wed, 19 Jun 2024 07:09:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 07:09:16 -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 6/7] OPP/pmdomain: Set the required_dev for a required OPP during genpd attach Date: Wed, 19 Jun 2024 16:08:48 +0200 Message-Id: <20240619140849.368580-7-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_070918_983461_629B55B0 X-CRM114-Status: GOOD ( 29.48 ) 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 Through dev_pm_opp_set_config() the _opp_attach_genpd() allows consumer drivers to hook up a device to its PM domains. This works for both a single and multiple PM domains. Their corresponding virtual devices that are created by genpd during attach, are later being assigned as the required_devs for the corresponding required OPPs. In principle this works fine, but there are some problems. Especially as the index for a "required-opps" may not necessarily need to match the index for the "power-domain" in DT, in which case things gets screwed up. To improve the situation, let's instead assign the required_devs during device attach in genpd, by using _opp_set_required_dev(). At this point the genpd and the genpd's OPP table are known for the device in question, which then can be used to find the correct index for the required-dev. As a part of this change, genpd also starts to assign the required_devs even for the single PM domain case, as a way to align the behaviour. Furthermore, to maintain the existing behaviour for consumers of _opp_attach_genpd(), let's adapt it to the new genpd behaviour. Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 45 +-------------------------------- drivers/pmdomain/core.c | 55 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 44 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index bc1ed1d3d60d..7e567b479c3d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2369,7 +2369,6 @@ static void _opp_detach_genpd(struct opp_table *opp_table) continue; dev_pm_domain_detach(opp_table->required_devs[index], false); - opp_table->required_devs[index] = NULL; } } @@ -2393,8 +2392,7 @@ static void _opp_detach_genpd(struct opp_table *opp_table) static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, const char * const *names, struct device ***virt_devs) { - struct device *virt_dev, *gdev; - struct opp_table *genpd_table; + struct device *virt_dev; int index = 0, ret = -EINVAL; const char * const *name = names; @@ -2427,47 +2425,6 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, goto err; } - /* - * The required_opp_tables parsing is not perfect, as the OPP - * core does the parsing solely based on the DT node pointers. - * The core sets the required_opp_tables entry to the first OPP - * table in the "opp_tables" list, that matches with the node - * pointer. - * - * If the target DT OPP table is used by multiple devices and - * they all create separate instances of 'struct opp_table' from - * it, then it is possible that the required_opp_tables entry - * may be set to the incorrect sibling device. - * - * Cross check it again and fix if required. - */ - gdev = dev_to_genpd_dev(virt_dev); - if (IS_ERR(gdev)) - return PTR_ERR(gdev); - - genpd_table = _find_opp_table(gdev); - if (!IS_ERR(genpd_table)) { - if (genpd_table != opp_table->required_opp_tables[index]) { - dev_pm_opp_put_opp_table(opp_table->required_opp_tables[index]); - opp_table->required_opp_tables[index] = genpd_table; - } else { - dev_pm_opp_put_opp_table(genpd_table); - } - } - - /* - * Add the virtual genpd device as a user of the OPP table, so - * we can call dev_pm_opp_set_opp() on it directly. - * - * This will be automatically removed when the OPP table is - * removed, don't need to handle that here. - */ - if (!_add_opp_dev(virt_dev, opp_table->required_opp_tables[index])) { - ret = -ENOMEM; - goto err; - } - - opp_table->required_devs[index] = virt_dev; index++; name++; } diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 74ebb8a423be..a38d08862a61 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -2774,6 +2774,57 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } +static struct opp_table *genpd_find_opp_table(struct generic_pm_domain *genpd, + unsigned int depth) +{ + struct opp_table *opp_table; + struct gpd_link *link; + + if (genpd->opp_table) + return genpd->opp_table; + + list_for_each_entry(link, &genpd->child_links, child_node) { + struct generic_pm_domain *parent = link->parent; + + genpd_lock_nested(parent, depth + 1); + opp_table = genpd_find_opp_table(parent, depth + 1); + genpd_unlock(parent); + + if (opp_table) + return opp_table; + } + + return NULL; +} + +static int genpd_set_required_opp_dev(struct device *dev, + struct device *base_dev) +{ + struct generic_pm_domain *genpd = dev_to_genpd(dev); + struct opp_table *opp_table; + int ret = 0; + + if (!dev_pm_opp_of_has_required_opp(base_dev)) + return 0; + + genpd_lock(genpd); + opp_table = genpd_find_opp_table(genpd, 0); + genpd_unlock(genpd); + + if (opp_table) { + struct dev_pm_opp_config config = { + .required_dev = dev, + .required_opp_table = opp_table, + }; + + ret = devm_pm_opp_set_config(base_dev, &config); + if (ret < 0) + dev_err(dev, "failed to set opp config %d\n", ret); + } + + return ret; +} + static int genpd_set_required_opp(struct device *dev, unsigned int index) { int ret, pstate; @@ -2830,6 +2881,10 @@ 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; + ret = genpd_set_required_opp_dev(dev, base_dev); + if (ret) + goto err; + ret = genpd_set_required_opp(dev, index); if (ret) goto err; From patchwork Wed Jun 19 14:08:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13703858 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 D5649C27C53 for ; Wed, 19 Jun 2024 14:10:03 +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=8CngIhS3kRulmGpU0Rg5JrWUuRc/630k552QGhg/cDY=; b=KqmMThiOHjf3yuVbkFCvWEi/ez VUXzL41S2nlCySoekYk84eIKHPcrj64GlKJsALU7WNYBeazW5UIcAD3tJG6Q014ZrnZR92hrycyCN qCe/IMtunbJiKw3bulB5xoemNowkzkfzH7tJwogquN1rH6tLTCq95E/BssLRJFtDdnTQA0o4/4da0 RG5PSziqpaArQnaDu+6c1KHZPjf1zo5o4piHVQW6aJXg9NMLUh2tnNO1hceFDqiRUodRFwy0en/Mj QiqAlBm3V5XL4zQwtrOnbjgLD/UtGbhWlVVF04x5kn08c7qzlqf15SfkjwYhbuEznuXde4HaqT7+u Rn54WPZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJw0T-00000001RN3-2YGP; Wed, 19 Jun 2024 14:09:49 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJvzz-00000001R48-2N7c for linux-arm-kernel@lists.infradead.org; Wed, 19 Jun 2024 14:09:22 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-52c7fbad011so7667756e87.0 for ; Wed, 19 Jun 2024 07:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718806158; x=1719410958; 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=8CngIhS3kRulmGpU0Rg5JrWUuRc/630k552QGhg/cDY=; b=HFhE2MhtG86e/BMHDuQpJkzmgTUpkzRQ/rKqAYE1HRL40rLgXX5C7d2/g4eOcQybWn pQJZCexdLFLZYjbJWUsWDDe/nasPICILzo43FSzwKJFlDAGtlLxM5206tMxjJTm54zMr g9Q7xe3iuH6JcCm99ik4LxQa4VSFwWeEdwa6CvGzgU9QoOM2yaYQT1qYeJOz5uU7osXV wVTIRUf8Q0xLVV8YWhBLwDy/rIL6cRjfRlj274bpyF57W0z1u8a91e69A3ClKZqmnptA oio+Pqc8BxApIpdzrzgfcWbwQ9o1ynE4ywC78r1QiccWH5OWDgoc3ViwOL2BWtOaf+J9 SRnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718806158; x=1719410958; 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=8CngIhS3kRulmGpU0Rg5JrWUuRc/630k552QGhg/cDY=; b=G57B04K1S5tLJPjdAQ5o4fATTuBQ/rcDhyZVJ7PkB/zz1BA1L3rXPrebGsLIkOVST4 w6Eje2PtLEHhe1K22WgwV7VBg0dxO48l8zXkUZfD7jV5iC3a3589UwlUofwWaUQPwhGR KRp0k2ELY7YO1JtFF8vWYod84bN7jLiOs0CblQCE9de7zFwQrR2Avl4EMwX+knT4h5h/ 1C0wOCcpbavmenn7Rt1HdZvIDFuQygdTH5ofnaeONEZTMBxA6X3LU2IyPaGB1PP0Wbtw e0PhkwdeHnV5w+75Mq46mAt8E4dS9yTju4m6lGqqccloPdzxWJoyIoWaPgexVwTiw9EG o+hQ== X-Forwarded-Encrypted: i=1; AJvYcCXMFzrDXjbo5ltnP5KwFIQDOxJErie04RKavHR5toTqiPVMnB6yFRh56V2JUV0/Bze1MR+nXBwsQv+eGiqECCtwnsa1SvogFP8AsdHlhfkZHGvr2Jg= X-Gm-Message-State: AOJu0YypyhYkjXruCvNFhv/Is6g9knBp0z64hi08Eq25zzXtuGl5Ef6D g5bEsi/uHnHaja8c/e0+kXGbOSWYBFrjJfPhm4jvgnZUpmZh56qRobMt/hMYMus= X-Google-Smtp-Source: AGHT+IGtMjaVRxqwME3U7CGrSptN6JfejN8F/ypK0frJbXiy1thTIGiCDNeAXU2vN4DLOqXBQiFdNw== X-Received: by 2002:a05:6512:3ca1:b0:52c:8b03:99d6 with SMTP id 2adb3069b0e04-52ccaa585e9mr2256803e87.6.1718806157835; Wed, 19 Jun 2024 07:09:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 07:09:17 -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 7/7] pmdomain: core: Drop the redundant dev_to_genpd_dev() Date: Wed, 19 Jun 2024 16:08:49 +0200 Message-Id: <20240619140849.368580-8-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_070920_376096_BFF728DA X-CRM114-Status: GOOD ( 10.48 ) 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 There's no longer any users of dev_to_genpd_dev(), hence let's drop it. Signed-off-by: Ulf Hansson --- drivers/pmdomain/core.c | 10 ---------- include/linux/pm_domain.h | 6 ------ 2 files changed, 16 deletions(-) diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index a38d08862a61..4abedbb65354 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -184,16 +184,6 @@ static struct generic_pm_domain *dev_to_genpd(struct device *dev) return pd_to_genpd(dev->pm_domain); } -struct device *dev_to_genpd_dev(struct device *dev) -{ - struct generic_pm_domain *genpd = dev_to_genpd(dev); - - if (IS_ERR(genpd)) - return ERR_CAST(genpd); - - return &genpd->dev; -} - static int genpd_stop_dev(const struct generic_pm_domain *genpd, struct device *dev) { diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f24546a3d3db..772d3280d35f 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -260,7 +260,6 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, int pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off); int pm_genpd_remove(struct generic_pm_domain *genpd); -struct device *dev_to_genpd_dev(struct device *dev); int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); int dev_pm_genpd_add_notifier(struct device *dev, struct notifier_block *nb); int dev_pm_genpd_remove_notifier(struct device *dev); @@ -308,11 +307,6 @@ static inline int pm_genpd_remove(struct generic_pm_domain *genpd) return -EOPNOTSUPP; } -static inline struct device *dev_to_genpd_dev(struct device *dev) -{ - return ERR_PTR(-EOPNOTSUPP); -} - static inline int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) {