mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 00:22:00 +02:00
vfio/type1: Convert all vaddr_get_pfns() callers to use vfio_batch
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 <peterx@redhat.com> Reviewed-by: Mitchell Augustin <mitchell.augustin@canonical.com> Tested-by: Mitchell Augustin <mitchell.augustin@canonical.com> Link: https://lore.kernel.org/r/20250218222209.1382449-3-alex.williamson@redhat.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
afe84f3b7a
commit
7a701e90fc
|
|
@ -471,12 +471,12 @@ static int put_pfn(unsigned long pfn, int prot)
|
|||
|
||||
#define VFIO_BATCH_MAX_CAPACITY (PAGE_SIZE / sizeof(struct page *))
|
||||
|
||||
static void vfio_batch_init(struct vfio_batch *batch)
|
||||
static void __vfio_batch_init(struct vfio_batch *batch, bool single)
|
||||
{
|
||||
batch->size = 0;
|
||||
batch->offset = 0;
|
||||
|
||||
if (unlikely(disable_hugepages))
|
||||
if (single || unlikely(disable_hugepages))
|
||||
goto fallback;
|
||||
|
||||
batch->pages = (struct page **) __get_free_page(GFP_KERNEL);
|
||||
|
|
@ -491,6 +491,16 @@ static void vfio_batch_init(struct vfio_batch *batch)
|
|||
batch->capacity = 1;
|
||||
}
|
||||
|
||||
static void vfio_batch_init(struct vfio_batch *batch)
|
||||
{
|
||||
__vfio_batch_init(batch, false);
|
||||
}
|
||||
|
||||
static void vfio_batch_init_single(struct vfio_batch *batch)
|
||||
{
|
||||
__vfio_batch_init(batch, true);
|
||||
}
|
||||
|
||||
static void vfio_batch_unpin(struct vfio_batch *batch, struct vfio_dma *dma)
|
||||
{
|
||||
while (batch->size) {
|
||||
|
|
@ -730,7 +740,7 @@ static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
|
|||
static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
|
||||
unsigned long *pfn_base, bool do_accounting)
|
||||
{
|
||||
struct page *pages[1];
|
||||
struct vfio_batch batch;
|
||||
struct mm_struct *mm;
|
||||
int ret;
|
||||
|
||||
|
|
@ -738,7 +748,9 @@ static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
|
|||
if (!mmget_not_zero(mm))
|
||||
return -ENODEV;
|
||||
|
||||
ret = vaddr_get_pfns(mm, vaddr, 1, dma->prot, pfn_base, pages);
|
||||
vfio_batch_init_single(&batch);
|
||||
|
||||
ret = vaddr_get_pfns(mm, vaddr, 1, dma->prot, pfn_base, batch.pages);
|
||||
if (ret != 1)
|
||||
goto out;
|
||||
|
||||
|
|
@ -757,6 +769,7 @@ static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
|
|||
}
|
||||
|
||||
out:
|
||||
vfio_batch_fini(&batch);
|
||||
mmput(mm);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user