Skip to content

Commit 7ce8549

Browse files
committed
vfio/type1: Convert all vaddr_get_pfns() callers to use vfio_batch
jira LE-3557 Rebuild_History Non-Buildable kernel-5.14.0-570.26.1.el9_6 commit-author Alex Williamson <[email protected]> commit 7a701e9 This is a step towards passing the structure to vaddr_get_pfns() directly in order to provide greater distinction between page backed pfns and pfnmaps. Reviewed-by: Peter Xu <[email protected]> Reviewed-by: Mitchell Augustin <[email protected]> Tested-by: Mitchell Augustin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]> (cherry picked from commit 7a701e9) Signed-off-by: Jonathan Maple <[email protected]>
1 parent ce902cc commit 7ce8549

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

drivers/vfio/vfio_iommu_type1.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,12 @@ static int put_pfn(unsigned long pfn, int prot)
474474

475475
#define VFIO_BATCH_MAX_CAPACITY (PAGE_SIZE / sizeof(struct page *))
476476

477-
static void vfio_batch_init(struct vfio_batch *batch)
477+
static void __vfio_batch_init(struct vfio_batch *batch, bool single)
478478
{
479479
batch->size = 0;
480480
batch->offset = 0;
481481

482-
if (unlikely(disable_hugepages))
482+
if (single || unlikely(disable_hugepages))
483483
goto fallback;
484484

485485
batch->pages = (struct page **) __get_free_page(GFP_KERNEL);
@@ -494,6 +494,16 @@ static void vfio_batch_init(struct vfio_batch *batch)
494494
batch->capacity = 1;
495495
}
496496

497+
static void vfio_batch_init(struct vfio_batch *batch)
498+
{
499+
__vfio_batch_init(batch, false);
500+
}
501+
502+
static void vfio_batch_init_single(struct vfio_batch *batch)
503+
{
504+
__vfio_batch_init(batch, true);
505+
}
506+
497507
static void vfio_batch_unpin(struct vfio_batch *batch, struct vfio_dma *dma)
498508
{
499509
while (batch->size) {
@@ -737,15 +747,17 @@ static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
737747
static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
738748
unsigned long *pfn_base, bool do_accounting)
739749
{
740-
struct page *pages[1];
750+
struct vfio_batch batch;
741751
struct mm_struct *mm;
742752
int ret;
743753

744754
mm = dma->mm;
745755
if (!mmget_not_zero(mm))
746756
return -ENODEV;
747757

748-
ret = vaddr_get_pfns(mm, vaddr, 1, dma->prot, pfn_base, pages);
758+
vfio_batch_init_single(&batch);
759+
760+
ret = vaddr_get_pfns(mm, vaddr, 1, dma->prot, pfn_base, batch.pages);
749761
if (ret != 1)
750762
goto out;
751763

@@ -764,6 +776,7 @@ static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
764776
}
765777

766778
out:
779+
vfio_batch_fini(&batch);
767780
mmput(mm);
768781
return ret;
769782
}

0 commit comments

Comments
 (0)