Home | History | Annotate | Download | only in pci
History log of /src/sys/dev/pci/viomb.c
RevisionDateAuthorComments
 1.17  25-Mar-2023  mlelstv Mark as MPSAFE.
 1.16  25-Mar-2023  mlelstv Fix 32bit overflow when calculating balloon size.
Don't make uvm_pglistalloc wait, it will wait forever. Instead rely on
the retries by this driver. This also allows to cancel the request.
Increase inflate speed by factor 10 (same as deflate).
 1.15  23-Mar-2023  yamaguchi Added functions to set interrupt handler and index into virtqueue
 1.14  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.13  13-Apr-2022  uwe branches: 1.13.4;
virtio: use the new syntax for snprintb(3) format strings.

The old syntax is limited to 32 bits only (and has 1-based bit numbers
which is rather incovenient too).
 1.12  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.11  13-Jan-2021  reinoud Fix for virtios viomb memory balloon driver. The inflate_done() and
deflate_done() issued a wrong extent to bus_dmamap_sync() giving rise to
panics on aarch64s mmio backend.
 1.10  10-Dec-2019  ad branches: 1.10.8;
p->phys_addr -> VM_PAGE_TO_PHYS(p)
 1.9  10-Jun-2018  jakllsch branches: 1.9.2;
remove irrelevant pci(9) #includes from virtio child drivers
 1.8  25-Mar-2017  jdolecek branches: 1.8.12;
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.7  27-Sep-2016  pgoyette branches: 1.7.2;
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.6  07-Jul-2016  msaitoh branches: 1.6.2;
KNF. Remove extra spaces. No functional change.
 1.5  27-Oct-2015  christos Print the negotiated feature bits
 1.4  04-May-2015  ozaki-r Add NULL check for TAILQ_FIRST
 1.3  22-Jul-2014  ozaki-r branches: 1.3.4;
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.2  17-Oct-2013  christos branches: 1.2.2;
- remove unused variables
- move debugging code inside debugging sections
 1.1  30-Oct-2011  hannken branches: 1.1.2; 1.1.8; 1.1.14; 1.1.18;
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.1.18.1  18-May-2014  rmind sync with head
 1.1.14.2  03-Dec-2017  jdolecek update from HEAD
 1.1.14.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.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.1.8.1  30-Oct-2011  riz file viomb.c was added on branch netbsd-5 on 2012-01-25 21:18:15 +0000
 1.1.2.1  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-Aug-2014  tls Rebase.
 1.3.4.5  28-Aug-2017  skrll Sync with HEAD
 1.3.4.4  05-Oct-2016  skrll Sync with HEAD
 1.3.4.3  09-Jul-2016  skrll Sync with HEAD
 1.3.4.2  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3.4.1  06-Jun-2015  skrll Sync with HEAD
 1.6.2.2  26-Apr-2017  pgoyette Sync with HEAD
 1.6.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.7.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.8.12.1  25-Jun-2018  pgoyette Sync with HEAD
 1.9.2.1  08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.8.1  03-Apr-2021  thorpej Sync with HEAD.
 1.13.4.1  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

RSS XML Feed