virtio-pci: Use PCI MMIO instead of PIO when available
Currently virtio-pci is specced so that configuration of the device is
done through a PCI IO space (via BAR 0 of the virtual PCI device).
However, use of PCI IO space (aka PIO) is long deprecated, and can be
awkward to use on some systems (for example IBM pSeries machines
typically have many PCI domains, and not all firmware/hypervisor
versions necessarily support PCI PIO access on all domains).
Therefore, it would be preferable for the virtio virtual PCI device to
advertise a PCI memory space (aka MMIO) BAR and have configuration
done through this interface instead. This can be done backwards
compatibly by advertising the MMIO BAR in addition to the existing PIO
BAR so that the guest driver can choose whichever interface.
In anticipation of adding such an MMIO BAR to virtio host-side
implementations (e.g. qemu), this patch updates the Linux virtio-pci
driver to attempt to use BAR 2 (which will be MMIO) in preference to
the existing PIO BAR 0.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Krishna Kumar [Wed, 5 Oct 2011 05:38:59 +0000 (11:08 +0530)]
virtio: Dont add "config" to list for !per_vq_vector
For the MSI but non-per_vq_vector case, the config/change vq
also gets added to the list of vqs that need to process the
MSI interrupt. This is not needed as config has it's own
handler (vp_config_changed). In any case, vring_interrupt()
finds nothing needs to be done on this vq.
I tested this patch by testing the "Fallback:" and "Finally
fall back" cases in vp_find_vqs(). Please review.
Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
virtio: console: wait for first console port for early console output
On s390 I have seen some random
"Warning: unable to open an initial console"
boot failure. Turns out that tty_open fails, because the
hvc_alloc was not yet done. In former times this could not happen,
since the probe function automatically called hvc_alloc. With newer
versions (multiport) some host<->guest interaction is required
before hvc_alloc is called. This might be too late, especially if
an initramfs is involved. Lets use a completion if we have
multiport and an early console.
[Amit:
* Use NULL instead of 0 for pointer comparison
* Rename 'port_added' to 'early_console_added'
* Re-format, re-word commit message
* Rebase patch on top of current queue]
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Acked-by: Chrstian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Amit Shah [Wed, 14 Sep 2011 07:36:46 +0000 (13:06 +0530)]
virtio: console: add port stats for bytes received, sent and discarded
This commit adds port-specific stats for the number of bytes received,
sent and discarded. They're exposed via the debugfs interface. This
data can be used to check for data loss bugs (or disprove such claims).
It can also be used for accounting, if there's such a need.
The stats remain valid throughout the lifetime of the port. Unplugging
a port will reset the stats. The numbers are not reset across port
opens/closes.
Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Amit Shah [Wed, 14 Sep 2011 07:36:45 +0000 (13:06 +0530)]
virtio: console: make discard_port_data() use get_inbuf()
discard_port_data() used virtqueue_get_buf() directly instead of using
get_inbuf(). Fix this, so that we get accounting for all received
bytes. This also simplifies the code a lot.
Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Amit Shah [Wed, 14 Sep 2011 07:36:43 +0000 (13:06 +0530)]
virtio: console: make get_inbuf() return port->inbuf if present
Instead of pulling in a buffer from the vq each time it's called,
get_inbuf() now checks if the current active buffer, in port->inbuf is
valid. If it is, just returns a pointer to it. This ends up
simplifying a lot of code calling get_inbuf() since the check for
port->inbuf being valid was done by all the callers.
Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Amit Shah [Wed, 14 Sep 2011 07:36:40 +0000 (13:06 +0530)]
virtio: console: Ignore port name update request if name already set
We don't allow port name changes dynamically for a port. So any
requests by the host to change the name are ignored.
Before this patch, if the hypervisor sent a port name while we had one
set already, we would leak memory equivalent to the size of the old
name.
This scenario wasn't expected so far, but with the suspend-resume
support, we'll send the VIRTIO_CONSOLE_PORT_READY message after restore,
which can get us into this situation.
Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Sasha Levin [Sun, 14 Aug 2011 14:52:33 +0000 (17:52 +0300)]
virtio-net: Use virtio_config_val() for retrieving config
This patch modifies virtio-net to use virtio_config_val() instead
of a 'if(virtio_has_feature()) vdev->config->get()' construct to retrieve
optional values from the config space.
Cc: Amit Shah <amit.shah@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: virtualization@lists.linux-foundation.org Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Sasha Levin [Sun, 14 Aug 2011 14:52:32 +0000 (17:52 +0300)]
virtio_config: Add virtio_config_val_len()
This patch adds virtio_config_val_len() which allows retrieving variable
length data from the virtio config space only if a specific feature is on.
Cc: Amit Shah <amit.shah@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: virtualization@lists.linux-foundation.org Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Sasha Levin [Sun, 14 Aug 2011 14:52:31 +0000 (17:52 +0300)]
virtio-console: Use virtio_config_val() for retrieving config
This patch modifies virtio-console to use virtio_config_val() instead
of a 'if(virtio_has_feature()) vdev->config->get()' construct to retrieve
optional values from the config space.
Cc: Amit Shah <amit.shah@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: virtualization@lists.linux-foundation.org Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Michal Hocko [Tue, 27 Sep 2011 06:56:03 +0000 (08:56 +0200)]
lguest: move process freezing before pending signals check
run_guest tries to freeze the current process after it has handled
pending interrupts and before it calls lguest_arch_run_guest.
This doesn't work nicely if the task has been killed while being frozen
and when we want to handle that signal as soon as possible.
Let's move try_to_freeze before we check for pending signal so that we
can get out of the loop as soon as possible.
Signed-off-by: Michal Hocko <mhocko@suse.cz> Acked-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>