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-nixiaom...@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(-)

-- 
2.27.0

Reply via email to