diff mbox series

[U-Boot,v2,3/3] ubi: Add "skipcheck" command to set/clear this bit in the UBI volume hdr

Message ID 20190917071753.4403-1-sr@denx.de
State Accepted
Delegated to: Heiko Schocher
Headers show
Series None | expand

Commit Message

Stefan Roese Sept. 17, 2019, 7:17 a.m. UTC
U-Boot now supports the "skip_check" flag to optionally skip the CRC
check at open time. Currently its only possible to set this bit upon
UBI volume creation. But it might be very useful to also set this bit
on already installed systems (e.g. field upgrade) to make also use of
the boot-time decrease on those systems.

This patch now adds a new "ubi" command "ubi skipcheck" to set or clear
this bit in the UBI volume header:

=> ubi skipcheck rootfs0 on
Setting skip_check on volume rootfs0

BTW: This saves approx. 10 seconds Linux bootup time on a MT7688 based
target with 128MiB of SPI NAND.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Heiko Schocher <hs@denx.de>
Cc: Quentin Schulz <quentin.schulz@bootlin.com>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Heiko Schocher <hs@denx.de>
Cc: Andreas Dannenberg <dannenberg@ti.com>
---
v2:
- Add documentation to doc/README.ubi as suggested by Andreas

 cmd/ubi.c      | 34 ++++++++++++++++++++++++++++++++++
 doc/README.ubi | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)

Comments

Heiko Schocher Oct. 8, 2019, 10:41 a.m. UTC | #1
Hello Stefan,

Am 17.09.2019 um 09:17 schrieb Stefan Roese:
> U-Boot now supports the "skip_check" flag to optionally skip the CRC
> check at open time. Currently its only possible to set this bit upon
> UBI volume creation. But it might be very useful to also set this bit
> on already installed systems (e.g. field upgrade) to make also use of
> the boot-time decrease on those systems.
> 
> This patch now adds a new "ubi" command "ubi skipcheck" to set or clear
> this bit in the UBI volume header:
> 
> => ubi skipcheck rootfs0 on
> Setting skip_check on volume rootfs0
> 
> BTW: This saves approx. 10 seconds Linux bootup time on a MT7688 based
> target with 128MiB of SPI NAND.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>
> Cc: Quentin Schulz <quentin.schulz@bootlin.com>
> Cc: Boris Brezillon <boris.brezillon@collabora.com>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Andreas Dannenberg <dannenberg@ti.com>
> ---
> v2:
> - Add documentation to doc/README.ubi as suggested by Andreas
> 
>   cmd/ubi.c      | 34 ++++++++++++++++++++++++++++++++++
>   doc/README.ubi | 33 +++++++++++++++++++++++++++++++++
>   2 files changed, 67 insertions(+)

Just applied it locally and started a travis build [1] for your patch
series.

Unfortunately it breaks [2] sheevaplug board (size limit).

Added Prafulla to cc may he can give a hint, if we can remove something?

@Prafulla: This board drops a lot of build warnings [3] ... is it used
            anymore? Do you plan to update to DM support? Or should we
            remove this board?
bye,
Heiko
[1] https://travis-ci.org/hsdenx/u-boot-ubi/builds/594929737
[2] https://travis-ci.org/hsdenx/u-boot-ubi/jobs/594929765
[3] build warnings sheevaplug
===================== WARNING ======================
This board does not use CONFIG_DM_MMC. Please update
the board to use CONFIG_DM_MMC before the v2019.04 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/MIGRATION.txt for more info.
====================================================
===================== WARNING ======================
This board does not use CONFIG_DM_USB. Please update
the board to use CONFIG_DM_USB before the v2019.07 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/MIGRATION.txt for more info.
====================================================
===================== WARNING ======================
This board does use CONFIG_MVSATA_IDE which is not
ported to driver-model (DM) yet. Please update the storage
controller driver to use CONFIG_AHCI before the v2019.07
release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/MIGRATION.txt for more info.
====================================================
===================== WARNING ======================
This board does not use CONFIG_DM_ETH (Driver Model
for Ethernet drivers). Please update the board to use
CONFIG_DM_ETH before the v2020.07 release. Failure to
update by the deadline may result in board removal.
See doc/driver-model/migration.rst for more info.
====================================================
Heiko Schocher Oct. 16, 2019, 9 a.m. UTC | #2
Hello Stefan,

Am 17.09.2019 um 09:17 schrieb Stefan Roese:
> U-Boot now supports the "skip_check" flag to optionally skip the CRC
> check at open time. Currently its only possible to set this bit upon
> UBI volume creation. But it might be very useful to also set this bit
> on already installed systems (e.g. field upgrade) to make also use of
> the boot-time decrease on those systems.
> 
> This patch now adds a new "ubi" command "ubi skipcheck" to set or clear
> this bit in the UBI volume header:
> 
> => ubi skipcheck rootfs0 on
> Setting skip_check on volume rootfs0
> 
> BTW: This saves approx. 10 seconds Linux bootup time on a MT7688 based
> target with 128MiB of SPI NAND.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>
> Cc: Quentin Schulz <quentin.schulz@bootlin.com>
> Cc: Boris Brezillon <boris.brezillon@collabora.com>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Andreas Dannenberg <dannenberg@ti.com>
> ---
> v2:
> - Add documentation to doc/README.ubi as suggested by Andreas
> 
>   cmd/ubi.c      | 34 ++++++++++++++++++++++++++++++++++
>   doc/README.ubi | 33 +++++++++++++++++++++++++++++++++
>   2 files changed, 67 insertions(+)

Thanks!

applied to u-boot-ubi.git master

bye,
Heiko
diff mbox series

Patch

diff --git a/cmd/ubi.c b/cmd/ubi.c
index c857f07d93..42b5641b32 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -419,6 +419,30 @@  static int ubi_dev_scan(struct mtd_info *info, const char *vid_header_offset)
 	return 0;
 }
 
+static int ubi_set_skip_check(char *volume, bool skip_check)
+{
+	struct ubi_vtbl_record vtbl_rec;
+	struct ubi_volume *vol;
+
+	vol = ubi_find_volume(volume);
+	if (vol == NULL)
+		return ENODEV;
+
+	printf("%sing skip_check on volume %s\n",
+	       skip_check ? "Sett" : "Clear", volume);
+
+	vtbl_rec = ubi->vtbl[vol->vol_id];
+	if (skip_check) {
+		vtbl_rec.flags |= UBI_VTBL_SKIP_CRC_CHECK_FLG;
+		vol->skip_check = 1;
+	} else {
+		vtbl_rec.flags &= ~UBI_VTBL_SKIP_CRC_CHECK_FLG;
+		vol->skip_check = 0;
+	}
+
+	return ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec);
+}
+
 static int ubi_detach(void)
 {
 #ifdef CONFIG_CMD_UBIFS
@@ -578,6 +602,14 @@  static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			return ubi_remove_vol(argv[2]);
 	}
 
+	if (strncmp(argv[1], "skipcheck", 9) == 0) {
+		/* E.g., change skip_check flag */
+		if (argc == 4) {
+			skipcheck = strncmp(argv[3], "on", 2) == 0;
+			return ubi_set_skip_check(argv[2], skipcheck);
+		}
+	}
+
 	if (strncmp(argv[1], "write", 5) == 0) {
 		int ret;
 
@@ -658,6 +690,8 @@  U_BOOT_CMD(
 		" - Read volume to address with size\n"
 	"ubi remove[vol] volume"
 		" - Remove volume\n"
+	"ubi skipcheck volume on/off"
+		" - Set or clear skip_check flag in volume header\n"
 	"[Legends]\n"
 	" volume: character name\n"
 	" size: specified in bytes\n"
diff --git a/doc/README.ubi b/doc/README.ubi
index 9efab6cdc9..c78a81795b 100644
--- a/doc/README.ubi
+++ b/doc/README.ubi
@@ -223,3 +223,36 @@  For example:
 
 => ubifsumount
 Unmounting UBIFS volume recovery!
+
+
+Usage of the UBI CRC skip-check flag of static volumes:
+-------------------------------------------------------
+Some users of static UBI volumes implement their own integrity check,
+thus making the volume CRC check done at open time useless. For
+instance, this is the case when one use the ubiblock + dm-verity +
+squashfs combination, where dm-verity already checks integrity of the
+block device but this time at the block granularity instead of verifying
+the whole volume.
+
+Skipping this test drastically improves the boot-time.
+
+U-Boot now supports the "skip_check" flag to optionally skip the CRC
+check at open time.
+
+Usage: Case A - Upon UBI volume creation:
+You can optionally add "--skipcheck" to the "ubi create" command:
+
+ubi create[vol] volume [size] [type] [id] [--skipcheck]
+ - create volume name with size ('-' for maximum available size)
+
+Usage: Case B - With an already existing UBI volume:
+Use the "ubi skipcheck" command:
+
+ubi skipcheck volume on/off - Set or clear skip_check flag in volume header
+
+Example:
+=> ubi skipcheck rootfs0 on
+Setting skip_check on volume rootfs0
+
+BTW: This saves approx. 10 seconds Linux bootup time on a MT7688 based
+target with 128MiB of SPI NAND.