diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-18 23:50:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-18 23:50:30 -0500 |
commit | 64ec45bff6b3dade2643ed4c0f688a15ecf46ea2 (patch) | |
tree | 29816f500d80a64c84455778918d94ff3ddf02e4 /drivers/virtio | |
parent | c0f486fde3f353232c1cc2fd4d62783ac782a467 (diff) | |
parent | 5ff16110c637726111662c1df41afd9df7ef36bd (diff) |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael S Tsirkin:
"virtio 1.0 related fixes
Most importantly, this fixes using virtio_pci as a module.
Further, the big virtio 1.0 conversion missed a couple of places.
This fixes them up.
This isn't 100% sparse-clean yet because on many architectures
get_user triggers sparse warnings when used with __bitwise tag (when
same tag is on both pointer and value read).
I posted a patchset to fix it up by adding __force on all arches that
don't already have it (many do), when that's merged these warnings
will go away"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
virtio_pci: restore module attributes
mic/host: fix up virtio 1.0 APIs
vringh: update for virtio 1.0 APIs
vringh: 64 bit features
tools/virtio: add virtio 1.0 in vringh_test
tools/virtio: add virtio 1.0 in virtio_test
tools/virtio: enable -Werror
tools/virtio: 64 bit features
tools/virtio: fix vringh test
tools/virtio: more stubs
virtio: core support for config generation
virtio_pci: add VIRTIO_PCI_NO_LEGACY
virtio_pci: move probe to common file
virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACY
virtio_config: fix virtio_cread_bytes
virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio.c | 37 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci_common.c | 39 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci_common.h | 7 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci_legacy.c | 24 |
4 files changed, 66 insertions, 41 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index f22665868781..b9f70dfc4751 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -162,6 +162,27 @@ static void virtio_config_enable(struct virtio_device *dev) | |||
162 | spin_unlock_irq(&dev->config_lock); | 162 | spin_unlock_irq(&dev->config_lock); |
163 | } | 163 | } |
164 | 164 | ||
165 | static int virtio_finalize_features(struct virtio_device *dev) | ||
166 | { | ||
167 | int ret = dev->config->finalize_features(dev); | ||
168 | unsigned status; | ||
169 | |||
170 | if (ret) | ||
171 | return ret; | ||
172 | |||
173 | if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1)) | ||
174 | return 0; | ||
175 | |||
176 | add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); | ||
177 | status = dev->config->get_status(dev); | ||
178 | if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) { | ||
179 | dev_err(&dev->dev, "virtio: device refuses features: %x\n", | ||
180 | status); | ||
181 | return -ENODEV; | ||
182 | } | ||
183 | return 0; | ||
184 | } | ||
185 | |||
165 | static int virtio_dev_probe(struct device *_d) | 186 | static int virtio_dev_probe(struct device *_d) |
166 | { | 187 | { |
167 | int err, i; | 188 | int err, i; |
@@ -170,7 +191,6 @@ static int virtio_dev_probe(struct device *_d) | |||
170 | u64 device_features; | 191 | u64 device_features; |
171 | u64 driver_features; | 192 | u64 driver_features; |
172 | u64 driver_features_legacy; | 193 | u64 driver_features_legacy; |
173 | unsigned status; | ||
174 | 194 | ||
175 | /* We have a driver! */ | 195 | /* We have a driver! */ |
176 | add_status(dev, VIRTIO_CONFIG_S_DRIVER); | 196 | add_status(dev, VIRTIO_CONFIG_S_DRIVER); |
@@ -208,21 +228,10 @@ static int virtio_dev_probe(struct device *_d) | |||
208 | if (device_features & (1ULL << i)) | 228 | if (device_features & (1ULL << i)) |
209 | __virtio_set_bit(dev, i); | 229 | __virtio_set_bit(dev, i); |
210 | 230 | ||
211 | err = dev->config->finalize_features(dev); | 231 | err = virtio_finalize_features(dev); |
212 | if (err) | 232 | if (err) |
213 | goto err; | 233 | goto err; |
214 | 234 | ||
215 | if (virtio_has_feature(dev, VIRTIO_F_VERSION_1)) { | ||
216 | add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); | ||
217 | status = dev->config->get_status(dev); | ||
218 | if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) { | ||
219 | dev_err(_d, "virtio: device refuses features: %x\n", | ||
220 | status); | ||
221 | err = -ENODEV; | ||
222 | goto err; | ||
223 | } | ||
224 | } | ||
225 | |||
226 | err = drv->probe(dev); | 235 | err = drv->probe(dev); |
227 | if (err) | 236 | if (err) |
228 | goto err; | 237 | goto err; |
@@ -372,7 +381,7 @@ int virtio_device_restore(struct virtio_device *dev) | |||
372 | /* We have a driver! */ | 381 | /* We have a driver! */ |
373 | add_status(dev, VIRTIO_CONFIG_S_DRIVER); | 382 | add_status(dev, VIRTIO_CONFIG_S_DRIVER); |
374 | 383 | ||
375 | ret = dev->config->finalize_features(dev); | 384 | ret = virtio_finalize_features(dev); |
376 | if (ret) | 385 | if (ret) |
377 | goto err; | 386 | goto err; |
378 | 387 | ||
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 953057d84185..2ef9529809d8 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c | |||
@@ -458,7 +458,44 @@ static int virtio_pci_restore(struct device *dev) | |||
458 | return virtio_device_restore(&vp_dev->vdev); | 458 | return virtio_device_restore(&vp_dev->vdev); |
459 | } | 459 | } |
460 | 460 | ||
461 | const struct dev_pm_ops virtio_pci_pm_ops = { | 461 | static const struct dev_pm_ops virtio_pci_pm_ops = { |
462 | SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore) | 462 | SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore) |
463 | }; | 463 | }; |
464 | #endif | 464 | #endif |
465 | |||
466 | |||
467 | /* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */ | ||
468 | static const struct pci_device_id virtio_pci_id_table[] = { | ||
469 | { PCI_DEVICE(0x1af4, PCI_ANY_ID) }, | ||
470 | { 0 } | ||
471 | }; | ||
472 | |||
473 | MODULE_DEVICE_TABLE(pci, virtio_pci_id_table); | ||
474 | |||
475 | static int virtio_pci_probe(struct pci_dev *pci_dev, | ||
476 | const struct pci_device_id *id) | ||
477 | { | ||
478 | return virtio_pci_legacy_probe(pci_dev, id); | ||
479 | } | ||
480 | |||
481 | static void virtio_pci_remove(struct pci_dev *pci_dev) | ||
482 | { | ||
483 | virtio_pci_legacy_remove(pci_dev); | ||
484 | } | ||
485 | |||
486 | static struct pci_driver virtio_pci_driver = { | ||
487 | .name = "virtio-pci", | ||
488 | .id_table = virtio_pci_id_table, | ||
489 | .probe = virtio_pci_probe, | ||
490 | .remove = virtio_pci_remove, | ||
491 | #ifdef CONFIG_PM_SLEEP | ||
492 | .driver.pm = &virtio_pci_pm_ops, | ||
493 | #endif | ||
494 | }; | ||
495 | |||
496 | module_pci_driver(virtio_pci_driver); | ||
497 | |||
498 | MODULE_AUTHOR("Anthony Liguori <aliguori@us.ibm.com>"); | ||
499 | MODULE_DESCRIPTION("virtio-pci"); | ||
500 | MODULE_LICENSE("GPL"); | ||
501 | MODULE_VERSION("1"); | ||
diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h index d840dad4149d..adddb647b21d 100644 --- a/drivers/virtio/virtio_pci_common.h +++ b/drivers/virtio/virtio_pci_common.h | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/virtio.h> | 27 | #include <linux/virtio.h> |
28 | #include <linux/virtio_config.h> | 28 | #include <linux/virtio_config.h> |
29 | #include <linux/virtio_ring.h> | 29 | #include <linux/virtio_ring.h> |
30 | #define VIRTIO_PCI_NO_LEGACY | ||
31 | #include <linux/virtio_pci.h> | 30 | #include <linux/virtio_pci.h> |
32 | #include <linux/highmem.h> | 31 | #include <linux/highmem.h> |
33 | #include <linux/spinlock.h> | 32 | #include <linux/spinlock.h> |
@@ -129,8 +128,8 @@ const char *vp_bus_name(struct virtio_device *vdev); | |||
129 | int vp_set_vq_affinity(struct virtqueue *vq, int cpu); | 128 | int vp_set_vq_affinity(struct virtqueue *vq, int cpu); |
130 | void virtio_pci_release_dev(struct device *); | 129 | void virtio_pci_release_dev(struct device *); |
131 | 130 | ||
132 | #ifdef CONFIG_PM_SLEEP | 131 | int virtio_pci_legacy_probe(struct pci_dev *pci_dev, |
133 | extern const struct dev_pm_ops virtio_pci_pm_ops; | 132 | const struct pci_device_id *id); |
134 | #endif | 133 | void virtio_pci_legacy_remove(struct pci_dev *pci_dev); |
135 | 134 | ||
136 | #endif | 135 | #endif |
diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c index 2588252e5c1c..6c76f0f5658c 100644 --- a/drivers/virtio/virtio_pci_legacy.c +++ b/drivers/virtio/virtio_pci_legacy.c | |||
@@ -19,14 +19,6 @@ | |||
19 | 19 | ||
20 | #include "virtio_pci_common.h" | 20 | #include "virtio_pci_common.h" |
21 | 21 | ||
22 | /* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */ | ||
23 | static const struct pci_device_id virtio_pci_id_table[] = { | ||
24 | { PCI_DEVICE(0x1af4, PCI_ANY_ID) }, | ||
25 | { 0 } | ||
26 | }; | ||
27 | |||
28 | MODULE_DEVICE_TABLE(pci, virtio_pci_id_table); | ||
29 | |||
30 | /* virtio config->get_features() implementation */ | 22 | /* virtio config->get_features() implementation */ |
31 | static u64 vp_get_features(struct virtio_device *vdev) | 23 | static u64 vp_get_features(struct virtio_device *vdev) |
32 | { | 24 | { |
@@ -220,7 +212,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = { | |||
220 | }; | 212 | }; |
221 | 213 | ||
222 | /* the PCI probing function */ | 214 | /* the PCI probing function */ |
223 | static int virtio_pci_probe(struct pci_dev *pci_dev, | 215 | int virtio_pci_legacy_probe(struct pci_dev *pci_dev, |
224 | const struct pci_device_id *id) | 216 | const struct pci_device_id *id) |
225 | { | 217 | { |
226 | struct virtio_pci_device *vp_dev; | 218 | struct virtio_pci_device *vp_dev; |
@@ -300,7 +292,7 @@ out: | |||
300 | return err; | 292 | return err; |
301 | } | 293 | } |
302 | 294 | ||
303 | static void virtio_pci_remove(struct pci_dev *pci_dev) | 295 | void virtio_pci_legacy_remove(struct pci_dev *pci_dev) |
304 | { | 296 | { |
305 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); | 297 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); |
306 | 298 | ||
@@ -312,15 +304,3 @@ static void virtio_pci_remove(struct pci_dev *pci_dev) | |||
312 | pci_disable_device(pci_dev); | 304 | pci_disable_device(pci_dev); |
313 | kfree(vp_dev); | 305 | kfree(vp_dev); |
314 | } | 306 | } |
315 | |||
316 | static struct pci_driver virtio_pci_driver = { | ||
317 | .name = "virtio-pci", | ||
318 | .id_table = virtio_pci_id_table, | ||
319 | .probe = virtio_pci_probe, | ||
320 | .remove = virtio_pci_remove, | ||
321 | #ifdef CONFIG_PM_SLEEP | ||
322 | .driver.pm = &virtio_pci_pm_ops, | ||
323 | #endif | ||
324 | }; | ||
325 | |||
326 | module_pci_driver(virtio_pci_driver); | ||