public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: "André Draszik" <andre.draszik@linaro.org>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	"Rob Herring" <robh@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Ulf Hansson" <ulf.hansson@linaro.org>
Cc: Peter Griffin <peter.griffin@linaro.org>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Will McVicker <willmcvicker@google.com>,
	kernel-team@android.com, linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH v3 06/10] pmdomain: samsung: convert to regmap_read_poll_timeout()
Date: Tue, 21 Oct 2025 22:38:01 +0200	[thread overview]
Message-ID: <2e38e6c2-0548-432f-ae34-daf3972877ac@samsung.com> (raw)
In-Reply-To: <20251016-gs101-pd-v3-6-7b30797396e7@linaro.org>

On 16.10.2025 17:58, André Draszik wrote:
> Replace the open-coded PD status polling with
> regmap_read_poll_timeout(). This change simplifies the code without
> altering functionality.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>   drivers/pmdomain/samsung/exynos-pm-domains.c | 29 ++++++++--------------------
>   1 file changed, 8 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/pmdomain/samsung/exynos-pm-domains.c b/drivers/pmdomain/samsung/exynos-pm-domains.c
> index 383126245811cb8e4dbae3b99ced3f06d3093f35..431548ad9a7e40c0a77ac6672081b600c90ddd4e 100644
> --- a/drivers/pmdomain/samsung/exynos-pm-domains.c
> +++ b/drivers/pmdomain/samsung/exynos-pm-domains.c
> @@ -13,7 +13,6 @@
>   #include <linux/platform_device.h>
>   #include <linux/slab.h>
>   #include <linux/pm_domain.h>
> -#include <linux/delay.h>
>   #include <linux/of.h>
>   #include <linux/pm_runtime.h>
>   #include <linux/regmap.h>
> @@ -35,7 +34,8 @@ struct exynos_pm_domain {
>   static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
>   {
>   	struct exynos_pm_domain *pd;
> -	u32 timeout, pwr;
> +	unsigned int val;
> +	u32 pwr;
>   	int err;
>   
>   	pd = container_of(domain, struct exynos_pm_domain, pd);
> @@ -45,25 +45,12 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
>   	if (err)
>   		return err;
>   
> -	/* Wait max 1ms */
> -	timeout = 10;
> -	while (timeout-- > 0) {
> -		unsigned int val;
> -
> -		err = regmap_read(pd->regmap, 0x4, &val);
> -		if (err || ((val & pd->local_pwr_cfg) != pwr)) {
> -			cpu_relax();
> -			usleep_range(80, 100);
> -			continue;
> -		}
> -
> -		return 0;
> -	}
> -
> -	if (!err)
> -		err = -ETIMEDOUT;
> -	pr_err("Power domain %s %sable failed: %d\n", domain->name,
> -	       power_on ? "en" : "dis", err);
> +	err = regmap_read_poll_timeout(pd->regmap, 0x4, val,
> +				       (val & pd->local_pwr_cfg) == pwr,
> +				       100, 1 * USEC_PER_MSEC);
> +	if (err)
> +		pr_err("Power domain %s %sable failed: %d (%#.2x)\n",
> +		       domain->name, power_on ? "en" : "dis", err, val);

I've posted my 'tested-by' tag for this patchset, but in meantime I 
found that this patch causes regression from time to time on old Exynos 
SoCs (especially when all debugs are disabled). It looks that there are 
some subtle differences between reading the status register up to 10 
times with cpu_relax()+usleep_range() and the 
regmap_read_poll_timeout(). I will try to analyze this a bit more and 
provide details, but I suspect that the old loop might take a bit longer 
than the 1ms from the comment above this code.


>   	return err;
>   }
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland



  reply	other threads:[~2025-10-21 20:38 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20251016155848eucas1p193debe70e38b1694bfb250d748f4aa14@eucas1p1.samsung.com>
2025-10-16 15:58 ` [PATCH v3 00/10] pmdomain: samsung: add supoort for Google GS101 André Draszik
2025-10-16 15:58   ` [PATCH v3 01/10] dt-bindings: power: samsung: add google,gs101-pd André Draszik
2025-10-22  6:31     ` Krzysztof Kozlowski
2025-10-16 15:58   ` [PATCH v3 02/10] dt-bindings: soc: samsung: exynos-pmu: move gs101-pmu into separate binding André Draszik
2025-10-22  6:34     ` Krzysztof Kozlowski
2025-10-22  6:36       ` Krzysztof Kozlowski
2025-10-16 15:58   ` [PATCH v3 03/10] dt-bindings: soc: samsung: gs101-pmu: allow power domains as children André Draszik
2025-10-21 12:59     ` Ulf Hansson
2025-10-21 16:18       ` Krzysztof Kozlowski
2025-10-22 10:03         ` Ulf Hansson
2025-10-22  6:39     ` Krzysztof Kozlowski
2025-10-16 15:58   ` [PATCH v3 04/10] pmdomain: samsung: plug potential memleak during probe André Draszik
2025-10-21 13:54     ` Ulf Hansson
2025-10-16 15:58   ` [PATCH v3 05/10] pmdomain: samsung: convert to using regmap André Draszik
2025-10-16 15:58   ` [PATCH v3 06/10] pmdomain: samsung: convert to regmap_read_poll_timeout() André Draszik
2025-10-21 20:38     ` Marek Szyprowski [this message]
2025-10-22 13:45       ` Marek Szyprowski
2025-10-16 15:58   ` [PATCH v3 07/10] pmdomain: samsung: don't hardcode offset for registers to 0 and 4 André Draszik
2025-10-16 15:58   ` [PATCH v3 08/10] pmdomain: samsung: selectively handle enforced sync_state André Draszik
2025-10-22 11:06     ` Ulf Hansson
2025-10-22 18:39       ` Marek Szyprowski
2025-10-23 10:02         ` Ulf Hansson
2025-10-23 12:17           ` Marek Szyprowski
2025-10-23 13:46             ` Ulf Hansson
2025-10-16 15:58   ` [PATCH v3 09/10] pmdomain: samsung: add support for google,gs101-pd André Draszik
2025-10-16 15:58   ` [PATCH v3 10/10] pmdomain: samsung: use dev_err() instead of pr_err() André Draszik
2025-10-17  6:43   ` [PATCH v3 00/10] pmdomain: samsung: add supoort for Google GS101 Marek Szyprowski

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=2e38e6c2-0548-432f-ae34-daf3972877ac@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=alim.akhtar@samsung.com \
    --cc=andre.draszik@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel-team@android.com \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=robh@kernel.org \
    --cc=tudor.ambarus@linaro.org \
    --cc=ulf.hansson@linaro.org \
    --cc=willmcvicker@google.com \
    /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