blob: aca285046576aa5bfa901e2a28c46e116e7719b0 [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 &&
Adrian Hunter7afafc82016-08-16 10:59:35 +03007 (req_op(req) == REQ_OP_FLUSH ||
8 req_op(req) == REQ_OP_DISCARD ||
9 req_op(req) == REQ_OP_SECURE_ERASE);
Mike Christiec2df40d2016-06-05 14:32:17 -050010}
Seungwon Jeonef3a69c72013-03-14 15:17:13 +090011
Linus Torvalds1da177e2005-04-16 15:20:36 -070012struct request;
13struct task_struct;
Linus Walleij7db30282016-11-18 13:36:15 +010014struct mmc_blk_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Per Forlin97868a22011-07-09 17:12:36 -040016struct mmc_blk_request {
17 struct mmc_request mrq;
18 struct mmc_command sbc;
19 struct mmc_command cmd;
20 struct mmc_command stop;
21 struct mmc_data data;
Adrian Hunterb8360a42015-05-07 13:10:24 +030022 int retune_retry_done;
Per Forlin97868a22011-07-09 17:12:36 -040023};
24
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090025enum mmc_packed_type {
26 MMC_PACKED_NONE = 0,
27 MMC_PACKED_WRITE,
28};
29
30#define mmc_packed_cmd(type) ((type) != MMC_PACKED_NONE)
31#define mmc_packed_wr(type) ((type) == MMC_PACKED_WRITE)
32
33struct mmc_packed {
34 struct list_head list;
Jiri Slaby3f2d2662016-10-03 10:58:28 +020035 __le32 cmd_hdr[1024];
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090036 unsigned int blocks;
37 u8 nr_entries;
38 u8 retries;
39 s16 idx_failure;
40};
41
Per Forlin97868a22011-07-09 17:12:36 -040042struct mmc_queue_req {
43 struct request *req;
44 struct mmc_blk_request brq;
45 struct scatterlist *sg;
46 char *bounce_buf;
47 struct scatterlist *bounce_sg;
48 unsigned int bounce_sg_len;
Per Forlinee8a43a2011-07-01 18:55:33 +020049 struct mmc_async_req mmc_active;
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090050 enum mmc_packed_type cmd_type;
51 struct mmc_packed *packed;
Per Forlin97868a22011-07-09 17:12:36 -040052};
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054struct mmc_queue {
55 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010056 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 struct semaphore thread_sem;
58 unsigned int flags;
Konstantin Dorfman2220eed2013-01-14 14:28:17 -050059#define MMC_QUEUE_SUSPENDED (1 << 0)
60#define MMC_QUEUE_NEW_REQUEST (1 << 1)
Linus Walleij7db30282016-11-18 13:36:15 +010061 struct mmc_blk_data *blkdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 struct request_queue *queue;
Per Forlin04296b72011-07-01 18:55:31 +020063 struct mmc_queue_req mqrq[2];
Per Forlin97868a22011-07-09 17:12:36 -040064 struct mmc_queue_req *mqrq_cur;
Per Forlin04296b72011-07-01 18:55:31 +020065 struct mmc_queue_req *mqrq_prev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066};
67
Adrian Hunterd09408a2011-06-23 13:40:28 +030068extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
69 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070extern void mmc_cleanup_queue(struct mmc_queue *);
71extern void mmc_queue_suspend(struct mmc_queue *);
72extern void mmc_queue_resume(struct mmc_queue *);
73
Per Forlin97868a22011-07-09 17:12:36 -040074extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
75 struct mmc_queue_req *);
76extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
77extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020078
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090079extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
80extern void mmc_packed_clean(struct mmc_queue *);
81
Chuanxiao Dong4e93b9a2014-08-12 12:01:30 +080082extern int mmc_access_rpmb(struct mmc_queue *);
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084#endif