linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, willy@infradead.org
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	linux-nvme@lists.infradead.org
Subject: [PATCH V3 04/10] nvme: centralize queue action nvme_unfreeze()
Date: Tue, 14 Jul 2020 16:30:51 -0700	[thread overview]
Message-ID: <20200714233057.10915-5-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20200714233057.10915-1-chaitanya.kulkarni@wdc.com>

There is no point in having 7 different functions which are differing
with just one line.

The helper functions for ctrl queue management can be centralized with
the help of the descriptive enums for action. This avoids code
duplication which spans across the 7 functions as compare to one
function and exporting 7 symbols as compare to one symbol.

This patch merges nvme_unfreeze() into newly introduced nvme_queue_act()
which handles the queue management.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/core.c | 15 ++++-----------
 drivers/nvme/host/nvme.h |  2 +-
 drivers/nvme/host/pci.c  |  4 ++--
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b39aafcbdde9..fdf47ff7c60c 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1452,7 +1452,7 @@ static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects)
 	if (effects & NVME_CMD_EFFECTS_LBCC)
 		nvme_update_formats(ctrl, &effects);
 	if (effects & (NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK)) {
-		nvme_unfreeze(ctrl);
+		nvme_queue_act(ctrl, NVME_UNFREEZE_QUEUES);
 		nvme_mpath_unfreeze(ctrl->subsys);
 		mutex_unlock(&ctrl->subsys->lock);
 		nvme_remove_invalid_namespaces(ctrl, NVME_NSID_ALL);
@@ -4472,6 +4472,9 @@ void nvme_queue_act(struct nvme_ctrl *ctrl, enum nvme_queue_act op)
 		case NVME_KILL_QUEUES:
 			nvme_set_queue_dying(ns);
 			break;
+		case NVME_UNFREEZE_QUEUES:
+			blk_mq_unfreeze_queue(ns->queue);
+			break;
 		default:
 			pr_warn("invalid %s op 0x%x\n", __func__, op);
 			break;
@@ -4480,16 +4483,6 @@ void nvme_queue_act(struct nvme_ctrl *ctrl, enum nvme_queue_act op)
 }
 EXPORT_SYMBOL_GPL(nvme_queue_act);
 
-void nvme_unfreeze(struct nvme_ctrl *ctrl)
-{
-	struct nvme_ns *ns;
-	unsigned long idx;
-
-	xa_for_each(&ctrl->namespaces, idx, ns)
-		blk_mq_unfreeze_queue(ns->queue);
-}
-EXPORT_SYMBOL_GPL(nvme_unfreeze);
-
 void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout)
 {
 	struct nvme_ns *ns;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index b1cde85e9a85..a1b2364d2bb2 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -547,13 +547,13 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
 
 enum nvme_queue_act {
 	NVME_KILL_QUEUES = 1,
+	NVME_UNFREEZE_QUEUES,
 };
 
 void nvme_queue_act(struct nvme_ctrl *ctrl, enum nvme_queue_act op);
 void nvme_stop_queues(struct nvme_ctrl *ctrl);
 void nvme_start_queues(struct nvme_ctrl *ctrl);
 void nvme_sync_queues(struct nvme_ctrl *ctrl);
-void nvme_unfreeze(struct nvme_ctrl *ctrl);
 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
 void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
 void nvme_start_freeze(struct nvme_ctrl *ctrl);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index ce04a76a48af..b87e2f0dcdf2 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2624,7 +2624,7 @@ static void nvme_reset_work(struct work_struct *work)
 		nvme_start_queues(&dev->ctrl);
 		nvme_wait_freeze(&dev->ctrl);
 		nvme_dev_add(dev);
-		nvme_unfreeze(&dev->ctrl);
+		nvme_queue_act(&dev->ctrl, NVME_UNFREEZE_QUEUES);
 	}
 
 	/*
@@ -2997,7 +2997,7 @@ static int nvme_suspend(struct device *dev)
 		ctrl->npss = 0;
 	}
 unfreeze:
-	nvme_unfreeze(ctrl);
+	nvme_queue_act(ctrl, NVME_UNFREEZE_QUEUES);
 	return ret;
 }
 
-- 
2.26.0


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2020-07-14 23:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 23:30 [PATCH V3 00/10] nvme: use xarray for ns tracking Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 01/10] xarray: add __xa_load() version Chaitanya Kulkarni
2020-07-15  0:46   ` Keith Busch
2020-07-15  0:47     ` Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 02/10] nvme-core: use xarray for ctrl ns tracking Chaitanya Kulkarni
2020-07-15  0:55   ` Keith Busch
2020-07-15  1:33     ` Matthew Wilcox
2020-07-15  1:41       ` Keith Busch
2020-07-15  5:12         ` Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 03/10] nvme: centralize queue action nvme_kill_queues() Chaitanya Kulkarni
2020-07-15  1:36   ` Keith Busch
2020-07-15  1:39     ` Matthew Wilcox
2020-07-15  7:11   ` Christoph Hellwig
2020-07-14 23:30 ` Chaitanya Kulkarni [this message]
2020-07-14 23:30 ` [PATCH V3 05/10] nvme: centralize queue action nvme_wait_freeze() Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 06/10] nvme: centralize queue action nvme_start_freeze() Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 07/10] nvme: centralize queue action nvme_stop_queues() Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 08/10] nvme: centralize queue action nvme_start_queues() Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 09/10] nvme: centralize queue action nvme_sync_queues() Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 10/10] nvmet: use xarray for ctrl ns storing Chaitanya Kulkarni
2020-07-15  7:10   ` Christoph Hellwig
2020-07-17  1:52     ` Chaitanya Kulkarni
2020-07-15  7:03 ` [PATCH V3 00/10] nvme: use xarray for ns tracking Christoph Hellwig
2020-07-16  1:48   ` Chaitanya Kulkarni
2020-07-17  2:02   ` Chaitanya Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200714233057.10915-5-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).