From mboxrd@z Thu Jan 1 00:00:00 1970 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 AEF98C61DA4 for ; Thu, 9 Feb 2023 12:30:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7DC6285F38; Thu, 9 Feb 2023 13:30:35 +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=1675945836; bh=Zy+Hbm/PFqiT41sgOVZnFNr+/vO6Kdn0H2EmE21EOcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=wrdFXxY0sD+6322pe6rrLJgeZ56pr49VAHo4mGm4JHezlupwVT6TSVT8KIbyam74S PlVAPMDF0ANvftVBDar2fsbWAHC9LVN02ozASnKNPdaQtebgRo574QeC4+qpS0esS2 gYMIsW+UriRJteJfjNONCPRJXlVbccL9hZUy6c1Bgx4LuTxBE1sx0GKRouF2DRmEzm /zRqgAa+jpWXPM3dlEFn0u/dldId868ncbXRtGyeVG69LE7hanUfdpR1yfF2cemBmf gtHwBm7PlaAL8ohowqMAjUWNNejEj+nKWm0WWkWoYcds7oBvGMqY7uZfFEjyk3AbXG d0M6F5/uCkcEA== 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 96B4985D58; Thu, 9 Feb 2023 13:30:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1675945825; bh=Zy+Hbm/PFqiT41sgOVZnFNr+/vO6Kdn0H2EmE21EOcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aknYO6/sn/nzcYHnnFd2zwqTcdQvK1Mb/mcI4QqCuM7klqtg78tv7gxbktOZ/+UmP 9+PP2TzM+ff+OFPUyGIscIv6oXJSR9ZCoZwQNrbRxYoVpx9BecwTtpDZPYVMgk5q4l toUcJz/S2PhQRTzglIqcXB/GXy6TxBvEcEOPG4GHQlIQE+fgmij+q4H8STOGO3MNPr Z3Q6luVQf9TywXvSb7avVRyQPYyvvpSloFcv9ujm8zDsZyXT6Z95t1yPzHWKPLAUcF 4UJlT1tRl9gbvbbOIegkWZjiBpl+uXZshM8YOWYKp2GYUN0Ska2hfeVL4/ujCYdTld opsi5V8lP4Dwg== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrice Chotard , Patrick Delaunay , Tom Rini Subject: [PATCH v2 2/2] env: mmc: Apply GPT only on eMMC user HW partition Date: Thu, 9 Feb 2023 13:30:10 +0100 Message-Id: <20230209123010.31953-2-marex@denx.de> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209123010.31953-1-marex@denx.de> References: <20230209123010.31953-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 --- V2: Rebase on changes in 1/2 --- env/mmc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/env/mmc.c b/env/mmc.c index d51a5579128..88f8a9a8978 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 (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { + if (IS_ENABLED(CONFIG_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