Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef MMC_QUEUE_H |
| 2 | #define MMC_QUEUE_H |
| 3 | |
Mike Christie | c2df40d | 2016-06-05 14:32:17 -0500 | [diff] [blame] | 4 | static inline bool mmc_req_is_special(struct request *req) |
| 5 | { |
Mike Christie | 3a5e02c | 2016-06-05 14:32:23 -0500 | [diff] [blame] | 6 | return req && |
| 7 | (req_op(req) == REQ_OP_FLUSH || req_op(req) == REQ_OP_DISCARD); |
Mike Christie | c2df40d | 2016-06-05 14:32:17 -0500 | [diff] [blame] | 8 | } |
Seungwon Jeon | ef3a69c7 | 2013-03-14 15:17:13 +0900 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | struct request; |
| 11 | struct task_struct; |
| 12 | |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 13 | struct mmc_blk_request { |
| 14 | struct mmc_request mrq; |
| 15 | struct mmc_command sbc; |
| 16 | struct mmc_command cmd; |
| 17 | struct mmc_command stop; |
| 18 | struct mmc_data data; |
Adrian Hunter | b8360a4 | 2015-05-07 13:10:24 +0300 | [diff] [blame] | 19 | int retune_retry_done; |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 20 | }; |
| 21 | |
Seungwon Jeon | ce39f9d | 2013-02-06 17:02:46 +0900 | [diff] [blame] | 22 | enum mmc_packed_type { |
| 23 | MMC_PACKED_NONE = 0, |
| 24 | MMC_PACKED_WRITE, |
| 25 | }; |
| 26 | |
| 27 | #define mmc_packed_cmd(type) ((type) != MMC_PACKED_NONE) |
| 28 | #define mmc_packed_wr(type) ((type) == MMC_PACKED_WRITE) |
| 29 | |
| 30 | struct mmc_packed { |
| 31 | struct list_head list; |
| 32 | u32 cmd_hdr[1024]; |
| 33 | unsigned int blocks; |
| 34 | u8 nr_entries; |
| 35 | u8 retries; |
| 36 | s16 idx_failure; |
| 37 | }; |
| 38 | |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 39 | struct mmc_queue_req { |
| 40 | struct request *req; |
| 41 | struct mmc_blk_request brq; |
| 42 | struct scatterlist *sg; |
| 43 | char *bounce_buf; |
| 44 | struct scatterlist *bounce_sg; |
| 45 | unsigned int bounce_sg_len; |
Per Forlin | ee8a43a | 2011-07-01 18:55:33 +0200 | [diff] [blame] | 46 | struct mmc_async_req mmc_active; |
Seungwon Jeon | ce39f9d | 2013-02-06 17:02:46 +0900 | [diff] [blame] | 47 | enum mmc_packed_type cmd_type; |
| 48 | struct mmc_packed *packed; |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 49 | }; |
| 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | struct mmc_queue { |
| 52 | struct mmc_card *card; |
Christoph Hellwig | 87598a2 | 2006-11-13 20:23:52 +0100 | [diff] [blame] | 53 | struct task_struct *thread; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | struct semaphore thread_sem; |
| 55 | unsigned int flags; |
Konstantin Dorfman | 2220eed | 2013-01-14 14:28:17 -0500 | [diff] [blame] | 56 | #define MMC_QUEUE_SUSPENDED (1 << 0) |
| 57 | #define MMC_QUEUE_NEW_REQUEST (1 << 1) |
| 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | int (*issue_fn)(struct mmc_queue *, struct request *); |
| 60 | void *data; |
| 61 | struct request_queue *queue; |
Per Forlin | 04296b7 | 2011-07-01 18:55:31 +0200 | [diff] [blame] | 62 | struct mmc_queue_req mqrq[2]; |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 63 | struct mmc_queue_req *mqrq_cur; |
Per Forlin | 04296b7 | 2011-07-01 18:55:31 +0200 | [diff] [blame] | 64 | struct mmc_queue_req *mqrq_prev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
Adrian Hunter | d09408a | 2011-06-23 13:40:28 +0300 | [diff] [blame] | 67 | extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *, |
| 68 | const char *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | extern void mmc_cleanup_queue(struct mmc_queue *); |
| 70 | extern void mmc_queue_suspend(struct mmc_queue *); |
| 71 | extern void mmc_queue_resume(struct mmc_queue *); |
| 72 | |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 73 | extern unsigned int mmc_queue_map_sg(struct mmc_queue *, |
| 74 | struct mmc_queue_req *); |
| 75 | extern void mmc_queue_bounce_pre(struct mmc_queue_req *); |
| 76 | extern void mmc_queue_bounce_post(struct mmc_queue_req *); |
Pierre Ossman | 98ccf14 | 2007-05-12 00:26:16 +0200 | [diff] [blame] | 77 | |
Seungwon Jeon | ce39f9d | 2013-02-06 17:02:46 +0900 | [diff] [blame] | 78 | extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *); |
| 79 | extern void mmc_packed_clean(struct mmc_queue *); |
| 80 | |
Chuanxiao Dong | 4e93b9a | 2014-08-12 12:01:30 +0800 | [diff] [blame] | 81 | extern int mmc_access_rpmb(struct mmc_queue *); |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #endif |