From c375c363d9025b334c6cea967bb0cee9d9a41169 Mon Sep 17 00:00:00 2001 From: patrick Date: Mon, 15 Mar 2021 22:44:57 +0000 Subject: [PATCH] Add acpi_iommu_device_map(), which replaces the DMA tag with one that is blessed with IOMMU magic, if available. This is mainly for arm64, since on amd64 and i386 the IOMMU only captures PCIe devices, as far as I know, which uses the pci_probe_device_hook(). This though is for non-PCI devices attached through ACPI. ok kettenis@ --- sys/arch/amd64/amd64/acpi_machdep.c | 8 +++++++- sys/arch/arm64/arm64/acpi_machdep.c | 8 +++++++- sys/arch/i386/i386/acpi_machdep.c | 8 +++++++- sys/dev/acpi/acpi.c | 4 +++- sys/dev/acpi/acpivar.h | 4 +++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c index f97523bb5b1..0502a18a2a8 100644 --- a/sys/arch/amd64/amd64/acpi_machdep.c +++ b/sys/arch/amd64/amd64/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.93 2020/12/06 21:42:24 kettenis Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.94 2021/03/15 22:44:57 patrick Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -568,3 +568,9 @@ acpi_resume_mp(void) #endif /* MULTIPROCESSOR */ #endif /* ! SMALL_KERNEL */ + +bus_dma_tag_t +acpi_iommu_device_map(struct aml_node *node, bus_dma_tag_t dmat) +{ + return dmat; +} diff --git a/sys/arch/arm64/arm64/acpi_machdep.c b/sys/arch/arm64/arm64/acpi_machdep.c index 0402c8aa95f..5d78f6d9638 100644 --- a/sys/arch/arm64/arm64/acpi_machdep.c +++ b/sys/arch/arm64/arm64/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.11 2020/12/19 06:28:42 jmatthew Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.12 2021/03/15 22:44:57 patrick Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -216,3 +216,9 @@ acpi_resume_mp(void) } #endif + +bus_dma_tag_t +acpi_iommu_device_map(struct aml_node *node, bus_dma_tag_t dmat) +{ + return dmat; +} diff --git a/sys/arch/i386/i386/acpi_machdep.c b/sys/arch/i386/i386/acpi_machdep.c index b5319472fe7..4f011d47cbe 100644 --- a/sys/arch/i386/i386/acpi_machdep.c +++ b/sys/arch/i386/i386/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.75 2020/12/19 06:28:42 jmatthew Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.76 2021/03/15 22:44:57 patrick Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -520,3 +520,9 @@ acpi_resume_mp(void) #endif /* MULTIPROCESSOR */ #endif /* ! SMALL_KERNEL */ + +bus_dma_tag_t +acpi_iommu_device_map(struct aml_node *node, bus_dma_tag_t dmat) +{ + return dmat; +} diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 12c59317e0d..f39e9231599 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.396 2021/03/07 15:17:58 patrick Exp $ */ +/* $OpenBSD: acpi.c,v 1.397 2021/03/15 22:44:57 patrick Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -3357,6 +3357,8 @@ acpi_foundhid(struct aml_node *node, void *arg) acpi_matchhids(&aaa, acpi_isa_hids, "none")) return (0); + aaa.aaa_dmat = acpi_iommu_device_map(node->parent, aaa.aaa_dmat); + if (!node->parent->attached) { node->parent->attached = 1; config_found(self, &aaa, acpi_print); diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index 7b49d355247..ff369eeb5eb 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.113 2020/12/06 21:19:55 kettenis Exp $ */ +/* $OpenBSD: acpivar.h,v 1.114 2021/03/15 22:44:57 patrick Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -410,6 +410,8 @@ void acpi_intr_disestablish(void *); struct acpi_q *acpi_maptable(struct acpi_softc *sc, paddr_t, const char *, const char *, const char *, int); +bus_dma_tag_t acpi_iommu_device_map(struct aml_node *, bus_dma_tag_t); + #endif #endif /* !_ACPI_WAKECODE */ -- 2.20.1