Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef MMC_QUEUE_H |
| 2 | #define MMC_QUEUE_H |
| 3 | |
Ulf Hansson | 066185d | 2017-01-13 14:14:07 +0100 | [diff] [blame] | 4 | #include <linux/types.h> |
| 5 | #include <linux/blkdev.h> |
Linus Walleij | 304419d | 2017-05-18 11:29:32 +0200 | [diff] [blame^] | 6 | #include <linux/blk-mq.h> |
Ulf Hansson | 066185d | 2017-01-13 14:14:07 +0100 | [diff] [blame] | 7 | #include <linux/mmc/core.h> |
| 8 | #include <linux/mmc/host.h> |
| 9 | |
Linus Walleij | 304419d | 2017-05-18 11:29:32 +0200 | [diff] [blame^] | 10 | static 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 Christie | c2df40d | 2016-06-05 14:32:17 -0500 | [diff] [blame] | 15 | static inline bool mmc_req_is_special(struct request *req) |
| 16 | { |
Mike Christie | 3a5e02c | 2016-06-05 14:32:23 -0500 | [diff] [blame] | 17 | return req && |
Adrian Hunter | 7afafc8 | 2016-08-16 10:59:35 +0300 | [diff] [blame] | 18 | (req_op(req) == REQ_OP_FLUSH || |
| 19 | req_op(req) == REQ_OP_DISCARD || |
| 20 | req_op(req) == REQ_OP_SECURE_ERASE); |
Mike Christie | c2df40d | 2016-06-05 14:32:17 -0500 | [diff] [blame] | 21 | } |
Seungwon Jeon | ef3a69c7 | 2013-03-14 15:17:13 +0900 | [diff] [blame] | 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | struct task_struct; |
Linus Walleij | 7db3028 | 2016-11-18 13:36:15 +0100 | [diff] [blame] | 24 | struct mmc_blk_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 26 | struct 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 Hunter | b8360a4 | 2015-05-07 13:10:24 +0300 | [diff] [blame] | 32 | int retune_retry_done; |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | struct mmc_queue_req { |
| 36 | struct request *req; |
| 37 | struct mmc_blk_request brq; |
| 38 | struct scatterlist *sg; |
| 39 | char *bounce_buf; |
| 40 | struct scatterlist *bounce_sg; |
| 41 | unsigned int bounce_sg_len; |
Linus Walleij | 74f5ba3 | 2017-02-01 13:47:55 +0100 | [diff] [blame] | 42 | struct mmc_async_req areq; |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 43 | }; |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | struct mmc_queue { |
| 46 | struct mmc_card *card; |
Christoph Hellwig | 87598a2 | 2006-11-13 20:23:52 +0100 | [diff] [blame] | 47 | struct task_struct *thread; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | struct semaphore thread_sem; |
Linus Walleij | 9491be5 | 2017-02-01 13:47:56 +0100 | [diff] [blame] | 49 | bool suspended; |
Adrian Hunter | e0097cf | 2016-11-29 12:09:10 +0200 | [diff] [blame] | 50 | bool asleep; |
Linus Walleij | 7db3028 | 2016-11-18 13:36:15 +0100 | [diff] [blame] | 51 | struct mmc_blk_data *blkdata; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | struct request_queue *queue; |
Linus Walleij | 304419d | 2017-05-18 11:29:32 +0200 | [diff] [blame^] | 53 | /* |
| 54 | * FIXME: this counter is not a very reliable way of keeping |
| 55 | * track of how many requests that are ongoing. Switch to just |
| 56 | * letting the block core keep track of requests and per-request |
| 57 | * associated mmc_queue_req data. |
| 58 | */ |
Adrian Hunter | cdf8a6f | 2017-03-13 14:36:35 +0200 | [diff] [blame] | 59 | int qcnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
Adrian Hunter | d09408a | 2011-06-23 13:40:28 +0300 | [diff] [blame] | 62 | extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *, |
| 63 | const char *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | extern void mmc_cleanup_queue(struct mmc_queue *); |
| 65 | extern void mmc_queue_suspend(struct mmc_queue *); |
| 66 | extern void mmc_queue_resume(struct mmc_queue *); |
| 67 | |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 68 | extern unsigned int mmc_queue_map_sg(struct mmc_queue *, |
| 69 | struct mmc_queue_req *); |
| 70 | extern void mmc_queue_bounce_pre(struct mmc_queue_req *); |
| 71 | extern void mmc_queue_bounce_post(struct mmc_queue_req *); |
Pierre Ossman | 98ccf14 | 2007-05-12 00:26:16 +0200 | [diff] [blame] | 72 | |
Chuanxiao Dong | 4e93b9a | 2014-08-12 12:01:30 +0800 | [diff] [blame] | 73 | extern int mmc_access_rpmb(struct mmc_queue *); |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #endif |