Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp285300pxb; Wed, 3 Feb 2021 05:42:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJLzA+a5L5UKH7qrokbfQceSLQdbJL09HgCBzUtGvG+LDHKgu7dM3txdIp9+CGkOz53lMG X-Received: by 2002:a17:906:3484:: with SMTP id g4mr3216977ejb.38.1612359747642; Wed, 03 Feb 2021 05:42:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612359747; cv=none; d=google.com; s=arc-20160816; b=CyXLKLTAVcm5MMY+0Bj+/s6k1Qh/fMzkYd8g0hLaLC2mHvxRMJZfXCq/O5vLUhhawp sg/3vERlDbLk2gHzHpFuTGIqY/jGKm2BUgrywfEBYsh7CMXSQvPO+N5RSFDzus27/qXy BD4RYaktmmeNiyZRTppnObM9+oWilGXZ/mlC3B52DfaalHvNk4bL4rVr2axvH/0ROIdT +uGbRpFkGP85iVueVmxQ0rNWgtJ2JqFgD8IxfdgG6wy5DYyaRAYs4I/VsbVsFfBVsXrU O9gSuLi5a8ttcr9js+tZcLkR2ODuomfNXYzvpA97mvN3z7PiCv7sKfc6RgUVF9i44DYT 527g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=cz6KkiClMWBqBhUhCCdzqR7CEqPcM5OQiZfEW26vLus=; b=DWtMf+9Pq9y9N47Wl/9pD1Yss6bxDIwCpNCcKbbNpWDoFYDPVaQTWwesV7R6dgyTh3 gyGFGV/hdWy7Rcsed7RLA3xR3NRNETTzMyKLrGZTck9JzNpOM7BCCFN8h0QebDf99r2Z uT4x9FmK8JEBkrjtK/xR7CXvQK3Z3vy1BTp1bHDdiTBxVxKchgM/BOplP8htjayEicIv 8g+68NedJ2qqoFSEure+eTlAAqWQDz75ITDADFgNWfs3lyYB4r//0+n7zW1Nxxr6holx xKDL3ib0eeh1UYkMU/FpKFULErx7uKN+GOSQ4fE05p0xPOozAiO/HM82+nPQrhUqWcLD iMYw== 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 r13si1250905ejz.437.2021.02.03.05.42.00; Wed, 03 Feb 2021 05:42:27 -0800 (PST) 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 S231866AbhBCNiT (ORCPT + 99 others); Wed, 3 Feb 2021 08:38:19 -0500 Received: from verein.lst.de ([213.95.11.211]:51287 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbhBCNh7 (ORCPT ); Wed, 3 Feb 2021 08:37:59 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id 6150367357; Wed, 3 Feb 2021 14:37:12 +0100 (CET) Date: Wed, 3 Feb 2021 14:37:12 +0100 From: Christoph Hellwig To: Jianxiong Gao Cc: Keith Busch , Erdem Aktas , Marc Orr , Christoph Hellwig , m.szyprowski@samsung.com, Robin Murphy , gregkh@linuxfoundation.org, Saravana Kannan , heikki.krogerus@linux.intel.com, rafael.j.wysocki@intel.com, Andy Shevchenko , dan.j.williams@intel.com, bgolaszewski@baylibre.com, jroedel@suse.de, iommu@lists.linux-foundation.org, Konrad Rzeszutek Wilk , axboe@fb.com, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 3/3] Adding device_dma_parameters->offset_preserve_mask to NVMe driver. Message-ID: <20210203133712.GA24674@lst.de> References: <20210201183017.3339130-1-jxgao@google.com> <20210201183017.3339130-4-jxgao@google.com> <20210201205759.GA2128135@dhcp-10-100-145-180.wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Please try with this extra patch: --- From 212764c3c15ce859e6f55d2146f450ea4ca6fdb9 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 3 Feb 2021 14:27:13 +0100 Subject: nvme-pci: fix 2nd PRP setup in nvme_setup_prp_simple Use the dma address instead of the bio_vec offset for the arithmetics to find the address for the 2nd PRP. Fixes: dff824b2aadb ("nvme-pci: optimize mapping of small single segment requests") Reported-by: Jianxiong Gao Signed-off-by: Christoph Hellwig --- drivers/nvme/host/pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 30e45f7e0f750c..4ae51735d72f4a 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -808,8 +808,7 @@ static blk_status_t nvme_setup_prp_simple(struct nvme_dev *dev, struct bio_vec *bv) { struct nvme_iod *iod = blk_mq_rq_to_pdu(req); - unsigned int offset = bv->bv_offset & (NVME_CTRL_PAGE_SIZE - 1); - unsigned int first_prp_len = NVME_CTRL_PAGE_SIZE - offset; + dma_addr_t next_prp; iod->first_dma = dma_map_bvec(dev->dev, bv, rq_dma_dir(req), 0); if (dma_mapping_error(dev->dev, iod->first_dma)) @@ -817,8 +816,9 @@ static blk_status_t nvme_setup_prp_simple(struct nvme_dev *dev, iod->dma_len = bv->bv_len; cmnd->dptr.prp1 = cpu_to_le64(iod->first_dma); - if (bv->bv_len > first_prp_len) - cmnd->dptr.prp2 = cpu_to_le64(iod->first_dma + first_prp_len); + next_prp = round_down(iod->first_dma + bv->bv_len, NVME_CTRL_PAGE_SIZE); + if (next_prp > iod->first_dma) + cmnd->dptr.prp2 = cpu_to_le64(next_prp); return BLK_STS_OK; } -- 2.29.2