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 | */ | |
12 | #include <linux/module.h> | |
13 | #include <linux/blkdev.h> | |
83144186 | 14 | #include <linux/freezer.h> |
87598a2b | 15 | #include <linux/kthread.h> |
45711f1a | 16 | #include <linux/scatterlist.h> |
1da177e4 LT |
17 | |
18 | #include <linux/mmc/card.h> | |
19 | #include <linux/mmc/host.h> | |
98ac2162 | 20 | #include "queue.h" |
1da177e4 | 21 | |
98ccf149 PO |
22 | #define MMC_QUEUE_BOUNCESZ 65536 |
23 | ||
87598a2b | 24 | #define MMC_QUEUE_SUSPENDED (1 << 0) |
1da177e4 LT |
25 | |
26 | /* | |
9c9f2d63 | 27 | * Prepare a MMC request. This just filters out odd stuff. |
1da177e4 LT |
28 | */ |
29 | static int mmc_prep_request(struct request_queue *q, struct request *req) | |
30 | { | |
9c9f2d63 PO |
31 | /* |
32 | * We only like normal block requests. | |
33 | */ | |
d6d8de33 | 34 | if (!blk_fs_request(req)) { |
1da177e4 | 35 | blk_dump_rq_flags(req, "MMC bad request"); |
9c9f2d63 | 36 | return BLKPREP_KILL; |
1da177e4 LT |
37 | } |
38 | ||
9c9f2d63 | 39 | req->cmd_flags |= REQ_DONTPREP; |
1da177e4 | 40 | |
9c9f2d63 | 41 | return BLKPREP_OK; |
1da177e4 LT |
42 | } |
43 | ||
44 | static int mmc_queue_thread(void *d) | |
45 | { | |
46 | struct mmc_queue *mq = d; | |
47 | struct request_queue *q = mq->queue; | |
1da177e4 | 48 | |
83144186 | 49 | current->flags |= PF_MEMALLOC; |
1da177e4 | 50 | |
1da177e4 | 51 | down(&mq->thread_sem); |
1da177e4 LT |
52 | do { |
53 | struct request *req = NULL; | |
54 | ||
55 | spin_lock_irq(q->queue_lock); | |
56 | set_current_state(TASK_INTERRUPTIBLE); | |
9934c8c0 TH |
57 | if (!blk_queue_plugged(q)) |
58 | req = blk_fetch_request(q); |