Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp723666ybt; Fri, 26 Jun 2020 10:00:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5I9H5ljhSS3cGubfXwo5pMSkgRxaOHq7ADbzebVGZM6imnmGb+rYdPyNZmVSfDGYEJoX2 X-Received: by 2002:a17:906:3fd2:: with SMTP id k18mr3576869ejj.387.1593190833060; Fri, 26 Jun 2020 10:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593190833; cv=none; d=google.com; s=arc-20160816; b=kdJOy8jkZXXhvamNgrzgm4PqkjVqlyJTziBdCyxlrKd1r8P2kbdfkf/VYsKbxwK3Mg Gezi7NJYCwhEiuYs50zaGDYHDxQOkZBrPgpKTqcLlP9G3h6jc9zzV3kGLiNEcoa8ghPO dr773r+695SHVvzL8K69pS2sra7gsj+S29OdjTvuM6RXCb8U4bOsrTCe+WNq2cCNOsdR GkQKsme9jKwCtKGU3U6joYU/56kC7tInWfPRBjKUH0Q5iG1fm1G4zAYEHNK/VaWMfx+A XKdRX3MPHPNvjFiP8jmsXxwt6RfQYoEF1wCuFu6ruZCpb8sdPpnwaEpRxNS/u0kebCi4 4bag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from :dkim-signature; bh=YVpFGCh6EGMUx4V1DZhBcdqMu33QeEIPAYjGc/iH+uU=; b=aq/sqcDC9RzAoqq/A5VlrTcS12ny5tT+zu344Qkksen84tvbAj6CvOtIV2bEkIDVWC +To5RELKOHBbl5iJPKGEfW61B+nWcRPQyXRxhhM+y3FEa4jcRfJd7vPh2EeWIRTBT5wQ ReSxqMH8dMyPMb4UFt59lgwYOwfponnMNa7BBjJ5dhrsLRnFPyTtV6r9fjjHsnwVxBPZ ii5xNLa53lZcUE71rEYBUu7uadpQq02J2lFZX2pjxW8PL8v+ZHo12m3DFCrpOBvL0aHo rwpQxzFNtMHKlCJVKXxupqaYJ/dkhDu5J3uADPl82Y7HA7tp1oz5IrunEHDAUi9oQw0n mOGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@deltatee.com header.s=20200525 header.b=bB22qYrC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ob24si16305957ejb.701.2020.06.26.10.00.08; Fri, 26 Jun 2020 10:00:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@deltatee.com header.s=20200525 header.b=bB22qYrC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729843AbgFZPk1 (ORCPT + 99 others); Fri, 26 Jun 2020 11:40:27 -0400 Received: from ale.deltatee.com ([207.54.116.67]:34834 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729724AbgFZPjh (ORCPT ); Fri, 26 Jun 2020 11:39:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=YVpFGCh6EGMUx4V1DZhBcdqMu33QeEIPAYjGc/iH+uU=; b=bB22qYrCaEH9GS6N7EoA2Hnmx6 kz5rUm+2e5XV/Gj2EQT6dPMNvv4M3gdJHG0qKR/ZZ/zjqbrbDOHJrtIxZFxaNYfaE6JDLMz6GNlX/ PDl+5dNtcLgsz33mmmaI2qkZpAlTjeYCiezLssfi5ltKhF2FJ8yefcPxjT0DWKg79DzcWzzyZFU3d lBrTIm3ClC8hvTWCCoMhYGM2etUbH+Z2uAzBd0x+7oAM0JztUu+9ygB7CFBsHOwef/sP9mnLh3QsD UyqO7b2REM1LkRFGI3j4I0auOUgLmxgVkY4U8IpJ77YQ3+5Xc0iwG3PPybg2Luq3R4zyVCSItEWJV F5c598pQ==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1joqRu-0000oP-43; Fri, 26 Jun 2020 09:39:34 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1joqRm-0007HQ-Tv; Fri, 26 Jun 2020 09:39:22 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Christoph Hellwig , Sagi Grimberg , Keith Busch , Jens Axboe , Chaitanya Kulkarni , Max Gurtovoy , Stephen Bates , Logan Gunthorpe Date: Fri, 26 Jun 2020 09:39:11 -0600 Message-Id: <20200626153918.27929-3-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200626153918.27929-1-logang@deltatee.com> References: <20200626153918.27929-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, hch@lst.de, sagi@grimberg.me, kbusch@kernel.org, axboe@fb.com, Chaitanya.Kulkarni@wdc.com, maxg@mellanox.com, sbates@raithlin.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v14 2/9] nvme: Create helper function to obtain command effects X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Separate the code to obtain command effects from the code to start a passthru request and open code nvme_known_admin_effects() in the new helper. The new helper function will be necessary for nvmet passthru code to determine if we need to change out of interrupt context to handle the effects. Signed-off-by: Logan Gunthorpe Reviewed-by: Sagi Grimberg --- drivers/nvme/host/core.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index c0f5d82f2c3d..85521a523076 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1326,22 +1326,8 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) metadata, meta_len, lower_32_bits(io.slba), NULL, 0); } -static u32 nvme_known_admin_effects(u8 opcode) -{ - switch (opcode) { - case nvme_admin_format_nvm: - return NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC | - NVME_CMD_EFFECTS_CSE_MASK; - case nvme_admin_sanitize_nvm: - return NVME_CMD_EFFECTS_CSE_MASK; - default: - break; - } - return 0; -} - -static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, - u8 opcode) +static u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns, + u8 opcode) { u32 effects = 0; @@ -1357,7 +1343,26 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, if (ctrl->effects) effects = le32_to_cpu(ctrl->effects->acs[opcode]); - effects |= nvme_known_admin_effects(opcode); + + switch (opcode) { + case nvme_admin_format_nvm: + effects |= NVME_CMD_EFFECTS_CSUPP | NVME_CMD_EFFECTS_LBCC | + NVME_CMD_EFFECTS_CSE_MASK; + break; + case nvme_admin_sanitize_nvm: + effects |= NVME_CMD_EFFECTS_CSE_MASK; + break; + default: + break; + } + + return effects; +} + +static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, + u8 opcode) +{ + u32 effects = nvme_command_effects(ctrl, ns, opcode); /* * For simplicity, IO to all namespaces is quiesced even if the command -- 2.20.1