Skip to contentSkip to conversation

add machine-specific hook to machine_kexec

PATCH New Eric Cooper 3 participants 5 messages Feb 2, 2011 – Feb 4, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 add machine-specific hook to machine_kexec

Provide the option to call a machine-specific function before kexec'ing a new kernel.

---
 arch/arm/kernel/machine_kexec.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/kernel/machine_kexec.c +7 -0
index 30ead13..e59bbd4 100644
@@ -75,6 +75,11 @@ void machine_crash_shutdown(struct pt_regs *regs)
 	printk(KERN_INFO "Loading crashdump kernel...\n");
 }
 
+/*
+ * Function pointer to optional machine-specific reinitialization
+ */
+void (*kexec_reinit)(void);
+
 void machine_kexec(struct kimage *image)
 {
 	unsigned long page_list;
@@ -104,6 +109,8 @@ void machine_kexec(struct kimage *image)
 			   (unsigned long) reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE);
 	printk(KERN_INFO "Bye!\n");
 
+	if (kexec_reinit)
+		kexec_reinit();
 	local_irq_disable();
 	local_fiq_disable();
 	setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH v2 2/3 Kirkwood: enable PCIe before reading device ID register

PCIe may have been disabled (by kirkwood_clock_gate) if this kernel was started by kexec. Make sure PCIe is enabled before attempting to access the device ID register, otherwise the system will hang.

---
 arch/arm/mach-kirkwood/common.h |    1 +
 arch/arm/mach-kirkwood/pcie.c   |    8 ++++++++
 2 files changed, 9 insertions(+), 0 deletions(-)
arch/arm/mach-kirkwood/common.h +1 -0
index 95bb0a7..a35b862 100644
@@ -32,6 +32,7 @@ void kirkwood_init_irq(void);
 extern struct mbus_dram_target_info kirkwood_mbus_dram_info;
 void kirkwood_setup_cpu_mbus(void);
 
+void kirkwood_enable_pcie(void);
 void kirkwood_pcie_id(u32 *dev, u32 *rev);
 
 void kirkwood_ehci_init(void);
arch/arm/mach-kirkwood/pcie.c +8 -0
index 513ad31..ca294ff 100644
@@ -18,8 +18,16 @@
 #include <mach/bridge-regs.h>
 #include "common.h"
 
+void kirkwood_enable_pcie(void)
+{
+	u32 curr = readl(CLOCK_GATING_CTRL);
+	if (!(curr & CGC_PEX0))
+		writel(curr | CGC_PEX0, CLOCK_GATING_CTRL);
+}
+
 void __init kirkwood_pcie_id(u32 *dev, u32 *rev)
 {
+	kirkwood_enable_pcie();
 	*dev = orion_pcie_dev_id((void __iomem *)PCIE_VIRT_BASE);
 	*rev = orion_pcie_rev((void __iomem *)PCIE_VIRT_BASE);
 }
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH v2 2/3 Kirkwood: enable PCIe before reading device ID register

Hello.

Quoted 6 lines · Eric Cooper

PCIe may have been disabled (by kirkwood_clock_gate) if this kernel was started by kexec. Make sure PCIe is enabled before attempting to access the device ID register, otherwise the system will hang.

[...]

arch/arm/mach-kirkwood/pcie.c line 23

Quoted 11 lines
arch/arm/mach-kirkwood/pcie.c +3 -0
index 513ad31..ca294ff 100644
@@ -18,8 +18,16 @@
  #include<mach/bridge-regs.h>
  #include "common.h"
 
+void kirkwood_enable_pcie(void)
+{
+	u32 curr = readl(CLOCK_GATING_CTRL);

An empty line wouldn't hurt here...

arch/arm/mach-kirkwood/pcie.c line 27

Quoted 4 lines
arch/arm/mach-kirkwood/pcie.c +4 -0
+	if (!(curr&  CGC_PEX0))
+		writel(curr | CGC_PEX0, CLOCK_GATING_CTRL);
+}
+

WBR, Sergei

#3 lore raw

PATCH v2 3/3 Kirkwood: enable PCIe for kexec

In reply to Eric Cooper

Use the machine-specific kexec_reinit hook to make sure PCIe is enabled before starting a new kernel.

---
 arch/arm/mach-kirkwood/common.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/mach-kirkwood/common.c +4 -0
index 3688123..78eeb63 100644
@@ -974,6 +974,8 @@ static void __init kirkwood_l2_init(void)
 
 void __init kirkwood_init(void)
 {
+	extern void (*kexec_reinit)(void);
+
 	printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
 		kirkwood_id(), kirkwood_tclk);
 	kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
@@ -1003,6 +1005,8 @@ void __init kirkwood_init(void)
 	kirkwood_xor0_init();
 	kirkwood_xor1_init();
 	kirkwood_crypto_init();
+
+	kexec_reinit = kirkwood_enable_pcie;
 }
 
 static int __init kirkwood_clock_gate(void)
Signature · 1 line
1.7.2.3
#4 lore raw

PATCH v2 1/3 add machine-specific hook to machine_kexec

In reply to Eric Cooper
Quoted 4 lines · Eric Cooper

Provide the option to call a machine-specific function before kexec'ing a new kernel.

Russell: if you agree I can carry this in the kirkwood git tree as the following kirkwood specific patches depend on this.

Quoted 32 lines
---
 arch/arm/kernel/machine_kexec.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/kernel/machine_kexec.c +7 -0
index 30ead13..e59bbd4 100644
@@ -75,6 +75,11 @@ void machine_crash_shutdown(struct pt_regs *regs)
 	printk(KERN_INFO "Loading crashdump kernel...\n");
 }
 
+/*
+ * Function pointer to optional machine-specific reinitialization
+ */
+void (*kexec_reinit)(void);
+
 void machine_kexec(struct kimage *image)
 {
 	unsigned long page_list;
@@ -104,6 +109,8 @@ void machine_kexec(struct kimage *image)
 			   (unsigned long) reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE);
 	printk(KERN_INFO "Bye!\n");
 
+	if (kexec_reinit)
+		kexec_reinit();
 	local_irq_disable();
 	local_fiq_disable();
 	setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
Signature · 1 line
1.7.2.3