[PATCH] vfio/type1: Absorb num_pages_contiguous()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Objections were raised to adding this helper to common code with only a
single user and dubious generalism.  Pull it back into subsystem code.

Link: https://lore.kernel.org/all/CAHk-=whhYRMS7Xc9k_JBdrGvp++JLmU0T2xXEgn046hWrj7q8Q@xxxxxxxxxxxxxx/
Cc: David Hildenbrand <david@xxxxxxxxxx>
Cc: Jason Gunthorpe <jgg@xxxxxxxxxx>
Cc: Li Zhe <lizhe.67@xxxxxxxxxxxxx>
Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
---
 drivers/vfio/vfio_iommu_type1.c | 22 ++++++++++++++++++++++
 include/linux/mm.h              | 23 -----------------------
 2 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 33384a8c152d..3f06a8d937fa 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -659,6 +659,28 @@ static long vpfn_pages(struct vfio_dma *dma,
 	return ret;
 }
 
+/*
+ * num_pages_contiguous() - determine the number of contiguous pages
+ * starting from the first page.
+ *
+ * Pages are contiguous if they represent contiguous PFNs. Depending on
+ * the memory model, this can mean that the addresses of the "struct page"s
+ * are not contiguous.
+ *
+ * @pages: an array of page pointers
+ * @nr_pages: length of the array
+ */
+static unsigned long num_pages_contiguous(struct page **pages, size_t nr_pages)
+{
+	size_t i;
+
+	for (i = 1; i < nr_pages; i++)
+		if (pages[i] != nth_page(pages[0], i))
+			break;
+
+	return i;
+}
+
 /*
  * Attempt to pin pages.  We really don't want to track all the pfns and
  * the iommu can only map chunks of consecutive pfns anyway, so get the
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fae82df6d7d7..0ef2ba0c667a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1761,29 +1761,6 @@ static inline unsigned long page_to_section(const struct page *page)
 }
 #endif
 
-/*
- * num_pages_contiguous() - determine the number of contiguous pages
- * starting from the first page.
- *
- * Pages are contiguous if they represent contiguous PFNs. Depending on
- * the memory model, this can mean that the addresses of the "struct page"s
- * are not contiguous.
- *
- * @pages: an array of page pointers
- * @nr_pages: length of the array
- */
-static inline unsigned long num_pages_contiguous(struct page **pages,
-						 size_t nr_pages)
-{
-	size_t i;
-
-	for (i = 1; i < nr_pages; i++)
-		if (pages[i] != nth_page(pages[0], i))
-			break;
-
-	return i;
-}
-
 /**
  * folio_pfn - Return the Page Frame Number of a folio.
  * @folio: The folio.
-- 
2.50.1





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux