diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2021-03-15 22:48:58 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2021-03-15 22:48:58 +0000 |
commit | 00b2701eaaffb416064f918fd5593dadffb577ba (patch) | |
tree | b287962f78c806f522474bf8745783bcccb2459f /sys | |
parent | 30e7942acbcad35d2bba2765cab17065973ab7de (diff) |
Change API of acpiiort(4). It was written as a hook before, taking the
PCI attach args and replacing the DMA tag inside. Our other IOMMU API
though takes a DMA tag and returns the old one or a new one. To have
acpiiort(4) integrate better with non-PCI ACPI devices, change the API
so that it is more similar to the other API. This also makes the code
easier to understand.
ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/arm64/dev/acpiiort.c | 16 | ||||
-rw-r--r-- | sys/arch/arm64/dev/acpiiort.h | 9 | ||||
-rw-r--r-- | sys/arch/arm64/dev/acpipci.c | 4 | ||||
-rw-r--r-- | sys/arch/arm64/dev/smmu.c | 14 | ||||
-rw-r--r-- | sys/arch/arm64/dev/smmu_acpi.c | 4 | ||||
-rw-r--r-- | sys/arch/arm64/dev/smmu_fdt.c | 4 | ||||
-rw-r--r-- | sys/arch/arm64/dev/smmuvar.h | 5 |
7 files changed, 23 insertions, 33 deletions
diff --git a/sys/arch/arm64/dev/acpiiort.c b/sys/arch/arm64/dev/acpiiort.c index 4ce2e5438fe..710d8fdb6ec 100644 --- a/sys/arch/arm64/dev/acpiiort.c +++ b/sys/arch/arm64/dev/acpiiort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiiort.c,v 1.1 2021/02/28 21:31:10 patrick Exp $ */ +/* $OpenBSD: acpiiort.c,v 1.2 2021/03/15 22:48:57 patrick Exp $ */ /* * Copyright (c) 2021 Patrick Wildt <patrick@blueri.se> * @@ -88,16 +88,16 @@ acpiiort_smmu_register(struct acpiiort_smmu *as) SIMPLEQ_INSERT_TAIL(&acpiiort_smmu_list, as, as_list); } -void -acpiiort_smmu_hook(struct acpi_iort_node *node, uint32_t rid, - struct pci_attach_args *pa) +bus_dma_tag_t +acpiiort_smmu_map(struct acpi_iort_node *node, uint32_t rid, + bus_dma_tag_t dmat) { struct acpiiort_smmu *as; SIMPLEQ_FOREACH(as, &acpiiort_smmu_list, as_list) { - if (as->as_node == node) { - as->as_hook(as->as_cookie, rid, pa); - break; - } + if (as->as_node == node) + return as->as_map(as->as_cookie, rid, dmat); } + + return dmat; } diff --git a/sys/arch/arm64/dev/acpiiort.h b/sys/arch/arm64/dev/acpiiort.h index 2ee15345d00..fd0c991526f 100644 --- a/sys/arch/arm64/dev/acpiiort.h +++ b/sys/arch/arm64/dev/acpiiort.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiiort.h,v 1.1 2021/02/28 21:31:10 patrick Exp $ */ +/* $OpenBSD: acpiiort.h,v 1.2 2021/03/15 22:48:57 patrick Exp $ */ /* * Copyright (c) 2021 Patrick Wildt <patrick@blueri.se> * @@ -26,10 +26,9 @@ struct acpiiort_smmu { SIMPLEQ_ENTRY(acpiiort_smmu) as_list; struct acpi_iort_node *as_node; void *as_cookie; - void (*as_hook)(void *, uint32_t, - struct pci_attach_args *); + bus_dma_tag_t (*as_map)(void *, uint32_t, + bus_dma_tag_t); }; void acpiiort_smmu_register(struct acpiiort_smmu *); -void acpiiort_smmu_hook(struct acpi_iort_node *, uint32_t, - struct pci_attach_args *); +bus_dma_tag_t acpiiort_smmu_map(struct acpi_iort_node *, uint32_t, bus_dma_tag_t); diff --git a/sys/arch/arm64/dev/acpipci.c b/sys/arch/arm64/dev/acpipci.c index 4b63fa5f48f..08d7553d7ae 100644 --- a/sys/arch/arm64/dev/acpipci.c +++ b/sys/arch/arm64/dev/acpipci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpipci.c,v 1.26 2021/02/28 21:42:08 patrick Exp $ */ +/* $OpenBSD: acpipci.c,v 1.27 2021/03/15 22:48:57 patrick Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -412,7 +412,7 @@ acpipci_probe_device_hook(void *v, struct pci_attach_args *pa) node = (struct acpi_iort_node *)((char *)iort + offset); if (node->type == ACPI_IORT_SMMU) - acpiiort_smmu_hook(node, rid, pa); + pa->pa_dmat = acpiiort_smmu_map(node, rid, pa->pa_dmat); return 0; } diff --git a/sys/arch/arm64/dev/smmu.c b/sys/arch/arm64/dev/smmu.c index 0afe7650f65..b25c4f1d58d 100644 --- a/sys/arch/arm64/dev/smmu.c +++ b/sys/arch/arm64/dev/smmu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smmu.c,v 1.9 2021/03/06 19:30:07 patrick Exp $ */ +/* $OpenBSD: smmu.c,v 1.10 2021/03/15 22:48:57 patrick Exp $ */ /* * Copyright (c) 2008-2009,2014-2016 Dale Rahn <drahn@dalerahn.com> * Copyright (c) 2021 Patrick Wildt <patrick@blueri.se> @@ -500,8 +500,9 @@ smmu_cb_write_8(struct smmu_softc *sc, int idx, bus_size_t off, uint64_t val) } bus_dma_tag_t -smmu_device_hook(struct smmu_softc *sc, uint32_t sid, bus_dma_tag_t dmat) +smmu_device_map(void *cookie, uint32_t sid, bus_dma_tag_t dmat) { + struct smmu_softc *sc = cookie; struct smmu_domain *dom; dom = smmu_domain_lookup(sc, sid); @@ -527,15 +528,6 @@ smmu_device_hook(struct smmu_softc *sc, uint32_t sid, bus_dma_tag_t dmat) return dom->sd_dmat; } -void -smmu_pci_device_hook(void *cookie, uint32_t rid, struct pci_attach_args *pa) -{ - struct smmu_softc *sc = cookie; - - printf("%s: rid %x\n", sc->sc_dev.dv_xname, rid); - pa->pa_dmat = smmu_device_hook(sc, rid, pa->pa_dmat); -} - struct smmu_domain * smmu_domain_lookup(struct smmu_softc *sc, uint32_t sid) { diff --git a/sys/arch/arm64/dev/smmu_acpi.c b/sys/arch/arm64/dev/smmu_acpi.c index 9947383bbc1..10c1daf6137 100644 --- a/sys/arch/arm64/dev/smmu_acpi.c +++ b/sys/arch/arm64/dev/smmu_acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smmu_acpi.c,v 1.1 2021/02/28 21:39:31 patrick Exp $ */ +/* $OpenBSD: smmu_acpi.c,v 1.2 2021/03/15 22:48:57 patrick Exp $ */ /* * Copyright (c) 2021 Patrick Wildt <patrick@blueri.se> * @@ -125,6 +125,6 @@ smmu_acpi_attach(struct device *parent, struct device *self, void *aux) as = malloc(sizeof(*as), M_DEVBUF, M_WAITOK | M_ZERO); as->as_node = node; as->as_cookie = sc; - as->as_hook = smmu_pci_device_hook; + as->as_map = smmu_device_map; acpiiort_smmu_register(as); } diff --git a/sys/arch/arm64/dev/smmu_fdt.c b/sys/arch/arm64/dev/smmu_fdt.c index b21466abe36..75c80c8efe6 100644 --- a/sys/arch/arm64/dev/smmu_fdt.c +++ b/sys/arch/arm64/dev/smmu_fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smmu_fdt.c,v 1.2 2021/03/01 21:35:03 patrick Exp $ */ +/* $OpenBSD: smmu_fdt.c,v 1.3 2021/03/15 22:48:57 patrick Exp $ */ /* * Copyright (c) 2021 Patrick Wildt <patrick@blueri.se> * @@ -117,5 +117,5 @@ smmu_fdt_map(void *cookie, uint32_t *cells, bus_dma_tag_t dmat) struct smmu_fdt_softc *fsc = (struct smmu_fdt_softc *)cookie; struct smmu_softc *sc = &fsc->sc_smmu; - return smmu_device_hook(sc, cells[0], dmat); + return smmu_device_map(sc, cells[0], dmat); } diff --git a/sys/arch/arm64/dev/smmuvar.h b/sys/arch/arm64/dev/smmuvar.h index 3d52f3c8b69..ca3a7b36d14 100644 --- a/sys/arch/arm64/dev/smmuvar.h +++ b/sys/arch/arm64/dev/smmuvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smmuvar.h,v 1.3 2021/03/05 00:55:45 patrick Exp $ */ +/* $OpenBSD: smmuvar.h,v 1.4 2021/03/15 22:48:57 patrick Exp $ */ /* * Copyright (c) 2021 Patrick Wildt <patrick@blueri.se> * @@ -79,5 +79,4 @@ struct smmu_softc { int smmu_attach(struct smmu_softc *); int smmu_global_irq(void *); int smmu_context_irq(void *); -bus_dma_tag_t smmu_device_hook(struct smmu_softc *, uint32_t, bus_dma_tag_t); -void smmu_pci_device_hook(void *, uint32_t, struct pci_attach_args *); +bus_dma_tag_t smmu_device_map(void *, uint32_t, bus_dma_tag_t); |