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: 13703861 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A21181E51E for ; Wed, 19 Jun 2024 14:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806149; cv=none; b=GdTi4UyS//vdxWgAmEmG9luGPH0dkPsi3Ko6rEY1Ngiq7IideR8RFCT3pUoLQDd6lxnHfAPMrzjPGBZaieA5meZVXZOLmS8c++kag6iQTrd4NVJ0pX4FSkLiMI3S/URil0HvIPEjZ3PLbAoH8Mk1TnSakIBNEitT62ogxXWU3tQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806149; c=relaxed/simple; bh=O83FNAdgJkgnscldJT04vDrZcANIzWxDsUu1SHrFuVQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U3N/U1CBA3YaxewE4rLVlShfLGrERGr39w92/rhTWdAmErBA2Xp03eay+itx//jNq5gZ87Jo0dNRD2Jdx7pTB9v4ZzJjtL1AhPLwAT+Mn+bwvH2vBM4FvBtSjCZq+ocfyCkFknV33hAKYbAEchW4TNQLxy4T4G4jqS/x/16Ii5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Aa9e9Z4q; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Aa9e9Z4q" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-52bc27cfb14so8015308e87.0 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=vger.kernel.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=Aa9e9Z4qC+7FRcAJ1q2bo3powkg2C0Eji6uh/qT8BlN6pbygVtWXlC4Z1NUFWoY5Ov CWW9Kxr6kafVXafeZxEvTQgiJ1untXlvfuG2i8Ttd/NV+6kGhINmMTblQwWUd3tEKzLc vMkb/NuOjstnpFgVQa94K7Htzwmb7oE8xv4mUhHThgiyzrYrSBFZ8qqqDFeo3+Pscyvq QRzqfK7G8hbj/mZmBoqMYogESV50dA6KQ4sz04UNZM5g7NqtJDcwkHAviTLPJZbLcUsN oP6kr414Und5rnU1baOpQwzopZrD0jxCaiBcfHF1pAG8j3mLkWSh+NZeait5QzhY7xhN Y7Zw== 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=eAbljMMi3JEJN95fATWZvIl/Wu87zRcB71zrZGW3S6mwRlmPWgwAqxlaonJGIzmey2 619gFlQVhDQyaPKmeYx7uenGA6Odpui37GeLz3Z8InBa1SiBg1nx2UCq88BGZRYdWAPs DY2pXMqaM7SDX8qo6d17tgoyIjzxVSfu3lHDT7RiBzO3c1siMvoLdeDDiSpeW3cd2ZAL xxR6xEBkLxX1p0wuZt+sUFOkWEU1TssgWsmyVSYV+OMbpRP8I6+h21ehuS1SO6OUcBWZ zH3hee69gmmMznGguP23bgOo1XV1+VjtlcqmRX8NRfB7h5FGPxLQAOQHqJd2hG82mOtF jU5A== X-Forwarded-Encrypted: i=1; AJvYcCW5TvO1O18cN8pNeOzllH5JLLQ9THxpXFcqkJOm3hT5jxR6NDP7s2XgpnOyAFkbWtxgeLasXk8MLY8kDG5oiMhlVQnvzMkUh70= X-Gm-Message-State: AOJu0Yzl7KAD4zOCTbey6aGkU2je1uEcVeaQR2ouNMGV4tkspuagrC/w YzoYEsSdQODKTYchJn76JB2AfbIcS/Jj7Hkt7aDzFK4JbWnoWLk7WEja1yo5sAk= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13703862 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F182115098E for ; Wed, 19 Jun 2024 14:09:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806150; cv=none; b=nLfkbged5pJrwfpQenIEndqX6OhGkb6fLoi+Vo0oZHm/exbdJbu+o/zL/zhQ4vJJC29ewuiEmoLdEtsopdoUQjXdr5y5X0OS36gjFE12jOGOg0bhIWdtGMkHMwgw4kYjVX9yYd5QLPN8/UFgLv0QJn6skMyb0ddhxv0AKiYFfYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806150; c=relaxed/simple; bh=p1L/5WV4IXuFQfEzRqNkQGg76bWmSg2tiKmoi6P2mIg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ziz+UV+hHqJG3ErA4Jm1/BPanB1FRijEN//9n1/FT7FC0oh0bVFAtUnU2OeJ1NoRbnhN1tIwBP74i4udpel1D8++F1MVSlraiH419Q3F9xedau4YV80XK8EMdEYl3iMsUHXja874jizp6yXdJZ6Hv2MhxaOijFAVb9rfiNFFYyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=P7yF7jEU; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="P7yF7jEU" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2ec408c6d94so7464391fa.3 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=vger.kernel.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=P7yF7jEUQoKqne+fN5LFnkYRcW2vYKJBuVwDTBKCLV+ub0r0OJBbgaLvfyfz0Um8Te N7TB4ly/88uZV0qwc3F5Xqp++h/U8PpstQXa5UlC2b2D0agiTPydkibtsdN0TODEXmUI BFty1N7iv28efjLTE8rWeLd95/IJ3rqYN+nT2WXkLyBxrxsMeqse8fv1lpN2IoEd3VKA WGcq1ahZnu1zHciMKsDfZhX7mWmlbV4LyHW0Bw13rT9/23o3n6kHxUNTXmh1WqxFOljZ FgWt/Uqy3k4bDU5tRxfYBpAGsJO2NL5w1TAjlpLAI0AhIZOlHIuA7qBCZ2Nw0Nyp7mux n1Gg== 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=Cpzg24D7aUcNQr7C8jXlu5lmI0R6vt7CIgfR0jGBUIdjWFp6B58CECY3UimgMwkVv8 0EOaj5Yqo1lt8gyHTDASdr0pSPPfwTCns3SiYVXZVaYz7Bzk4oMHLDVmYYPybTJ/UkeF CYehiYY+IpMQoYMogI3IVTveEeNWPWZaTymhTxLGrpHh85P061axaCvCV21wOW0FCY2w u/A6fR0sT4VtHOsrOw247+XANuBcuccJAQgbexHTLt3cMU+WCkzDCSxFiYEgzfUcQkRZ kadkNP+HVoL55r4KqlUKDaiMdksgc+IDmCmErR7u75EzkoknU81gHhLAy47lbr0sWUuU PPsA== X-Forwarded-Encrypted: i=1; AJvYcCX6owDXIh+ILaLq5rbrZx1cysS8v1uGiAchpnJtGJBZls+rycZ0l5vRGjj7uraiLjdXklBBdmudkP08n8SV1X4+jCAUr5H4qJY= X-Gm-Message-State: AOJu0YyFUx/wnfyiK1uQOpuLK8msOtwxiR6Rbu9x936kLJJc0qSydcoE +tTbO1zBOM/ay2tvbvDgLeQGuDUnHKkKmmVM6jdFant4uAT29MWN6sDKwWWw4As= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13703863 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CFF5152524 for ; Wed, 19 Jun 2024 14:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806154; cv=none; b=WjQJtHm8HNCq4gIJItxuFe9N72xkgaczUTS16xbnYm8BzZz629OVN+AaBQjubgLMMclpn4kkJX89GWLFZ0iHaaiSRJiJyWEanwffAXa3I09LodaCD6Hn3UZCP0P6M/MsD0jyOOrMr3BMnGanr+C0a7qb5Lo3tGEKHlrHVjosE/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806154; c=relaxed/simple; bh=r7WdFwdIx0SvBrhoxR/qHtGpCRe300sQa3NmHIufVxI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q85w/bV5h87fPlo/2Yx03MAMvdEpdUwI/6S29UjU2hoFXoIqHoeour5XV0E2mTf8ujRL9wQc259ciznKjEp2HmAGG5faecJnR82nUkDPas25tS8H65Gj/V+4SKPvCRxVb1MoOlo2eZe3uIfFdcOFL9khF0CHGquEkXDhAKdRIM4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NdSfIRHU; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NdSfIRHU" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-52cc671f170so820087e87.1 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=vger.kernel.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=NdSfIRHUQLGX1+aZpgzO59rYyhDd+mNcpsuHilBoqGnXidcoqFfBi2Yg2gzXonqEow Dm6SlvTPv/2lu81v7B0F7Xvt43vpX/6v7pbfBO+fnV2MIX7PlCLAT3Vp2CFoNhoSQUB5 qhLZXlexWocdoUTMysJzcerzGvfU6+YBKOq6oJN6n5LXEn3+mWFN6wLwmyW0F7Q1eEhI oaCCBrd4D9QjM2Dhp0NkRIzEGdl+MVFac/ObLbTCQoECae+cf+0ZQQj9N/Eape6U6jJ0 M7oQOBC5Z7EFi4QtlFwQO3gy0s677IdVXKy5bkkzF9t0Skxw8IxTx2JzVEUVDQ4e6+db OKEQ== 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=NITM7o2CXo/tTV4n2AbfTVlCt2UWU8eJnEtzEOnVfxO46bqZub83zgnSxvVc0BmLCg E+75j93Jms171rGuPTCmWWkT/pwuSqqiDUNVWwvcvv9QliCYMuJl+vK4QGH1okvItS+Q LW6OjzXiuxZgPvAjnZo2dWKPQpQFpfeszysUGM4Z5uVbuNGJ+LaQ6fb41fTXGi8vA9OC CNQ6BhHjkEbpRmtB1X4zGdH7KWlk/GIVDdPS9NxYAnZUvm8ftaK1WOGYK6PhRoNqDY+Q MRVz0UGuLCkUP2gfIM8LaU91KVcATvcJd+4iSCEpulIyt+6ozteDJtVfJ5q2JOLpsTRD o2yA== X-Forwarded-Encrypted: i=1; AJvYcCWLbSkfpFUP1WLEYE7UuPdGiTjldiX+CL+fVqFAxeOW3qTEmvZ2mN6916ZYc0ubjnd+243LyRvU7rlNgy9Rq55rm+E0+C+SVv8= X-Gm-Message-State: AOJu0YwP43iNwQSbGNBAoZ3Cj27rDzL1Xmle1VsKdUQoa4OJX69xhysC ZkC6PvR6X1FIT+MzUNBPxg3qIbksAV0Wqsz6Z4C24GERBVtWMJgTecEOwMDhAns= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13703864 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6BAC152796 for ; Wed, 19 Jun 2024 14:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806155; cv=none; b=GJ32/ua51WO5Ur90DMlk2+dEAzNG1rlk8O6k1XzQdXbQBnsIm3Y1OAsj6NNIGsLFW6jBGBOxeHnj6KSIHjdCJ+IFYLV5El1Z8T3lLKx+fALreV6DSetWxYNk8rrA5o+3F05ua+9x/7ong4fxeb0CiKpCB/40ceCoeLbn1hgKOPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806155; c=relaxed/simple; bh=xVTzIOADtFMWN8HF0VXifzBdG/mUYz+OV6Ng8rERawc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FcGfqxge93LO1RT8pAf2NSGr9AqxQtu3/be1/3Hrva4CK0u4jExhPjXmOZB/tIleehKc4tmSsS2uSNsOJ1nKMWfObvQxolLEaumxNed3/JVDKE/2d3mFW0HcArEH9W3naw+YJU+/TimFUojei7Mi+ZPl8SMnaHDYiibNvXKW4tM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ig9zOITN; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ig9zOITN" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-52c9034860dso8376261e87.2 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=vger.kernel.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=ig9zOITN5Bv/ZTGOI7aJ4UnF62+XsCDxc5reJAm++NzDbhe/zNs8Z0pUJ2h1scak0Q lhLjjoEgyEOOesAr7lEjZkfmgGAM0Wy8q17MuPlbeQzPNdyu4v6aZmIAXcR8hMNhwlJC DCmHKj+1daWXe0/zRUsy5uB9af+7hDBBQj73Lse3PR97pUGYh011iVckBBIRWs/TNXRF X0D4t9AnOF+Cnjw57heRJaA9uLogTxJMJX9asOn9azpCYgRMzjpevDYYxcL2sM4JrNkl 2d5tOX68to9dukh5VX16NbKQttW1PaIWNIfcvSgLI5dDh+VLVdYr8mK+8iYndMwIQgGv brqQ== 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=kKNtLtECjlcYTaZPSV1kzPIn2h4iZACHGUFeiGQOmMeIWAkNo1R8oNHH1lAWHm/DCl nXpZEOqeZ80qymVInU2ZclKorNPv3q1hXRf/5KyT4TiHxqUAEkoXg/aSg6TtYZrynoJK qsJxWc8dkxVEr7oR5q7ibDki8e1lnpU7EAR2WnEIpZoDQwiCg401BqdHCtlPGwZPCSK+ qVodPyVrSlFUrO2jWKbLRPcyLtj+33ic4NxS8ShhMmGyo66sZRBudixbDerC+kUydNME 95bJFytLrEpxBnXKzsypntLh0wp50MNbbOYnSzvl4Qmo6fIiPZgxJzgnOQBIgYv7Hl0B Aleg== X-Forwarded-Encrypted: i=1; AJvYcCWoVB1shckHfaqX3S9rJCJc7eaj4hErHmvRhp8/00VpBvBY9jidmUuzihh9jF+zK+ryEUtP46SXn4gHPao1VRD7LQSTP1nE32g= X-Gm-Message-State: AOJu0YwOSCJJI/h3Na1ouJHxyQ5Dy3TUgXjVdlKuObsaz0uXh+q6S8Oc m8ntsPOnxMoeCeyXwbGgDqiTn+AnIDck9uD9NA1iYTd25B1q56TA+T0H5+kH2ZI= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13703865 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5084F153573 for ; Wed, 19 Jun 2024 14:09:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806158; cv=none; b=TVOKC+v9kM0xxcq/81eVbaYqYrv10gWMB/OiXH+CzUXVCScZA9HEmQ+xSiYBKGJL1QZisf9S3I4FVxtUFOVSg73n+g6l0EGL4DNyBJGJWl+qLVOJa0Nd4Ha2DKk9vT1TVzgahShSA0De9w1CsQFRXGfbfFTbdD/ylDJB4oSGICg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806158; c=relaxed/simple; bh=BCICaCFGMmLOmUyHekQXCYwkgEJHZLXP9WCwg2mTagk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JU3siDzX6X7kRQM+OPquHgLBORmgSTev1zVxXjXGT5Wzt3FSCADmW/TTc4i0kXB1dkx0xxQ8t/EvTitLhdWPf1wGd06hLAhiDYCK1b9lqLKlxU6Wv+Bo+haikEIPnyOLOHT3XRF03WxYnm0eOSuuOJAOtIda/uKSUXY+VQrBkLQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=cDMuDzVA; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cDMuDzVA" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-52c525257feso8275644e87.1 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=vger.kernel.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=cDMuDzVAxB+RkzVufgRrgeI2dN1yf80nzlXdJ8BvBTplY9O2Kkl6UF9iHJcc312xEZ poLY6VOqX0xoyAY9s4xEDNVkvW9zd24fOFvOI9lUPwML6daw5exQ0KdYDqdQNhDPzmXn CbNwCqTXf+DW4AnUoWECdnfMr2RWgfVQ1cNH3g24Tv5x7/ajuu57yJHDY0lXilC8xy1G U9GlBK/16ZTlRhiYA+oTOBt9kQXiC2PXejwNqt/10pqmpF0hK0smeZoXu7V9PFtT6Xwl /m+sHbW+LLk6JfV+27cadEMkw0KPl5pvA1dl0HQ95MJvyMsxUANTyYTJoxs0UlrIFndP qlyw== 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=XmUczLUzig18xPEyqSk5Kv3yJdwUv0TZrzcsHo7rGNVAcVCDIbCOhX1KNpBs1iT3G5 jWNY6egfEd/cDVrpoWV3ZoyUazGKgiEo+3pU4hER/fyLBZdsIaf6DHxNSR25PjWhn5W9 QMP2OTDdG5QnXiweWCC6zJp5mNHqORoX7WRvCveChRIj6hcN2l+uU3EMjlyB51k4Y/YE mCQtmMUPZJKJJnOAROX2XYV3HNyqFZhDIJv1oJ7wm8KjPILfNuZNo8F/p9AkGAGsEfoq 29VM2yfSGWHDklRc4o9AhciP3bQL1Qs34nzzkT00DU6O6l6lKagGbQAcHVQWnfFMhY3m kM0g== X-Forwarded-Encrypted: i=1; AJvYcCWjPAuEycWk2UadAtQSZbyR7wVSYXKaLscarpGIcAmJTE2wV0EhGO7tFScHNmVwDjqlD1vodPNaiamdVxqja1lMNXD7+dzpRxs= X-Gm-Message-State: AOJu0YxnlwcMZTySmQ4qBsmt2t/WwoMkyDp6E97Bu9Yoj2S4x6j/mKyG CxMPtwWj6nsajOChMcn2oP+dPFwxwBDOEiX6dFfbNWw512Eb5TQYstWlxXR84FU= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13703866 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F4CA153819 for ; Wed, 19 Jun 2024 14:09:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806160; cv=none; b=fSdZaNtSlnqfE8+gDkQZp21JbJlHeFhJtnojMialzMFQR9A9r9S+YlEsuQSOuOU2RIj7a3VnLVW+ualtU9iUvZN3PYwFK4ks26Qjmyg4EJWD2cWaKZXdsX2BggSoc50snbCYYa35FFi4ly2l9Q53cCjp7cUdb7V9Vobu76OL9Jo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806160; c=relaxed/simple; bh=UqitLzzPeo8+v+foWj/D1g1tTUg9dHcKK5jhxbU/5dc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ku0TgJ7LU4PNtSjNSDEQWzOrcmyGIS5WZs90wE/NUZz6XMLYtSXKAJuiUOz//ytgHwUenanSnIOGUn5eYQ8Mi4o6Sl9kPkyasuUCfDZZMEXPRVWRnwm8QkBIzK4L3szfK5vI34ZDcH+MFBqd8ADl6Z539f1ZNxaydhysgo9aHYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Qs/GKz/5; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qs/GKz/5" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2e95a75a90eso71418481fa.2 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=vger.kernel.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=Qs/GKz/5laiNYvsjeBxiBkVMGf/5lX6TdCWc6ifXLOHgmafbxHh2zpaImHh9Aj7Z2y TyThogMJ1kLkUrYNneisnVLk0Xo6zFuDgxy/H+IAcao0s98TKJrXJ+4812XNsNKFpvMr Q4WH+vfDxF3QDnMROa3kDLorTNL2hG+0xoD+C/wUumglztuHan1jB5e1hvG/OxlbGnAk iC3q199BeVgMRNPD9Buz20CPnxCc/mWExi6FmsV4hi6MZQ5wOlIrnSVeaGPeS6LO71Zb 0vZJoHp7bz4l7vpkJdZantaZNhc6nhoMXd39Fov9k1UcZeiceWknmsAaPpiZkv+S+agn fBzw== 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=N1nHCb7v5zvK54kaIq6WL5FpvUt4gQsTUNXD+xf+CTaODwXFU6j9oaV62hdR0uFhJS rmOQ8xAjCFmgqQaJ81lriQw/s9WubtYS50mYU4MBRy7leQLqKhRlxQdaJaf1fpGqN2th F7iKJzUZKqU4dpqq2itM44qe/yz+5cdwYy4TYdCXS1QSlygZorEPbiFuqhfIEKF6pGYH jUwlWpY3OM6ucyqpNoYIEzttglWSM23EXOuuDqEyGaCK6JyYvuwQItrWNJwPM+AXqFF9 z47XCImn0oqwIrktN4J3mtuQNF816s07Hg6ZoL+Zeo+YJQUAOqSOKqjdKvgvLEFoLZCE fZbw== X-Forwarded-Encrypted: i=1; AJvYcCU9JKqECZrR5zSX22BCp+WOUXICSY6+vzHGHF10/FEu8AlzEZnne6nT5BjEC8o0GW+xB7dwc4M67mCtgzkc4NxA4HN2ReFByJg= X-Gm-Message-State: AOJu0YxLkwe+Wy7Knqqt3g73+Kz+U4Axh14D74Ni/qzagghtKFiQPTlY 7IXxZzCNzSgjjnKr/j3Z++nlrkBBuw2OztoLDoSmGRTEUbZLT9u62yFAmRDakxE= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13703867 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97529154420 for ; Wed, 19 Jun 2024 14:09:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806161; cv=none; b=mh7GHozzqOulw8jcjGqlKZj+JbuoSVE9ow0gw13rpTM6qib6ZXqzoHxdaHvxPYscPGFbVBZifa7HgpbxrCVH5Lr/F/AGPWISuKQ0qRHk4QZNmGj5w1uyfCDp6ucOmnSGbBDcXXLRMf7FVtxG6bLtRvGTaw5dGWnhNGTFoWp0CuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718806161; c=relaxed/simple; bh=tMkKP1j3bPuCq4pIK6nHgDfdOCxrfuXOdv1IXJAZ2JI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MNocW8InXCT2HqiivcHubqnWlRX8389Rgo/cPe35QUNHS7+859haMlvwvYx7W3xcu72JFltb5ofQ10mdh8SNZ+cULQS4AGwSzTFg+xogOXzPVzqIPOHfGZADxMCo8JePXJrW9aMxwNYhtmrvc8QvAm3reMBGT3v2MtQjiJ43YwA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=uXlD6olg; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uXlD6olg" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-52bbf73f334so6348192e87.2 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=vger.kernel.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=uXlD6olgAX1XYnFHcIuNNjtrSHiXI4DaZY3yL2t5QT2XfkplFCnxbZdJTviVhc39fR 3K9D01pwUPEg28oXcKRIjlNSrZK1yk9a5kaMp2BhqMV8SgPN7OIdzAdwC8uY0PLBK3wh 5+HcyOU+scfZ7ICiiqPrrOiIl0jnd3c9eT5uFm9NwBZasV3zdQEWlP/1Ox/PUsxH/b4l Obso2qXO+lpG1WymmtK4ktMsg6iVtpdKh1gVh6S7rpsae5dovkiark6HMxNSXvKwJKu2 wMq45yGBQxehJ2KV3pxHmG35I3OOsIFf219XluuRanpdLwi7FnGV40N/wC53m8h9aV4p Wlsg== 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=n13RgzYAGeMM55As6+e5XWRiXtNN+JTMJnZHBttvzyvKOjKHuIqTxe2gIYR9gVmbgi y5Bi+s4pElpTNLEluExoXF5IexmQ4H6i3ZlzV5Kd7PSgGAse+9ms655OpKG2hAo42Dmw XrgAjd4L7qSbz2HABMXaSX+Tc5g4mItriI1BjNUwdkGolow71hmCQPcKz42baPrga0fn S1USnMV5/s89BCpKy9Lm+6rPSslADhCHuGeumYnLdyl9V6jOf4svSnn4mFw4nqBdUl7f 6TXgzN29K89uMf4m2yeCgysfu5IkGDqBcgOlhn3nnohUeTRrdglRaGcuvcvHKwrV0/Ud yl5g== X-Forwarded-Encrypted: i=1; AJvYcCW2z8JVvCREGCLlX+uMT3NcwGhvg059H+T099Oud/IYAiIh9ZXQOm1Ei1L/FwJwNn8mQDs+GugpnpSHuvDipWRHvH0N4VGE3FM= X-Gm-Message-State: AOJu0Yw5hSEavBPb8gWdEENXKye+k8wVM3fF2Ljxf5gfOpDGV25u2yYg 21yZtUQcFFbui8zhQ7/D4SN6tNNcUrq83vvx8kzsnanRjWaKJeN0I6wn8piHqZY= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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) {