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