blob: 005ece9ac7cb89a0bf4f8c1eb94bba72113ef40a [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>
Linus Walleij304419d2017-05-18 11:29:32 +02006#include <linux/blk-mq.h>
Ulf Hansson066185d2017-01-13 14:14:07 +01007#include <linux/mmc/core.h>
8#include <linux/mmc/host.h>
9
Linus Walleij304419d2017-05-18 11:29:32 +020010static inline struct mmc_queue_req *req_to_mmc_queue_req(struct request *rq)
11{
12 return blk_mq_rq_to_pdu(rq);
13}
14
Mike Christiec2df40d2016-06-05 14:32:17 -050015static inline bool mmc_req_is_special(struct request *req)
16{
Mike Christie3a5e02c2016-06-05 14:32:23 -050017 return req &&
Adrian Hunter7afafc82016-08-16 10:59:35 +030018 (req_op(req) == REQ_OP_FLUSH ||
19 req_op(req) == REQ_OP_DISCARD ||
20 req_op(req) == REQ_OP_SECURE_ERASE);
Mike Christiec2df40d2016-06-05 14:32:17 -050021}
Seungwon Jeonef3a69c72013-03-14 15:17:13 +090022
Linus Torvalds1da177e2005-04-16 15:20:36 -070023struct task_struct;
Linus Walleij7db30282016-11-18 13:36:15 +010024struct mmc_blk_data;
Linus Walleij614f0382017-05-18 11:29:34 +020025struct mmc_blk_ioc_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Per Forlin97868a22011-07-09 17:12:36 -040027struct mmc_blk_request {
28 struct mmc_request mrq;
29 struct mmc_command sbc;
30 struct mmc_command cmd;
31 struct mmc_command stop;
32 struct mmc_data data;
Adrian Hunterb8360a42015-05-07 13:10:24 +030033 int retune_retry_done;
Per Forlin97868a22011-07-09 17:12:36 -040034};
35
36struct mmc_queue_req {
37 struct request *req;
38 struct mmc_blk_request brq;
39 struct scatterlist *sg;
40 char *bounce_buf;
41 struct scatterlist *bounce_sg;
42 unsigned int bounce_sg_len;
Linus Walleij74f5ba32017-02-01 13:47:55 +010043 struct mmc_async_req areq;
Linus Walleij614f0382017-05-18 11:29:34 +020044 int ioc_result;
45 struct mmc_blk_ioc_data *idata;
Per Forlin97868a22011-07-09 17:12:36 -040046};
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048struct mmc_queue {
49 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010050 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 struct semaphore thread_sem;
Linus Walleij9491be52017-02-01 13:47:56 +010052 bool suspended;
Adrian Huntere0097cf2016-11-29 12:09:10 +020053 bool asleep;
Linus Walleij7db30282016-11-18 13:36:15 +010054 struct mmc_blk_data *blkdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 struct request_queue *queue;
Linus Walleij304419d2017-05-18 11:29:32 +020056 /*
57 * FIXME: this counter is not a very reliable way of keeping
58 * track of how many requests that are ongoing. Switch to just
59 * letting the block core keep track of requests and per-request
60 * associated mmc_queue_req data.
61 */
Adrian Huntercdf8a6f2017-03-13 14:36:35 +020062 int qcnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063};
64
Adrian Hunterd09408a2011-06-23 13:40:28 +030065extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
66 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067extern void mmc_cleanup_queue(struct mmc_queue *);
68extern void mmc_queue_suspend(struct mmc_queue *);
69extern void mmc_queue_resume(struct mmc_queue *);
70
Per Forlin97868a22011-07-09 17:12:36 -040071extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
72 struct mmc_queue_req *);
73extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
74extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020075
Chuanxiao Dong4e93b9a2014-08-12 12:01:30 +080076extern int mmc_access_rpmb(struct mmc_queue *);
77
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#endif