blob: a8c104ed7425ac7554bbf37c0b3fc760fd0c2eca [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef MMC_QUEUE_H
2#define MMC_QUEUE_H
3
4struct request;
5struct task_struct;
6
Per Forlincb86e7b2011-07-09 17:12:36 -04007struct mmc_blk_request {
8 struct mmc_request mrq;
9 struct mmc_command sbc;
10 struct mmc_command cmd;
11 struct mmc_command stop;
12 struct mmc_data data;
13};
14
Tatyana Brokhman60aaa642012-10-09 13:50:56 +020015enum mmc_blk_status {
16 MMC_BLK_SUCCESS = 0,
17 MMC_BLK_PARTIAL,
18 MMC_BLK_CMD_ERR,
19 MMC_BLK_RETRY,
20 MMC_BLK_ABORT,
21 MMC_BLK_DATA_ERR,
22 MMC_BLK_ECC_ERR,
23 MMC_BLK_NOMEDIUM,
24};
25
Seungwon Jeon121b8e82012-09-27 15:00:26 +020026enum mmc_packed_cmd {
27 MMC_PACKED_NONE = 0,
28 MMC_PACKED_WRITE,
29};
30
Per Forlincb86e7b2011-07-09 17:12:36 -040031struct mmc_queue_req {
32 struct request *req;
33 struct mmc_blk_request brq;
34 struct scatterlist *sg;
35 char *bounce_buf;
36 struct scatterlist *bounce_sg;
37 unsigned int bounce_sg_len;
Per Forlin91fd00b2011-07-01 18:55:33 +020038 struct mmc_async_req mmc_active;
Seungwon Jeon121b8e82012-09-27 15:00:26 +020039 struct list_head packed_list;
40 u32 packed_cmd_hdr[128];
41 unsigned int packed_blocks;
42 enum mmc_packed_cmd packed_cmd;
43 int packed_retries;
44 int packed_fail_idx;
45 u8 packed_num;
Per Forlincb86e7b2011-07-09 17:12:36 -040046};
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048struct mmc_queue {
49 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010050 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 struct semaphore thread_sem;
52 unsigned int flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 int (*issue_fn)(struct mmc_queue *, struct request *);
54 void *data;
55 struct request_queue *queue;
Per Forlind07424b2011-07-01 18:55:31 +020056 struct mmc_queue_req mqrq[2];
Per Forlincb86e7b2011-07-09 17:12:36 -040057 struct mmc_queue_req *mqrq_cur;
Per Forlind07424b2011-07-01 18:55:31 +020058 struct mmc_queue_req *mqrq_prev;
Tatyana Brokhman98e67812012-10-07 09:52:16 +020059 bool wr_packing_enabled;
60 int num_of_potential_packed_wr_reqs;
61 int num_wr_reqs_to_start_packing;
Tatyana Brokhman60aaa642012-10-09 13:50:56 +020062 int (*err_check_fn) (struct mmc_card *, struct mmc_async_req *);
63 void (*packed_test_fn) (struct request_queue *, struct mmc_queue_req *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064};
65
Adrian Hunterd09408a2011-06-23 13:40:28 +030066extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
67 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068extern void mmc_cleanup_queue(struct mmc_queue *);
69extern void mmc_queue_suspend(struct mmc_queue *);
70extern void mmc_queue_resume(struct mmc_queue *);
71
Per Forlincb86e7b2011-07-09 17:12:36 -040072extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
73 struct mmc_queue_req *);
74extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
75extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020076
Tatyana Brokhman60aaa642012-10-09 13:50:56 +020077extern void print_mmc_packing_stats(struct mmc_card *card);
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#endif