From nobody Tue Dec 16 12:42:44 2025 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 CE5E71D0DE2 for ; Thu, 22 Aug 2024 22:46:07 +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=1724366769; cv=none; b=ZXBrkhSzFAC5M0gPFyXKCrMQ6MCHUN5nwyY0KMKJpr+DBiJNIcGorP7ApsOKLQI4I0cT/0OLSMHy+UnWo3IxpVcffSGqscxL/En4bWukidewJfRgsKzw0NXKacucazHvXoc4rvz8WoJFC1crDRJ1XxO5oPX35nI8cI4kEsUpLaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366769; c=relaxed/simple; bh=6EO0O4o9JKGH4hQejEuuwX4Rpu4yTFw6q9CWeFJnSgs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gOtsipGGTGolwZEbJZtCBssFyMDf0VDB05Kf4eKQStnlX7f7TSuMA0kwYozmpTe+0cGDAs8gg9/D4JLyN0P5bUV2zmADymeeXZ6zWMmVWXXKfB6NzSR//liYNkE3NPMHnHUcodLX40gHdFsLz8wnEExU1sCfw+EXkwXP8sfzy3U= 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=Z3k6r+dH; 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="Z3k6r+dH" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5334b0e1a8eso1693571e87.0 for ; Thu, 22 Aug 2024 15:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366766; x=1724971566; 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=rd4L2pq+cNv6ptoDFsJhK7t/4J9oetWQgiC2gczlRyk=; b=Z3k6r+dHHxeQydjJA3fj0+rgwM2Vypu9l6UL/k4maW5PVfy+R81guPoRV4cJXwCE6w hKufeaHLsHXAkMSPTudDcbN/BLDBGAsnwPtT+exL8QUWOqBmb6WqU7wfaupaz0tJ7FjP omyvnx4QOQtNe3pZtGyvLvO8zTuIX22vnJK3YSDJmc0G36cWnMmJ2WsLEiBSljuBluCb I3kR/RDXRaGtK1qjyn8UxeEgstLIfGLIFkSF+4qnO9YOC7suWLh2Jn/VaZ6DIetLF9Zc ZaBmx0LoTW350RYfh2ONT7nOJ1n/zfptILzKJrzL2HZsFzuK5MdsFOG5VsaxhG8n0wa7 8DTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366766; x=1724971566; 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=rd4L2pq+cNv6ptoDFsJhK7t/4J9oetWQgiC2gczlRyk=; b=QzQqGjfryMFVuQzQzVycQcjCV15R98rC6yM9SDAMAaKo1RzzWy+rib2tJgRUmu1PgC YkDTV2e7dHbeJYFQLop2zSebJiC+mXteXUNnfxoyTFbQQc2MTMogaRKUVLZyW2+cYs64 6P2cL+w7kL62P10LLwbSVoGnmNieLoBtCxF5uxlDhGpJbq0O/qZZodfZmAoceHx1gZec rhB/wbmVvmsvKPE/zN7A2E45Nua/xu0Ec54EwhfrL8avdllxUp5eFgC4HBS4gZrxZdky ZB9Rxxndw63RWC/t7rkVj5IAGedgDr3m4K51Yxh4YLL61PcYAdQBAXD1o53ELWUWOnWQ arew== X-Forwarded-Encrypted: i=1; AJvYcCWnOvahuqUE+Y7uhY6MPsMqbq8uwuQMv1thOpAZ9ogbLVcJCOTLpyFaYtvcZFBNEuG4BF9n8ciNr9yjC1I=@vger.kernel.org X-Gm-Message-State: AOJu0YyNxQd5lEAiYgVeQQgld1RY8Uj05rV7G3L5O7kRNPO4k8QYJ3IJ AfHYkYnnAlQa3x+9lKBwCQlcHEoCNyvxnZJSQsxYYg+CZAoE0za6Ss4b3ggJbYg= X-Google-Smtp-Source: AGHT+IElCYJAQaHkgKGtxiZoFimfR6Ft/lHijVpFpocO2DjQz0yBFh0jjHM8cqfvGlobtCvc9hXNsw== X-Received: by 2002:a05:6512:33c8:b0:533:4638:d490 with SMTP id 2adb3069b0e04-534387bbf16mr242936e87.38.1724366765813; Thu, 22 Aug 2024 15:46: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-5334ea362a4sm379443e87.66.2024.08.22.15.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:05 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v3 01/10] OPP: Fix support for required OPPs for multiple PM domains Date: Fri, 23 Aug 2024 00:45:38 +0200 Message-Id: <20240822224547.385095-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 an OPP for a required_dev that belongs to a required-OPP table. The problem with this, is that we may have several devices sharing the same required-OPP table, which leads to an incorrect behaviour in regards to aggregating the per device votes. To fix the problem for a required-OPP table belonging to a PM domain, which is the only existing usecase for now, let's simply replace the call to dev_pm_opp_set_opp() in _set_required_opps() by a call to _set_opp_level(). Moving forward we may potentially need to add support for other types of required-OPP tables. In this case, the aggregation needs to be thought of. Fixes: e37440e7e2c2 ("OPP: Call dev_pm_opp_set_opp() for required OPPs") Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson Acked-by: Viresh Kumar --- Changes in v3: - Clarified the commitmsg. 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_t= able, return 0; } =20 +static int _set_opp_level(struct device *dev, struct dev_pm_opp *opp) +{ + unsigned int level =3D 0; + int ret =3D 0; + + if (opp) { + if (opp->level =3D=3D OPP_LEVEL_UNSET) + return 0; + + level =3D opp->level; + } + + /* Request a new performance state through the device's PM domain. */ + ret =3D 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_ta= ble, struct dev_pm_opp *opp, bool up) @@ -1091,7 +1112,7 @@ static int _set_required_opps(struct device *dev, str= uct opp_table *opp_table, if (devs[index]) { required_opp =3D opp ? opp->required_opps[index] : NULL; =20 - ret =3D dev_pm_opp_set_opp(devs[index], required_opp); + ret =3D _set_opp_level(devs[index], required_opp); if (ret) return ret; } @@ -1102,27 +1123,6 @@ static int _set_required_opps(struct device *dev, st= ruct opp_table *opp_table, return 0; } =20 -static int _set_opp_level(struct device *dev, struct dev_pm_opp *opp) -{ - unsigned int level =3D 0; - int ret =3D 0; - - if (opp) { - if (opp->level =3D=3D OPP_LEVEL_UNSET) - return 0; - - level =3D opp->level; - } - - /* Request a new performance state through the device's PM domain. */ - ret =3D 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_ta= ble) { struct dev_pm_opp *opp =3D ERR_PTR(-ENODEV); @@ -2457,18 +2457,6 @@ static int _opp_attach_genpd(struct opp_table *opp_t= able, struct device *dev, } } =20 - /* - * 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 =3D -ENOMEM; - goto err; - } - opp_table->required_devs[index] =3D virt_dev; index++; name++; --=20 2.34.1 From nobody Tue Dec 16 12:42:44 2025 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 7C0691D1F58 for ; Thu, 22 Aug 2024 22:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366771; cv=none; b=nOCE3WpJOmkG1IczProD3ie4hnEI0OwK7UBqyw57xY3MhO5HF3Zk8/NgC5Y3wI6KVeWzBARVgxrjsCrtFJ42BndRBI91lhCm1Fuzf9dhXm/NVHld8pLh5EsHKrXNb5roAwdtK6U0isyakpsd1B+vEmZ3eOFzGJ5hNnfJibe7bzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366771; c=relaxed/simple; bh=WdnHFE8/V90EQ5qUO1bLdMKKNLwX5wtnv0epXeooAd8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OGqN7wVXuv4W4pkmYgeObQELKk+lCRqU3vlmEWMimOkvKjQ7PpE4vpAaIeu/fRqSlqaco1CNSs0zSkDFuEDhL6ChhXYv2yX2VrttXxQRvAhnhnuJGWhfiuUrjvLbHZUNjOgOdAF0yHp27SBTj4WfFqwkhjQOGKllk/+4zhuu8Bg= 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=uRcgXjBa; arc=none smtp.client-ip=209.85.167.47 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="uRcgXjBa" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5334a8a1b07so1846546e87.1 for ; Thu, 22 Aug 2024 15:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366767; x=1724971567; 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=lvx3dtDyuaLtWvQBN1ccLzAdA+uGExJd6lwl1p/+zuE=; b=uRcgXjBanJMDcZ8Y9zmj6If03scUGabH/lyycgOnSa3PC7UecrHRxlu97fbbfdfCQ4 NZC9gcx2quEbEDmqtlgl9m3znp1tOosYHsGewBFYTF7TbXwxPTcZfSLFwls1z28SE0Rs eeKIG7kJPsNT0NNALN0FvsosOzqeUHpJF5UWPcC9McpkCQY53W6xgUa0rRv/UlU8r5f8 cafTx3etf7N5Fb0FSvB5YUCiOxo3BCf3jZ1vYGc9VkljQGjzaRL4zBOrkznOK+1Ibqfw qFiuI0vxp8VOaLGKMK66fMeFbX1gL+iPdQopwrWyitpmuQsjOICDcQEYavIu7bSKUSdV kYWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366767; x=1724971567; 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=lvx3dtDyuaLtWvQBN1ccLzAdA+uGExJd6lwl1p/+zuE=; b=XMJxJ+CgKdqjnL0pbdyhBMRXucVav6s8NZf0Tnuacv2fFa2u37YVYP0LvZZmAnICbd xAhdO6AQWSQGlgSIh/I0w1HcW6RGeI4GhlXOtSEdtbQtwP4ibChjuwaRhbEv/PDZzekG VksKtfICynZrZD6lgRfCyoCaHvDM1gUuWzE+g7zt3G+1+kOmPjTrCzeHcowayaTVrDY7 c/UaqGzZ5/e91jDMIx0U249bef6WPrTltuvGmIHAEs8A+rfS90SzWVZROtMKCLmPO/tD +dMbeS3bmHwYdgSkDCaANUInF/akpb4WZ0VSXX0XTpb4DzbURMuFOUQIiDoAFVDUL6rA vurw== X-Forwarded-Encrypted: i=1; AJvYcCXlozYwqltdwsPYCWNzetqQqOr0aHeJB4KII7qcnLUkOvuRe1fCQ+xo/Xn4nkDkp7IciUEMQFZotKNyq28=@vger.kernel.org X-Gm-Message-State: AOJu0YzGiSsuOfKibo01gHjvg++9CrpsEeOR5CLTMDCLB8OZZPbWqlx4 vIzdI5UHX6JB0rcBTPIr9BZ5xCBIQAx4TyCYp6fnXIyaDTjRRcwEj0w14WqgwcQ= X-Google-Smtp-Source: AGHT+IGxvA4Uq9Y8lvyO5rIqpEo5VlzIQ99oKaiGIrLuFmsy7/2BQLTwlcgbwEWVVwymuZXSfzR59g== X-Received: by 2002:ac2:4e09:0:b0:52e:941d:7039 with SMTP id 2adb3069b0e04-5343886c9bdmr183956e87.59.1724366767061; Thu, 22 Aug 2024 15:46: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-5334ea362a4sm379443e87.66.2024.08.22.15.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:06 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/10] OPP: Rework _set_required_devs() to manage a single device per call Date: Fri, 23 Aug 2024 00:45:39 +0200 Message-Id: <20240822224547.385095-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 attach, one device at the time is being hooked up to its corresponding PM domain. Therefore, let's update the _set_required_devs() to align to this behaviour, allowing callers to fill out one required_dev per call. As shown from a subsequent change, genpd becomes the first user of the reworked _set_required_dev(). Signed-off-by: Ulf Hansson Acked-by: Viresh Kumar --- Changes in v3: - Clarified the commitmsg. 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_t= able, struct device *dev, =20 } =20 -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; =20 @@ -2484,36 +2485,70 @@ static int _opp_set_required_devs(struct opp_table = *opp_table, return -EINVAL; } =20 - /* 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; + } =20 for (i =3D 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 =3D 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; =20 - opp_table->required_devs[i] =3D 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 =3D=3D 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 !=3D table) { + dev_pm_opp_put_opp_table(table); + _get_opp_table_kref(required_opp_table); + opp_table->required_opp_tables[i] =3D required_opp_table; + } + + opp_table->required_devs[i] =3D required_dev; + return i; + } } =20 - return 0; + dev_err(dev, "Missing OPP table, unable to set the required dev\n"); + return -ENODEV; } =20 -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 =3D 0; i < opp_table->required_opp_count; i++) - opp_table->required_devs[i] =3D NULL; + opp_table->required_devs[index] =3D NULL; } =20 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); =20 @@ -2630,7 +2665,7 @@ int dev_pm_opp_set_config(struct device *dev, struct = dev_pm_opp_config *config) =20 /* Attach genpds */ if (config->genpd_names) { - if (config->required_devs) + if (config->required_dev) goto err; =20 ret =3D _opp_attach_genpd(opp_table, dev, config->genpd_names, @@ -2639,13 +2674,15 @@ int dev_pm_opp_set_config(struct device *dev, struc= t dev_pm_opp_config *config) goto err; =20 data->flags |=3D OPP_CONFIG_GENPD; - } else if (config->required_devs) { - ret =3D _opp_set_required_devs(opp_table, dev, - config->required_devs); - if (ret) + } else if (config->required_dev && config->required_opp_table) { + ret =3D _opp_set_required_dev(opp_table, dev, + config->required_dev, + config->required_opp_table); + if (ret < 0) goto err; =20 - data->flags |=3D OPP_CONFIG_REQUIRED_DEVS; + data->index =3D ret; + data->flags |=3D OPP_CONFIG_REQUIRED_DEV; } =20 ret =3D 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) =20 /** * 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; }; =20 /** 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 gen= pd to - * attach. Mutually exclusive with required_devs. + * attach. Mutually exclusive with required_dev. * @virt_devs: Pointer to return the array of genpd virtual devices. Mutua= lly - * exclusive with required_devs. - * @required_devs: Required OPP devices. Mutually exclusive with genpd_nam= es/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 de= vice. */ @@ -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; }; =20 #define OPP_LEVEL_UNSET U32_MAX --=20 2.34.1 From nobody Tue Dec 16 12:42:44 2025 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 A00C71D278D for ; Thu, 22 Aug 2024 22:46:10 +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=1724366772; cv=none; b=JVBnmxLX5Z/AhNnfrJUPzkwuMEUl3UwPCHncag4H0NgR2NkfXlmrjYIgmU+akTsEF14kdaFjmJjwCoXfIPTjnh7xQU+AbDMG5EdR6fbaZypb1BPAk2rhDUNXm1s4xtZ7HDDGk8bZ2H2ELqMoT64ZOgBsRfY/eQ/+bj0zW2Y1wok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366772; c=relaxed/simple; bh=hYhQGKE1LwPkoZhf3M1NbzKrzI4lCg6eCswGukUEMHA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qyBqrQM34c7jeiI1UjPGncTwyhN+PBBI6c2NSOAaTrs6kzlK/IpPzoj1UJYtCjLG90uz3EOoIG7a+yRw6K2xnJK8BB7zs/vwyHJVugjamICI/hVtX/mqfzjF6/t5WwdR81b7WAehRZkLgbAQQGD2Jee1wnroBoHrH3vA9Lt02gM= 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=aMIte4RG; 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="aMIte4RG" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-533488ffaf7so1786030e87.0 for ; Thu, 22 Aug 2024 15:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366769; x=1724971569; 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=24E2ZJlxZRFr5xBB3D3mkMAuhlD0R/qQC+7zUcBQFEc=; b=aMIte4RGqNOSHiRa/8OigcuE37kk5vNc099jNq0JTO2c0rxJRkKT+cgiNZwBk06yYq zTIZucuYrTjH3A1fYZNQoj4FYupk7JbX0PbV+T8Vf2iy3xciC2MaTKX9DyZEp7YAigd9 OwsXsSeA1nfPYnjLx/ZuSX7S9+U6dcobdu0/tm7pck0u10wuhzC+nbTxtHm08iFVmDJc f7Inp86vravRPkO/NMFWTBqKZwVcjcJDYl0b92/ukpwZ/FaKMO0SaUK7KLQgYHp4sGZd ei8mhcqGVWuYWVAS8f49ktBUDpxBoaGO7qxnUF4PYZ+qzX76heCzMom/L0o66gfi85vh vY9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366769; x=1724971569; 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=24E2ZJlxZRFr5xBB3D3mkMAuhlD0R/qQC+7zUcBQFEc=; b=oJSS6uhyF9wC3maaSq61/TRuUNrEY5MgIZgHydgO+5OhT3OX2eDkH3RTMKWedmTQvs Hu2n1ge5xWByNuQelPeAE9Ps81jtPtQsneejgqDJNCGlF181kYWG50dCwaSiv2nwVg8y EamMAYXEpZQmmhxYR+THDqF9mT/8nib2fHTgfEZI+YxbWIhllgOs47phpU3oWGtcIGZ9 9QeVZ9L2LBHuCHsRsoYsYX9dGmzaXNKFODnIq0/ZctzPvLBc31M5RF1zJkDiDFTapc5n AP+mohnb2GZSpaBDsxlTfhvtlWBrbkRyUdgg9d/Uq5rJW3sBhmg1bUIwcrFjkqE3tg35 l3dg== X-Forwarded-Encrypted: i=1; AJvYcCUQJQEHiN3ypOwA+PK3NAKOIplaG6QQXZVUiAydh/DVtWJMHpVcHgm9g1Inbk+qoESNNrR5OxAnDXtgTIw=@vger.kernel.org X-Gm-Message-State: AOJu0YyhZvdfv8htKHWQdIK0oYGKQtiCZUE7MA//TykZOH5uJlGgXxSC f2KUgKAQaxuZygs7eQ72GvLz/IdGfpNhZFDdTzx3xr9jiAfc+mgF2zXSJNbtUkk= X-Google-Smtp-Source: AGHT+IELTL8/y0e0fGbr2lzzbBRJ4DDHIa+OZXd4j/RR2q0PvMAUXPDsy1xGSGg5oKqO9JdJ+zyCrg== X-Received: by 2002:a05:6512:23a9:b0:52c:d27b:ddcb with SMTP id 2adb3069b0e04-534387554cemr259563e87.3.1724366768686; Thu, 22 Aug 2024 15:46: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-5334ea362a4sm379443e87.66.2024.08.22.15.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:08 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 03/10] pmdomain: core: Manage the default required OPP from a separate function Date: Fri, 23 Aug 2024 00:45:40 +0200 Message-Id: <20240822224547.385095-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Viresh Kumar --- Changes in v3: - None. 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 2731b285e017..08c2192c02b4 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -2884,12 +2884,34 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } =20 +static int genpd_set_required_opp(struct device *dev, unsigned int index) +{ + int ret, pstate; + + /* Set the default performance state */ + pstate =3D of_get_required_opp_performance_state(dev->of_node, index); + if (pstate < 0 && pstate !=3D -ENODEV && pstate !=3D -EOPNOTSUPP) { + ret =3D pstate; + goto err; + } else if (pstate > 0) { + ret =3D dev_pm_genpd_set_performance_state(dev, pstate); + if (ret) + goto err; + dev_gpd_data(dev)->default_pstate =3D 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_d= ev, unsigned int index, bool power_on) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; - int pstate; int ret; =20 ret =3D of_parse_phandle_with_args(dev->of_node, "power-domains", @@ -2918,17 +2940,9 @@ static int __genpd_dev_pm_attach(struct device *dev,= struct device *base_dev, dev->pm_domain->detach =3D genpd_dev_pm_detach; dev->pm_domain->sync =3D genpd_dev_pm_sync; =20 - /* Set the default performance state */ - pstate =3D of_get_required_opp_performance_state(dev->of_node, index); - if (pstate < 0 && pstate !=3D -ENODEV && pstate !=3D -EOPNOTSUPP) { - ret =3D pstate; + ret =3D genpd_set_required_opp(dev, index); + if (ret) goto err; - } else if (pstate > 0) { - ret =3D dev_pm_genpd_set_performance_state(dev, pstate); - if (ret) - goto err; - dev_gpd_data(dev)->default_pstate =3D pstate; - } =20 if (power_on) { genpd_lock(pd); @@ -2950,8 +2964,6 @@ static int __genpd_dev_pm_attach(struct device *dev, = struct device *base_dev, return 1; =20 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; } --=20 2.34.1 From nobody Tue Dec 16 12:42:44 2025 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 2E0FF1D27B7 for ; Thu, 22 Aug 2024 22:46:11 +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=1724366774; cv=none; b=fJ+iJGv8hBJNbElm6CxTtv1VOQs3AJEG7ft1ow+xtSjBxTSaoxM2UuP8J5JShSttup3euBEOOAMJs5dxPFOaLuJ4ox0IEyAvxeZZ3MGD/wEhcunahzqBv+MmL2vMkyue+REEeqOR5As88nD4a2i29ifF/3G4iELE4/ZSyHYz+7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366774; c=relaxed/simple; bh=kYws5feVcAp5TCTiYhNwS/JM4enNtl/LEnARtxGFF3s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YWtb8h8XIWlOrX6dqHFxD8cW8yPVO+0YXYIPudmnaZOfnubTTGQCeVhDr3CHPs/D3C2vqal7UnDjp09sK6+DJ/r3L51HVQBEfOWe3OTlBPx1wYQYYYwlwooOEkBoVxRBqHfxn6LaKZXtVHuTG5D6gv0to3fBjaosXZFW00mkjyg= 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=VD/yZl27; 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="VD/yZl27" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2f3b8eb3df5so12951871fa.1 for ; Thu, 22 Aug 2024 15:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366770; x=1724971570; 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=StJQRqCUVSSiSwu+3Mjs57fSdgGfFXaPCc1PsB3TzNQ=; b=VD/yZl27SA6t5R3fvsyAkDGFePeZjZkAaHB6oGxUqMf1e+cVsbGowljG8SHPVuDVO3 wS6x0hZn8UBY/DC5dTwrxpjusVuZqdJmPKexhbFPsymxhIzi/4muepCF+gMrVqTtUQqD c5ItPaFhnp85U7LSl56vpNu0TwGilTZaQHDDJM+Hbm/ix1lnhoPQWZW4PE6uKyFfJnv6 0FAxUBuZnmOd8pHlZpl3rALWslBBZWVo6xeFJohQSGQeRI6v5CPpVY1UCzNpkP1Uvb9D 2HXDgXQubOSr4OM5kyLr+JBJf3AyrkPefetOiQ+CM5TDbq2yoUgjl6okZi80LZTE/JG2 iPNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366770; x=1724971570; 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=StJQRqCUVSSiSwu+3Mjs57fSdgGfFXaPCc1PsB3TzNQ=; b=UK6RE90odUl5cBjyCPYXUrW8Ki1VsogsSh4LXa16oVYQ4qv+yiU3tvWsP7F9gPZ8Pf 8L4z+rHb4GIq8Xf9/oeJn1KniP0oVvesGjQ5QLJuAkqgT1fPymadSW3RpdM4j8J1KxP6 mfadH2QKJ18eNLurVNwOlVBERpquh+RgAZnMyXpRvPiKdj+XtXRDNZfKX4Xutt77YvNL HLMWlw6ZOa5HB22fikgSC0VPwzYDjCaXlqSWdQ8owrCoe4I9oM5jAN4YqxkzNVNi25mz VudOpOfXdf9RyUVKodauStKU243aHSRm3BBeGgYS0E0uqAaUZTW17DGxG/gar2WbUveO l2SQ== X-Forwarded-Encrypted: i=1; AJvYcCUBjCMiCJy389TwrIsfuFedolrUW/rx12wphw8uzZwqeoACZDBMYK7VENMbzHbIu+o/0peY/gPlfEZ5+XQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwYMmAYrn5Anwpqh1gzwlIo6EVPMXGPV7Ro7MT7zr/4O+EL2+9/ H+P0tU6r1JYJQu/SaUag5ipWAu422+JijTjHCpeXxRm6RALWya6vUwdF79Rd9BA= X-Google-Smtp-Source: AGHT+IGZamYSbygv3IkTZMVDGmekn9pjg+mdj2f5WolkNXH5KSnZ+vzYw3XXkDNayrwgkV2Bn3eurg== X-Received: by 2002:a05:6512:3b88:b0:532:c197:393e with SMTP id 2adb3069b0e04-5343882d172mr169993e87.11.1724366770078; Thu, 22 Aug 2024 15:46:10 -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-5334ea362a4sm379443e87.66.2024.08.22.15.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:09 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/10] OPP/pmdomain: Set the required_dev for a required OPP during genpd attach Date: Fri, 23 Aug 2024 00:45:41 +0200 Message-Id: <20240822224547.385095-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Through dev_pm_opp_set_config() the _opp_attach_genpd() allows consumer drivers to attach 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 principle, using dev_pm_opp_set_config() for this works fine. However, attaching a device to its PM domains is in general better done with dev_pm_domain_attach|detach_list(). To avoid having two different ways to manage this, let's prepare for the removal of _opp_attach_genpd(). More precisely, let's assign the required_devs during device attach in genpd, by using _opp_set_required_dev(). In this way, the consumer driver can rely solely on dev_pm_domain_attach|detach_list() to attach its device to its PM domains. 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() can be removed. Signed-off-by: Ulf Hansson Acked-by: Viresh Kumar --- Changes in v3: - Clarified the commitmsg. 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_t= able) continue; =20 dev_pm_domain_detach(opp_table->required_devs[index], false); - opp_table->required_devs[index] =3D NULL; } } =20 @@ -2393,8 +2392,7 @@ static void _opp_detach_genpd(struct opp_table *opp_t= able) static int _opp_attach_genpd(struct opp_table *opp_table, struct device *d= ev, const char * const *names, struct device ***virt_devs) { - struct device *virt_dev, *gdev; - struct opp_table *genpd_table; + struct device *virt_dev; int index =3D 0, ret =3D -EINVAL; const char * const *name =3D names; =20 @@ -2427,37 +2425,6 @@ static int _opp_attach_genpd(struct opp_table *opp_t= able, struct device *dev, goto err; } =20 - /* - * 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 =3D dev_to_genpd_dev(virt_dev); - if (IS_ERR(gdev)) { - ret =3D PTR_ERR(gdev); - goto err; - } - - genpd_table =3D _find_opp_table(gdev); - if (!IS_ERR(genpd_table)) { - if (genpd_table !=3D opp_table->required_opp_tables[index]) { - dev_pm_opp_put_opp_table(opp_table->required_opp_tables[index]); - opp_table->required_opp_tables[index] =3D genpd_table; - } else { - dev_pm_opp_put_opp_table(genpd_table); - } - } - - opp_table->required_devs[index] =3D virt_dev; index++; name++; } diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index 08c2192c02b4..0749da94624f 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -2884,6 +2884,61 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } =20 +static struct opp_table *genpd_find_opp_table(struct generic_pm_domain *ge= npd, + 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 =3D link->parent; + + genpd_lock_nested(parent, depth + 1); + opp_table =3D 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 =3D dev_to_genpd(dev); + struct opp_table *opp_table; + int ret =3D 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 =3D genpd_find_opp_table(genpd, 0); + genpd_unlock(genpd); + + if (opp_table) { + struct dev_pm_opp_config config =3D { + .required_dev =3D dev, + .required_opp_table =3D opp_table, + }; + + ret =3D 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; @@ -2940,6 +2995,10 @@ static int __genpd_dev_pm_attach(struct device *dev,= struct device *base_dev, dev->pm_domain->detach =3D genpd_dev_pm_detach; dev->pm_domain->sync =3D genpd_dev_pm_sync; =20 + ret =3D genpd_set_required_opp_dev(dev, base_dev); + if (ret) + goto err; + ret =3D genpd_set_required_opp(dev, index); if (ret) goto err; --=20 2.34.1 From nobody Tue Dec 16 12:42:44 2025 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 774ED1D2F61 for ; Thu, 22 Aug 2024 22:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366775; cv=none; b=MGJhLI51Pw8WdE8RILuWeil01RVynWJAefH75zNJJJyAUspsssV4URiPy98/ZIGpiWywuvX8r5xN/F4BESH/by7e2IAsGp2GeIP21dWSDtcU/1qJ0B4PTuglyiIHCZP7qB6LuuszxKpvBkALAl5o4RskTZc+ovWCvcAOd6pAGow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366775; c=relaxed/simple; bh=KEvEd+LQGygUiMRwqOZhLYNHpMTQYMq7EOdWZ45iHDk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o5IbSf0UR85voCwRHCnID/cPjIeFUcgEK78bOgZknGf1w+l+ZQb0dFbrFi85CL6O1AFsEyhWBCGY9PQZcRewGPDQmhbZk2z1XAzn2WE3/NFrZMnyof4+n5q1I/lQrU8v4N7uJl9QEQp6wZKFcVAuXLsovKj/c6HhMN1vj9qLDOs= 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=IWoHAsCA; arc=none smtp.client-ip=209.85.167.47 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="IWoHAsCA" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-53349ee42a9so1662830e87.3 for ; Thu, 22 Aug 2024 15:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366771; x=1724971571; 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=9IgtH0skR0e3C63jmvkIAtxr085sHyospA98t+tzDJI=; b=IWoHAsCA5t+GKz4hF4RFOSz7b7o5MR58bORAYlj561skVhRktprz5Ajxe2rkS1laSe u/EHHI/IuCDjuMOgFcYOiHN9G35Yr1I3W9TtR50NqgsQo0ZHoWutoIrIgwnctJyXqbaS csqcytQFepyTYblg6rkIXdbTcFLRxLsqTJVnw11Wottezf/hrsFjeaJY2xtLcYgxfya+ sBuYJUyEjWbSflffsB0TgQ0eusoMxT9OMHTzoyEUmjKcSnu9NAA78L6NTOB4cXdy4etw Ri8A050WkM9M8IpPq0gNvhOgFzTZSwgHpuDftbF22y2Uf/cPNDOLvTjFZyXVCzUBHyeD SqlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366771; x=1724971571; 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=9IgtH0skR0e3C63jmvkIAtxr085sHyospA98t+tzDJI=; b=I0LXGHbKsnBxS8Ya5gFbW4V/yE4mHopk9pvUBv5hXqhBOsfhecId3meG3PMQh1cVQ3 7MuwvkVzrhG9/1nCS0GyDRwFaNP+SS2+prMte5W30wTLMXQWiae+RBUiiKRS8e3Cba0q V5DXtpifIJsT2AGiK4Ec8LFwiD+cPar4L+WV0m4krx27RxzFRMhsRcUkj6hJf1ptJGuJ uXMRx6rrcpnGz8mgO8GgD4cWxKMGDFx74zp/nemPE2WnpvPe2KchroJoQcJioqAHCcx3 xnj7fxKmSAmrW2CKiKjI9/cXQRQFCiDfGfzYDqOgYhdaUWIB6XxL6mIR61yOmV1bOsVE vEGA== X-Forwarded-Encrypted: i=1; AJvYcCVxPOFi9EUzViroNrm9zcZ2RMQcHizUZyG+xUSKRlkuuKDOiMzeYDvEvruTU1tx8AzgxoAO30oY3dmskrA=@vger.kernel.org X-Gm-Message-State: AOJu0YwS0EgTh1PTdb9wE6VsdgtwTzN2FbmZI6K5SuFN6RsDZQBXgKmE aWCnPnZ+ZVTAs/4zBF8cVsCawZwzMbT+OUEE//A5f2jk7rg2P1Ki5AxIX5mnCaE= X-Google-Smtp-Source: AGHT+IFNgxeohcK9pIDV2zZdHATDKL7WYCEymR2r9L2dWkQ/5MOeAMKb0NrqhPaC3r++lSrG4socBw== X-Received: by 2002:a05:6512:3c87:b0:52c:d905:9645 with SMTP id 2adb3069b0e04-534387786ebmr208252e87.13.1724366771338; Thu, 22 Aug 2024 15:46: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-5334ea362a4sm379443e87.66.2024.08.22.15.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:10 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/10] pmdomain: core: Drop the redundant dev_to_genpd_dev() Date: Fri, 23 Aug 2024 00:45:42 +0200 Message-Id: <20240822224547.385095-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There's no longer any users of dev_to_genpd_dev(), hence let's drop it. Signed-off-by: Ulf Hansson Acked-by: Viresh Kumar --- Changes in v3: - None. 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 0749da94624f..edef1a520110 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -226,16 +226,6 @@ static struct generic_pm_domain *dev_to_genpd(struct d= evice *dev) return pd_to_genpd(dev->pm_domain); } =20 -struct device *dev_to_genpd_dev(struct device *dev) -{ - struct generic_pm_domain *genpd =3D 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 b637ec14025f..f6d26cd81096 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -268,7 +268,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 st= ate); int dev_pm_genpd_add_notifier(struct device *dev, struct notifier_block *n= b); int dev_pm_genpd_remove_notifier(struct device *dev); @@ -318,11 +317,6 @@ static inline int pm_genpd_remove(struct generic_pm_do= main *genpd) return -EOPNOTSUPP; } =20 -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) { --=20 2.34.1 From nobody Tue Dec 16 12:42:44 2025 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 14D0C1D3183 for ; Thu, 22 Aug 2024 22:46:14 +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=1724366776; cv=none; b=ll4NHIkbBIc3AIPkZ0yrTotlEfihVXqh+szXMSAp1fyoE8ZQqsNgeOK2bYS5Kw0scACm5Qk+RlkdDNNQL3nL1WoAzRJlsLqbxnhZfdBIWpH3joQVd970RFwyR5nEeU9EXrnaW4yehpQoGfofw4MSg/JwOkj+kmcpU4leeF+apmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366776; c=relaxed/simple; bh=DdbTGiKeukNvKrj58NdnlQsJE/mkxNsRhHB3HvpjByg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i+gDYsvVwS1reLfDTqp1BacZbZO7jg6dbuYeQxe7c1/BcPNcne9TZ1wlG026DEN/88E3y3gCOEnsv1MjLFFvihZ6qX+gec9X5vm8i90I3S2wE7P22Kld0TKpPwgLI57Y1dfas4vCY16t1kexGe55ftA+d0yBeQ2IzU6Ck+nkl+A= 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=MBr0PZac; 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="MBr0PZac" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-533461323cdso1584904e87.2 for ; Thu, 22 Aug 2024 15:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366773; x=1724971573; 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=/D/aVXPRU7SQfotSax/kaOpx6m/gKAibnYASkuMoMcQ=; b=MBr0PZaceVkmnuGhJBesuGJ7nSFgz1cZNpzKi55wgAu3/KBXy4ZCPqrr6x3nSvOR9r O2yJ7CjKmdhFwvODskfm8x1FeBXJDs6qCE/XgUEZx1JtPhyKxLchW+pIekzQkzuLUOQ0 qMGFDO0boE8vZHM0B2yskT1X+uaYBECzDq0U9nci3YkwjvVV/Os/c8BwTenOiqGo04q+ wYlQrC9q+9Bw+1fhLj1ltg/4CFfjPmmJPTpZbzcWT33/19Pd+httNAI8oe31sm6w7FcM 62SwGp0pBb0sOdvE1/HgMvWCf1B5tioX66d+VUlYUmoEkerf8VhNhLxvKDM7QrmeLjsO mBww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366773; x=1724971573; 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=/D/aVXPRU7SQfotSax/kaOpx6m/gKAibnYASkuMoMcQ=; b=ia3kNwLLRQ6afck/eCbjDCJaCaOTeZVPTJZFeCLdWYcnA3chzvbUftn8/M59b5IZJh OgoqP6NaVcZGYOfbLHZuNDtCwj0xqSXY56etJ2z3wulxg8yeKDjeX6xmc+49+gWNsOpa Xvcu452xOOi25/+8CJr8G30F5oE8wn3c/sSkC0Uz81uTLiUasE1TqqFlD+EBDUAM3mNQ y6S0GkDs2FT5SDGIxfi8CZ8NTYOimgqSNnCLbebZ7SlxDbE+DIQGsDQgi0kEsgOM8eIB u7bQ4RNaOGcWINN+0OO0i8e5fjgK5+rRWUF7KgicPgw67uXoxdJuWcqZWXGjnEEmWDct 2Pyw== X-Forwarded-Encrypted: i=1; AJvYcCVC1KozwZapZJPz0rj3RUoZCnK8fopb9dUfByckOVWkyG3W+SqGACYJlHJIVYdK5sCxWnWZvzGBuIZ8Xmg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4MOqKxwKgL2Jk0sD+9J41R7X2lq1cL+F1g3D3u5soJVYfpfOJ 5ZDng5Xy+SC8/Oe93sVwejpPcvINwNWEUF9CrkuDWmw47WP4jkgK60gyfCxDdI0= X-Google-Smtp-Source: AGHT+IHhhSvatCGlzIYJAKPJG00P39imQvuyh3f4XRIvd0rEr5zWn9noMQWqj/FUZVYPNGBt3R/oLQ== X-Received: by 2002:a05:6512:e89:b0:52e:767a:ada7 with SMTP id 2adb3069b0e04-53438868d57mr128566e87.50.1724366772836; Thu, 22 Aug 2024 15:46:12 -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-5334ea362a4sm379443e87.66.2024.08.22.15.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:12 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 06/10] OPP: Drop redundant code in _link_required_opps() Date: Fri, 23 Aug 2024 00:45:43 +0200 Message-Id: <20240822224547.385095-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Viresh Kumar --- Changes in v3: - None. --- 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); } =20 -static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *o= pp_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; } =20 - /* - * 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 =3D=3D 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 !=3D OPP_LEVEL_UNSET)) - opp->level =3D opp->required_opps[0]->level; - } - } - return 0; } =20 @@ -370,7 +337,7 @@ static int _of_opp_alloc_required_opps(struct opp_table= *opp_table, if (IS_ERR_OR_NULL(required_table)) continue; =20 - ret =3D _link_required_opps(opp, opp_table, required_table, i); + ret =3D _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 *op= p_table, int ret; =20 list_for_each_entry(opp, &opp_table->opp_list, node) { - ret =3D _link_required_opps(opp, opp_table, new_table, index); + ret =3D _link_required_opps(opp, new_table, index); if (ret) return ret; } --=20 2.34.1 From nobody Tue Dec 16 12:42:44 2025 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 162421D31A3 for ; Thu, 22 Aug 2024 22:46:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366778; cv=none; b=aHS8J8jg8C6SMWQkRntG6fZMmXLxpxVbOFwHv/APBDag2B9rQ+o3ViMQui6usOkhylbGZkJAYzNSwGH5eLtvfmOsNb+eWUoKILBCAs+lvKYrScV2i3VFQ/P6V3UFpyWCcW5cxOL2Txb5XpKz//bJCsf/ZOnzCnX1IOcB4a8fDCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366778; c=relaxed/simple; bh=aTdXvkE8ROQKXFHFBAQ24D4NEQho2z3rdw1RpRjU0c0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kbnZSi2sn5nneW6eDAsVLFyGj17bZvUxfJ4O0XoDXoUV1p8wYO7FGuHpq4lwRI/bRBJh4hYvMnwhU/tz53nxPz7ctz/AhcvHu3BJ+mGYUG+qrCDGSCkexuO1H9axQAUm6rNU5nh0OewYMiVaaLhF+1Xvd+6s9dDfQuV5+A3ux+E= 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=o7BV5jQ+; arc=none smtp.client-ip=209.85.208.178 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="o7BV5jQ+" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2f3f163e379so22750741fa.3 for ; Thu, 22 Aug 2024 15:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366774; x=1724971574; 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=/SUsoi4RcXT0izJStB+EvDnWgGn5xCm1gI9JONZb3y0=; b=o7BV5jQ+N0P62oXue/wvqFkHWl2zRVz5w06+d3+UNS/O6K/oFROhrWnanEvc8M97Ya FIbEay6117dGgDHn47H+yJScq3Lq153bbpXr6qrxb+RgS/U8zoi60hjGvFv7o2wzQYOS yJw0AeenZO9bMG4YAXjbjzH1TBoicW4i/iHnAn3kJrHxjQiECy0liUxIjP7c0+tDUaF2 rTAkEcGB+jCp+Jg5IpQ4BqmrCpGLcWP6MSOqICI7mYzHE8cNPlloWK0qKVfSVMrVdkFV ZQTLXmoKge4Br18jaOVaGGMZ9xmHgUk+FC46T+eSDdUjf25+Y7RNdLgGhD36KnDAfhuk r76g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366774; x=1724971574; 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=/SUsoi4RcXT0izJStB+EvDnWgGn5xCm1gI9JONZb3y0=; b=CzMD85S/JZnWb7q1NiKKuDBthlsBkawOwhFdAhh8riRO+qehhWfsR9NJ60hc+Xp08/ qSFKgEtQDA3n/wHmayJysMFkeuUooPuIl+gC0mBpM7hegAJj/9oYnVQf9BCs/LZvRPF6 U9FhZRcxxV66f/ilVaGvUfDITOYczkIIZ8hrPLs0XXspExC03YHIZq33JeW7d9J7fRfd dj3oAfYBmUv61okW6w4JTD0Su6Apag9+A51RLcHxOtGH3T7DoZz5RyGCsr3oVqeXk7nZ i7zyk+2aWZvLoJdoQlhUNgAEejjM8P7DZ6BEXrIFRxXDUa57H42coZpEp2q58fnrNdeg 8yrw== X-Forwarded-Encrypted: i=1; AJvYcCXep1kOcYv4dAc9Vqxj1a674Qm/WHoyU2fZYPJe6UPTircJvkGUJkW2sVPImJN4jn3IY4l45LQRlh82mq4=@vger.kernel.org X-Gm-Message-State: AOJu0YxAiTcyLt2foe2Whf6Ilv9i7VoCRWPHjyGRaaQftxF4DzJV1XLv GnU9acyxQVQRNFfxW5sD3sUHGiYnkPAmTnu7horTFxlXXStiNRFeXTKXeLwCoLA= X-Google-Smtp-Source: AGHT+IFCCObzEZAVeGe1xfyTqYfuTrbw8eyiD2QimVszxWbvB5nuySwzUySXFi47i38a78U9YOXQGg== X-Received: by 2002:a05:6512:3e19:b0:532:fb9e:a175 with SMTP id 2adb3069b0e04-5343883d5e7mr474551e87.6.1724366774161; Thu, 22 Aug 2024 15:46:14 -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-5334ea362a4sm379443e87.66.2024.08.22.15.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:13 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 07/10] drm/tegra: gr3d: Convert into devm_pm_domain_attach_list() Date: Fri, 23 Aug 2024 00:45:44 +0200 Message-Id: <20240822224547.385095-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than hooking up the PM domains through devm_pm_opp_attach_genpd() and manage the device-link, let's avoid the boilerplate-code by converting into devm_pm_domain_attach_list(). Signed-off-by: Ulf Hansson Acked-by: Thierry Reding Acked-by: Viresh Kumar --- Changes in v3: - Updated commitmsg. - Converted to devm mangaged version of dev_pm_domain_attach_list() --- drivers/gpu/drm/tegra/gr3d.c | 38 +++++++----------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index 00c8564520e7..d52433cf939a 100644 --- a/drivers/gpu/drm/tegra/gr3d.c +++ b/drivers/gpu/drm/tegra/gr3d.c @@ -46,6 +46,7 @@ struct gr3d { unsigned int nclocks; struct reset_control_bulk_data resets[RST_GR3D_MAX]; unsigned int nresets; + struct dev_pm_domain_list *pd_list; =20 DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS); }; @@ -369,18 +370,12 @@ static int gr3d_power_up_legacy_domain(struct device = *dev, const char *name, return 0; } =20 -static void gr3d_del_link(void *link) -{ - device_link_del(link); -} - static int gr3d_init_power(struct device *dev, struct gr3d *gr3d) { - static const char * const opp_genpd_names[] =3D { "3d0", "3d1", NULL }; - const u32 link_flags =3D DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME; - struct device **opp_virt_devs, *pd_dev; - struct device_link *link; - unsigned int i; + struct dev_pm_domain_attach_data pd_data =3D { + .pd_names =3D (const char *[]) { "3d0", "3d1" }, + .num_pd_names =3D 2, + }; int err; =20 err =3D of_count_phandle_with_args(dev->of_node, "power-domains", @@ -414,29 +409,10 @@ static int gr3d_init_power(struct device *dev, struct= gr3d *gr3d) if (dev->pm_domain) return 0; =20 - err =3D devm_pm_opp_attach_genpd(dev, opp_genpd_names, &opp_virt_devs); - if (err) + err =3D devm_pm_domain_attach_list(dev, &pd_data, &gr3d->pd_list); + if (err < 0) return err; =20 - for (i =3D 0; opp_genpd_names[i]; i++) { - pd_dev =3D opp_virt_devs[i]; - if (!pd_dev) { - dev_err(dev, "failed to get %s power domain\n", - opp_genpd_names[i]); - return -EINVAL; - } - - link =3D device_link_add(dev, pd_dev, link_flags); - if (!link) { - dev_err(dev, "failed to link to %s\n", dev_name(pd_dev)); - return -EINVAL; - } - - err =3D devm_add_action_or_reset(dev, gr3d_del_link, link); - if (err) - return err; - } - return 0; } =20 --=20 2.34.1 From nobody Tue Dec 16 12:42:44 2025 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 832CE1D31BE for ; Thu, 22 Aug 2024 22:46:17 +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=1724366779; cv=none; b=QE1pyCnrqeL8xpYGrcM0q0K3MuginKDJYZm2ovAvvaYdPK0eYCTslh8SMhIu9N/dojMuuOShzzKXh38jFlZp3Zd1OV3b7ipJQeqPKtGEbP9ljMrIjyIS1GFiQlbszkrnOS84GiKToN2uXbrm2eTTJXh9uam3tY7s/TcJkGj0juY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366779; c=relaxed/simple; bh=Ovr+J/J43NIgh+z5G4Zg3sqsrt0ah7LcS47W5xpCqBs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YWnaCJ1/Ko1oe+3VGJgua7NYq2EWxYae7WLoT+gYZ9sCT6r8mUvF9zAFY3GyEfrlciiZK/fxD4/IOjtC/HbBB4RM4c+Rr+bi4EV/gqvRwrYSq2Pu2/CGRnCS4RPvIEoGhuec8nRbQhZeOqj6rHWToUoqiL5gzmW+WnSN+rxcz7k= 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=fk5nOHwa; 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="fk5nOHwa" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-53438aa64a4so60800e87.3 for ; Thu, 22 Aug 2024 15:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366775; x=1724971575; 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=X1A26YlhfePaP3jDbaTwUiFXKbFKwoAq1rqRtisM7j8=; b=fk5nOHwa9nMMFrtfZs6iHo2/IEDoWXppuaW04I9eEO5OcfThpPQe3BeOa+aIky8gAD zUWEyIWBgn5t0ddLruaprxqZdjtTtcL3sl5KVs/O5VTHNDdbPec7UyruCkRyc6Ayi+gP zcLcrWHu58hs41+aoyfE7Rr10szAXGOnXZppxEoVGhLnAymMmaFzkcFFRBLAyv1mM5/n hfUwr2Kr2F5p7JYFq0jeMGtteFtgkRCMxS1k2Yh6Z2YGTJQyMYCcYCfwS/fwdZ/pCzdk RiBCEJ+y54w4mzDGhtGIp/zo0vWk+c1pAsowwRlFtuxaOEBOymguqKS+HeXIiNYWyy3U xxew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366775; x=1724971575; 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=X1A26YlhfePaP3jDbaTwUiFXKbFKwoAq1rqRtisM7j8=; b=f59+9D/7DpDoHpDVlIBOiX0sIpFeGxzT3BnXq+g7CvKBYodQS9at8RYZLc0iqbT1ue qSBK4oKevzC6KKd8mOeINE8CIty+92/9Zx5CE3744s0fDBByyXGuXZZtm6O6rX8v+3GQ O43qKx2w0EDWJ0+kUM4ez0CekTvkuHVkTgpDvzUPOss1BG06QpQqMGaMhWvJ3EgbP5KX IwYfOBuDT05BBvhzubB+MB2bkTqMVB7NEZo9v1a/poG5/CXXdOvIihOT5rs0spRBydpp FCTfQIMEzt6Zs3wPyVH3HA4rqGCOHrMDEydt4LOmOKozAYEJwl2svqRPsDglL8NqQITg 1HUg== X-Forwarded-Encrypted: i=1; AJvYcCV+kfynPtlm9qkVaYo2cjBFmthyvpYEJfngwzm8KFMHPpzB9ukxfCp+58I8b9JxBlHBFgF/jiF3RK7PIns=@vger.kernel.org X-Gm-Message-State: AOJu0YxGh7OFCPL6tYOIXHI50YyNj4mMmPZQXHPZQ7XQ2OvMTkI/XFOs NupfOgR817PG9qjmfYuZSol11rK3m1y1U+J7PaBe9w6NXgOwHtos7JV/raeYOp4= X-Google-Smtp-Source: AGHT+IEYCvO6PxDZuiKr7Z/6TAjnmPIaE1HH1Y16/UregoH9/xLXNer5kgVUUiDFaWpCN/2/MSiCtA== X-Received: by 2002:a05:6512:1282:b0:533:4785:82a2 with SMTP id 2adb3069b0e04-53438869dccmr141908e87.59.1724366775519; Thu, 22 Aug 2024 15:46:15 -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-5334ea362a4sm379443e87.66.2024.08.22.15.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:15 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 08/10] media: venus: Convert into devm_pm_domain_attach_list() for OPP PM domain Date: Fri, 23 Aug 2024 00:45:45 +0200 Message-Id: <20240822224547.385095-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than hooking up the PM domain through devm_pm_opp_attach_genpd() and manage the device-link, let's avoid the boilerplate-code by converting into devm_pm_domain_attach_list(). Acked-by: Stanimir Varbanov Signed-off-by: Ulf Hansson Acked-by: Viresh Kumar --- Changes in v3: - Updated commitmsg and added Stanimir's ack. - Converted to devm mangaged version of dev_pm_domain_attach_list() --- drivers/media/platform/qcom/venus/core.c | 8 ++-- drivers/media/platform/qcom/venus/core.h | 6 +-- .../media/platform/qcom/venus/pm_helpers.c | 44 +++++-------------- 3 files changed, 15 insertions(+), 43 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platf= orm/qcom/venus/core.c index 165c947a6703..4666278671e2 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -751,7 +751,7 @@ static const struct venus_resources sdm845_res_v2 =3D { .vcodec_clks_num =3D 2, .vcodec_pmdomains =3D (const char *[]) { "venus", "vcodec0", "vcodec1" }, .vcodec_pmdomains_num =3D 3, - .opp_pmdomain =3D (const char *[]) { "cx", NULL }, + .opp_pmdomain =3D (const char *[]) { "cx" }, .vcodec_num =3D 2, .max_load =3D 3110400, /* 4096x2160@90 */ .hfi_version =3D HFI_VERSION_4XX, @@ -800,7 +800,7 @@ static const struct venus_resources sc7180_res =3D { .vcodec_clks_num =3D 2, .vcodec_pmdomains =3D (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num =3D 2, - .opp_pmdomain =3D (const char *[]) { "cx", NULL }, + .opp_pmdomain =3D (const char *[]) { "cx" }, .vcodec_num =3D 1, .hfi_version =3D HFI_VERSION_4XX, .vpu_version =3D VPU_VERSION_AR50, @@ -857,7 +857,7 @@ static const struct venus_resources sm8250_res =3D { .vcodec_clks_num =3D 1, .vcodec_pmdomains =3D (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num =3D 2, - .opp_pmdomain =3D (const char *[]) { "mx", NULL }, + .opp_pmdomain =3D (const char *[]) { "mx" }, .vcodec_num =3D 1, .max_load =3D 7833600, .hfi_version =3D HFI_VERSION_6XX, @@ -916,7 +916,7 @@ static const struct venus_resources sc7280_res =3D { .vcodec_clks_num =3D 2, .vcodec_pmdomains =3D (const char *[]) { "venus", "vcodec0" }, .vcodec_pmdomains_num =3D 2, - .opp_pmdomain =3D (const char *[]) { "cx", NULL }, + .opp_pmdomain =3D (const char *[]) { "cx" }, .vcodec_num =3D 1, .hfi_version =3D HFI_VERSION_6XX, .vpu_version =3D VPU_VERSION_IRIS2_1, diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platf= orm/qcom/venus/core.h index 55202b89e1b9..435325432922 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -132,9 +132,7 @@ struct venus_format { * @vcodec1_clks: an array of vcodec1 struct clk pointers * @video_path: an interconnect handle to video to/from memory path * @cpucfg_path: an interconnect handle to cpu configuration path - * @has_opp_table: does OPP table exist * @pmdomains: a pointer to a list of pmdomains - * @opp_dl_venus: an device-link for device OPP * @opp_pmdomain: an OPP power-domain * @resets: an array of reset signals * @vdev_dec: a reference to video device structure for decoder instances @@ -186,10 +184,8 @@ struct venus_core { struct clk *vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX]; struct icc_path *video_path; struct icc_path *cpucfg_path; - bool has_opp_table; struct dev_pm_domain_list *pmdomains; - struct device_link *opp_dl_venus; - struct device *opp_pmdomain; + struct dev_pm_domain_list *opp_pmdomain; struct reset_control *resets[VIDC_RESETS_NUM_MAX]; struct video_device *vdev_dec; struct video_device *vdev_enc; diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media= /platform/qcom/venus/pm_helpers.c index ea8a2bd9419e..355dfa586f8e 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -864,7 +864,6 @@ static int venc_power_v4(struct device *dev, int on) static int vcodec_domains_get(struct venus_core *core) { int ret; - struct device **opp_virt_dev; struct device *dev =3D core->dev; const struct venus_resources *res =3D core->res; struct dev_pm_domain_attach_data vcodec_data =3D { @@ -872,6 +871,11 @@ static int vcodec_domains_get(struct venus_core *core) .num_pd_names =3D res->vcodec_pmdomains_num, .pd_flags =3D PD_FLAG_NO_DEV_LINK, }; + struct dev_pm_domain_attach_data opp_pd_data =3D { + .pd_names =3D res->opp_pmdomain, + .num_pd_names =3D 1, + .pd_flags =3D PD_FLAG_DEV_LINK_ON, + }; =20 if (!res->vcodec_pmdomains_num) goto skip_pmdomains; @@ -881,37 +885,15 @@ static int vcodec_domains_get(struct venus_core *core) return ret; =20 skip_pmdomains: - if (!core->res->opp_pmdomain) + if (!res->opp_pmdomain) return 0; =20 /* Attach the power domain for setting performance state */ - ret =3D devm_pm_opp_attach_genpd(dev, res->opp_pmdomain, &opp_virt_dev); - if (ret) - goto opp_attach_err; - - core->opp_pmdomain =3D *opp_virt_dev; - core->opp_dl_venus =3D device_link_add(dev, core->opp_pmdomain, - DL_FLAG_RPM_ACTIVE | - DL_FLAG_PM_RUNTIME | - DL_FLAG_STATELESS); - if (!core->opp_dl_venus) { - ret =3D -ENODEV; - goto opp_attach_err; - } + ret =3D devm_pm_domain_attach_list(dev, &opp_pd_data, &core->opp_pmdomain= ); + if (ret < 0) + return ret; =20 return 0; - -opp_attach_err: - return ret; -} - -static void vcodec_domains_put(struct venus_core *core) -{ - if (!core->has_opp_table) - return; - - if (core->opp_dl_venus) - device_link_del(core->opp_dl_venus); } =20 static int core_resets_reset(struct venus_core *core) @@ -1000,9 +982,7 @@ static int core_get_v4(struct venus_core *core) =20 if (core->res->opp_pmdomain) { ret =3D devm_pm_opp_of_add_table(dev); - if (!ret) { - core->has_opp_table =3D true; - } else if (ret !=3D -ENODEV) { + if (ret && ret !=3D -ENODEV) { dev_err(dev, "invalid OPP table in device tree\n"); return ret; } @@ -1013,10 +993,6 @@ static int core_get_v4(struct venus_core *core) =20 static void core_put_v4(struct venus_core *core) { - if (legacy_binding) - return; - - vcodec_domains_put(core); } =20 static int core_power_v4(struct venus_core *core, int on) --=20 2.34.1 From nobody Tue Dec 16 12:42:44 2025 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 DE3561D3643 for ; Thu, 22 Aug 2024 22:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366780; cv=none; b=IAlcXvq5NN6qr9QxBXYMxMCFwX46Z+ODWk9jHIi1bjD4g2tNx4eguJ27YWdFnD1G1U1AJ3rHw6sdzVQPbGdh94mOrc2bgppdHj5jMLFJr61mVZs08DRRERW1iAqcBmz0gxgrcm1EKecmm7mMJAd8BSr18NbCfWSrXgAOYQPLA3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366780; c=relaxed/simple; bh=fzv2Qhm8qkbuiNawozPPsMhWU0ubmi4ni4I/TKeUmdc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YBK+osurjkqnAU/IFLRAczaVl2bb26L12M5q+wZ/r0Lua0K34vRDRCLx2FF0YPPonUG5w/dPCtZRHzlhHk7gzjGwURtbQw9ROr8+C+xIgZOfL4/fLhWcNKdfCjVKvsn3yKL9RYctKssA7SpjMbYZ0HeDWyntKiaC524Wx5clg90= 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=h4tVCANt; arc=none smtp.client-ip=209.85.167.53 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="h4tVCANt" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-53349ee42a9so1662881e87.3 for ; Thu, 22 Aug 2024 15:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366777; x=1724971577; 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=iksFSJ//26ReVaxAnVHvTDyArAC4NnchBY2BZAJDBow=; b=h4tVCANtLg/Hai7zD3IRKcelktZ8/qw4aWtj6JFt6o0Uu+wuK/g4mO9M82r8KzfeSN Tsnnf6sNMlrRVGvWbrXsHceLbucnQmJAyckQSoWYDAoipRSWqyMsLtU1GOyIzz2LX7pe PM1qe3oL1nuGzckGy2HLizataa7AHiZ4qTjGP6sxEJ4N58xuqkWFo/OPmfM7GTkvF56d oM7EGprVswx/WIZJvHzJo3sgCpbRh+5cgyoaQOmFn/ejN4MvjKGhsT0KY5irnO2IpxHw uxZJf+DztaHY3BKECZ75Bxa7jk9F3sp2wfA2i3INKMvjxC2EpsMlqXl5YkJmemCDGjKk PVRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366777; x=1724971577; 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=iksFSJ//26ReVaxAnVHvTDyArAC4NnchBY2BZAJDBow=; b=M/fLsNKo7JSfj3qZwfFJUmPKigwYR/WBO21dRtJ51CCIyq73LZrOTpLol0oBh6I64B ECHuZr5WXUCiWvylbF89pfKBStm36+F7T1VJaFJWTMMucz/XhVm6MgSss9lcYR7ASnY0 irjEN+t4z+hb6n31lssufBwMXRifb4km5pro8V0mkp+3+b27oRbzedVFcibcOZxd3QQ0 lUmAIXm4Zqhp6kX+zdJHTtpA/6E6LgT4vTR+06r+EwYFjXX148DwOeH+hspRgkO6iFC6 7SQ867M+7SOt2yRAw1nqlGjn3YiZSg+JFFs55TONj8tJHn8QAeBYNOsY16gzzf7o95N2 jbWQ== X-Forwarded-Encrypted: i=1; AJvYcCU+WSzBww0ieOPWrkHgZCOGbtyS8fJ0OeK7lNZAxKcSzSjfEOe58p4gtIpYq5gDWMDr5ray1LmOJcB45qE=@vger.kernel.org X-Gm-Message-State: AOJu0YyEoavJycvfYLNlO4nvdiZengv4wiZyOhKzGi9g9UTIQC7Le9ZK Gr/6R1W/phDisHRTpe/uzJleBMGT6m2wMaf1civcfCTPID/e8a4Hf96ehkKsp3U= X-Google-Smtp-Source: AGHT+IFqYnnUrUddlV2VzJzkFcuvSxGz0XMOiVMuzx0Kw0HD/D4q6JeKW5PZ8PIU3LGdvGhnAFZwtQ== X-Received: by 2002:a05:6512:15a2:b0:530:ba4b:f65d with SMTP id 2adb3069b0e04-534387852e1mr179442e87.28.1724366776756; Thu, 22 Aug 2024 15:46: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-5334ea362a4sm379443e87.66.2024.08.22.15.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:16 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/10] cpufreq: qcom-nvmem: Convert to dev_pm_domain_attach|detach_list() Date: Fri, 23 Aug 2024 00:45:46 +0200 Message-Id: <20240822224547.385095-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than hooking up the PM domains through _opp_attach_genpd() and manually manage runtime PM for the corresponding virtual devices created by genpd during attach, let's avoid the boilerplate-code by converting into dev_pm_domain_attach|detach_list. Signed-off-by: Ulf Hansson Acked-by: Viresh Kumar --- Changes in v3: - None. --- drivers/cpufreq/qcom-cpufreq-nvmem.c | 79 +++++++++------------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cp= ufreq-nvmem.c index 939702dfa73f..6ba8c8378384 100644 --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c @@ -52,12 +52,13 @@ struct qcom_cpufreq_match_data { struct nvmem_cell *speedbin_nvmem, char **pvs_name, struct qcom_cpufreq_drv *drv); - const char **genpd_names; + const char **pd_names; + unsigned int num_pd_names; }; =20 struct qcom_cpufreq_drv_cpu { int opp_token; - struct device **virt_devs; + struct dev_pm_domain_list *pd_list; }; =20 struct qcom_cpufreq_drv { @@ -395,8 +396,6 @@ static int qcom_cpufreq_ipq8074_name_version(struct dev= ice *cpu_dev, return 0; } =20 -static const char *generic_genpd_names[] =3D { "perf", NULL }; - static const struct qcom_cpufreq_match_data match_data_kryo =3D { .get_version =3D qcom_cpufreq_kryo_name_version, }; @@ -407,13 +406,13 @@ static const struct qcom_cpufreq_match_data match_dat= a_krait =3D { =20 static const struct qcom_cpufreq_match_data match_data_msm8909 =3D { .get_version =3D qcom_cpufreq_simple_get_version, - .genpd_names =3D generic_genpd_names, + .pd_names =3D (const char *[]) { "perf" }, + .num_pd_names =3D 1, }; =20 -static const char *qcs404_genpd_names[] =3D { "cpr", NULL }; - static const struct qcom_cpufreq_match_data match_data_qcs404 =3D { - .genpd_names =3D qcs404_genpd_names, + .pd_names =3D (const char *[]) { "cpr" }, + .num_pd_names =3D 1, }; =20 static const struct qcom_cpufreq_match_data match_data_ipq6018 =3D { @@ -428,28 +427,16 @@ static const struct qcom_cpufreq_match_data match_dat= a_ipq8074 =3D { .get_version =3D qcom_cpufreq_ipq8074_name_version, }; =20 -static void qcom_cpufreq_suspend_virt_devs(struct qcom_cpufreq_drv *drv, u= nsigned int cpu) +static void qcom_cpufreq_suspend_pd_devs(struct qcom_cpufreq_drv *drv, uns= igned int cpu) { - const char * const *name =3D drv->data->genpd_names; + struct dev_pm_domain_list *pd_list =3D drv->cpus[cpu].pd_list; int i; =20 - if (!drv->cpus[cpu].virt_devs) + if (!pd_list) return; =20 - for (i =3D 0; *name; i++, name++) - device_set_awake_path(drv->cpus[cpu].virt_devs[i]); -} - -static void qcom_cpufreq_put_virt_devs(struct qcom_cpufreq_drv *drv, unsig= ned int cpu) -{ - const char * const *name =3D drv->data->genpd_names; - int i; - - if (!drv->cpus[cpu].virt_devs) - return; - - for (i =3D 0; *name; i++, name++) - pm_runtime_put(drv->cpus[cpu].virt_devs[i]); + for (i =3D 0; i < pd_list->num_pds; i++) + device_set_awake_path(pd_list->pd_devs[i]); } =20 static int qcom_cpufreq_probe(struct platform_device *pdev) @@ -503,7 +490,6 @@ static int qcom_cpufreq_probe(struct platform_device *p= dev) } =20 for_each_possible_cpu(cpu) { - struct device **virt_devs =3D NULL; struct dev_pm_opp_config config =3D { .supported_hw =3D NULL, }; @@ -522,12 +508,7 @@ static int qcom_cpufreq_probe(struct platform_device *= pdev) config.prop_name =3D pvs_name; } =20 - if (drv->data->genpd_names) { - config.genpd_names =3D drv->data->genpd_names; - config.virt_devs =3D &virt_devs; - } - - if (config.supported_hw || config.genpd_names) { + if (config.supported_hw) { drv->cpus[cpu].opp_token =3D dev_pm_opp_set_config(cpu_dev, &config); if (drv->cpus[cpu].opp_token < 0) { ret =3D drv->cpus[cpu].opp_token; @@ -536,25 +517,17 @@ static int qcom_cpufreq_probe(struct platform_device = *pdev) } } =20 - if (virt_devs) { - const char * const *name =3D config.genpd_names; - int i, j; - - for (i =3D 0; *name; i++, name++) { - ret =3D pm_runtime_resume_and_get(virt_devs[i]); - if (ret) { - dev_err(cpu_dev, "failed to resume %s: %d\n", - *name, ret); + if (drv->data->pd_names) { + struct dev_pm_domain_attach_data attach_data =3D { + .pd_names =3D drv->data->pd_names, + .num_pd_names =3D drv->data->num_pd_names, + .pd_flags =3D PD_FLAG_DEV_LINK_ON, + }; =20 - /* Rollback previous PM runtime calls */ - name =3D config.genpd_names; - for (j =3D 0; *name && j < i; j++, name++) - pm_runtime_put(virt_devs[j]); - - goto free_opp; - } - } - drv->cpus[cpu].virt_devs =3D virt_devs; + ret =3D dev_pm_domain_attach_list(cpu_dev, &attach_data, + &drv->cpus[cpu].pd_list); + if (ret < 0) + goto free_opp; } } =20 @@ -570,7 +543,7 @@ static int qcom_cpufreq_probe(struct platform_device *p= dev) =20 free_opp: for_each_possible_cpu(cpu) { - qcom_cpufreq_put_virt_devs(drv, cpu); + dev_pm_domain_detach_list(drv->cpus[cpu].pd_list); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); } return ret; @@ -584,7 +557,7 @@ static void qcom_cpufreq_remove(struct platform_device = *pdev) platform_device_unregister(cpufreq_dt_pdev); =20 for_each_possible_cpu(cpu) { - qcom_cpufreq_put_virt_devs(drv, cpu); + dev_pm_domain_detach_list(drv->cpus[cpu].pd_list); dev_pm_opp_clear_config(drv->cpus[cpu].opp_token); } } @@ -595,7 +568,7 @@ static int qcom_cpufreq_suspend(struct device *dev) unsigned int cpu; =20 for_each_possible_cpu(cpu) - qcom_cpufreq_suspend_virt_devs(drv, cpu); + qcom_cpufreq_suspend_pd_devs(drv, cpu); =20 return 0; } --=20 2.34.1 From nobody Tue Dec 16 12:42:44 2025 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 0876C1D4142 for ; Thu, 22 Aug 2024 22:46:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366781; cv=none; b=WA2ymTB+xIJ/niq6BH7HBWP8rwCqkfuclXHPhT0zgdZtO9Kvwr2QIX1G60rFLo0TiZXor93kaIFqcoQgmMQSqptRNSOakdvP/tHa+6+IJVesrjMkpyUH0imjAyLlqvcmi214Ah/gOAM2XuSSD6mbrWFAqaa+gXpjq6Nf9p7xNJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724366781; c=relaxed/simple; bh=B+QYo/05J+LjG9pa7GZRM+j5LasnoK0b6yQeAZz29bc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GU03Q+wEgwZl0vvzT0A/LKYq++V0pxztFcLyB0VdHlAFHs81bK4mKmI+13jdBBv6QbmArroavMK7CtcR7mOEPD+9UAz56/NtutGuX6EbzI5Bol5RehKyqDbK7bez1OaoS21yybF8IM3Wfv/knkpVLJWMvpFrqcLzruxM72mPrwY= 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=b9Y8KOdX; arc=none smtp.client-ip=209.85.167.43 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="b9Y8KOdX" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5334879ba28so1672087e87.3 for ; Thu, 22 Aug 2024 15:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724366778; x=1724971578; 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=VphURB1Gan/55uptQu3RfCpWor8wG0jCnNbpjQVr+aE=; b=b9Y8KOdXYy2tEkdyjH9tI726n/QiCiErvdulB+h9r6tYpFzkWrGEm5JvLYEL95snBH tpmbdy4zvRZbswbjoFvBCRUVgTY5wRidF6050EHmVNzLWZlDIpZnNIn3tSwpGMSKzUKj 0tWuAKQo7LJo3tlCz70VOdrTyo8fw+rNmZbDl/KWQSfGIkqq4MKT0VPah4g3ysxu2Rml S9x6VRR6/jh/vU4fptgo5LDTAiSwslYwvUsR7+MBkL/iZHf/FA1mGoS6u27LhkpH2dTg MEUY/OvUEdBDkfGeT7Fe9RtZMMwdTy+dX4Vxtf+AG+4PG9Q8jWQ1+nbyvzjRawlaG4yI 2ivw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724366778; x=1724971578; 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=VphURB1Gan/55uptQu3RfCpWor8wG0jCnNbpjQVr+aE=; b=gVDd2BU54JUQrjJc29T+KnfjR9kO4oWzPdUTfrl7Xsb0LCUKb8YUdHCwbSCnFQyfsP m3vKd1uhGhZdtEyGvSqsUjSq3vJ5xKmZ+4SEJABwezJ6zSmm1jM2ELaNfua2MzNGwIUL Q/7lOv069n3LfcUpnbJAM6LQ6mAClVunBBX6i7Cv12jAofpI8FVMvSDdmxD07U8ujnYY fL20zXVCcwM2pt/Uf2dNjNsaYH/enfRNKWMDA3R9Pt8nXFpKbS51Irfoenxc0p0BJZPN M3KH5mAMH+c4CK3CsPXpX7+AH4m1Ms0ICBxKuEC7DBSAAhkCHgBmwtgLqFwA/0oJUAEd ilPw== X-Forwarded-Encrypted: i=1; AJvYcCWornw3Y24UZ+M5TqMgv7Z7q0hdAzn8WWspjTjvvCDWftgFrs+pwgbRksk4vzsA5w2h1+xN4CzAisYk+GU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5dt5NPFDwRbsk6Ot0p89eYvgfGFCAF+DcHlXkzr4V/UJ98Y2n 6OTeMyHH0Xm16Mnu8o7CSncArFrDojhKndjovoNE78NWwYaNESG7O2lllutkijU= X-Google-Smtp-Source: AGHT+IFXpNYl8qtj2IvlPSDp3CA4+6RBm9vf/UbMJ3jZi+owQVOFOxqR3Yik2fhh9EMH6VdRLWKJ4g== X-Received: by 2002:a05:6512:31c4:b0:52e:f950:31f3 with SMTP id 2adb3069b0e04-53438785441mr234491e87.35.1724366778108; Thu, 22 Aug 2024 15:46:18 -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-5334ea362a4sm379443e87.66.2024.08.22.15.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 15:46:17 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/10] OPP: Drop redundant _opp_attach|detach_genpd() Date: Fri, 23 Aug 2024 00:45:47 +0200 Message-Id: <20240822224547.385095-11-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822224547.385095-1-ulf.hansson@linaro.org> References: <20240822224547.385095-1-ulf.hansson@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All users of _opp_attach|detach_genpd(), have been converted to use dev|devm_pm_domain_attach|detach_list(), hence let's drop it along with its corresponding exported functions. Signed-off-by: Ulf Hansson Acked-by: Viresh Kumar --- Changes in v3: - None. --- drivers/opp/core.c | 96 +----------------------------------------- drivers/opp/opp.h | 3 +- include/linux/pm_opp.h | 38 +---------------- 3 files changed, 3 insertions(+), 134 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index cad7e84c9ad3..66cac7a1d9db 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2360,86 +2360,6 @@ static void _opp_put_config_regulators_helper(struct= opp_table *opp_table) opp_table->config_regulators =3D NULL; } =20 -static void _opp_detach_genpd(struct opp_table *opp_table) -{ - int index; - - for (index =3D 0; index < opp_table->required_opp_count; index++) { - if (!opp_table->required_devs[index]) - continue; - - dev_pm_domain_detach(opp_table->required_devs[index], false); - } -} - -/* - * Multiple generic power domains for a device are supported with the help= of - * virtual genpd devices, which are created for each consumer device - gen= pd - * pair. These are the device structures which are attached to the power d= omain - * and are required by the OPP core to set the performance state of the ge= npd. - * The same API also works for the case where single genpd is available an= d so - * we don't need to support that separately. - * - * This helper will normally be called by the consumer driver of the device - * "dev", as only that has details of the genpd names. - * - * This helper needs to be called once with a list of all genpd to attach. - * Otherwise the original device structure will be used instead by the OPP= core. - * - * The order of entries in the names array must match the order in which - * "required-opps" are added in DT. - */ -static int _opp_attach_genpd(struct opp_table *opp_table, struct device *d= ev, - const char * const *names, struct device ***virt_devs) -{ - struct device *virt_dev; - int index =3D 0, ret =3D -EINVAL; - const char * const *name =3D names; - - if (!opp_table->required_devs) { - dev_err(dev, "Required OPPs not available, can't attach genpd\n"); - return -EINVAL; - } - - /* 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; - } - - /* Checking only the first one is enough ? */ - if (opp_table->required_devs[0]) - return 0; - - while (*name) { - if (index >=3D opp_table->required_opp_count) { - dev_err(dev, "Index can't be greater than required-opp-count - 1, %s (%= d : %d)\n", - *name, opp_table->required_opp_count, index); - goto err; - } - - virt_dev =3D dev_pm_domain_attach_by_name(dev, *name); - if (IS_ERR_OR_NULL(virt_dev)) { - ret =3D virt_dev ? PTR_ERR(virt_dev) : -ENODEV; - dev_err(dev, "Couldn't attach to pm_domain: %d\n", ret); - goto err; - } - - index++; - name++; - } - - if (virt_devs) - *virt_devs =3D opp_table->required_devs; - - return 0; - -err: - _opp_detach_genpd(opp_table); - return ret; - -} - static int _opp_set_required_dev(struct opp_table *opp_table, struct device *dev, struct device *required_dev, @@ -2516,9 +2436,6 @@ static void _opp_clear_config(struct opp_config_data = *data) { 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); - if (data->flags & OPP_CONFIG_REGULATOR) _opp_put_regulators(data->opp_table); if (data->flags & OPP_CONFIG_SUPPORTED_HW) @@ -2630,18 +2547,7 @@ int dev_pm_opp_set_config(struct device *dev, struct= dev_pm_opp_config *config) data->flags |=3D OPP_CONFIG_REGULATOR; } =20 - /* Attach genpds */ - if (config->genpd_names) { - if (config->required_dev) - goto err; - - ret =3D _opp_attach_genpd(opp_table, dev, config->genpd_names, - config->virt_devs); - if (ret) - goto err; - - data->flags |=3D OPP_CONFIG_GENPD; - } else if (config->required_dev && config->required_opp_table) { + if (config->required_dev && config->required_opp_table) { ret =3D _opp_set_required_dev(opp_table, dev, config->required_dev, config->required_opp_table); diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 5b5a4bd89c9e..318a4ecbabf1 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -34,8 +34,7 @@ extern struct list_head opp_tables; #define OPP_CONFIG_REGULATOR_HELPER BIT(2) #define OPP_CONFIG_PROP_NAME BIT(3) #define OPP_CONFIG_SUPPORTED_HW BIT(4) -#define OPP_CONFIG_GENPD BIT(5) -#define OPP_CONFIG_REQUIRED_DEV BIT(6) +#define OPP_CONFIG_REQUIRED_DEV BIT(5) =20 /** * struct opp_config_data - data for set config operations diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 5fade5c4de40..451a7465a605 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -62,11 +62,7 @@ typedef int (*config_clks_t)(struct device *dev, struct = opp_table *opp_table, * @supported_hw: Array of hierarchy of versions to match. * @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 gen= pd to - * attach. Mutually exclusive with required_dev. - * @virt_devs: Pointer to return the array of genpd virtual devices. Mutua= lly - * exclusive with required_dev. - * @required_dev: Required OPP device. Mutually exclusive with genpd_names= /virt_devs. + * @required_dev: Required OPP device. * @required_opp_table: The corresponding required OPP table for @required= _dev. * * This structure contains platform specific OPP configurations for the de= vice. @@ -80,8 +76,6 @@ struct dev_pm_opp_config { const unsigned int *supported_hw; unsigned int supported_hw_count; const char * const *regulator_names; - const char * const *genpd_names; - struct device ***virt_devs; struct device *required_dev; struct opp_table *required_opp_table; }; @@ -677,36 +671,6 @@ static inline void dev_pm_opp_put_config_regulators(in= t token) dev_pm_opp_clear_config(token); } =20 -/* genpd helpers */ -static inline int dev_pm_opp_attach_genpd(struct device *dev, - const char * const *names, - struct device ***virt_devs) -{ - struct dev_pm_opp_config config =3D { - .genpd_names =3D names, - .virt_devs =3D virt_devs, - }; - - return dev_pm_opp_set_config(dev, &config); -} - -static inline void dev_pm_opp_detach_genpd(int token) -{ - dev_pm_opp_clear_config(token); -} - -static inline int devm_pm_opp_attach_genpd(struct device *dev, - const char * const *names, - struct device ***virt_devs) -{ - struct dev_pm_opp_config config =3D { - .genpd_names =3D names, - .virt_devs =3D virt_devs, - }; - - return devm_pm_opp_set_config(dev, &config); -} - /* prop-name helpers */ static inline int dev_pm_opp_set_prop_name(struct device *dev, const char = *name) { --=20 2.34.1