summaryrefslogtreecommitdiffstats
path: root/drivers/nvme/host/nvme.h
diff options
context:
space:
mode:
authorKeith Busch <kbusch@kernel.org>2023-10-30 16:13:09 +0100
committerKeith Busch <kbusch@kernel.org>2023-12-04 17:39:03 +0100
commit5c687c287c46fadb14644091823298875a5216aa (patch)
tree128648783e08c11c1c5ebff84928547f7656cb69 /drivers/nvme/host/nvme.h
parentMerge tag 'md-fixes-20231201-1' of https://git.kernel.org/pub/scm/linux/kerne... (diff)
downloadlinux-5c687c287c46fadb14644091823298875a5216aa.tar.xz
linux-5c687c287c46fadb14644091823298875a5216aa.zip
nvme: introduce helper function to get ctrl state
The controller state is typically written by another CPU, so reading it should ensure no optimizations are taken. This is a repeated pattern in the driver, so start with adding a convenience function that returns the controller state with READ_ONCE(). Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <kbusch@kernel.org>
Diffstat (limited to 'drivers/nvme/host/nvme.h')
-rw-r--r--drivers/nvme/host/nvme.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 39a90b7cb125..578e6d311bc9 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -387,6 +387,11 @@ struct nvme_ctrl {
enum nvme_dctype dctype;
};
+static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl)
+{
+ return READ_ONCE(ctrl->state);
+}
+
enum nvme_iopolicy {
NVME_IOPOLICY_NUMA,
NVME_IOPOLICY_RR,