Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3808145ybz; Mon, 20 Apr 2020 09:49:00 -0700 (PDT) X-Google-Smtp-Source: APiQypJ3RA6M0Mqiomtxp0fSj1ZW8QmHh4/QHIW+Bf0hiXz4xYMlKaKVXWzoLS4xLIvTp7Yu+OrL X-Received: by 2002:a17:906:15d4:: with SMTP id l20mr16782050ejd.91.1587401340814; Mon, 20 Apr 2020 09:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587401340; cv=none; d=google.com; s=arc-20160816; b=NhhBkRlcrFOK72huFowk3izGsdm/BtARi3d51hfvZLI4wW0oQLePsCYUbRgmVbGhDa jAIMMb3huNYXfB7GbRi9L64K8cCexFWo5ERgul78OVElfDWKh6mW2UyxR00pHfT/o+Gc RB+FDQ1JsTUReIx6Hmb6EB/v4i3xY45w5dlsUgnd0sTBvTtwhw7SiSG2iR3CYljvbm/S ZjvOTdZ6+/3vsUDM2PD+WTeRd6HfDpZHuQi3urVEiasWswknGVmDfskUgfQnyQ86HdTI 0oJNVTz128CIstnS7pwxSZAnUwT+Jac0YlQs3TiqDnr4VgsrC1ghMEuSHXJ/AuerXS0Y v0sA== 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; bh=dDHk+wXHxl3amQHKqm6OKVAUPAjCs3M7ydUxA/9Tn/w=; b=WOBPb3T9y92U5sQ3Ll+g2+0Lu/toQu4kTKatveBpbsg+6IZF7KXNQTgdxnvPPfqJ77 t/D9U+UqpRYlz7Ra1ywnDzeja4NdtO6YG0p9/o56PTojjrc6EJ8ApEWJRGago3xG74OD JUU00OVXDhddVBHUpa8xiinfJ1195ifUt5+VSwwKlKU25nKXYCl61UgiSSJvy6n+atG0 tLsp+XJnEo/orybs0EucDhkjC2R7CLzKjzYSRPFuTPRSZK8zl20uavP4spg5VgdhEmFa DsAhgMQqUaglUPGV32+X+agaDtbZDAfC/zEkYB59p9e2QXCLbd8BHebaXmS62pJI3wKs Zonw== ARC-Authentication-Results: i=1; mx.google.com; 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 h23si820098ejs.491.2020.04.20.09.48.36; Mon, 20 Apr 2020 09:49:00 -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; 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 S1726628AbgDTQrY (ORCPT + 99 others); Mon, 20 Apr 2020 12:47:24 -0400 Received: from ale.deltatee.com ([207.54.116.67]:43034 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726484AbgDTQrS (ORCPT ); Mon, 20 Apr 2020 12:47:18 -0400 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 1jQZZb-0008F2-BJ; Mon, 20 Apr 2020 10:47:08 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1jQZZZ-0005df-VF; Mon, 20 Apr 2020 10:47:06 -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: Mon, 20 Apr 2020 10:46:53 -0600 Message-Id: <20200420164700.21620-3-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200420164700.21620-1-logang@deltatee.com> References: <20200420164700.21620-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 autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v12 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 f5283b300e87..fedcc5f18e03 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1317,22 +1317,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; @@ -1348,7 +1334,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