blob: 9fb26f20a44d4d5bc414e284c4a2ed456a49c3ef [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef MMC_QUEUE_H
2#define MMC_QUEUE_H
3
Mike Christiec2df40d2016-06-05 14:32:17 -05004static inline bool mmc_req_is_special(struct request *req)
5{
6 return req && (req->cmd_flags & REQ_FLUSH || req_op(req) == REQ_OP_DISCARD);
7}
Seungwon Jeonef3a69c72013-03-14 15:17:13 +09008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009struct request;
10struct task_struct;
11
Per Forlin97868a22011-07-09 17:12:36 -040012struct mmc_blk_request {
13 struct mmc_request mrq;
14 struct mmc_command sbc;
15 struct mmc_command cmd;
16 struct mmc_command stop;
17 struct mmc_data data;
Adrian Hunterb8360a42015-05-07 13:10:24 +030018 int retune_retry_done;
Per Forlin97868a22011-07-09 17:12:36 -040019};
20
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090021enum mmc_packed_type {
22 MMC_PACKED_NONE = 0,
23 MMC_PACKED_WRITE,
24};
25
26#define mmc_packed_cmd(type) ((type) != MMC_PACKED_NONE)
27#define mmc_packed_wr(type) ((type) == MMC_PACKED_WRITE)
28
29struct mmc_packed {
30 struct list_head list;
31 u32 cmd_hdr[1024];
32 unsigned int blocks;
33 u8 nr_entries;
34 u8 retries;
35 s16 idx_failure;
36};
37
Per Forlin97868a22011-07-09 17:12:36 -040038struct mmc_queue_req {
39 struct request *req;
40 struct mmc_blk_request brq;
41 struct scatterlist *sg;
42 char *bounce_buf;
43 struct scatterlist *bounce_sg;
44 unsigned int bounce_sg_len;
Per Forlinee8a43a2011-07-01 18:55:33 +020045 struct mmc_async_req mmc_active;
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090046 enum mmc_packed_type cmd_type;
47 struct mmc_packed *packed;
Per Forlin97868a22011-07-09 17:12:36 -040048};
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050struct mmc_queue {
51 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010052 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 struct semaphore thread_sem;
54 unsigned int flags;
Konstantin Dorfman2220eed2013-01-14 14:28:17 -050055#define MMC_QUEUE_SUSPENDED (1 << 0)
56#define MMC_QUEUE_NEW_REQUEST (1 << 1)
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 int (*issue_fn)(struct mmc_queue *, struct request *);
59 void *data;
60 struct request_queue *queue;
Per Forlin04296b72011-07-01 18:55:31 +020061 struct mmc_queue_req mqrq[2];
Per Forlin97868a22011-07-09 17:12:36 -040062 struct mmc_queue_req *mqrq_cur;
Per Forlin04296b72011-07-01 18:55:31 +020063 struct mmc_queue_req *mqrq_prev;
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 Forlin97868a22011-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
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090077extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
78extern void mmc_packed_clean(struct mmc_queue *);
79
Chuanxiao Dong4e93b9a2014-08-12 12:01:30 +080080extern int mmc_access_rpmb(struct mmc_queue *);
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#endif