Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BACD5C05027 for ; Wed, 8 Feb 2023 11:33:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6676285E82; Wed, 8 Feb 2023 12:33:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1675855989; bh=KhlyVV1rXdnm9ov7TeSgjESVgJ9v5biMbo+LaW0sXPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fgofls7+lWtEXDLGbcwdQEJvHuZY+e2diqu7rn+//DPkIPFMaPwW+2kGoLC48eHq/ 0XWIR5e3gxA9pUktMyv7/0RpigkLPpzXBYI5XdTzpnDtkjvnAVajf0VW3HSU0r4Hoi 0jH0xVXp4pLIfLQkCO9exysq22vlLDleAXhxUFlRDYe/LzcDDA/hch7ekeCDr9f3ZY YNBqSLi+ArGZ2n6IvqEDlkrJMq1eA9Jh4oJh7WqJmMkuMcU/KawtPAhM87qf5PT1s5 WCJRxzSFVT3iviB9Qkg0ctMh+BKGjXjMpnc1h4Xfe3alZxhtyE+Xqtac1HyPnpL25T CqWqAukXZUs+g== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 7D90A85CFB; Wed, 8 Feb 2023 12:33:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1675855980; bh=KhlyVV1rXdnm9ov7TeSgjESVgJ9v5biMbo+LaW0sXPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yJHOUqfYpJTM+C4l8tQ+bHcuPJ0/4hZyWdc2jUUfkc0LucRzRK1bBZkD8UCuAPdE8 j6R4gfj4+i+7lrMS3KiM2fk4PYMo+jAo6FU6h6cSXahvHoc7BB4Uh6Li77O2YzpCgv JpkWutcWHaQEWL1URpLKtAldRGivRD2pkG7mezFoPIRHj4tj9JbYowQeZbRAqHd3LG oH61zE8j5p1+6x54YLvDab3lfCq/G5CGoTzcv5iqD4fNKRibmJVDBD7X3GQxFw/b9I Y7X8mv/08lt+AC7mp527Syl3GD5IRomlkNAm1COfRgSQFwv/aiW8o2N7MKaCopZC5I rhGBmMPh2eSZw== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrice Chotard , Patrick Delaunay , Tom Rini Subject: [PATCH 2/2] env: mmc: Apply GPT only on eMMC user HW partition Date: Wed, 8 Feb 2023 12:32:44 +0100 Message-Id: <20230208113244.131488-2-marex@denx.de> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208113244.131488-1-marex@denx.de> References: <20230208113244.131488-1-marex@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Apply the GPT U-Boot environment GUID type look up only on eMMC user HW partition, do not apply the look up on eMMC boot HW partitions as mmc_offset_try_partition() assumes either SD partitions or eMMC user HW partition. This fixes environment operation on systems where CONFIG_SYS_MMC_ENV_PART is non-zero and CONFIG_SYS_REDUNDAND_ENVIRONMENT is set. Fixes: 80105d8fd52 ("env: mmc: select GPT env partition by type guid") Signed-off-by: Marek Vasut --- Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Tom Rini --- env/mmc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/env/mmc.c b/env/mmc.c index b34a8dd982e..25df750ffd9 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -92,7 +92,7 @@ static inline int mmc_offset_try_partition(const char *str, int copy, s64 *val) return 0; } -static inline s64 mmc_offset(int copy) +static inline s64 mmc_offset(struct mmc *mmc, int copy) { const struct { const char *offset_redund; @@ -106,8 +106,12 @@ static inline s64 mmc_offset(int copy) s64 val = 0, defvalue; const char *propname; const char *str; + int hwpart = 0; int err; + if (IS_ENABLED(CONFIG_SYS_MMC_ENV_PART)) + hwpart = mmc_get_env_part(mmc); + /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */ str = ofnode_conf_read_str(dt_prop.partition); if (str) { @@ -119,7 +123,7 @@ static inline s64 mmc_offset(int copy) } /* try the GPT partition with "U-Boot ENV" TYPE GUID */ - if (CONFIG_IS_ENABLED(PARTITION_TYPE_GUID)) { + if (CONFIG_IS_ENABLED(PARTITION_TYPE_GUID) && hwpart == 0) { err = mmc_offset_try_partition(NULL, copy, &val); if (!err) return val; @@ -136,7 +140,7 @@ static inline s64 mmc_offset(int copy) return ofnode_conf_read_int(propname, defvalue); } #else -static inline s64 mmc_offset(int copy) +static inline s64 mmc_offset(struct mmc *mmc, int copy) { s64 offset = ENV_MMC_OFFSET; @@ -149,7 +153,7 @@ static inline s64 mmc_offset(int copy) __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr) { - s64 offset = mmc_offset(copy); + s64 offset = mmc_offset(mmc, copy); if (offset == ENV_MMC_INVALID_OFFSET) { printf("Invalid ENV offset in MMC, copy=%d\n", copy); -- 2.39.1