git: d1ea07642c47 - main - LinuxKPI: cleanup internal calls to VM_PAGE_TO_PHYS

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Mon, 07 Aug 2023 01:00:21 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=d1ea07642c47e26effec58f53b7369bf5f797252

commit d1ea07642c47e26effec58f53b7369bf5f797252
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-07-31 03:15:29 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-08-07 00:57:42 +0000

    LinuxKPI: cleanup internal calls to VM_PAGE_TO_PHYS
    
    Replace FreeBSD native VM_PAGE_TO_PHYS() calls with page_to_phys()
    allowing us to work on a struct page in the future using the one
    single public Linux KPI interface to map to a native FreeBSD vm_page.
    
    This should be a NOP.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 weeks
    Reviewed by:    markj
    Differential Revision: https://reviews.freebsd.org/D41256
---
 sys/compat/linuxkpi/common/include/linux/dma-mapping.h | 4 ++--
 sys/compat/linuxkpi/common/include/linux/highmem.h     | 2 +-
 sys/compat/linuxkpi/common/include/linux/scatterlist.h | 4 ++--
 sys/compat/linuxkpi/common/src/linux_page.c            | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/dma-mapping.h b/sys/compat/linuxkpi/common/include/linux/dma-mapping.h
index 01395cc7a0d5..e910545e04fc 100644
--- a/sys/compat/linuxkpi/common/include/linux/dma-mapping.h
+++ b/sys/compat/linuxkpi/common/include/linux/dma-mapping.h
@@ -183,7 +183,7 @@ dma_map_page_attrs(struct device *dev, struct page *page, size_t offset,
     size_t size, enum dma_data_direction dir, unsigned long attrs)
 {
 
-	return (linux_dma_map_phys(dev, VM_PAGE_TO_PHYS(page) + offset, size));
+	return (linux_dma_map_phys(dev, page_to_phys(page) + offset, size));
 }
 
 /* linux_dma_(un)map_sg_attrs does not support attrs yet */
@@ -198,7 +198,7 @@ dma_map_page(struct device *dev, struct page *page,
     unsigned long offset, size_t size, enum dma_data_direction direction)
 {
 
-	return (linux_dma_map_phys(dev, VM_PAGE_TO_PHYS(page) + offset, size));
+	return (linux_dma_map_phys(dev, page_to_phys(page) + offset, size));
 }
 
 static inline void
diff --git a/sys/compat/linuxkpi/common/include/linux/highmem.h b/sys/compat/linuxkpi/common/include/linux/highmem.h
index a3f9af82400e..f770bef6b3b7 100644
--- a/sys/compat/linuxkpi/common/include/linux/highmem.h
+++ b/sys/compat/linuxkpi/common/include/linux/highmem.h
@@ -60,7 +60,7 @@ kmap(struct page *page)
 	struct sf_buf *sf;
 
 	if (PMAP_HAS_DMAP) {
-		return ((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page)));
+		return ((void *)PHYS_TO_DMAP(page_to_phys(page)));
 	} else {
 		sched_pin();
 		sf = sf_buf_alloc(page, SFB_NOWAIT | SFB_CPUPRIVATE);
diff --git a/sys/compat/linuxkpi/common/include/linux/scatterlist.h b/sys/compat/linuxkpi/common/include/linux/scatterlist.h
index b448262f3497..703e0a59e03c 100644
--- a/sys/compat/linuxkpi/common/include/linux/scatterlist.h
+++ b/sys/compat/linuxkpi/common/include/linux/scatterlist.h
@@ -158,7 +158,7 @@ sg_next(struct scatterlist *sg)
 static inline vm_paddr_t
 sg_phys(struct scatterlist *sg)
 {
-	return (VM_PAGE_TO_PHYS(sg_page(sg)) + sg->offset);
+	return (page_to_phys(sg_page(sg)) + sg->offset);
 }
 
 static inline void *
@@ -649,7 +649,7 @@ sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
 				break;
 			vaddr = (char *)sf_buf_kva(sf);
 		} else
-			vaddr = (char *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page));
+			vaddr = (char *)PHYS_TO_DMAP(page_to_phys(page));
 		memcpy(buf, vaddr + sg->offset + offset, len);
 		if (!PMAP_HAS_DMAP)
 			sf_buf_free(sf);
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
index 0cb724ebf6c4..cc45a77eadbe 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -91,7 +91,7 @@ linux_page_address(struct page *page)
 
 	if (page->object != kernel_object) {
 		return (PMAP_HAS_DMAP ?
-		    ((void *)(uintptr_t)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page))) :
+		    ((void *)(uintptr_t)PHYS_TO_DMAP(page_to_phys(page))) :
 		    NULL);
 	}
 	return ((void *)(uintptr_t)(VM_MIN_KERNEL_ADDRESS +