Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/module.h> |
| 3 | #include <linux/backing-dev.h> |
| 4 | #include <linux/bio.h> |
| 5 | #include <linux/blkdev.h> |
| 6 | #include <linux/mm.h> |
| 7 | #include <linux/init.h> |
| 8 | #include <linux/slab.h> |
| 9 | #include <linux/workqueue.h> |
| 10 | #include <linux/smp.h> |
| 11 | |
| 12 | #include <linux/blk-mq.h> |
| 13 | #include "blk-mq.h" |
| 14 | #include "blk-mq-tag.h" |
| 15 | |
| 16 | static void blk_mq_sysfs_release(struct kobject *kobj) |
| 17 | { |
| 18 | } |
| 19 | |
Ming Lei | 6c8b232 | 2017-02-22 18:14:01 +0800 | [diff] [blame^] | 20 | static void blk_mq_hw_sysfs_release(struct kobject *kobj) |
| 21 | { |
| 22 | struct blk_mq_hw_ctx *hctx = container_of(kobj, struct blk_mq_hw_ctx, |
| 23 | kobj); |
| 24 | kfree(hctx->ctxs); |
| 25 | kfree(hctx); |
| 26 | } |
| 27 | |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 28 | struct blk_mq_ctx_sysfs_entry { |
| 29 | struct attribute attr; |
| 30 | ssize_t (*show)(struct blk_mq_ctx *, char *); |
| 31 | ssize_t (*store)(struct blk_mq_ctx *, const char *, size_t); |
| 32 | }; |
| 33 | |
| 34 | struct blk_mq_hw_ctx_sysfs_entry { |
| 35 | struct attribute attr; |
| 36 | ssize_t (*show)(struct blk_mq_hw_ctx *, char *); |
| 37 | ssize_t (*store)(struct blk_mq_hw_ctx *, const char *, size_t); |
| 38 | }; |
| 39 | |
| 40 | static ssize_t blk_mq_sysfs_show(struct kobject *kobj, struct attribute *attr, |
| 41 | char *page) |
| 42 | { |
| 43 | struct blk_mq_ctx_sysfs_entry *entry; |
| 44 | struct blk_mq_ctx *ctx; |
| 45 | struct request_queue *q; |
| 46 | ssize_t res; |
| 47 | |
| 48 | entry = container_of(attr, struct blk_mq_ctx_sysfs_entry, attr); |
| 49 | ctx = container_of(kobj, struct blk_mq_ctx, kobj); |
| 50 | q = ctx->queue; |
| 51 | |
| 52 | if (!entry->show) |
| 53 | return -EIO; |
| 54 | |
| 55 | res = -ENOENT; |
| 56 | mutex_lock(&q->sysfs_lock); |
| 57 | if (!blk_queue_dying(q)) |
| 58 | res = entry->show(ctx, page); |
| 59 | mutex_unlock(&q->sysfs_lock); |
| 60 | return res; |
| 61 | } |
| 62 | |
| 63 | static ssize_t blk_mq_sysfs_store(struct kobject *kobj, struct attribute *attr, |
| 64 | const char *page, size_t length) |
| 65 | { |
| 66 | struct blk_mq_ctx_sysfs_entry *entry; |
| 67 | struct blk_mq_ctx *ctx; |
| 68 | struct request_queue *q; |
| 69 | ssize_t res; |
| 70 | |
| 71 | entry = container_of(attr, struct blk_mq_ctx_sysfs_entry, attr); |
| 72 | ctx = container_of(kobj, struct blk_mq_ctx, kobj); |
| 73 | q = ctx->queue; |
| 74 | |
| 75 | if (!entry->store) |
| 76 | return -EIO; |
| 77 | |
| 78 | res = -ENOENT; |
| 79 | mutex_lock(&q->sysfs_lock); |
| 80 | if (!blk_queue_dying(q)) |
| 81 | res = entry->store(ctx, page, length); |
| 82 | mutex_unlock(&q->sysfs_lock); |
| 83 | return res; |
| 84 | } |
| 85 | |
| 86 | static ssize_t blk_mq_hw_sysfs_show(struct kobject *kobj, |
| 87 | struct attribute *attr, char *page) |
| 88 | { |
| 89 | struct blk_mq_hw_ctx_sysfs_entry *entry; |
| 90 | struct blk_mq_hw_ctx *hctx; |
| 91 | struct request_queue *q; |
| 92 | ssize_t res; |
| 93 | |
| 94 | entry = container_of(attr, struct blk_mq_hw_ctx_sysfs_entry, attr); |
| 95 | hctx = container_of(kobj, struct blk_mq_hw_ctx, kobj); |
| 96 | q = hctx->queue; |
| 97 | |
| 98 | if (!entry->show) |
| 99 | return -EIO; |
| 100 | |
| 101 | res = -ENOENT; |
| 102 | mutex_lock(&q->sysfs_lock); |
| 103 | if (!blk_queue_dying(q)) |
| 104 | res = entry->show(hctx, page); |
| 105 | mutex_unlock(&q->sysfs_lock); |
| 106 | return res; |
| 107 | } |
| 108 | |
| 109 | static ssize_t blk_mq_hw_sysfs_store(struct kobject *kobj, |
| 110 | struct attribute *attr, const char *page, |
| 111 | size_t length) |
| 112 | { |
| 113 | struct blk_mq_hw_ctx_sysfs_entry *entry; |
| 114 | struct blk_mq_hw_ctx *hctx; |
| 115 | struct request_queue *q; |
| 116 | ssize_t res; |
| 117 | |
| 118 | entry = container_of(attr, struct blk_mq_hw_ctx_sysfs_entry, attr); |
| 119 | hctx = container_of(kobj, struct blk_mq_hw_ctx, kobj); |
| 120 | q = hctx->queue; |
| 121 | |
| 122 | if (!entry->store) |
| 123 | return -EIO; |
| 124 | |
| 125 | res = -ENOENT; |
| 126 | mutex_lock(&q->sysfs_lock); |
| 127 | if (!blk_queue_dying(q)) |
| 128 | res = entry->store(hctx, page, length); |
| 129 | mutex_unlock(&q->sysfs_lock); |
| 130 | return res; |
| 131 | } |
| 132 | |
Omar Sandoval | d96b37c | 2017-01-25 08:06:46 -0800 | [diff] [blame] | 133 | static ssize_t blk_mq_hw_sysfs_nr_tags_show(struct blk_mq_hw_ctx *hctx, |
| 134 | char *page) |
Jens Axboe | bd166ef | 2017-01-17 06:03:22 -0700 | [diff] [blame] | 135 | { |
Omar Sandoval | d96b37c | 2017-01-25 08:06:46 -0800 | [diff] [blame] | 136 | return sprintf(page, "%u\n", hctx->tags->nr_tags); |
Jens Axboe | bd166ef | 2017-01-17 06:03:22 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Omar Sandoval | d96b37c | 2017-01-25 08:06:46 -0800 | [diff] [blame] | 139 | static ssize_t blk_mq_hw_sysfs_nr_reserved_tags_show(struct blk_mq_hw_ctx *hctx, |
| 140 | char *page) |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 141 | { |
Omar Sandoval | d96b37c | 2017-01-25 08:06:46 -0800 | [diff] [blame] | 142 | return sprintf(page, "%u\n", hctx->tags->nr_reserved_tags); |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 143 | } |
| 144 | |
Jens Axboe | 676141e | 2014-03-20 13:29:18 -0600 | [diff] [blame] | 145 | static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page) |
| 146 | { |
Jens Axboe | cb2da43 | 2014-04-09 10:53:21 -0600 | [diff] [blame] | 147 | unsigned int i, first = 1; |
Jens Axboe | 676141e | 2014-03-20 13:29:18 -0600 | [diff] [blame] | 148 | ssize_t ret = 0; |
| 149 | |
Jens Axboe | cb2da43 | 2014-04-09 10:53:21 -0600 | [diff] [blame] | 150 | for_each_cpu(i, hctx->cpumask) { |
Jens Axboe | 676141e | 2014-03-20 13:29:18 -0600 | [diff] [blame] | 151 | if (first) |
| 152 | ret += sprintf(ret + page, "%u", i); |
| 153 | else |
| 154 | ret += sprintf(ret + page, ", %u", i); |
| 155 | |
| 156 | first = 0; |
| 157 | } |
| 158 | |
Jens Axboe | 676141e | 2014-03-20 13:29:18 -0600 | [diff] [blame] | 159 | ret += sprintf(ret + page, "\n"); |
| 160 | return ret; |
| 161 | } |
| 162 | |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 163 | static struct attribute *default_ctx_attrs[] = { |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 164 | NULL, |
| 165 | }; |
| 166 | |
Omar Sandoval | d96b37c | 2017-01-25 08:06:46 -0800 | [diff] [blame] | 167 | static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_tags = { |
| 168 | .attr = {.name = "nr_tags", .mode = S_IRUGO }, |
| 169 | .show = blk_mq_hw_sysfs_nr_tags_show, |
| 170 | }; |
| 171 | static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_reserved_tags = { |
| 172 | .attr = {.name = "nr_reserved_tags", .mode = S_IRUGO }, |
| 173 | .show = blk_mq_hw_sysfs_nr_reserved_tags_show, |
| 174 | }; |
Jens Axboe | 676141e | 2014-03-20 13:29:18 -0600 | [diff] [blame] | 175 | static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_cpus = { |
| 176 | .attr = {.name = "cpu_list", .mode = S_IRUGO }, |
| 177 | .show = blk_mq_hw_sysfs_cpus_show, |
| 178 | }; |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 179 | |
| 180 | static struct attribute *default_hw_ctx_attrs[] = { |
Omar Sandoval | d96b37c | 2017-01-25 08:06:46 -0800 | [diff] [blame] | 181 | &blk_mq_hw_sysfs_nr_tags.attr, |
| 182 | &blk_mq_hw_sysfs_nr_reserved_tags.attr, |
Jens Axboe | 676141e | 2014-03-20 13:29:18 -0600 | [diff] [blame] | 183 | &blk_mq_hw_sysfs_cpus.attr, |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 184 | NULL, |
| 185 | }; |
| 186 | |
| 187 | static const struct sysfs_ops blk_mq_sysfs_ops = { |
| 188 | .show = blk_mq_sysfs_show, |
| 189 | .store = blk_mq_sysfs_store, |
| 190 | }; |
| 191 | |
| 192 | static const struct sysfs_ops blk_mq_hw_sysfs_ops = { |
| 193 | .show = blk_mq_hw_sysfs_show, |
| 194 | .store = blk_mq_hw_sysfs_store, |
| 195 | }; |
| 196 | |
| 197 | static struct kobj_type blk_mq_ktype = { |
| 198 | .sysfs_ops = &blk_mq_sysfs_ops, |
| 199 | .release = blk_mq_sysfs_release, |
| 200 | }; |
| 201 | |
| 202 | static struct kobj_type blk_mq_ctx_ktype = { |
| 203 | .sysfs_ops = &blk_mq_sysfs_ops, |
| 204 | .default_attrs = default_ctx_attrs, |
Ming Lei | 7417011 | 2015-01-29 20:17:26 +0800 | [diff] [blame] | 205 | .release = blk_mq_sysfs_release, |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 206 | }; |
| 207 | |
| 208 | static struct kobj_type blk_mq_hw_ktype = { |
| 209 | .sysfs_ops = &blk_mq_hw_sysfs_ops, |
| 210 | .default_attrs = default_hw_ctx_attrs, |
Ming Lei | 6c8b232 | 2017-02-22 18:14:01 +0800 | [diff] [blame^] | 211 | .release = blk_mq_hw_sysfs_release, |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 212 | }; |
| 213 | |
Fengguang Wu | ee3c5db | 2014-05-30 10:31:13 -0600 | [diff] [blame] | 214 | static void blk_mq_unregister_hctx(struct blk_mq_hw_ctx *hctx) |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 215 | { |
| 216 | struct blk_mq_ctx *ctx; |
| 217 | int i; |
| 218 | |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 219 | if (!hctx->nr_ctx) |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 220 | return; |
| 221 | |
| 222 | hctx_for_each_ctx(hctx, ctx, i) |
| 223 | kobject_del(&ctx->kobj); |
| 224 | |
| 225 | kobject_del(&hctx->kobj); |
| 226 | } |
| 227 | |
Fengguang Wu | ee3c5db | 2014-05-30 10:31:13 -0600 | [diff] [blame] | 228 | static int blk_mq_register_hctx(struct blk_mq_hw_ctx *hctx) |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 229 | { |
| 230 | struct request_queue *q = hctx->queue; |
| 231 | struct blk_mq_ctx *ctx; |
| 232 | int i, ret; |
| 233 | |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 234 | if (!hctx->nr_ctx) |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 235 | return 0; |
| 236 | |
| 237 | ret = kobject_add(&hctx->kobj, &q->mq_kobj, "%u", hctx->queue_num); |
| 238 | if (ret) |
| 239 | return ret; |
| 240 | |
| 241 | hctx_for_each_ctx(hctx, ctx, i) { |
| 242 | ret = kobject_add(&ctx->kobj, &hctx->kobj, "cpu%u", ctx->cpu); |
| 243 | if (ret) |
| 244 | break; |
| 245 | } |
| 246 | |
| 247 | return ret; |
| 248 | } |
| 249 | |
Matias Bjørling | b21d5b3 | 2016-09-16 14:25:06 +0200 | [diff] [blame] | 250 | static void __blk_mq_unregister_dev(struct device *dev, struct request_queue *q) |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 251 | { |
Andrey Vagin | 8515736 | 2013-12-06 09:06:41 +0400 | [diff] [blame] | 252 | struct blk_mq_hw_ctx *hctx; |
Ming Lei | 7ea5fe3 | 2017-02-22 18:14:00 +0800 | [diff] [blame] | 253 | int i; |
Andrey Vagin | 8515736 | 2013-12-06 09:06:41 +0400 | [diff] [blame] | 254 | |
Ming Lei | 6c8b232 | 2017-02-22 18:14:01 +0800 | [diff] [blame^] | 255 | queue_for_each_hw_ctx(q, hctx, i) |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 256 | blk_mq_unregister_hctx(hctx); |
| 257 | |
Omar Sandoval | 62ebce1 | 2017-01-31 14:53:21 -0800 | [diff] [blame] | 258 | blk_mq_debugfs_unregister_hctxs(q); |
Omar Sandoval | 07e4fea | 2017-01-25 08:06:40 -0800 | [diff] [blame] | 259 | |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 260 | kobject_uevent(&q->mq_kobj, KOBJ_REMOVE); |
| 261 | kobject_del(&q->mq_kobj); |
Matias Bjørling | b21d5b3 | 2016-09-16 14:25:06 +0200 | [diff] [blame] | 262 | kobject_put(&dev->kobj); |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 263 | |
| 264 | q->mq_sysfs_init_done = false; |
Jens Axboe | c0f3fd2 | 2016-08-02 08:45:44 -0600 | [diff] [blame] | 265 | } |
| 266 | |
Matias Bjørling | b21d5b3 | 2016-09-16 14:25:06 +0200 | [diff] [blame] | 267 | void blk_mq_unregister_dev(struct device *dev, struct request_queue *q) |
Jens Axboe | c0f3fd2 | 2016-08-02 08:45:44 -0600 | [diff] [blame] | 268 | { |
| 269 | blk_mq_disable_hotplug(); |
Matias Bjørling | b21d5b3 | 2016-09-16 14:25:06 +0200 | [diff] [blame] | 270 | __blk_mq_unregister_dev(dev, q); |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 271 | blk_mq_enable_hotplug(); |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 272 | } |
| 273 | |
Keith Busch | 868f2f0 | 2015-12-17 17:08:14 -0700 | [diff] [blame] | 274 | void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx) |
| 275 | { |
| 276 | kobject_init(&hctx->kobj, &blk_mq_hw_ktype); |
| 277 | } |
| 278 | |
Ming Lei | 7ea5fe3 | 2017-02-22 18:14:00 +0800 | [diff] [blame] | 279 | void blk_mq_sysfs_deinit(struct request_queue *q) |
| 280 | { |
| 281 | struct blk_mq_ctx *ctx; |
| 282 | int cpu; |
| 283 | |
| 284 | for_each_possible_cpu(cpu) { |
| 285 | ctx = per_cpu_ptr(q->queue_ctx, cpu); |
| 286 | kobject_put(&ctx->kobj); |
| 287 | } |
| 288 | kobject_put(&q->mq_kobj); |
| 289 | } |
| 290 | |
Ming Lei | 737f98c | 2017-02-22 18:13:59 +0800 | [diff] [blame] | 291 | void blk_mq_sysfs_init(struct request_queue *q) |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 292 | { |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 293 | struct blk_mq_ctx *ctx; |
Thomas Gleixner | 897bb0c | 2016-03-19 11:30:33 +0100 | [diff] [blame] | 294 | int cpu; |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 295 | |
| 296 | kobject_init(&q->mq_kobj, &blk_mq_ktype); |
| 297 | |
Thomas Gleixner | 897bb0c | 2016-03-19 11:30:33 +0100 | [diff] [blame] | 298 | for_each_possible_cpu(cpu) { |
| 299 | ctx = per_cpu_ptr(q->queue_ctx, cpu); |
Takashi Iwai | 06a41a9 | 2014-12-10 16:38:30 +0100 | [diff] [blame] | 300 | kobject_init(&ctx->kobj, &blk_mq_ctx_ktype); |
Thomas Gleixner | 897bb0c | 2016-03-19 11:30:33 +0100 | [diff] [blame] | 301 | } |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 302 | } |
| 303 | |
Matias Bjørling | b21d5b3 | 2016-09-16 14:25:06 +0200 | [diff] [blame] | 304 | int blk_mq_register_dev(struct device *dev, struct request_queue *q) |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 305 | { |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 306 | struct blk_mq_hw_ctx *hctx; |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 307 | int ret, i; |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 308 | |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 309 | blk_mq_disable_hotplug(); |
| 310 | |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 311 | ret = kobject_add(&q->mq_kobj, kobject_get(&dev->kobj), "%s", "mq"); |
| 312 | if (ret < 0) |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 313 | goto out; |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 314 | |
| 315 | kobject_uevent(&q->mq_kobj, KOBJ_ADD); |
| 316 | |
Omar Sandoval | 07e4fea | 2017-01-25 08:06:40 -0800 | [diff] [blame] | 317 | blk_mq_debugfs_register(q, kobject_name(&dev->kobj)); |
| 318 | |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 319 | queue_for_each_hw_ctx(q, hctx, i) { |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 320 | ret = blk_mq_register_hctx(hctx); |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 321 | if (ret) |
| 322 | break; |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 323 | } |
| 324 | |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 325 | if (ret) |
Matias Bjørling | b21d5b3 | 2016-09-16 14:25:06 +0200 | [diff] [blame] | 326 | __blk_mq_unregister_dev(dev, q); |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 327 | else |
| 328 | q->mq_sysfs_init_done = true; |
| 329 | out: |
| 330 | blk_mq_enable_hotplug(); |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 331 | |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 332 | return ret; |
Jens Axboe | 320ae51 | 2013-10-24 09:20:05 +0100 | [diff] [blame] | 333 | } |
Matias Bjørling | b21d5b3 | 2016-09-16 14:25:06 +0200 | [diff] [blame] | 334 | EXPORT_SYMBOL_GPL(blk_mq_register_dev); |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 335 | |
| 336 | void blk_mq_sysfs_unregister(struct request_queue *q) |
| 337 | { |
| 338 | struct blk_mq_hw_ctx *hctx; |
| 339 | int i; |
| 340 | |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 341 | if (!q->mq_sysfs_init_done) |
| 342 | return; |
| 343 | |
Omar Sandoval | 07e4fea | 2017-01-25 08:06:40 -0800 | [diff] [blame] | 344 | blk_mq_debugfs_unregister_hctxs(q); |
| 345 | |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 346 | queue_for_each_hw_ctx(q, hctx, i) |
| 347 | blk_mq_unregister_hctx(hctx); |
| 348 | } |
| 349 | |
| 350 | int blk_mq_sysfs_register(struct request_queue *q) |
| 351 | { |
| 352 | struct blk_mq_hw_ctx *hctx; |
| 353 | int i, ret = 0; |
| 354 | |
Akinobu Mita | 4593fdb | 2015-09-27 02:09:20 +0900 | [diff] [blame] | 355 | if (!q->mq_sysfs_init_done) |
| 356 | return ret; |
| 357 | |
Omar Sandoval | 07e4fea | 2017-01-25 08:06:40 -0800 | [diff] [blame] | 358 | blk_mq_debugfs_register_hctxs(q); |
| 359 | |
Jens Axboe | 67aec14 | 2014-05-30 08:25:36 -0600 | [diff] [blame] | 360 | queue_for_each_hw_ctx(q, hctx, i) { |
| 361 | ret = blk_mq_register_hctx(hctx); |
| 362 | if (ret) |
| 363 | break; |
| 364 | } |
| 365 | |
| 366 | return ret; |
| 367 | } |