All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andreas Kemnade" <andreas@kemnade.info>
Cc: imx@lists.linux.dev, devicetree@vger.kernel.org, robh@kernel.org,
	conor+dt@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH RFC 1/3] ARM: imx: enable STOP-ON mode in idle if wakeup requirements permit
Date: Mon, 23 Nov 2026 20:49:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-230024@kernel.org> (raw)
In-Reply-To: <20261123-imx6-idlestop-v1-1-e32f1f44e46f@kemnade.info>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] ARM: imx: i.MX6SLL-only STOP ON idle state registered on all
  i.MX6SX/UL SoCs
- [Medium] ARM: imx: imx6sll_check_pll_are_used() omits DCP DMA clock in
  CCGR0 check
- [Low] ARM: imx: duplicate BIT(21) term in CCGR5 mask in
  imx6sll_check_pll_are_used()
- [Low] ARM: imx: imx6sx_enter_pll_off() duplicates state 2 power-off
  sequence
--

commit faf6510335563388f22705edc72db8052152fc32
Author: Andreas Kemnade <andreas@kemnade.info>

ARM: imx: enable STOP-ON mode in idle if wakeup requirements permit

This commit adds a fourth cpuidle state ("STOP ON") to imx6sx_cpuidle_driver
that enters STOP_POWER_ON mode on i.MX6SLL when CCGR0..CCGR6 indicate that
PLLs are not in use.

> diff --git a/arch/arm/mach-imx/cpuidle-imx6sx.c b/arch/arm/mach-imx/cpuidle-imx6sx.c
> index 83c5cbd3748e1..4537cb7b3a637 100644
> --- a/arch/arm/mach-imx/cpuidle-imx6sx.c
> +++ b/arch/arm/mach-imx/cpuidle-imx6sx.c
> @@ -65,6 +65,36 @@ static __cpuidle int imx6sx_enter_wait(struct cpuidle_device *dev,
>  	return index;
>  }
>  
> +static __cpuidle int imx6sx_enter_pll_off(struct cpuidle_device *dev,
> +				       struct cpuidle_driver *drv, int index)
> +{
> +	if (!cpu_is_imx6sll() || imx6sll_check_pll_are_used())
> +		return imx6sx_enter_wait(dev, drv, 2);
> +
> +	imx6_set_lpm(STOP_POWER_ON);
> +	imx6_enable_rbc(true);
> +	imx_gpc_set_arm_power_in_lpm(true);
> +	imx_set_cpu_jump(0, v7_cpu_resume);
> +	imx6_set_int_mem_clk_lpm(true);
> +	/* Need to notify there is a cpu pm operation. */
> +	cpu_pm_enter();
> +	cpu_cluster_pm_enter();
> +
> +	ct_cpuidle_enter();
> +
> +	cpu_suspend(0, imx6sx_idle_finish);
> +
> +	ct_cpuidle_exit();
> +
> +	cpu_cluster_pm_exit();
> +	cpu_pm_exit();
> +	imx6_enable_rbc(false);
> +	imx_gpc_set_arm_power_in_lpm(false);
> +
> +	imx6_set_lpm(WAIT_CLOCKED);
> +	return index;
> +}

[Severity: Low]
This isn't a bug, but imx6sx_enter_pll_off() duplicates the state 2
power-off sequence from imx6sx_enter_wait(), differing only in passing
STOP_POWER_ON instead of WAIT_UNCLOCKED to imx6_set_lpm().  Calling
imx6_set_int_mem_clk_lpm(true) on every entry is also redundant, since
imx6sx_cpuidle_init() sets it at init and imx6q_pm_enter() restores it on
resume from suspend.

> @@ -95,8 +125,18 @@ static struct cpuidle_driver imx6sx_cpuidle_driver = {
>  			.name = "LOW-POWER-IDLE",
>  			.desc = "ARM power off",
>  		},
> +		/* STOP ON */
> +		{
> +			.exit_latency = 500,
> +			.target_residency = 800,
> +			.flags = CPUIDLE_FLAG_TIMER_STOP |
> +				 CPUIDLE_FLAG_RCU_IDLE,
> +			.enter = imx6sx_enter_pll_off,
> +			.name = "STOP ON",
> +			.desc = "ARM power off + PLL off",
> +		},
>  	},
> -	.state_count = 3,
> +	.state_count = 4,
>  	.safe_state_index = 0,
>  };

[Severity: Medium]
Should state 3 only be exposed on i.MX6SLL, and should falling back to
state 2 respect dev->states_usage[2].disable?

imx6sx_cpuidle_init() registers imx6sx_cpuidle_driver on i.MX6SX, i.MX6UL,
i.MX6ULL and i.MX6ULZ as well as i.MX6SLL.  Unconditionally setting
state_count = 4 advertises an enabled state 3 on those other SoCs that
always demotes to state 2, causing cpuidle_enter_state() to record false
state 2 "below" misses whenever actual idle time reaches 800 us and
skewing governor residency bins.  In addition, calling
imx6sx_enter_wait(dev, drv, 2) directly bypasses sysfs if state 2 has been
disabled by userspace.

> diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
> index 3c73e2cdb8ceb..65a5268d31614 100644
> --- a/arch/arm/mach-imx/pm-imx6.c
> +++ b/arch/arm/mach-imx/pm-imx6.c
[ ... ]
> @@ -287,6 +295,21 @@ void imx6_enable_rbc(bool enable)
>  	imx_gpc_restore_all();
>  }
>  
> +bool imx6sll_check_pll_are_used(void)
> +{
> +	/* check for any clock active which provides more than register access */
> +	return readl_relaxed(ccm_base + CCGR0) & BIT(29)  ||

[Severity: Medium]
Does the CCGR0 mask also need BIT(11) for IMX6SLL_CLK_DCP?

In drivers/clk/imx/clk-imx6sll.c, IMX6SLL_CLK_DCP ("dcp", parented to
"ahb") is gated by CCGR0 bits 11:10.  When mxs_dcp_start_dma() starts a
crypto DMA transfer and sleeps in wait_for_completion_timeout(), the
single CPU on i.MX6SLL can enter cpuidle; without BIT(11) in the CCGR0
check, entering STOP_POWER_ON stops AHB and PLL clocks mid-transfer and
stalls DCP DMA until it times out.

> +		readl_relaxed(ccm_base + CCGR1) & (BIT(25) | BIT(23) | BIT(15) | BIT(13) |
> +						   BIT(11) | BIT(7) | BIT(5) | BIT(3) | BIT(1)) ||
> +		readl_relaxed(ccm_base + CCGR2) & (BIT(31) | BIT(29) | BIT(11) | BIT(9) |
> +						   BIT(7) | BIT(3)) ||
> +		readl_relaxed(ccm_base + CCGR3) & (BIT(11) | BIT(5) | BIT(3)) ||
> +		readl_relaxed(ccm_base + CCGR4) & (BIT(23) | BIT(21) | BIT(19) | BIT(17)) ||
> +		readl_relaxed(ccm_base + CCGR5) & (BIT(25) | BIT(23) | BIT(21) | BIT(21) |
> +						   BIT(19) | BIT(15) | BIT(7)) ||

[Severity: Low]
BIT(21) is listed twice in the CCGR5 mask; is one of them redundant or
meant to be another bit?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-imx6-idlestop-v1-0-e32f1f44e46f@kemnade.info?part=1

  reply	other threads:[~2026-11-23 20:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 20:31 [PATCH RFC 0/3] ARM: imx: Add a more agressive idle mode on i.MX6SLL Andreas Kemnade
2026-11-23 20:31 ` [PATCH RFC 1/3] ARM: imx: enable STOP-ON mode in idle if wakeup requirements permit Andreas Kemnade
2026-11-23 20:49   ` sashiko-bot [this message]
2026-11-24 10:28     ` Andreas Kemnade
2026-11-23 20:31 ` [PATCH 2/3] timer-imx-gpt: Allow 32K clock to be used as a clock source Andreas Kemnade
2026-11-23 20:45   ` sashiko-bot
2026-11-23 20:31 ` [PATCH 3/3] ARM: dts: imx: kobo-clarahd: Use 32K clock for the timer Andreas Kemnade
2026-11-23 20:59   ` sashiko-bot
2026-11-23 21:26     ` Andreas Kemnade

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=sashiko-outbox-230024@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=andreas@kemnade.info \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.