Skip to contentSkip to conversation

mmc: queue: Cancel recovery work on cleanup

PATCH Superseded Christian Löhle 3 participants 3 messages Oct 7, 2022 – Oct 13, 2022 MMC, SD and SDIO

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 mmc: queue: Cancel recovery work on cleanup

To prevent any recovery work running after the queue cleanup cancel it. Any recovery running post-cleanup dereferenced mq->card as NULL and was not meaningful to begin with.

---
-v2: Use cancel instead of flush

 drivers/mmc/core/queue.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mmc/core/queue.c +7 -0
index fefaa901b50f..86be55d7cf55 100644
@@ -493,6 +493,13 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
 	if (blk_queue_quiesced(q))
 		blk_mq_unquiesce_queue(q);
 
+	/*
+	 * If the recovery completes the last (and only remaining) request in
+	 * the queue, and the card has been removed, we could end up here with
+	 * the recovery not quite finished yet, so cancel it.
+	 */
+	cancel_work_sync(&mq->recovery_work);
+
 	blk_mq_free_tag_set(&mq->tag_set);
 
 	/*
Signature · 5 lines
2.37.3

Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782
Acked-by on v2 2/2
#1 lore raw
Quoted 7 lines · Christian Löhle

To prevent any recovery work running after the queue cleanup cancel it. Any recovery running post-cleanup dereferenced mq->card as NULL and was not meaningful to begin with.

Quoted 24 lines

---

(quoted diff) +0 -1
-v2: Use cancel instead of flush
 
 drivers/mmc/core/queue.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mmc/core/queue.c +7 -0
index fefaa901b50f..86be55d7cf55 100644
@@ -493,6 +493,13 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
 	if (blk_queue_quiesced(q))
 		blk_mq_unquiesce_queue(q);
 
+	/*
+	 * If the recovery completes the last (and only remaining) request in
+	 * the queue, and the card has been removed, we could end up here with
+	 * the recovery not quite finished yet, so cancel it.
+	 */
+	cancel_work_sync(&mq->recovery_work);
+
 	blk_mq_free_tag_set(&mq->tag_set);
 
 	/*
#2 lore raw
In reply to Christian Löhle
Quoted 8 lines · Christian Löhle

To prevent any recovery work running after the queue cleanup cancel it. Any recovery running post-cleanup dereferenced mq->card as NULL and was not meaningful to begin with.

Applied for fixes, thanks!

Kind regards
Uffe

Quoted 31 lines

---

(quoted diff) +0 -1
-v2: Use cancel instead of flush
 
 drivers/mmc/core/queue.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mmc/core/queue.c +7 -1
index fefaa901b50f..86be55d7cf55 100644
@@ -493,6 +493,13 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
        if (blk_queue_quiesced(q))
                blk_mq_unquiesce_queue(q);
 
+       /*
+        * If the recovery completes the last (and only remaining) request in
+        * the queue, and the card has been removed, we could end up here with
+        * the recovery not quite finished yet, so cancel it.
+        */
+       cancel_work_sync(&mq->recovery_work);
+
        blk_mq_free_tag_set(&mq->tag_set);
 
        /*
--

2.37.3

Hyperstone GmbH | Reichenaustr. 39a | 78467 Konstanz Managing Director: Dr. Jan Peter Berns. Commercial register of local courts: Freiburg HRB381782