1
0
Fork 0
Commit Graph

11 Commits (040a3eadf00b4993fb215fba1d788c91712401ba)

Author SHA1 Message Date
Andy Lutomirski 7a5589b240 virtio_pci: Use the DMA API if enabled
This switches to vring_create_virtqueue, simplifying the driver and
adding DMA API support.

This fixes virtio-pci on platforms and busses that have IOMMUs.  This
will break the experimental QEMU Q35 IOMMU support until QEMU is
fixed.  In exchange, it fixes physical virtio hardware as well as
virtio-pci running under Xen.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2016-03-02 17:01:58 +02:00
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 ff31d2e285 virtio_pci: move probe/remove code to common
Most of initialization is device-independent.
Let's move it to common.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-01-21 16:28:51 +10:30
Sasha Levin 2bd56afd44 virtio_pci: drop useless del_vqs call
Device VQs were getting freed twice: once in every device's removal
functions, and then again in virtio_pci_legacy_remove().  The ones in
devices are called first, so drop the useless second call.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-01-21 16:28:50 +10:30
Michael S. Tsirkin a1eb03f546 virtio_pci: document why we defer kfree
The reason we defer kfree until release function is because it's a
general rule for kobjects: kfree of the reference counter itself is only
legal in the release function.

Previous patch didn't make this clear, document this in code.

Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2015-01-06 16:35:36 +02:00
Sasha Levin 63bd62a08c virtio_pci: defer kfree until release callback
A struct device which has just been unregistered can live on past the
point at which a driver decides to drop it's initial reference to the
kobject gained on allocation.

This implies that when releasing a virtio device, we can't free a struct
virtio_device until the underlying struct device has been released,
which might not happen immediately on device_unregister().

Unfortunately, this is exactly what virtio pci does:
it has an empty release callback, and frees memory immediately
after unregistering the device.

This causes an easy to reproduce crash if CONFIG_DEBUG_KOBJECT_RELEASE
it enabled.

To fix, free the memory only once we know the device is gone in the release
callback.

Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2015-01-06 16:35:36 +02:00
Michael S. Tsirkin 945399a8c7 virtio_pci: device-specific release callback
It turns out we need to add device-specific code
in release callback. Move it to virtio_pci_legacy.c.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2015-01-06 16:35:36 +02:00
Michael S. Tsirkin 9a4253db0c virtio_pci: move probe to common file
It turns out this make everything easier.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-12-14 15:10:30 +02:00
Michael S. Tsirkin 5f4c976089 virtio_pci: rename virtio_pci -> virtio_pci_common
kbuild does not seem to like it when we name source
files same as the module.
Let's rename virtio_pci -> virtio_pci_common,
and get rid of #include-ing c files.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-12-09 21:42:05 +02:00
Michael S. Tsirkin a90fdce9dc virtio_pci: update file descriptions and copyright
There's been a lot of changes since 2007.
List main authors, add Red Hat copyright.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-12-09 21:42:05 +02:00
Michael S. Tsirkin 38eb4a29a7 virtio_pci: split out legacy device support
Move everything dealing with legacy devices out to virtio_pci_legacy.c.
Expose common code APIs in virtio_pci.h

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-12-09 21:42:04 +02:00