Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2265392iof; Wed, 8 Jun 2022 00:52:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL0hNrT3qWO2eZFcMuQZO3su/YeS4YL9A/USzDi4j6LlSxnxKyJ5wQl1u2h8cCH9JUg70F X-Received: by 2002:a63:2:0:b0:3fe:2558:545 with SMTP id 2-20020a630002000000b003fe25580545mr3224362pga.580.1654674760687; Wed, 08 Jun 2022 00:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654674760; cv=none; d=google.com; s=arc-20160816; b=UUJknRtqgWLVzquw0cT7CLV4Gc/QjzHH9YrP6mM8EKwvaZSrMv+OkuQNT2oqTsbbKl ZXRi9HeavE3rYkfsKsZWEOxHDzuXabKMiUROWiwMvg0L1Zb6HFl5zdEm0A0QfqMJ1AU3 2Yju7usedmnIQvssnGGEXovQuj1IT3pcGHpQuhJxMu8pi/S3+clEfNEyFO0BM50LSBuB tR55wPzICskT431eyP1Ww5gyFbrDzsAtVs0ECU3doe5sA3Xmb3wfPqBdrsKlUm5lJ0/O xO5svxxZ7Whx03b9WuevFj5N99oWyjNjQiTngi1tCpWguerkw3sobLOUHmwI9CDgMot6 k2iA== 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=h7Sz1pIoW70iPtdx94OOYZzAHqdXrWONeYJT8LCQiME=; b=Xogf21T0jb+DvcN+BxjbLLEY/NAOTm6DKuGZxo2qWR5cYX13qCMZF8xOMey3lcspTR SunK6kE/+w+yb5ruD1QpO+ohufR6HnaVrhM+4LrZ6yZkNXRkExp0nnvq8epmD4i6WL76 SYUElKPYtmRPnJ9Iw96Y5YUMhoMEwAxM7Ed7FKNT1jj5Xm3Pjp6/MvAhxlMZ/pzxrRk7 4T2DC1pVNJfCdKBdug7vdwHwrHXfyqRRnnLHAcO4WEt1/Fl5PI1lAZB89pbrYlvS6DJD QJxxM+xGYwbSjx1kGTwPqqdAIPty2L+wS8nllCqNUsKAmyxVSumzshEhlDoLmmDpZTNf 2JUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="v4z/K292"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id kk18-20020a17090b4a1200b001df4a0f2605si20031765pjb.2.2022.06.08.00.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 00:52:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="v4z/K292"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C1BCE1CE7A8; Wed, 8 Jun 2022 00:22:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381833AbiFGWTe (ORCPT + 99 others); Tue, 7 Jun 2022 18:19:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346961AbiFGVNr (ORCPT ); Tue, 7 Jun 2022 17:13:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55FE121AC46; Tue, 7 Jun 2022 11:54:29 -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 A8077B82018; Tue, 7 Jun 2022 18:54:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19785C385A5; Tue, 7 Jun 2022 18:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628066; bh=q3LpIfPSwOGe/mvSWUmd9l5vhrYfQkqCQRcFEYW08qE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v4z/K2928vMxMevcc+2G6zT+bjnLBhNCx/rz67Xcy1zlulZoY/geWqQ+zHkVrR/ND RNxAVj9G28/DFrCIets1+nX7B6FH9Hbu8q65/0jg+KYAycqeCGbE6gBRelzmU2W7Do bKIM6Zbg2tLK7jjC6xMSyRCzlopH5I4n0HmD/IZk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chaitanya Kulkarni , Keith Busch , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.18 192/879] nvme: set non-mdts limits in nvme_scan_work Date: Tue, 7 Jun 2022 18:55:10 +0200 Message-Id: <20220607165008.414623997@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 78288665b5d0154978fed431985310cb4f166836 ] In current implementation we set the non-mdts limits by calling nvme_init_non_mdts_limits() from nvme_init_ctrl_finish(). This also tries to set the limits for the discovery controller which has no I/O queues resulting in the warning message reported by the nvme_log_error() when running blktest nvme/002: - [ 2005.155946] run blktests nvme/002 at 2022-04-09 16:57:47 [ 2005.192223] loop: module loaded [ 2005.196429] nvmet: adding nsid 1 to subsystem blktests-subsystem-0 [ 2005.200334] nvmet: adding nsid 1 to subsystem blktests-subsystem-1 <------------------------------SNIP----------------------------------> [ 2008.958108] nvmet: adding nsid 1 to subsystem blktests-subsystem-997 [ 2008.962082] nvmet: adding nsid 1 to subsystem blktests-subsystem-998 [ 2008.966102] nvmet: adding nsid 1 to subsystem blktests-subsystem-999 [ 2008.973132] nvmet: creating discovery controller 1 for subsystem nqn.2014-08.org.nvmexpress.discovery for NQN testhostnqn. *[ 2008.973196] nvme1: Identify(0x6), Invalid Field in Command (sct 0x0 / sc 0x2) MORE DNR* [ 2008.974595] nvme nvme1: new ctrl: "nqn.2014-08.org.nvmexpress.discovery" [ 2009.103248] nvme nvme1: Removing ctrl: NQN "nqn.2014-08.org.nvmexpress.discovery" Move the call of nvme_init_non_mdts_limits() to nvme_scan_work() after we verify that I/O queues are created since that is a converging point for each transport where these limits are actually used. 1. FC : nvme_fc_create_association() ... nvme_fc_create_io_queues(ctrl); ... nvme_start_ctrl() nvme_scan_queue() nvme_scan_work() 2. PCIe:- nvme_reset_work() ... nvme_setup_io_queues() nvme_create_io_queues() nvme_alloc_queue() ... nvme_start_ctrl() nvme_scan_queue() nvme_scan_work() 3. RDMA :- nvme_rdma_setup_ctrl ... nvme_rdma_configure_io_queues ... nvme_start_ctrl() nvme_scan_queue() nvme_scan_work() 4. TCP :- nvme_tcp_setup_ctrl ... nvme_tcp_configure_io_queues ... nvme_start_ctrl() nvme_scan_queue() nvme_scan_work() * nvme_scan_work() ... nvme_validate_or_alloc_ns() nvme_alloc_ns() nvme_update_ns_info() nvme_update_disk_info() nvme_config_discard() <--- blk_queue_max_write_zeroes_sectors() <--- Signed-off-by: Chaitanya Kulkarni Reviewed-by: Keith Busch Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index e1846d04817f..ac32d1cd8477 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3080,10 +3080,6 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl) if (ret) return ret; - ret = nvme_init_non_mdts_limits(ctrl); - if (ret < 0) - return ret; - ret = nvme_configure_apst(ctrl); if (ret < 0) return ret; @@ -4237,11 +4233,26 @@ static void nvme_scan_work(struct work_struct *work) { struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, scan_work); + int ret; /* No tagset on a live ctrl means IO queues could not created */ if (ctrl->state != NVME_CTRL_LIVE || !ctrl->tagset) return; + /* + * Identify controller limits can change at controller reset due to + * new firmware download, even though it is not common we cannot ignore + * such scenario. Controller's non-mdts limits are reported in the unit + * of logical blocks that is dependent on the format of attached + * namespace. Hence re-read the limits at the time of ns allocation. + */ + ret = nvme_init_non_mdts_limits(ctrl); + if (ret < 0) { + dev_warn(ctrl->device, + "reading non-mdts-limits failed: %d\n", ret); + return; + } + if (test_and_clear_bit(NVME_AER_NOTICE_NS_CHANGED, &ctrl->events)) { dev_info(ctrl->device, "rescanning namespaces.\n"); nvme_clear_changed_ns_log(ctrl); -- 2.35.1