diff options
author | Sagi Grimberg <sagig@mellanox.com> | 2015-12-24 09:26:59 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-01-12 15:30:11 -0500 |
commit | 363c9aacb6c59bb63148dd115632880a4aed4d88 (patch) | |
tree | d018bf0126b3224ebcf541b8f66dc84964b6d28a | |
parent | c89e5b80245899fc51fb1d83880e2f5762fcf350 (diff) |
nvme: Move nvme_freeze/unfreeze_queues to nvme core
Nothing pci specific about them and We'll need them exported
in other transports too.
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | drivers/nvme/host/core.c | 28 | ||||
-rw-r--r-- | drivers/nvme/host/nvme.h | 3 | ||||
-rw-r--r-- | drivers/nvme/host/pci.c | 32 |
3 files changed, 33 insertions, 30 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 1437ff36e91c..27130056136b 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c | |||
@@ -1328,6 +1328,34 @@ out: | |||
1328 | return ret; | 1328 | return ret; |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | void nvme_freeze_queues(struct nvme_ctrl *ctrl) | ||
1332 | { | ||
1333 | struct nvme_ns *ns; | ||
1334 | |||
1335 | list_for_each_entry(ns, &ctrl->namespaces, list) { | ||
1336 | blk_mq_freeze_queue_start(ns->queue); | ||
1337 | |||
1338 | spin_lock_irq(ns->queue->queue_lock); | ||
1339 | queue_flag_set(QUEUE_FLAG_STOPPED, ns->queue); | ||
1340 | spin_unlock_irq(ns->queue->queue_lock); | ||
1341 | |||
1342 | blk_mq_cancel_requeue_work(ns->queue); | ||
1343 | blk_mq_stop_hw_queues(ns->queue); | ||
1344 | } | ||
1345 | } | ||
1346 | |||
1347 | void nvme_unfreeze_queues(struct nvme_ctrl *ctrl) | ||
1348 | { | ||
1349 | struct nvme_ns *ns; | ||
1350 | |||
1351 | list_for_each_entry(ns, &ctrl->namespaces, list) { | ||
1352 | queue_flag_clear_unlocked(QUEUE_FLAG_STOPPED, ns->queue); | ||
1353 | blk_mq_unfreeze_queue(ns->queue); | ||
1354 | blk_mq_start_stopped_hw_queues(ns->queue, true); | ||
1355 | blk_mq_kick_requeue_list(ns->queue); | ||
1356 | } | ||
1357 | } | ||
1358 | |||
1331 | int __init nvme_core_init(void) | 1359 | int __init nvme_core_init(void) |
1332 | { | 1360 | { |
1333 | int result; | 1361 | int result; |
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index d88cf45fbcc1..0da67474ce6d 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h | |||
@@ -237,6 +237,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl); | |||
237 | void nvme_scan_namespaces(struct nvme_ctrl *ctrl); | 237 | void nvme_scan_namespaces(struct nvme_ctrl *ctrl); |
238 | void nvme_remove_namespaces(struct nvme_ctrl *ctrl); | 238 | void nvme_remove_namespaces(struct nvme_ctrl *ctrl); |
239 | 239 | ||
240 | void nvme_freeze_queues(struct nvme_ctrl *ctrl); | ||
241 | void nvme_unfreeze_queues(struct nvme_ctrl *ctrl); | ||
242 | |||
240 | struct request *nvme_alloc_request(struct request_queue *q, | 243 | struct request *nvme_alloc_request(struct request_queue *q, |
241 | struct nvme_command *cmd, unsigned int flags); | 244 | struct nvme_command *cmd, unsigned int flags); |
242 | void nvme_requeue_req(struct request *req); | 245 | void nvme_requeue_req(struct request *req); |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index b82bbea909cd..a7e549969462 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
@@ -1903,34 +1903,6 @@ static void nvme_dev_list_remove(struct nvme_dev *dev) | |||
1903 | kthread_stop(tmp); | 1903 | kthread_stop(tmp); |
1904 | } | 1904 | } |
1905 | 1905 | ||
1906 | static void nvme_freeze_queues(struct nvme_dev *dev) | ||
1907 | { | ||
1908 | struct nvme_ns *ns; | ||
1909 | |||
1910 | list_for_each_entry(ns, &dev->ctrl.namespaces, list) { | ||
1911 | blk_mq_freeze_queue_start(ns->queue); | ||
1912 | |||
1913 | spin_lock_irq(ns->queue->queue_lock); | ||
1914 | queue_flag_set(QUEUE_FLAG_STOPPED, ns->queue); | ||
1915 | spin_unlock_irq(ns->queue->queue_lock); | ||
1916 | |||
1917 | blk_mq_cancel_requeue_work(ns->queue); | ||
1918 | blk_mq_stop_hw_queues(ns->queue); | ||
1919 | } | ||
1920 | } | ||
1921 | |||
1922 | static void nvme_unfreeze_queues(struct nvme_dev *dev) | ||
1923 | { | ||
1924 | struct nvme_ns *ns; | ||
1925 | |||
1926 | list_for_each_entry(ns, &dev->ctrl.namespaces, list) { | ||
1927 | queue_flag_clear_unlocked(QUEUE_FLAG_STOPPED, ns->queue); | ||
1928 | blk_mq_unfreeze_queue(ns->queue); | ||
1929 | blk_mq_start_stopped_hw_queues(ns->queue, true); | ||
1930 | blk_mq_kick_requeue_list(ns->queue); | ||
1931 | } | ||
1932 | } | ||
1933 | |||
1934 | static void nvme_dev_shutdown(struct nvme_dev *dev) | 1906 | static void nvme_dev_shutdown(struct nvme_dev *dev) |
1935 | { | 1907 | { |
1936 | int i; | 1908 | int i; |
@@ -1940,7 +1912,7 @@ static void nvme_dev_shutdown(struct nvme_dev *dev) | |||
1940 | 1912 | ||
1941 | mutex_lock(&dev->shutdown_lock); | 1913 | mutex_lock(&dev->shutdown_lock); |
1942 | if (dev->bar) { | 1914 | if (dev->bar) { |
1943 | nvme_freeze_queues(dev); | 1915 | nvme_freeze_queues(&dev->ctrl); |
1944 | csts = readl(dev->bar + NVME_REG_CSTS); | 1916 | csts = readl(dev->bar + NVME_REG_CSTS); |
1945 | } | 1917 | } |
1946 | if (csts & NVME_CSTS_CFS || !(csts & NVME_CSTS_RDY)) { | 1918 | if (csts & NVME_CSTS_CFS || !(csts & NVME_CSTS_RDY)) { |
@@ -2049,7 +2021,7 @@ static void nvme_reset_work(struct work_struct *work) | |||
2049 | dev_warn(dev->dev, "IO queues not created\n"); | 2021 | dev_warn(dev->dev, "IO queues not created\n"); |
2050 | nvme_remove_namespaces(&dev->ctrl); | 2022 | nvme_remove_namespaces(&dev->ctrl); |
2051 | } else { | 2023 | } else { |
2052 | nvme_unfreeze_queues(dev); | 2024 | nvme_unfreeze_queues(&dev->ctrl); |
2053 | nvme_dev_add(dev); | 2025 | nvme_dev_add(dev); |
2054 | } | 2026 | } |
2055 | 2027 | ||