| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: msipic.c,v 1.13 2019/06/14 05:59:40 msaitoh Exp $ */ | | 1 | /* $NetBSD: msipic.c,v 1.14 2019/06/17 05:45:46 msaitoh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2015 Internet Initiative Japan Inc. | | 4 | * Copyright (c) 2015 Internet Initiative Japan Inc. |
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. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.13 2019/06/14 05:59:40 msaitoh Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.14 2019/06/17 05:45:46 msaitoh Exp $"); |
31 | | | 31 | |
32 | #include "opt_intrdebug.h" | | 32 | #include "opt_intrdebug.h" |
33 | | | 33 | |
34 | #include <sys/types.h> | | 34 | #include <sys/types.h> |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | #include <sys/errno.h> | | 37 | #include <sys/errno.h> |
38 | #include <sys/kmem.h> | | 38 | #include <sys/kmem.h> |
39 | #include <sys/mutex.h> | | 39 | #include <sys/mutex.h> |
40 | | | 40 | |
41 | #include <dev/pci/pcivar.h> | | 41 | #include <dev/pci/pcivar.h> |
42 | | | 42 | |
43 | #include <machine/i82489reg.h> | | 43 | #include <machine/i82489reg.h> |
| @@ -240,27 +240,28 @@ msipic_construct_common_msi_pic(const st | | | @@ -240,27 +240,28 @@ msipic_construct_common_msi_pic(const st |
240 | msipic = kmem_zalloc(sizeof(*msipic), KM_SLEEP); | | 240 | msipic = kmem_zalloc(sizeof(*msipic), KM_SLEEP); |
241 | | | 241 | |
242 | mutex_enter(&msipic_list_lock); | | 242 | mutex_enter(&msipic_list_lock); |
243 | | | 243 | |
244 | devid = msipic_allocate_common_msi_devid(pa); | | 244 | devid = msipic_allocate_common_msi_devid(pa); |
245 | if (devid == -1) { | | 245 | if (devid == -1) { |
246 | mutex_exit(&msipic_list_lock); | | 246 | mutex_exit(&msipic_list_lock); |
247 | kmem_free(pic, sizeof(*pic)); | | 247 | kmem_free(pic, sizeof(*pic)); |
248 | kmem_free(msipic, sizeof(*msipic)); | | 248 | kmem_free(msipic, sizeof(*msipic)); |
249 | return NULL; | | 249 | return NULL; |
250 | } | | 250 | } |
251 | | | 251 | |
252 | memcpy(pic, pic_tmpl, sizeof(*pic)); | | 252 | memcpy(pic, pic_tmpl, sizeof(*pic)); |
253 | pic->pic_edge_stubs = x2apic_mode ? x2apic_edge_stubs : ioapic_edge_stubs, | | 253 | pic->pic_edge_stubs |
| | | 254 | = x2apic_mode ? x2apic_edge_stubs : ioapic_edge_stubs; |
254 | pic->pic_msipic = msipic; | | 255 | pic->pic_msipic = msipic; |
255 | msipic->mp_pic = pic; | | 256 | msipic->mp_pic = pic; |
256 | pci_decompose_tag(pa->pa_pc, pa->pa_tag, | | 257 | pci_decompose_tag(pa->pa_pc, pa->pa_tag, |
257 | &msipic->mp_bus, &msipic->mp_dev, &msipic->mp_fun); | | 258 | &msipic->mp_bus, &msipic->mp_dev, &msipic->mp_fun); |
258 | memcpy(&msipic->mp_pa, pa, sizeof(msipic->mp_pa)); | | 259 | memcpy(&msipic->mp_pa, pa, sizeof(msipic->mp_pa)); |
259 | msipic->mp_devid = devid; | | 260 | msipic->mp_devid = devid; |
260 | /* | | 261 | /* |
261 | * pci_msi{,x}_alloc() must be called only once in the device driver. | | 262 | * pci_msi{,x}_alloc() must be called only once in the device driver. |
262 | */ | | 263 | */ |
263 | KASSERT(msipic_find_msi_pic_locked(msipic->mp_devid) == NULL); | | 264 | KASSERT(msipic_find_msi_pic_locked(msipic->mp_devid) == NULL); |
264 | | | 265 | |
265 | LIST_INSERT_HEAD(&msipic_list, msipic, mp_list); | | 266 | LIST_INSERT_HEAD(&msipic_list, msipic, mp_list); |
266 | | | 267 | |