mbox series

[v2,0/2] powerpc:85xx: fix timebase sync issue when CONFIG_HOTPLUG_CPU=n

Message ID 20210929033646.39630-1-nixiaoming@huawei.com (mailing list archive)
Headers show
Series powerpc:85xx: fix timebase sync issue when CONFIG_HOTPLUG_CPU=n | expand

Message

Xiaoming Ni Sept. 29, 2021, 3:36 a.m. UTC
When CONFIG_SMP=y, timebase synchronization is required for mpc8572 when
 the second kernel is started
	arch/powerpc/kernel/smp.c:
	int __cpu_up(unsigned int cpu, struct task_struct *tidle)
	{
		...
		if (smp_ops->give_timebase)
			smp_ops->give_timebase();
		...
	}

	void start_secondary(void *unused)
	{
		...
		if (smp_ops->take_timebase)
			smp_ops->take_timebase();
		...
	}

When CONFIG_HOTPLUG_CPU=n and CONFIG_KEXEC_CORE=n,
 smp_85xx_ops.give_timebase is NULL,
 smp_85xx_ops.take_timebase is NULL,
As a result, the timebase is not synchronized.

test code:
	for i in $(seq 1 3); do taskset 1 date; taskset 2 date; sleep 1; echo;done
log:
	Sat Sep 25 18:50:00 CST 2021
	Sat Sep 25 19:07:47 CST 2021

	Sat Sep 25 18:50:01 CST 2021
	Sat Sep 25 19:07:48 CST 2021

	Sat Sep 25 18:50:02 CST 2021
	Sat Sep 25 19:07:49 CST 2021

Code snippet about give_timebase and take_timebase assignments:
	arch/powerpc/platforms/85xx/smp.c:
	#ifdef CONFIG_HOTPLUG_CPU
	#ifdef CONFIG_FSL_CORENET_RCPM
		fsl_rcpm_init();
	#endif
	#ifdef CONFIG_FSL_PMC
		mpc85xx_setup_pmc();
	#endif
		if (qoriq_pm_ops) {
			smp_85xx_ops.give_timebase = mpc85xx_give_timebase;
			smp_85xx_ops.take_timebase = mpc85xx_take_timebase;

config dependency:
	FSL_CORENET_RCPM depends on the PPC_E500MC.
	FSL_PMC depends on SUSPEND.
	SUSPEND depends on ARCH_SUSPEND_POSSIBLE.
	ARCH_SUSPEND_POSSIBLE depends on !PPC_E500MC.

CONFIG_HOTPLUG_CPU and CONFIG_FSL_PMC require the timebase function, but
the timebase should not depend on CONFIG_HOTPLUG_CPU and CONFIG_FSL_PMC.
Therefore, adjust the macro control range. Ensure that the corresponding
 timebase hook function is not empty when the dtsi node is configured.

-----
changes in v2:
 1. add new patch: "powerpc:85xx:Fix oops when mpc85xx_smp_guts_ids node
  cannot be found"
 2. Using !CONFIG_FSL_CORENET_RCPM to manage the timebase code of !PPC_E500MC

v1:
 https://lore.kernel.org/lkml/20210926025144.55674-1-nixiaoming@huawei.com
------

Xiaoming Ni (2):
  powerpc:85xx:Fix oops when mpc85xx_smp_guts_ids node cannot be found
  powerpc:85xx: fix timebase sync issue when CONFIG_HOTPLUG_CPU=n

 arch/powerpc/platforms/85xx/Makefile         |  4 +++-
 arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c |  7 +++++--
 arch/powerpc/platforms/85xx/smp.c            | 12 ++++++------
 3 files changed, 14 insertions(+), 9 deletions(-)

Comments

Michael Ellerman Oct. 11, 2021, 12:06 p.m. UTC | #1
On Wed, 29 Sep 2021 11:36:44 +0800, Xiaoming Ni wrote:
> When CONFIG_SMP=y, timebase synchronization is required for mpc8572 when
>  the second kernel is started
> 	arch/powerpc/kernel/smp.c:
> 	int __cpu_up(unsigned int cpu, struct task_struct *tidle)
> 	{
> 		...
> 		if (smp_ops->give_timebase)
> 			smp_ops->give_timebase();
> 		...
> 	}
> 
> [...]

Applied to powerpc/next.

[1/2] powerpc:85xx:Fix oops when mpc85xx_smp_guts_ids node cannot be found
      https://git.kernel.org/powerpc/c/3c2172c1c47b4079c29f0e6637d764a99355ebcd
[2/2] powerpc:85xx: fix timebase sync issue when CONFIG_HOTPLUG_CPU=n
      https://git.kernel.org/powerpc/c/c45361abb9185b1e172bd75eff51ad5f601ccae4

cheers