Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
320ae51f JA |
2 | #ifndef INT_BLK_MQ_TAG_H |
3 | #define INT_BLK_MQ_TAG_H | |
4 | ||
2e9bc346 CH |
5 | struct blk_mq_alloc_data; |
6 | ||
24d2f903 CH |
7 | /* |
8 | * Tag address space map. | |
9 | */ | |
10 | struct blk_mq_tags { | |
11 | unsigned int nr_tags; | |
12 | unsigned int nr_reserved_tags; | |
24d2f903 | 13 | |
0d2602ca JA |
14 | atomic_t active_queues; |
15 | ||
ae0f1a73 JG |
16 | struct sbitmap_queue bitmap_tags; |
17 | struct sbitmap_queue breserved_tags; | |
24d2f903 CH |
18 | |
19 | struct request **rqs; | |
2af8cbe3 | 20 | struct request **static_rqs; |
24d2f903 | 21 | struct list_head page_list; |
bd63141d ML |
22 | |
23 | /* | |
24 | * used to clear request reference in rqs[] before freeing one | |
25 | * request pool | |
26 | */ | |
27 | spinlock_t lock; | |
24d2f903 CH |
28 | }; |
29 | ||
1c0706a7 JG |
30 | extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags, |
31 | unsigned int reserved_tags, | |
e155b0c2 JG |
32 | int node, int alloc_policy); |
33 | extern void blk_mq_free_tags(struct blk_mq_tags *tags); | |
56b68085 JG |
34 | extern int blk_mq_init_bitmaps(struct sbitmap_queue *bitmap_tags, |
35 | struct sbitmap_queue *breserved_tags, | |
36 | unsigned int queue_depth, | |
37 | unsigned int reserved, | |
38 | int node, int alloc_policy); | |
320ae51f | 39 | |
cb96a42c | 40 | extern unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data); |
cae740a0 JG |
41 | extern void blk_mq_put_tag(struct blk_mq_tags *tags, struct blk_mq_ctx *ctx, |
42 | unsigned int tag); | |
70f36b60 JA |
43 | extern int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx, |
44 | struct blk_mq_tags **tags, | |
45 | unsigned int depth, bool can_grow); | |
32bc15af JG |
46 | extern void blk_mq_tag_resize_shared_sbitmap(struct blk_mq_tag_set *set, |
47 | unsigned int size); | |
a7e7388d | 48 | extern void blk_mq_tag_update_sched_shared_sbitmap(struct request_queue *q); |
32bc15af | 49 | |
aed3ea94 | 50 | extern void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags, bool); |
0bf6cd5b CH |
51 | void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn, |
52 | void *priv); | |
602380d2 ML |
53 | void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn, |
54 | void *priv); | |
320ae51f | 55 | |
88459642 OS |
56 | static inline struct sbq_wait_state *bt_wait_ptr(struct sbitmap_queue *bt, |
57 | struct blk_mq_hw_ctx *hctx) | |
58 | { | |
59 | if (!hctx) | |
60 | return &bt->ws[0]; | |
61 | return sbq_wait_ptr(bt, &hctx->wait_index); | |
62 | } | |
63 | ||
320ae51f | 64 | enum { |
419c3d5e | 65 | BLK_MQ_NO_TAG = -1U, |
5385fa47 | 66 | BLK_MQ_TAG_MIN = 1, |
419c3d5e | 67 | BLK_MQ_TAG_MAX = BLK_MQ_NO_TAG - 1, |
320ae51f JA |
68 | }; |
69 | ||
0d2602ca JA |
70 | extern bool __blk_mq_tag_busy(struct blk_mq_hw_ctx *); |
71 | extern void __blk_mq_tag_idle(struct blk_mq_hw_ctx *); | |
72 | ||
73 | static inline bool blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx) | |
74 | { | |
51db1c37 | 75 | if (!(hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED)) |
0d2602ca JA |
76 | return false; |
77 | ||
78 | return __blk_mq_tag_busy(hctx); | |
79 | } | |
80 | ||
81 | static inline void blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx) | |
82 | { | |
51db1c37 | 83 | if (!(hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED)) |
0d2602ca JA |
84 | return; |
85 | ||
86 | __blk_mq_tag_idle(hctx); | |
87 | } | |
88 | ||
415b806d SG |
89 | static inline bool blk_mq_tag_is_reserved(struct blk_mq_tags *tags, |
90 | unsigned int tag) | |
91 | { | |
92 | return tag < tags->nr_reserved_tags; | |
93 | } | |
94 | ||
320ae51f | 95 | #endif |