]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
powerpc/kexec: Add support for FSL-BookE
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Sun, 4 Apr 2010 20:19:03 +0000 (22:19 +0200)
committerKumar Gala <galak@kernel.crashing.org>
Tue, 25 May 2010 02:25:32 +0000 (21:25 -0500)
This adds support kexec on FSL-BookE where the MMU can not be simply
switched off. The code borrows the initial MMU-setup code to create the
identical mapping mapping. The only difference to the original boot code
is the size of the mapping(s) and the executeable address.
The kexec code maps the first 2 GiB of memory in 256 MiB steps. This
should work also on e500v1 boxes.
SMP support is still not available.

(Kumar: Added minor change to build to ifdef CONFIG_PPC_STD_MMU_64 some
code that was PPC64 specific)

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/Kconfig
arch/powerpc/include/asm/kexec.h
arch/powerpc/kernel/crash.c
arch/powerpc/kernel/fsl_booke_entry_mapping.S
arch/powerpc/kernel/head_fsl_booke.S
arch/powerpc/kernel/misc_32.S

index c4c4549c22bbe8a3ce06149429096d0c87207c73..5887cff167859e3b9c605a8ffe77ab313a8e9086 100644 (file)
@@ -351,7 +351,7 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE
 
 config KEXEC
        bool "kexec system call (EXPERIMENTAL)"
-       depends on PPC_BOOK3S && EXPERIMENTAL
+       depends on (PPC_BOOK3S || (FSL_BOOKE && !SMP)) && EXPERIMENTAL
        help
          kexec is a system call that implements the ability to shutdown your
          current kernel, and to start another kernel.  It is like a reboot
index a6ca6da1430bd60506af9b5babc62df147c8c9f7..2a9cd74a841e3e234b6d1a4bb6beb8e5cd1b207b 100644 (file)
@@ -2,6 +2,18 @@
 #define _ASM_POWERPC_KEXEC_H
 #ifdef __KERNEL__
 
+#ifdef CONFIG_FSL_BOOKE
+
+/*
+ * On FSL-BookE we setup a 1:1 mapping which covers the first 2GiB of memory
+ * and therefore we can only deal with memory within this range
+ */
+#define KEXEC_SOURCE_MEMORY_LIMIT      (2 * 1024 * 1024 * 1024UL)
+#define KEXEC_DESTINATION_MEMORY_LIMIT (2 * 1024 * 1024 * 1024UL)
+#define KEXEC_CONTROL_MEMORY_LIMIT     (2 * 1024 * 1024 * 1024UL)
+
+#else
+
 /*
  * Maximum page that is mapped directly into kernel memory.
  * XXX: Since we copy virt we can use any page we allocate
@@ -21,6 +33,7 @@
 /* TASK_SIZE, probably left over from use_mm ?? */
 #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
 #endif
+#endif
 
 #define KEXEC_CONTROL_PAGE_SIZE 4096
 
index 8c066d6a8e4b4ee015bc8ccf93bf5fc321267bbe..b46f2e09bd81df4bea175401fe4f70fbf45bfb35 100644 (file)
@@ -163,6 +163,7 @@ static void crash_kexec_prepare_cpus(int cpu)
 }
 
 /* wait for all the CPUs to hit real mode but timeout if they don't come in */
+#ifdef CONFIG_PPC_STD_MMU_64
 static void crash_kexec_wait_realmode(int cpu)
 {
        unsigned int msecs;
@@ -187,6 +188,7 @@ static void crash_kexec_wait_realmode(int cpu)
        }
        mb();
 }
+#endif
 
 /*
  * This function will be called by secondary cpus or by kexec cpu
@@ -445,7 +447,9 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
        crash_kexec_prepare_cpus(crashing_cpu);
        cpu_set(crashing_cpu, cpus_in_crash);
        crash_kexec_stop_spus();
+#ifdef CONFIG_PPC_STD_MMU_64
        crash_kexec_wait_realmode(crashing_cpu);
+#endif
        if (ppc_md.kexec_cpu_down)
                ppc_md.kexec_cpu_down(1, 0);
 }
index cdb1296f972dffab1dd1d1a7d323e2d6786f1ccb..beb4d78a23049603a7806b1ad2bdbd0c0787226b 100644 (file)
@@ -159,6 +159,8 @@ skpinv:     addi    r6,r6,1                         /* Increment */
 #define M_IF_SMP       0
 #endif
 
+#if defined(ENTRY_MAPPING_BOOT_SETUP)
+
 /* 6. Setup KERNELBASE mapping in TLB1[0] */
        lis     r6,0x1000               /* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
        mtspr   SPRN_MAS0,r6
@@ -174,6 +176,41 @@ skpinv:    addi    r6,r6,1                         /* Increment */
 /* 7. Jump to KERNELBASE mapping */
        lis     r6,(KERNELBASE & ~0xfff)@h
        ori     r6,r6,(KERNELBASE & ~0xfff)@l
+
+#elif defined(ENTRY_MAPPING_KEXEC_SETUP)
+/*
+ * 6. Setup a 1:1 mapping in TLB1. Esel 0 is unsued, 1 or 2 contains the tmp
+ * mapping so we start at 3. We setup 8 mappings, each 256MiB in size. This
+ * will cover the first 2GiB of memory.
+ */
+
+       lis r10, (MAS1_VALID|MAS1_IPROT)@h
+       ori r10,r10, (MAS1_TSIZE(BOOK3E_PAGESZ_256M))@l
+       li  r11, 0
+       li  r0, 8
+       mtctr   r0
+
+next_tlb_setup:
+       addi    r0, r11, 3
+       rlwinm  r0, r0, 16, 4, 15  // Compute esel
+       rlwinm  r9, r11, 28, 0, 3   // Compute [ER]PN
+       oris    r0, r0, (MAS0_TLBSEL(1))@h
+       mtspr   SPRN_MAS0,r0
+       mtspr   SPRN_MAS1,r10
+       mtspr   SPRN_MAS2,r9
+       ori r9, r9, (MAS3_SX|MAS3_SW|MAS3_SR)
+       mtspr   SPRN_MAS3,r9
+       tlbwe
+       addi    r11, r11, 1
+       bdnz+   next_tlb_setup
+
+/* 7. Jump to our 1:1 mapping */
+       li      r6, 0
+
+#else
+       #error You need to specify the mapping or not use this at all.
+#endif
+
        lis     r7,MSR_KERNEL@h
        ori     r7,r7,MSR_KERNEL@l
        bl      1f                      /* Find our address */
index 6b5b1f3b61121043497c5d4d716316f977755c9d..4faeba247854c038078ef4362836d50b37f4f44a 100644 (file)
@@ -95,7 +95,9 @@ _ENTRY(_start);
 
 _ENTRY(__early_start)
 
+#define ENTRY_MAPPING_BOOT_SETUP
 #include "fsl_booke_entry_mapping.S"
+#undef ENTRY_MAPPING_BOOT_SETUP
 
        /* Establish the interrupt vector offsets */
        SET_IVOR(0,  CriticalInput);
index 8043d1b73cf0cbe98186b3e38aadbf908b283d3e..dc66d52dcff56b8be102b6ed25f160d9b44eaf87 100644 (file)
@@ -711,6 +711,22 @@ relocate_new_kernel:
        /* r4 = reboot_code_buffer */
        /* r5 = start_address      */
 
+#ifdef CONFIG_FSL_BOOKE
+
+       mr      r29, r3
+       mr      r30, r4
+       mr      r31, r5
+
+#define ENTRY_MAPPING_KEXEC_SETUP
+#include "fsl_booke_entry_mapping.S"
+#undef ENTRY_MAPPING_KEXEC_SETUP
+
+       mr      r3, r29
+       mr      r4, r30
+       mr      r5, r31
+
+       li      r0, 0
+#else
        li      r0, 0
 
        /*
@@ -727,6 +743,7 @@ relocate_new_kernel:
        rfi
 
 1:
+#endif
        /* from this point address translation is turned off */
        /* and interrupts are disabled */