u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] cmd: mmc: Support mmc hwpartition user enh start -
@ 2021-09-11 21:14 Marek Vasut
  2021-09-15  2:30 ` Peng Fan (OSS)
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2021-09-11 21:14 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Fabio Estevam, Jaehoon Chung, Peng Fan, Stefano Babic

Add option to extend the hardware partition to the maximum size by
using the '-' dash sign instead of $cnt parameter. This is useful
in case we want to switch the entire eMMC user area into pSLC mode,
especially in case the device may be populated with different size
eMMCs. With this change, we do not have to calculate the number of
blocks of the user area manually.

To switch the pSLC mode for user area, use e.g. the following.
WARNING: This is a one-time irreversible change.
=> mmc hwpartition user enh 0 - wrrel on complete

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
---
 cmd/mmc.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/cmd/mmc.c b/cmd/mmc.c
index c67ad762422..b6bb951347d 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -560,7 +560,32 @@ static int do_mmc_list(struct cmd_tbl *cmdtp, int flag,
 }
 
 #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
-static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
+static void parse_hwpart_user_enh_size(struct mmc *mmc,
+				       struct mmc_hwpart_conf *pconf,
+				       char *argv)
+{
+	int ret;
+
+	pconf->user.enh_size = 0;
+
+	if (!strcmp(argv, "-"))	{ /* The rest of eMMC */
+		ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
+		ret = mmc_send_ext_csd(mmc, ext_csd);
+		if (ret)
+			return;
+		pconf->user.enh_size =
+			((ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT+2] << 16) +
+			(ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT+1] << 8) +
+			ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT]) * 1024 *
+			ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
+			ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
+		pconf->user.enh_size -= pconf->user.enh_start;
+	} else {
+		pconf->user.enh_size = dectoul(argv, NULL);
+	}
+}
+
+static int parse_hwpart_user(struct mmc *mmc, struct mmc_hwpart_conf *pconf,
 			     int argc, char *const argv[])
 {
 	int i = 0;
@@ -573,8 +598,7 @@ static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
 				return -1;
 			pconf->user.enh_start =
 				dectoul(argv[i + 1], NULL);
-			pconf->user.enh_size =
-				dectoul(argv[i + 2], NULL);
+			parse_hwpart_user_enh_size(mmc, pconf, argv[i + 2]);
 			i += 3;
 		} else if (!strcmp(argv[i], "wrrel")) {
 			if (i + 1 >= argc)
@@ -646,7 +670,7 @@ static int do_mmc_hwpartition(struct cmd_tbl *cmdtp, int flag,
 	while (i < argc) {
 		if (!strcmp(argv[i], "user")) {
 			i++;
-			r = parse_hwpart_user(&pconf, argc-i, &argv[i]);
+			r = parse_hwpart_user(mmc, &pconf, argc-i, &argv[i]);
 			if (r < 0)
 				return CMD_RET_USAGE;
 			i += r;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cmd: mmc: Support mmc hwpartition user enh start -
  2021-09-11 21:14 [PATCH] cmd: mmc: Support mmc hwpartition user enh start - Marek Vasut
@ 2021-09-15  2:30 ` Peng Fan (OSS)
  2021-09-15  9:40   ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Fan (OSS) @ 2021-09-15  2:30 UTC (permalink / raw)
  To: Marek Vasut, u-boot; +Cc: Fabio Estevam, Jaehoon Chung, Peng Fan, Stefano Babic


On 2021/9/12 5:14, Marek Vasut wrote:
> Add option to extend the hardware partition to the maximum size by
> using the '-' dash sign instead of $cnt parameter. This is useful
> in case we want to switch the entire eMMC user area into pSLC mode,
> especially in case the device may be populated with different size
> eMMCs. With this change, we do not have to calculate the number of
> blocks of the user area manually.
> 
> To switch the pSLC mode for user area, use e.g. the following.
> WARNING: This is a one-time irreversible change.
> => mmc hwpartition user enh 0 - wrrel on complete
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
>   cmd/mmc.c | 32 ++++++++++++++++++++++++++++----
>   1 file changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/cmd/mmc.c b/cmd/mmc.c
> index c67ad762422..b6bb951347d 100644
> --- a/cmd/mmc.c
> +++ b/cmd/mmc.c
> @@ -560,7 +560,32 @@ static int do_mmc_list(struct cmd_tbl *cmdtp, int flag,
>   }
>   
>   #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
> -static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
> +static void parse_hwpart_user_enh_size(struct mmc *mmc,
> +				       struct mmc_hwpart_conf *pconf,
> +				       char *argv)
> +{
> +	int ret;
> +
> +	pconf->user.enh_size = 0;
> +
> +	if (!strcmp(argv, "-"))	{ /* The rest of eMMC */
> +		ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
> +		ret = mmc_send_ext_csd(mmc, ext_csd);
> +		if (ret)
> +			return;
> +		pconf->user.enh_size =
> +			((ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT+2] << 16) +

space before/after "+"

> +			(ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT+1] << 8) +

Ditto

> +			ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT]) * 1024 *

Hardcode HC_WP_GRP_SIZE to 1024?
Per spec:

(GP_SIZE_MULT_X_2 * 2^16 + GP_SIZE_MULT_X_1 * 2^8 + GP_SIZE_MULT_X_0 * 
2^0) * HC_WP_GRP_SIZE * HC_ERASE_GRP_SIZE * 512kBytes

Thanks,
Peng.


> +			ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
> +			ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
> +		pconf->user.enh_size -= pconf->user.enh_start;
> +	} else {
> +		pconf->user.enh_size = dectoul(argv, NULL);
> +	}
> +}
> +
> +static int parse_hwpart_user(struct mmc *mmc, struct mmc_hwpart_conf *pconf,
>   			     int argc, char *const argv[])
>   {
>   	int i = 0;
> @@ -573,8 +598,7 @@ static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
>   				return -1;
>   			pconf->user.enh_start =
>   				dectoul(argv[i + 1], NULL);
> -			pconf->user.enh_size =
> -				dectoul(argv[i + 2], NULL);
> +			parse_hwpart_user_enh_size(mmc, pconf, argv[i + 2]);
>   			i += 3;
>   		} else if (!strcmp(argv[i], "wrrel")) {
>   			if (i + 1 >= argc)
> @@ -646,7 +670,7 @@ static int do_mmc_hwpartition(struct cmd_tbl *cmdtp, int flag,
>   	while (i < argc) {
>   		if (!strcmp(argv[i], "user")) {
>   			i++;
> -			r = parse_hwpart_user(&pconf, argc-i, &argv[i]);
> +			r = parse_hwpart_user(mmc, &pconf, argc-i, &argv[i]);
>   			if (r < 0)
>   				return CMD_RET_USAGE;
>   			i += r;
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cmd: mmc: Support mmc hwpartition user enh start -
  2021-09-15  2:30 ` Peng Fan (OSS)
@ 2021-09-15  9:40   ` Marek Vasut
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2021-09-15  9:40 UTC (permalink / raw)
  To: Peng Fan (OSS), u-boot
  Cc: Fabio Estevam, Jaehoon Chung, Peng Fan, Stefano Babic

On 9/15/21 4:30 AM, Peng Fan (OSS) wrote:
> 
> On 2021/9/12 5:14, Marek Vasut wrote:
>> Add option to extend the hardware partition to the maximum size by
>> using the '-' dash sign instead of $cnt parameter. This is useful
>> in case we want to switch the entire eMMC user area into pSLC mode,
>> especially in case the device may be populated with different size
>> eMMCs. With this change, we do not have to calculate the number of
>> blocks of the user area manually.
>>
>> To switch the pSLC mode for user area, use e.g. the following.
>> WARNING: This is a one-time irreversible change.
>> => mmc hwpartition user enh 0 - wrrel on complete
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> Cc: Fabio Estevam <festevam@gmail.com>
>> Cc: Jaehoon Chung <jh80.chung@samsung.com>
>> Cc: Peng Fan <peng.fan@nxp.com>
>> Cc: Stefano Babic <sbabic@denx.de>
>> ---
>>   cmd/mmc.c | 32 ++++++++++++++++++++++++++++----
>>   1 file changed, 28 insertions(+), 4 deletions(-)
>>
>> diff --git a/cmd/mmc.c b/cmd/mmc.c
>> index c67ad762422..b6bb951347d 100644
>> --- a/cmd/mmc.c
>> +++ b/cmd/mmc.c
>> @@ -560,7 +560,32 @@ static int do_mmc_list(struct cmd_tbl *cmdtp, int 
>> flag,
>>   }
>>   #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
>> -static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
>> +static void parse_hwpart_user_enh_size(struct mmc *mmc,
>> +                       struct mmc_hwpart_conf *pconf,
>> +                       char *argv)
>> +{
>> +    int ret;
>> +
>> +    pconf->user.enh_size = 0;
>> +
>> +    if (!strcmp(argv, "-"))    { /* The rest of eMMC */
>> +        ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
>> +        ret = mmc_send_ext_csd(mmc, ext_csd);
>> +        if (ret)
>> +            return;
>> +        pconf->user.enh_size =
>> +            ((ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT+2] << 16) +
> 
> space before/after "+"
> 
>> +            (ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT+1] << 8) +
> 
> Ditto
> 
>> +            ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT]) * 1024 *
> 
> Hardcode HC_WP_GRP_SIZE to 1024?
> Per spec:
> 
> (GP_SIZE_MULT_X_2 * 2^16 + GP_SIZE_MULT_X_1 * 2^8 + GP_SIZE_MULT_X_0 * 
> 2^0) * HC_WP_GRP_SIZE * HC_ERASE_GRP_SIZE * 512kBytes

That "1024" above is that "* 512kBytes" part, in 512 Byte block units.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-15  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11 21:14 [PATCH] cmd: mmc: Support mmc hwpartition user enh start - Marek Vasut
2021-09-15  2:30 ` Peng Fan (OSS)
2021-09-15  9:40   ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).