diff mbox series

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

Message ID 20190912144103.17261-3-sr@denx.de
State Superseded
Delegated to: Heiko Schocher
Headers show
Series [U-Boot,1/3] ubi: provide a way to skip CRC checks | expand

Commit Message

Stefan Roese Sept. 12, 2019, 2:41 p.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>
Cc: Quentin Schulz <quentin.schulz@bootlin.com>
Cc: Boris Brezillon <boris.brezillon@bootlin.com>
Cc: Heiko Schocher <hs@denx.de>
---
 cmd/ubi.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

Comments

Andreas Dannenberg Sept. 13, 2019, 9:11 p.m. UTC | #1
Hi Stefan,

On Thu, Sep 12, 2019 at 04:41:03PM +0200, Stefan Roese wrote:
> 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.

This is a useful series, thanks for preparing/submitting.

But how about adding the above info to the doc/README.ubi file
(updating the copy&paste of the help text and the example so the new
flag is shown, and giving a quick summary of what this option does).


--
Andreas Dannenberg
Texas Instruments Inc



> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Quentin Schulz <quentin.schulz@bootlin.com>
> Cc: Boris Brezillon <boris.brezillon@bootlin.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>  cmd/ubi.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> 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"
> -- 
> 2.23.0
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Heiko Schocher Sept. 17, 2019, 5:45 a.m. UTC | #2
Hello Stefan,

Am 12.09.2019 um 16:41 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>
> Cc: Quentin Schulz <quentin.schulz@bootlin.com>
> Cc: Boris Brezillon <boris.brezillon@bootlin.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   cmd/ubi.c | 34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)

Reviewed-by: Heiko Schocher <hs@denx.de>

Could you please send a v2 with the suggestion from Andreas to add
some infos into doc/README.ubi?

Thanks!

bye,
Heiko
Stefan Roese Sept. 17, 2019, 5:54 a.m. UTC | #3
Hi Heiko,

On 17.09.19 07:45, Heiko Schocher wrote:
> Hello Stefan,
> 
> Am 12.09.2019 um 16:41 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>
>> Cc: Quentin Schulz <quentin.schulz@bootlin.com>
>> Cc: Boris Brezillon <boris.brezillon@bootlin.com>
>> Cc: Heiko Schocher <hs@denx.de>
>> ---
>>    cmd/ubi.c | 34 ++++++++++++++++++++++++++++++++++
>>    1 file changed, 34 insertions(+)
> 
> Reviewed-by: Heiko Schocher <hs@denx.de>
> 
> Could you please send a v2 with the suggestion from Andreas to add
> some infos into doc/README.ubi?

Yes, its on my list for today. ;)

Thanks,
Stefan
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"