| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: virtio_pci.c,v 1.13 2020/09/17 17:33:50 jakllsch Exp $ */ | | 1 | /* $NetBSD: virtio_pci.c,v 1.14 2020/09/23 13:45:14 jakllsch Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2010 Minoura Makoto. | | 4 | * Copyright (c) 2010 Minoura Makoto. |
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. |
| @@ -16,27 +16,27 @@ | | | @@ -16,27 +16,27 @@ |
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | | 26 | */ |
27 | | | 27 | |
28 | #include <sys/cdefs.h> | | 28 | #include <sys/cdefs.h> |
29 | __KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.13 2020/09/17 17:33:50 jakllsch Exp $"); | | 29 | __KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.14 2020/09/23 13:45:14 jakllsch Exp $"); |
30 | | | 30 | |
31 | #include <sys/param.h> | | 31 | #include <sys/param.h> |
32 | #include <sys/systm.h> | | 32 | #include <sys/systm.h> |
33 | #include <sys/kmem.h> | | 33 | #include <sys/kmem.h> |
34 | #include <sys/module.h> | | 34 | #include <sys/module.h> |
35 | #include <sys/interrupt.h> | | 35 | #include <sys/interrupt.h> |
36 | | | 36 | |
37 | #include <sys/device.h> | | 37 | #include <sys/device.h> |
38 | | | 38 | |
39 | #include <dev/pci/pcidevs.h> | | 39 | #include <dev/pci/pcidevs.h> |
40 | #include <dev/pci/pcireg.h> | | 40 | #include <dev/pci/pcireg.h> |
41 | #include <dev/pci/pcivar.h> | | 41 | #include <dev/pci/pcivar.h> |
42 | | | 42 | |
| @@ -724,27 +724,27 @@ retry: | | | @@ -724,27 +724,27 @@ retry: |
724 | psc->sc_ihs = kmem_zalloc(sizeof(*psc->sc_ihs) * 1, | | 724 | psc->sc_ihs = kmem_zalloc(sizeof(*psc->sc_ihs) * 1, |
725 | KM_SLEEP); | | 725 | KM_SLEEP); |
726 | | | 726 | |
727 | error = virtio_pci_setup_intx_interrupt(sc, &psc->sc_pa); | | 727 | error = virtio_pci_setup_intx_interrupt(sc, &psc->sc_pa); |
728 | if (error != 0) { | | 728 | if (error != 0) { |
729 | kmem_free(psc->sc_ihs, sizeof(*psc->sc_ihs) * 1); | | 729 | kmem_free(psc->sc_ihs, sizeof(*psc->sc_ihs) * 1); |
730 | pci_intr_release(pc, psc->sc_ihp, 1); | | 730 | pci_intr_release(pc, psc->sc_ihp, 1); |
731 | return -1; | | 731 | return -1; |
732 | } | | 732 | } |
733 | | | 733 | |
734 | psc->sc_ihs_num = 1; | | 734 | psc->sc_ihs_num = 1; |
735 | psc->sc_config_offset = VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI; | | 735 | psc->sc_config_offset = VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI; |
736 | | | 736 | |
737 | error = pci_get_capability(pc, tag, PCI_CAP_MSIX, &off, NULL); | | 737 | error = pci_get_capability(pc, tag, PCI_CAP_MSIX, &off, NULL); |
738 | if (error != 0) { | | 738 | if (error != 0) { |
739 | ctl = pci_conf_read(pc, tag, off + PCI_MSIX_CTL); | | 739 | ctl = pci_conf_read(pc, tag, off + PCI_MSIX_CTL); |
740 | ctl &= ~PCI_MSIX_CTL_ENABLE; | | 740 | ctl &= ~PCI_MSIX_CTL_ENABLE; |
741 | pci_conf_write(pc, tag, off + PCI_MSIX_CTL, ctl); | | 741 | pci_conf_write(pc, tag, off + PCI_MSIX_CTL, ctl); |
742 | } | | 742 | } |
743 | } | | 743 | } |
744 | | | 744 | |
745 | return 0; | | 745 | return 0; |
746 | } | | 746 | } |
747 | | | 747 | |
748 | static void | | 748 | static void |
749 | virtio_pci_free_interrupts(struct virtio_softc *sc) | | 749 | virtio_pci_free_interrupts(struct virtio_softc *sc) |
750 | { | | 750 | { |