Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2744445ybg; Mon, 28 Oct 2019 01:27:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMdvphLig6ozLytLOrYlUWS882sM5FTSlUIqEKLXb9nQ3oIufF7T2v7GbgL6OukkyJGq+G X-Received: by 2002:a05:6402:7cd:: with SMTP id u13mr18325627edy.245.1572251266805; Mon, 28 Oct 2019 01:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572251266; cv=none; d=google.com; s=arc-20160816; b=a655jYJ3A6pIQEp+SucKRbvNImjZAQj2VYFCjppAdbuO2lr75yQzcI+UG7TrKbgtZO y7F7vTop5qJWFEkUnGUNw1tO9muBN8+eEAJlWqHRJxt5157bLrv1BL5pzvZyi8U+TC3C 6lpifCGG5vP9rqY7wVJDvqKpGwW6tqRrc0Rt3o9oKinm3K6jD2vcJWwem5kMWEYOJqzG gVSpMm0o7Kc/901xVFY5YRodNfMcyT4AhJqhr3NWLMuZdodXddOMLLPeRj3K5j4D4hC2 yC75nTvQoiQud2pr2gOD8eTIyHmZ8Eh9MxNzlHuuvjH5oC+rhu7RzGwvxmzzAIDh0P/v Xeqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rlnGQxaY01Ga5ZmelvnRFEkUDoaR/NWnvN70a6MdilA=; b=VCtsEcMsgeVjpDj74XlV3QiXwWB9gtx4VV+OAolnuDwfliVJDwBw/L8f859vY1dx8j qUI9u5MFvsgkZPVpkTyjO+/gmQ9aWOMjXa1eUZIU2hv9hjpLj0uI2kBfgtbFtvlJc4fE oTk3wdt4CjpcubzdSmm7WqTX+1CeVawwyUpqv1ERNBgKnmRYuxp1h8rK4ZKUK6S7x69g i9VNO0P5hVQ703TVF5GiwvhyXr7gg4sLi7PXAHVD9RDK0XUyKCZAg9/vuJHlm9EyGW42 kSwzMPySvwU9AZOtaJPRv+I9BcX//FZFzfy/LNjF9CZiQxVoXezcuFvpS5fQAkBM0Gpq LaqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RX799BkT; 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 m7si8126313eda.192.2019.10.28.01.26.50; Mon, 28 Oct 2019 01:27:46 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=RX799BkT; 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 S1731633AbfJ0VUH (ORCPT + 99 others); Sun, 27 Oct 2019 17:20:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:40586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731622AbfJ0VUG (ORCPT ); Sun, 27 Oct 2019 17:20:06 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A3A462070B; Sun, 27 Oct 2019 21:20:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211206; bh=uEigrDSO+Ag3UVASUP0pmv4uqt7zouB0tEdl/zaUl3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RX799BkTP8NyaH18CgxZqQiX5vEF9LvWieD+Ep7VEuCwzp7+4KSgM5RlmcZYlIIRK 2x7hzs9B43VnTg9g+tTiHlWKI2hKkeSZQqriq+hfcC3y+xP3vQfcOyCZR8t8BVJ6cF iKabs5m1GDdhuLiQoVICcN9T3xcTX+plHyqJnAko= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Kevin Hao , Keith Busch Subject: [PATCH 5.3 068/197] nvme-pci: Set the prp2 correctly when using more than 4k page Date: Sun, 27 Oct 2019 21:59:46 +0100 Message-Id: <20191027203355.327536227@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203351.684916567@linuxfoundation.org> References: <20191027203351.684916567@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kevin Hao commit a4f40484e7f1dff56bb9f286cc59ffa36e0259eb upstream. In the current code, the nvme is using a fixed 4k PRP entry size, but if the kernel use a page size which is more than 4k, we should consider the situation that the bv_offset may be larger than the dev->ctrl.page_size. Otherwise we may miss setting the prp2 and then cause the command can't be executed correctly. Fixes: dff824b2aadb ("nvme-pci: optimize mapping of small single segment requests") Cc: stable@vger.kernel.org Reviewed-by: Christoph Hellwig Signed-off-by: Kevin Hao Signed-off-by: Keith Busch Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -769,7 +769,8 @@ static blk_status_t nvme_setup_prp_simpl struct bio_vec *bv) { struct nvme_iod *iod = blk_mq_rq_to_pdu(req); - unsigned int first_prp_len = dev->ctrl.page_size - bv->bv_offset; + unsigned int offset = bv->bv_offset & (dev->ctrl.page_size - 1); + unsigned int first_prp_len = dev->ctrl.page_size - offset; iod->first_dma = dma_map_bvec(dev->dev, bv, rq_dma_dir(req), 0); if (dma_mapping_error(dev->dev, iod->first_dma))