diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 7ba6c5515d21..3b887a4b9e7c 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -199,6 +199,7 @@ void mmc_host_clk_hold(struct mmc_host *host) spin_unlock_irqrestore(&host->clk_lock, flags); mutex_unlock(&host->clk_gate_mutex); } +EXPORT_SYMBOL(mmc_host_clk_hold); /** * mmc_host_may_gate_card - check if this card may be gated @@ -248,6 +249,7 @@ void mmc_host_clk_release(struct mmc_host *host) msecs_to_jiffies(host->clkgate_delay)); spin_unlock_irqrestore(&host->clk_lock, flags); } +EXPORT_SYMBOL(mmc_host_clk_release); /** * mmc_host_clk_rate - get current clock frequency setting diff --git a/drivers/mmc/host/cmdq_hci-crypto-qti.c b/drivers/mmc/host/cmdq_hci-crypto-qti.c index 80fb35ff35a5..0c96f74cc633 100644 --- a/drivers/mmc/host/cmdq_hci-crypto-qti.c +++ b/drivers/mmc/host/cmdq_hci-crypto-qti.c @@ -19,7 +19,6 @@ #include "sdhci-msm.h" #include "cmdq_hci-crypto-qti.h" #include -#include #include #if IS_ENABLED(CONFIG_CRYPTO_DEV_QCOM_ICE) #include @@ -30,6 +29,8 @@ #define MINIMUM_DUN_SIZE 512 #define MAXIMUM_DUN_SIZE 65536 +static struct mmc_host *mmc_host; + static struct cmdq_host_crypto_variant_ops cmdq_crypto_qti_variant_ops = { .host_init_crypto = cmdq_crypto_qti_init_crypto, .enable = cmdq_crypto_qti_enable, @@ -121,11 +122,15 @@ static int cmdq_crypto_qti_keyslot_program(struct keyslot_manager *ksm, return -EINVAL; } + mmc_host_clk_hold(mmc_host); + err = crypto_qti_keyslot_program(host->crypto_vops->priv, key, slot, data_unit_mask, crypto_alg_id); if (err) pr_err("%s: failed with error %d\n", __func__, err); + mmc_host_clk_release(mmc_host); + return err; } @@ -137,19 +142,21 @@ static int cmdq_crypto_qti_keyslot_evict(struct keyslot_manager *ksm, int val = 0; struct cmdq_host *host = keyslot_manager_private(ksm); - pm_runtime_get_sync(&host->mmc->card->dev); - if (!cmdq_is_crypto_enabled(host) || !cmdq_keyslot_valid(host, slot)) { - pm_runtime_put_sync(&host->mmc->card->dev); return -EINVAL; } + mmc_host_clk_hold(mmc_host); + err = crypto_qti_keyslot_evict(host->crypto_vops->priv, slot); - if (err) + if (err) { pr_err("%s: failed with error %d\n", __func__, err); + mmc_host_clk_release(mmc_host); + return err; + } + mmc_host_clk_release(mmc_host); - pm_runtime_put_sync(&host->mmc->card->dev); val = atomic_read(&keycache) & ~(1 << slot); atomic_set(&keycache, val); @@ -237,6 +244,11 @@ int cmdq_host_init_crypto_qti_spec(struct cmdq_host *host, * descriptor would be used to pass crypto specific informaton. */ host->caps |= CMDQ_TASK_DESC_SZ_128; + mmc_host = host->mmc; + if (!mmc_host) { + err = -ENODEV; + goto out; + } return 0; out: @@ -319,6 +331,11 @@ int cmdq_host_init_crypto_qti_spec(struct cmdq_host *host, * descriptor would be used to pass crypto specific informaton. */ host->caps |= CMDQ_TASK_DESC_SZ_128; + mmc_host = host->mmc; + if (!mmc_host) { + err = -ENODEV; + goto out; + } return 0;