Received: by 10.223.176.46 with SMTP id f43csp497553wra; Thu, 18 Jan 2018 20:58:55 -0800 (PST) X-Google-Smtp-Source: ACJfBouDD4JyDjQg5h+t3UJ14BcOnY0PcNvBglBKeVzVd/C9EtwbYuCSVmYsBKTDLg71TuG0qWpM X-Received: by 10.98.89.198 with SMTP id k67mr10973205pfj.110.1516337935471; Thu, 18 Jan 2018 20:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516337935; cv=none; d=google.com; s=arc-20160816; b=JWbuLRPgKqfl6vDY03A8pICQNRIoen08q/kYn3UxMMBhzyfKIDLMSMPV2bzZ/BLaqm Y0I/UNVH3lvtNgQgIyQtPuERpmdjZUnMjI4WaoNXG1t5gWodnboe4BFWO6nhhcxpnGIX MXKbXtTd/YAHcPkf7g8yqa/1E/40j4+07gmvzHbQaJEcC4GkoIJzUCK78JJEltUzsUrk MYxKxkGJ05hpi0ay3zcan1lLwMZM3laNSW2fXEifUn9JUgCmWVm/xW+vm0Rzwx2f2L5e pod1Nf/ZsZlXKZ6aKSumR1/wi4mWbL/t/9HiWu58WF8F5BNeI+wX512jXMUxhntlLmSy K1KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=yU1Q50U7JX3/2k6Ita5W3OHgOD0Ce/xNl41gLgsi8bQ=; b=Z5DlFB3bzxUAkCQ+Flmk4krXG1Mr0wePdJFNaJdV/NZ0FBB8ZKTk2oQnRNdlv9G5w+ sCcHJpevj96fZ7OcrnCYh/g2H2Fg6+onq5ypw8WwAaqe+gem8/2ZliIK30P1i4VhszYp 7H0vyrlaiSJQqFZdVzdprqk3RW8Kdlj1Fdz32Ffd0Q/HSf1K0o526bEJLLBEDOhWkH0y /BlJPNLi5GPJ4F1TYLRWeQ1CaOlBGAqN6yLe14cMFYp3FtRIlcW+3QnHNAOZWs3m90fy TbCT5L88goS2FFNQWG6fwoOW6FsAHVAJN65OL9Uu2mE0AeXYPUkT9IRWwsSZ1pbJSjda O8Bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4-v6si520455plt.483.2018.01.18.20.58.41; Thu, 18 Jan 2018 20:58:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753799AbeASE4d (ORCPT + 99 others); Thu, 18 Jan 2018 23:56:33 -0500 Received: from mga02.intel.com ([134.134.136.20]:56841 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750757AbeASE40 (ORCPT ); Thu, 18 Jan 2018 23:56:26 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 20:56:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,380,1511856000"; d="scan'208";a="20957878" Received: from unknown (HELO localhost.localdomain) ([10.232.112.44]) by FMSMGA003.fm.intel.com with ESMTP; 18 Jan 2018 20:56:25 -0800 Date: Thu, 18 Jan 2018 21:59:45 -0700 From: Keith Busch To: Jianchao Wang Cc: axboe@fb.com, hch@lst.de, sagi@grimberg.me, maxg@mellanox.com, james.smart@broadcom.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V5 2/2] nvme-pci: fixup the timeout case when reset is ongoing Message-ID: <20180119045944.GC12043@localhost.localdomain> References: <1516270202-8051-1-git-send-email-jianchao.w.wang@oracle.com> <1516270202-8051-3-git-send-email-jianchao.w.wang@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516270202-8051-3-git-send-email-jianchao.w.wang@oracle.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 18, 2018 at 06:10:02PM +0800, Jianchao Wang wrote: > + * - When the ctrl.state is NVME_CTRL_RESETTING, the expired > + * request should come from the previous work and we handle > + * it as nvme_cancel_request. > + * - When the ctrl.state is NVME_CTRL_RECONNECTING, the expired > + * request should come from the initializing procedure such as > + * setup io queues, because all the previous outstanding > + * requests should have been cancelled. > */ > - if (dev->ctrl.state == NVME_CTRL_RESETTING) { > - dev_warn(dev->ctrl.device, > - "I/O %d QID %d timeout, disable controller\n", > - req->tag, nvmeq->qid); > - nvme_dev_disable(dev, false); > + switch (dev->ctrl.state) { > + case NVME_CTRL_RESETTING: > + nvme_req(req)->status = NVME_SC_ABORT_REQ; > + return BLK_EH_HANDLED; > + case NVME_CTRL_RECONNECTING: > + WARN_ON_ONCE(nvmeq->qid); > nvme_req(req)->flags |= NVME_REQ_CANCELLED; > return BLK_EH_HANDLED; > + default: > + break; > } The driver may be giving up on the command here, but that doesn't mean the controller has. We can't just end the request like this because that will release the memory the controller still owns. We must wait until after nvme_dev_disable clears bus master because we can't say for sure the controller isn't going to write to that address right after we end the request.