RDMA/mlx5: Fix indirect mkey ODP page count
authorMichael Guralnik <michaelgur@nvidia.com>
Mon, 6 Jan 2025 18:27:10 +0000 (20:27 +0200)
committerLeon Romanovsky <leon@kernel.org>
Mon, 13 Jan 2025 11:40:19 +0000 (06:40 -0500)
commit235f238402194a78ac5fb882a46717eac817e5d1
treeb09ec35aef95029c91f9492748299da053e25b48
parent76b26917e4ff9545b321730cd3b64fdd2e043769
RDMA/mlx5: Fix indirect mkey ODP page count

Restrict the check for the number of pages handled during an ODP page
fault to direct mkeys.
Perform the check right after handling the page fault and don't
propagate the number of handled pages to callers.

Indirect mkeys and their associated direct mkeys can have different
start addresses. As a result, the calculation of the number of pages to
handle for an indirect mkey may not match the actual page fault
handling done on the direct mkey.

For example:
A 4K sized page fault on a KSM mkey that has a start address that is not
aligned to a page will result a calculation that assumes the number of
pages required to handle are 2.
While the underlying MTT might be aligned will require fetching only a
single page.
Thus, do the calculation and compare number of pages handled only per
direct mkey.

Fixes: db570d7deafb ("IB/mlx5: Add ODP support to MW")
Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Reviewed-by: Artemy Kovalyov <artemyko@nvidia.com>
Link: https://patch.msgid.link/86c483d9e75ce8fe14e9ff85b62df72b779f8ab1.1736187990.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/mlx5/odp.c