From patchwork Thu Jul 18 23:43:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13736783 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 18476C3DA49 for ; Thu, 18 Jul 2024 23:44:19 +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=+zb2TnLEPy/yYn4OHpN9GAbJBX2HlvGglgTvnLaEwow=; b=ROz60hJWdcLV+5KYljFOlleEAR b1EcIVcxpEnDnYkJRU7Z7TSMMx3vN19q4hraEaT50m7734BaD8W2hakqh0zQBIIWB1RsOTcn3DVGz I+kPcfzV8WtLslCG2BSs9zGg1hKjiMUzGW5hpbR1gMWFMMz1VXhpAhYKf8jd9/XPvAqNxM9DTQhC4 4+swuMCfHHPpqCQ2+Dz7ESFH+SbmAKdxX4C6kD7dS9TjccM0dQoDSYGuhr27U9uZuN98Etf4n8pPp yMiRRQFwoW+3vdjtEIcRe9f0ejHSwjbeko7ECUSz5EvWZkYXnvSubjNvpB98tKxhUkH/WhpYUt+Jl fmxEkvoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUan9-000000011G7-2OCL; Thu, 18 Jul 2024 23:44:07 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUamV-0000000114G-289u for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 23:43:29 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52e976208f8so937949e87.2 for ; Thu, 18 Jul 2024 16:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721346206; x=1721951006; 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=+zb2TnLEPy/yYn4OHpN9GAbJBX2HlvGglgTvnLaEwow=; b=pEpMo4CFgDfWgdWd2RbjC5//0n/ZqK+CCMjZ2ETufDWzc1pjFXzivc5nRtkc2r8d14 bfXp0tWNyBsfMx4JCBp0l6wQ2Fj9DV1gdYuxKNq7Z4KA96o97Bn47WRiOgPNP0o9BsUG kOgP4I6hFuqdMskFksjkigk3Mixm5+TGfKnyZBVD36NZjnCt4uesh3dnVQOgtcFrcz7b XAJRfuyPuiJQWVoRQitu/ohOeOdMnzWs3mEknodAhYQpFeZ47MYJQ/FXaINyMKemX9ar IGl6BFj0Wandah0jsuNeQkntndI+V/rqu7ntLgo9lz9H0mWD8btQUiymQqajIcwffwTd Gmrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721346206; x=1721951006; 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=+zb2TnLEPy/yYn4OHpN9GAbJBX2HlvGglgTvnLaEwow=; b=nwwQzotqre2QUTBRCcUxUjtW4YRpU5Tnr9J8gktPFOYxgSQBsfhBrJd1jTF7IwP5Kk aHdfyt3ewiSz5WdKsAR63lHYCxOjhU1RFCj/6BovEPTrODu914ZT/OnJI9YdjCnZErfr z/c1sJRRab43KFdCOnvK394vsDosOo0fyhV29tVhFa2p/VttpdHV+1OAlrXciq4F3zKD OLSg9/YMrihxBJMXioGY3sKU5hbS+AnQ/C6eceiz+N9dqgYNNQEvrvIKZVmeXKzoor28 2tE71Sk7YUCGYvTYWEVRHGTUravBC52uqgNf8/xTO0bI46DSCLZr3jFzCoG8T9Yv49+b Cafg== X-Forwarded-Encrypted: i=1; AJvYcCUte36y+6ojq7rpRU6gDyycT+TauJ+cKim+Jfbbv6eO5D5ygKW1bJ5kY2Hl6u6bn+rJBmo/i+WmL7VloCDQhbnDejjo0JlYRQdTcdS9OrJEBqmVXmQ= X-Gm-Message-State: AOJu0YyhaqG8R9eSAw/B7fkKRcc0I2CJKqggewGVeFosGKEYz1CcwSLN O/xYVGd2kFC6RU6e6kFgqQ5g0qYZXS1ViBJAgLwBNb92zR4j5D/Z/7plwUlrdJM= X-Google-Smtp-Source: AGHT+IFF8smI3aMAQT3AbKX1NQGZpHaJaCkvum5gaxbfN2nJOzdqHbIsk7af5xBZTpN9HOnmw05rOw== X-Received: by 2002:a05:6512:ac7:b0:52b:9c8a:734f with SMTP id 2adb3069b0e04-52ee5411e3dmr5098927e87.50.1721346205884; Thu, 18 Jul 2024 16:43:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 16:43:25 -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 v2 1/6] OPP: Fix support for required OPPs for multiple PM domains Date: Fri, 19 Jul 2024 01:43:14 +0200 Message-Id: <20240718234319.356451-2-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_164327_584241_50942A0C X-CRM114-Status: GOOD ( 29.76 ) 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 It has turned out that having _set_required_opps() to recursively call dev_pm_opp_set_opp() to set the required OPPs, doesn't really work as well as we expected. More precisely, at each recursive call to dev_pm_opp_set_opp() we are changing the OPP for a genpd's OPP table for a device that has been attached to it. The problem with this, is that we may have several devices being attached to the same genpd, thus sharing the same OPP-table that is being used for their required OPPs. So, typically we may have several active requests simultaneously for different OPPs for a genpd's OPP table. This may lead to that the per device vote for a performance-state (opp-level) for a genpd doesn't get requested accordingly. Moreover, dev_pm_opp_set_opp() doesn't get called for a required OPP when a device has been attached to a single PM domain. Even if a consumer driver would attempt to assign the required-devs, via _opp_attach_genpd() or _opp_set_required_devs() it would not be possible, as there is no separate virtual device at hand to use in this case. The above said, let's fix the problem by replacing the call to dev_pm_opp_set_opp() in _set_required_opps() by a call to _set_opp_level(). At the moment there's no drawback doing this, as there is no need to manage anything but the performance-state of the genpd. If it later turns out that another resource needs to be managed for a required-OPP, it can still be extended without having to call dev_pm_opp_set_opp(). Fixes: e37440e7e2c2 ("OPP: Call dev_pm_opp_set_opp() for required OPPs") Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- Changes in v2: - Clarified the commitmsg. - Addressed some comments from Viresh. - Drop calls to _add_opp_dev() for required_devs. --- drivers/opp/core.c | 56 ++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 5f4598246a87..494f8860220d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1061,6 +1061,27 @@ static int _set_opp_bw(const struct opp_table *opp_table, return 0; } +static int _set_opp_level(struct device *dev, 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 +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 = dev_pm_opp_set_opp(devs[index], required_opp); + ret = _set_opp_level(devs[index], required_opp); if (ret) return ret; } @@ -1102,27 +1123,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 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); @@ -2457,18 +2457,6 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev, } } - /* - * 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++; From patchwork Thu Jul 18 23:43:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13736784 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 1800DC3DA61 for ; Thu, 18 Jul 2024 23:44:43 +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=0E4K3m18NzNAaiIJOKht8f12lpSSf/q6AadozsUAGZI=; b=kYxbmpqwEJstioY8MCSpFerG7s 5LdAgt5nZK86MpEDyYnPseTyjCXLb/SpNyseicJeNiL7B6yiqNBOZ2851bR5W0WnVMH78Lf4IPFLS np79lUDPelAtN2y2ky/qMighyYhv5OkFbwZ1Is5cnBgNcTyED9Yh9lwB41Ofps7Nwq1aaSBOi9Wbw pekFbqCLwj3ErHLwM6HU44UE6E023arCa97ArokgbXCGjoXguwI8zGEngr2ZO4++fw32edur/ZvF7 7QRHhCTeaCxag8iX6BX0uX78DEf9O4flq3QZFJulABsVdI0rHBXizpQqzxg1lPzRp6lQAMzJJKu5c sKbcwfWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUanT-000000011OL-10yP; Thu, 18 Jul 2024 23:44:27 +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 1sUamX-0000000114p-1ZQq for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 23:43:31 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52e9a550e9fso849953e87.0 for ; Thu, 18 Jul 2024 16:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721346207; x=1721951007; 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=0E4K3m18NzNAaiIJOKht8f12lpSSf/q6AadozsUAGZI=; b=hwITM1fVZwLfvplgJ40o9bAK3gk3pAOq1V7uEvwWLXnz0FWWWEjbcRaqNhhDgSIFNg zZoXn3o3+a3yDr2aeAKodIFpwhFsLbNjVr3YAjMbjol/4hiZTKmHbxDkNHSzNb9zC0zT 79i3+Fc5VIMi350bLWbmCoXh4BLyCJv5V38vlnpNjtaEnLemjskrDu9Y/oI1aFqyIQ2K zlsOfjQDk9TJ4CzM9BSy7iUSVnAW9s1fltlJiqhuvOCLHR5kbtk/9ZM7PZGzStwuUkII fEVo9Jm0x2Q2j1LR1o30MFqP19nU42IGe97MlT+Lw9Rll46D5OkU6KqGHePbJ24bJ+1s Gpcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721346207; x=1721951007; 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=0E4K3m18NzNAaiIJOKht8f12lpSSf/q6AadozsUAGZI=; b=wqSfArjjbv19sqVDVGgHZX8Q+uMjJKQcwEu407jclgsmEMLlRgN0ajcQTDaW5CJnLP icuSrZxP20s+qeWNW0X7LhwSfYGkaQAy+A9BFClbJCUQZKstK0EzdNDNyTqTWc0fVV9D YbpwMux9hPPU6Uf8B9Aycd4yqZvNm6jDlcfWJ48pvHFauJCH7ezABb9SNPP0TBJHkQGe xP3Z9xARKxmCH3K4bLlzwtHUsYwVX/D7eOzXHGYV/eLC0YnI9T7r68ZkcL8bnxU1FNBO s+tsDHdR2yrol7dQmgUb5VbTaEidJYatBwUQHPmmltlckUNfIgi/njjUKlEJkafoQuST 0jxg== X-Forwarded-Encrypted: i=1; AJvYcCUbcPFfP6fX3fLCAvAIiv1K8IZDHQuP31X44N7KthWWh9AhmwPyrUpPOVln5M6MFzHg2PwJvSkF0gENKXKgQiK0K2UNJMGc3rk8jf/rMwvwYPvXghE= X-Gm-Message-State: AOJu0Yzhw5/1RvDkq3iEe0vjD8eDw1nMehC8k5FWaSR/GOQ/PpzKt/yH vPHwh1ivydz02/5a7MRGlMtEl4UqoekfdFZXGzQ6K4I9k2NbmICZRS25VrM3xTPOajuP77Y9/+h 4 X-Google-Smtp-Source: AGHT+IF4/9i2ZMuh/4tFXo5zf6/+vwOKWzikZWarKDokHXv+3/nfYbGMIJc93vRDdzW6MYNrmK/FGg== X-Received: by 2002:a05:6512:10c5:b0:52e:7278:a39d with SMTP id 2adb3069b0e04-52ef0875a86mr753924e87.0.1721346207064; Thu, 18 Jul 2024 16:43:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 16:43:26 -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 2/6] OPP: Rework _set_required_devs() to manage a single device per call Date: Fri, 19 Jul 2024 01:43:15 +0200 Message-Id: <20240718234319.356451-3-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_164329_439792_0BFA2FEB X-CRM114-Status: GOOD ( 32.44 ) 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 --- Changes in v2: - Addressed some comments from Viresh. - Drop calls to _add_opp_dev() for required_devs. --- drivers/opp/core.c | 91 +++++++++++++++++++++++++++++------------- drivers/opp/opp.h | 4 +- include/linux/pm_opp.h | 10 +++-- 3 files changed, 73 insertions(+), 32 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 494f8860220d..b6a699286aaa 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2473,9 +2473,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; @@ -2484,36 +2485,70 @@ 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; - opp_table->required_devs[i] = required_devs[i]; + /* Move to the next available index. */ + if (opp_table->required_devs[i]) + continue; + + /* + * 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) { + /* + * 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. + */ + 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; + 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); @@ -2630,7 +2665,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, @@ -2639,13 +2674,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 6424692c30b7..5fade5c4de40 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 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; } From patchwork Thu Jul 18 23:43:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13736786 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 9A2DEC3DA61 for ; Thu, 18 Jul 2024 23:45:20 +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=J9vI4SwwGNFQB5ve0cZ2IKXbIbaFjJCx9WMpU5iHjvI=; b=PiQIup9UhrG591bPORo7UeFmWa A5vjuFw+lyh+MqCSzjlLUo2/OfugLdyMWUHoQ05srUVTT7BqbkMGfRnC4PQr7I1UsKhkdFzpmoGlI lSl53Twcri6uWnhEis2wFutQS6NpKTtg/+QKxg1VUrnMg6SqhpAbefavfMMZ242JUrg17CK7BKN85 IPLHq0QxdrUgamdk85VbqEBFASNV3mEhkmzo8r/9qrBzLX2TXW71AMIYKMugoydiDTW4+tl51YdO0 rYhtm6y6dgfxnI2RMjsCYH197uo4Azl+5My20FPVfiwqi8FbOg1qB7mHU1xY+XmTMp7B4heV8lz1U 1Xzsk9BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUao6-000000011cl-3YAX; Thu, 18 Jul 2024 23:45:06 +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 1sUamZ-0000000115Y-1cpZ for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 23:43:33 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52ea79e6979so1206424e87.2 for ; Thu, 18 Jul 2024 16:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721346209; x=1721951009; 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=J9vI4SwwGNFQB5ve0cZ2IKXbIbaFjJCx9WMpU5iHjvI=; b=xgGm48WHxT518vf4ShQoECJk0kVt+xmyiYmzfS+gUwc8A+q+piz8AJWVAb5zqPPPhY ovDMKzinlgAIPVubAlnYXsqHIrEDooFwbsw9JnigQhDop9RVF44YWgswCiRxTGlI3tbe yvWEFgDtTQojM8qFbOlJKDCbKI3CFBGYE8WfEmUPcJ5mOoG46T6OKeDAnxmJUkVpF7nG TXZppvGgIRwdwks14tdx3BjgoTGAazmQ+41joLL46Gjy14Orh74jwQdbr+z2LrNsVT6/ nQMYUCSxObzUtd0RjOgAk8gcW1LpolTbX4G06OMzDvDdCU3KFzeuyVN+8phsN6nSD5GS W5ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721346209; x=1721951009; 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=J9vI4SwwGNFQB5ve0cZ2IKXbIbaFjJCx9WMpU5iHjvI=; b=wbqrlubBeDMNJgLE65d0/Q7mnddqR4gU9EXUeidsyxpAoXElI002mhST+iQz0go6o8 Nfry/b4AtMZ7u5OhE95krv2ed6NobGbzSw/eV+jOLq8Nthuch935tqERD1eqvu8dMEAP 8AvYpMc6Zrk42xaG/Z82lFmOnMPBmD/yCdVgsuHV38e3p5RcDPjpOgfAHxKawqQU/gEa huIk/Fstl04gQVmzouSMWqi/TwsvHpeQF65j3wALy9Ua3BWnwkJLvXhd/VWAxFWgoh/e L495Pbe7XaSkwZhkrE3G7MwZ2heVKA0tsfwuVdHA5cHPLvAUZ2jDa0WIGQcZpm5a1+54 Wv9A== X-Forwarded-Encrypted: i=1; AJvYcCU2GTdS+Q4KX9Cyn5vwSumXxKgFu+GVSnWX/Lg/InwJYjS6XvvuEXEyUWqNdMj8Zrp/LHyuGypLYqUbChfk81UkdlMQ+5NIAeKcsH2flHoQO+lihgA= X-Gm-Message-State: AOJu0YypRoAf9/DhIHYUK8XfpdTamfhymDtrcEdpEk5L4OMOIEMUQSo4 dIqVd3GInoFlYuFChnVKXVKy7mSH3FrWABPFZADYIz9MtXOZqiJYJn1dsBNlonM= X-Google-Smtp-Source: AGHT+IHhvBJQZZLF4qvCA1+VeH1XflwZ0B4C4bcRfZpPoV5ESlTMWrHmMyYLyE0Fj/9144c0IPpr/w== X-Received: by 2002:a05:6512:31ca:b0:52e:be30:7e7 with SMTP id 2adb3069b0e04-52ee53a25ebmr4597627e87.1.1721346209536; Thu, 18 Jul 2024 16:43:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 16:43:29 -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 4/6] OPP/pmdomain: Set the required_dev for a required OPP during genpd attach Date: Fri, 19 Jul 2024 01:43:17 +0200 Message-Id: <20240718234319.356451-5-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_164331_582305_8CDF8484 X-CRM114-Status: GOOD ( 27.93 ) 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. 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 _opp_attach_genpd() we are also cross-checking whether the attached device's required OPPs really belongs to its PM domain's OPP table - and tries to fix it up if possible. In principle this works fine, but sometimes it's not convenient for consumer drivers to use _opp_attach_genpd(). Especially in the single PM domain case, when a device is usually attached by the bus-level ->probe() callbacks. Moreover, we now have dev_pm_domain_attach|detach_list() that helps consumer drivers to attach their devices to their PM domains. To improve the situation, let's instead assign the required_devs during device attach in genpd, by using _opp_set_required_dev(). In this way, the cross-check of the OPP table is always being done. Note that, we still need to allow existing users of _opp_attach_genpd(), which makes this change slightly more complicated. On the other hand, once we have migrated those users to dev_pm_domain_attach|detach_list(), the entire _opp_attach_genpd() should be removed. Signed-off-by: Ulf Hansson --- Changes in v2: - Clarified the commitmsg. - Add a check for #power-domain-cells in genpd to avoid assigning the required-devs for non-genpd-providers. --- drivers/opp/core.c | 35 +----------------------- drivers/pmdomain/core.c | 59 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 34 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index b6a699286aaa..cad7e84c9ad3 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,37 +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)) { - ret = PTR_ERR(gdev); - goto err; - } - - 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); - } - } - - opp_table->required_devs[index] = virt_dev; index++; name++; } diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 930cd5382032..fdbc3aab9083 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -2774,6 +2774,61 @@ 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; + + /* Limit support to non-providers for now. */ + if (of_property_present(base_dev->of_node, "#power-domain-cells")) + return 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 +2885,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 Thu Jul 18 23:43:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13736787 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 7B5F3C3DA61 for ; Thu, 18 Jul 2024 23:45:39 +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=qiy79RCH12nO+kuD43r9KxQZmT684plvYyRVA5SbNNc=; b=K8NW+m6mLCN8n9Ju2bZ1cT1b45 ywQbkIWbJOJXeV0aknGLAlBy7e37ekJPdqbMSnDajvh0hRlqTmNM/O8lY68iu/XkAPzztj42keGbE 38TDMVVBEg258GkvHHIBhnBL6v03xgptgdCXMyF7nZ8imsr8kdofcYoiRJ9Ll+hKHimeHi0yT/yjr PvCap4f4EHnZpMUnBFIhHoEa9/FBq4uWVvXLvDsDyhLiNIKvjOID9hzRlu2riRrtPykIfqhVbYDA5 gXQpOinLLJhi6EA/+qZk56/IaQy6c04U7uQVRITX0p1z3wBPjn1aE/5Sxv1e88Jo9KibEAs1hnOyY VVSzyxSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUaoR-000000011lo-1j41; Thu, 18 Jul 2024 23:45:27 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUama-0000000115k-2oKX for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 23:43:34 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2eea7e2b0e6so21540541fa.3 for ; Thu, 18 Jul 2024 16:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721346211; x=1721951011; 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=qiy79RCH12nO+kuD43r9KxQZmT684plvYyRVA5SbNNc=; b=eW4XjwDwPI61PJznhFS4WJUKni858awq33B1gA1apPrL3boRWp7hun8NND7l86wkL2 9CNaoAH5tl6pGBHHqTHL8stPm6yqWO6N0+1Ng181O5KQOqbobDYrLRg1BTSOnZXm6x+z j/dYzmjqWuRK3zqDhfk2wVt2Jjp2Z1oypm3QOdv4o2JdB8S1rsFYtrzgfoeYrOd8LZoC h9bU3je3FkENMcE63tWfS+9s0juLT1IIz9f1szOn4tE3/Ptr7LyQzAqGrStxVy7kubUs /gv4bJE6tvugjyJA+zjGzGbPL+whW8IxVv/Up5pOJBemjKAAfhSsYxOtALyIOAevM16L Oc4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721346211; x=1721951011; 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=qiy79RCH12nO+kuD43r9KxQZmT684plvYyRVA5SbNNc=; b=G/Sp9IWAN2Nj6otDT4MAeJubcy/RJC6e5hY6B5scAMleG2UO0DBsVKvEz5101A7deX FfXZaptW76uOKT66J9uS76SO/VZW90k4hNm10zeIGnXbSj/N/QfaadGooq1NRpvG+lwA O+WsZj1nDiKHHyjXnq7lOIxFIRSTnCMgsCcYZuWUFoVynYXAZb454hF5UkGy0PbCj6jt kagGt2Y2AN4/LETOzyu+WvqJb06Q4zIvmmDyLFRLuf32lDC5Mtrfd5RGfhjxaYtM5qIM 62Q5P2lM3GBRnalRQ2o3Z7DmKHnsbRrEVF852fm+YnogDrNcZTD2e9RVRVZds8uB3jmq 3Njw== X-Forwarded-Encrypted: i=1; AJvYcCWqOKU+TZlgHjJqyy8Fi7zKbVlDgvJyPO2d4x6OH9CITZQNKuBY27qH5X0IrAZ2uKNDMH2miPIXhcQRQiAlInrAmIcHpDqiqBbVKuW2tsLSWRlCk/w= X-Gm-Message-State: AOJu0Yw0LWdKP6vH5UguqxqasnciR1wPi58Wd1YRu7TmxkpZ+6qHE6fI mlf8bXnGksy68nlatPWR/n+qNCwTWk6+fa3sIB0EkzkNO8AwEN+vJmATgI9jay01NyqvVtqGb2m D X-Google-Smtp-Source: AGHT+IE/PQcs9Xj45ekRvDZ9k+t/Et7RHcrmh62SIuBoPAG7Wl7rJpYPtWq1KQeWzrJ9ZjlpqQ2KEA== X-Received: by 2002:a05:6512:39c7:b0:52c:8df9:2e6f with SMTP id 2adb3069b0e04-52ee5429228mr4551665e87.42.1721346210863; Thu, 18 Jul 2024 16:43:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 16:43:30 -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 5/6] pmdomain: core: Drop the redundant dev_to_genpd_dev() Date: Fri, 19 Jul 2024 01:43:18 +0200 Message-Id: <20240718234319.356451-6-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_164332_732557_4110B393 X-CRM114-Status: GOOD ( 10.71 ) 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 --- Changes in v2: - None. --- 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 fdbc3aab9083..bc89edcbd583 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) { From patchwork Thu Jul 18 23:43:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13736788 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 1105BC3DA49 for ; Thu, 18 Jul 2024 23:45:59 +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=X41EpoGFTr7V+lfPhB4bKmmLvKDngcfGjNQze8E5PAc=; b=c08ROwy+hLO78tqo+d1hwa8yHR 9mb1vZkmphWO3uai7Yzq/ECMcufOhHHWqkJV0ZVij5N2O+ydXWv614ZJXmSaCOBiBJjoiB54ZDxPC pB5hOdOo5VroFLIekvrqx+Qe5P5e8IWeSdL07Yj4XxrpvHDGik8IwonhNxtSqwZVhdzLO4+Dx9w5H zWLVnrMYymxIgWxLsGd6MnSwxNr8WQv0C6Pu+nAQusxG15RIVm36UJoSCllGVc7KyHQOoCyI5Z6la W6tzPO5kUFjX4wk1qc9IKH4In2r8xYv4XDrmX5+6Y8Kao8lYzv/BUE9qwlHgeenPpe2jkGpVpmhZm flXNtt4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUaok-000000011sh-0XGg; Thu, 18 Jul 2024 23:45:46 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUamb-00000001165-3NiA for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 23:43:35 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52e97e5a84bso1431674e87.2 for ; Thu, 18 Jul 2024 16:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721346212; x=1721951012; 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=X41EpoGFTr7V+lfPhB4bKmmLvKDngcfGjNQze8E5PAc=; b=rREnCAriwiv9zru64OHoq4tt5ZNyoJqFxDH6i4Keq8zIFE3ABB9vf13Ar2lX7rYcpD bzFnPzVq2TihecFdGFiPwA4p3jbqlWqG9OrpmLYihP1AacV+Md4wUkYogNrawk8gROO2 njIlSiCJLqBcUhdABwkbWQjwfktpwPPLbipaqlLR+y40LLond788JeSpEcdvMkIZXTg3 ZTUg/L/iRGy9trpz71n7rpHaoG1A4yYLHThltHt0ndGMLf8CzVWFBx79/OFOYg7DJRon 2MhLjUMsb8wr47wVXuqWcLZZYFdibVgThpufzW0Mw0ak9b6V7QLyrVZvShg0YUZ6TZiw O7/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721346212; x=1721951012; 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=X41EpoGFTr7V+lfPhB4bKmmLvKDngcfGjNQze8E5PAc=; b=QU+l1E9J2WY2ftj5+9ni8pD4jvvi16GaDK70KPNoXW7r2mI006/TFFWscsnHK39IzR 91beWmrgWxQgS+F6Wi4Bp+mD76pcrU/ME438J8xEHSefDqqQTZ9aq11c67jCwWUmYUFE 6+UjuAqKHnX05UY8jqXtTGbXvG/ZbUkwe87PSZcmQQHTkh5VyilWmqg9UVILy8IJvtYJ U1HycPFRgieFbWYxLnPV5GeTalXDpb8ZkAnarWM9NM2Wfipj+ubT6qebz4GY7LIkhV4H fay/LMyJYPbybvJDWloiqEn9tee9q5Ipu7z0Yyw4CpQOOr9d0wC7rSCpyD/Mf5FddtVm advQ== X-Forwarded-Encrypted: i=1; AJvYcCXxOLWgUV6DQzYXarhUEweKJxo6vR97yOEpqegIZx8oc1iRcjW0rSgPyTwybB6BYzHLZVKdmiG3xPe57LDvjsbCluJZdTG7kpuqWHsVjBUxIGh/jno= X-Gm-Message-State: AOJu0Yym6ft2ayXiVvdeP0piu264e51W3Q4N5krOD19vT6boEokuMn9y HJQdThNyKog9AKo37Wq0zJYa8cowwalPb11gHTeYrVTd9qBUBQmJxSNQ8XepH9c= X-Google-Smtp-Source: AGHT+IE9TgIAs0CUhULlnfsv1TaESmkfsLC57MT/HQS4rq5Rt9A4FzXWOTcdoX2vwlTRiyP6cV3eIQ== X-Received: by 2002:a05:6512:3a87:b0:52c:dd94:bda9 with SMTP id 2adb3069b0e04-52ee5452793mr5704184e87.56.1721346212081; Thu, 18 Jul 2024 16:43:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 16:43:31 -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 6/6] OPP: Drop redundant code in _link_required_opps() Date: Fri, 19 Jul 2024 01:43:19 +0200 Message-Id: <20240718234319.356451-7-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_164333_871661_B15D9912 X-CRM114-Status: GOOD ( 20.11 ) 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 Due to that the required-devs for the required OPPs are now always being assigned during the attach process in genpd, we no longer need the special treatment in _link_required_opps() for the single PM domain case. Let's therefore drop it. Signed-off-by: Ulf Hansson --- Changes in v2: - New patch. --- drivers/opp/of.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 55c8cfef97d4..fd5ed2858258 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -295,7 +295,7 @@ void _of_clear_opp(struct opp_table *opp_table, struct dev_pm_opp *opp) of_node_put(opp->np); } -static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_table, +static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *required_table, int index) { struct device_node *np; @@ -313,39 +313,6 @@ static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_tab return -ENODEV; } - /* - * There are two genpd (as required-opp) cases that we need to handle, - * devices with a single genpd and ones with multiple genpds. - * - * The single genpd case requires special handling as we need to use the - * same `dev` structure (instead of a virtual one provided by genpd - * core) for setting the performance state. - * - * It doesn't make sense for a device's DT entry to have both - * "opp-level" and single "required-opps" entry pointing to a genpd's - * OPP, as that would make the OPP core call - * dev_pm_domain_set_performance_state() for two different values for - * the same device structure. Lets treat single genpd configuration as a - * case where the OPP's level is directly available without required-opp - * link in the DT. - * - * Just update the `level` with the right value, which - * dev_pm_opp_set_opp() will take care of in the normal path itself. - * - * There is another case though, where a genpd's OPP table has - * required-opps set to a parent genpd. The OPP core expects the user to - * set the respective required `struct device` pointer via - * dev_pm_opp_set_config(). - */ - if (required_table->is_genpd && opp_table->required_opp_count == 1 && - !opp_table->required_devs[0]) { - /* Genpd core takes care of propagation to parent genpd */ - if (!opp_table->is_genpd) { - if (!WARN_ON(opp->level != OPP_LEVEL_UNSET)) - opp->level = opp->required_opps[0]->level; - } - } - return 0; } @@ -370,7 +337,7 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table, if (IS_ERR_OR_NULL(required_table)) continue; - ret = _link_required_opps(opp, opp_table, required_table, i); + ret = _link_required_opps(opp, required_table, i); if (ret) goto free_required_opps; } @@ -391,7 +358,7 @@ static int lazy_link_required_opps(struct opp_table *opp_table, int ret; list_for_each_entry(opp, &opp_table->opp_list, node) { - ret = _link_required_opps(opp, opp_table, new_table, index); + ret = _link_required_opps(opp, new_table, index); if (ret) return ret; }