From patchwork Wed May 22 17:48:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10956411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50EFE112C for ; Wed, 22 May 2019 17:53:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4031728C71 for ; Wed, 22 May 2019 17:53:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E39D28C9E; Wed, 22 May 2019 17:53:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBFA428C71 for ; Wed, 22 May 2019 17:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728674AbfEVRxR (ORCPT ); Wed, 22 May 2019 13:53:17 -0400 Received: from mga07.intel.com ([134.134.136.100]:57850 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728533AbfEVRxQ (ORCPT ); Wed, 22 May 2019 13:53:16 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2019 10:53:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,500,1549958400"; d="scan'208";a="174471731" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga002.fm.intel.com with ESMTP; 22 May 2019 10:53:15 -0700 From: Keith Busch To: Jens Axboe , Christoph Hellwig , linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Cc: Ming Lei , Keith Busch Subject: [PATCH 1/2] blk-mq: provide way to reset rq deadline Date: Wed, 22 May 2019 11:48:11 -0600 Message-Id: <20190522174812.5597-2-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190522174812.5597-1-keith.busch@intel.com> References: <20190522174812.5597-1-keith.busch@intel.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If hardware has temporarily paused processing requests that its driver has dispatched, the driver may need to halt timeout detection during that temporary stoppage. When the hardware has un-paused request processing, the driver needs a way to rebase all dispatched request dealines using current jiffies so that time accrued during the paused state doesn't count against that request. Signed-off-by: Keith Busch --- block/blk-mq.c | 30 ++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 1 + 2 files changed, 31 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index 08a6248d8536..9d85903d4e0c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -960,6 +960,36 @@ static void blk_mq_timeout_work(struct work_struct *work) blk_queue_exit(q); } +static bool blk_mq_reset_rq(struct blk_mq_hw_ctx *hctx, struct request *rq, + void *priv, bool reserved) +{ + if (blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) + blk_add_timer(rq); + return true; +} + +/** + * blk_mq_reset_rqs - reset the timers on all inflight requests + * + * @q - request queue to iterate + * + * This is intended for use when a driver detects its hardware has temporarily + * paused processing commands. When the condition is initially detected, the + * driver should call blk_mq_quiesce_queue() to block new requests from + * dispatching, then blk_sync_queue() to halt any timeout work. When the + * hardware becomes operational again, the driver should call this function to + * reset previously dispatched request timers who's processing had been paused + * by the hardware, then call blk_mq_unquiesce_queue() to unblock future + * dispatch. + */ +void blk_mq_reset_rqs(struct request_queue *q) +{ + if (WARN_ON(!blk_queue_quiesced(q))) + return; + blk_mq_queue_tag_busy_iter(q, blk_mq_reset_rq, NULL); +} +EXPORT_SYMBOL_GPL(blk_mq_reset_rqs); + struct flush_busy_ctx_data { struct blk_mq_hw_ctx *hctx; struct list_head *list; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 15d1aa53d96c..28c421ba5094 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -327,6 +327,7 @@ void blk_freeze_queue_start(struct request_queue *q); void blk_mq_freeze_queue_wait(struct request_queue *q); int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, unsigned long timeout); +void blk_mq_reset_rqs(struct request_queue *q); int blk_mq_map_queues(struct blk_mq_queue_map *qmap); void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues); From patchwork Wed May 22 17:48:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10956413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F3D317E0 for ; Wed, 22 May 2019 17:53:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D68E28CA9 for ; Wed, 22 May 2019 17:53:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B97E28CA4; Wed, 22 May 2019 17:53:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECBED28CBE for ; Wed, 22 May 2019 17:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728533AbfEVRxR (ORCPT ); Wed, 22 May 2019 13:53:17 -0400 Received: from mga07.intel.com ([134.134.136.100]:57850 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728450AbfEVRxR (ORCPT ); Wed, 22 May 2019 13:53:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2019 10:53:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,500,1549958400"; d="scan'208";a="174471736" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga002.fm.intel.com with ESMTP; 22 May 2019 10:53:15 -0700 From: Keith Busch To: Jens Axboe , Christoph Hellwig , linux-nvme@lists.infradead.org, linux-block@vger.kernel.org Cc: Ming Lei , Keith Busch Subject: [PATCH 2/2] nvme: reset request timeouts during fw activation Date: Wed, 22 May 2019 11:48:12 -0600 Message-Id: <20190522174812.5597-3-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190522174812.5597-1-keith.busch@intel.com> References: <20190522174812.5597-1-keith.busch@intel.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The nvme controller may pause command processing during firmware activation. The driver will quiesce queues during this time, but commands dispatched prior to the notification will not be processed until the hardware completes this activation. We do not want those requests to time out while the hardware is in this paused state as we don't expect those commands to complete during this time, and that handling will interfere with the firmware activation process. In addition to quiescing the queues, halt timeout detection during the paused state and reset the dispatched request deadlines when the hardware exists that state. This action applies to IO and admin queues. Signed-off-by: Keith Busch --- drivers/nvme/host/core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 1b7c2afd84cb..37a9a66ada22 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -89,6 +89,7 @@ static dev_t nvme_chr_devt; static struct class *nvme_class; static struct class *nvme_subsys_class; +static void nvme_reset_queues(struct nvme_ctrl *ctrl); static int nvme_revalidate_disk(struct gendisk *disk); static void nvme_put_subsystem(struct nvme_subsystem *subsys); static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl, @@ -3605,6 +3606,11 @@ static void nvme_fw_act_work(struct work_struct *work) msecs_to_jiffies(admin_timeout * 1000); nvme_stop_queues(ctrl); + nvme_sync_queues(ctrl); + + blk_mq_quiesce_queue(ctrl->admin_q); + blk_sync_queue(ctrl->admin_q); + while (nvme_ctrl_pp_status(ctrl)) { if (time_after(jiffies, fw_act_timeout)) { dev_warn(ctrl->device, @@ -3618,7 +3624,12 @@ static void nvme_fw_act_work(struct work_struct *work) if (ctrl->state != NVME_CTRL_LIVE) return; + blk_mq_reset_rqs(ctrl->admin_q); + blk_mq_unquiesce_queue(ctrl->admin_q); + + nvme_reset_queues(ctrl); nvme_start_queues(ctrl); + /* read FW slot information to clear the AER */ nvme_get_fw_slot_info(ctrl); } @@ -3901,6 +3912,15 @@ void nvme_start_queues(struct nvme_ctrl *ctrl) } EXPORT_SYMBOL_GPL(nvme_start_queues); +static void nvme_reset_queues(struct nvme_ctrl *ctrl) +{ + struct nvme_ns *ns; + + down_read(&ctrl->namespaces_rwsem); + list_for_each_entry(ns, &ctrl->namespaces, list) + blk_mq_reset_rqs(ns->queue); + up_read(&ctrl->namespaces_rwsem); +} void nvme_sync_queues(struct nvme_ctrl *ctrl) {