]> www.infradead.org Git - linux.git/commitdiff
nvme: use helper nvme_ctrl_state in nvme_keep_alive_finish function
authorNilay Shroff <nilay@linux.ibm.com>
Wed, 16 Oct 2024 03:03:16 +0000 (08:33 +0530)
committerKeith Busch <kbusch@kernel.org>
Thu, 17 Oct 2024 18:07:37 +0000 (11:07 -0700)
We no more need acquiring ctrl->lock before accessing the
NVMe controller state and instead we can now use the helper
nvme_ctrl_state. So replace the use of ctrl->lock from
nvme_keep_alive_finish function with nvme_ctrl_state call.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/core.c

index 60163840b8ffaaef56606420f5f25c0203e2e876..876c8e6311db4bc49c2f2c97698142297b005112 100644 (file)
@@ -1295,10 +1295,9 @@ static void nvme_queue_keep_alive_work(struct nvme_ctrl *ctrl)
 static void nvme_keep_alive_finish(struct request *rq,
                blk_status_t status, struct nvme_ctrl *ctrl)
 {
-       unsigned long flags;
-       bool startka = false;
        unsigned long rtt = jiffies - (rq->deadline - rq->timeout);
        unsigned long delay = nvme_keep_alive_work_period(ctrl);
+       enum nvme_ctrl_state state = nvme_ctrl_state(ctrl);
 
        /*
         * Subtract off the keepalive RTT so nvme_keep_alive_work runs
@@ -1321,12 +1320,7 @@ static void nvme_keep_alive_finish(struct request *rq,
 
        ctrl->ka_last_check_time = jiffies;
        ctrl->comp_seen = false;
-       spin_lock_irqsave(&ctrl->lock, flags);
-       if (ctrl->state == NVME_CTRL_LIVE ||
-           ctrl->state == NVME_CTRL_CONNECTING)
-               startka = true;
-       spin_unlock_irqrestore(&ctrl->lock, flags);
-       if (startka)
+       if (state == NVME_CTRL_LIVE || state == NVME_CTRL_CONNECTING)
                queue_delayed_work(nvme_wq, &ctrl->ka_work, delay);
 }