From 4b6875cbce3da0ac10333699ea50916e695483f6 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 20 Nov 2015 09:36:44 +0100 Subject: [PATCH] nvme: switch abort_limit to an atomic_t There is no lock to sychronize access to the abort_limit field of struct nvme_ctrl, so switch it to an atomic_t. Signed-off-by: Christoph Hellwig Signed-off-by: Keith Busch Signed-off-by: Jens Axboe Orabug: 25130845 Cherry pick commit: 6bf25d1 Conflicts: drivers/nvme/host/pci.c Signed-off-by: Ashok Vairavan Reviewed-by: Martin K. Petersen --- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 1ac5f7a1409c..8df1ed283386 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -799,7 +799,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) } ctrl->oncs = le16_to_cpup(&id->oncs); - ctrl->abort_limit = id->acl + 1; + atomic_set(&ctrl->abort_limit, id->acl + 1); ctrl->vwc = id->vwc; memcpy(ctrl->serial, id->sn, sizeof(id->sn)); memcpy(ctrl->model, id->mn, sizeof(id->mn)); diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 8ae0d2ebf926..a5ecf08c8406 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -77,7 +77,7 @@ struct nvme_ctrl { u32 max_hw_sectors; u32 stripe_size; u16 oncs; - u16 abort_limit; + atomic_t abort_limit; u8 event_limit; u8 vwc; u32 vs; diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index ecc8322a6aec..82dfc7a50d9d 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -395,7 +395,7 @@ static void abort_completion(struct nvme_queue *nvmeq, void *ctx, blk_mq_free_request(req); dev_warn(nvmeq->q_dmadev, "Abort status:%x result:%x", status, result); - ++nvmeq->dev->ctrl.abort_limit; + atomic_inc(&nvmeq->dev->ctrl.abort_limit); } static void async_completion(struct nvme_queue *nvmeq, void *ctx, @@ -1145,13 +1145,15 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) return BLK_EH_HANDLED; } - if (!dev->ctrl.abort_limit) + if (atomic_dec_and_test(&dev->ctrl.abort_limit)) return BLK_EH_RESET_TIMER; abort_req = blk_mq_alloc_request(dev->ctrl.admin_q, WRITE, GFP_ATOMIC, false); if (IS_ERR(abort_req)) + atomic_inc(&dev->ctrl.abort_limit); return BLK_EH_RESET_TIMER; + } abort_cmd = blk_mq_rq_to_pdu(abort_req); nvme_set_info(abort_cmd, abort_req, abort_completion); @@ -1162,7 +1164,6 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) cmd.abort.sqid = cpu_to_le16(nvmeq->qid); cmd.abort.command_id = abort_req->tag; - --dev->ctrl.abort_limit; cmd_rq->aborted = 1; dev_warn(nvmeq->q_dmadev, "I/O %d QID %d timeout, aborting\n", -- 2.50.1