Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
70f10482 | 2 | * linux/drivers/mmc/card/queue.c |
1da177e4 LT |
3 | * |
4 | * Copyright (C) 2003 Russell King, All Rights Reserved. | |
98ac2162 | 5 | * Copyright 2006-2007 Pierre Ossman |
1da177e4 LT |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | * | |
11 | */ | |
5a0e3ad6 | 12 | #include <linux/slab.h> |
1da177e4 LT |
13 | #include <linux/module.h> |
14 | #include <linux/blkdev.h> | |
83144186 | 15 | #include <linux/freezer.h> |
87598a2b | 16 | #include <linux/kthread.h> |
45711f1a | 17 | #include <linux/scatterlist.h> |
1da177e4 LT |
18 | |
19 | #include <linux/mmc/card.h> | |
20 | #include <linux/mmc/host.h> | |
98ac2162 | 21 | #include "queue.h" |
1da177e4 | 22 | |
98ccf149 PO |
23 | #define MMC_QUEUE_BOUNCESZ 65536 |
24 | ||
87598a2b | 25 | #define MMC_QUEUE_SUSPENDED (1 << 0) |
1da177e4 LT |
26 | |
27 | /* | |
9c9f2d63 | 28 | * Prepare a MMC request. This just filters out odd stuff. |
1da177e4 LT |
29 | */ |
30 | static int mmc_prep_request(struct request_queue *q, struct request *req) | |
31 | { | |
9c9f2d63 | 32 | /* |
bd788c96 | 33 | * We only like normal block requests and discards. |
9c9f2d63 | 34 | */ |
bd788c96 | 35 | if (req->cmd_type != REQ_TYPE_FS && !(req->cmd_flags & REQ_DISCARD)) { |
1da177e4 | 36 | blk_dump_rq_flags(req, "MMC bad request"); |
9c9f2d63 | 37 | return BLKPREP_KILL; |
1da177e4 LT |
38 | } |
39 | ||
9c9f2d63 | 40 | req->cmd_flags |= REQ_DONTPREP; |
1da177e4 | 41 | |
9c9f2d63 | 42 | return BLKPREP_OK; |
1da177e4 LT |
43 | } |
44 | ||
45 | static int mmc_queue_thread(void *d) | |
46 | { | |
47 | struct mmc_queue *mq = d; | |
48 | struct request_queue *q = mq->queue; | |
1da177e4 | 49 | |
83144186 | 50 | current->flags |= PF_MEMALLOC; |
1da177e4 | 51 | |
1da177e4 | 52 | down(&mq->thread_sem); |
1da177e4 LT |
53 | do { |
54 | struct request *req = NULL; | |
55 | ||
56 | spin_lock_irq(q->queue_lock); | |
57 | set_current_state(TASK_INTERRUPTIBLE); | |
9934c8c0 TH |
58 | if (!blk_queue_plugged(q)) |
59 | req = blk_fetch_request(q); |