Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp688628ybv; Thu, 13 Feb 2020 07:48:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxqD1QQI3HDNMBn1Fpj1KYnxFz5IU579c1wTU5TioSkP8KvrVCIPJvhfwKViDRZeWIr/s0o X-Received: by 2002:aca:6543:: with SMTP id j3mr3285368oiw.150.1581608894203; Thu, 13 Feb 2020 07:48:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608894; cv=none; d=google.com; s=arc-20160816; b=EJzW9jb4ZFGpYEBHAK3UC3ceb+uAJ9xf2pam/BY5ewThmTJCJ478fn05KZK2WFg5gT URPFFfw5B5KgPXgsIFul2VqS7oc8GzK6vRvNKw1OP6pnG52eL5HzkqUzBZ2LapbNb82P p1X5sIzc2VCd/6/pOooq1uWvbS9R7Lwnlzqjr+kQBZaNUEJzWnU4d1d7NZYzEZFmaN2B Ay3yE6wVWATUXmEZi6KN63NegwkhUqy6+MrTL4n8sY/WehS93bMS+/goAi5d6cvX6yhb cw4fdLW1lnnbiDjgfev8LU5htG6p/ViFgiNxn6RpTSY8iRoBzx7c83sZ36FFbahPDFyS toxQ== 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=2MUbViWkdyorP9lkbDJ0E5Aks60u6dR/BBgiOQ8Ok+I=; b=MvP9u1nL8mmzI1MySB2rJGSqznsdy8fpBE/f8n1Y8kMu3zl0ntz5f1SOmpzvXtwOjT OopgZvTinL5zSYT3B5vhqBIrHRbFEh5KBPUW4uiH6XrJJN+MuX2/KBXtEbn+w6Uya2YP m2ZMzJlHdMLpOVpOGl3d/9+30/uKkvu86IsEuIcaS5qo8gxUz697ZuZRp3VRVsA48SIX jtt7kQj0sxIfBTijKoArWAzjd5TEY5qlcyXdQx2epfX4xfK+e57q0WAH/3gqidlL7Vdj vyeYvkYvPaPb7gVmbFLQt4C1j09PS065+5dsaEutPwS4IFm+GmIRzLJpcNPvgjmW/4lk lq2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oRm4rnDU; 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 h9si1247805oti.155.2020.02.13.07.48.01; Thu, 13 Feb 2020 07:48:14 -0800 (PST) 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=oRm4rnDU; 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 S2387978AbgBMPr5 (ORCPT + 99 others); Thu, 13 Feb 2020 10:47:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:47986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727986AbgBMP06 (ORCPT ); Thu, 13 Feb 2020 10:26:58 -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 23AAF24677; Thu, 13 Feb 2020 15:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607618; bh=Qi7UqkWj3azxCJlMz34Rq3df9Z8YUBZlDpzh1tYSrkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oRm4rnDUArGq0hMl+SMRmNOZ4gR0eAHq4lIf04cHObxre5HlF2dTtfv/aZSAfnhiU ZQMcNeIrEnKPPeCJl/iLjXDCswdRMVUI0CMHaEIcnEZf4mTIVp85FSPsRWikZ/LDSU a4cSmhBsacLKdlhA65+w31WpxONhm9OZc6bwJ7DQ= 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.4 11/96] RDMA/umem: Fix ib_umem_find_best_pgsz() Date: Thu, 13 Feb 2020 07:20:18 -0800 Message-Id: <20200213151843.594895581@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@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: 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);