linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic
@ 2010-09-16 22:58 Matthew McClintock
  2010-09-16 22:58 ` [PATCH 2/4] powerpc/85xx: Remove call to mpic_teardown_this_cpu in kexec Matthew McClintock
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Matthew McClintock @ 2010-09-16 22:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Matthew McClintock, kumar.gala

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 <msm@freescale.com>
---
 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(-)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 076327f..f54408d 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -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; }
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 4457382..832c8c4 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -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
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index dd6c141..df7e20c 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -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)
diff --git a/arch/powerpc/kernel/machine_kexec_32.c b/arch/powerpc/kernel/machine_kexec_32.c
index ae63a96..e63f2e7 100644
--- a/arch/powerpc/kernel/machine_kexec_32.c
+++ b/arch/powerpc/kernel/machine_kexec_32.c
@@ -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 */
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] powerpc/85xx: Remove call to mpic_teardown_this_cpu in kexec
  2010-09-16 22:58 [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic Matthew McClintock
@ 2010-09-16 22:58 ` Matthew McClintock
  2010-10-07  6:00   ` Kumar Gala
  2010-09-16 22:58 ` [PATCH 3/4] powerpc/85xx: Minor fixups for kexec on 85xx Matthew McClintock
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Matthew McClintock @ 2010-09-16 22:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Matthew McClintock, kumar.gala

We no longer need to call this explicitly as a generic version is
called by default

Signed-off-by: Matthew McClintock <msm@freescale.com>
---
 arch/powerpc/platforms/85xx/smp.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index a6b1065..cb8ad3b 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -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)
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] powerpc/85xx: Minor fixups for kexec on 85xx
  2010-09-16 22:58 [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic Matthew McClintock
  2010-09-16 22:58 ` [PATCH 2/4] powerpc/85xx: Remove call to mpic_teardown_this_cpu in kexec Matthew McClintock
@ 2010-09-16 22:58 ` Matthew McClintock
  2010-10-07  6:00   ` Kumar Gala
  2010-09-16 22:58 ` [PATCH 4/4] powerpc/85xx: flush dcache before resetting cores Matthew McClintock
  2010-10-07  6:00 ` [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic Kumar Gala
  3 siblings, 1 reply; 8+ messages in thread
From: Matthew McClintock @ 2010-09-16 22:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Matthew McClintock, kumar.gala

Make 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

Signed-off-by: Matthew McClintock <msm@freescale.com>
---
 arch/powerpc/platforms/85xx/smp.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index cb8ad3b..29416a9 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -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);
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] powerpc/85xx: flush dcache before resetting cores
  2010-09-16 22:58 [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic Matthew McClintock
  2010-09-16 22:58 ` [PATCH 2/4] powerpc/85xx: Remove call to mpic_teardown_this_cpu in kexec Matthew McClintock
  2010-09-16 22:58 ` [PATCH 3/4] powerpc/85xx: Minor fixups for kexec on 85xx Matthew McClintock
@ 2010-09-16 22:58 ` Matthew McClintock
  2010-10-07  6:00   ` Kumar Gala
  2010-10-07  6:00 ` [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic Kumar Gala
  3 siblings, 1 reply; 8+ messages in thread
From: Matthew McClintock @ 2010-09-16 22:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Matthew McClintock, kumar.gala

When we do an mpic_reset_core we need to make sure the dcache
is flushed

Signed-off-by: Matthew McClintock <msm@freescale.com>
---
 arch/powerpc/platforms/85xx/smp.c |   50 +++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index 29416a9..c89a370 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -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);
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic
  2010-09-16 22:58 [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic Matthew McClintock
                   ` (2 preceding siblings ...)
  2010-09-16 22:58 ` [PATCH 4/4] powerpc/85xx: flush dcache before resetting cores Matthew McClintock
@ 2010-10-07  6:00 ` Kumar Gala
  3 siblings, 0 replies; 8+ messages in thread
From: Kumar Gala @ 2010-10-07  6:00 UTC (permalink / raw)
  To: Matthew McClintock; +Cc: linuxppc-dev


On Sep 16, 2010, at 5:58 PM, Matthew McClintock wrote:

> 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 <msm@freescale.com>
> ---
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] powerpc/85xx: Remove call to mpic_teardown_this_cpu in kexec
  2010-09-16 22:58 ` [PATCH 2/4] powerpc/85xx: Remove call to mpic_teardown_this_cpu in kexec Matthew McClintock
@ 2010-10-07  6:00   ` Kumar Gala
  0 siblings, 0 replies; 8+ messages in thread
From: Kumar Gala @ 2010-10-07  6:00 UTC (permalink / raw)
  To: Matthew McClintock; +Cc: linuxppc-dev


On Sep 16, 2010, at 5:58 PM, Matthew McClintock wrote:

> We no longer need to call this explicitly as a generic version is
> called by default
> 
> Signed-off-by: Matthew McClintock <msm@freescale.com>
> ---
> arch/powerpc/platforms/85xx/smp.c |    2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)

applied to next

- k

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] powerpc/85xx: Minor fixups for kexec on 85xx
  2010-09-16 22:58 ` [PATCH 3/4] powerpc/85xx: Minor fixups for kexec on 85xx Matthew McClintock
@ 2010-10-07  6:00   ` Kumar Gala
  0 siblings, 0 replies; 8+ messages in thread
From: Kumar Gala @ 2010-10-07  6:00 UTC (permalink / raw)
  To: Matthew McClintock; +Cc: linuxppc-dev


On Sep 16, 2010, at 5:58 PM, Matthew McClintock wrote:

> Make 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
> 
> Signed-off-by: Matthew McClintock <msm@freescale.com>
> ---
> arch/powerpc/platforms/85xx/smp.c |   24 +++++++++++-------------
> 1 files changed, 11 insertions(+), 13 deletions(-)

applied to next

- k

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] powerpc/85xx: flush dcache before resetting cores
  2010-09-16 22:58 ` [PATCH 4/4] powerpc/85xx: flush dcache before resetting cores Matthew McClintock
@ 2010-10-07  6:00   ` Kumar Gala
  0 siblings, 0 replies; 8+ messages in thread
From: Kumar Gala @ 2010-10-07  6:00 UTC (permalink / raw)
  To: Matthew McClintock; +Cc: linuxppc-dev


On Sep 16, 2010, at 5:58 PM, Matthew McClintock wrote:

> When we do an mpic_reset_core we need to make sure the dcache
> is flushed
>=20
> Signed-off-by: Matthew McClintock <msm@freescale.com>
> ---
> arch/powerpc/platforms/85xx/smp.c |   50 =
+++++++++++++++++++++++++++++++++++++
> 1 files changed, 50 insertions(+), 0 deletions(-)

applied to next

- k=

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-10-07  6:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-16 22:58 [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic Matthew McClintock
2010-09-16 22:58 ` [PATCH 2/4] powerpc/85xx: Remove call to mpic_teardown_this_cpu in kexec Matthew McClintock
2010-10-07  6:00   ` Kumar Gala
2010-09-16 22:58 ` [PATCH 3/4] powerpc/85xx: Minor fixups for kexec on 85xx Matthew McClintock
2010-10-07  6:00   ` Kumar Gala
2010-09-16 22:58 ` [PATCH 4/4] powerpc/85xx: flush dcache before resetting cores Matthew McClintock
2010-10-07  6:00   ` Kumar Gala
2010-10-07  6:00 ` [PATCH 1/4] powerpc/kexec: make masking/disabling interrupts generic Kumar Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).