Commit Graph

10 Commits

Author SHA1 Message Date
Gerd Hoffmann 59a5b0f7bf virtio-pci: alloc only resources actually used.
Move resource allocation from common code to legacy and modern code.
Only request resources actually used, i.e. bar0 in legacy mode and
the bar(s) specified by capabilities in modern mode.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2015-06-24 08:15:09 +02:00
Michael S. Tsirkin f71d8286c1 virtio_pci: support non-legacy balloon devices
virtio_device_is_legacy_only is always false now,
drop the test from virtio pci.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-04-15 12:41:13 +09:30
Michael S. Tsirkin a8557d32fe virtio_pci_modern: switch to type-safe io accessors
As Rusty noted, we were accessing queue_enable with an incorrect width.
Switch to type-safe accessors so we don't make this mistake again in the
future.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-04-01 14:43:34 +10:30
Michael S. Tsirkin c5d4c2c9ce virtio_pci_modern: type-safe io accessors
The spec is very clear on this:

4.1.3.1 Driver Requirements: PCI Device Layout

The driver MUST access each field using the “natural” access method,
i.e. 32-bit accesses for 32-bit fields, 16-bit accesses for 16-bit
fields and 8-bit accesses for 8-bit fields.

Add type-safe wrappers to prevent access with incorrect width.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-04-01 14:37:15 +10:30
Rusty Russell 7abb568dbb virtio_pci: use 16-bit accessor for queue_enable.
Since PCI is little endian, 8-bit access might work, but the spec section
is very clear on this:

  4.1.3.1 Driver Requirements: PCI Device Layout

  The driver MUST access each field using the “natural” access method,
  i.e. 32-bit accesses for 32-bit fields, 16-bit accesses for 16-bit
  fields and 8-bit accesses for 8-bit fields.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
2015-02-11 15:03:16 +10:30
Michael S. Tsirkin 76545f066d virtio_pci_modern: drop an unused function
release function in modern driver is unused:
it's a left-over from when each driver had
to have its own release.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2015-01-21 16:29:01 +10:30
Michael S. Tsirkin d3f5f06560 virtio_pci_modern: support devices with no config
Virtio 1.0 spec lists device config as optional.
Set get/set callbacks to NULL. Drivers can check that
and fail gracefully.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-01-21 16:28:55 +10:30
Michael S. Tsirkin 3909213cfd virtio_pci_modern: reduce number of mappings
We don't know the # of VQs that drivers are going to use so it's hard to
predict how much memory we'll need to map. However, the relevant
capability does give us an upper limit.
If that's below a page, we can reduce the number of required
mappings by mapping it all once ahead of the time.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-01-21 16:28:55 +10:30
Rusty Russell 89461c4a12 virtio_pci: macros for PCI layout offsets
QEMU wants it, so why not?  Trust, but verify.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2015-01-21 16:28:54 +10:30
Michael S. Tsirkin 1fcf0512c9 virtio_pci: modern driver
Lightly tested against qemu.

One thing *not* implemented here is separate mappings
for descriptor/avail/used rings. That's nice to have,
will be done later after we have core support.

This also exposes the PCI layout to userspace, and
adds macros for PCI layout offsets:

QEMU wants it, so why not?  Trust, but verify.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2015-01-21 16:28:53 +10:30