blob: d62531124d542c0ff82893ed04226e2a0c04016e [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{
Mike Christie3a5e02c2016-06-05 14:32:23 -05006 return req &&
7 (req_op(req) == REQ_OP_FLUSH || req_op(req) == REQ_OP_DISCARD);
Mike Christiec2df40d2016-06-05 14:32:17 -05008}
Seungwon Jeonef3a69c72013-03-14 15:17:13 +09009
Linus Torvalds1da177e2005-04-16 15:20:36 -070010struct request;
11struct task_struct;
12
Per Forlin97868a22011-07-09 17:12:36 -040013struct mmc_blk_request {
14 struct mmc_request mrq;
15 struct mmc_command sbc;
16 struct mmc_command cmd;
17 struct mmc_command stop;
18 struct mmc_data data;
Adrian Hunterb8360a42015-05-07 13:10:24 +030019 int retune_retry_done;
Per Forlin97868a22011-07-09 17:12:36 -040020};
21
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090022enum mmc_packed_type {
23 MMC_PACKED_NONE = 0,
24 MMC_PACKED_WRITE,
25};
26
27#define mmc_packed_cmd(type) ((type) != MMC_PACKED_NONE)
28#define mmc_packed_wr(type) ((type) == MMC_PACKED_WRITE)
29
30struct mmc_packed {
31 struct list_head list;
32 u32 cmd_hdr[1024];
33 unsigned int blocks;
34 u8 nr_entries;
35 u8 retries;
36 s16 idx_failure;
37};
38
Per Forlin97868a22011-07-09 17:12:36 -040039struct mmc_queue_req {
40 struct request *req;
41 struct mmc_blk_request brq;
42 struct scatterlist *sg;
43 char *bounce_buf;
44 struct scatterlist *bounce_sg;
45 unsigned int bounce_sg_len;
Per Forlinee8a43a2011-07-01 18:55:33 +020046 struct mmc_async_req mmc_active;
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090047 enum mmc_packed_type cmd_type;
48 struct mmc_packed *packed;
Per Forlin97868a22011-07-09 17:12:36 -040049};
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051struct mmc_queue {
52 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010053 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 struct semaphore thread_sem;
55 unsigned int flags;
Konstantin Dorfman2220eed2013-01-14 14:28:17 -050056#define MMC_QUEUE_SUSPENDED (1 << 0)
57#define MMC_QUEUE_NEW_REQUEST (1 << 1)
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 int (*issue_fn)(struct mmc_queue *, struct request *);
60 void *data;
61 struct request_queue *queue;
Per Forlin04296b72011-07-01 18:55:31 +020062 struct mmc_queue_req mqrq[2];
Per Forlin97868a22011-07-09 17:12:36 -040063 struct mmc_queue_req *mqrq_cur;
Per Forlin04296b72011-07-01 18:55:31 +020064 struct mmc_queue_req *mqrq_prev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065};
66
Adrian Hunterd09408a2011-06-23 13:40:28 +030067extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
68 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069extern void mmc_cleanup_queue(struct mmc_queue *);
70extern void mmc_queue_suspend(struct mmc_queue *);
71extern void mmc_queue_resume(struct mmc_queue *);
72
Per Forlin97868a22011-07-09 17:12:36 -040073extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
74 struct mmc_queue_req *);
75extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
76extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020077
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090078extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
79extern void mmc_packed_clean(struct mmc_queue *);
80
Chuanxiao Dong4e93b9a2014-08-12 12:01:30 +080081extern int mmc_access_rpmb(struct mmc_queue *);
82
Linus Torvalds1da177e2005-04-16 15:20:36 -070083#endif