Module Name: src Committed By: riastradh Date: Tue Jun 25 14:54:55 UTC 2024
Modified Files: src/sys/dev/pci: virtio_pci.c Log Message: virtio_pci.c: Sprinkle KNF. - No parameter names in function prototypes. - Fix indentation. - Break overlong lines. - Blank line between declarations and rest of block. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/dev/pci/virtio_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/virtio_pci.c diff -u src/sys/dev/pci/virtio_pci.c:1.51 src/sys/dev/pci/virtio_pci.c:1.52 --- src/sys/dev/pci/virtio_pci.c:1.51 Tue Jun 25 14:54:03 2024 +++ src/sys/dev/pci/virtio_pci.c Tue Jun 25 14:54:55 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_pci.c,v 1.51 2024/06/25 14:54:03 riastradh Exp $ */ +/* $NetBSD: virtio_pci.c,v 1.52 2024/06/25 14:54:55 riastradh Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.51 2024/06/25 14:54:03 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.52 2024/06/25 14:54:55 riastradh Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -116,22 +116,27 @@ struct virtio_pci_softc { static int virtio_pci_attach_09(device_t, void *); static void virtio_pci_kick_09(struct virtio_softc *, uint16_t); static uint16_t virtio_pci_read_queue_size_09(struct virtio_softc *, uint16_t); -static void virtio_pci_setup_queue_09(struct virtio_softc *, uint16_t, uint64_t); +static void virtio_pci_setup_queue_09(struct virtio_softc *, uint16_t, + uint64_t); static void virtio_pci_set_status_09(struct virtio_softc *, int); -static void virtio_pci_negotiate_features_09(struct virtio_softc *, uint64_t); +static void virtio_pci_negotiate_features_09(struct virtio_softc *, + uint64_t); static int virtio_pci_attach_10(device_t, void *); static void virtio_pci_kick_10(struct virtio_softc *, uint16_t); static uint16_t virtio_pci_read_queue_size_10(struct virtio_softc *, uint16_t); -static void virtio_pci_setup_queue_10(struct virtio_softc *, uint16_t, uint64_t); +static void virtio_pci_setup_queue_10(struct virtio_softc *, uint16_t, + uint64_t); static void virtio_pci_set_status_10(struct virtio_softc *, int); -static void virtio_pci_negotiate_features_10(struct virtio_softc *, uint64_t); -static int virtio_pci_find_cap(struct virtio_pci_softc *psc, int cfg_type, void *buf, int buflen); +static void virtio_pci_negotiate_features_10(struct virtio_softc *, + uint64_t); +static int virtio_pci_find_cap(struct virtio_pci_softc *, int, void *, + int); static int virtio_pci_alloc_interrupts(struct virtio_softc *); static void virtio_pci_free_interrupts(struct virtio_softc *); -static int virtio_pci_adjust_config_region(struct virtio_pci_softc *psc); -static int virtio_pci_intr(void *arg); +static int virtio_pci_adjust_config_region(struct virtio_pci_softc *); +static int virtio_pci_intr(void *); static int virtio_pci_msix_queue_intr(void *); static int virtio_pci_msix_config_intr(void *); static int virtio_pci_setup_interrupts_09(struct virtio_softc *, int); @@ -207,10 +212,10 @@ virtio_pci_match(device_t parent, cfdata case PCI_VENDOR_QUMRANET: /* Transitional devices MUST have a PCI Revision ID of 0. */ if (((PCI_PRODUCT_QUMRANET_VIRTIO_1000 <= - PCI_PRODUCT(pa->pa_id)) && - (PCI_PRODUCT(pa->pa_id) <= - PCI_PRODUCT_QUMRANET_VIRTIO_103F)) && - PCI_REVISION(pa->pa_class) == 0) + PCI_PRODUCT(pa->pa_id)) && + (PCI_PRODUCT(pa->pa_id) <= + PCI_PRODUCT_QUMRANET_VIRTIO_103F)) && + PCI_REVISION(pa->pa_class) == 0) return 1; /* * Non-transitional devices SHOULD have a PCI Revision @@ -218,11 +223,11 @@ virtio_pci_match(device_t parent, cfdata * Revision ID value. */ if (((PCI_PRODUCT_QUMRANET_VIRTIO_1040 <= - PCI_PRODUCT(pa->pa_id)) && - (PCI_PRODUCT(pa->pa_id) <= - PCI_PRODUCT_QUMRANET_VIRTIO_107F)) && - /* XXX: TODO */ - PCI_REVISION(pa->pa_class) == 1) + PCI_PRODUCT(pa->pa_id)) && + (PCI_PRODUCT(pa->pa_id) <= + PCI_PRODUCT_QUMRANET_VIRTIO_107F)) && + /* XXX: TODO */ + PCI_REVISION(pa->pa_class) == 1) return 1; break; } @@ -255,7 +260,7 @@ virtio_pci_attach(device_t parent, devic break; default: aprint_normal(": unknown revision 0x%02x; giving up\n", - revision); + revision); return; } @@ -394,14 +399,14 @@ virtio_pci_attach_09(device_t self, void /* complete IO region */ if (pci_mapreg_map(pa, PCI_MAPREG_START, PCI_MAPREG_TYPE_IO, 0, - &psc->sc_iot, &psc->sc_ioh, NULL, &psc->sc_iosize)) { + &psc->sc_iot, &psc->sc_ioh, NULL, &psc->sc_iosize)) { aprint_error_dev(self, "can't map i/o space\n"); return EIO; } /* queue space */ if (bus_space_subregion(psc->sc_iot, psc->sc_ioh, - VIRTIO_CONFIG_QUEUE_NOTIFY, 2, &psc->sc_notify_ioh)) { + VIRTIO_CONFIG_QUEUE_NOTIFY, 2, &psc->sc_notify_ioh)) { aprint_error_dev(self, "can't map notify i/o space\n"); return EIO; } @@ -410,7 +415,7 @@ virtio_pci_attach_09(device_t self, void /* ISR space */ if (bus_space_subregion(psc->sc_iot, psc->sc_ioh, - VIRTIO_CONFIG_ISR_STATUS, 1, &psc->sc_isr_ioh)) { + VIRTIO_CONFIG_ISR_STATUS, 1, &psc->sc_isr_ioh)) { aprint_error_dev(self, "can't map isr i/o space\n"); return EIO; } @@ -419,7 +424,7 @@ virtio_pci_attach_09(device_t self, void /* set our version 0.9 ops */ sc->sc_ops = &virtio_pci_ops_09; - sc->sc_bus_endian = READ_ENDIAN_09; + sc->sc_bus_endian = READ_ENDIAN_09; sc->sc_struct_endian = STRUCT_ENDIAN_09; return 0; } @@ -438,20 +443,21 @@ virtio_pci_attach_10(device_t self, void int have_device_cfg = 0; bus_size_t bars[NMAPREG] = { 0 }; int bars_idx[NMAPREG] = { 0 }; - struct virtio_pci_cap *caps[] = { &common, &isr, &device, ¬ify.cap }; + struct virtio_pci_cap * const caps[] = + { &common, &isr, &device, ¬ify.cap }; int i, j, ret = 0; if (virtio_pci_find_cap(psc, VIRTIO_PCI_CAP_COMMON_CFG, - &common, sizeof(common))) + &common, sizeof(common))) return ENODEV; if (virtio_pci_find_cap(psc, VIRTIO_PCI_CAP_NOTIFY_CFG, - ¬ify, sizeof(notify))) + ¬ify, sizeof(notify))) return ENODEV; if (virtio_pci_find_cap(psc, VIRTIO_PCI_CAP_ISR_CFG, - &isr, sizeof(isr))) + &isr, sizeof(isr))) return ENODEV; if (virtio_pci_find_cap(psc, VIRTIO_PCI_CAP_DEVICE_CFG, - &device, sizeof(device))) + &device, sizeof(device))) memset(&device, 0, sizeof(device)); else have_device_cfg = 1; @@ -460,6 +466,7 @@ virtio_pci_attach_10(device_t self, void for (i = 0; i < __arraycount(caps); i++) { int bar = caps[i]->bar; bus_size_t len = caps[i]->offset + caps[i]->length; + if (caps[i]->length == 0) continue; if (bars[bar] < len) @@ -469,13 +476,14 @@ virtio_pci_attach_10(device_t self, void for (i = j = 0; i < __arraycount(bars); i++) { int reg; pcireg_t type; + if (bars[i] == 0) continue; reg = PCI_BAR(i); type = pci_mapreg_type(pc, tag, reg); if (pci_mapreg_map(pa, reg, type, 0, - &psc->sc_bars_iot[j], &psc->sc_bars_ioh[j], - NULL, &psc->sc_bars_iosize[j])) { + &psc->sc_bars_iot[j], &psc->sc_bars_ioh[j], + NULL, &psc->sc_bars_iosize[j])) { aprint_error_dev(self, "can't map bar %u \n", i); ret = EIO; goto err; @@ -489,8 +497,7 @@ virtio_pci_attach_10(device_t self, void i = bars_idx[notify.cap.bar]; if (bus_space_subregion(psc->sc_bars_iot[i], psc->sc_bars_ioh[i], - notify.cap.offset, notify.cap.length, - &psc->sc_notify_ioh)) { + notify.cap.offset, notify.cap.length, &psc->sc_notify_ioh)) { aprint_error_dev(self, "can't map notify i/o space\n"); ret = EIO; goto err; @@ -501,23 +508,23 @@ virtio_pci_attach_10(device_t self, void if (have_device_cfg) { i = bars_idx[device.bar]; - if (bus_space_subregion(psc->sc_bars_iot[i], psc->sc_bars_ioh[i], - device.offset, device.length, - &sc->sc_devcfg_ioh)) { + if (bus_space_subregion(psc->sc_bars_iot[i], + psc->sc_bars_ioh[i], device.offset, device.length, + &sc->sc_devcfg_ioh)) { aprint_error_dev(self, "can't map devcfg i/o space\n"); ret = EIO; goto err; } aprint_debug_dev(self, - "device.offset = 0x%x, device.length = 0x%x\n", - device.offset, device.length); + "device.offset = 0x%x, device.length = 0x%x\n", + device.offset, device.length); sc->sc_devcfg_iosize = device.length; sc->sc_devcfg_iot = psc->sc_bars_iot[i]; } i = bars_idx[isr.bar]; if (bus_space_subregion(psc->sc_bars_iot[i], psc->sc_bars_ioh[i], - isr.offset, isr.length, &psc->sc_isr_ioh)) { + isr.offset, isr.length, &psc->sc_isr_ioh)) { aprint_error_dev(self, "can't map isr i/o space\n"); ret = EIO; goto err; @@ -527,7 +534,7 @@ virtio_pci_attach_10(device_t self, void i = bars_idx[common.bar]; if (bus_space_subregion(psc->sc_bars_iot[i], psc->sc_bars_ioh[i], - common.offset, common.length, &psc->sc_ioh)) { + common.offset, common.length, &psc->sc_ioh)) { aprint_error_dev(self, "can't map common i/o space\n"); ret = EIO; goto err; @@ -539,7 +546,7 @@ virtio_pci_attach_10(device_t self, void /* set our version 1.0 ops */ sc->sc_ops = &virtio_pci_ops_10; - sc->sc_bus_endian = READ_ENDIAN_10; + sc->sc_bus_endian = READ_ENDIAN_10; sc->sc_struct_endian = STRUCT_ENDIAN_10; return 0; @@ -557,7 +564,8 @@ err: /* v1.0 attach helper */ static int -virtio_pci_find_cap(struct virtio_pci_softc *psc, int cfg_type, void *buf, int buflen) +virtio_pci_find_cap(struct virtio_pci_softc *psc, int cfg_type, void *buf, + int buflen) { device_t self = psc->sc_sc.sc_dev; pci_chipset_tag_t pc = psc->sc_pa.pa_pc; @@ -571,13 +579,14 @@ virtio_pci_find_cap(struct virtio_pci_so if (buflen < sizeof(struct virtio_pci_cap)) return ERANGE; - if (!pci_get_capability(pc, tag, PCI_CAP_VENDSPEC, &offset, &v->reg[0])) + if (!pci_get_capability(pc, tag, PCI_CAP_VENDSPEC, &offset, + &v->reg[0])) return ENOENT; do { for (i = 0; i < 4; i++) v->reg[i] = - le32toh(pci_conf_read(pc, tag, offset + i * 4)); + le32toh(pci_conf_read(pc, tag, offset + i * 4)); if (v->vcap.cfg_type == cfg_type) break; offset = v->vcap.cap_next; @@ -594,7 +603,7 @@ virtio_pci_find_cap(struct virtio_pci_so } for (i = 4; i < len / sizeof(pcireg_t); i++) v->reg[i] = - le32toh(pci_conf_read(pc, tag, offset + i * 4)); + le32toh(pci_conf_read(pc, tag, offset + i * 4)); } /* endian fixup */ @@ -628,8 +637,8 @@ virtio_pci_adjust_config_region(struct v sc->sc_devcfg_iosize = psc->sc_iosize - psc->sc_devcfg_offset; sc->sc_devcfg_iot = psc->sc_iot; if (bus_space_subregion(psc->sc_iot, psc->sc_ioh, - psc->sc_devcfg_offset, sc->sc_devcfg_iosize, - &sc->sc_devcfg_ioh)) { + psc->sc_devcfg_offset, sc->sc_devcfg_iosize, + &sc->sc_devcfg_ioh)) { aprint_error_dev(self, "can't map config i/o space\n"); return EIO; } @@ -674,15 +683,16 @@ virtio_pci_set_status_09(struct virtio_s int old = 0; if (status != 0) { - old = bus_space_read_1(psc->sc_iot, psc->sc_ioh, - VIRTIO_CONFIG_DEVICE_STATUS); + old = bus_space_read_1(psc->sc_iot, psc->sc_ioh, + VIRTIO_CONFIG_DEVICE_STATUS); } bus_space_write_1(psc->sc_iot, psc->sc_ioh, VIRTIO_CONFIG_DEVICE_STATUS, status|old); } static void -virtio_pci_negotiate_features_09(struct virtio_softc *sc, uint64_t guest_features) +virtio_pci_negotiate_features_09(struct virtio_softc *sc, + uint64_t guest_features) { struct virtio_pci_softc * const psc = (struct virtio_pci_softc *)sc; uint32_t r; @@ -707,7 +717,7 @@ virtio_pci_kick_10(struct virtio_softc * { struct virtio_pci_softc * const psc = (struct virtio_pci_softc *)sc; unsigned offset = sc->sc_vqs[idx].vq_notify_off * - psc->sc_notify_off_multiplier; + psc->sc_notify_off_multiplier; bus_space_write_2(psc->sc_notify_iot, psc->sc_notify_ioh, offset, idx); } @@ -737,7 +747,7 @@ virtio_pci_read_queue_size_10(struct vir */ static __inline void virtio_pci_bus_space_write_8(bus_space_tag_t iot, bus_space_handle_t ioh, - bus_size_t offset, uint64_t value) + bus_size_t offset, uint64_t value) { #if _QUAD_HIGHWORD bus_space_write_4(iot, ioh, offset, BUS_ADDR_LO32(value)); @@ -753,7 +763,7 @@ virtio_pci_setup_queue_10(struct virtio_ { struct virtio_pci_softc * const psc = (struct virtio_pci_softc *)sc; struct virtqueue *vq = &sc->sc_vqs[idx]; - bus_space_tag_t iot = psc->sc_iot; + bus_space_tag_t iot = psc->sc_iot; bus_space_handle_t ioh = psc->sc_ioh; KASSERT(vq->vq_index == idx); @@ -761,22 +771,22 @@ virtio_pci_setup_queue_10(struct virtio_ if (addr == 0) { bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_ENABLE, 0); virtio_pci_bus_space_write_8(iot, ioh, - VIRTIO_CONFIG1_QUEUE_DESC, 0); + VIRTIO_CONFIG1_QUEUE_DESC, 0); virtio_pci_bus_space_write_8(iot, ioh, - VIRTIO_CONFIG1_QUEUE_AVAIL, 0); + VIRTIO_CONFIG1_QUEUE_AVAIL, 0); virtio_pci_bus_space_write_8(iot, ioh, - VIRTIO_CONFIG1_QUEUE_USED, 0); + VIRTIO_CONFIG1_QUEUE_USED, 0); } else { virtio_pci_bus_space_write_8(iot, ioh, - VIRTIO_CONFIG1_QUEUE_DESC, addr); + VIRTIO_CONFIG1_QUEUE_DESC, addr); virtio_pci_bus_space_write_8(iot, ioh, - VIRTIO_CONFIG1_QUEUE_AVAIL, addr + vq->vq_availoffset); + VIRTIO_CONFIG1_QUEUE_AVAIL, addr + vq->vq_availoffset); virtio_pci_bus_space_write_8(iot, ioh, - VIRTIO_CONFIG1_QUEUE_USED, addr + vq->vq_usedoffset); + VIRTIO_CONFIG1_QUEUE_USED, addr + vq->vq_usedoffset); bus_space_write_2(iot, ioh, - VIRTIO_CONFIG1_QUEUE_ENABLE, 1); + VIRTIO_CONFIG1_QUEUE_ENABLE, 1); vq->vq_notify_off = bus_space_read_2(iot, ioh, - VIRTIO_CONFIG1_QUEUE_NOTIFY_OFF); + VIRTIO_CONFIG1_QUEUE_NOTIFY_OFF); } if (psc->sc_ihs_num > 1) { @@ -784,7 +794,7 @@ virtio_pci_setup_queue_10(struct virtio_ if (psc->sc_intr_pervq) vec += idx; bus_space_write_2(iot, ioh, - VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR, vec); + VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR, vec); } } @@ -798,11 +808,13 @@ virtio_pci_set_status_10(struct virtio_s if (status) old = bus_space_read_1(iot, ioh, VIRTIO_CONFIG1_DEVICE_STATUS); - bus_space_write_1(iot, ioh, VIRTIO_CONFIG1_DEVICE_STATUS, status | old); + bus_space_write_1(iot, ioh, VIRTIO_CONFIG1_DEVICE_STATUS, + status | old); } void -virtio_pci_negotiate_features_10(struct virtio_softc *sc, uint64_t guest_features) +virtio_pci_negotiate_features_10(struct virtio_softc *sc, + uint64_t guest_features) { struct virtio_pci_softc * const psc = (struct virtio_pci_softc *)sc; device_t self = sc->sc_dev; @@ -822,31 +834,32 @@ virtio_pci_negotiate_features_10(struct bus_space_write_4(iot, ioh, VIRTIO_CONFIG1_DEVICE_FEATURE_SELECT, 0); host = bus_space_read_4(iot, ioh, VIRTIO_CONFIG1_DEVICE_FEATURE); bus_space_write_4(iot, ioh, VIRTIO_CONFIG1_DEVICE_FEATURE_SELECT, 1); - host |= (uint64_t) - bus_space_read_4(iot, ioh, VIRTIO_CONFIG1_DEVICE_FEATURE) << 32; + host |= (uint64_t)bus_space_read_4(iot, ioh, + VIRTIO_CONFIG1_DEVICE_FEATURE) << 32; negotiated = host & guest_features; bus_space_write_4(iot, ioh, VIRTIO_CONFIG1_DRIVER_FEATURE_SELECT, 0); bus_space_write_4(iot, ioh, VIRTIO_CONFIG1_DRIVER_FEATURE, - negotiated & 0xffffffff); + negotiated & 0xffffffff); bus_space_write_4(iot, ioh, VIRTIO_CONFIG1_DRIVER_FEATURE_SELECT, 1); bus_space_write_4(iot, ioh, VIRTIO_CONFIG1_DRIVER_FEATURE, - negotiated >> 32); + negotiated >> 32); virtio_pci_set_status_10(sc, VIRTIO_CONFIG_DEVICE_STATUS_FEATURES_OK); - device_status = bus_space_read_1(iot, ioh, VIRTIO_CONFIG1_DEVICE_STATUS); + device_status = bus_space_read_1(iot, ioh, + VIRTIO_CONFIG1_DEVICE_STATUS); if ((device_status & VIRTIO_CONFIG_DEVICE_STATUS_FEATURES_OK) == 0) { aprint_error_dev(self, "feature negotiation failed\n"); bus_space_write_1(iot, ioh, VIRTIO_CONFIG1_DEVICE_STATUS, - VIRTIO_CONFIG_DEVICE_STATUS_FAILED); + VIRTIO_CONFIG_DEVICE_STATUS_FAILED); return; } if ((negotiated & VIRTIO_F_VERSION_1) == 0) { aprint_error_dev(self, "host rejected version 1\n"); bus_space_write_1(iot, ioh, VIRTIO_CONFIG1_DEVICE_STATUS, - VIRTIO_CONFIG_DEVICE_STATUS_FAILED); + VIRTIO_CONFIG_DEVICE_STATUS_FAILED); return; } @@ -870,12 +883,10 @@ virtio_pci_setup_interrupts_10(struct vi return 0; vector = VIRTIO_MSIX_CONFIG_VECTOR_INDEX; - bus_space_write_2(iot, ioh, - VIRTIO_CONFIG1_CONFIG_MSIX_VECTOR, vector); + bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_CONFIG_MSIX_VECTOR, vector); ret = bus_space_read_2(iot, ioh, VIRTIO_CONFIG1_CONFIG_MSIX_VECTOR); if (ret != vector) { - VIRTIO_PCI_LOG(sc, reinit, - "can't set config msix vector\n"); + VIRTIO_PCI_LOG(sc, reinit, "can't set config msix vector\n"); return -1; } @@ -886,9 +897,9 @@ virtio_pci_setup_interrupts_10(struct vi vector += qid; bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SELECT, qid); bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR, - vector); + vector); ret = bus_space_read_2(iot, ioh, - VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR); + VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR); if (ret != vector) { VIRTIO_PCI_LOG(sc, reinit, "can't set queue %d " "msix vector\n", qid); @@ -969,7 +980,8 @@ virtio_pci_establish_msix_interrupts(str psc->sc_ihs[idx] = pci_intr_establish_xname(pc, psc->sc_ihp[idx], sc->sc_ipl, virtio_pci_msix_config_intr, sc, intr_xname); if (psc->sc_ihs[idx] == NULL) { - aprint_error_dev(self, "couldn't establish MSI-X for config\n"); + aprint_error_dev(self, + "couldn't establish MSI-X for config\n"); goto error; } @@ -987,29 +999,36 @@ virtio_pci_establish_msix_interrupts(str PCI_INTR_MPSAFE, true); } - psc->sc_ihs[n] = pci_intr_establish_xname(pc, psc->sc_ihp[n], - sc->sc_ipl, vq->vq_intrhand, vq->vq_intrhand_arg, intr_xname); + psc->sc_ihs[n] = pci_intr_establish_xname(pc, + psc->sc_ihp[n], sc->sc_ipl, + vq->vq_intrhand, vq->vq_intrhand_arg, intr_xname); if (psc->sc_ihs[n] == NULL) { - aprint_error_dev(self, "couldn't establish MSI-X for a vq\n"); + aprint_error_dev(self, + "couldn't establish MSI-X for a vq\n"); goto error; } } } else { - if (sc->sc_flags & VIRTIO_F_INTR_MPSAFE) - pci_intr_setattr(pc, &psc->sc_ihp[idx], PCI_INTR_MPSAFE, true); + if (sc->sc_flags & VIRTIO_F_INTR_MPSAFE) { + pci_intr_setattr(pc, &psc->sc_ihp[idx], + PCI_INTR_MPSAFE, true); + } snprintf(intr_xname, sizeof(intr_xname), "%s queues", device_xname(sc->sc_dev)); - psc->sc_ihs[idx] = pci_intr_establish_xname(pc, psc->sc_ihp[idx], - sc->sc_ipl, virtio_pci_msix_queue_intr, sc, intr_xname); + psc->sc_ihs[idx] = pci_intr_establish_xname(pc, + psc->sc_ihp[idx], sc->sc_ipl, + virtio_pci_msix_queue_intr, sc, intr_xname); if (psc->sc_ihs[idx] == NULL) { - aprint_error_dev(self, "couldn't establish MSI-X for queues\n"); + aprint_error_dev(self, + "couldn't establish MSI-X for queues\n"); goto error; } } idx = VIRTIO_MSIX_CONFIG_VECTOR_INDEX; - intrstr = pci_intr_string(pc, psc->sc_ihp[idx], intrbuf, sizeof(intrbuf)); + intrstr = pci_intr_string(pc, psc->sc_ihp[idx], intrbuf, + sizeof(intrbuf)); aprint_normal_dev(self, "config interrupting at %s\n", intrstr); idx = VIRTIO_MSIX_QUEUE_VECTOR_INDEX; if (psc->sc_intr_pervq) { @@ -1027,10 +1046,12 @@ virtio_pci_establish_msix_interrupts(str kcpuset_zero(affinity); kcpuset_set(affinity, affinity_to); - r = interrupt_distribute(psc->sc_ihs[n], affinity, NULL); + r = interrupt_distribute(psc->sc_ihs[n], affinity, + NULL); if (r == 0) { aprint_normal_dev(self, - "for vq #%d interrupting at %s affinity to %u\n", + "for vq #%d interrupting at %s" + " affinity to %u\n", qid, intrstr, affinity_to); } else { aprint_normal_dev(self, @@ -1041,8 +1062,10 @@ virtio_pci_establish_msix_interrupts(str kcpuset_destroy(affinity); } else { - intrstr = pci_intr_string(pc, psc->sc_ihp[idx], intrbuf, sizeof(intrbuf)); - aprint_normal_dev(self, "queues interrupting at %s\n", intrstr); + intrstr = pci_intr_string(pc, psc->sc_ihp[idx], intrbuf, + sizeof(intrbuf)); + aprint_normal_dev(self, "queues interrupting at %s\n", + intrstr); } return 0; @@ -1057,12 +1080,15 @@ error: n = idx + qid; if (psc->sc_ihs[n] == NULL) continue; - pci_intr_disestablish(psc->sc_pa.pa_pc, psc->sc_ihs[n]); + pci_intr_disestablish(psc->sc_pa.pa_pc, + psc->sc_ihs[n]); } } else { - if (psc->sc_ihs[idx] != NULL) - pci_intr_disestablish(psc->sc_pa.pa_pc, psc->sc_ihs[idx]); + if (psc->sc_ihs[idx] != NULL) { + pci_intr_disestablish(psc->sc_pa.pa_pc, + psc->sc_ihs[idx]); + } } return -1; @@ -1088,7 +1114,8 @@ virtio_pci_establish_intx_interrupt(stru return -1; } - intrstr = pci_intr_string(pc, psc->sc_ihp[0], intrbuf, sizeof(intrbuf)); + intrstr = pci_intr_string(pc, psc->sc_ihp[0], intrbuf, + sizeof(intrbuf)); aprint_normal_dev(self, "interrupting at %s\n", intrstr); return 0; @@ -1198,8 +1225,10 @@ virtio_pci_free_interrupts(struct virtio psc->sc_ihs[i] = NULL; } - if (psc->sc_ihs_num > 0) - pci_intr_release(psc->sc_pa.pa_pc, psc->sc_ihp, psc->sc_ihs_num); + if (psc->sc_ihs_num > 0) { + pci_intr_release(psc->sc_pa.pa_pc, psc->sc_ihp, + psc->sc_ihs_num); + } if (psc->sc_ihs != NULL) { kmem_free(psc->sc_ihs, sizeof(*psc->sc_ihs) * psc->sc_ihs_num);