The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Chen-Yu Tsai <wenst@chromium.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Mark Brown <broonie@kernel.org>
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org,
	Douglas Anderson <dianders@chromium.org>,
	Johan Hovold <johan@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Pablo Sun <pablo.sun@mediatek.com>,
	Macpaul Lin <macpaul.lin@mediatek.com>,
	Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: Re: [PATCH v8 3/3] pmdomain: mediatek: Use OF-specific regulator API to get power domain supply
Date: Thu, 26 Sep 2024 10:48:56 +0200	[thread overview]
Message-ID: <e3eabcc4-1174-4a58-a084-d37467f63ced@collabora.com> (raw)
In-Reply-To: <20240925093807.1026949-4-wenst@chromium.org>

Il 25/09/24 11:38, Chen-Yu Tsai ha scritto:
> The MediaTek power domain driver contains a hack that assigns the device
> node of the power domain to the struct device of the power domain
> controller in order to use the devres regulator API.
> 
> Now that there is a proper OF-specific regulator API, and even a devres
> version, replace the hack with proper code.
> 
> This change is incompatible with incomplete device trees. Instead of
> assigning the dummy regulator in cases where the power domain requires
> a supply but the device tree does not provide one, the driver will just
> error out. This will be seen on the MT8390 EVK, which is missing
> supplies for the IMG_VCORE and CAM_VCORE domains. And likely all the
> MediaTek EVBs, which have no power domain supplies specified. This is
> however the correct behavior. If the power domain's supply is missing,
> then it should not work. Relying on other parts of the system to keep
> the unattached regulator enabled is likely to break in ways less easier
> to understand.
> 

Breaking something that was "working" (not really working though) before is a
hard thing to justify, but I feel like this is one of the cases in which we
have to swallow the pill.

This is a hack that I've always been angry about, and causing all sorts of
random issues on MediaTek SoCs from time to time... that was fixed multiple
times by hacking the previous hack which was needed for this hack to still
work in a way or another.

I am tempted to give you a R-b right now, but let me carefully test this on
multiple devices before that.

Meanwhile, I just wanted to say that I agree with you about this commit and
wanted to give a bit more context to people reading "this breaks things" so
that they can understand what's going on (and that we're not crazy! ..or at
least, not *that* much :-P).

Cheers,
Angelo

> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> ---
> Changes since v7:
> - New patch
> 
> The other option is to follow what Rockchip will be doing: getting the
> regulator supply upon first use / enable [1]. This will result in less
> breakage: only the power domain that is missing its supplies will fail
> to be attached.
> 
> [1] https://lore.kernel.org/all/20240919091834.83572-6-sebastian.reichel@collabora.com/
> ---
>   drivers/pmdomain/mediatek/mtk-pm-domains.c | 12 +-----------
>   1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.c b/drivers/pmdomain/mediatek/mtk-pm-domains.c
> index 88406e9ac63c..3580913f25d3 100644
> --- a/drivers/pmdomain/mediatek/mtk-pm-domains.c
> +++ b/drivers/pmdomain/mediatek/mtk-pm-domains.c
> @@ -353,7 +353,6 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys *scpsys, struct device_no
>   {
>   	const struct scpsys_domain_data *domain_data;
>   	struct scpsys_domain *pd;
> -	struct device_node *root_node = scpsys->dev->of_node;
>   	struct device_node *smi_node;
>   	struct property *prop;
>   	const char *clk_name;
> @@ -388,16 +387,7 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys *scpsys, struct device_no
>   	pd->scpsys = scpsys;
>   
>   	if (MTK_SCPD_CAPS(pd, MTK_SCPD_DOMAIN_SUPPLY)) {
> -		/*
> -		 * Find regulator in current power domain node.
> -		 * devm_regulator_get() finds regulator in a node and its child
> -		 * node, so set of_node to current power domain node then change
> -		 * back to original node after regulator is found for current
> -		 * power domain node.
> -		 */
> -		scpsys->dev->of_node = node;
> -		pd->supply = devm_regulator_get(scpsys->dev, "domain");
> -		scpsys->dev->of_node = root_node;
> +		pd->supply = devm_of_regulator_get_optional(scpsys->dev, node, "domain");
>   		if (IS_ERR(pd->supply))
>   			return dev_err_cast_probe(scpsys->dev, pd->supply,
>   				      "%pOF: failed to get power supply.\n",




  reply	other threads:[~2024-09-26  8:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25  9:38 [PATCH v8 0/3] Add of_regulator_get_optional() and Fix MTK Power Domain Driver Chen-Yu Tsai
2024-09-25  9:38 ` [PATCH v8 1/3] regulator: Add of_regulator_get_optional() for pure DT regulator lookup Chen-Yu Tsai
2024-09-25 10:53   ` Andy Shevchenko
2024-09-25  9:38 ` [PATCH v8 2/3] regulator: Add devres version of of_regulator_get_optional() Chen-Yu Tsai
2024-09-25 10:56   ` Andy Shevchenko
2024-09-26  8:43     ` Chen-Yu Tsai
2024-09-26 12:26       ` Andy Shevchenko
2024-09-27  4:38         ` Chen-Yu Tsai
2024-09-27  9:48           ` Andy Shevchenko
2024-09-25  9:38 ` [PATCH v8 3/3] pmdomain: mediatek: Use OF-specific regulator API to get power domain supply Chen-Yu Tsai
2024-09-26  8:48   ` AngeloGioacchino Del Regno [this message]
2024-09-26 15:49 ` [PATCH v8 0/3] Add of_regulator_get_optional() and Fix MTK Power Domain Driver Ulf Hansson
2024-09-27  4:00   ` Chen-Yu Tsai
2024-09-30 22:29 ` (subset) " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3eabcc4-1174-4a58-a084-d37467f63ced@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=johan@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=macpaul.lin@mediatek.com \
    --cc=matthias.bgg@gmail.com \
    --cc=pablo.sun@mediatek.com \
    --cc=sebastian.reichel@collabora.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wenst@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox