Skip to content

Commit

Permalink
iommufd/iova_bitmap: Cache mapped length in iova_bitmap_map struct
Browse files Browse the repository at this point in the history
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/[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]>
(cherry picked from commit a84c690)
Signed-off-by: Matthew R. Ochs <[email protected]>
Acked-by: Kai-Heng Feng <[email protected]>
Acked-by: Koba Ko <[email protected]>
Signed-off-by: Matthew R. Ochs <[email protected]>
  • Loading branch information
jpemartins authored and nvmochs committed Oct 18, 2024
1 parent 99e03cb commit cf346ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/iommu/iommufd/iova_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ struct iova_bitmap_map {
/* base IOVA representing bit 0 of the first page */
unsigned long iova;

/* mapped length */
unsigned long length;

/* page size order that each bit granules to */
unsigned long pgshift;

Expand Down Expand Up @@ -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);
}

static unsigned long iova_bitmap_mapped_length(struct iova_bitmap *bitmap);

/*
* Pins the bitmap user pages for the current range window.
* This is internal to IOVA bitmap and called when advancing the
Expand Down Expand Up @@ -206,6 +211,7 @@ static int iova_bitmap_get(struct iova_bitmap *bitmap)
* aligned.
*/
mapped->pgoff = offset_in_page(addr);
mapped->length = iova_bitmap_mapped_length(bitmap);
return 0;
}

Expand Down

0 comments on commit cf346ad

Please sign in to comment.