From patchwork Wed Jul 3 14:12:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 256654 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 8C6EF2C0322 for ; Thu, 4 Jul 2013 00:20:31 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4664F4A03E; Wed, 3 Jul 2013 16:20:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yD32dOPJppEb; Wed, 3 Jul 2013 16:20:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 21FE34A027; Wed, 3 Jul 2013 16:20:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BF05E4A027 for ; Wed, 3 Jul 2013 16:20:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mw69w7UgER+9 for ; Wed, 3 Jul 2013 16:20:21 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-yh0-f74.google.com (mail-yh0-f74.google.com [209.85.213.74]) by theia.denx.de (Postfix) with ESMTPS id 4B5F94A026 for ; Wed, 3 Jul 2013 16:20:15 +0200 (CEST) Received: by mail-yh0-f74.google.com with SMTP id z20so16534yhz.3 for ; Wed, 03 Jul 2013 07:20:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=QDLldICDmRXfGJeXiHPo+Lt4kz5jLjDv2Vcbh2tyPkQ=; b=UoP3a1zBvTtqZxGjhbykHr6/LNvWyssIrQBwouDsplCt5LTDLPeczVMiEsuV7r//YJ fa49YPWzHiBnwGpLj+EOLJo591F75Lqe2uwRvxW7B5jfhg3F3LbFkk8QzdtZgmY8/UIT u1Q2iU5oOfzJeP6McbtvLp+8o460pedKvt0hW1LROqdwdoiu4R5ORFbiq6gHe9d9Dnc8 m/VgKpccjE65VGMfsGK0ZBG7oVMkGuZEUakUHMgKk8h1RyO+gUJ4Z4tgSdp5sGCn/+1s uf1UHEMbgMCHyPt7e79NNjVlGq7E6KaTCfgnqjlLjqaGqpDi5YYUq+f7c7cuh7OWZPsq Ugiw== X-Received: by 10.236.163.193 with SMTP id a41mr487300yhl.0.1372860791889; Wed, 03 Jul 2013 07:13:11 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id x33si108075yhj.0.2013.07.03.07.13.11 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Wed, 03 Jul 2013 07:13:11 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id A003031C205; Wed, 3 Jul 2013 07:13:11 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 51B03160886; Wed, 3 Jul 2013 07:13:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Wed, 3 Jul 2013 07:12:47 -0700 Message-Id: <1372860768-8044-2-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1372860768-8044-1-git-send-email-sjg@chromium.org> References: <1372860768-8044-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQnjujyGH8iRC9q4S0mSa2z0W2FzBTlU/GtJNpH0Xh77X6IzqUWm23Dwp/M5HVjBdXWFzOJDGqCL56trM9mUdBc4UnPZn8huLZxGcij1DyLoe43EYJEfodPJ07o3CqRmfmklDvCxi9CvmfCjuYH/oq4d81r+62R3SAtgN9NqgxlJvoUMSSvXf9b4Kxbmj5EWF/8hQnqw Cc: Tom Rini Subject: [U-Boot] [PATCH 2/3] bootm: Disable interrupts only when loading X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- 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 f4df0a0..401055d 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);