Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb021827 authored by urevanth's avatar urevanth Committed by Gerrit - the friendly Code Review server
Browse files

Dm-verity: Enable dm_device_wait parameter



Set dm_device_wait parameter through rootwait
to eliminate dm-verity timing issue for emmc.

Change-Id: I7a5065f2c020c98c3a308d2c17ad3610a7ae0c07
Signed-off-by: default avatarurevanth <quic_urevanth@quicinc.com>
parent e6d9ead2
Loading
Loading
Loading
Loading
+11 −46
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "dm-verity-fec.h"
#include <linux/delay.h>
#include "dm-verity-verify-sig.h"
#include <linux/init.h>
#include <linux/module.h>
#include <linux/reboot.h>

@@ -29,7 +30,6 @@

#define DM_VERITY_MAX_CORRUPTED_ERRS	100

#define DM_VERITY_OPT_DEVICE_WAIT       "device_wait"
#define DM_VERITY_OPT_LOGGING		"ignore_corruption"
#define DM_VERITY_OPT_RESTART		"restart_on_corruption"
#define DM_VERITY_OPT_IGN_ZEROES	"ignore_zero_blocks"
@@ -42,7 +42,17 @@ static unsigned dm_verity_prefetch_cluster = DM_VERITY_DEFAULT_PREFETCH_SIZE;

module_param_named(prefetch_cluster, dm_verity_prefetch_cluster, uint, S_IRUGO | S_IWUSR);

/*
 * If rootwait parameter defined, wait for root device to be available
 * before continuing with verity target
 */
static int dm_device_wait;
static int __init dm_verity_root_wait_setup(char *s)
{
	dm_device_wait = 1;
	return 0;
}
early_param("rootwait", dm_verity_root_wait_setup);

struct dm_verity_prefetch_work {
	struct work_struct work;
@@ -888,39 +898,6 @@ static int verity_alloc_zero_digest(struct dm_verity *v)
	return r;
}


static int verity_parse_pre_opt_args(struct dm_arg_set *as, struct dm_verity *v)
{
	int r;
	unsigned int argc;
	const char *arg_name;
	struct dm_target *ti = v->ti;
	static struct dm_arg _args[] = {
		{0, DM_VERITY_OPTS_MAX, "Invalid number of feature args"},
	};

	r = dm_read_arg_group(_args, as, &argc, &ti->error);
	if (r)
		return -EINVAL;

	if (!argc)
		return 0;

	do {
		arg_name = dm_shift_arg(as);
		argc--;

		if (!strcasecmp(arg_name, DM_VERITY_OPT_DEVICE_WAIT)) {

			dm_device_wait = 1;
			continue;
		}

	} while (argc);

	return 0;
}

static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v,
				 struct dm_verity_sig_opts *verify_args)
{
@@ -972,9 +949,6 @@ static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v,
				return r;
			continue;

		} else if (!strcasecmp(arg_name, DM_VERITY_OPT_DEVICE_WAIT)) {
			continue;

		} else if (verity_verify_is_sig_opt_arg(arg_name)) {
			r = verity_verify_sig_parse_opt_args(as, v,
							     verify_args,
@@ -1043,15 +1017,6 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
		goto bad;
	}

	/* Optional parameters which are parsed pre required args. */
	if ((argc - 10)) {
		as.argc = argc - 10;
		as.argv = argv + 10;
		r = verity_parse_pre_opt_args(&as, v);
		if (r < 0)
			goto bad;
	}

	if (sscanf(argv[0], "%u%c", &num, &dummy) != 1 ||
	    num > 1) {
		ti->error = "Invalid version";