Report HW DMA capability and if the DMA tag limits it.diff -r1.8 -r1.9 src/sys/dev/acpi/xhci_acpi.c
(skrll)
--- src/sys/dev/acpi/xhci_acpi.c 2020/10/24 08:55:23 1.8
+++ src/sys/dev/acpi/xhci_acpi.c 2020/10/27 13:50:57 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: xhci_acpi.c,v 1.8 2020/10/24 08:55:23 skrll Exp $ */ | 1 | /* $NetBSD: xhci_acpi.c,v 1.9 2020/10/27 13:50:57 skrll 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: xhci_acpi.c,v 1.8 2020/10/24 08:55:23 skrll Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: xhci_acpi.c,v 1.9 2020/10/27 13:50:57 skrll 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/cpu.h> | 37 | #include <sys/cpu.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | 39 | |||
40 | #include <dev/usb/usb.h> | 40 | #include <dev/usb/usb.h> | |
41 | #include <dev/usb/usbdi.h> | 41 | #include <dev/usb/usbdi.h> | |
42 | #include <dev/usb/usbdivar.h> | 42 | #include <dev/usb/usbdivar.h> | |
43 | #include <dev/usb/usb_mem.h> | 43 | #include <dev/usb/usb_mem.h> | |
44 | #include <dev/usb/xhcireg.h> | 44 | #include <dev/usb/xhcireg.h> | |
45 | #include <dev/usb/xhcivar.h> | 45 | #include <dev/usb/xhcivar.h> | |
46 | 46 | |||
@@ -119,31 +119,37 @@ xhci_acpi_attach(device_t parent, device | @@ -119,31 +119,37 @@ xhci_acpi_attach(device_t parent, device | |||
119 | aprint_error_dev(self, "couldn't find irq resource\n"); | 119 | aprint_error_dev(self, "couldn't find irq resource\n"); | |
120 | goto done; | 120 | goto done; | |
121 | } | 121 | } | |
122 | 122 | |||
123 | sc->sc_ios = mem->ar_length; | 123 | sc->sc_ios = mem->ar_length; | |
124 | sc->sc_iot = aa->aa_memt; | 124 | sc->sc_iot = aa->aa_memt; | |
125 | error = bus_space_map(sc->sc_iot, mem->ar_base, mem->ar_length, 0, &sc->sc_ioh); | 125 | error = bus_space_map(sc->sc_iot, mem->ar_base, mem->ar_length, 0, &sc->sc_ioh); | |
126 | if (error) { | 126 | if (error) { | |
127 | aprint_error_dev(self, "couldn't map registers\n"); | 127 | aprint_error_dev(self, "couldn't map registers\n"); | |
128 | return; | 128 | return; | |
129 | } | 129 | } | |
130 | 130 | |||
131 | hccparams = bus_space_read_4(sc->sc_iot, sc->sc_ioh, XHCI_HCCPARAMS); | 131 | hccparams = bus_space_read_4(sc->sc_iot, sc->sc_ioh, XHCI_HCCPARAMS); | |
132 | if (XHCI_HCC_AC64(hccparams) && BUS_DMA_TAG_VALID(aa->aa_dmat64)) { | 132 | if (XHCI_HCC_AC64(hccparams)) { | |
133 | aprint_verbose_dev(self, "using 64-bit DMA\n"); | 133 | aprint_verbose_dev(self, "64-bit DMA"); | |
134 | sc->sc_bus.ub_dmatag = aa->aa_dmat64; | 134 | if (BUS_DMA_TAG_VALID(aa->aa_dmat64)) { | |
135 | aprint_verbose("\n"); | |||
136 | sc->sc_bus.ub_dmatag = aa->aa_dmat64; | |||
137 | } else { | |||
138 | aprint_verbose(" - limited\n"); | |||
139 | sc->sc_bus.ub_dmatag = aa->aa_dmat; | |||
140 | } | |||
135 | } else { | 141 | } else { | |
136 | aprint_verbose_dev(self, "using 32-bit DMA\n"); | 142 | aprint_verbose_dev(self, "32-bit DMA\n"); | |
137 | sc->sc_bus.ub_dmatag = aa->aa_dmat; | 143 | sc->sc_bus.ub_dmatag = aa->aa_dmat; | |
138 | } | 144 | } | |
139 | 145 | |||
140 | ih = acpi_intr_establish(self, (uint64_t)aa->aa_node->ad_handle, | 146 | ih = acpi_intr_establish(self, (uint64_t)aa->aa_node->ad_handle, | |
141 | IPL_USB, true, xhci_intr, sc, device_xname(self)); | 147 | IPL_USB, true, xhci_intr, sc, device_xname(self)); | |
142 | if (ih == NULL) { | 148 | if (ih == NULL) { | |
143 | aprint_error_dev(self, "couldn't establish interrupt\n"); | 149 | aprint_error_dev(self, "couldn't establish interrupt\n"); | |
144 | return; | 150 | return; | |
145 | } | 151 | } | |
146 | 152 | |||
147 | error = xhci_init(sc); | 153 | error = xhci_init(sc); | |
148 | if (error) { | 154 | if (error) { | |
149 | aprint_error_dev(self, "init failed, error = %d\n", error); | 155 | aprint_error_dev(self, "init failed, error = %d\n", error); |
--- src/sys/dev/pci/xhci_pci.c 2019/12/02 03:06:51 1.24
+++ src/sys/dev/pci/xhci_pci.c 2020/10/27 13:50:57 1.25
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: xhci_pci.c,v 1.24 2019/12/02 03:06:51 msaitoh Exp $ */ | 1 | /* $NetBSD: xhci_pci.c,v 1.25 2020/10/27 13:50:57 skrll Exp $ */ | |
2 | /* OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp */ | 2 | /* OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | 5 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This code is derived from software contributed to The NetBSD Foundation | 8 | * This code is derived from software contributed to The NetBSD Foundation | |
9 | * by Lennart Augustsson (lennart@augustsson.net) at | 9 | * by Lennart Augustsson (lennart@augustsson.net) at | |
10 | * Carlstedt Research & Technology. | 10 | * Carlstedt Research & Technology. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | * POSSIBILITY OF SUCH DAMAGE. | 31 | * POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.24 2019/12/02 03:06:51 msaitoh Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.25 2020/10/27 13:50:57 skrll Exp $"); | |
36 | 36 | |||
37 | #ifdef _KERNEL_OPT | 37 | #ifdef _KERNEL_OPT | |
38 | #include "opt_xhci_pci.h" | 38 | #include "opt_xhci_pci.h" | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/kernel.h> | 43 | #include <sys/kernel.h> | |
44 | #include <sys/device.h> | 44 | #include <sys/device.h> | |
45 | #include <sys/proc.h> | 45 | #include <sys/proc.h> | |
46 | #include <sys/queue.h> | 46 | #include <sys/queue.h> | |
47 | 47 | |||
48 | #include <sys/bus.h> | 48 | #include <sys/bus.h> | |
@@ -183,30 +183,39 @@ xhci_pci_attach(device_t parent, device_ | @@ -183,30 +183,39 @@ xhci_pci_attach(device_t parent, device_ | |||
183 | } | 183 | } | |
184 | if (bus_space_map(sc->sc_iot, memaddr, sc->sc_ios, flags, | 184 | if (bus_space_map(sc->sc_iot, memaddr, sc->sc_ios, flags, | |
185 | &sc->sc_ioh)) { | 185 | &sc->sc_ioh)) { | |
186 | sc->sc_ios = 0; | 186 | sc->sc_ios = 0; | |
187 | aprint_error_dev(self, "can't map mem space\n"); | 187 | aprint_error_dev(self, "can't map mem space\n"); | |
188 | return; | 188 | return; | |
189 | } | 189 | } | |
190 | 190 | |||
191 | psc->sc_pc = pc; | 191 | psc->sc_pc = pc; | |
192 | psc->sc_tag = tag; | 192 | psc->sc_tag = tag; | |
193 | 193 | |||
194 | hccparams = bus_space_read_4(sc->sc_iot, sc->sc_ioh, XHCI_HCCPARAMS); | 194 | hccparams = bus_space_read_4(sc->sc_iot, sc->sc_ioh, XHCI_HCCPARAMS); | |
195 | 195 | |||
196 | if (pci_dma64_available(pa) && (XHCI_HCC_AC64(hccparams) != 0)) | 196 | if (XHCI_HCC_AC64(hccparams) != 0) { | |
197 | sc->sc_bus.ub_dmatag = pa->pa_dmat64; | 197 | aprint_verbose_dev(self, "64-bit DMA"); | |
198 | else | 198 | if (pci_dma64_available(pa)) { | |
199 | sc->sc_bus.ub_dmatag = pa->pa_dmat64; | |||
200 | aprint_verbose("\n"); | |||
201 | } else { | |||
202 | aprint_verbose(" - limited\n"); | |||
203 | sc->sc_bus.ub_dmatag = pa->pa_dmat; | |||
204 | } | |||
205 | } else { | |||
206 | aprint_verbose_dev(self, "32-bit DMA\n"); | |||
199 | sc->sc_bus.ub_dmatag = pa->pa_dmat; | 207 | sc->sc_bus.ub_dmatag = pa->pa_dmat; | |
208 | } | |||
200 | 209 | |||
201 | /* Enable the device. */ | 210 | /* Enable the device. */ | |
202 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, | 211 | pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG, | |
203 | csr | PCI_COMMAND_MASTER_ENABLE); | 212 | csr | PCI_COMMAND_MASTER_ENABLE); | |
204 | 213 | |||
205 | /* Allocate and establish the interrupt. */ | 214 | /* Allocate and establish the interrupt. */ | |
206 | if (pci_intr_alloc(pa, &psc->sc_pihp, NULL, 0)) { | 215 | if (pci_intr_alloc(pa, &psc->sc_pihp, NULL, 0)) { | |
207 | aprint_error_dev(self, "can't allocate handler\n"); | 216 | aprint_error_dev(self, "can't allocate handler\n"); | |
208 | goto fail; | 217 | goto fail; | |
209 | } | 218 | } | |
210 | intrstr = pci_intr_string(pc, psc->sc_pihp[0], intrbuf, | 219 | intrstr = pci_intr_string(pc, psc->sc_pihp[0], intrbuf, | |
211 | sizeof(intrbuf)); | 220 | sizeof(intrbuf)); | |
212 | psc->sc_ih = pci_intr_establish_xname(pc, psc->sc_pihp[0], IPL_USB, | 221 | psc->sc_ih = pci_intr_establish_xname(pc, psc->sc_pihp[0], IPL_USB, |