blob: 9280d1b883460a6a3a9c2c7d57772d290cf5c54a [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
Seungwon Jeon53f8f572012-09-27 15:00:26 +020015enum mmc_packed_cmd {
16 MMC_PACKED_NONE = 0,
17 MMC_PACKED_WRITE,
18};
19
Per Forlincb86e7b2011-07-09 17:12:36 -040020struct mmc_queue_req {
21 struct request *req;
22 struct mmc_blk_request brq;
23 struct scatterlist *sg;
24 char *bounce_buf;
25 struct scatterlist *bounce_sg;
26 unsigned int bounce_sg_len;
Per Forlin91fd00b2011-07-01 18:55:33 +020027 struct mmc_async_req mmc_active;
Seungwon Jeon53f8f572012-09-27 15:00:26 +020028 struct list_head packed_list;
29 u32 packed_cmd_hdr[128];
30 unsigned int packed_blocks;
31 enum mmc_packed_cmd packed_cmd;
32 int packed_retries;
33 int packed_fail_idx;
34 u8 packed_num;
Per Forlincb86e7b2011-07-09 17:12:36 -040035};
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037struct mmc_queue {
38 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010039 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 struct semaphore thread_sem;
41 unsigned int flags;
Konstantin Dorfman9b0f5ec2013-02-12 13:19:48 +020042#define MMC_QUEUE_SUSPENDED (1 << 0)
43#define MMC_QUEUE_NEW_REQUEST (1 << 1)
44#define MMC_QUEUE_URGENT_REQUEST (1 << 2)
Konstantin Dorfman69bd0fb2012-12-12 16:12:08 +020045
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 int (*issue_fn)(struct mmc_queue *, struct request *);
47 void *data;
48 struct request_queue *queue;
Per Forlind07424b2011-07-01 18:55:31 +020049 struct mmc_queue_req mqrq[2];
Per Forlincb86e7b2011-07-09 17:12:36 -040050 struct mmc_queue_req *mqrq_cur;
Per Forlind07424b2011-07-01 18:55:31 +020051 struct mmc_queue_req *mqrq_prev;
Tatyana Brokhman0cc76402012-10-07 09:52:16 +020052 bool wr_packing_enabled;
53 int num_of_potential_packed_wr_reqs;
54 int num_wr_reqs_to_start_packing;
Maya Erez64d12462013-01-06 10:19:38 +020055 bool no_pack_for_random;
Tatyana Brokhman09b010d2012-10-09 13:50:56 +020056 int (*err_check_fn) (struct mmc_card *, struct mmc_async_req *);
57 void (*packed_test_fn) (struct request_queue *, struct mmc_queue_req *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058};
59
Adrian Hunterd09408a2011-06-23 13:40:28 +030060extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
61 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062extern void mmc_cleanup_queue(struct mmc_queue *);
Subhash Jadavanid1c87f12013-02-26 17:32:58 +053063extern int mmc_queue_suspend(struct mmc_queue *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064extern void mmc_queue_resume(struct mmc_queue *);
65
Per Forlincb86e7b2011-07-09 17:12:36 -040066extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
67 struct mmc_queue_req *);
68extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
69extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020070
Tatyana Brokhman09b010d2012-10-09 13:50:56 +020071extern void print_mmc_packing_stats(struct mmc_card *card);
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#endif