From patchwork Fri Feb 2 09:47:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 868544 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="oklDqM+m"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zXsZw0B3dz9sDB for ; Fri, 2 Feb 2018 20:47:03 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9ABE8C21E1E; Fri, 2 Feb 2018 09:47:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1588EC21CB1; Fri, 2 Feb 2018 09:46:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 134E1C21CB1; Fri, 2 Feb 2018 09:46:57 +0000 (UTC) Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by lists.denx.de (Postfix) with ESMTPS id 6A563C21C3F for ; Fri, 2 Feb 2018 09:46:57 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w129ksN7000729; Fri, 2 Feb 2018 03:46:54 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1517564814; bh=zhr8weosUZhwvl8bBriuspY9mhWJu67RQH1nyqVgBg0=; h=From:To:CC:Subject:Date; b=oklDqM+mU4XTcsCkQ3s+MvIMD7ftO/SjrDpH5fYAbx6F7GqeY8gSWL2+94SqUXll6 i6kc0lKMTXR77mA5A3kP+YKC54aUmQqUqw78DkAaLJRRynV0VJmWqOFubwhLEfhmqR dXRhy4FGaEKCKz4zu7TnOLgr/YVyNYGgZP+lvmoM= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w129ks52016672; Fri, 2 Feb 2018 03:46:54 -0600 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Fri, 2 Feb 2018 03:46:54 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Fri, 2 Feb 2018 03:46:54 -0600 Received: from a0230074-OptiPlex-7010.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w129kqbc030661; Fri, 2 Feb 2018 03:46:52 -0600 From: Faiz Abbas To: , Date: Fri, 2 Feb 2018 15:17:55 +0530 Message-ID: <1517564875-10237-1-git-send-email-faiz_abbas@ti.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de, faiz_abbas@ti.com Subject: [U-Boot] [PATCH] env: mmc/fat/ext4: make sure that the MMC sub-system is initialized before using it X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When booting from a non-MMC device, the MMC sub-system may not be initialized when the environment is first accessed. We need to make sure that the MMC sub-system is ready in even a non-MMC boot case. Therefore, initialize mmc during .init() of environment. Signed-off-by: Faiz Abbas Reviewed-by: Lukasz Majewski --- env/ext4.c | 9 +++++++++ env/fat.c | 9 +++++++++ env/mmc.c | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/env/ext4.c b/env/ext4.c index 9cdf28e..ba93e5b 100644 --- a/env/ext4.c +++ b/env/ext4.c @@ -123,9 +123,18 @@ err_env_relocate: return -EIO; } +static int env_ext4_init(void) +{ + if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc")) + mmc_initialize(NULL); + + return 0; +} + U_BOOT_ENV_LOCATION(ext4) = { .location = ENVL_EXT4, ENV_NAME("EXT4") .load = env_ext4_load, .save = env_save_ptr(env_ext4_save), + .init = env_ext4_init, }; diff --git a/env/fat.c b/env/fat.c index ec49c39..9f147ee 100644 --- a/env/fat.c +++ b/env/fat.c @@ -112,6 +112,14 @@ err_env_relocate: } #endif /* LOADENV */ +static int env_fat_init(void) +{ + if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc")) + mmc_initialize(NULL); + + return 0; +} + U_BOOT_ENV_LOCATION(fat) = { .location = ENVL_FAT, ENV_NAME("FAT") @@ -121,4 +129,5 @@ U_BOOT_ENV_LOCATION(fat) = { #ifdef CMD_SAVEENV .save = env_save_ptr(env_fat_save), #endif + .init = env_fat_init, }; diff --git a/env/mmc.c b/env/mmc.c index ed7bcf1..714a073 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -365,6 +365,13 @@ err: } #endif /* CONFIG_ENV_OFFSET_REDUND */ +static int env_mmc_init(void) +{ + mmc_initialize(NULL); + + return 0; +} + U_BOOT_ENV_LOCATION(mmc) = { .location = ENVL_MMC, ENV_NAME("MMC") @@ -372,4 +379,5 @@ U_BOOT_ENV_LOCATION(mmc) = { #ifndef CONFIG_SPL_BUILD .save = env_save_ptr(env_mmc_save), #endif + .init = env_mmc_init, };