Skip to content

Commit

Permalink
powerpc/85xx: fix timebase sync issue when CONFIG_HOTPLUG_CPU=n
Browse files Browse the repository at this point in the history
When CONFIG_SMP=y, timebase synchronization is required 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.

Timebase  synchronization does not depend on CONFIG_HOTPLUG_CPU.

Fixes: 56f1ba2 ("powerpc/mpc85xx: refactor the PM operations")
Cc: [email protected] # v4.6+
Signed-off-by: Xiaoming Ni <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
nixiaoming authored and mpe committed Oct 8, 2021
1 parent 3c2172c commit c45361a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion arch/powerpc/platforms/85xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# Makefile for the PowerPC 85xx linux kernel.
#
obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_FSL_PMC) += mpc85xx_pm_ops.o
ifneq ($(CONFIG_FSL_CORENET_RCPM),y)
obj-$(CONFIG_SMP) += mpc85xx_pm_ops.o
endif

obj-y += common.o

Expand Down
4 changes: 4 additions & 0 deletions arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

static struct ccsr_guts __iomem *guts;

#ifdef CONFIG_FSL_PMC
static void mpc85xx_irq_mask(int cpu)
{

Expand Down Expand Up @@ -49,6 +50,7 @@ static void mpc85xx_cpu_up_prepare(int cpu)
{

}
#endif

static void mpc85xx_freeze_time_base(bool freeze)
{
Expand Down Expand Up @@ -76,10 +78,12 @@ static const struct of_device_id mpc85xx_smp_guts_ids[] = {

static const struct fsl_pm_ops mpc85xx_pm_ops = {
.freeze_time_base = mpc85xx_freeze_time_base,
#ifdef CONFIG_FSL_PMC
.irq_mask = mpc85xx_irq_mask,
.irq_unmask = mpc85xx_irq_unmask,
.cpu_die = mpc85xx_cpu_die,
.cpu_up_prepare = mpc85xx_cpu_up_prepare,
#endif
};

int __init mpc85xx_setup_pmc(void)
Expand Down
12 changes: 6 additions & 6 deletions arch/powerpc/platforms/85xx/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ struct epapr_spin_table {
u32 pir;
};

#ifdef CONFIG_HOTPLUG_CPU
static u64 timebase;
static int tb_req;
static int tb_valid;
Expand Down Expand Up @@ -112,6 +111,7 @@ static void mpc85xx_take_timebase(void)
local_irq_restore(flags);
}

#ifdef CONFIG_HOTPLUG_CPU
static void smp_85xx_cpu_offline_self(void)
{
unsigned int cpu = smp_processor_id();
Expand Down Expand Up @@ -495,21 +495,21 @@ void __init mpc85xx_smp_init(void)
smp_85xx_ops.probe = NULL;
}

#ifdef CONFIG_HOTPLUG_CPU
#ifdef CONFIG_FSL_CORENET_RCPM
/* Assign a value to qoriq_pm_ops on PPC_E500MC */
fsl_rcpm_init();
#endif

#ifdef CONFIG_FSL_PMC
#else
/* Assign a value to qoriq_pm_ops on !PPC_E500MC */
mpc85xx_setup_pmc();
#endif
if (qoriq_pm_ops) {
smp_85xx_ops.give_timebase = mpc85xx_give_timebase;
smp_85xx_ops.take_timebase = mpc85xx_take_timebase;
#ifdef CONFIG_HOTPLUG_CPU
smp_85xx_ops.cpu_offline_self = smp_85xx_cpu_offline_self;
smp_85xx_ops.cpu_die = qoriq_cpu_kill;
}
#endif
}
smp_ops = &smp_85xx_ops;

#ifdef CONFIG_KEXEC_CORE
Expand Down

0 comments on commit c45361a

Please sign in to comment.