Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2909709iog; Mon, 27 Jun 2022 05:34:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tE1S1lKuzso/zqV4XoMDTxs6CRXlasxK6feNXGHIZheairMDJgGLhJH43H+AOrZOhWprW6 X-Received: by 2002:a17:90a:b703:b0:1dd:1e2f:97d7 with SMTP id l3-20020a17090ab70300b001dd1e2f97d7mr20617969pjr.62.1656333264947; Mon, 27 Jun 2022 05:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333264; cv=none; d=google.com; s=arc-20160816; b=hteA/In2Q/rquv2/t3CR38RWrgzNA0w66eckuR+0hP5sW7S8Zshb68uqEsx2zdy6v5 ffidXKXRG/yAWux7I6BT0elTFC/VaKS/lhHk0a9bRw861yMXjiLLIK/vvHZH9PkTwU8D /YDvPR/N3YFvdILTKcvYD6IFSxcg5OVmEoWesBJD7nVcNl2xsvjBuAMRB4swRW6jf9io S5J15tdM0/ds6yWgbMs+2JMBhlDZ4i6byp72gSaen3TRBUCfs83S31HzUzb2qWN5BiAV pPQM7Fftfp7mVPaLK+oRtkwORz1IhJT64z7umen7HlVx1N8TwojZuGn7gaFcR+J41ON5 rf5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=an9x3QJqm90fgN7gENiZxmRTRQ+8gHIneQ7V8z1zXwM=; b=GpAmNMRyYIMuKO8d+xcRcbt3P8WXb7mDH28uaMITY+e2XfarO2nNb3/1uxHwfEqZzO OwUYzam9SMkwTTZWF329Sgzvio7PK0wZCu4g5LcX97MAWLh16XPAWd1XlycpShrA/CKJ TGqqTvjaYipVP1Ufo4YHnN/H+HuxQ03g92csAVqxneF2mHTVm370OlVnVzHrV7P9nFyv al7L+mr47mLD7AOkPIGUqLyT+Nzpt+JYxMw9F+XwkN+VQ+Y7swp8NA99doVFsTQOFTSm nWmyQqn5uFgBGCcgtPZr3PdUE9B7vS+PzlrSoX1aRt3w7/+lAsbHLdoOpFoAD5q17c7N FiCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fMriZVm2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b28-20020a631b1c000000b003db2ab7cae4si14142234pgb.688.2022.06.27.05.34.12; Mon, 27 Jun 2022 05:34:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fMriZVm2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234850AbiF0L0L (ORCPT + 99 others); Mon, 27 Jun 2022 07:26:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234911AbiF0LZR (ORCPT ); Mon, 27 Jun 2022 07:25:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82A9F65BE; Mon, 27 Jun 2022 04:25:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2C153B81123; Mon, 27 Jun 2022 11:25:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D88DC3411D; Mon, 27 Jun 2022 11:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329109; bh=FyoFVqtZUvwcbGZZh1GV52hKkfQQUNKMb6E4lVcaMVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fMriZVm2Nm6Mbgf5q/q+JlyQAbDrwih2COKSSlLUPRlAGJgZIOf0+DrvMiwtJcVhQ RtcXcMgDsrn547G27zbmbKqAMhyJnGpt1sdEaJe7XaiCRQNaoIKOFM4kMOF2irZXoX wbay9F1zvvfJJ9lZKDz+mcukZsuZfBkHrOiPDmHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chaitanya Kulkarni , Sagi Grimberg , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.10 054/102] nvme: centralize setting the timeout in nvme_alloc_request Date: Mon, 27 Jun 2022 13:21:05 +0200 Message-Id: <20220627111935.074765866@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chaitanya Kulkarni [ Upstream commit 0d2e7c840b178bf9a47bd0de89d8f9182fa71d86 ] The function nvme_alloc_request() is called from different context (I/O and Admin queue) where callers do not consider the I/O timeout when called from I/O queue context. Update nvme_alloc_request() to set the default I/O and Admin timeout value based on whether the queuedata is set or not. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 11 +++++++++-- drivers/nvme/host/lightnvm.c | 3 ++- drivers/nvme/host/pci.c | 2 -- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 0aa68da51ed7..4a7154cbca50 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -553,6 +553,11 @@ struct request *nvme_alloc_request(struct request_queue *q, if (IS_ERR(req)) return req; + if (req->q->queuedata) + req->timeout = NVME_IO_TIMEOUT; + else /* no queuedata implies admin queue */ + req->timeout = ADMIN_TIMEOUT; + req->cmd_flags |= REQ_FAILFAST_DRIVER; nvme_clear_nvme_request(req); nvme_req(req)->cmd = cmd; @@ -927,7 +932,8 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, if (IS_ERR(req)) return PTR_ERR(req); - req->timeout = timeout ? timeout : ADMIN_TIMEOUT; + if (timeout) + req->timeout = timeout; if (buffer && bufflen) { ret = blk_rq_map_kern(q, req, buffer, bufflen, GFP_KERNEL); @@ -1097,7 +1103,8 @@ static int nvme_submit_user_cmd(struct request_queue *q, if (IS_ERR(req)) return PTR_ERR(req); - req->timeout = timeout ? timeout : ADMIN_TIMEOUT; + if (timeout) + req->timeout = timeout; nvme_req(req)->flags |= NVME_REQ_USERCMD; if (ubuffer && bufflen) { diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index 8e562d0f2c30..88a7c8eac455 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -774,7 +774,8 @@ static int nvme_nvm_submit_user_cmd(struct request_queue *q, goto err_cmd; } - rq->timeout = timeout ? timeout : ADMIN_TIMEOUT; + if (timeout) + rq->timeout = timeout; if (ppa_buf && ppa_len) { ppa_list = dma_pool_alloc(dev->dma_pool, GFP_KERNEL, &ppa_dma); diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 7de24a10dd92..f2d0148d4050 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1356,7 +1356,6 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) return BLK_EH_RESET_TIMER; } - abort_req->timeout = ADMIN_TIMEOUT; abort_req->end_io_data = NULL; blk_execute_rq_nowait(abort_req->q, NULL, abort_req, 0, abort_endio); @@ -2283,7 +2282,6 @@ static int nvme_delete_queue(struct nvme_queue *nvmeq, u8 opcode) if (IS_ERR(req)) return PTR_ERR(req); - req->timeout = ADMIN_TIMEOUT; req->end_io_data = nvmeq; init_completion(&nvmeq->delete_done); -- 2.35.1