powerpc/kexec: make masking/disabling interrupts generic
Subsystems (2)
PATCH 1/4 powerpc/kexec: make masking/disabling interrupts generic
Right now just the kexec crash pathway turns turns off the interrupts. Pull that out and make a generic version for use elsewhere
--- arch/powerpc/include/asm/kexec.h | 1 + arch/powerpc/kernel/crash.c | 13 +------------ arch/powerpc/kernel/machine_kexec.c | 24 ++++++++++++++++++++++++ arch/powerpc/kernel/machine_kexec_32.c | 4 ++++ 4 files changed, 30 insertions(+), 12 deletions(-)
arch/powerpc/include/asm/kexec.h +1 -0
@@ -91,6 +91,7 @@ extern void machine_kexec_simple(struct kimage *image);extern void crash_kexec_secondary (struct pt_regs *regs);extern int overlaps_crashkernel (unsigned long start,unsigned long size);extern void reserve_crashkernel (void ); +extern void machine_kexec_mask_interrupts (void );#else /* !CONFIG_KEXEC */ static inline int kexec_sr_activated (int cpu) {return 0 ; }
arch/powerpc/kernel/crash.c +1 -12
@@ -414,18 +414,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)crash_kexec_wait_realmode (crashing_cpu);#endif -for_each_irq (i) { -struct irq_desc *desc =irq_to_desc (i); - -if (!desc || !desc->chip || !desc->chip->eoi) -continue ; - -if (desc->status &IRQ_INPROGRESS ) - desc->chip->eoi (i); - -if (!(desc->status &IRQ_DISABLED )) - desc->chip->shutdown (i); - } +machine_kexec_mask_interrupts ();/* * Call registered shutdown routines savely. Swap out
arch/powerpc/kernel/machine_kexec.c +24 -0
@@ -14,10 +14,34 @@#include <linux/threads.h> #include <linux/memblock.h> #include <linux/of.h> +#include <linux/irq.h> +#include <asm/machdep.h> #include <asm/prom.h> #include <asm/sections.h> +void machine_kexec_mask_interrupts (void ) { +unsigned int i; + +for_each_irq (i) { +struct irq_desc *desc =irq_to_desc (i); + +if (!desc || !desc->chip) +continue ; + +if (desc->chip->eoi && + desc->status &IRQ_INPROGRESS ) + desc->chip->eoi (i); + +if (desc->chip->mask) + desc->chip->mask (i); + +if (desc->chip->disable && + !(desc->status &IRQ_DISABLED )) + desc->chip->disable (i); + } +} +void machine_crash_shutdown (struct pt_regs *regs) {if (ppc_md.machine_crash_shutdown)
arch/powerpc/kernel/machine_kexec_32.c +4 -0
@@ -39,6 +39,10 @@ void default_machine_kexec(struct kimage *image)/* Interrupts aren't acceptable while we reboot */ local_irq_disable (); +/* mask each interrupt so we are in a more sane state for the +* kexec kernel */ +machine_kexec_mask_interrupts (); + page_list = image->head;/* we need both effective and real address here */
Signature · 1 line
1.6.6.1
PATCH 2/4 powerpc/85xx: Remove call to mpic_teardown_this_cpu in kexec
We no longer need to call this explicitly as a generic version is called by default
--- arch/powerpc/platforms/85xx/smp.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
arch/powerpc/platforms/85xx/smp.c +0 -2
@@ -118,8 +118,6 @@ static int kexec_down_cpus = 0;void mpc85xx_smp_kexec_cpu_down (int crash_shutdown,int secondary) { -mpic_teardown_this_cpu (1 ); -/* When crashing, this gets called on all CPU's we only * take down the non-boot cpus */ if (smp_processor_id () != boot_cpuid)
Signature · 1 line
1.6.6.1
Kumar Gala
AppliedRe: [PATCH 2/4] powerpc/85xx: Remove call to mpic_teardown_this_cpu in kexec
Quoted 7 lines · Matthew McClintock
We no longer need to call this explicitly as a generic version is called by default
Signed-off-by Matthew McClintock <[email protected]>---
arch/powerpc/platforms/85xx/smp.c| 2 --1 files changed, 0 insertions(+), 2 deletions(-)
applied to next
- k
PATCH 3/4 powerpc/85xx: Minor fixups for kexec on 85xx
In reply to Matthew McClintockMake kexec_down_cpus atmoic since it will be incremented by all cores as they are coming down
Remove duplicate calls to mpc85xx_smp_kexec_down, now it's called by the crash and normal kexec pathway only once
Increase the timeout to wait for other cores to shutdown
--- arch/powerpc/platforms/85xx/smp.c | 24 +++++++++++------------- 1 files changed, 11 insertions(+), 13 deletions(-)
arch/powerpc/platforms/85xx/smp.c +11 -13
@@ -114,17 +114,15 @@ struct smp_ops_t smp_85xx_ops = { };#ifdef CONFIG_KEXEC -static int kexec_down_cpus =0 ; +atomic_t kexec_down_cpus =ATOMIC_INIT (0 );void mpc85xx_smp_kexec_cpu_down (int crash_shutdown,int secondary) { -/* When crashing, this gets called on all CPU's we only -* take down the non-boot cpus */ -if (smp_processor_id () != boot_cpuid) - { -local_irq_disable (); - kexec_down_cpus++; +local_irq_disable (); +if (secondary) { +atomic_inc (&kexec_down_cpus); +/* loop forever */ while (1 ); } }
@@ -137,14 +135,14 @@ static void mpc85xx_smp_kexec_down(void *arg)static void mpc85xx_smp_machine_kexec (struct kimage *image) { -int timeout =2000 ; -int i; +int timeout =INT_MAX ; +int i, num_cpus =num_present_cpus (); -set_cpus_allowed (current,cpumask_of_cpu (boot_cpuid)); -smp_call_function (mpc85xx_smp_kexec_down,NULL ,0 ); +if (image->type ==KEXEC_TYPE_DEFAULT ) +smp_call_function (mpc85xx_smp_kexec_down,NULL ,0 ); -while ( (kexec_down_cpus != (num_online_cpus () -1 )) && +while ( (atomic_read (&kexec_down_cpus) != (num_cpus -1 )) && ( timeout >0 ) ) { timeout--;
@@ -153,7 +151,7 @@ static void mpc85xx_smp_machine_kexec(struct kimage *image)if ( !timeout )printk (KERN_ERR "Unable to bring down secondary cpu(s)" ); -for (i =0 ; i <num_present_cpus (); i++) +for (i =0 ; i < num_cpus; i++) {if ( i ==smp_processor_id () )continue ;mpic_reset_core (i);
Signature · 1 line
1.6.6.1
Kumar Gala
AppliedRe: [PATCH 3/4] powerpc/85xx: Minor fixups for kexec on 85xx
Quoted 6 lines · Matthew McClintock
Make
kexec_down_cpusatmoic since it will be incremented by all cores as they are coming downRemove duplicate calls to
mpc85xx_smp_kexec_down, now it's called by the crash and normal kexec pathway only once
Quoted 6 lines
Increase the timeout to wait for other cores to shutdown
Signed-off-by Matthew McClintock <[email protected]>---
arch/powerpc/platforms/85xx/smp.c| 24 +++++++++++-------------1 files changed, 11 insertions(+), 13 deletions(-)
applied to next
- k
PATCH 4/4 powerpc/85xx: flush dcache before resetting cores
In reply to Matthew McClintockWhen we do an mpic_reset_core we need to make sure the dcache is flushed
--- arch/powerpc/platforms/85xx/smp.c | 50 +++++++++++++++++++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-)
arch/powerpc/platforms/85xx/smp.c +50 -0
@@ -16,6 +16,7 @@#include <linux/delay.h> #include <linux/of.h> #include <linux/kexec.h> +#include <linux/highmem.h> #include <asm/machdep.h> #include <asm/pgtable.h>
@@ -133,11 +134,60 @@ static void mpc85xx_smp_kexec_down(void *arg) ppc_md.kexec_cpu_down (0 ,1 ); } +static void map_and_flush (unsigned long paddr) +{ +struct page *page =pfn_to_page (paddr >>PAGE_SHIFT ); +unsigned long kaddr = (unsigned long )kmap (page); + +flush_dcache_range (kaddr, kaddr +PAGE_SIZE ); +kunmap (page); +} + +/** +* Before we reset the other cores, we need to flush relevant cache +* out to memory so we don't get anything corrupted, some of these flushes +* are performed out of an overabundance of caution as interrupts are not +* disabled yet and we can switch cores +*/ +static void mpc85xx_smp_flush_dcache_kexec (struct kimage *image) +{ +kimage_entry_t *ptr, entry; +unsigned long paddr; +int i; + +if (image->type ==KEXEC_TYPE_DEFAULT ) { +/* normal kexec images are stored in temporary pages */ +for (ptr = &image->head; (entry = *ptr) && !(entry &IND_DONE ); + ptr = (entry &IND_INDIRECTION ) ? +phys_to_virt (entry &PAGE_MASK ) : ptr +1 ) { +if (!(entry &IND_DESTINATION )) { +map_and_flush (entry); + } + } +/* flush out last IND_DONE page */ +map_and_flush (entry); + }else { +/* crash type kexec images are copied to the crash region */ +for (i =0 ; i < image->nr_segments; i++) { +struct kexec_segment *seg = &image->segment[i]; +for (paddr = seg->mem; paddr < seg->mem + seg->memsz; + paddr +=PAGE_SIZE ) { +map_and_flush (paddr); + } + } + } + +/* also flush the kimage struct to be passed in as well */ +flush_dcache_range ((unsigned long )image, + (unsigned long )image +sizeof (*image)); +} +static void mpc85xx_smp_machine_kexec (struct kimage *image) {int timeout =INT_MAX ;int i, num_cpus =num_present_cpus (); +mpc85xx_smp_flush_dcache_kexec (image);if (image->type ==KEXEC_TYPE_DEFAULT )smp_call_function (mpc85xx_smp_kexec_down,NULL ,0 );
Signature · 1 line
1.6.6.1
Kumar Gala
AppliedRe: [PATCH 4/4] powerpc/85xx: flush dcache before resetting cores
Quoted 6 lines · Matthew McClintock
When we do an
mpic_reset_corewe need to make sure the dcache is flushed
=20Signed-off-by Matthew McClintock <[email protected]>---
arch/powerpc/platforms/85xx/smp.c| 50 =
+++++++++++++++++++++++++++++++++++++
Quoted 1 line
1 files changed, 50 insertions(+), 0 deletions(-)
applied to next
- k=
Kumar Gala
AppliedQuoted 11 lines · Matthew McClintock
Right now just the kexec crash pathway turns turns off the interrupts. Pull that out and make a generic version for use elsewhere
Signed-off-by Matthew McClintock <[email protected]>---
arch/powerpc/include/asm/kexec.h | 1 + arch/powerpc/kernel/crash.c | 13 +------------ arch/powerpc/kernel/machine_kexec.c | 24 ++++++++++++++++++++++++ arch/powerpc/kernel/machine_kexec_32.c | 4 ++++ 4 files changed, 30 insertions(+), 12 deletions(-)
applied to next
- k