blob: e298f100101b9c3807dc0249bc2412b0f64bb77e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef MMC_QUEUE_H
2#define MMC_QUEUE_H
3
Ulf Hansson066185d2017-01-13 14:14:07 +01004#include <linux/types.h>
5#include <linux/blkdev.h>
6#include <linux/mmc/core.h>
7#include <linux/mmc/host.h>
8
Mike Christiec2df40d2016-06-05 14:32:17 -05009static inline bool mmc_req_is_special(struct request *req)
10{
Mike Christie3a5e02c2016-06-05 14:32:23 -050011 return req &&
Adrian Hunter7afafc82016-08-16 10:59:35 +030012 (req_op(req) == REQ_OP_FLUSH ||
13 req_op(req) == REQ_OP_DISCARD ||
14 req_op(req) == REQ_OP_SECURE_ERASE);
Mike Christiec2df40d2016-06-05 14:32:17 -050015}
Seungwon Jeonef3a69c72013-03-14 15:17:13 +090016
Linus Torvalds1da177e2005-04-16 15:20:36 -070017struct task_struct;
Linus Walleij7db30282016-11-18 13:36:15 +010018struct mmc_blk_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Per Forlin97868a22011-07-09 17:12:36 -040020struct mmc_blk_request {
21 struct mmc_request mrq;
22 struct mmc_command sbc;
23 struct mmc_command cmd;
24 struct mmc_command stop;
25 struct mmc_data data;
Adrian Hunterb8360a42015-05-07 13:10:24 +030026 int retune_retry_done;
Per Forlin97868a22011-07-09 17:12:36 -040027};
28
29struct mmc_queue_req {
30 struct request *req;
31 struct mmc_blk_request brq;
32 struct scatterlist *sg;
33 char *bounce_buf;
34 struct scatterlist *bounce_sg;
35 unsigned int bounce_sg_len;
Linus Walleij74f5ba32017-02-01 13:47:55 +010036 struct mmc_async_req areq;
Per Forlin97868a22011-07-09 17:12:36 -040037};
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039struct mmc_queue {
40 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010041 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 struct semaphore thread_sem;
Linus Walleij9491be52017-02-01 13:47:56 +010043 bool new_request;
44 bool suspended;
Adrian Huntere0097cf2016-11-29 12:09:10 +020045 bool asleep;
Linus Walleij7db30282016-11-18 13:36:15 +010046 struct mmc_blk_data *blkdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 struct request_queue *queue;
Adrian Hunterc5bda0c2016-11-29 12:09:15 +020048 struct mmc_queue_req *mqrq;
Per Forlin97868a22011-07-09 17:12:36 -040049 struct mmc_queue_req *mqrq_cur;
Per Forlin04296b72011-07-01 18:55:31 +020050 struct mmc_queue_req *mqrq_prev;
Adrian Hunterc5bda0c2016-11-29 12:09:15 +020051 int qdepth;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052};
53
Adrian Hunterd09408a2011-06-23 13:40:28 +030054extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
55 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056extern void mmc_cleanup_queue(struct mmc_queue *);
57extern void mmc_queue_suspend(struct mmc_queue *);
58extern void mmc_queue_resume(struct mmc_queue *);
59
Per Forlin97868a22011-07-09 17:12:36 -040060extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
61 struct mmc_queue_req *);
62extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
63extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020064
Chuanxiao Dong4e93b9a2014-08-12 12:01:30 +080065extern int mmc_access_rpmb(struct mmc_queue *);
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#endif