blob: dac8c3d010dd9615a576256ec45b2dd7cef5a6f2 [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
25struct mmc_queue_req {
26 struct request *req;
27 struct mmc_blk_request brq;
28 struct scatterlist *sg;
29 char *bounce_buf;
30 struct scatterlist *bounce_sg;
31 unsigned int bounce_sg_len;
Per Forlinee8a43a2011-07-01 18:55:33 +020032 struct mmc_async_req mmc_active;
Per Forlin97868a22011-07-09 17:12:36 -040033};
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035struct mmc_queue {
36 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010037 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 struct semaphore thread_sem;
39 unsigned int flags;
Konstantin Dorfman2220eed2013-01-14 14:28:17 -050040#define MMC_QUEUE_SUSPENDED (1 << 0)
41#define MMC_QUEUE_NEW_REQUEST (1 << 1)
Adrian Huntere0097cf2016-11-29 12:09:10 +020042 bool asleep;
Linus Walleij7db30282016-11-18 13:36:15 +010043 struct mmc_blk_data *blkdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 struct request_queue *queue;
Adrian Hunterc5bda0c2016-11-29 12:09:15 +020045 struct mmc_queue_req *mqrq;
Per Forlin97868a22011-07-09 17:12:36 -040046 struct mmc_queue_req *mqrq_cur;
Per Forlin04296b72011-07-01 18:55:31 +020047 struct mmc_queue_req *mqrq_prev;
Adrian Hunterc5bda0c2016-11-29 12:09:15 +020048 int qdepth;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049};
50
Adrian Hunterd09408a2011-06-23 13:40:28 +030051extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
52 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053extern void mmc_cleanup_queue(struct mmc_queue *);
54extern void mmc_queue_suspend(struct mmc_queue *);
55extern void mmc_queue_resume(struct mmc_queue *);
56
Per Forlin97868a22011-07-09 17:12:36 -040057extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
58 struct mmc_queue_req *);
59extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
60extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020061
Chuanxiao Dong4e93b9a2014-08-12 12:01:30 +080062extern int mmc_access_rpmb(struct mmc_queue *);
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#endif