Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2346170ybh; Fri, 24 Jul 2020 10:26:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVk+aKLlmGhNXcrR1jAZLwb9BoYWyAFCvm1DJKgEZe6R8mySnOMBcVrZ4d/WuKJFUT01d1 X-Received: by 2002:a17:906:c04f:: with SMTP id bm15mr777521ejb.207.1595611578804; Fri, 24 Jul 2020 10:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595611578; cv=none; d=google.com; s=arc-20160816; b=VY3iwmq7ROZkEHz5EjEL8d+TGCZ+Rk/4+42ZUDGmTGfrC10XIaf3W6JVy2sfCMCgHi isVtwi2foFs2f3yXdb0lrEWp5/qN6pYE35nG4hAQTzyMtS3bcrFdIEnessG+7OgyMonB 6zlwiB3RRy8IlnbikiyfpolzChQMxDhDC5RWpnsEM8BMeqf8wQAwpsTl3NhBGH8vNjD5 +9ByF8NL0iNyxPBWWqVPY8k5rq2t74m571dmvC1owZ4x6CFPzxzOygzAZGdNsVnnTXQn lj/XLNlLXtN9Ij+OKc6g3cur+rBwA+v8wqevH7FkToXa7d1PTjGJxKMB/935GG8EC9QD xouw== 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=2UfxIISUaPeKQG++CK8g3xGqVmbeNNUeZkMHeeWJQ1w=; b=lTRec7rpqyLVTyXdjpqtZL9Kznv4ei3ePh/H4X60qonz03J6uk68rvTsjvCCdIYyqO SHGqK8RriXugE8OOT67aLXqREQjPLV/Trh6s7uAUaa0RJH7x1epYLZgHy1XwqU3tJS4p ckQYwd2Z6Z9vRkrz8JwWKIK/t8A/EAZrc720pydS3p7AUDywG+tcLlKBO7/IkkP2etwd IYeHkSFHq/IG+zEgtmHAxIJtytdcDu5lPx6aDncLPdd6iH9pNBDpx48aUaK7YN4UttRR 4vdudMtSdmNtmbNez/LN3GoNkKI1kAZjGLmRgg/bLV+XyJIPH0qca0Jt4BO2pg8AaH0D ciUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@deltatee.com header.s=20200525 header.b=saPSIzft; 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 p2si894099eju.192.2020.07.24.10.25.55; Fri, 24 Jul 2020 10:26:18 -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=saPSIzft; 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 S1727786AbgGXRZa (ORCPT + 99 others); Fri, 24 Jul 2020 13:25:30 -0400 Received: from ale.deltatee.com ([204.191.154.188]:58576 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726512AbgGXRZ2 (ORCPT ); Fri, 24 Jul 2020 13:25:28 -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=2UfxIISUaPeKQG++CK8g3xGqVmbeNNUeZkMHeeWJQ1w=; b=saPSIzftg6ezGmgLjTkCLiv+Ii Y7bozgRTJikeP4c0oDmcT01NQYyTCUZLTYCwzwhq86ooCZlZsA+d9bZ7mp4dES09I/8dGPRKQxLh2 4fSEFPbQLLYQcuS6vtb3vQFNM5hBFtREEmZFTg0EelhRJLIYEzHxbhX8e60X92GMvV5J32gN+jWXl /05eqql1qgRmiWNvqRa7oEIjRtZ5e9tAHoczSiu1u4OLMpndSsDkqo8p9QbVkq4LmY4j00L1VPBJ8 eEdDUQ+KfkstrkMGBR/HJEasXMYWTGp7kQrl52VfgTDjnZiQpZVtJ0YM068/0sOH7k56gfvnYyOR5 WzP6n4TA==; 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 1jz1Rk-0006yn-5m; Fri, 24 Jul 2020 11:25:28 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1jz1Rh-0004G6-VE; Fri, 24 Jul 2020 11:25: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, 24 Jul 2020 11:25:12 -0600 Message-Id: <20200724172520.16318-2-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200724172520.16318-1-logang@deltatee.com> References: <20200724172520.16318-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 v16 1/9] nvme-core: Clear any SGL flags in passthru commands 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 The host driver should decide whether to use SGLs or PRPs and they currently assume the flags are cleared after the call to nvme_setup_cmd(). However, passed-through commands may erroneously set these bits; so clear them for all cases. Signed-off-by: Logan Gunthorpe Reviewed-by: Sagi Grimberg --- drivers/nvme/host/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 1d7c7afb1348..6f80bd78eba6 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -593,6 +593,14 @@ static void nvme_assign_write_stream(struct nvme_ctrl *ctrl, req->q->write_hints[streamid] += blk_rq_bytes(req) >> 9; } +static void nvme_setup_passthrough(struct request *req, + struct nvme_command *cmd) +{ + memcpy(cmd, nvme_req(req)->cmd, sizeof(*cmd)); + /* passthru commands should let the driver set the SGL flags */ + cmd->common.flags &= ~NVME_CMD_SGL_ALL; +} + static inline void nvme_setup_flush(struct nvme_ns *ns, struct nvme_command *cmnd) { @@ -758,7 +766,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req, switch (req_op(req)) { case REQ_OP_DRV_IN: case REQ_OP_DRV_OUT: - memcpy(cmd, nvme_req(req)->cmd, sizeof(*cmd)); + nvme_setup_passthrough(req, cmd); break; case REQ_OP_FLUSH: nvme_setup_flush(ns, cmd); -- 2.20.1