blob: 1e6062eb3e07062714ccb16517bff9b71fe1edad [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
Linus Walleij67e69d52017-05-19 15:37:27 +020015struct mmc_queue_req;
16
17static inline struct request *mmc_queue_req_to_req(struct mmc_queue_req *mqr)
18{
19 return blk_mq_rq_from_pdu(mqr);
20}
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022struct task_struct;
Linus Walleij7db30282016-11-18 13:36:15 +010023struct mmc_blk_data;
Linus Walleij614f0382017-05-18 11:29:34 +020024struct mmc_blk_ioc_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Per Forlin97868a22011-07-09 17:12:36 -040026struct mmc_blk_request {
27 struct mmc_request mrq;
28 struct mmc_command sbc;
29 struct mmc_command cmd;
30 struct mmc_command stop;
31 struct mmc_data data;
Adrian Hunterb8360a42015-05-07 13:10:24 +030032 int retune_retry_done;
Per Forlin97868a22011-07-09 17:12:36 -040033};
34
Linus Walleij02166a02017-05-19 15:37:28 +020035/**
36 * enum mmc_drv_op - enumerates the operations in the mmc_queue_req
37 * @MMC_DRV_OP_IOCTL: ioctl operation
38 */
39enum mmc_drv_op {
40 MMC_DRV_OP_IOCTL,
41};
42
Per Forlin97868a22011-07-09 17:12:36 -040043struct mmc_queue_req {
Per Forlin97868a22011-07-09 17:12:36 -040044 struct mmc_blk_request brq;
45 struct scatterlist *sg;
46 char *bounce_buf;
47 struct scatterlist *bounce_sg;
48 unsigned int bounce_sg_len;
Linus Walleij74f5ba32017-02-01 13:47:55 +010049 struct mmc_async_req areq;
Linus Walleij02166a02017-05-19 15:37:28 +020050 enum mmc_drv_op drv_op;
Linus Walleij614f0382017-05-18 11:29:34 +020051 int ioc_result;
Linus Walleij3ecd8cf2017-05-18 11:29:35 +020052 struct mmc_blk_ioc_data **idata;
53 unsigned int ioc_count;
Per Forlin97868a22011-07-09 17:12:36 -040054};
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056struct mmc_queue {
57 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010058 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 struct semaphore thread_sem;
Linus Walleij9491be52017-02-01 13:47:56 +010060 bool suspended;
Adrian Huntere0097cf2016-11-29 12:09:10 +020061 bool asleep;
Linus Walleij7db30282016-11-18 13:36:15 +010062 struct mmc_blk_data *blkdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 struct request_queue *queue;
Linus Walleij304419d2017-05-18 11:29:32 +020064 /*
65 * FIXME: this counter is not a very reliable way of keeping
66 * track of how many requests that are ongoing. Switch to just
67 * letting the block core keep track of requests and per-request
68 * associated mmc_queue_req data.
69 */
Adrian Huntercdf8a6f2017-03-13 14:36:35 +020070 int qcnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071};
72
Adrian Hunterd09408a2011-06-23 13:40:28 +030073extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
74 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075extern void mmc_cleanup_queue(struct mmc_queue *);
76extern void mmc_queue_suspend(struct mmc_queue *);
77extern void mmc_queue_resume(struct mmc_queue *);
78
Per Forlin97868a22011-07-09 17:12:36 -040079extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
80 struct mmc_queue_req *);
81extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
82extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020083
Chuanxiao Dong4e93b9a2014-08-12 12:01:30 +080084extern int mmc_access_rpmb(struct mmc_queue *);
85
Linus Torvalds1da177e2005-04-16 15:20:36 -070086#endif