From bb8d261e088811ef2b564d745afcd1633428010a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 26 Apr 2016 13:51:57 +0200 Subject: nvme: introduce a controller state machine Replace the adhoc flags in the PCI driver with a state machine in the core code. Based on code from Sagi Grimberg for the Fabrics driver. Signed-off-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Acked-by Jon Derrick: Signed-off-by: Jens Axboe --- drivers/nvme/host/nvme.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/nvme/host/nvme.h') diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 41e922b33f11..4135626a3d6f 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -67,7 +67,16 @@ enum nvme_quirks { NVME_QUIRK_DISCARD_ZEROES = (1 << 2), }; +enum nvme_ctrl_state { + NVME_CTRL_NEW, + NVME_CTRL_LIVE, + NVME_CTRL_RESETTING, + NVME_CTRL_DELETING, +}; + struct nvme_ctrl { + enum nvme_ctrl_state state; + spinlock_t lock; const struct nvme_ctrl_ops *ops; struct request_queue *admin_q; struct device *dev; @@ -187,6 +196,8 @@ static inline bool nvme_req_needs_retry(struct request *req, u16 status) (jiffies - req->start_time) < req->timeout; } +bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, + enum nvme_ctrl_state new_state); int nvme_disable_ctrl(struct nvme_ctrl *ctrl, u64 cap); int nvme_enable_ctrl(struct nvme_ctrl *ctrl, u64 cap); int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl); -- cgit v1.2.3