aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Martins <[email protected]>2024-06-27 12:01:00 +0100
committerJason Gunthorpe <[email protected]>2024-06-28 13:12:22 -0300
commit792583656f554e35383d6b2325371c8fe056a56b (patch)
treef21cf2237acf6123bc66c3d54a0814b52ace35ec
parentdceb5304d7263f72333d25e5940254f98b663010 (diff)
iommufd/iova_bitmap: Check iova_bitmap_done() after set ahead
After iova_bitmap_set_ahead() returns it may be at the end of the range. Move iova_bitmap_set_ahead() earlier to avoid unnecessary attempt in trying to pin the next pages by reusing iova_bitmap_done() check. Fixes: 2780025e01e2 ("iommufd/iova_bitmap: Handle recording beyond the mapped pages") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joao Martins <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Tested-by: Matt Ochs <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
-rw-r--r--drivers/iommu/iommufd/iova_bitmap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/iommu/iommufd/iova_bitmap.c b/drivers/iommu/iommufd/iova_bitmap.c
index db8c46bee155..e33ddfc239b5 100644
--- a/drivers/iommu/iommufd/iova_bitmap.c
+++ b/drivers/iommu/iommufd/iova_bitmap.c
@@ -384,8 +384,6 @@ static int iova_bitmap_advance(struct iova_bitmap *bitmap)
bitmap->mapped_base_index += count;
iova_bitmap_put(bitmap);
- if (iova_bitmap_done(bitmap))
- return 0;
/* Iterate, set and skip any bits requested for next iteration */
if (bitmap->set_ahead_length) {
@@ -396,6 +394,9 @@ static int iova_bitmap_advance(struct iova_bitmap *bitmap)
return ret;
}
+ if (iova_bitmap_done(bitmap))
+ return 0;
+
/* When advancing the index we pin the next set of bitmap pages */
return iova_bitmap_get(bitmap);
}