1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef LINUX_MMC_HSQ_H
3 #define LINUX_MMC_HSQ_H
4 
5 #define HSQ_NUM_SLOTS	64
6 #define HSQ_INVALID_TAG	HSQ_NUM_SLOTS
7 
8 /*
9  * For MMC host software queue, we only allow 2 requests in
10  * flight to avoid a long latency.
11  */
12 #define HSQ_NORMAL_DEPTH	2
13 /*
14  * For 4k random writes, we allow hsq_depth to increase to 5
15  * for better performance.
16  */
17 #define HSQ_PERFORMANCE_DEPTH	5
18 
19 struct hsq_slot {
20 	struct mmc_request *mrq;
21 };
22 
23 struct mmc_hsq {
24 	struct mmc_host *mmc;
25 	struct mmc_request *mrq;
26 	wait_queue_head_t wait_queue;
27 	struct hsq_slot *slot;
28 	spinlock_t lock;
29 	struct work_struct retry_work;
30 
31 	int next_tag;
32 	int num_slots;
33 	int qcnt;
34 	int tail_tag;
35 	int tag_slot[HSQ_NUM_SLOTS];
36 
37 	bool enabled;
38 	bool waiting_for_idle;
39 	bool recovery_halt;
40 };
41 
42 int mmc_hsq_init(struct mmc_hsq *hsq, struct mmc_host *mmc);
43 void mmc_hsq_suspend(struct mmc_host *mmc);
44 int mmc_hsq_resume(struct mmc_host *mmc);
45 bool mmc_hsq_finalize_request(struct mmc_host *mmc, struct mmc_request *mrq);
46 
47 #endif
48