From patchwork Wed Sep 22 12:30:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 1531222 X-Patchwork-Delegate: jh80.chung@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tq-group.com header.i=@tq-group.com header.a=rsa-sha256 header.s=key1 header.b=Ll2KGF8t; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.a=rsa-sha256 header.s=key1 header.b=Ll2KGF8t; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4HDyMc6QGcz9t0Y for ; Wed, 22 Sep 2021 22:31:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 388DE8321D; Wed, 22 Sep 2021 14:31:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=tq-group.com header.i=@tq-group.com header.b="Ll2KGF8t"; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.b="Ll2KGF8t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DDD7882D74; Wed, 22 Sep 2021 14:31:02 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E1FAB82ECC for ; Wed, 22 Sep 2021 14:30:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=matthias.schiffer@ew.tq-group.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1632313858; x=1663849858; h=from:to:cc:subject:date:message-id; bh=lYYx+CM8P/1ZySBEo/KUu64YNMR+/rvyezgOZpVrPOM=; b=Ll2KGF8tIJe7F1xw6vXc6jcNUo7kmLys93OWTk44eGKzCD3pk/yzH0ZE X+EdgqPuie9qhzcP0bCM+zBbnLwZYYn+W/g2CNaWtBhiCItHrMcrcYAK1 H4J31jkod94zTT/uEwVsUCLEolns8vNuRFBlHaBaxXD+uRlDj387AM5Io ceEB7XIJkyJaNUDesfEjQiHHtuaZXNRi6XgU+UFNeML0Dajhy13ph7o2F 6rfZw0di3SAFgVGbqv33EujITk1a36azXsjKdHyYjlbbn8eB3VfSrT2T3 bgG7ul6aFFubxvq16psYNI1sM8jKy486rO5eDDL1/QMxHRAEaDrsr3L17 A==; X-IronPort-AV: E=Sophos;i="5.85,313,1624312800"; d="scan'208";a="19648595" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 22 Sep 2021 14:30:58 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Wed, 22 Sep 2021 14:30:58 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Wed, 22 Sep 2021 14:30:58 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1632313858; x=1663849858; h=from:to:cc:subject:date:message-id; bh=lYYx+CM8P/1ZySBEo/KUu64YNMR+/rvyezgOZpVrPOM=; b=Ll2KGF8tIJe7F1xw6vXc6jcNUo7kmLys93OWTk44eGKzCD3pk/yzH0ZE X+EdgqPuie9qhzcP0bCM+zBbnLwZYYn+W/g2CNaWtBhiCItHrMcrcYAK1 H4J31jkod94zTT/uEwVsUCLEolns8vNuRFBlHaBaxXD+uRlDj387AM5Io ceEB7XIJkyJaNUDesfEjQiHHtuaZXNRi6XgU+UFNeML0Dajhy13ph7o2F 6rfZw0di3SAFgVGbqv33EujITk1a36azXsjKdHyYjlbbn8eB3VfSrT2T3 bgG7ul6aFFubxvq16psYNI1sM8jKy486rO5eDDL1/QMxHRAEaDrsr3L17 A==; X-IronPort-AV: E=Sophos;i="5.85,313,1624312800"; d="scan'208";a="19648594" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 22 Sep 2021 14:30:58 +0200 Received: from schifferm-ubuntu4.tq-net.de (schifferm-ubuntu4.tq-net.de [10.121.48.12]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id DC5AC280075; Wed, 22 Sep 2021 14:30:57 +0200 (CEST) From: Matthias Schiffer To: u-boot@lists.denx.de Cc: Peng Fan , Jaehoon Chung , Markus Niebel , Matthias Schiffer Subject: [PATCH 2/2] cmd/mmc: add subcommand to query max enhanced partition size Date: Wed, 22 Sep 2021 14:30:37 +0200 Message-Id: <5bfd7e81fd5ed77e049d3fc3892c9175aa80e5cd.1632313515.git.matthias.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <1d862733e0d4ae632eb036de13aaf048b31b8bdb.1632313515.git.matthias.schiffer@ew.tq-group.com> References: <1d862733e0d4ae632eb036de13aaf048b31b8bdb.1632313515.git.matthias.schiffer@ew.tq-group.com> In-Reply-To: <1d862733e0d4ae632eb036de13aaf048b31b8bdb.1632313515.git.matthias.schiffer@ew.tq-group.com> References: <1d862733e0d4ae632eb036de13aaf048b31b8bdb.1632313515.git.matthias.schiffer@ew.tq-group.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean From: Markus Niebel 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 Signed-off-by: Markus Niebel Signed-off-by: Matthias Schiffer --- 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, §ors)) + 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 - does hardware partitioning\n" " arguments (sizes in 512-byte blocks):\n" " USER - <{on|off}>\n"