From 89b4e133afea9fce333054b94d89953583a55c19 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 14 Nov 2006 22:08:16 +0100 Subject: mmc: Flush block queue when removing card After mmc_block's remove function has exited, we must not touch the card structure in any way. This means we not only must remove the gendisk, we must also flush out any remaning requests already queued up. We previously removed the disk, but didn't flush it, causing oops:es when removing a card in the middle of a transfer. Signed-off-by: Pierre Ossman --- drivers/mmc/mmc_block.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/mmc/mmc_block.c') diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c index f9027c8db79..5025abebfc8 100644 --- a/drivers/mmc/mmc_block.c +++ b/drivers/mmc/mmc_block.c @@ -83,7 +83,6 @@ static void mmc_blk_put(struct mmc_blk_data *md) md->usage--; if (md->usage == 0) { put_disk(md->disk); - mmc_cleanup_queue(&md->queue); kfree(md); } mutex_unlock(&open_lock); @@ -553,12 +552,11 @@ static void mmc_blk_remove(struct mmc_card *card) if (md) { int devidx; + /* Stop new requests from getting into the queue */ del_gendisk(md->disk); - /* - * I think this is needed. - */ - md->disk->queue = NULL; + /* Then flush out any already in there */ + mmc_cleanup_queue(&md->queue); devidx = md->disk->first_minor >> MMC_SHIFT; __clear_bit(devidx, dev_use); -- cgit v1.2.3-70-g09d2 From 8b7feff881b7e9f065ddd718a6841121207c3c19 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 14 Nov 2006 22:13:13 +0100 Subject: mmc: correct request error handling We need to jump to the part of just flushing the request when we cannot claim the bus. Sending commands to a bus we do not own will give unpredictable results. Signed-off-by: Pierre Ossman --- drivers/mmc/mmc_block.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/mmc/mmc_block.c') diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c index 5025abebfc8..87713572293 100644 --- a/drivers/mmc/mmc_block.c +++ b/drivers/mmc/mmc_block.c @@ -224,10 +224,10 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) struct mmc_blk_data *md = mq->data; struct mmc_card *card = md->queue.card; struct mmc_blk_request brq; - int ret; + int ret = 1; if (mmc_card_claim_host(card)) - goto cmd_err; + goto flush_queue; do { struct mmc_command cmd; @@ -344,8 +344,6 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) return 1; cmd_err: - ret = 1; - /* * If this is an SD card and we're writing, we can first * mark the known good sectors as ok. @@ -379,6 +377,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) mmc_card_release_host(card); +flush_queue: spin_lock_irq(&md->lock); while (ret) { ret = end_that_request_chunk(req, 0, -- cgit v1.2.3-70-g09d2