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

Commit 871acc52 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mmc: host: Handle config dependencies for cqhci crypto"

parents 6151ff0c ab87b60f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -420,7 +420,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)

	init_waitqueue_head(&mq->wait);

#if defined(CONFIG_SDC_QTI)
#if defined(CONFIG_SDC_QTI) && defined(CONFIG_MMC_CQHCI_CRYPTO)
	if (host->cqe_ops && host->cqe_ops->cqe_crypto_update_queue)
		host->cqe_ops->cqe_crypto_update_queue(host, mq->queue);
#endif
+6 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#define MINIMUM_DUN_SIZE 512
#define MAXIMUM_DUN_SIZE 65536

static struct cqhci_host_crypto_variant_ops cqhci_crypto_qti_variant_ops = {
static struct cqhci_host_crypto_variant_ops __maybe_unused cqhci_crypto_qti_variant_ops = {
	.host_init_crypto = cqhci_crypto_qti_init_crypto,
	.enable = cqhci_crypto_qti_enable,
	.disable = cqhci_crypto_qti_disable,
@@ -305,10 +305,15 @@ 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
}

int cqhci_crypto_qti_resume(struct cqhci_host *host)
{
	return crypto_qti_resume(host->crypto_vops->priv);
}

MODULE_DESCRIPTION("Vendor specific CQHCI Crypto Engine Support");
MODULE_LICENSE("GPL v2");
+3 −0
Original line number Diff line number Diff line
@@ -530,3 +530,6 @@ int cqhci_crypto_recovery_finish(struct cqhci_host *host)

	return 0;
}

MODULE_DESCRIPTION("CQHCI Crypto Engine Support");
MODULE_LICENSE("GPL v2");
+1 −85
Original line number Diff line number Diff line
@@ -10,10 +10,9 @@
#define _CQHCI_CRYPTO_H

#include <linux/mmc/host.h>
#include <linux/module.h>
#include "cqhci.h"

#ifdef CONFIG_MMC_CQHCI_CRYPTO

static inline int cqhci_num_keyslots(struct cqhci_host *host)
{
	return host->crypto_capabilities.config_count + 1;
@@ -95,89 +94,6 @@ int cqhci_crypto_recovery_finish(struct cqhci_host *host);
int cqhci_crypto_cap_find(void *host_p,  enum blk_crypto_mode_num crypto_mode,
			  unsigned int data_unit_size);

#else /* CONFIG_MMC_CQHCI_CRYPTO */

static inline bool cqhci_keyslot_valid(struct cqhci_host *host,
					unsigned int slot)
{
	return false;
}

static inline bool cqhci_host_is_crypto_supported(struct cqhci_host *host)
{
	return false;
}

static inline bool cqhci_is_crypto_enabled(struct cqhci_host *host)
{
	return false;
}

static inline void cqhci_crypto_enable(struct cqhci_host *host) { }

static inline int cqhci_crypto_cap_find(void *host_p,
					enum blk_crypto_mode_num crypto_mode,
					unsigned int data_unit_size)
{
	return 0;
}

static inline void cqhci_crypto_disable(struct cqhci_host *host) { }

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

static inline void cqhci_crypto_setup_rq_keyslot_manager(
					struct cqhci_host *host,
					struct request_queue *q) { }

static inline void
cqhci_crypto_destroy_rq_keyslot_manager(struct cqhci_host *host,
					 struct request_queue *q) { }

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

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

static inline void cqhci_crypto_debug(struct cqhci_host *host) { }

static inline void cqhci_crypto_set_vops(struct cqhci_host *host,
			struct cqhci_host_crypto_variant_ops *crypto_vops) { }

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

static inline int cqhci_crypto_resume(struct cqhci_host *host)
{
	return 0;
}

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

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

#endif /* CONFIG_MMC_CQHCI_CRYPTO */
#endif /* _CQHCI_CRYPTO_H */

+25 −9
Original line number Diff line number Diff line
@@ -154,7 +154,9 @@ static void cqhci_dumpregs(struct cqhci_host *cq_host)
	CQHCI_DUMP("Vendor cfg 0x%08x\n",
		   cqhci_readl(cq_host, CQHCI_VENDOR_CFG + offset));

#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	cqhci_crypto_debug(cq_host);
#endif

	if (cq_host->ops->dumpregs)
		cq_host->ops->dumpregs(mmc);
@@ -276,8 +278,10 @@ static void __cqhci_enable(struct cqhci_host *cq_host)
	if (cq_host->caps & CQHCI_TASK_DESC_SZ_128)
		cqcfg |= CQHCI_TASK_DESC_SZ;

#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	if (cqhci_host_is_crypto_supported(cq_host))
		cqcfg |= CQHCI_ICE_ENABLE;
#endif

	cqhci_writel(cq_host, cqcfg, CQHCI_CFG);

@@ -326,8 +330,9 @@ int cqhci_deactivate(struct mmc_host *mmc)
{
	struct cqhci_host *cq_host = mmc->cqe_private;

#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	cqhci_crypto_suspend(cq_host);

#endif
	if (cq_host->enabled && cq_host->activated)
		__cqhci_disable(cq_host);

@@ -362,8 +367,10 @@ static int cqhci_enable(struct mmc_host *mmc, struct mmc_card *card)
		return err;
	}

#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	if (cqhci_host_is_crypto_supported(cq_host))
		cqhci_crypto_enable(cq_host);
#endif

	__cqhci_enable(cq_host);

@@ -418,8 +425,10 @@ static void cqhci_disable(struct mmc_host *mmc)

	cqhci_off(mmc);

#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	if (cqhci_host_is_crypto_supported(cq_host))
		cqhci_crypto_disable(cq_host);
#endif

	__cqhci_disable(cq_host);

@@ -651,12 +660,14 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
	}

	if (mrq->data) {
#if defined(CONFIG_MMC_CQHCI_CRYPTO)
		err = cqhci_crypto_get_ctx(cq_host, mrq, &ice_ctx);
		if (err) {
			pr_err("%s: failed to retrieve crypto ctx for tag %d\n",
				mmc_hostname(mmc), tag);
			goto out;
			return err;
		}
#endif
		task_desc = (__le64 __force *)get_desc(cq_host, tag);
		cqhci_prep_task_desc(mrq, &data, 1);
		*task_desc = cpu_to_le64(data);
@@ -696,13 +707,14 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
	if (err)
		cqhci_post_req(mmc, mrq);

#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	if (mrq->data)
		cqhci_complete_crypto_desc(cq_host, mrq, NULL);
out:
#endif
	return err;
}

#if defined(CONFIG_SDC_QTI)
#if defined(CONFIG_SDC_QTI) && defined(CONFIG_MMC_CQHCI_CRYPTO)
static void cqhci_crypto_update_queue(struct mmc_host *mmc,
					struct request_queue *queue)
{
@@ -840,8 +852,9 @@ static void cqhci_finish_mrq(struct mmc_host *mmc, unsigned int tag)

	data = mrq->data;
	if (data) {
#if defined(CONFIG_MMC_CQHCI_CRYPTO)
		cqhci_complete_crypto_desc(cq_host, mrq, NULL);

#endif
		if (data->error)
			data->bytes_xfered = 0;
		else
@@ -1043,7 +1056,9 @@ static void cqhci_recovery_start(struct mmc_host *mmc)

	pr_debug("%s: cqhci: %s\n", mmc_hostname(mmc), __func__);

#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	cqhci_crypto_reset(cq_host);
#endif

	WARN_ON(!cq_host->recovery_halt);

@@ -1165,8 +1180,9 @@ static void cqhci_recovery_finish(struct mmc_host *mmc)

	cqhci_set_irqs(cq_host, CQHCI_IS_MASK);

#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	cqhci_crypto_recovery_finish(cq_host);

#endif
	pr_debug("%s: cqhci: recovery done\n", mmc_hostname(mmc));
	mmc_log_string(mmc, "recovery done\n");
}
@@ -1181,7 +1197,7 @@ static const struct mmc_cqe_ops cqhci_cqe_ops = {
	.cqe_timeout = cqhci_timeout,
	.cqe_recovery_start = cqhci_recovery_start,
	.cqe_recovery_finish = cqhci_recovery_finish,
#if defined(CONFIG_SDC_QTI)
#if defined(CONFIG_SDC_QTI) && defined(CONFIG_MMC_CQHCI_CRYPTO)
	.cqe_crypto_update_queue = cqhci_crypto_update_queue,
#endif
};
@@ -1210,9 +1226,7 @@ struct cqhci_host *cqhci_pltfm_init(struct platform_device *pdev)
		return ERR_PTR(-EBUSY);
	}

#ifdef CONFIG_MMC_CQHCI_CRYPTO_QTI
	cq_host->pdev = pdev;
#endif /* CONFIG_MMC_CQHCI_CRYPTO_QTI */

	dev_dbg(&pdev->dev, "CMDQ ioremap: done\n");

@@ -1259,12 +1273,14 @@ int cqhci_init(struct cqhci_host *cq_host, struct mmc_host *mmc,

	spin_lock_init(&cq_host->lock);

#if defined(CONFIG_MMC_CQHCI_CRYPTO)
	err = cqhci_host_init_crypto(cq_host);
	if (err) {
		pr_err("%s: CQHCI version %u.%02u Crypto init failed err %d\n",
		       mmc_hostname(mmc), cqhci_ver_major(cq_host),
		       cqhci_ver_minor(cq_host), err);
	}
#endif

	init_completion(&cq_host->halt_comp);
	init_waitqueue_head(&cq_host->wait_queue);
Loading