From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Cc: Marek Vasut <marex@denx.de>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Patrick Delaunay <patrick.delaunay@foss.st.com>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH v2 2/2] env: mmc: Apply GPT only on eMMC user HW partition
Date: Thu, 9 Feb 2023 13:30:10 +0100 [thread overview]
Message-ID: <20230209123010.31953-2-marex@denx.de> (raw)
In-Reply-To: <20230209123010.31953-1-marex@denx.de>
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 <marex@denx.de>
---
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Tom Rini <trini@konsulko.com>
---
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
next prev parent reply other threads:[~2023-02-09 12:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230209123058epcas1p22a2f76f8e2ba8c365886322e217cb453@epcas1p2.samsung.com>
2023-02-09 12:30 ` [PATCH v2 1/2] env: mmc: Clean up macro usage Marek Vasut
2023-02-09 12:30 ` Marek Vasut [this message]
2023-02-09 15:27 ` [PATCH v2 2/2] env: mmc: Apply GPT only on eMMC user HW partition Tom Rini
2023-02-09 16:33 ` Marek Vasut
2023-02-24 14:43 ` Tom Rini
2023-02-09 15:27 ` [PATCH v2 1/2] env: mmc: Clean up macro usage Tom Rini
2023-02-09 20:13 ` Simon Glass
2023-02-10 0:01 ` Jaehoon Chung
2023-02-23 10:41 ` Patrick DELAUNAY
2023-02-23 13:22 ` Marek Vasut
2023-02-23 16:32 ` Tom Rini
2023-02-23 18:24 ` Marek Vasut
2023-02-23 17:17 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230209123010.31953-2-marex@denx.de \
--to=marex@denx.de \
--cc=patrice.chotard@foss.st.com \
--cc=patrick.delaunay@foss.st.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox