From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA01BC3B18B for ; Thu, 13 Feb 2020 15:42:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6DA320661 for ; Thu, 13 Feb 2020 15:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581608538; bh=Qi7UqkWj3azxCJlMz34Rq3df9Z8YUBZlDpzh1tYSrkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nhI59IHzHxVoAha81Gw36u61cY6NhTpFbwk0jq9XElQntSDo7+L4+mSraxIPArCcI rW/dPVIuK6w9JkoAL3vuWQqqImZDVXWZ+Zsvqo9/drAeG9R3KocyNmw996Eyr3mOjw CbBwLuFd3BwyX/1lO0qNzESAUU0SG7Y5BSiSzR7I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729222AbgBMPmH (ORCPT ); Thu, 13 Feb 2020 10:42:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:55144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387433AbgBMP2S (ORCPT ); Thu, 13 Feb 2020 10:28:18 -0500 Received: from localhost (unknown [104.132.1.104]) (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 6439B24677; Thu, 13 Feb 2020 15:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607697; bh=Qi7UqkWj3azxCJlMz34Rq3df9Z8YUBZlDpzh1tYSrkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eeft0rl/NW6LvU/+5VcF74XEDEb5obRdfIMAUob43+U2TgV+lTZRc0q+Flbt0FCXt rj51siyiXAhs6weJ0o4rSg9pzQ+AWzuTbo6RJuwdQ3MbCC8i6f8nDsAc2iW3S+oIbR LdAUcJnMhmNykumR3Y+tZ2hLYyOdzY9M8k6NeQL0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Artemy Kovalyov , Leon Romanovsky , Gal Pressman , Jason Gunthorpe Subject: [PATCH 5.5 012/120] RDMA/umem: Fix ib_umem_find_best_pgsz() Date: Thu, 13 Feb 2020 07:20:08 -0800 Message-Id: <20200213151905.799749780@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151901.039700531@linuxfoundation.org> References: <20200213151901.039700531@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Artemy Kovalyov commit 36798d5ae1af62e830c5e045b2e41ce038690c61 upstream. Except for the last entry, the ending iova alignment sets the maximum possible page size as the low bits of the iova must be zero when starting the next chunk. Fixes: 4a35339958f1 ("RDMA/umem: Add API to find best driver supported page size in an MR") Link: https://lore.kernel.org/r/20200128135612.174820-1-leon@kernel.org Signed-off-by: Artemy Kovalyov Signed-off-by: Leon Romanovsky Tested-by: Gal Pressman Reviewed-by: Jason Gunthorpe Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/umem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -166,10 +166,13 @@ unsigned long ib_umem_find_best_pgsz(str * for any address. */ mask |= (sg_dma_address(sg) + pgoff) ^ va; - if (i && i != (umem->nmap - 1)) - /* restrict by length as well for interior SGEs */ - mask |= sg_dma_len(sg); va += sg_dma_len(sg) - pgoff; + /* Except for the last entry, the ending iova alignment sets + * the maximum possible page size as the low bits of the iova + * must be zero when starting the next chunk. + */ + if (i != (umem->nmap - 1)) + mask |= va; pgoff = 0; } best_pg_bit = rdma_find_pg_bit(mask, pgsz_bitmap);