Sun Dec 29 23:47:56 2019 UTC ()
Allow MD code to provide custom bus_dma tags on a per-node basis. On Arm
this is required to return non-coherent bus_dma tags for device nodes with
_CCA=0


(jmcneill)
diff -r1.13 -r1.14 src/sys/arch/arm/acpi/acpi_machdep.c
diff -r1.14 -r1.15 src/sys/arch/arm/acpi/acpipchb.c
diff -r1.12 -r1.13 src/sys/arch/arm/fdt/acpi_fdt.c
diff -r1.278 -r1.279 src/sys/dev/acpi/acpi.c
diff -r1.77 -r1.78 src/sys/dev/acpi/acpivar.h

cvs diff -r1.13 -r1.14 src/sys/arch/arm/acpi/acpi_machdep.c (expand / switch to unified diff)

--- src/sys/arch/arm/acpi/acpi_machdep.c 2019/12/28 17:19:43 1.13
+++ src/sys/arch/arm/acpi/acpi_machdep.c 2019/12/29 23:47:56 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_machdep.c,v 1.13 2019/12/28 17:19:43 jmcneill Exp $ */ 1/* $NetBSD: acpi_machdep.c,v 1.14 2019/12/29 23:47:56 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2018 The NetBSD Foundation, Inc. 4 * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jared McNeill <jmcneill@invisible.ca>. 8 * by Jared McNeill <jmcneill@invisible.ca>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -22,53 +22,57 @@ @@ -22,53 +22,57 @@
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include "pci.h" 32#include "pci.h"
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.13 2019/12/28 17:19:43 jmcneill Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.14 2019/12/29 23:47:56 jmcneill Exp $");
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/bus.h> 39#include <sys/bus.h>
40#include <sys/cpu.h> 40#include <sys/cpu.h>
41#include <sys/device.h> 41#include <sys/device.h>
42 42
43#include <uvm/uvm_extern.h> 43#include <uvm/uvm_extern.h>
44 44
45#include <dev/fdt/fdtvar.h> 45#include <dev/fdt/fdtvar.h>
46 46
47#include <dev/acpi/acpica.h> 47#include <dev/acpi/acpica.h>
48#include <dev/acpi/acpivar.h> 48#include <dev/acpi/acpivar.h>
49#if NPCI > 0 49#if NPCI > 0
50#include <dev/acpi/acpi_mcfg.h> 50#include <dev/acpi/acpi_mcfg.h>
51#endif 51#endif
52 52
53#include <arm/arm/efi_runtime.h> 53#include <arm/arm/efi_runtime.h>
54 54
55#include <arm/pic/picvar.h> 55#include <arm/pic/picvar.h>
56 56
57#include <arm/locore.h> 57#include <arm/locore.h>
58 58
59#include <machine/acpi_machdep.h> 59#include <machine/acpi_machdep.h>
60 60
61extern struct bus_space arm_generic_bs_tag; 61extern struct bus_space arm_generic_bs_tag;
 62extern struct arm32_bus_dma_tag acpi_coherent_dma_tag;
 63extern struct arm32_bus_dma_tag arm_generic_dma_tag;
 64
 65bus_dma_tag_t arm_acpi_dma_tag(struct acpi_softc *, struct acpi_devnode *);
62 66
63static int 67static int
64acpi_md_pmapflags(paddr_t pa) 68acpi_md_pmapflags(paddr_t pa)
65{ 69{
66 int len; 70 int len;
67 71
68 const int chosen = OF_finddevice("/chosen"); 72 const int chosen = OF_finddevice("/chosen");
69 if (chosen == -1) 73 if (chosen == -1)
70 return 0; 74 return 0;
71 75
72 const uint32_t *map = fdtbus_get_prop(chosen, "netbsd,uefi-memmap", &len); 76 const uint32_t *map = fdtbus_get_prop(chosen, "netbsd,uefi-memmap", &len);
73 if (map == NULL) 77 if (map == NULL)
74 return 0; 78 return 0;
@@ -352,13 +356,29 @@ acpi_md_callback(struct acpi_softc *sc) @@ -352,13 +356,29 @@ acpi_md_callback(struct acpi_softc *sc)
352 panic("Failed to map MADT"); 356 panic("Failed to map MADT");
353 acpi_madt_walk(acpi_md_madt_probe_cpu, sc); 357 acpi_madt_walk(acpi_md_madt_probe_cpu, sc);
354 acpi_madt_walk(acpi_md_madt_probe_gic, sc); 358 acpi_madt_walk(acpi_md_madt_probe_gic, sc);
355 acpi_madt_unmap(); 359 acpi_madt_unmap();
356 360
357 if (acpi_gtdt_map() != AE_OK) 361 if (acpi_gtdt_map() != AE_OK)
358 panic("Failed to map GTDT"); 362 panic("Failed to map GTDT");
359 acpi_gtdt_walk(acpi_md_gtdt_probe, sc); 363 acpi_gtdt_walk(acpi_md_gtdt_probe, sc);
360 acpi_gtdt_unmap(); 364 acpi_gtdt_unmap();
361 365
362 if (ACPI_SUCCESS(AcpiGetTable(ACPI_SIG_GTDT, 0, &hdrp))) 366 if (ACPI_SUCCESS(AcpiGetTable(ACPI_SIG_GTDT, 0, &hdrp)))
363 config_found_ia(sc->sc_dev, "acpisdtbus", hdrp, NULL); 367 config_found_ia(sc->sc_dev, "acpisdtbus", hdrp, NULL);
364} 368}
 369
 370bus_dma_tag_t
 371arm_acpi_dma_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
 372{
 373 ACPI_INTEGER cca;
 374
 375 if (ACPI_FAILURE(acpi_eval_integer(ad->ad_handle, "_CCA", &cca)))
 376 cca = 1;
 377
 378 if (cca)
 379 return &acpi_coherent_dma_tag;
 380 else
 381 return &arm_generic_dma_tag;
 382}
 383__strong_alias(acpi_get_dma_tag,arm_acpi_dma_tag);
 384__strong_alias(acpi_get_dma64_tag,arm_acpi_dma_tag);

cvs diff -r1.14 -r1.15 src/sys/arch/arm/acpi/acpipchb.c (expand / switch to unified diff)

--- src/sys/arch/arm/acpi/acpipchb.c 2019/12/28 17:19:43 1.14
+++ src/sys/arch/arm/acpi/acpipchb.c 2019/12/29 23:47:56 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpipchb.c,v 1.14 2019/12/28 17:19:43 jmcneill Exp $ */ 1/* $NetBSD: acpipchb.c,v 1.15 2019/12/29 23:47:56 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2018 The NetBSD Foundation, Inc. 4 * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jared McNeill <jmcneill@invisible.ca>. 8 * by Jared McNeill <jmcneill@invisible.ca>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.14 2019/12/28 17:19:43 jmcneill Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.15 2019/12/29 23:47:56 jmcneill Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/bus.h> 36#include <sys/bus.h>
37#include <sys/device.h> 37#include <sys/device.h>
38#include <sys/intr.h> 38#include <sys/intr.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/kernel.h> 40#include <sys/kernel.h>
41#include <sys/extent.h> 41#include <sys/extent.h>
42#include <sys/queue.h> 42#include <sys/queue.h>
43#include <sys/mutex.h> 43#include <sys/mutex.h>
44#include <sys/kmem.h> 44#include <sys/kmem.h>
45 45
46#include <machine/cpu.h> 46#include <machine/cpu.h>
@@ -232,47 +232,42 @@ acpipchb_match(device_t parent, cfdata_t @@ -232,47 +232,42 @@ acpipchb_match(device_t parent, cfdata_t
232 if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE) 232 if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
233 return 0; 233 return 0;
234 234
235 return acpi_match_hid(aa->aa_node->ad_devinfo, compatible); 235 return acpi_match_hid(aa->aa_node->ad_devinfo, compatible);
236} 236}
237 237
238static void 238static void
239acpipchb_attach(device_t parent, device_t self, void *aux) 239acpipchb_attach(device_t parent, device_t self, void *aux)
240{ 240{
241 struct acpipchb_softc * const sc = device_private(self); 241 struct acpipchb_softc * const sc = device_private(self);
242 struct acpi_attach_args *aa = aux; 242 struct acpi_attach_args *aa = aux;
243 struct pcibus_attach_args pba; 243 struct pcibus_attach_args pba;
244 const struct acpipchb_quirk *q; 244 const struct acpipchb_quirk *q;
245 ACPI_INTEGER cca, seg; 245 ACPI_INTEGER seg;
246 246
247 sc->sc_dev = self; 247 sc->sc_dev = self;
248 sc->sc_memt = aa->aa_memt; 248 sc->sc_memt = aa->aa_memt;
249 sc->sc_handle = aa->aa_node->ad_handle; 249 sc->sc_handle = aa->aa_node->ad_handle;
250 250
251 if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_BBN", &sc->sc_bus))) 251 if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_BBN", &sc->sc_bus)))
252 sc->sc_bus = 0; 252 sc->sc_bus = 0;
253 253
254 if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", &seg))) 254 if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", &seg)))
255 seg = 0; 255 seg = 0;
256 256
257 if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_CCA", &cca))) 
258 cca = 1; 
259 
260 aprint_naive("\n"); 257 aprint_naive("\n");
261 aprint_normal(": PCI Express Host Bridge\n"); 258 aprint_normal(": PCI Express Host Bridge\n");
262 259
263 sc->sc_dmat = *aa->aa_dmat; 260 sc->sc_dmat = *aa->aa_dmat;
264 if (cca == 0) 
265 sc->sc_dmat._nranges = 0; 
266 261
267 sc->sc_ap.ap_dev = self; 262 sc->sc_ap.ap_dev = self;
268 sc->sc_ap.ap_pc = *aa->aa_pc; 263 sc->sc_ap.ap_pc = *aa->aa_pc;
269 sc->sc_ap.ap_pc.pc_conf_v = &sc->sc_ap; 264 sc->sc_ap.ap_pc.pc_conf_v = &sc->sc_ap;
270 sc->sc_ap.ap_seg = seg; 265 sc->sc_ap.ap_seg = seg;
271 sc->sc_ap.ap_handle = sc->sc_handle; 266 sc->sc_ap.ap_handle = sc->sc_handle;
272 sc->sc_ap.ap_bus = sc->sc_bus; 267 sc->sc_ap.ap_bus = sc->sc_bus;
273 sc->sc_ap.ap_bst = sc->sc_memt; 268 sc->sc_ap.ap_bst = sc->sc_memt;
274 269
275 q = acpipchb_find_quirk(); 270 q = acpipchb_find_quirk();
276 if (q != NULL) 271 if (q != NULL)
277 q->q_init(&sc->sc_ap); 272 q->q_init(&sc->sc_ap);
278 273

cvs diff -r1.12 -r1.13 src/sys/arch/arm/fdt/acpi_fdt.c (expand / switch to unified diff)

--- src/sys/arch/arm/fdt/acpi_fdt.c 2019/06/22 19:47:27 1.12
+++ src/sys/arch/arm/fdt/acpi_fdt.c 2019/12/29 23:47:56 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_fdt.c,v 1.12 2019/06/22 19:47:27 jmcneill Exp $ */ 1/* $NetBSD: acpi_fdt.c,v 1.13 2019/12/29 23:47:56 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include "pci.h" 29#include "pci.h"
30#include "opt_efi.h" 30#include "opt_efi.h"
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.12 2019/06/22 19:47:27 jmcneill Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.13 2019/12/29 23:47:56 jmcneill Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/bus.h> 36#include <sys/bus.h>
37#include <sys/device.h> 37#include <sys/device.h>
38#include <sys/intr.h> 38#include <sys/intr.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/kernel.h> 40#include <sys/kernel.h>
41#include <sys/lwp.h> 41#include <sys/lwp.h>
42#include <sys/kmem.h> 42#include <sys/kmem.h>
43#include <sys/queue.h> 43#include <sys/queue.h>
44#include <sys/sysctl.h> 44#include <sys/sysctl.h>
45 45
46#include <dev/fdt/fdtvar.h> 46#include <dev/fdt/fdtvar.h>
@@ -126,30 +126,28 @@ acpi_fdt_attach(device_t parent, device_ @@ -126,30 +126,28 @@ acpi_fdt_attach(device_t parent, device_
126 acpi_fdt_pci_context.ap_pc.pc_conf_v = &acpi_fdt_pci_context; 126 acpi_fdt_pci_context.ap_pc.pc_conf_v = &acpi_fdt_pci_context;
127 acpi_fdt_pci_context.ap_seg = 0; 127 acpi_fdt_pci_context.ap_seg = 0;
128 aa.aa_pciflags = 128 aa.aa_pciflags =
129 /*PCI_FLAGS_IO_OKAY |*/ PCI_FLAGS_MEM_OKAY | 129 /*PCI_FLAGS_IO_OKAY |*/ PCI_FLAGS_MEM_OKAY |
130 PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |  130 PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
131 PCI_FLAGS_MWI_OKAY; 131 PCI_FLAGS_MWI_OKAY;
132#ifdef __HAVE_PCI_MSI_MSIX 132#ifdef __HAVE_PCI_MSI_MSIX
133 aa.aa_pciflags |= PCI_FLAGS_MSI_OKAY | PCI_FLAGS_MSIX_OKAY; 133 aa.aa_pciflags |= PCI_FLAGS_MSI_OKAY | PCI_FLAGS_MSIX_OKAY;
134#endif 134#endif
135 aa.aa_pc = &acpi_fdt_pci_context.ap_pc; 135 aa.aa_pc = &acpi_fdt_pci_context.ap_pc;
136#endif 136#endif
137 137
138 aa.aa_memt = faa->faa_bst; 138 aa.aa_memt = faa->faa_bst;
139 aa.aa_dmat = &acpi_coherent_dma_tag; 139 aa.aa_dmat = NULL;
140#ifdef _PCI_HAVE_DMA64 140 aa.aa_dmat64 = NULL;
141 aa.aa_dmat64 = &acpi_coherent_dma_tag; 
142#endif 
143 config_found_ia(self, "acpibus", &aa, 0); 141 config_found_ia(self, "acpibus", &aa, 0);
144 142
145 acpi_fdt_sysctl_init(); 143 acpi_fdt_sysctl_init();
146} 144}
147 145
148static void 146static void
149acpi_fdt_poweroff(device_t dev) 147acpi_fdt_poweroff(device_t dev)
150{ 148{
151 delay(500000); 149 delay(500000);
152#ifdef EFI_RUNTIME 150#ifdef EFI_RUNTIME
153 if (arm_efirt_reset(EFI_RESET_SHUTDOWN) == 0) 151 if (arm_efirt_reset(EFI_RESET_SHUTDOWN) == 0)
154 return; 152 return;
155#endif 153#endif

cvs diff -r1.278 -r1.279 src/sys/dev/acpi/acpi.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi.c 2018/10/21 13:41:15 1.278
+++ src/sys/dev/acpi/acpi.c 2019/12/29 23:47:56 1.279
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi.c,v 1.278 2018/10/21 13:41:15 jmcneill Exp $ */ 1/* $NetBSD: acpi.c,v 1.279 2019/12/29 23:47:56 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum of By Noon Software, Inc. 8 * by Charles M. Hannum of By Noon Software, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -90,27 +90,27 @@ @@ -90,27 +90,27 @@
90 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 90 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
91 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 91 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
92 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 92 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
93 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 93 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
94 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 94 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
95 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 95 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
96 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 96 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
97 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 97 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
98 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 98 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
99 * POSSIBILITY OF SUCH DAMAGE. 99 * POSSIBILITY OF SUCH DAMAGE.
100 */ 100 */
101 101
102#include <sys/cdefs.h> 102#include <sys/cdefs.h>
103__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.278 2018/10/21 13:41:15 jmcneill Exp $"); 103__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.279 2019/12/29 23:47:56 jmcneill Exp $");
104 104
105#include "pci.h" 105#include "pci.h"
106#include "opt_acpi.h" 106#include "opt_acpi.h"
107#include "opt_pcifixup.h" 107#include "opt_pcifixup.h"
108 108
109#include <sys/param.h> 109#include <sys/param.h>
110#include <sys/device.h> 110#include <sys/device.h>
111#include <sys/kernel.h> 111#include <sys/kernel.h>
112#include <sys/kmem.h> 112#include <sys/kmem.h>
113#include <sys/malloc.h> 113#include <sys/malloc.h>
114#include <sys/module.h> 114#include <sys/module.h>
115#include <sys/mutex.h> 115#include <sys/mutex.h>
116#include <sys/sysctl.h> 116#include <sys/sysctl.h>
@@ -227,26 +227,29 @@ static int sysctl_hw_acpi_sleepstates(S @@ -227,26 +227,29 @@ static int sysctl_hw_acpi_sleepstates(S
227static bool acpi_is_scope(struct acpi_devnode *); 227static bool acpi_is_scope(struct acpi_devnode *);
228static ACPI_TABLE_HEADER *acpi_map_rsdt(void); 228static ACPI_TABLE_HEADER *acpi_map_rsdt(void);
229static void acpi_unmap_rsdt(ACPI_TABLE_HEADER *); 229static void acpi_unmap_rsdt(ACPI_TABLE_HEADER *);
230 230
231void acpi_print_verbose_stub(struct acpi_softc *); 231void acpi_print_verbose_stub(struct acpi_softc *);
232void acpi_print_dev_stub(const char *); 232void acpi_print_dev_stub(const char *);
233 233
234static void acpi_activate_device(ACPI_HANDLE, ACPI_DEVICE_INFO **); 234static void acpi_activate_device(ACPI_HANDLE, ACPI_DEVICE_INFO **);
235ACPI_STATUS acpi_allocate_resources(ACPI_HANDLE); 235ACPI_STATUS acpi_allocate_resources(ACPI_HANDLE);
236 236
237void (*acpi_print_verbose)(struct acpi_softc *) = acpi_print_verbose_stub; 237void (*acpi_print_verbose)(struct acpi_softc *) = acpi_print_verbose_stub;
238void (*acpi_print_dev)(const char *) = acpi_print_dev_stub; 238void (*acpi_print_dev)(const char *) = acpi_print_dev_stub;
239 239
 240bus_dma_tag_t acpi_default_dma_tag(struct acpi_softc *, struct acpi_devnode *);
 241bus_dma_tag_t acpi_default_dma64_tag(struct acpi_softc *, struct acpi_devnode *);
 242
240CFATTACH_DECL2_NEW(acpi, sizeof(struct acpi_softc), 243CFATTACH_DECL2_NEW(acpi, sizeof(struct acpi_softc),
241 acpi_match, acpi_attach, acpi_detach, NULL, acpi_rescan, acpi_childdet); 244 acpi_match, acpi_attach, acpi_detach, NULL, acpi_rescan, acpi_childdet);
242 245
243/* 246/*
244 * Probe for ACPI support. 247 * Probe for ACPI support.
245 * 248 *
246 * This is called by the machine-dependent ACPI front-end. 249 * This is called by the machine-dependent ACPI front-end.
247 * Note: this is not an autoconfiguration interface function. 250 * Note: this is not an autoconfiguration interface function.
248 */ 251 */
249int 252int
250acpi_probe(void) 253acpi_probe(void)
251{ 254{
252 ACPI_TABLE_HEADER *rsdt; 255 ACPI_TABLE_HEADER *rsdt;
@@ -798,26 +801,40 @@ acpi_make_name(struct acpi_devnode *ad,  @@ -798,26 +801,40 @@ acpi_make_name(struct acpi_devnode *ad,
798 801
799 if (clear == 0 && anu->Ascii[i] == '_') 802 if (clear == 0 && anu->Ascii[i] == '_')
800 ad->ad_name[i] = '\0'; 803 ad->ad_name[i] = '\0';
801 else { 804 else {
802 ad->ad_name[i] = anu->Ascii[i]; 805 ad->ad_name[i] = anu->Ascii[i];
803 clear = 1; 806 clear = 1;
804 } 807 }
805 } 808 }
806 809
807 if (ad->ad_name[0] == '\0') 810 if (ad->ad_name[0] == '\0')
808 ad->ad_name[0] = '_'; 811 ad->ad_name[0] = '_';
809} 812}
810 813
 814bus_dma_tag_t
 815acpi_default_dma_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
 816{
 817 return sc->sc_dmat;
 818}
 819__weak_alias(acpi_get_dma_tag,acpi_default_dma_tag);
 820
 821bus_dma_tag_t
 822acpi_default_dma64_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
 823{
 824 return sc->sc_dmat64;
 825}
 826__weak_alias(acpi_get_dma64_tag,acpi_default_dma64_tag);
 827
811/* 828/*
812 * Device attachment. 829 * Device attachment.
813 */ 830 */
814static int 831static int
815acpi_rescan(device_t self, const char *ifattr, const int *locators) 832acpi_rescan(device_t self, const char *ifattr, const int *locators)
816{ 833{
817 struct acpi_softc *sc = device_private(self); 834 struct acpi_softc *sc = device_private(self);
818 struct acpi_attach_args aa; 835 struct acpi_attach_args aa;
819 836
820 /* 837 /*
821 * Try to attach hpet(4) first via a specific table. 838 * Try to attach hpet(4) first via a specific table.
822 */ 839 */
823 aa.aa_memt = sc->sc_memt; 840 aa.aa_memt = sc->sc_memt;
@@ -867,28 +884,28 @@ acpi_rescan_early(struct acpi_softc *sc) @@ -867,28 +884,28 @@ acpi_rescan_early(struct acpi_softc *sc)
867 884
868 if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE) 885 if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE)
869 continue; 886 continue;
870 887
871 if (acpi_match_hid(ad->ad_devinfo, acpi_early_ids) == 0) 888 if (acpi_match_hid(ad->ad_devinfo, acpi_early_ids) == 0)
872 continue; 889 continue;
873 890
874 aa.aa_node = ad; 891 aa.aa_node = ad;
875 aa.aa_iot = sc->sc_iot; 892 aa.aa_iot = sc->sc_iot;
876 aa.aa_memt = sc->sc_memt; 893 aa.aa_memt = sc->sc_memt;
877 aa.aa_pc = sc->sc_pc; 894 aa.aa_pc = sc->sc_pc;
878 aa.aa_pciflags = sc->sc_pciflags; 895 aa.aa_pciflags = sc->sc_pciflags;
879 aa.aa_ic = sc->sc_ic; 896 aa.aa_ic = sc->sc_ic;
880 aa.aa_dmat = sc->sc_dmat; 897 aa.aa_dmat = acpi_get_dma_tag(sc, ad);
881 aa.aa_dmat64 = sc->sc_dmat64; 898 aa.aa_dmat64 = acpi_get_dma64_tag(sc, ad);
882 899
883 ad->ad_device = config_found_ia(sc->sc_dev, 900 ad->ad_device = config_found_ia(sc->sc_dev,
884 "acpinodebus", &aa, acpi_print); 901 "acpinodebus", &aa, acpi_print);
885 } 902 }
886} 903}
887 904
888static void 905static void
889acpi_rescan_nodes(struct acpi_softc *sc) 906acpi_rescan_nodes(struct acpi_softc *sc)
890{ 907{
891 const char * const hpet_ids[] = { "PNP0103", NULL }; 908 const char * const hpet_ids[] = { "PNP0103", NULL };
892 struct acpi_attach_args aa; 909 struct acpi_attach_args aa;
893 struct acpi_devnode *ad; 910 struct acpi_devnode *ad;
894 ACPI_DEVICE_INFO *di; 911 ACPI_DEVICE_INFO *di;
@@ -929,28 +946,28 @@ acpi_rescan_nodes(struct acpi_softc *sc) @@ -929,28 +946,28 @@ acpi_rescan_nodes(struct acpi_softc *sc)
929 946
930 if (acpi_match_hid(di, acpi_ignored_ids) != 0) 947 if (acpi_match_hid(di, acpi_ignored_ids) != 0)
931 continue; 948 continue;
932 949
933 if (acpi_match_hid(di, hpet_ids) != 0 && sc->sc_hpet != NULL) 950 if (acpi_match_hid(di, hpet_ids) != 0 && sc->sc_hpet != NULL)
934 continue; 951 continue;
935 952
936 aa.aa_node = ad; 953 aa.aa_node = ad;
937 aa.aa_iot = sc->sc_iot; 954 aa.aa_iot = sc->sc_iot;
938 aa.aa_memt = sc->sc_memt; 955 aa.aa_memt = sc->sc_memt;
939 aa.aa_pc = sc->sc_pc; 956 aa.aa_pc = sc->sc_pc;
940 aa.aa_pciflags = sc->sc_pciflags; 957 aa.aa_pciflags = sc->sc_pciflags;
941 aa.aa_ic = sc->sc_ic; 958 aa.aa_ic = sc->sc_ic;
942 aa.aa_dmat = sc->sc_dmat; 959 aa.aa_dmat = acpi_get_dma_tag(sc, ad);
943 aa.aa_dmat64 = sc->sc_dmat64; 960 aa.aa_dmat64 = acpi_get_dma64_tag(sc, ad);
944 961
945 ad->ad_device = config_found_ia(sc->sc_dev, 962 ad->ad_device = config_found_ia(sc->sc_dev,
946 "acpinodebus", &aa, acpi_print); 963 "acpinodebus", &aa, acpi_print);
947 } 964 }
948} 965}
949 966
950static void 967static void
951acpi_rescan_capabilities(device_t self) 968acpi_rescan_capabilities(device_t self)
952{ 969{
953 struct acpi_softc *sc = device_private(self); 970 struct acpi_softc *sc = device_private(self);
954 struct acpi_devnode *ad; 971 struct acpi_devnode *ad;
955 ACPI_HANDLE tmp; 972 ACPI_HANDLE tmp;
956 ACPI_STATUS rv; 973 ACPI_STATUS rv;

cvs diff -r1.77 -r1.78 src/sys/dev/acpi/acpivar.h (expand / switch to unified diff)

--- src/sys/dev/acpi/acpivar.h 2018/10/25 10:38:57 1.77
+++ src/sys/dev/acpi/acpivar.h 2019/12/29 23:47:56 1.78
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpivar.h,v 1.77 2018/10/25 10:38:57 jmcneill Exp $ */ 1/* $NetBSD: acpivar.h,v 1.78 2019/12/29 23:47:56 jmcneill Exp $ */
2 2
3/* 3/*
4 * Copyright 2001 Wasabi Systems, Inc. 4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -374,23 +374,26 @@ struct acpi_quirk { @@ -374,23 +374,26 @@ struct acpi_quirk {
374#define ACPI_QUIRK_BADPCI 0x00000002 /* bad PCI hierarchy */ 374#define ACPI_QUIRK_BADPCI 0x00000002 /* bad PCI hierarchy */
375#define ACPI_QUIRK_BADBBN 0x00000004 /* _BBN broken */ 375#define ACPI_QUIRK_BADBBN 0x00000004 /* _BBN broken */
376#define ACPI_QUIRK_IRQ0 0x00000008 /* bad 0->2 irq override */ 376#define ACPI_QUIRK_IRQ0 0x00000008 /* bad 0->2 irq override */
377#define ACPI_QUIRK_OLDBIOS 0x00000010 /* BIOS date blacklisted */ 377#define ACPI_QUIRK_OLDBIOS 0x00000010 /* BIOS date blacklisted */
378 378
379int acpi_find_quirks(void); 379int acpi_find_quirks(void);
380int acpi_quirks_osi_add(const char *); 380int acpi_quirks_osi_add(const char *);
381int acpi_quirks_osi_del(const char *); 381int acpi_quirks_osi_del(const char *);
382 382
383#ifdef ACPI_DEBUG 383#ifdef ACPI_DEBUG
384void acpi_debug_init(void); 384void acpi_debug_init(void);
385#endif 385#endif
386 386
 387bus_dma_tag_t acpi_get_dma_tag(struct acpi_softc *, struct acpi_devnode *);
 388bus_dma_tag_t acpi_get_dma64_tag(struct acpi_softc *, struct acpi_devnode *);
 389
387/* 390/*
388 * Misc routines with vectors updated by acpiverbose module. 391 * Misc routines with vectors updated by acpiverbose module.
389 */ 392 */
390extern void (*acpi_print_verbose)(struct acpi_softc *); 393extern void (*acpi_print_verbose)(struct acpi_softc *);
391extern void (*acpi_print_dev)(const char *); 394extern void (*acpi_print_dev)(const char *);
392 395
393void acpi_load_verbose(void); 396void acpi_load_verbose(void);
394extern int acpi_verbose_loaded; 397extern int acpi_verbose_loaded;
395 398
396#endif /* !_SYS_DEV_ACPI_ACPIVAR_H */ 399#endif /* !_SYS_DEV_ACPI_ACPIVAR_H */