Re: [PATCH v5 1/5] powerpc/85xx: implement hardware timebase sync

From: Li Yang
Date: Tue May 29 2012 - 03:30:47 EST


Hi Scott,

Thanks for the valuable comment raised before and we have updated the
patches accordingly. Please review the updated patch set and ACK if
they are good to you. We hope it can be applied in this window.

Leo

On Fri, May 11, 2012 at 7:53 PM, Zhao Chenhui
<chenhui.zhao@xxxxxxxxxxxxx> wrote:
> Do hardware timebase sync. Firstly, stop all timebases, and transfer
> the timebase value of the boot core to the other core. Finally,
> start all timebases.
>
> Only apply to dual-core chips, such as MPC8572, P2020, etc.
>
> Signed-off-by: Zhao Chenhui <chenhui.zhao@xxxxxxxxxxxxx>
> Signed-off-by: Li Yang <leoli@xxxxxxxxxxxxx>
> ---
> Âarch/powerpc/include/asm/fsl_guts.h | Â Â2 +
> Âarch/powerpc/platforms/85xx/smp.c  |  93 +++++++++++++++++++++++++++++++++--
> Â2 files changed, 91 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/fsl_guts.h b/arch/powerpc/include/asm/fsl_guts.h
> index aa4c488..dd5ba2c 100644
> --- a/arch/powerpc/include/asm/fsl_guts.h
> +++ b/arch/powerpc/include/asm/fsl_guts.h
> @@ -48,6 +48,8 @@ struct ccsr_guts {
> Â Â Â Â __be32 Âdmuxcr; Â Â Â Â Â Â Â Â/* 0x.0068 - DMA Mux Control Register */
> Â Â Â Â u8 Â Â res06c[0x70 - 0x6c];
> Â Â Â Â__be32 Âdevdisr; Â Â Â Â/* 0x.0070 - Device Disable Control */
> +#define CCSR_GUTS_DEVDISR_TB1 Â0x00001000
> +#define CCSR_GUTS_DEVDISR_TB0 Â0x00004000
> Â Â Â Â__be32 Âdevdisr2; Â Â Â /* 0x.0074 - Device Disable Control 2 */
> Â Â Â Âu8 Â Â Âres078[0x7c - 0x78];
> Â Â Â Â__be32 Âpmjcr; Â Â Â Â Â/* 0x.007c - 4 Power Management Jog Control Register */
> diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
> index ff42490..6862dda 100644
> --- a/arch/powerpc/platforms/85xx/smp.c
> +++ b/arch/powerpc/platforms/85xx/smp.c
> @@ -24,6 +24,7 @@
> Â#include <asm/mpic.h>
> Â#include <asm/cacheflush.h>
> Â#include <asm/dbell.h>
> +#include <asm/fsl_guts.h>
>
> Â#include <sysdev/fsl_soc.h>
> Â#include <sysdev/mpic.h>
> @@ -115,13 +116,70 @@ smp_85xx_kick_cpu(int nr)
>
> Âstruct smp_ops_t smp_85xx_ops = {
> Â Â Â Â.kick_cpu = smp_85xx_kick_cpu,
> -#ifdef CONFIG_KEXEC
> - Â Â Â .give_timebase Â= smp_generic_give_timebase,
> - Â Â Â .take_timebase Â= smp_generic_take_timebase,
> -#endif
> Â};
>
> Â#ifdef CONFIG_KEXEC
> +static struct ccsr_guts __iomem *guts;
> +static u64 timebase;
> +static int tb_req;
> +static int tb_valid;
> +
> +static void mpc85xx_timebase_freeze(int freeze)
> +{
> + Â Â Â unsigned int mask;
> +
> + Â Â Â if (!guts)
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â mask = CCSR_GUTS_DEVDISR_TB0 | CCSR_GUTS_DEVDISR_TB1;
> + Â Â Â if (freeze)
> + Â Â Â Â Â Â Â setbits32(&guts->devdisr, mask);
> + Â Â Â else
> + Â Â Â Â Â Â Â clrbits32(&guts->devdisr, mask);
> +
> + Â Â Â in_be32(&guts->devdisr);
> +}
> +
> +static void mpc85xx_give_timebase(void)
> +{
> + Â Â Â unsigned long flags;
> +
> + Â Â Â local_irq_save(flags);
> +
> + Â Â Â while (!tb_req)
> + Â Â Â Â Â Â Â barrier();
> + Â Â Â tb_req = 0;
> +
> + Â Â Â mpc85xx_timebase_freeze(1);
> + Â Â Â timebase = get_tb();
> + Â Â Â mb();
> + Â Â Â tb_valid = 1;
> +
> + Â Â Â while (tb_valid)
> + Â Â Â Â Â Â Â barrier();
> +
> + Â Â Â mpc85xx_timebase_freeze(0);
> +
> + Â Â Â local_irq_restore(flags);
> +}
> +
> +static void mpc85xx_take_timebase(void)
> +{
> + Â Â Â unsigned long flags;
> +
> + Â Â Â local_irq_save(flags);
> +
> + Â Â Â tb_req = 1;
> + Â Â Â while (!tb_valid)
> + Â Â Â Â Â Â Â barrier();
> +
> + Â Â Â set_tb(timebase >> 32, timebase & 0xffffffff);
> + Â Â Â mb();
> + Â Â Â tb_valid = 0;
> +
> + Â Â Â local_irq_restore(flags);
> +}
> +
> Âatomic_t kexec_down_cpus = ATOMIC_INIT(0);
>
> Âvoid mpc85xx_smp_kexec_cpu_down(int crash_shutdown, int secondary)
> @@ -228,6 +286,20 @@ smp_85xx_setup_cpu(int cpu_nr)
> Â Â Â Â Â Â Â Âdoorbell_setup_this_cpu();
> Â}
>
> +#ifdef CONFIG_KEXEC
> +static const struct of_device_id guts_ids[] = {
> + Â Â Â { .compatible = "fsl,mpc8572-guts", },
> + Â Â Â { .compatible = "fsl,mpc8560-guts", },
> + Â Â Â { .compatible = "fsl,mpc8536-guts", },
> + Â Â Â { .compatible = "fsl,p1020-guts", },
> + Â Â Â { .compatible = "fsl,p1021-guts", },
> + Â Â Â { .compatible = "fsl,p1022-guts", },
> + Â Â Â { .compatible = "fsl,p1023-guts", },
> + Â Â Â { .compatible = "fsl,p2020-guts", },
> + Â Â Â {},
> +};
> +#endif
> +
> Âvoid __init mpc85xx_smp_init(void)
> Â{
> Â Â Â Âstruct device_node *np;
> @@ -249,6 +321,19 @@ void __init mpc85xx_smp_init(void)
> Â Â Â Â Â Â Â Âsmp_85xx_ops.cause_ipi = doorbell_cause_ipi;
> Â Â Â Â}
>
> +#ifdef CONFIG_KEXEC
> + Â Â Â np = of_find_matching_node(NULL, guts_ids);
> + Â Â Â if (np) {
> + Â Â Â Â Â Â Â guts = of_iomap(np, 0);
> + Â Â Â Â Â Â Â smp_85xx_ops.give_timebase = mpc85xx_give_timebase;
> + Â Â Â Â Â Â Â smp_85xx_ops.take_timebase = mpc85xx_take_timebase;
> + Â Â Â Â Â Â Â of_node_put(np);
> + Â Â Â } else {
> + Â Â Â Â Â Â Â smp_85xx_ops.give_timebase = smp_generic_give_timebase;
> + Â Â Â Â Â Â Â smp_85xx_ops.take_timebase = smp_generic_take_timebase;
> + Â Â Â }
> +#endif
> +
> Â Â Â Âsmp_ops = &smp_85xx_ops;
>
> Â#ifdef CONFIG_KEXEC
> --
> 1.6.4.1
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/



--
- Leo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/