iommufd/iova_bitmap: Check iova_bitmap_done() after set ahead
BugLink: https://bugs.launchpad.net/bugs/2083196
[ Upstream commit 792583656f554e35383d6b2325371c8fe056a56b ]
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: 2780025e01 ("iommufd/iova_bitmap: Handle recording beyond the mapped pages")
Link: https://lore.kernel.org/r/20240627110105.62325-7-joao.m.martins@oracle.com
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Tested-by: Matt Ochs <mochs@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Portia Stephens <portia.stephens@canonical.com>
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
73756db541
commit
e0884b3ed0
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user