Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9116288pxu; Mon, 28 Dec 2020 07:03:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJycejYNAy7SGWxdNnTCVUcHibNXa42gAU2bFWPdt5Q6NCvfkv0Wa0T9jL+5pVnLTSoxajoI X-Received: by 2002:a05:6402:1803:: with SMTP id g3mr43193767edy.10.1609167823169; Mon, 28 Dec 2020 07:03:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167823; cv=none; d=google.com; s=arc-20160816; b=aKYt8Ruc2rFv06C1urZLXISQNElb+pi7AceBix1AqS8u//Il90iBX0s85k2+RkU0qK QkTI0uz/6YSjL9/r16zhFiCMq40aj3LX+E8OAC7M8+AZPHQbV2/FF/8W1TuB8rVnuiaQ 2bPAcLxitFJcNGgeBHwbpesW5AtU4PoIuYtFjHKEmKAvWM6rtniCYx+lrZ63bU5+9h3R uJt+rmUPFE+mtdsxiEn/Or2fyPvlfjP50gFxjVub1MO/Qa5eUEHTabmOfOLIaV5PQ9Vd juXf3mbFSIsL4XS+v+wOyKwxdJovWwkjbk3gPmowATOetAtVUWY5SixvYB2SCX8YN5ml WwZQ== 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=X+hU5nlEN68bOZcqDoGe4dHWoiKHctvlKc3BI4ByRmE=; b=uxuCKM5e6VzsGWj6Y/BlPrs26rHQQpJTypvJ1dOFnLkyT+yaIaMNpDVoYXwOrO4v/D PJFJyVKe9nd6T0ydgpg65u2XWSjc4c9zSkjqNsF2EwnDhM+slHz+vS44bI0eRh9sK2Tx 3BsRdkNpWK7D7mDPG51eo4w99ScjTGAkCB/RxizHOppXwDQBjYfC5eF/YB55aAh8DJuh uvyR5Yszj6ZPtlbsIdwcG+bFLr9fpr/s0tNfSGbNJuKeW1hFK0VBUO/jLS0nV0bgVmnv qQYhMmcIA3ziUbphVu2vB0QYZjdU+YS2Cqtp1FgB2SFfW8bHozgphNSUaE0J5jRkBDmj FRNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ShLSdvCE; 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 gu1si2226231ejb.20.2020.12.28.07.03.19; Mon, 28 Dec 2020 07:03:43 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ShLSdvCE; 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 S2440102AbgL1ONN (ORCPT + 99 others); Mon, 28 Dec 2020 09:13:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:45022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439522AbgL1OLM (ORCPT ); Mon, 28 Dec 2020 09:11:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 334E8206C3; Mon, 28 Dec 2020 14:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164656; bh=dc5OAZpa9xNIsOyxCytIC9WiWqe3rcRfKFLxic3kvz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ShLSdvCEHqugpwQc3UHfo5nn8ugKxLVKWeAS/JJxOGocfUHMBlWuQpe32s+xsuuj+ RDsxmSO16vbZsjeVhsWYnfRSyGAdhG8Ois9/OUBGoKbApu3gHEJNHw4UCpGcGxktGa xVnSfo0RpcytQKgUFpxjwDudTnnbokH7lSNXN12s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yangyang Li , Weihang Li , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 252/717] RDMA/hns: Bugfix for calculation of extended sge Date: Mon, 28 Dec 2020 13:44:10 +0100 Message-Id: <20201228125033.060064393@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Yangyang Li [ Upstream commit d34895c319faa1e0fc1a48c3b06bba6a8a39ba44 ] Page alignment is required when setting the number of extended sge according to the hardware's achivement. If the space of needed extended sge is greater than one page, the roundup_pow_of_two() can ensure that. But if the needed extended sge isn't 0 and can not be filled in a whole page, the driver should align it specifically. Fixes: 54d6638765b0 ("RDMA/hns: Optimize WQE buffer size calculating process") Link: https://lore.kernel.org/r/1606558959-48510-3-git-send-email-liweihang@huawei.com Signed-off-by: Yangyang Li Signed-off-by: Weihang Li Reviewed-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/hns/hns_roce_qp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c index 6c081dd985fc9..71ea8fd9041b9 100644 --- a/drivers/infiniband/hw/hns/hns_roce_qp.c +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c @@ -432,7 +432,12 @@ static int set_extend_sge_param(struct hns_roce_dev *hr_dev, u32 sq_wqe_cnt, } hr_qp->sge.sge_shift = HNS_ROCE_SGE_SHIFT; - hr_qp->sge.sge_cnt = cnt; + + /* If the number of extended sge is not zero, they MUST use the + * space of HNS_HW_PAGE_SIZE at least. + */ + hr_qp->sge.sge_cnt = cnt ? + max(cnt, (u32)HNS_HW_PAGE_SIZE / HNS_ROCE_SGE_SIZE) : 0; return 0; } -- 2.27.0