From 8e403b4a17cb96535c693b1970bb3b5e1081bb27 Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Fri, 5 Mar 2021 00:18:27 +0000 Subject: Extend the commented code that shows which additional mappings are needed, or which regions need to be reserved. As it turns out, a region we should not map is the PCIe address space. Making a PCIe device try to do DMA to an address in PCIe address space will obviously not make its way to SMMU and host memory. We'll probably have to add an API for that. --- sys/arch/arm64/dev/smmu.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'sys/arch/arm64') diff --git a/sys/arch/arm64/dev/smmu.c b/sys/arch/arm64/dev/smmu.c index 0b206a63875..aaf07169873 100644 --- a/sys/arch/arm64/dev/smmu.c +++ b/sys/arch/arm64/dev/smmu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smmu.c,v 1.4 2021/03/02 01:34:43 patrick Exp $ */ +/* $OpenBSD: smmu.c,v 1.5 2021/03/05 00:18:26 patrick Exp $ */ /* * Copyright (c) 2008-2009,2014-2016 Dale Rahn * Copyright (c) 2021 Patrick Wildt @@ -767,23 +767,41 @@ smmu_domain_create(struct smmu_softc *sc, uint32_t sid) M_DEVBUF, NULL, 0, EX_WAITOK | EX_NOCOALESCE); #if 0 - /* FIXME MSI map on */ + /* FIXME MSI map & PCIe address space */ { - paddr_t msi_pa = 0x78020000; /* Ampere */ - paddr_t msi_pa = 0x6020000; /* LX2K */ +#if 0 + /* Reserve and map Ampere MSI */ + paddr_t msi_pa = 0x78020000; size_t msi_len = 0x20000; - paddr_t msi_pa = 0xf0280000; /* 8040 GICv2 */ +#endif +#if 0 + /* Reserve and map LX2K MSI */ + paddr_t msi_pa = 0x6020000; + size_t msi_len = 0x20000; +#endif +#if 1 + /* Reserve and map 8040 GICv2M */ + paddr_t msi_pa = 0xf0280000; size_t msi_len = 0x40000; +#endif + extent_alloc_region(dom->sd_iovamap, msi_pa, msi_len, EX_WAITOK); while (msi_len) { smmu_enter(dom, msi_pa, msi_pa, PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE, PMAP_CACHE_WB); msi_pa += PAGE_SIZE; msi_len -= PAGE_SIZE; } - msi_pa = 0xf03f0000; /* 8040 GICP */ +#if 1 + /* Reserve and map 8040 GICP */ + msi_pa = 0xf03f0000; msi_len = 0x1000; + extent_alloc_region(dom->sd_iovamap, msi_pa, msi_len, EX_WAITOK); smmu_enter(dom, msi_pa, msi_pa, PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE, PMAP_CACHE_WB); + /* Reserve 8040 PCI address space */ + extent_alloc_region(dom->sd_iovamap, 0xc0000000, 0x20000000, + EX_WAITOK); +#endif } #endif -- cgit v1.2.3