diff mbox series

pmdomain: renesas: rcar-gen4-sysc: Reduce atomic delays

Message ID 77f150522096d55c6da0ff983db61e0cf6309344.1709317289.git.geert+renesas@glider.be
State Accepted
Commit ccabbb6768fc72d6cb0223324925c93658d91e63
Headers show
Series pmdomain: renesas: rcar-gen4-sysc: Reduce atomic delays | expand

Commit Message

Geert Uytterhoeven March 1, 2024, 6:23 p.m. UTC
The delays used with the various atomic polling loops are already at the
maximum value of ~10µs, as documented for read_poll_timeout_atomic().
Hence reduce the delays from 10 to 1 µs.  Increase PDRESR_RETRIES
accordingly, to retain the old (generous) timeout value.

Measurements on R-Car V3U, S4, V4H, and V4M show that the first three
polling loops rarely (never?) loop, so the actual delay does not matter.
The fourth loop (for SYSCISCR in rcar_gen4_sysc_power()) typically ran
for one or two cycles with the old delay.  With the reduced delay, it
typically runs for two to 17 cycles, and finishes earlier than before,
which can reduce loop time up to a factor of three.

While at it, rename the SYSCISR_{TIMEOUT,DELAY_US} definitions to
SYSCISCR_{TIMEOUT,DELAY_US}, to match the register name they apply to.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/pmdomain/renesas/rcar-gen4-sysc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Ulf Hansson March 6, 2024, 10:26 a.m. UTC | #1
On Fri, 1 Mar 2024 at 19:23, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>
> The delays used with the various atomic polling loops are already at the
> maximum value of ~10µs, as documented for read_poll_timeout_atomic().
> Hence reduce the delays from 10 to 1 µs.  Increase PDRESR_RETRIES
> accordingly, to retain the old (generous) timeout value.
>
> Measurements on R-Car V3U, S4, V4H, and V4M show that the first three
> polling loops rarely (never?) loop, so the actual delay does not matter.
> The fourth loop (for SYSCISCR in rcar_gen4_sysc_power()) typically ran
> for one or two cycles with the old delay.  With the reduced delay, it
> typically runs for two to 17 cycles, and finishes earlier than before,
> which can reduce loop time up to a factor of three.
>
> While at it, rename the SYSCISR_{TIMEOUT,DELAY_US} definitions to
> SYSCISCR_{TIMEOUT,DELAY_US}, to match the register name they apply to.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied for next, thanks!

Kind regards
Uffe

> ---
>  drivers/pmdomain/renesas/rcar-gen4-sysc.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/pmdomain/renesas/rcar-gen4-sysc.c b/drivers/pmdomain/renesas/rcar-gen4-sysc.c
> index 728248659a97e8cc..66409cff2083fcd8 100644
> --- a/drivers/pmdomain/renesas/rcar-gen4-sysc.c
> +++ b/drivers/pmdomain/renesas/rcar-gen4-sysc.c
> @@ -50,13 +50,13 @@
>  #define SYSCSR_BUSY            GENMASK(1, 0)   /* All bit sets is not busy */
>
>  #define SYSCSR_TIMEOUT         10000
> -#define SYSCSR_DELAY_US                10
> +#define SYSCSR_DELAY_US                1
>
> -#define PDRESR_RETRIES         1000
> -#define PDRESR_DELAY_US                10
> +#define PDRESR_RETRIES         10000
> +#define PDRESR_DELAY_US                1
>
> -#define SYSCISR_TIMEOUT                10000
> -#define SYSCISR_DELAY_US       10
> +#define SYSCISCR_TIMEOUT       10000
> +#define SYSCISCR_DELAY_US      1
>
>  #define RCAR_GEN4_PD_ALWAYS_ON 64
>  #define NUM_DOMAINS_EACH_REG   BITS_PER_TYPE(u32)
> @@ -97,7 +97,7 @@ static int clear_irq_flags(unsigned int reg_idx, unsigned int isr_mask)
>
>         ret = readl_poll_timeout_atomic(rcar_gen4_sysc_base + SYSCISCR(reg_idx),
>                                         val, !(val & isr_mask),
> -                                       SYSCISR_DELAY_US, SYSCISR_TIMEOUT);
> +                                       SYSCISCR_DELAY_US, SYSCISCR_TIMEOUT);
>         if (ret < 0) {
>                 pr_err("\n %s : Can not clear IRQ flags in SYSCISCR", __func__);
>                 return -EIO;
> @@ -157,7 +157,7 @@ static int rcar_gen4_sysc_power(u8 pdr, bool on)
>         /* Wait until the power shutoff or resume request has completed * */
>         ret = readl_poll_timeout_atomic(rcar_gen4_sysc_base + SYSCISCR(reg_idx),
>                                         val, (val & isr_mask),
> -                                       SYSCISR_DELAY_US, SYSCISR_TIMEOUT);
> +                                       SYSCISCR_DELAY_US, SYSCISCR_TIMEOUT);
>         if (ret < 0) {
>                 ret = -EIO;
>                 goto out;
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/pmdomain/renesas/rcar-gen4-sysc.c b/drivers/pmdomain/renesas/rcar-gen4-sysc.c
index 728248659a97e8cc..66409cff2083fcd8 100644
--- a/drivers/pmdomain/renesas/rcar-gen4-sysc.c
+++ b/drivers/pmdomain/renesas/rcar-gen4-sysc.c
@@ -50,13 +50,13 @@ 
 #define SYSCSR_BUSY		GENMASK(1, 0)	/* All bit sets is not busy */
 
 #define SYSCSR_TIMEOUT		10000
-#define SYSCSR_DELAY_US		10
+#define SYSCSR_DELAY_US		1
 
-#define PDRESR_RETRIES		1000
-#define PDRESR_DELAY_US		10
+#define PDRESR_RETRIES		10000
+#define PDRESR_DELAY_US		1
 
-#define SYSCISR_TIMEOUT		10000
-#define SYSCISR_DELAY_US	10
+#define SYSCISCR_TIMEOUT	10000
+#define SYSCISCR_DELAY_US	1
 
 #define RCAR_GEN4_PD_ALWAYS_ON	64
 #define NUM_DOMAINS_EACH_REG	BITS_PER_TYPE(u32)
@@ -97,7 +97,7 @@  static int clear_irq_flags(unsigned int reg_idx, unsigned int isr_mask)
 
 	ret = readl_poll_timeout_atomic(rcar_gen4_sysc_base + SYSCISCR(reg_idx),
 					val, !(val & isr_mask),
-					SYSCISR_DELAY_US, SYSCISR_TIMEOUT);
+					SYSCISCR_DELAY_US, SYSCISCR_TIMEOUT);
 	if (ret < 0) {
 		pr_err("\n %s : Can not clear IRQ flags in SYSCISCR", __func__);
 		return -EIO;
@@ -157,7 +157,7 @@  static int rcar_gen4_sysc_power(u8 pdr, bool on)
 	/* Wait until the power shutoff or resume request has completed * */
 	ret = readl_poll_timeout_atomic(rcar_gen4_sysc_base + SYSCISCR(reg_idx),
 					val, (val & isr_mask),
-					SYSCISR_DELAY_US, SYSCISR_TIMEOUT);
+					SYSCISCR_DELAY_US, SYSCISCR_TIMEOUT);
 	if (ret < 0) {
 		ret = -EIO;
 		goto out;