Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1073762ybv; Thu, 20 Feb 2020 12:39:26 -0800 (PST) X-Google-Smtp-Source: APXvYqykTAk3Db0irZiewPtitd/R9ScEBDctHjSqekkUGaVamjujfDT5AK8gl5wI8fDpuzXxeeKe X-Received: by 2002:a9d:67c9:: with SMTP id c9mr26361893otn.144.1582231165800; Thu, 20 Feb 2020 12:39:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582231165; cv=none; d=google.com; s=arc-20160816; b=bVTmrc55ZSqmidps8OSx4mxmaaeskV6Nf+E1kAhAMw/hyavE6lq7RS1RG6t9KMl6yC 0ukfwL3ZETr/cSEh5Yj5czMsp1vOOTlLpke0oV2SkOFzFjhb0VSvbrWWKlTVAsIbaWG+ v2ImDJVwqPuD7BHmyzhvBsz1xySzhB9cn/cTI78wMs/q9QXa4LfG2ki+xjMztBeKhGjD OLY6FF7BKE72noN+mS6fgF1wyhxSMXwOV0HWi0wqiwc7xmi+zZfdLSaf32Z/pSGSOcSg pRkcfmpVzQl45s6sOVNGx2EB50EhAzQfezelOEoNOjDChpnKrqmJqwxEeBKGar9STFVB hScA== 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=1qZ7LrIXIbs6w4ScnJQ/dcY7B/eGYmzQXgSiR+tU6fA=; b=bCowBC0RP6qYjvzltCvrbhgwfsIi744UL3TMwWJKbkHigENxOMKcWFCQfuabt/hUaH NCKSTRZFhf4/ZA42XAHekuzVR4KBflg5rHY/vxCBHsUA7GWNtaVZx7mHEXjiHidlFTx/ cRix0wXPh5gXnRxrYGty8WoVgy8LsHNla4TOMSaFDhNcqa+wwwAq1PKE5MNcO4nxevtB Q18ea/O8JvDkU3y6qVs9A8gviWxdkFptwOIZkDS5bCWCBzaev5LkSjm80A5Ytdb7KGXG 3vEApgsBDE5GTc5XijUX0IV8wdapBR4KDAavsBG8yMkSPmCwFJcAWVmcyo7QtsSgELjb lytQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a143si204757oii.179.2020.02.20.12.39.13; Thu, 20 Feb 2020 12:39:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729102AbgBTUhA (ORCPT + 99 others); Thu, 20 Feb 2020 15:37:00 -0500 Received: from ale.deltatee.com ([207.54.116.67]:45112 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728582AbgBTUhA (ORCPT ); Thu, 20 Feb 2020 15:37:00 -0500 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 1j4sZ8-0005cP-BW; Thu, 20 Feb 2020 13:36:59 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1j4sZ7-0006yA-QL; Thu, 20 Feb 2020 13:36:57 -0700 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: Thu, 20 Feb 2020 13:36:45 -0700 Message-Id: <20200220203652.26734-3-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220203652.26734-1-logang@deltatee.com> References: <20200220203652.26734-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 v11 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 --- 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 330b05ef1b16..101137bdfece 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1300,22 +1300,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; @@ -1331,7 +1317,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