diff options
author | Keith Busch <kbusch@kernel.org> | 2023-10-30 18:13:09 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-01-20 13:50:06 +0300 |
commit | df2bd52354d8f5ffc4c9cbedad414794d86be5a0 (patch) | |
tree | 2b7c136bc4355637719661d6842a8fb473b375de /drivers/nvme | |
parent | a50562146d6c7650029a115c96ef9aaa7648c344 (diff) | |
download | linux-df2bd52354d8f5ffc4c9cbedad414794d86be5a0.tar.xz |
nvme: introduce helper function to get ctrl state
[ 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>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/host/nvme.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 118bf08a708b..a892d679e338 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -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, |