public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 2/5] bootm: Disable interrupts only when loading
@ 2013-07-04 20:26 Simon Glass
  2013-07-04 20:26 ` [U-Boot] [PATCH v2 3/5] bootm: Require boot function only if it is about to be used Simon Glass
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: Simon Glass @ 2013-07-04 20:26 UTC (permalink / raw)
  To: u-boot

With the move of the interrupt code to earlier in the sequence, we
exposed a problem where the interrupts are disabled at each bootm
stage. This is not correct - it should be done only once. Let's disable
interrupts in the LOAD stage. Put the code in a function for clarity.

Also, bootz lost its interrupt code altogether, so reinstate it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None

 common/cmd_bootm.c | 67 +++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 24 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 652513a..0c88be1 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -539,6 +539,42 @@ static int boot_selected_os(int argc, char * const argv[], int state,
 }
 
 /**
+ * bootm_disable_interrupts() - Disable interrupts in preparation for load/boot
+ *
+ * @return interrupt flag (0 if interrupts were disabled, non-zero if they were
+ *	enabled)
+ */
+static ulong bootm_disable_interrupts(void)
+{
+	ulong iflag;
+
+	/*
+	 * We have reached the point of no return: we are going to
+	 * overwrite all exception vector code, so we cannot easily
+	 * recover from any failures any more...
+	 */
+	iflag = disable_interrupts();
+#ifdef CONFIG_NETCONSOLE
+	/* Stop the ethernet stack if NetConsole could have left it up */
+	eth_halt();
+#endif
+
+#if defined(CONFIG_CMD_USB)
+	/*
+	 * turn off USB to prevent the host controller from writing to the
+	 * SDRAM while Linux is booting. This could happen (at least for OHCI
+	 * controller), because the HCCA (Host Controller Communication Area)
+	 * lies within the SDRAM and the host controller writes continously to
+	 * this area (as busmaster!). The HccaFrameNumber is for example
+	 * updated every 1 ms within the HCCA structure in SDRAM! For more
+	 * details see the OpenHCI specification.
+	 */
+	usb_stop();
+#endif
+	return iflag;
+}
+
+/**
  * Execute selected states of the bootm command.
  *
  * Note the arguments to this state must be the first argument, Any 'bootm'
@@ -588,34 +624,11 @@ static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
 		argc = 0;	/* consume the args */
 	}
 
-	/*
-	 * We have reached the point of no return: we are going to
-	 * overwrite all exception vector code, so we cannot easily
-	 * recover from any failures any more...
-	 */
-	iflag = disable_interrupts();
-#ifdef CONFIG_NETCONSOLE
-	/* Stop the ethernet stack if NetConsole could have left it up */
-	eth_halt();
-#endif
-
-#if defined(CONFIG_CMD_USB)
-	/*
-	 * turn off USB to prevent the host controller from writing to the
-	 * SDRAM while Linux is booting. This could happen (at least for OHCI
-	 * controller), because the HCCA (Host Controller Communication Area)
-	 * lies within the SDRAM and the host controller writes continously to
-	 * this area (as busmaster!). The HccaFrameNumber is for example
-	 * updated every 1 ms within the HCCA structure in SDRAM! For more
-	 * details see the OpenHCI specification.
-	 */
-	usb_stop();
-#endif
-
 	/* Load the OS */
 	if (!ret && (states & BOOTM_STATE_LOADOS)) {
 		ulong load_end;
 
+		iflag = bootm_disable_interrupts();
 		ret = bootm_load_os(images, &load_end, 0);
 		if (ret && ret != BOOTM_ERR_OVERLAP)
 			goto err;
@@ -1774,6 +1787,12 @@ int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (bootz_start(cmdtp, flag, argc, argv, &images))
 		return 1;
 
+	/*
+	 * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
+	 * disable interrupts ourselves
+	 */
+	bootm_disable_interrupts();
+
 	ret = do_bootm_states(cmdtp, flag, argc, argv,
 			      BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO,
 			      &images, 1);
-- 
1.8.3

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

end of thread, other threads:[~2013-07-12 16:49 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-04 20:26 [U-Boot] [PATCH v2 2/5] bootm: Disable interrupts only when loading Simon Glass
2013-07-04 20:26 ` [U-Boot] [PATCH v2 3/5] bootm: Require boot function only if it is about to be used Simon Glass
2013-07-04 20:26 ` [U-Boot] [PATCH v2 4/5] bootm: Clean up bootz_setup() function Simon Glass
2013-07-04 20:26 ` [U-Boot] [PATCH v2 5/5] bootm: Add the missing PREP stage to bootz and correct image handling Simon Glass
2013-07-08 14:13   ` Tom Rini
2013-07-08 14:17     ` Robert Nelson
2013-07-08 14:22       ` Tom Rini
2013-07-09 17:01         ` Tom Rini
2013-07-09 19:00           ` Simon Glass
2013-07-09 19:05             ` Tom Rini
2013-07-09 20:04               ` Simon Glass
2013-07-09 21:19                 ` Tom Rini
2013-07-09 21:24                   ` Robert Nelson
2013-07-09 21:39                     ` Robert Nelson
2013-07-09 21:44                   ` Simon Glass
2013-07-10  9:51                   ` Sughosh Ganu
2013-07-10 10:08                     ` Simon Glass
2013-07-11  6:03                     ` Sughosh Ganu
2013-07-11  6:56                       ` Simon Glass
2013-07-12  8:21                         ` Sughosh Ganu
2013-07-12 16:49                           ` Simon Glass
2013-07-10 10:13                   ` Simon Glass
2013-07-10 10:15                     ` Simon Glass
2013-07-09 19:05             ` Robert Nelson
2013-07-10 13:18 ` [U-Boot] [PATCH v2 2/5] bootm: Disable interrupts only when loading Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox