From 17f54d16a19afd13ca577aae04cbeeb40025143c Mon Sep 17 00:00:00 2001 From: Veerabhadrarao Badiganti Date: Mon, 9 Oct 2017 19:51:46 +0530 Subject: [PATCH 1/2] mmc: cmdq_hci: Remove runtime PM vote if request issuing fails Remove the runtime PM vote if command-queue request processing fails. Otherwise, in case command-queue request preparation fails, the runtime PM votes go out of sync and sdhc platform device suspend might get blocked. Change-Id: Ibe95e1653f7558a7994b606922a1625b429d57f6 Signed-off-by: Veerabhadrarao Badiganti --- drivers/mmc/host/cmdq_hci.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/cmdq_hci.c b/drivers/mmc/host/cmdq_hci.c index 3f741f83a436..83d24fcaf2ab 100644 --- a/drivers/mmc/host/cmdq_hci.c +++ b/drivers/mmc/host/cmdq_hci.c @@ -805,7 +805,7 @@ static int cmdq_request(struct mmc_host *mmc, struct mmc_request *mrq) if (err) { pr_err("%s: failed to configure crypto: err %d tag %d\n", mmc_hostname(mmc), err, tag); - goto out; + goto ice_err; } } @@ -823,7 +823,7 @@ static int cmdq_request(struct mmc_host *mmc, struct mmc_request *mrq) if (err) { pr_err("%s: %s: failed to setup tx desc: %d\n", mmc_hostname(mmc), __func__, err); - goto out; + goto desc_err; } cq_host->mrq_slot[tag] = mrq; @@ -843,6 +843,22 @@ ring_doorbell: /* Commit the doorbell write immediately */ wmb(); + return err; + +desc_err: + if (cq_host->ops->crypto_cfg_end) { + err = cq_host->ops->crypto_cfg_end(mmc, mrq); + if (err) { + pr_err("%s: failed to end ice config: err %d tag %d\n", + mmc_hostname(mmc), err, tag); + } + } + if (!(cq_host->caps & CMDQ_CAP_CRYPTO_SUPPORT) && + cq_host->ops->crypto_cfg_reset) + cq_host->ops->crypto_cfg_reset(mmc, tag); +ice_err: + if (err) + cmdq_runtime_pm_put(cq_host); out: return err; } From 48f0cccb8c234698a76f3af4241e76a0ef8f1eab Mon Sep 17 00:00:00 2001 From: Veerabhadrarao Badiganti Date: Mon, 9 Oct 2017 20:13:45 +0530 Subject: [PATCH 2/2] mmc: core: Return the error if command queue request fails command-queue request may fail during preparation/issuing in some cases. In case if it fails, the error code needs to be propagated back to the function which initiated the request so that the request can be handled appropriately. Change-Id: Ia6946c14f0c106fb30bd70ca5c9e600c516fdf55 Signed-off-by: Veerabhadrarao Badiganti --- drivers/mmc/core/core.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index cfd56d9fa2ca..8c6861564ed2 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1166,9 +1166,11 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) return 0; } -static void mmc_start_cmdq_request(struct mmc_host *host, +static int mmc_start_cmdq_request(struct mmc_host *host, struct mmc_request *mrq) { + int ret = 0; + if (mrq->data) { pr_debug("%s: blksz %d blocks %d flags %08x tsac %lu ms nsac %d\n", mmc_hostname(host), mrq->data->blksz, @@ -1190,11 +1192,21 @@ static void mmc_start_cmdq_request(struct mmc_host *host, } mmc_host_clk_hold(host); - if (likely(host->cmdq_ops->request)) - host->cmdq_ops->request(host, mrq); - else - pr_err("%s: %s: issue request failed\n", mmc_hostname(host), - __func__); + if (likely(host->cmdq_ops->request)) { + ret = host->cmdq_ops->request(host, mrq); + } else { + ret = -ENOENT; + pr_err("%s: %s: cmdq request host op is not available\n", + mmc_hostname(host), __func__); + } + + if (ret) { + mmc_host_clk_release(host); + pr_err("%s: %s: issue request failed, err=%d\n", + mmc_hostname(host), __func__, ret); + } + + return ret; } /** @@ -1681,8 +1693,7 @@ int mmc_cmdq_start_req(struct mmc_host *host, struct mmc_cmdq_req *cmdq_req) mrq->cmd->error = -ENOMEDIUM; return -ENOMEDIUM; } - mmc_start_cmdq_request(host, mrq); - return 0; + return mmc_start_cmdq_request(host, mrq); } EXPORT_SYMBOL(mmc_cmdq_start_req);