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

Commit b2c36ddc authored by Dinesh K Garg's avatar Dinesh K Garg Committed by David Keitel
Browse files

crypto: ice: Make ICE init & reset API synchronous



ICE init & reset can be synchronous now because ICE does not need
to go to secure side for any ICE configuration. This would simplify
interface and make call more efficient.

Change-Id: I7aa4e2d3ba3383d25758b21b8ae261a0220f35f9
Signed-off-by: default avatarDinesh K Garg <dineshg@codeaurora.org>
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: default avatarGilad Broner <gbroner@codeaurora.org>
[venkatg@codeaurora.org: dropped ice driver and mmc ice changes]
Signed-off-by: default avatarVenkat Gopalakrishnan <venkatg@codeaurora.org>
parent ada96960
Loading
Loading
Loading
Loading
+5 −63
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@

#include <linux/io.h>
#include <linux/of.h>
#include <linux/async.h>
#include <linux/blkdev.h>
#include <crypto/ice.h>

@@ -53,24 +52,8 @@ void ufs_qcom_ice_print_regs(struct ufs_qcom_host *qcom_host)
		pr_err("REG_UFS_QCOM_ICE_CTRL_INFO_2_%d = 0x%08X\n", i,
			ufshcd_readl(qcom_host->hba,
				(REG_UFS_QCOM_ICE_CTRL_INFO_2_n + 8 * i)));

	}

	}

static void ufs_qcom_ice_success_cb(void *host_ctrl,
				enum ice_event_completion evt)
{
	struct ufs_qcom_host *qcom_host = (struct ufs_qcom_host *)host_ctrl;

	if (qcom_host->ice.state == UFS_QCOM_ICE_STATE_DISABLED &&
	    evt == ICE_INIT_COMPLETION)
		qcom_host->ice.state = UFS_QCOM_ICE_STATE_ACTIVE;
	 else if (qcom_host->ice.state == UFS_QCOM_ICE_STATE_SUSPENDED &&
		   evt == ICE_RESUME_COMPLETION)
		qcom_host->ice.state = UFS_QCOM_ICE_STATE_ACTIVE;

	complete(&qcom_host->ice.async_done);
}

static void ufs_qcom_ice_error_cb(void *host_ctrl, enum ice_error_code evt)
@@ -82,8 +65,6 @@ static void ufs_qcom_ice_error_cb(void *host_ctrl, enum ice_error_code evt)

	if (qcom_host->ice.state == UFS_QCOM_ICE_STATE_ACTIVE)
		qcom_host->ice.state = UFS_QCOM_ICE_STATE_DISABLED;

	complete(&qcom_host->ice.async_done);
}

static struct platform_device *ufs_qcom_ice_get_pdevice(struct device *ufs_dev)
@@ -195,33 +176,17 @@ out:
int ufs_qcom_ice_init(struct ufs_qcom_host *qcom_host)
{
	struct device *ufs_dev = qcom_host->hba->dev;
	int err = -EINVAL;
	int err;

	init_completion(&qcom_host->ice.async_done);
	err = qcom_host->ice.vops->init(qcom_host->ice.pdev,
				qcom_host,
				ufs_qcom_ice_success_cb,
				ufs_qcom_ice_error_cb);
	if (err) {
		dev_err(ufs_dev, "%s: ice init failed. err = %d\n",
			__func__, err);
		goto out;
	}

	if (!wait_for_completion_timeout(&qcom_host->ice.async_done,
			msecs_to_jiffies(UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS))) {
		dev_err(qcom_host->hba->dev,
			"%s: error. got timeout after %d ms\n",
			__func__, UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS);
		err = -ETIMEDOUT;
		goto out;
	}

	if (qcom_host->ice.state != UFS_QCOM_ICE_STATE_ACTIVE) {
		dev_err(qcom_host->hba->dev,
			"%s: error. ice.state (%d) is not in active state\n",
			__func__, qcom_host->ice.state);
		err = -EINVAL;
	} else {
		qcom_host->ice.state = UFS_QCOM_ICE_STATE_ACTIVE;
	}

	qcom_host->dbg_print_en |= UFS_QCOM_ICE_DEFAULT_DBG_PRINT_EN;
@@ -390,8 +355,6 @@ int ufs_qcom_ice_reset(struct ufs_qcom_host *qcom_host)
	if (qcom_host->ice.state != UFS_QCOM_ICE_STATE_ACTIVE)
		goto out;

	init_completion(&qcom_host->ice.async_done);

	if (qcom_host->ice.vops->reset) {
		err = qcom_host->ice.vops->reset(qcom_host->ice.pdev);
		if (err) {
@@ -401,14 +364,6 @@ int ufs_qcom_ice_reset(struct ufs_qcom_host *qcom_host)
		}
	}

	if (!wait_for_completion_timeout(&qcom_host->ice.async_done,
	     msecs_to_jiffies(UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS))) {
		dev_err(dev,
			"%s: error. got timeout after %d ms\n",
			__func__, UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS);
		err = -ETIMEDOUT;
	}

	if (qcom_host->ice.state != UFS_QCOM_ICE_STATE_ACTIVE) {
		dev_err(qcom_host->hba->dev,
			"%s: error. ice.state (%d) is not in active state\n",
@@ -450,28 +405,15 @@ int ufs_qcom_ice_resume(struct ufs_qcom_host *qcom_host)
		return -EINVAL;
	}

	init_completion(&qcom_host->ice.async_done);

	if (qcom_host->ice.vops->resume) {
		err = qcom_host->ice.vops->resume(qcom_host->ice.pdev);
		if (err) {
			dev_err(dev, "%s: ice_vops->resume failed. err %d\n",
				__func__, err);
			return -EINVAL;
		}
			return err;
		}

	if (!wait_for_completion_timeout(&qcom_host->ice.async_done,
			msecs_to_jiffies(UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS))) {
		dev_err(dev,
			"%s: error. got timeout after %d ms\n",
			__func__, UFS_QCOM_ICE_COMPLETION_TIMEOUT_MS);
		err = -ETIMEDOUT;
		goto out;
	}

	if (qcom_host->ice.state != UFS_QCOM_ICE_STATE_ACTIVE)
		err = -EINVAL;
	qcom_host->ice.state = UFS_QCOM_ICE_STATE_ACTIVE;
out:
	return err;
}
+0 −1
Original line number Diff line number Diff line
@@ -209,7 +209,6 @@ struct ufs_qcom_bus_vote {
 */
struct ufs_qcom_ice_data {
	struct qcom_ice_variant_ops *vops;
	struct completion async_done;
	struct platform_device *pdev;
	int state;