git: d71a00e9f5db - main - arm64: ofw: respect the nonposted-mmio prop in OF_decode_addr()

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Tue, 07 Mar 2023 06:15:48 UTC
The branch main has been updated by kevans:

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

commit d71a00e9f5db2379d1f267a151b90f1c19dce24d
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2023-03-07 06:15:32 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-03-07 06:15:32 +0000

    arm64: ofw: respect the nonposted-mmio prop in OF_decode_addr()
    
    This is the only mapping remaining which needs to respect nonposted-mmio
    to avoid breaking the boot on Apple silicon.
    
    Reviewed by:    andrew
    Differential Revision:  https://reviews.freebsd.org/D38920
---
 sys/arm64/arm64/ofw_machdep.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sys/arm64/arm64/ofw_machdep.c b/sys/arm64/arm64/ofw_machdep.c
index 3941c1d35617..61aa4c1a1208 100644
--- a/sys/arm64/arm64/ofw_machdep.c
+++ b/sys/arm64/arm64/ofw_machdep.c
@@ -43,7 +43,8 @@ OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
 {
 	bus_addr_t addr;
 	bus_size_t size;
-	int err;
+	phandle_t parent;
+	int err, flags;
 
 	err = ofw_reg_to_paddr(dev, regno, &addr, &size, NULL);
 	if (err != 0)
@@ -54,5 +55,10 @@ OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
 	if (sz != NULL)
 		*sz = size;
 
-	return (bus_space_map(*tag, addr, size, 0, handle));
+	flags = 0;
+	parent = OF_parent(dev);
+	if (parent > 0 && OF_hasprop(parent, "nonposted-mmio"))
+		flags |= BUS_SPACE_MAP_NONPOSTED;
+
+	return (bus_space_map(*tag, addr, size, flags, handle));
 }