All of lore.kernel.org
 help / color / mirror / Atom feed
* [V2 PATCH] socfpga_a10: fix a kexec boot issue
@ 2017-05-15  9:13 ` yanjiang.jin at windriver.com
  0 siblings, 0 replies; 6+ messages in thread
From: yanjiang.jin @ 2017-05-15  9:13 UTC (permalink / raw)
  To: mark.rutland, dinguyen, dinguyen, linux
  Cc: jinyanjiang, linux-arm-kernel, linux-kernel

From: Yanjiang Jin <yanjiang.jin@windriver.com>


V1->V2:
1. Add flush_cache_all() in cpu_die();
2. Add more descriptive on the commit log;
Also validate kexec and CPU_HOTPLUG as before.

I guess socfpga's other boards may need this patch, but I have Arria10
board only. 
So add a new function socfpga_a10_cpu_kill(), keep the old function
socfpga_cpu_kill() for other boards.
I also verified CPU_HOTPLUG after applying this patch, everything seems well.

Test steps:

1. Enable kexec and build a SOCFPGA kernel;
2. Use zImage as 1st and 2nd kernel;
3. kexec -l /root/zImage --append="`cat /proc/cmdline`" 
4. kexec -e

Test env:

U-Boot 2014.10 (Jan 13 2016 - 11:07:09)

CPU   : Altera SOCFPGA Arria 10 Platform
BOARD : Altera SOCFPGA Arria 10 Dev Kit

-- 
1.9.1

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

* [V2 PATCH] socfpga_a10: fix a kexec boot issue
@ 2017-05-15  9:13 ` yanjiang.jin at windriver.com
  0 siblings, 0 replies; 6+ messages in thread
From: yanjiang.jin at windriver.com @ 2017-05-15  9:13 UTC (permalink / raw)
  To: linux-arm-kernel

From: Yanjiang Jin <yanjiang.jin@windriver.com>


V1->V2:
1. Add flush_cache_all() in cpu_die();
2. Add more descriptive on the commit log;
Also validate kexec and CPU_HOTPLUG as before.

I guess socfpga's other boards may need this patch, but I have Arria10
board only. 
So add a new function socfpga_a10_cpu_kill(), keep the old function
socfpga_cpu_kill() for other boards.
I also verified CPU_HOTPLUG after applying this patch, everything seems well.

Test steps:

1. Enable kexec and build a SOCFPGA kernel;
2. Use zImage as 1st and 2nd kernel;
3. kexec -l /root/zImage --append="`cat /proc/cmdline`" 
4. kexec -e

Test env:

U-Boot 2014.10 (Jan 13 2016 - 11:07:09)

CPU   : Altera SOCFPGA Arria 10 Platform
BOARD : Altera SOCFPGA Arria 10 Dev Kit

-- 
1.9.1

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

* [PATCH] socfpga_a10: reset CPU1 in socfpga_cpu_kill()
  2017-05-15  9:13 ` yanjiang.jin at windriver.com
@ 2017-05-15  9:13   ` yanjiang.jin at windriver.com
  -1 siblings, 0 replies; 6+ messages in thread
From: yanjiang.jin @ 2017-05-15  9:13 UTC (permalink / raw)
  To: mark.rutland, dinguyen, dinguyen, linux
  Cc: jinyanjiang, linux-arm-kernel, linux-kernel

From: Yanjiang Jin <yanjiang.jin@windriver.com>

socfpga_cpu_die() just puts CPU in WFI, not actually off. So that Kexec's
second kernel goes wrong since the kerenl text gets ovewritten.
Now reset CPU1 in cpu_kill() to avoid this error.
Also add flush_cache_all() to prevent data from being lost in cpu_die().

Signed-off-by: Yanjiang Jin <yanjiang.jin@windriver.com>
---
 arch/arm/mach-socfpga/platsmp.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-socfpga/platsmp.c b/arch/arm/mach-socfpga/platsmp.c
index 0ee7677..53f290e 100644
--- a/arch/arm/mach-socfpga/platsmp.c
+++ b/arch/arm/mach-socfpga/platsmp.c
@@ -102,6 +102,8 @@ static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus)
  */
 static void socfpga_cpu_die(unsigned int cpu)
 {
+	flush_cache_all();
+
 	/* Do WFI. If we wake up early, go back into WFI */
 	while (1)
 		cpu_do_idle();
@@ -117,6 +119,15 @@ static int socfpga_cpu_kill(unsigned int cpu)
 {
 	return 1;
 }
+
+static int socfpga_a10_cpu_kill(unsigned int cpu)
+{
+	/* This will put CPU #1 into reset. */
+	writel(RSTMGR_MPUMODRST_CPU1, rst_manager_base_addr +
+		SOCFPGA_A10_RSTMGR_MODMPURST);
+
+	return 1;
+}
 #endif
 
 static const struct smp_operations socfpga_smp_ops __initconst = {
@@ -133,7 +144,7 @@ static int socfpga_cpu_kill(unsigned int cpu)
 	.smp_boot_secondary	= socfpga_a10_boot_secondary,
 #ifdef CONFIG_HOTPLUG_CPU
 	.cpu_die		= socfpga_cpu_die,
-	.cpu_kill		= socfpga_cpu_kill,
+	.cpu_kill		= socfpga_a10_cpu_kill,
 #endif
 };
 
-- 
1.9.1

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

* [PATCH] socfpga_a10: reset CPU1 in socfpga_cpu_kill()
@ 2017-05-15  9:13   ` yanjiang.jin at windriver.com
  0 siblings, 0 replies; 6+ messages in thread
From: yanjiang.jin at windriver.com @ 2017-05-15  9:13 UTC (permalink / raw)
  To: linux-arm-kernel

From: Yanjiang Jin <yanjiang.jin@windriver.com>

socfpga_cpu_die() just puts CPU in WFI, not actually off. So that Kexec's
second kernel goes wrong since the kerenl text gets ovewritten.
Now reset CPU1 in cpu_kill() to avoid this error.
Also add flush_cache_all() to prevent data from being lost in cpu_die().

Signed-off-by: Yanjiang Jin <yanjiang.jin@windriver.com>
---
 arch/arm/mach-socfpga/platsmp.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-socfpga/platsmp.c b/arch/arm/mach-socfpga/platsmp.c
index 0ee7677..53f290e 100644
--- a/arch/arm/mach-socfpga/platsmp.c
+++ b/arch/arm/mach-socfpga/platsmp.c
@@ -102,6 +102,8 @@ static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus)
  */
 static void socfpga_cpu_die(unsigned int cpu)
 {
+	flush_cache_all();
+
 	/* Do WFI. If we wake up early, go back into WFI */
 	while (1)
 		cpu_do_idle();
@@ -117,6 +119,15 @@ static int socfpga_cpu_kill(unsigned int cpu)
 {
 	return 1;
 }
+
+static int socfpga_a10_cpu_kill(unsigned int cpu)
+{
+	/* This will put CPU #1 into reset. */
+	writel(RSTMGR_MPUMODRST_CPU1, rst_manager_base_addr +
+		SOCFPGA_A10_RSTMGR_MODMPURST);
+
+	return 1;
+}
 #endif
 
 static const struct smp_operations socfpga_smp_ops __initconst = {
@@ -133,7 +144,7 @@ static int socfpga_cpu_kill(unsigned int cpu)
 	.smp_boot_secondary	= socfpga_a10_boot_secondary,
 #ifdef CONFIG_HOTPLUG_CPU
 	.cpu_die		= socfpga_cpu_die,
-	.cpu_kill		= socfpga_cpu_kill,
+	.cpu_kill		= socfpga_a10_cpu_kill,
 #endif
 };
 
-- 
1.9.1

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

* Re: [PATCH] socfpga_a10: reset CPU1 in socfpga_cpu_kill()
  2017-05-15  9:13   ` yanjiang.jin at windriver.com
@ 2017-05-15  9:55     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2017-05-15  9:55 UTC (permalink / raw)
  To: yanjiang.jin
  Cc: mark.rutland, dinguyen, dinguyen, jinyanjiang, linux-arm-kernel,
	linux-kernel

On Mon, May 15, 2017 at 05:13:36PM +0800, yanjiang.jin@windriver.com wrote:
> From: Yanjiang Jin <yanjiang.jin@windriver.com>
> 
> socfpga_cpu_die() just puts CPU in WFI, not actually off. So that Kexec's
> second kernel goes wrong since the kerenl text gets ovewritten.
> Now reset CPU1 in cpu_kill() to avoid this error.
> Also add flush_cache_all() to prevent data from being lost in cpu_die().

You should not need this, as the common code does the cache flushing
for you.

It's rather unsafe too - you are completely unsynchronised between the
CPU executing in cpu_die() and the CPU executing cpu_kill() - it's
quite possible for the code in cpu_kill() to take effect when you're
part-way through the flush_cache_all().

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH] socfpga_a10: reset CPU1 in socfpga_cpu_kill()
@ 2017-05-15  9:55     ` Russell King - ARM Linux
  0 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2017-05-15  9:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, May 15, 2017 at 05:13:36PM +0800, yanjiang.jin at windriver.com wrote:
> From: Yanjiang Jin <yanjiang.jin@windriver.com>
> 
> socfpga_cpu_die() just puts CPU in WFI, not actually off. So that Kexec's
> second kernel goes wrong since the kerenl text gets ovewritten.
> Now reset CPU1 in cpu_kill() to avoid this error.
> Also add flush_cache_all() to prevent data from being lost in cpu_die().

You should not need this, as the common code does the cache flushing
for you.

It's rather unsafe too - you are completely unsynchronised between the
CPU executing in cpu_die() and the CPU executing cpu_kill() - it's
quite possible for the code in cpu_kill() to take effect when you're
part-way through the flush_cache_all().

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

end of thread, other threads:[~2017-05-15  9:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15  9:13 [V2 PATCH] socfpga_a10: fix a kexec boot issue yanjiang.jin
2017-05-15  9:13 ` yanjiang.jin at windriver.com
2017-05-15  9:13 ` [PATCH] socfpga_a10: reset CPU1 in socfpga_cpu_kill() yanjiang.jin
2017-05-15  9:13   ` yanjiang.jin at windriver.com
2017-05-15  9:55   ` Russell King - ARM Linux
2017-05-15  9:55     ` Russell King - ARM Linux

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.