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

Commit 65ec3786 authored by Phanindra Babu Pabba's avatar Phanindra Babu Pabba
Browse files

mmc: host: Fix bootup issue with file encryption with GKI



Export and call crypto APIs from command queue driver to
service file encryption request and program inline crypto
engine to encrypt/decrypt the data.

Change-Id: I8c9c8413e59454605c711a6a5c14308122a751e2
Signed-off-by: default avatarPhanindra Babu Pabba <pabba@codeaurora.org>
parent aa860b5b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1044,7 +1044,7 @@ config SDC_QTI

config MMC_CQHCI_CRYPTO
	tristate "CQHCI Crypto Engine Support"
	depends on MMC_CQHCI && BLK_INLINE_ENCRYPTION
	depends on BLK_INLINE_ENCRYPTION
	help
	  Enable Crypto Engine Support in CQHCI.
	  Enabling this makes it possible for the kernel to use the crypto
+7 −6
Original line number Diff line number Diff line
@@ -210,19 +210,21 @@ int cqhci_host_init_crypto_qti_spec(struct cqhci_host *host,
				host->crypto_cap_array[cap_idx].sdus_mask * 512;
	}

	host->ksm = keyslot_manager_create(host->mmc->parent,
	host->mmc->ksm = keyslot_manager_create(host->mmc->parent,
				       cqhci_num_keyslots(host), ksm_ops,
				       BLK_CRYPTO_FEATURE_STANDARD_KEYS |
				       BLK_CRYPTO_FEATURE_WRAPPED_KEYS,
				       crypto_modes_supported,
				       host);

	keyslot_manager_set_max_dun_bytes(host->ksm, sizeof(u32));

	if (!host->ksm) {
	if (!host->mmc->ksm) {
		err = -ENOMEM;
		goto out;
	}

	host->mmc->caps2 |= MMC_CAP2_CRYPTO;
	keyslot_manager_set_max_dun_bytes(host->mmc->ksm, sizeof(u32));

	/*
	 * In case host controller supports cryptographic operations
	 * then, it uses 128bit task descriptor. Upper 64 bits of task
@@ -305,10 +307,9 @@ int cqhci_crypto_qti_debug(struct cqhci_host *host)

void cqhci_crypto_qti_set_vops(struct cqhci_host *host)
{
#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	return cqhci_crypto_set_vops(host, &cqhci_crypto_qti_variant_ops);
#endif
}
EXPORT_SYMBOL(cqhci_crypto_qti_set_vops);

int cqhci_crypto_qti_resume(struct cqhci_host *host)
{
+5 −0
Original line number Diff line number Diff line
@@ -19,7 +19,12 @@ int cqhci_crypto_qti_init_crypto(struct cqhci_host *host,

int cqhci_crypto_qti_debug(struct cqhci_host *host);

#if IS_ENABLED(CONFIG_MMC_CQHCI_CRYPTO_QTI)
void cqhci_crypto_qti_set_vops(struct cqhci_host *host);
#else
void cqhci_crypto_qti_set_vops(struct cqhci_host *host)
{}
#endif /* CONFIG_MMC_CQHCI_CRYPTO_QTI) */

int cqhci_crypto_qti_resume(struct cqhci_host *host);

+10 −0
Original line number Diff line number Diff line
@@ -426,6 +426,7 @@ void cqhci_crypto_enable(struct cqhci_host *host)

	return cqhci_crypto_enable_spec(host);
}
EXPORT_SYMBOL(cqhci_crypto_enable);

void cqhci_crypto_disable(struct cqhci_host *host)
{
@@ -434,6 +435,7 @@ void cqhci_crypto_disable(struct cqhci_host *host)

	return cqhci_crypto_disable_spec(host);
}
EXPORT_SYMBOL(cqhci_crypto_disable);

int cqhci_host_init_crypto(struct cqhci_host *host)
{
@@ -443,6 +445,7 @@ int cqhci_host_init_crypto(struct cqhci_host *host)

	return cqhci_host_init_crypto_spec(host, &cqhci_ksm_ops);
}
EXPORT_SYMBOL(cqhci_host_init_crypto);

void cqhci_crypto_setup_rq_keyslot_manager(struct cqhci_host *host,
					    struct request_queue *q)
@@ -472,6 +475,7 @@ int cqhci_crypto_get_ctx(struct cqhci_host *host,

	return cqhci_prepare_crypto_desc_spec(host, mrq, ice_ctx);
}
EXPORT_SYMBOL(cqhci_crypto_get_ctx);

int cqhci_complete_crypto_desc(struct cqhci_host *host,
				struct mmc_request *mrq,
@@ -483,18 +487,21 @@ int cqhci_complete_crypto_desc(struct cqhci_host *host,

	return 0;
}
EXPORT_SYMBOL(cqhci_complete_crypto_desc);

void cqhci_crypto_debug(struct cqhci_host *host)
{
	if (host->crypto_vops && host->crypto_vops->debug)
		host->crypto_vops->debug(host);
}
EXPORT_SYMBOL(cqhci_crypto_debug);

void cqhci_crypto_set_vops(struct cqhci_host *host,
			struct cqhci_host_crypto_variant_ops *crypto_vops)
{
	host->crypto_vops = crypto_vops;
}
EXPORT_SYMBOL(cqhci_crypto_set_vops);

int cqhci_crypto_suspend(struct cqhci_host *host)
{
@@ -503,6 +510,7 @@ int cqhci_crypto_suspend(struct cqhci_host *host)

	return 0;
}
EXPORT_SYMBOL(cqhci_crypto_suspend);

int cqhci_crypto_resume(struct cqhci_host *host)
{
@@ -519,6 +527,7 @@ int cqhci_crypto_reset(struct cqhci_host *host)

	return 0;
}
EXPORT_SYMBOL(cqhci_crypto_reset);

int cqhci_crypto_recovery_finish(struct cqhci_host *host)
{
@@ -530,6 +539,7 @@ int cqhci_crypto_recovery_finish(struct cqhci_host *host)

	return 0;
}
EXPORT_SYMBOL(cqhci_crypto_recovery_finish);

MODULE_DESCRIPTION("CQHCI Crypto Engine Support");
MODULE_LICENSE("GPL v2");
+74 −18
Original line number Diff line number Diff line
@@ -56,23 +56,23 @@ void cqhci_crypto_setup_rq_keyslot_manager_spec(struct cqhci_host *host,
void cqhci_crypto_destroy_rq_keyslot_manager_spec(struct cqhci_host *host,
						  struct request_queue *q);

#if IS_ENABLED(CONFIG_MMC_CQHCI_CRYPTO)
void cqhci_crypto_set_vops(struct cqhci_host *host,
			   struct cqhci_host_crypto_variant_ops *crypto_vops);
#else
void cqhci_crypto_set_vops(struct cqhci_host *host,
			   struct cqhci_host_crypto_variant_ops *crypto_vops)
{}
#endif /* CONFIG_MMC_CQHCI_CRYPTO */

/* Crypto Variant Ops Support */

#if IS_ENABLED(CONFIG_MMC_CQHCI_CRYPTO)
void cqhci_crypto_enable(struct cqhci_host *host);

void cqhci_crypto_disable(struct cqhci_host *host);

int cqhci_host_init_crypto(struct cqhci_host *host);

void cqhci_crypto_setup_rq_keyslot_manager(struct cqhci_host *host,
					    struct request_queue *q);

void cqhci_crypto_destroy_rq_keyslot_manager(struct cqhci_host *host,
					      struct request_queue *q);

int cqhci_crypto_get_ctx(struct cqhci_host *host,
			 struct mmc_request *mrq,
			 u64 *ice_ctx);
@@ -85,12 +85,68 @@ void cqhci_crypto_debug(struct cqhci_host *host);

int cqhci_crypto_suspend(struct cqhci_host *host);

int cqhci_crypto_resume(struct cqhci_host *host);

int cqhci_crypto_reset(struct cqhci_host *host);

int cqhci_crypto_recovery_finish(struct cqhci_host *host);


void cqhci_crypto_setup_rq_keyslot_manager(struct cqhci_host *host,
					   struct request_queue *q);
#else
void cqhci_crypto_enable(struct cqhci_host *host)
{}

void cqhci_crypto_disable(struct cqhci_host *host)
{}

int cqhci_host_init_crypto(struct cqhci_host *host)
{
	return 0;
}

int cqhci_crypto_get_ctx(struct cqhci_host *host,
			 struct mmc_request *mrq,
			 u64 *ice_ctx)
{
	return 0;
}

int cqhci_complete_crypto_desc(struct cqhci_host *host,
			       struct mmc_request *mrq,
			       u64 *ice_ctx)
{
	return 0;
}

void cqhci_crypto_debug(struct cqhci_host *host)
{}

int cqhci_crypto_suspend(struct cqhci_host *host)
{
	return 0;
}

int cqhci_crypto_reset(struct cqhci_host *host)
{
	return 0;
}

int cqhci_crypto_recovery_finish(struct cqhci_host *host)
{
	return 0;
}

void cqhci_crypto_setup_rq_keyslot_manager(struct cqhci_host *host,
					   struct request_queue *q)
{}
#endif /* CONFIG_MMC_CQHCI_CRYPTO */

void cqhci_crypto_destroy_rq_keyslot_manager(struct cqhci_host *host,
					     struct request_queue *q);


int cqhci_crypto_resume(struct cqhci_host *host);

int cqhci_crypto_cap_find(void *host_p,  enum blk_crypto_mode_num crypto_mode,
			  unsigned int data_unit_size);

Loading