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

Commit 5dd3350d authored by Neeraj Soni's avatar Neeraj Soni Committed by Jiten Patel
Browse files

mmc: host: Use right parameter for ext4 plus eMMC



With new encryption framework intermediate vector
calculation is changed so to support the legacy
mechanism for ext4 file system use correct parameter
for data encrypt/decrypt.

Ported and fixed the merged conflicts in cqhci-crypto-qti.c file
(cherry picked from mainline kernel_msm-4.14 commit 3344057)

Conflicts:
	drivers/mmc/host/cqhci-crypto-qti.c

Test:
1) Flashed Q meta, create multiple files under /data.
2) Build R (include changes topic: 660_OTA_FIXES) and flash
   APPS images of R except userdata and boot the device.
3) Device booted upto UI.
4) Files created with Q build retained.
5) Created new files under /data and checked retention across
   multiple re-boots.

Change-Id: I678c291c6a9a91a7aa8e9c64512dd23451873198
Signed-off-by: default avatarNeeraj Soni <neersoni@codeaurora.org>
Signed-off-by: default avatarJiten Patel <jitepate@codeaurora.org>
parent af4a70ad
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ static struct cqhci_host_crypto_variant_ops cqhci_crypto_qti_variant_ops = {
};

static atomic_t keycache;
static bool cmdq_use_default_du_size;

static bool ice_cap_idx_valid(struct cqhci_host *host,
					unsigned int cap_idx)
@@ -47,12 +48,19 @@ static bool ice_cap_idx_valid(struct cqhci_host *host,

static uint8_t get_data_unit_size_mask(unsigned int data_unit_size)
{
	unsigned int du_size;

	if (data_unit_size < MINIMUM_DUN_SIZE ||
		data_unit_size > MAXIMUM_DUN_SIZE ||
	    !is_power_of_2(data_unit_size))
		return 0;

	return data_unit_size / MINIMUM_DUN_SIZE;
	if (cmdq_use_default_du_size)
		du_size = MINIMUM_DUN_SIZE;
	else
		du_size =  data_unit_size;

	return du_size / MINIMUM_DUN_SIZE;
}


@@ -333,6 +341,8 @@ int cqhci_crypto_qti_prep_desc(struct cqhci_host *host, struct mmc_request *mrq,
	if (!cqhci_keyslot_valid(host, bc->bc_keyslot))
		return -EINVAL;
	if (!(atomic_read(&keycache) & (1 << bc->bc_keyslot))) {
		if (bc->is_ext4)
			cmdq_use_default_du_size = true;
		ret = cqhci_crypto_qti_keyslot_program(host->ksm, bc->bc_key,
						       bc->bc_keyslot);
		if (ret) {
@@ -344,8 +354,12 @@ int cqhci_crypto_qti_prep_desc(struct cqhci_host *host, struct mmc_request *mrq,
	}

	if (ice_ctx) {
		*ice_ctx = DATA_UNIT_NUM(bc->bc_dun[0]) |
			   CRYPTO_CONFIG_INDEX(bc->bc_keyslot) |
		if (bc->is_ext4)
			*ice_ctx = DATA_UNIT_NUM(req->__sector);
		else
			*ice_ctx = DATA_UNIT_NUM(bc->bc_dun[0]);

		*ice_ctx = *ice_ctx | CRYPTO_CONFIG_INDEX(bc->bc_keyslot) |
			    CRYPTO_ENABLE(true);
	}
	return 0;