aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@nokia.com>2010-01-08 17:43:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-01-11 12:34:06 -0500
commit5fa83ce284a4b7cd9dcfadd01500b0ed4ab9b740 (patch)
tree853c2e06c085fba633bcfef2c624a068adf2bbf5 /drivers/mmc
parent0a74ff29b8dd8b748f8856352f9a9b5c6cc362cc (diff)
mmc_block: fix queue cleanup
The main bug was that 'blk_cleanup_queue()' was called while the block device could still be in use, for example, because the card was removed while files were still open. In addition, to be sure that 'mmc_request()' will get called for all new requests (so it can error them out), the queue is emptied during cleanup. This is done after the worker thread is stopped to avoid racing with it. Finally, it is not a device error for this to be happening, so quiet the (sometimes very many) error messages. Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com> Cc: <linux-mmc@vger.kernel.org> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/card/block.c2
-rw-r--r--drivers/mmc/card/queue.c18
2 files changed, 11 insertions, 9 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index ee879117017f..1f552c6e7579 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -91,6 +91,8 @@ static void mmc_blk_put(struct mmc_blk_data *md)
91 if (!devmaj) 91 if (!devmaj)
92 devidx = md->disk->first_minor >> MMC_SHIFT; 92 devidx = md->disk->first_minor >> MMC_SHIFT;
93 93
94 blk_cleanup_queue(md->queue.queue);
95
94 __clear_bit(devidx, dev_use); 96 __clear_bit(devidx, dev_use);
95 97
96 put_disk(md->disk); 98 put_disk(md->disk);
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 49e582356c65..c5a7a855f4b1 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -90,9 +90,10 @@ static void mmc_request(struct request_queue *q)
90 struct request *req; 90 struct request *req;
91 91
92 if (!mq) { 92 if (!mq) {
93 printk(KERN_ERR "MMC: killing requests for dead queue\n"); 93 while ((req = blk_fetch_request(q)) != NULL) {
94 while ((req = blk_fetch_request(q)) != NULL) 94 req->cmd_flags |= REQ_QUIET;
95 __blk_end_request_all(req, -EIO); 95 __blk_end_request_all(req, -EIO);
96 }
96 return; 97 return;
97 } 98 }
98 99
@@ -223,17 +224,18 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
223 struct request_queue *q = mq->queue; 224 struct request_queue *q = mq->queue;
224 unsigned long flags; 225 unsigned long flags;
225 226
226 /* Mark that we should start throwing out stragglers */
227 spin_lock_irqsave(q->queue_lock, flags);
228 q->queuedata = NULL;
229 spin_unlock_irqrestore(q->queue_lock, flags);
230
231 /* Make sure the queue isn't suspended, as that will deadlock */ 227 /* Make sure the queue isn't suspended, as that will deadlock */
232 mmc_queue_resume(mq); 228 mmc_queue_resume(mq);
233 229
234 /* Then terminate our worker thread */ 230 /* Then terminate our worker thread */
235 kthread_stop(mq->thread); 231 kthread_stop(mq->thread);
236 232
233 /* Empty the queue */
234 spin_lock_irqsave(q->queue_lock, flags);
235 q->queuedata = NULL;
236 blk_start_queue(q);
237 spin_unlock_irqrestore(q->queue_lock, flags);
238
237 if (mq->bounce_sg) 239 if (mq->bounce_sg)
238 kfree(mq->bounce_sg); 240 kfree(mq->bounce_sg);
239 mq->bounce_sg = NULL; 241 mq->bounce_sg = NULL;
@@ -245,8 +247,6 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
245 kfree(mq->bounce_buf); 247 kfree(mq->bounce_buf);
246 mq->bounce_buf = NULL; 248 mq->bounce_buf = NULL;
247 249
248 blk_cleanup_queue(mq->queue);
249
250 mq->card = NULL; 250 mq->card = NULL;
251} 251}
252EXPORT_SYMBOL(mmc_cleanup_queue); 252EXPORT_SYMBOL(mmc_cleanup_queue);