From patchwork Fri Nov 20 16:35:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 7669921 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C94199F1C2 for ; Fri, 20 Nov 2015 16:42:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E71FC20384 for ; Fri, 20 Nov 2015 16:42:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E6AA020458 for ; Fri, 20 Nov 2015 16:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162862AbbKTQmR (ORCPT ); Fri, 20 Nov 2015 11:42:17 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:55263 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162440AbbKTQmR (ORCPT ); Fri, 20 Nov 2015 11:42:17 -0500 Received: from p3ee3e1bb.dip0.t-ipconnect.de ([62.227.225.187] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZzolI-00005Q-I5; Fri, 20 Nov 2015 16:42:13 +0000 From: Christoph Hellwig To: keith.busch@intel.com, axboe@fb.com Cc: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Subject: [PATCH 31/47] nvme: switch abort_limit to an atomic_t Date: Fri, 20 Nov 2015 17:35:26 +0100 Message-Id: <1448037342-18384-32-git-send-email-hch@lst.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448037342-18384-1-git-send-email-hch@lst.de> References: <1448037342-18384-1-git-send-email-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 4d83586..655295f 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -718,7 +718,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 40c9fed..993767e 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -61,7 +61,7 @@ struct nvme_ctrl { u32 stripe_size; u32 page_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 f64c2bb..425e48a 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -385,7 +385,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, @@ -1111,13 +1111,15 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) return BLK_EH_QUIESCED; } - 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, BLK_MQ_REQ_NOWAIT); - if (IS_ERR(abort_req)) + 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); @@ -1128,7 +1130,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",