History log of /src/sys/dev/pci/virtio.c |
Revision | | Date | Author | Comments |
1.84 |
| 06-Sep-2025 |
riastradh | virtio(4): Use paravirt_membar_sync(9) where needed.
PR kern/59618: occasional virtio block device lock ups/hangs
|
1.83 |
| 26-Jul-2025 |
martin | PR 58681: add a port of the OpenBSD viogpu(4) driver written by Joshua Stein <jcs@openbsd.org>. Port by George Matsumura with help from Jiaxun Yang.
|
1.82 |
| 05-Aug-2024 |
riastradh | virtio(4): Assert child attach finished before we allow queueing.
Should help catch mistakes like:
PR kern/58555: Kernel panic during boot when using viocon with PCIe
|
1.81 |
| 10-Feb-2024 |
isaki | branches: 1.81.2; Split KASSERT(A && B) into KASSERT(A); KASSERT(B).
|
1.80 |
| 09-Feb-2024 |
andvar | fix spelling mistakes, mainly in comments and log messages.
|
1.79 |
| 07-Nov-2023 |
rin | virtio_read_device_config_le_[24]: Fix for {aarch64,arm}eb
Stop byte-swapping for big-endian aarch64 and arm to fix corrupted read for, e.g., sc_taglen for vio9p(4).
As described as comments in virtio_pci.c, big-endian aarch64 and armv7 (armeb) are somewhat special. At the moment, all supported virtual/real machines are configured as little-endian, and only CPU cores are switched to big-endian mode during early boot stage.
Most peripheral buses for armeb are LSB as a result, and their default bus_space(9) functions swap byte-order. Therefore, PIOed data from memory-mapped devices, as well as pci(4) ones, are actually LSB, but observed as MSB for armeb.
Therefore, we should not swap byte-order further in virtio_read_device_config_le_[24] on armeb.
Thanks ozaki-r@ for comments.
XXX Centralize? See virtio_pci.c and sys/dev/fdt/virtio_mmio_fdt.c also.
|
1.78 |
| 21-Apr-2023 |
yamaguchi | virtio(4): change members of struct vring_desc_extra before free a slot
This prevents the following race condition. 1. Thread-A: calls virtio_dequeue_commit() and puts a slot into free descriptor chain in vq_free_slot() 2. Thread-B: calls virtio_enqueue_prep() and get the slot stored by Thread-A 3. Thread-B: calls virtio_enqueue_reserve() and changes desc_base and desc_free_idx for the slot 4. Thread-A: changes the same members updated by Thread-B
reported by hannken, thanks.
|
1.77 |
| 19-Apr-2023 |
yamaguchi | virtio(4): change variable name, nfc
|
1.76 |
| 19-Apr-2023 |
yamaguchi | Fix not to allocate unnecessary descriptor
fixes PR/57358
|
1.75 |
| 19-Apr-2023 |
yamaguchi | Use enumeration for state of a child driver instead of flags and check its detaching by using sc->sc_child in virtio_softc
pointed out by riastradh, thanks. fixes PR/57357
|
1.74 |
| 31-Mar-2023 |
yamaguchi | Added flags to store status of attaching a virtio device
This prevents a panic on reboot after a virtio device had called virtio_child_attach_failed().
|
1.73 |
| 31-Mar-2023 |
yamaguchi | Use descriptor chain for free slots instead of vq_entry list
Descriptors can be chained by themself. And descriptors added to avail ring or used ring are already chained. But it was not used for unused descriptors and another linked list structure named vq_entry was used. The chain is also used for unused descriptors to make virtio(4) simpler.
|
1.72 |
| 29-Mar-2023 |
riastradh | virtio(4): Fix sizing of virtqueue allocation.
vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero; likewise vq->vq_used[0].ring.
Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this and restore the previous allocation sizing logic.
XXX We shouldn't use zero-length arrays here -- they are asking for trouble like this, and C99 has a standard way to express what we're actually trying to get at it, flexible array members.
PR kern/57304
Reported-by: syzbot+7fb1047f5dfa33b26331@syzkaller.appspotmail.com
|
1.71 |
| 27-Mar-2023 |
nakayama | Use PRIuBUSSIZE to print bus_size_t variables.
|
1.70 |
| 27-Mar-2023 |
riastradh | virtio(4): Avoid name collision with global intrhand on sparc64.
Pacifies -Werror=shadow.
No functional change intended.
|
1.69 |
| 25-Mar-2023 |
yamaguchi | Setup virtqueues after registering them to virtio_softc
|
1.68 |
| 24-Mar-2023 |
yamaguchi | Added check of pointer for allocated memory before release of resource
|
1.67 |
| 23-Mar-2023 |
yamaguchi | Added functions to set interrupt handler and index into virtqueue
|
1.66 |
| 23-Mar-2023 |
yamaguchi | Set virtqueues in virtio_child_attach_finish
The number of virtqueue maybe change in a part of VirtIO devices (e.g. vioif(4)). And it is fixed after negotiation of features. So the configuration is moved into the function.
|
1.65 |
| 03-Jan-2023 |
jakllsch | Subtly adjust criteria for notification of Virtio devices in VIRTIO_F_RING_EVENT_IDX mode.
This fixes stalls in the vioif(4) transmit path that would happen sooner or later, depending on interface transmit utilization, and were particularly noticable with a NetBSD guest transmitting to its x86 KVM host at multi-gigabit speeds.
|
1.64 |
| 30-Dec-2022 |
jakllsch | Fix dmamap_syncs more; the number of ring elements is vq->vq_num, not sc->sc_nvqs.
|
1.63 |
| 31-Oct-2022 |
simonb | branches: 1.63.2; Use PRIx64 in a debug print macro to print a uint64_t.
|
1.62 |
| 18-Oct-2022 |
skrll | KNF
|
1.61 |
| 17-Oct-2022 |
skrll | Fix previous by using roundup (and not howmany).
|
1.60 |
| 15-Oct-2022 |
riastradh | virtio(4): Use howmany from sys/param.h instead of open-coding it.
howmany will divide by VIRTIO_PAGE_SIZE instead of doing & ~(VIRTIO_PAGE_SIZE - 1), but it's a constant 4096 so this should make no difference in the compiled output except possibly at -O0.
No functional change intended.
|
1.59 |
| 15-Oct-2022 |
riastradh | virtio(4): Sprinkle KNF.
No functional change intended.
|
1.58 |
| 14-Aug-2022 |
riastradh | virtio(4): Print numeric device type, even if unrecognized.
|
1.57 |
| 12-Aug-2022 |
riastradh | virtio(4): Membar and bus_dmamap_sync audit.
- Don't use membar_* for DMA.
- Sync only the header and payload of the rings separately as needed. If we bounce, this avoids large memcpy when we only care about the header.
- Sync uring with PREREAD before triggering anything that will return data in it.
=> Move uring PREREAD in virtio_enqueue_commit to _before_ updating vq->vq_avail->idx, which is the pointat which the DMA read is triggered in the `device' (host).
=> Omit needless membar_consumer in virtio_enqueue_commit -- may not work with DMA memory, and even if it does, redundant with bus_dmamap_sync uring PREREAD here.
=> XXX Does the device/host ever return unsolicited entries in the queue, or only solicited ones? If only solicited ones, the PREREAD in virtio_init_vq is redundant.
- Sync uring with POSTREAD before we read from it. This way the DMA read into our buffer has finished before we read from the buffer.
=> Add missing uring POSTREAD in virtio_vq_is_enqueued, between read of vq->vq_used_idx and return to caller, so that the caller can safely use virtio_dequeue.
=> Add missing uring POSTREADs in virtio_start_vq_intr: . between entry from caller and the read of vq->vq_used_idx . between the read of vq->vq_used_idx and return to caller, so that the caller can safely use virtio_dequeue, just like virtio_vq_is_enqueued
=> Move uring POSTREADs in virtio_enqueue_commit to _before_ reading vq->vq_used->flags or *vq->vq_avail_event, not after.
- After we write to aring, sync it with PREWRITE. This way we finish writing to our buffer before the DMA write from it.
=> Omit needless PREWRITE in virtio_init_vq -- we do the appropriate PREWRITE in virtio_enqueue_commit now.
=> Convert membar_producer to bus_dmamap_sync PREWRITE in virtio_enqueue_commit.
=> Omit incorrect aring POSTWRITE in virtio_enqueue_commit -- no need because the DMA write may not have completed yet at this point, and we already do a POSTWRITE in virtio_vq_is_enqueued.
=> Omit needless membar_producer in virtio_postpone_intr -- may not work with DMA memory, and even if it does, redundant with bus_dmamap_sync PREWRITE here.
- After xfers to aring have completed, sync it with POSTWRITE.
=> Add missing aring POSTWRITE in virtio_free_vq, in case there are paths from virtio_enqueue_commit to here that don't go through virtio_is_enqueued. (If there are no such paths, then maybe we should KASSERT(vq->vq_queued == 0) in virtio_free_vq.)
|
1.56 |
| 09-Aug-2022 |
riastradh | virtio(4): Move comment for virtio_vq_intr.
No functional change intended.
|
1.55 |
| 18-Jun-2022 |
andvar | fix typos in word "functions" in comments, mainly s/fuctions/functions/.
|
1.54 |
| 24-Apr-2022 |
uwe | virtio: cosmetics - use (*pfn)(...) syntax.
Some people prefer to call function pointers without an explicit dereference (that is purely cosmetic in this position), especially to create faux c++ s->pfn(...) with function pointers in struct members. Some prefer explicit dereference (that requires parens around it).
(pfn)(...) without dereference but with parens looks odd to both, so make it conform to one of the established alternatives.
Same object code is generated.
|
1.53 |
| 28-Oct-2021 |
yamaguchi | virtio: stop reinit for safety when a device resetting is failed
|
1.52 |
| 21-Oct-2021 |
yamaguchi | virtio: fix missing release of interrupt resources
|
1.51 |
| 21-Oct-2021 |
yamaguchi | virtio: reconfigure MSI-X vector on re-initialization
This may fix a problem that some interrupts, for example link-state change of vioif(4) are not notified.
|
1.50 |
| 21-Oct-2021 |
yamaguchi | divide setup routine of virtio interrupts into establishment and device configuration
|
1.49 |
| 07-Feb-2021 |
skrll | In virtio_alloc_vq change BUS_DMA_NOWAIT to BUS_DMA_WAITOK. It's always called from attach routines.
|
1.48 |
| 07-Feb-2021 |
skrll | Trailing whitespace
|
1.47 |
| 05-Feb-2021 |
reinoud | Better reading of 4.1.3.1, it seems that using 32 bit reads/writes is mandatory for non-legacy devices.
|
1.46 |
| 05-Feb-2021 |
reinoud | Second round of cleaning up endian code. No more tailored code to maintain.
|
1.45 |
| 28-Jan-2021 |
reinoud | Rewrite and streamline virtio device config read/write and explicitly cater for the Aarch64-eb bus problem with Qemu. This removes lots of bus_space `magic' and cleans up the code.
|
1.44 |
| 20-Jan-2021 |
reinoud | Remove the virtio child driver finalisation check KASSERT that, while it should never trigger, a possible bug in a child driver shouldn't have to panic the kernel. Instead report the internal error.
|
1.43 |
| 20-Jan-2021 |
reinoud | Add VirtIO PCI v1.0 attachments and fix the drivers affected.
The vioif, ld, scsi, viornd and viomb devices were adjusted when needed and tested both in legacy 0.9 and v1.0 attachments trough PCI on amd64, sparc64, aarch64 and aarch64-eb. ACPI/FDT attachments also tested on aarch64/aarch64-eb.
Known issues
* viomb on aarch64 works only with ACPI/FDT attachment but not with PCI attachment. PCI and ACPI/FDT attachment works on aarch64-eb.
* virtio on sparc64 attaches but is it not functioning though not a regression.
|
1.42 |
| 17-Sep-2020 |
jakllsch | branches: 1.42.2; Fix word-o of function name in comment
|
1.41 |
| 25-May-2020 |
yamaguchi | Set handlers implemented in child device of virtio(4) to virtqueue instead of the commonized function
|
1.40 |
| 25-May-2020 |
yamaguchi | Register an interrupt handler for virtqueue to that for pci to reduce function call
|
1.39 |
| 25-May-2020 |
yamaguchi | Remove VIRTIO_F_PCI_INTR_SOFTINT support for multiqueue
The functionality is no longer used by obsolating VIOIF_SOFTINT_INTR.
|
1.38 |
| 01-Oct-2019 |
chs | in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP and remove code to handle failures that can no longer happen.
|
1.37 |
| 14-Jan-2019 |
yamaguchi | Add multiqueue support, virtio(4)
|
1.36 |
| 30-Sep-2018 |
jmcneill | Suppress "not configured" message when no device is present
|
1.35 |
| 15-Jun-2018 |
jakllsch | branches: 1.35.2; Add cfprint_t virtiobusprint() and use it for virtio_mmio.
|
1.34 |
| 15-Jun-2018 |
jakllsch | Fix queue address setup bug introduced in 1.31.
This use-before-initialization problem resulted in non-zero queues never being initialized with their virtqueue pointer, and queue zero's pointer to be clobbered with the virtqueue pointer for the higest-indexed ring.
|
1.33 |
| 06-Jun-2018 |
jakllsch | remove now-irrelevant <dev/pci> includes
|
1.32 |
| 06-Jun-2018 |
jakllsch | fix up virtio module for current structure; add virtio_pci module
|
1.31 |
| 02-Jun-2018 |
jakllsch | Begin to detangle virtio from its PCI attachment
|
1.30 |
| 14-Feb-2018 |
uwe | branches: 1.30.2; Cosmetic - consistently use #define<SPACE>
|
1.29 |
| 02-Aug-2017 |
cherry | Reorg the virtio(4) config(9) code to be explicitly pci specific.
We'll later use this for a non-pci virtio(4) usecase.
ok martin
|
1.28 |
| 01-Jun-2017 |
chs | branches: 1.28.2; remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP kmem_zalloc() with KM_SLEEP percpu_alloc() pserialize_create() psref_class_create()
all of these paths include an assertion that the allocation has not failed, so callers should not assert that again.
|
1.27 |
| 28-Mar-2017 |
ozaki-r | Handle config change interrupts to inhibit sending packets while link down
PR kern/52103 by s-yamaguchi@IIJ
|
1.26 |
| 26-Mar-2017 |
jdolecek | fix pasto for nbo_bus_space_write_4() - value needs to be uint32_t
|
1.25 |
| 26-Mar-2017 |
martin | Duh, remove accidently left over debug printfs
|
1.24 |
| 26-Mar-2017 |
martin | Backout previous, no need for these accessor in MD code
|
1.23 |
| 26-Mar-2017 |
martin | Provide an accessor for the pci attach args of a virtio device (if available - future non-pci attachments may return NULL). Sparc64 MD code needs this to match the OF node of the virtio device for boot device recognition.
|
1.22 |
| 25-Mar-2017 |
jdolecek | reorganize the attachment process for virtio child devices, so that more common code is shared among the drivers, and it's possible for the drivers to be correctly dynamically loaded; forbid direct access to struct virtio_softc from the child driver code
|
1.21 |
| 25-Mar-2017 |
jdolecek | use ipl level specified by child when attaching interrupts, instead of always using IPL_NET
|
1.20 |
| 25-Mar-2017 |
martin | PR kern/52107: for now (while we still use the legacy virtio spec) at least hack around the endianess issues with that.
|
1.19 |
| 29-Nov-2016 |
uwe | branches: 1.19.2; Fix the "typical usage" example for enqueuing a request - if bus_dmamap_load(9) fails, we shouldn't call bus_dmamap_unload(9).
|
1.18 |
| 27-Sep-2016 |
pgoyette | Modularize the ld driver and all of its attachments. Ensure that all parents are capable of rescan (or otherwise provide a means of attaching children post-initialization).
|
1.17 |
| 14-Aug-2016 |
tron | Prevent a panic during system shutdown when vioif(4) is used
|
1.16 |
| 11-Jul-2016 |
knakahara | branches: 1.16.2; pci_intr_type() is required pci_chipset_tag_t argument by other than x86.
pointed out by nonaka@n.o.
|
1.15 |
| 07-Jul-2016 |
msaitoh | KNF. Remove extra spaces. No functional change.
|
1.14 |
| 10-Jan-2016 |
christos | PR/50636: Ryo ONODERA: Fix incorrect kmem_free()
|
1.13 |
| 30-Oct-2015 |
christos | more device names
|
1.12 |
| 27-Oct-2015 |
christos | use dma64 if available so we don't have do bounce around too much.
|
1.11 |
| 26-Oct-2015 |
ozaki-r | Support MSI-X in virtio
Currently only vioif(4) uses the feature.
knakahara@ helped to migrate to pci_intr_alloc(9). Thanks!
|
1.10 |
| 15-Oct-2015 |
ozaki-r | Name the interrupt handler for intrctl
|
1.9 |
| 05-May-2015 |
ozaki-r | Remove a garbage blank line
|
1.8 |
| 19-Dec-2014 |
ozaki-r | Implement softint-based interrupt handling in if_vioif
Softint-based interrupt handling is considered as a future direction of the (network) device driver architecture in NetBSD. pq3etsec of ppc is already implemented based on the architecture (unlike pq3etsec, this change doesn't include softint-based if_start). In this architecture, a hardware interrupt handler just schedules a softint and the softint performs actual interrupt processing. It reduces processing in hardware interrupt context and allows Layer 2 network stack (e.g., bridge, vlan and even bpf) run in softint context, which makes it easy to implement fine-grain locking in the layer.
This is an experimental implementation of the architecture in if_viof.
virtio introduces a new flag VIRTIO_F_PCI_INTR_SOFTINT. If a driver of virtio sets it to sc_flags of virtio_softc, virtio calls softint_schedule in virtio_intr instead of directly calling the interrupt handler of the driver.
When VIOIF_SOFTINT_INTR is on, vioif doesn't use the existing softint (vioif_rx_softint) that is called from vioif_rx_vq_done. Because vioif_rx_softint already runs in softint context and another softint isn't needed. This change actually improves performance in some cases.
The feature is disabled by default and enabled when SOFTINT_INTR is set somewhere (normally in a kernel configuration).
|
1.7 |
| 06-Oct-2014 |
mlelstv | branches: 1.7.2; use correct macro to handle subsys ids. Functional there is no change, as both macros select the same bits.
|
1.6 |
| 22-Jul-2014 |
ozaki-r | branches: 1.6.2; 1.6.6; Introduce VIRTIO_F_PCI_INTR_MPSAFE for virtio
It is set by a child driver, e.g., if_vioif. If set, virtio sets PCI_INTR_MPSAFE for pci_intr_establish.
|
1.5 |
| 29-Mar-2014 |
christos | branches: 1.5.2; make pci_intr_string and eisa_intr_string take a buffer and a length instead of relying in local static storage.
|
1.4 |
| 10-Aug-2013 |
tsutsui | Make sure to check if the driver has a valid intr handler in virtio_detach().
Fixes a panic during shutdown on KVM under ubuntu 13.04 with virtio, as reported in PR kern/48105 by Richard Hansen.
Should be pulled up to netbsd-6 branches.
|
1.3 |
| 02-Nov-2011 |
njoly | branches: 1.3.6; 1.3.8; 1.3.12; 1.3.14; 1.3.16; 1.3.22; Small typo in symbolic name.
|
1.2 |
| 02-Nov-2011 |
jakllsch | branches: 1.2.2; Use symbolic PCI_PRODUCTs.
|
1.1 |
| 30-Oct-2011 |
hannken | Import of the virtio driver written by MINOURA Makoto <minoura@netbsd.org> with minor changes to make it compile an run on -current. This driver speeds up disk and network access in virtual environments like KVM.
Enabled on i386 and amd64. Tested with a CentOS 5.7 x86_64 host.
See http://ozlabs.org/~rusty/virtio-spec/virtio.pdf for the specification.
|
1.2.2.2 |
| 22-May-2014 |
yamt | sync with head.
for a reference, the tree before this commit was tagged as yamt-pagecache-tag8.
this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments")
|
1.2.2.1 |
| 10-Nov-2011 |
yamt | sync with head
|
1.3.22.1 |
| 07-Sep-2013 |
bouyer | Pull up following revision(s) (requested by tsutsui in ticket #931): sys/dev/pci/virtio.c: revision 1.4 Make sure to check if the driver has a valid intr handler in virtio_detach(). Fixes a panic during shutdown on KVM under ubuntu 13.04 with virtio, as reported in PR kern/48105 by Richard Hansen. Should be pulled up to netbsd-6 branches.
|
1.3.16.2 |
| 18-May-2014 |
rmind | sync with head
|
1.3.16.1 |
| 28-Aug-2013 |
rmind | sync with head
|
1.3.14.1 |
| 07-Sep-2013 |
bouyer | Pull up following revision(s) (requested by tsutsui in ticket #931): sys/dev/pci/virtio.c: revision 1.4 Make sure to check if the driver has a valid intr handler in virtio_detach(). Fixes a panic during shutdown on KVM under ubuntu 13.04 with virtio, as reported in PR kern/48105 by Richard Hansen. Should be pulled up to netbsd-6 branches.
|
1.3.12.2 |
| 03-Dec-2017 |
jdolecek | update from HEAD
|
1.3.12.1 |
| 20-Aug-2014 |
tls | Rebase to HEAD as of a few days ago.
|
1.3.8.1 |
| 07-Sep-2013 |
bouyer | Pull up following revision(s) (requested by tsutsui in ticket #931): sys/dev/pci/virtio.c: revision 1.4 Make sure to check if the driver has a valid intr handler in virtio_detach(). Fixes a panic during shutdown on KVM under ubuntu 13.04 with virtio, as reported in PR kern/48105 by Richard Hansen. Should be pulled up to netbsd-6 branches.
|
1.3.6.2 |
| 25-Jan-2012 |
riz | Pull up following revision(s) (requested by hannken in ticket #1715): - Be robust against an invalid timer period value. sys/dev/ic/hpetreg.h Rev. 1.4 sys/dev/ic/hpet.c Rev. 1.8
- Fix wrong definition of LAPIC_LEVEL_ASSERT / _MASK sys/arch/x86/include/i82489reg.h Rev. 1.11
- Add virtio driver - speed up disk and network access in virtual environments sys/arch/i386/conf/GENERIC Rev. 1.1055 sys/arch/i386/conf/ALL Rev. 1.325 sys/arch/amd64/conf/GENERIC Rev. 1.338 sys/dev/pci/files.pci Rev. 1.350 sys/dev/pci/if_vioif.c Rev. 0-1.2 sys/dev/pci/ld_virtio.c Rev. 0-1.4 sys/dev/pci/viomb.c Rev. 0-1.1 sys/dev/pci/virtio.c Rev. 0-1.3 sys/dev/pci/virtioreg.h Rev. 0-1.1 sys/dev/pci/virtiovar.h Rev. 0-1.1 distrib/sets/lists/man/mi Rev. 1.1352 and 1.1358 share/man/man4/Makefile Rev. 1.573 and 1.575 share/man/man4/ld.4 Rev. 1.19 share/man/man4/virtio.4 Rev. 0-1.4 share/man/man4/vioif.4 Rev. 0-1.2 share/man/man4/viomb.4 Rev. 0-1.2
Allow NetBSD to run unmodified under Linux/kvm.
|
1.3.6.1 |
| 02-Nov-2011 |
riz | file virtio.c was added on branch netbsd-5 on 2012-01-25 21:18:15 +0000
|
1.5.2.1 |
| 10-Aug-2014 |
tls | Rebase.
|
1.6.6.1 |
| 18-Jan-2017 |
skrll | Sync with netbsd-5
|
1.6.2.1 |
| 23-Dec-2016 |
snj | Pull up following revision(s) (requested by bsiegert in ticket #1337): sys/dev/pci/if_vioif.c: revision 1.21 sys/dev/pci/virtio.c: revision 1.14 PR/50636: Ryo ONODERA: Fix incorrect kmem_free() -- PR/50636: Ryo ONODERA: Reduce memory use
|
1.7.2.8 |
| 28-Aug-2017 |
skrll | Sync with HEAD
|
1.7.2.7 |
| 05-Dec-2016 |
skrll | Sync with HEAD
|
1.7.2.6 |
| 05-Oct-2016 |
skrll | Sync with HEAD
|
1.7.2.5 |
| 09-Jul-2016 |
skrll | Sync with HEAD
|
1.7.2.4 |
| 19-Mar-2016 |
skrll | Sync with HEAD
|
1.7.2.3 |
| 27-Dec-2015 |
skrll | Sync with HEAD (as of 26th Dec)
|
1.7.2.2 |
| 06-Jun-2015 |
skrll | Sync with HEAD
|
1.7.2.1 |
| 06-Apr-2015 |
skrll | Sync with HEAD
|
1.16.2.3 |
| 26-Apr-2017 |
pgoyette | Sync with HEAD
|
1.16.2.2 |
| 07-Jan-2017 |
pgoyette | Sync with HEAD. (Note that most of these changes are simply $NetBSD$ tag issues.)
|
1.16.2.1 |
| 04-Nov-2016 |
pgoyette | Sync with HEAD
|
1.19.2.1 |
| 21-Apr-2017 |
bouyer | Sync with HEAD
|
1.28.2.3 |
| 23-Sep-2020 |
martin | Pull up following revision(s) (requested by jakllsch in ticket #1609):
sys/dev/pci/virtio_pci.c: revision 1.13 (patch) (applied to sys/dev/pci/virtio.c)
Ensure MSI-X is disabled if allocation of MSI-X interrupts fail.
The virtio device config space moves out from under us when MSI-X remains enabled, and/or INTx interrupts are masked if we don't ensure this.
This un-breaks virtio devices that run out of MSI-X interrupts. Particularly a problem on uniproc x86, where there are only 8 or 9 vectors available, allowing for only about 4 virtio devices to use MSI-X.
|
1.28.2.2 |
| 20-Sep-2020 |
martin | Pull up following revision(s) (requested by jakllsch in ticket #1608):
sys/dev/pci/virtio_pci.c: revision 1.12
Ensure interrupt handles buffer is zeroed on allocation Prevents crashes trying to deallocate interrupts at shutdown.
Found by kim and mlelstv, confirmed by me
|
1.28.2.1 |
| 19-Feb-2018 |
snj | Pull up following revision(s) (requested by uwe in ticket #553): sys/dev/pci/virtio_pci.c: 1.2 via patch to sys/dev/pci/virtio.c Explicitly enable PCI_COMMAND_MASTER_ENABLE and PCI_COMMAND_IO_ENABLE. Recent versions of VirtualBox do not enable bus-mastering by default - this will be fixed, but it doesn't hurt to do it ourselves too.
|
1.30.2.3 |
| 18-Jan-2019 |
pgoyette | Synch with HEAD
|
1.30.2.2 |
| 20-Oct-2018 |
pgoyette | Sync with head
|
1.30.2.1 |
| 25-Jun-2018 |
pgoyette | Sync with HEAD
|
1.35.2.2 |
| 13-Apr-2020 |
martin | Mostly merge changes from HEAD upto 20200411
|
1.35.2.1 |
| 10-Jun-2019 |
christos | Sync with HEAD
|
1.42.2.1 |
| 03-Apr-2021 |
thorpej | Sync with HEAD.
|
1.63.2.6 |
| 02-Oct-2024 |
martin | Pull up following revision(s) (requested by rin in ticket #914):
sys/dev/pci/virtio_pci.c: revision 1.50 sys/dev/pci/virtio_pci.c: revision 1.51 sys/dev/pci/virtio_pci.c: revision 1.52 sys/dev/pci/virtio_pci.c: revision 1.53 sys/dev/pci/virtio_pci.c: revision 1.54 sys/dev/pci/vioscsi.c: revision 1.35 sys/dev/pci/ld_virtio.c: revision 1.33 sys/dev/pci/ld_virtio.c: revision 1.34 sys/dev/virtio/viocon.c: revision 1.9 sys/dev/pci/ld_virtio.c: revision 1.35 sys/dev/pci/virtio.c: revision 1.80 sys/dev/pci/virtio.c: revision 1.81 sys/dev/pci/virtio.c: revision 1.82 sys/dev/pci/virtio_pci.c: revision 1.45 sys/dev/pci/virtio_pci.c: revision 1.46 sys/dev/pci/virtio_pci.c: revision 1.47 sys/dev/pci/virtio_pci.c: revision 1.48 sys/dev/pci/virtio_pci.c: revision 1.49 sys/dev/pci/virtio.c: revision 1.79
A single SCSI request may require multiple slots in the virtio queue but the queue isn't sized for the theoretical maximum. So just use XS_BUSY to pace the scsipi layer.
viocon(4): Show error in assertion failure.
virtio_read_device_config_le_[24]: Fix for {aarch64,arm}eb Stop byte-swapping for big-endian aarch64 and arm to fix corrupted read for, e.g., sc_taglen for vio9p(4).
As described as comments in virtio_pci.c, big-endian aarch64 and armv7 (armeb) are somewhat special. At the moment, all supported virtual/real machines are configured as little-endian, and only CPU cores are switched to big-endian mode during early boot stage.
Most peripheral buses for armeb are LSB as a result, and their default bus_space(9) functions swap byte-order. Therefore, PIOed data from memory-mapped devices, as well as pci(4) ones, are actually LSB, but observed as MSB for armeb.
Therefore, we should not swap byte-order further in virtio_read_device_config_le_[24] on armeb.
See virtio_pci.c and sys/dev/fdt/virtio_mmio_fdt.c also. fix spelling mistakes, mainly in comments and log messages.
Split KASSERT(A && B) into KASSERT(A); KASSERT(B).
Fix typo in error message.
Modify a confused expression in ld_virtio_attach().
VIRTIO_BLK_MIN_SEGMENTS should be the total number of non-data segments, so I rename it to VIRTIO_BLK_CTRL_SEGMENTS. PR kern/57981.
ld@virtio(4): Fix maximum size parameters. - SEG_MAX is the maximum number of segments. - SIZE_MAX is the maximum number of bytes in a single segment. The maximum transfer size is, therefore, SEG_MAX * SIZE_MAX. => Don't add two extra segments in the dmamap vr_payload for the header and status -- we already have a separate dmamap vr_cmdsts for that. => Don't recalculate payload dmamap parameters based on division by NBPG, just use the ones specified by the host. => Allow SIZE_MAX below MAXPHYS as long as SIZE_MAX*SEG_MAX >= MAXPHYS. Even though ldattach clamps ld->sc_maxxfer to MAXPHYS, make sure to clamp it in ld_virtio_attach before ld_virtio_alloc_reqs since it determines the dmamap sizes and bounce buffer allocation and there's no sense in allocating those larger than ld will use anyway. PR kern/58338
virtio_pci.c: Nix trailing whitespace.
virtio@pci: Unmap the BARs we actually mapped on >=1.0 detach. PR kern/58335
virtio@pci: Nix useless sc_mapped_iosize. This appears to have been a mistaken attempt to pass the subregion length through to bus_space_unmap, which doesn't make any sense -- bus_space_subregion does not allocate anything and the resulting handle must not be passed to bus_space_unmap.
Once we pass the size that was actually returned by pci_mapreg_map to bus_space_unmap, which matches the size passed internally by pci_mapreg_map to bus_space_map, sc_mapped_iosize is no longer used and can be flushed. Prompted by PR kern/58335.
virtio@pci: Don't detach on shutdown. The virtio bus does not keep state in memory that needs to flushed to persistent storage. Typically DVF_DETACH_SHUTDOWN is only needed by, e.g., disk drivers to flush disk caches (although really, vfs sync should do that anyway, so maybe we should just nix the option altogether). Prompted by PR kern/58335.
virtio@pci: Zero sc_bars_iosize[i] on unmap. No functional change intended, but this makes the code less brittle. Prompted by PR kern/58335.
virtio_pci.c: Sort includes. No functional change intended.
virtio_pci.c: Omit needless blank lines and commented code. No functional change intended.
virtio_pci.c: Sprinkle KNF. - No parameter names in function prototypes. - Fix indentation. - Break overlong lines. - Blank line between declarations and rest of block. virtio_pci.c: Sprinkle const. No functional change intended.
virtio_pci.c: Use container_of, not cast. virtio(4): Assert child attach finished before we allow queueing. Should help catch mistakes like: PR kern/58555: Kernel panic during boot when using viocon with PCIe
|
1.63.2.5 |
| 03-Jun-2023 |
martin | Pull up following revision(s) (requested by yamaguchi in ticket #186):
sys/dev/pci/virtio_pci.c: revision 1.41 sys/dev/pci/virtio_pci.c: revision 1.42 sys/dev/virtio/virtio_mmio.c: revision 1.10 sys/dev/pci/virtiovar.h: revision 1.29 sys/dev/pci/virtio.c: revision 1.75 sys/dev/pci/virtio.c: revision 1.76 sys/dev/pci/virtio.c: revision 1.77 sys/dev/pci/virtio.c: revision 1.78
virtio@pci: Fix assertion on detach.
If the child never attached in the first place, it's OK for it to not have detached.
XXX This should not be a set of flags; this should be a state enumeration, because some flags make no sense, like FINISHED|FAILED.
XXX This should not be asserted separately in each bus; there should be a single place in virtio.c to assert this, uniformly in all buses.
PR kern/57357
Use enumeration for state of a child driver instead of flags and check its detaching by using sc->sc_child in virtio_softc pointed out by riastradh, thanks. fixes PR/57357
Fix not to allocate unnecessary descriptor fixes PR/57358
virtio(4): change variable name, nfc
virtio(4): change members of struct vring_desc_extra before free a slot
This prevents the following race condition. 1. Thread-A: calls virtio_dequeue_commit() and puts a slot into free descriptor chain in vq_free_slot() 2. Thread-B: calls virtio_enqueue_prep() and get the slot stored by Thread-A 3. Thread-B: calls virtio_enqueue_reserve() and changes desc_base and desc_free_idx for the slot 4. Thread-A: changes the same members updated by Thread-B reported by hannken, thanks.
|
1.63.2.4 |
| 13-May-2023 |
martin | Pull up following revision(s) (requested by yamaguchi in ticket #139):
sys/dev/pci/vioscsi.c: revision 1.31 sys/dev/pci/vio9p.c: revision 1.10 sys/dev/pci/vioscsi.c: revision 1.32 sys/dev/pci/vio9p.c: revision 1.11 sys/dev/pci/vioscsi.c: revision 1.33 sys/dev/pci/ld_virtio.c: revision 1.31 sys/dev/virtio/viocon.c: revision 1.6 sys/dev/pci/vioscsi.c: revision 1.34 sys/dev/pci/ld_virtio.c: revision 1.32 sys/dev/virtio/viocon.c: revision 1.7 sys/dev/virtio/viocon.c: revision 1.8 sys/dev/pci/vioscsi.c: revision 1.36 sys/dev/pci/virtioreg.h: revision 1.12 sys/dev/pci/viornd.c: revision 1.19 sys/dev/pci/virtio.c: revision 1.66 sys/dev/pci/virtio.c: revision 1.67 sys/dev/pci/virtio.c: revision 1.68 sys/dev/pci/if_vioif.c: revision 1.103 sys/dev/pci/virtio.c: revision 1.69 sys/dev/pci/if_vioif.c: revision 1.104 sys/dev/pci/virtio_pci.c: revision 1.40 sys/dev/virtio/virtio_mmio.c: revision 1.8 sys/dev/virtio/virtio_mmio.c: revision 1.9 sys/dev/pci/viomb.c: revision 1.14 sys/dev/pci/viomb.c: revision 1.15 sys/dev/pci/viomb.c: revision 1.17 sys/dev/pci/viornd.c: revision 1.20 sys/dev/pci/viornd.c: revision 1.21 sys/dev/pci/virtiovar.h: revision 1.25 sys/dev/pci/virtiovar.h: revision 1.26 sys/dev/pci/virtiovar.h: revision 1.27 sys/dev/pci/virtiovar.h: revision 1.28 sys/dev/pci/virtio.c: revision 1.70 sys/dev/pci/virtio.c: revision 1.71 sys/dev/pci/virtio.c: revision 1.72 sys/dev/pci/virtio.c: revision 1.73 sys/dev/pci/virtio.c: revision 1.74 sys/dev/pci/virtio_pci.c: revision 1.39
Set virtqueues in virtio_child_attach_finish
The number of virtqueue maybe change in a part of VirtIO devices (e.g. vioif(4)). And it is fixed after negotiation of features. So the configuration is moved into the function.
viocon(4): fix not to allocate unused virtqueue
viocon(4) allocates 4 virtqueues but it only uses 2 (0 and 1) queues.
Added functions to set interrupt handler and index into virtqueue
Added check of pointer for allocated memory before release of resource
Setup virtqueues after registering them to virtio_softc restore fetch of qsize.
Mark as MPSAFE.
virtio(4): Avoid name collision with global intrhand on sparc64.
Pacifies -Werror=shadow. No functional change intended.
Use PRIuBUSSIZE to print bus_size_t variables.
virtio(4): Fix sizing of virtqueue allocation. vq->vq_avail[0].ring is a zero-length array, and thus sizeof is zero; likewise vq->vq_used[0].ring. Use vq->vq_avail[0].ring[0] and vq->vq_used[0].ring[0] to fix this and restore the previous allocation sizing logic. XXX We shouldn't use zero-length arrays here -- they are asking for trouble like this, and C99 has a standard way to express what we're actually trying to get at it, flexible array members. PR kern/57304
virtio(4): Use flexible array members, not zero-length arrays. This enables the compiler to detect sizeof mistakes like PR kern/57304.
Use descriptor chain for free slots instead of vq_entry list Descriptors can be chained by themself. And descriptors added to avail ring or used ring are already chained. But it was not used for unused descriptors and another linked list structure named vq_entry was used.
The chain is also used for unused descriptors to make virtio(4) simpler.
Added flags to store status of attaching a virtio device
This prevents a panic on reboot after a virtio device had called virtio_child_attach_failed().
Fix wrong variable names This fixes build errors in virtio_mmio.c
|
1.63.2.3 |
| 02-Apr-2023 |
martin | Backout attempts to build fix for ticket #128 for this file, needs other changes.
|
1.63.2.2 |
| 01-Apr-2023 |
martin | Additionally pull up the following for ticket #128 to fix the build:
sys/dev/pci/if_vioif.c: revision 1.107 sys/dev/pci/virtio.c: revision 1.71
Use PRIuBUSSIZE to print bus_size_t variables.
|
1.63.2.1 |
| 13-Jan-2023 |
martin | Pull up following revision(s) (requested by jakllsch in ticket #48):
sys/dev/pci/virtio.c: revision 1.64 sys/dev/pci/virtio.c: revision 1.65
Fix dmamap_syncs more; the number of ring elements is vq->vq_num, not sc->sc_nvqs.
Subtly adjust criteria for notification of Virtio devices in VIRTIO_F_RING_EVENT_IDX mode.
This fixes stalls in the vioif(4) transmit path that would happen sooner or later, depending on interface transmit utilization, and were particularly noticable with a NetBSD guest transmitting to its x86 KVM host at multi-gigabit speeds.
|
1.81.2.1 |
| 02-Aug-2025 |
perseant | Sync with HEAD
|