]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nvme: introduce helper function to get ctrl state
authorKeith Busch <kbusch@kernel.org>
Mon, 30 Oct 2023 15:13:09 +0000 (08:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Jan 2024 10:50:06 +0000 (11:50 +0100)
[ Upstream commit 5c687c287c46fadb14644091823298875a5216aa ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/nvme.h

index 118bf08a708b9e2714a6b69deddb89c3e36fedfe..a892d679e33890c3a8f7199b5ea2920c3ecb6326 100644 (file)
@@ -382,6 +382,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,