git: ea8f128c7c17 - main - pmap_mapdev: Consistently use vm_paddr_t for the first argument.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 28 Jul 2022 22:55:40 UTC
The branch main has been updated by jhb:

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

commit ea8f128c7c17d72fc956ee91e415605cff5cc5c3
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-07-28 22:55:10 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-07-28 22:55:10 +0000

    pmap_mapdev: Consistently use vm_paddr_t for the first argument.
    
    The devmap variants used vm_offset_t for some reason, and a few places
    explicitly cast bus addresses to vm_offset_t.  (Probably those casts
    along with similar casts for vm_size_t should just be removed and
    instead permit the compiler to DTRT.)
    
    Reviewed by:    markj
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D35961
---
 sys/arm/arm/nexus.c           | 2 +-
 sys/arm/freescale/fsl_ocotp.c | 2 +-
 sys/arm64/include/pmap.h      | 4 ++--
 sys/kern/subr_devmap.c        | 4 ++--
 sys/powerpc/powermac/macio.c  | 2 +-
 sys/powerpc/psim/iobus.c      | 2 +-
 sys/riscv/include/pmap.h      | 4 ++--
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c
index 958d2cc70587..2e825b5f66a9 100644
--- a/sys/arm/arm/nexus.c
+++ b/sys/arm/arm/nexus.c
@@ -363,7 +363,7 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid,
 		}
 		rman_set_bustag(r, fdtbus_bs_tag);
 #else
-		vaddr = (bus_space_handle_t)pmap_mapdev((vm_offset_t)paddr,
+		vaddr = (bus_space_handle_t)pmap_mapdev((vm_paddr_t)paddr,
 		    (vm_size_t)psize);
 		if (vaddr == 0) {
 			rman_deactivate_resource(r);
diff --git a/sys/arm/freescale/fsl_ocotp.c b/sys/arm/freescale/fsl_ocotp.c
index 606c4b54fe61..e757c262e61c 100644
--- a/sys/arm/freescale/fsl_ocotp.c
+++ b/sys/arm/freescale/fsl_ocotp.c
@@ -81,7 +81,7 @@ fsl_ocotp_devmap(void)
 
 	ocotp_size = (vm_size_t)size;
 
-	if ((ocotp_regs = pmap_mapdev((vm_offset_t)base, ocotp_size)) == NULL)
+	if ((ocotp_regs = pmap_mapdev((vm_paddr_t)base, ocotp_size)) == NULL)
 		goto fatal;
 
 	return;
diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h
index 87527c390f57..6da54a841a28 100644
--- a/sys/arm64/include/pmap.h
+++ b/sys/arm64/include/pmap.h
@@ -184,13 +184,13 @@ bool	pmap_klookup(vm_offset_t va, vm_paddr_t *pa);
 vm_paddr_t pmap_kextract(vm_offset_t va);
 void	pmap_kremove(vm_offset_t);
 void	pmap_kremove_device(vm_offset_t, vm_size_t);
-void	*pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma);
+void	*pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma);
 bool	pmap_page_is_mapped(vm_page_t m);
 int	pmap_pinit_stage(pmap_t, enum pmap_stage, int);
 bool	pmap_ps_enabled(pmap_t pmap);
 uint64_t pmap_to_ttbr0(pmap_t pmap);
 
-void	*pmap_mapdev(vm_offset_t, vm_size_t);
+void	*pmap_mapdev(vm_paddr_t, vm_size_t);
 void	*pmap_mapbios(vm_paddr_t, vm_size_t);
 void	pmap_unmapdev(vm_offset_t, vm_size_t);
 void	pmap_unmapbios(vm_offset_t, vm_size_t);
diff --git a/sys/kern/subr_devmap.c b/sys/kern/subr_devmap.c
index f29e6df472b5..2ca765878f38 100644
--- a/sys/kern/subr_devmap.c
+++ b/sys/kern/subr_devmap.c
@@ -260,7 +260,7 @@ devmap_vtop(void * vpva, vm_size_t size)
  * pmap_kenter_device().
  */
 void *
-pmap_mapdev(vm_offset_t pa, vm_size_t size)
+pmap_mapdev(vm_paddr_t pa, vm_size_t size)
 {
 	vm_offset_t va, offset;
 	void * rva;
@@ -292,7 +292,7 @@ pmap_mapdev(vm_offset_t pa, vm_size_t size)
 
 #if defined(__aarch64__) || defined(__riscv)
 void *
-pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma)
+pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma)
 {
 	vm_offset_t va, offset;
 	void * rva;
diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c
index 23b72edf6e0d..ca515b8ff38c 100644
--- a/sys/powerpc/powermac/macio.c
+++ b/sys/powerpc/powermac/macio.c
@@ -627,7 +627,7 @@ macio_activate_resource(device_t bus, device_t child, int type, int rid,
                 return (bus_activate_resource(bus, type, rid, res));
 
 	if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) {
-		p = pmap_mapdev((vm_offset_t)rman_get_start(res) + sc->sc_base,
+		p = pmap_mapdev((vm_paddr_t)rman_get_start(res) + sc->sc_base,
 				(vm_size_t)rman_get_size(res));
 		if (p == NULL)
 			return (ENOMEM);
diff --git a/sys/powerpc/psim/iobus.c b/sys/powerpc/psim/iobus.c
index 3e2c6aa658fc..28d677cd0f39 100644
--- a/sys/powerpc/psim/iobus.c
+++ b/sys/powerpc/psim/iobus.c
@@ -372,7 +372,7 @@ iobus_activate_resource(device_t bus, device_t child, int type, int rid,
                 return (bus_activate_resource(bus, type, rid, res));
 
 	if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) {
-		p = pmap_mapdev((vm_offset_t)rman_get_start(res) + sc->sc_addr,
+		p = pmap_mapdev((vm_paddr_t)rman_get_start(res) + sc->sc_addr,
 				(vm_size_t)rman_get_size(res));
 		if (p == NULL)
 			return (ENOMEM);
diff --git a/sys/riscv/include/pmap.h b/sys/riscv/include/pmap.h
index 8834c91362ad..8eb5b394fd32 100644
--- a/sys/riscv/include/pmap.h
+++ b/sys/riscv/include/pmap.h
@@ -162,11 +162,11 @@ void	pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t);
 vm_paddr_t pmap_kextract(vm_offset_t va);
 void	pmap_kremove(vm_offset_t);
 void	pmap_kremove_device(vm_offset_t, vm_size_t);
-void	*pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma);
+void	*pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma);
 bool	pmap_page_is_mapped(vm_page_t m);
 bool	pmap_ps_enabled(pmap_t);
 
-void	*pmap_mapdev(vm_offset_t, vm_size_t);
+void	*pmap_mapdev(vm_paddr_t, vm_size_t);
 void	*pmap_mapbios(vm_paddr_t, vm_size_t);
 void	pmap_unmapdev(vm_offset_t, vm_size_t);
 void	pmap_unmapbios(vm_offset_t, vm_size_t);