IB/mlx5: Simplify mlx5_ib_cont_pages
authorIlya Lesokhin <ilyal@mellanox.com>
Sun, 24 Sep 2017 18:46:34 +0000 (21:46 +0300)
committerDoug Ledford <dledford@redhat.com>
Mon, 25 Sep 2017 15:47:24 +0000 (11:47 -0400)
commitd67bc5d4e3e100d762c0f57ea67f28bc219698a6
tree97c09abe7880086ebb17cecb43359b58e75c9605
parent7c9d9662103ae1c11acc7bfc47d988466cff23cf
IB/mlx5: Simplify mlx5_ib_cont_pages

The patch simplifies mlx5_ib_cont_pages and fixes the following
issues in the original implementation:

First issues is related to alignment of the PFNs. After the check
base + p != PFN, the alignment of the PFN wasn't checked. So the PFN
sequence 0, 1, 1, 2 would result in a page_shift of 13 even though
the 3rd PFN is not 8KB aligned.

This wasn't actually a bug because it was supported by all the
existing mlx5 compatible device, but we don't want to require
this support in all future devices.

Another issue is because the inner loop didn't advance PFN so
the test "if (base + p != pfn)" always failed for SGE with
len > (1<<page_shift).

Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Signed-off-by: Ilya Lesokhin <ilyal@mellanox.com>
Reviewed-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx5/mem.c