Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp166993ybl; Thu, 12 Dec 2019 15:57:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwNT68FB8K1Dr8FnztGWdIwdE61f5gEa/mxJRR60w0s7p8/79rvz2xj2x/Jmi9GXmq7xvxI X-Received: by 2002:a05:6830:15a:: with SMTP id j26mr10863244otp.137.1576195039219; Thu, 12 Dec 2019 15:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576195039; cv=none; d=google.com; s=arc-20160816; b=FoA+JGabCIRhox/RH+ZuxvYJraYGtoMjGWcONmxd00zrkJjHKqe0Hruzcu6QS9ylEa h3XmI0ZxKrnmpvOwaHW3nf2slm7I4dgFXxg5GTlJvcX9W5ng5t+bIxHoKC1Mukjo67MX xnYR31jNdn2LPC3ulQ+3lTW8uqttVNeKrqxd6V2FmFNiDF841+hesAlsuCg5YOKHl2Dr ZH9wlzpd0AtdtYxNV/K6ndOR2hMGPAlDYOKb9ldkkFFk0T+AR3pounVWDVzRv1It/xwe D9xUTVc8mIvzhvCTFg+JD5B8xyU9W64bLQH3tb4WQfh7+OOVqsG/eCWTfjGRqlSgKa/C Kgsg== 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=rPoHlHmJDteLpXBh03uTxxKCEZ3vZiZzAeaJw+CCMSA=; b=HpaksV4isyDdArbpuTmTaWVG0D+iWolev93PswwQbbtteXzzrrOrcxqT3T/q36M5jA fxEJBDeS9fzvxCrEiDxlV8KRlm0hN9l+nIgBgqwvK499MjIn+CnxBY+Toafqs7nreCDi npiQDpAaYGJ4ZxuZ0E4Mlndiu/ZMh8mQoKhWIDSEqzsA3wCMuXNPWIMatvr4yJktzwHT lj/MI2IfJh2jLfwZXt36AUuzKfe1FZ/6X3FjXJ13cHchgF6yw/Jvvlf3FGhqMtMAgXNk XseKgF69QlcwYiFSpRdw7+sQN72UbyvQr76ofsF0TUwAyv2v0jNzTSwGxunJfQ7rgg3x MKBA== 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 u6si4419659oth.29.2019.12.12.15.56.58; Thu, 12 Dec 2019 15:57:19 -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 S1731513AbfLLXzF (ORCPT + 99 others); Thu, 12 Dec 2019 18:55:05 -0500 Received: from ale.deltatee.com ([207.54.116.67]:55876 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731425AbfLLXyh (ORCPT ); Thu, 12 Dec 2019 18:54:37 -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 1ifYHt-0004ZF-IM; Thu, 12 Dec 2019 16:54:32 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1ifYHn-0005qB-Dr; Thu, 12 Dec 2019 16:54:23 -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, 12 Dec 2019 16:54:11 -0700 Message-Id: <20191212235418.22396-3-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191212235418.22396-1-logang@deltatee.com> References: <20191212235418.22396-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=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT autolearn=ham autolearn_force=no version=3.4.2 Subject: [PATCH v10 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 f71566129d08..1cd325a8cf05 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1298,22 +1298,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; @@ -1329,7 +1315,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