mmc_block: be prepared for oversized requests
authorPierre Ossman <pierre@ossman.eu>
Fri, 10 Apr 2009 15:52:57 +0000 (17:52 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Mon, 31 Jan 2011 23:49:52 +0000 (01:49 +0200)
The block layer does not support very low sector count restrictions
so we need to be prepared to handle bigger requests than we can send
directly to the controller.

Problem found by Manuel Lauss.

Signed-off-by: Pierre Ossman <pierre@ossman.eu>
drivers/mmc/card/block.c

index fd30abc..6ffea7b 100644 (file)
@@ -253,6 +253,14 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
                brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
                brq.data.blocks = req->nr_sectors;
 
+               /*
+                * The block layer doesn't support all sector count
+                * restrictions, so we need to be prepared for too big
+                * requests.
+                */
+               if (brq.data.blocks > card->host->max_blk_count)
+                       brq.data.blocks = card->host->max_blk_count;
+
                /*
                 * After a read error, we redo the request one sector at a time
                 * in order to accurately determine which sectors can be read