Skip to content

Commit 39a22f7

Browse files
Sarthak GargUlf Hansson
authored andcommitted
mmc: core: Fix recursive locking issue in CQE recovery path
Consider the following stack trace -001|raw_spin_lock_irqsave -002|mmc_blk_cqe_complete_rq -003|__blk_mq_complete_request(inline) -003|blk_mq_complete_request(rq) -004|mmc_cqe_timed_out(inline) -004|mmc_mq_timed_out mmc_mq_timed_out acquires the queue_lock for the first time. The mmc_blk_cqe_complete_rq function also tries to acquire the same queue lock resulting in recursive locking where the task is spinning for the same lock which it has already acquired leading to watchdog bark. Fix this issue with the lock only for the required critical section. Cc: <stable@vger.kernel.org> Fixes: 1e8e55b ("mmc: block: Add CQE support") Suggested-by: Sahitya Tummala <stummala@codeaurora.org> Signed-off-by: Sarthak Garg <sartgarg@codeaurora.org> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/1588868135-31783-1-git-send-email-vbadigan@codeaurora.org Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent e6bfb1b commit 39a22f7

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎drivers/mmc/core/queue.c‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static enum blk_eh_timer_return mmc_cqe_timed_out(struct request *req)
107107
case MMC_ISSUE_DCMD:
108108
if (host->cqe_ops->cqe_timeout(host, mrq, &recovery_needed)) {
109109
if (recovery_needed)
110-
__mmc_cqe_recovery_notifier(mq);
110+
mmc_cqe_recovery_notifier(mrq);
111111
return BLK_EH_RESET_TIMER;
112112
}
113113
/* No timeout (XXX: huh? comment doesn't make much sense) */
@@ -127,18 +127,13 @@ static enum blk_eh_timer_return mmc_mq_timed_out(struct request *req,
127127
struct mmc_card *card = mq->card;
128128
struct mmc_host *host = card->host;
129129
unsigned long flags;
130-
int ret;
130+
bool ignore_tout;
131131

132132
spin_lock_irqsave(&mq->lock, flags);
133-
134-
if (mq->recovery_needed || !mq->use_cqe || host->hsq_enabled)
135-
ret = BLK_EH_RESET_TIMER;
136-
else
137-
ret = mmc_cqe_timed_out(req);
138-
133+
ignore_tout = mq->recovery_needed || !mq->use_cqe || host->hsq_enabled;
139134
spin_unlock_irqrestore(&mq->lock, flags);
140135

141-
return ret;
136+
return ignore_tout ? BLK_EH_RESET_TIMER : mmc_cqe_timed_out(req);
142137
}
143138

144139
static void mmc_mq_recovery_handler(struct work_struct *work)

0 commit comments

Comments
 (0)