summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-04-12 09:21:20 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-04-12 09:21:20 +0000
commit3a2e1e093a4754f0e95c3760da4dd04b8c9eab92 (patch)
tree629e39ac3ebb4660642426a4f0b286f89cc26875 /sys
parent35909dba937aeadc697f2f22cbc96a82af619364 (diff)
Add support for the _CCA method. This method indicates whether DMA is
cache-coherent or not. To implement this, acpi(4) gets two bus_dma tags and passes the appropriate one when attaching devices based on _CCA. On i386/amd64, where for all practical purpose DMA is always cache-coherent, the two tags are the same. But on arm64 they are distinct. ok patrick@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/acpi_machdep.c5
-rw-r--r--sys/arch/arm64/arm64/acpi_machdep.c11
-rw-r--r--sys/arch/i386/i386/acpi_machdep.c5
-rw-r--r--sys/dev/acpi/acpi.c8
-rw-r--r--sys/dev/acpi/acpivar.h5
5 files changed, 21 insertions, 13 deletions
diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c
index e41cd14a443..38cfe424770 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.89 2019/12/20 07:49:31 jsg Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.90 2020/04/12 09:21:19 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -96,7 +96,8 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
sc->sc_iot = ba->ba_iot;
sc->sc_memt = ba->ba_memt;
- sc->sc_dmat = &pci_bus_dma_tag;
+ sc->sc_cc_dmat = &pci_bus_dma_tag;
+ sc->sc_ci_dmat = &pci_bus_dma_tag;
acpi_attach_common(sc, ba->ba_acpipbase);
}
diff --git a/sys/arch/arm64/arm64/acpi_machdep.c b/sys/arch/arm64/arm64/acpi_machdep.c
index 5343fe30934..77871e18d9a 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.3 2019/08/27 22:39:53 deraadt Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.4 2020/04/12 09:21:19 kettenis Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis
*
@@ -56,13 +56,14 @@ acpi_fdt_attach(struct device *parent, struct device *self, void *aux)
struct fdt_attach_args *faa = aux;
bus_dma_tag_t dmat;
+ sc->sc_memt = faa->fa_iot;
+ sc->sc_ci_dmat = faa->fa_dmat;
+
/* Create coherent DMA tag. */
- dmat = malloc(sizeof(*sc->sc_dmat), M_DEVBUF, M_WAITOK | M_ZERO);
+ dmat = malloc(sizeof(*sc->sc_cc_dmat), M_DEVBUF, M_WAITOK | M_ZERO);
memcpy(dmat, faa->fa_dmat, sizeof(*dmat));
dmat->_flags |= BUS_DMA_COHERENT;
-
- sc->sc_memt = faa->fa_iot;
- sc->sc_dmat = dmat;
+ sc->sc_cc_dmat = dmat;
acpi_attach_common(sc, faa->fa_reg[0].addr);
}
diff --git a/sys/arch/i386/i386/acpi_machdep.c b/sys/arch/i386/i386/acpi_machdep.c
index 0e6d32de972..94281532997 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.72 2019/12/20 07:55:30 jsg Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.73 2020/04/12 09:21:19 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -106,7 +106,8 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
sc->sc_iot = ba->ba_iot;
sc->sc_memt = ba->ba_memt;
- sc->sc_dmat = &pci_bus_dma_tag;
+ sc->sc_cc_dmat = &pci_bus_dma_tag;
+ sc->sc_ci_dmat = &pci_bus_dma_tag;
acpi_attach_common(sc, ba->ba_acpipbase);
}
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 35b990dd7cf..ab5a2f09f1b 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.380 2020/04/07 13:27:51 visa Exp $ */
+/* $OpenBSD: acpi.c,v 1.381 2020/04/12 09:21:19 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -3122,6 +3122,7 @@ acpi_foundhid(struct aml_node *node, void *arg)
char dev[32];
struct acpi_attach_args aaa;
int64_t sta;
+ int64_t cca;
#ifndef SMALL_KERNEL
int i;
#endif
@@ -3133,12 +3134,15 @@ acpi_foundhid(struct aml_node *node, void *arg)
if ((sta & STA_PRESENT) == 0)
return (0);
+ if (aml_evalinteger(sc, node->parent, "_CCA", 0, NULL, &cca))
+ cca = 1;
+
acpi_attach_deps(sc, node->parent);
memset(&aaa, 0, sizeof(aaa));
aaa.aaa_iot = sc->sc_iot;
aaa.aaa_memt = sc->sc_memt;
- aaa.aaa_dmat = sc->sc_dmat;
+ aaa.aaa_dmat = cca ? sc->sc_cc_dmat : sc->sc_ci_dmat;
aaa.aaa_node = node->parent;
aaa.aaa_dev = dev;
aaa.aaa_cdev = cdev;
diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h
index 1805a2a9730..cfdc825bd23 100644
--- a/sys/dev/acpi/acpivar.h
+++ b/sys/dev/acpi/acpivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpivar.h,v 1.105 2019/09/07 13:46:20 kettenis Exp $ */
+/* $OpenBSD: acpivar.h,v 1.106 2020/04/12 09:21:19 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -208,7 +208,8 @@ struct acpi_softc {
bus_space_tag_t sc_iot;
bus_space_tag_t sc_memt;
- bus_dma_tag_t sc_dmat;
+ bus_dma_tag_t sc_cc_dmat;
+ bus_dma_tag_t sc_ci_dmat;
/*
* First-level ACPI tables