Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5144801pxj; Wed, 9 Jun 2021 10:07:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNMGpIkUfGJ10nilcTtk/cMBw/iwfK0/Lkk45SV7XYNV6mIl07g/yxXBQNYnHjM72OH9ff X-Received: by 2002:a17:906:b41:: with SMTP id v1mr860573ejg.246.1623258470720; Wed, 09 Jun 2021 10:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623258470; cv=none; d=google.com; s=arc-20160816; b=FPPJLUZNGQddJvNqDTFiFGDdogrypXYhKLtOIaJObcyPFes+jwRM40frrcoyY3eF9S iZOYSZW3GnJECxcVi4ZYI7nn6BzYis7JXAt7gASdiD+IHSQKdD8bMEYmihvkiksMH2Ar iCPFsRAERr1KoC63daykpoMn4oTcGh2ZpQ6orTaX8yrHBKcgZfW4dfdf5JRGBOEpIzoz BxLgaasBR8ojNbcAxRYZHlaToML1RxYpVrIUr3cAFjP7VQxx+ofCiXCz9QhJ6y7RxMG4 hnqMqBc9Ke2zOW9wWPsxpREOCjjTNVVpOVJDAVUHV/feP11Q9n1ZLuZWcJtGx4Uxj3/T 726Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wglyac9sv178a2YtQDOlod37ROj99AmgvArWnqFGTdI=; b=JSPh49WcDdzd+PP0XLO26m8SAosSOimTCTdWTBXwJ3vWXBzVUM/aLfp5QDswkmJFCC Wzwj2SryesDB/ANgM8YCFRCxV8rAJHWjrph50upNYilelhRdevCSPPCdM9UBx1I1EcAU p64qEK639ujT/qnWLO483vHNUB24/7+Rh2yrsCC25K9GkGybk9uXxZzA+D2ylGsw9PDb dpU85uVPqu3sSmRUlHaf4KHhCBZ/MHGxSAWQY+7c0sbCW0OACSUMq4M1ZK3eQa5q1bdh bAusKSo1CtX6pixjQKWfsTypqcoJBD238QSkHrjP0auMYiIQE+VcN+egmxCgVQaxIu7s jeig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=juW1uIzp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si253912eji.721.2021.06.09.10.07.26; Wed, 09 Jun 2021 10:07:50 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=juW1uIzp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236687AbhFIGU5 (ORCPT + 99 others); Wed, 9 Jun 2021 02:20:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:36460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232973AbhFIGU4 (ORCPT ); Wed, 9 Jun 2021 02:20:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 29F6E6101A; Wed, 9 Jun 2021 06:19:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623219542; bh=ts8xmqJk/pwHSYmRZhFquxYo/UmYjLxgRf8jkeUmvFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=juW1uIzphE/HLsxUx9qIJJvde/kBAY4i7huz33wahz0qL5OcEsvprb3hmJmze6Cjw vJ1npLy5jxEIOX4HGwgkM68BRfnZThpJQ0xEi/jsMlWpPOJHfGQgiiFA3EYkV0k80H aXkYrMGjYOXlpbx4qzFUAFhF1C30ABAhOR4XFSPI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Walker, Benjamin" , Sagi Grimberg , Max Gurtovoy , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.10 022/137] nvme-rdma: fix in-casule data send for chained sgls Date: Tue, 8 Jun 2021 20:26:02 +0200 Message-Id: <20210608175943.167114424@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175942.377073879@linuxfoundation.org> References: <20210608175942.377073879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sagi Grimberg [ Upstream commit 12b2aaadb6d5ef77434e8db21f469f46fe2d392e ] We have only 2 inline sg entries and we allow 4 sg entries for the send wr sge. Larger sgls entries will be chained. However when we build in-capsule send wr sge, we iterate without taking into account that the sgl may be chained and still fit in-capsule (which can happen if the sgl is bigger than 2, but lower-equal to 4). Fix in-capsule data mapping to correctly iterate chained sgls. Fixes: 38e1800275d3 ("nvme-rdma: Avoid preallocating big SGL for data") Reported-by: Walker, Benjamin Signed-off-by: Sagi Grimberg Reviewed-by: Max Gurtovoy Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/rdma.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 8b326508a480..e6d58402b829 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1327,16 +1327,17 @@ static int nvme_rdma_map_sg_inline(struct nvme_rdma_queue *queue, int count) { struct nvme_sgl_desc *sg = &c->common.dptr.sgl; - struct scatterlist *sgl = req->data_sgl.sg_table.sgl; struct ib_sge *sge = &req->sge[1]; + struct scatterlist *sgl; u32 len = 0; int i; - for (i = 0; i < count; i++, sgl++, sge++) { + for_each_sg(req->data_sgl.sg_table.sgl, sgl, count, i) { sge->addr = sg_dma_address(sgl); sge->length = sg_dma_len(sgl); sge->lkey = queue->device->pd->local_dma_lkey; len += sge->length; + sge++; } sg->addr = cpu_to_le64(queue->ctrl->ctrl.icdoff); -- 2.30.2