[PATCHv2 1/2] nvme: introduce helper function to get ctrl state
Keith Busch
kbusch at meta.com
Mon Nov 20 09:50:34 PST 2023
From: Keith Busch <kbusch at kernel.org>
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().
Signed-off-by: Keith Busch <kbusch at kernel.org>
---
drivers/nvme/host/nvme.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 39a90b7cb1254..578e6d311bc9c 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,
--
2.34.1
More information about the Linux-nvme
mailing list