All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaehoon Chung <jh80.chung@samsung.com>
To: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>,
	u-boot@lists.denx.de
Cc: Peng Fan <peng.fan@nxp.com>,
	Markus Niebel <Markus.Niebel@ew.tq-group.com>
Subject: Re: [PATCH 2/2] cmd/mmc: add subcommand to query max enhanced partition size
Date: Thu, 23 Sep 2021 21:03:24 +0900	[thread overview]
Message-ID: <1369dd62-fda1-fa2a-7535-3afc23ca924c@samsung.com> (raw)
In-Reply-To: <5bfd7e81fd5ed77e049d3fc3892c9175aa80e5cd.1632313515.git.matthias.schiffer@ew.tq-group.com>

On 9/22/21 9:30 PM, Matthias Schiffer wrote:
> From: Markus Niebel <Markus.Niebel@ew.tq-group.com>
> 
> The new command prints the sector count and size in a human-readable
> format and sets an environment variable for scripted handling. The
> variable value is set in decimal to match what the 'mmc hwpartition'
> command expects.
> 
> The environment variable can be used for automated partitioning scripts,
> for example the following would convert a whole eMMC to pSLC mode:
> 
>     mmc maxhwpartsectors
>     mmc hwpartition user enh 0 ${maxhwpartsectors} wrrel on complete


I don't have any objection about this patch.
If we can use more simpler variable name than maxhwpartsectors, I think that it's more useful.
But it's not important. :)

And Could you update doc/usage/mmc.rst about this command?

Best Regards,
Jaehoon Chung

> 
> Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> ---
> 
> The human-readable output of the command could also be added to `mmc info`,
> but it would still be great to have a separate command that sets an
> environment variable for scripting, like this patch adds.
> 
> 
>  cmd/mmc.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/cmd/mmc.c b/cmd/mmc.c
> index f1e30d0cf64..d0b33cc0494 100644
> --- a/cmd/mmc.c
> +++ b/cmd/mmc.c
> @@ -593,6 +593,33 @@ static int do_mmc_list(struct cmd_tbl *cmdtp, int flag,
>  }
>  
>  #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
> +static int do_mmc_maxhwpartsectors(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
> +{
> +	struct mmc *mmc;
> +	u64 sectors;
> +
> +	mmc = init_mmc_device(curr_device, false);
> +	if (!mmc)
> +		return CMD_RET_FAILURE;
> +
> +	if (mmc_max_enhanced_size_sectors(mmc, &sectors))
> +		return CMD_RET_FAILURE;
> +
> +	/* Ensure that the value fits in mmc_hwpart_conf::user.enh_size */
> +	if (sectors > UINT_MAX) {
> +		puts("ERROR: sector count larger than UINT_MAX\n");
> +		return CMD_RET_FAILURE;
> +	}
> +
> +	env_set_ulong("maxhwpartsectors", sectors);
> +
> +	printf("Maximum size of hardware partition: %u sectors (",
> +	       (uint)sectors);
> +	print_size(sectors * 512, ")\n");
> +
> +	return 0;
> +}
> +
>  static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
>  			     int argc, char *const argv[])
>  {
> @@ -1021,6 +1048,7 @@ static struct cmd_tbl cmd_mmc[] = {
>  	U_BOOT_CMD_MKENT(dev, 4, 0, do_mmc_dev, "", ""),
>  	U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""),
>  #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
> +	U_BOOT_CMD_MKENT(maxhwpartsectors, 1, 0, do_mmc_maxhwpartsectors, "", ""),
>  	U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", ""),
>  #endif
>  #ifdef CONFIG_SUPPORT_EMMC_BOOT
> @@ -1084,6 +1112,8 @@ U_BOOT_CMD(
>  	"mmc list - lists available devices\n"
>  	"mmc wp - power on write protect boot partitions\n"
>  #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
> +	"mmc maxhwpartsectors - shows the maximum number of 512-byte blocks usable for hardware partitioning\n"
> +	"  Sets env var maxhwpartsectors on success.\n"
>  	"mmc hwpartition <USER> <GP> <MODE> - does hardware partitioning\n"
>  	"  arguments (sizes in 512-byte blocks):\n"
>  	"   USER - <user> <enh> <start> <cnt> <wrrel> <{on|off}>\n"
> 


  reply	other threads:[~2021-09-23 12:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210922123104epcas1p4ac210f3dfb4a2900f4a3b172953663b6@epcas1p4.samsung.com>
2021-09-22 12:30 ` [PATCH 1/2] mmc: add helper to query max enhanced part size Matthias Schiffer
2021-09-22 12:30   ` [PATCH 2/2] cmd/mmc: add subcommand to query max enhanced partition size Matthias Schiffer
2021-09-23 12:03     ` Jaehoon Chung [this message]
2021-09-23 11:58   ` [PATCH 1/2] mmc: add helper to query max enhanced part size Jaehoon Chung
2021-09-23 12:55     ` Matthias Schiffer

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=1369dd62-fda1-fa2a-7535-3afc23ca924c@samsung.com \
    --to=jh80.chung@samsung.com \
    --cc=Markus.Niebel@ew.tq-group.com \
    --cc=matthias.schiffer@ew.tq-group.com \
    --cc=peng.fan@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.