Commit a84c690e authored by Joao Martins's avatar Joao Martins Committed by Jason Gunthorpe

iommufd/iova_bitmap: Cache mapped length in iova_bitmap_map struct

The amount of IOVA mapped will be used more often in iova_bitmap_set() in
preparation to dynamically iterate the bitmap. Cache said length to avoid
having to calculate it all the time.

Link: https://lore.kernel.org/r/20240627110105.62325-8-joao.m.martins@oracle.comSigned-off-by: default avatarJoao Martins <joao.m.martins@oracle.com>
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Tested-by: default avatarMatt Ochs <mochs@nvidia.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 79258365
...@@ -35,6 +35,9 @@ struct iova_bitmap_map { ...@@ -35,6 +35,9 @@ struct iova_bitmap_map {
/* base IOVA representing bit 0 of the first page */ /* base IOVA representing bit 0 of the first page */
unsigned long iova; unsigned long iova;
/* mapped length */
unsigned long length;
/* page size order that each bit granules to */ /* page size order that each bit granules to */
unsigned long pgshift; unsigned long pgshift;
...@@ -156,6 +159,8 @@ static unsigned long iova_bitmap_mapped_iova(struct iova_bitmap *bitmap) ...@@ -156,6 +159,8 @@ static unsigned long iova_bitmap_mapped_iova(struct iova_bitmap *bitmap)
return bitmap->iova + iova_bitmap_index_to_offset(bitmap, skip); return bitmap->iova + iova_bitmap_index_to_offset(bitmap, skip);
} }
static unsigned long iova_bitmap_mapped_length(struct iova_bitmap *bitmap);
/* /*
* Pins the bitmap user pages for the current range window. * Pins the bitmap user pages for the current range window.
* This is internal to IOVA bitmap and called when advancing the * This is internal to IOVA bitmap and called when advancing the
...@@ -206,6 +211,7 @@ static int iova_bitmap_get(struct iova_bitmap *bitmap) ...@@ -206,6 +211,7 @@ static int iova_bitmap_get(struct iova_bitmap *bitmap)
* aligned. * aligned.
*/ */
mapped->pgoff = offset_in_page(addr); mapped->pgoff = offset_in_page(addr);
mapped->length = iova_bitmap_mapped_length(bitmap);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment