aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/lguest/lguest_device.c4
-rw-r--r--drivers/misc/mic/card/mic_virtio.c4
-rw-r--r--drivers/remoteproc/remoteproc_virtio.c4
-rw-r--r--drivers/s390/kvm/kvm_virtio.c4
-rw-r--r--drivers/s390/kvm/virtio_ccw.c6
-rw-r--r--drivers/virtio/virtio.c21
-rw-r--r--drivers/virtio/virtio_mmio.c4
-rw-r--r--drivers/virtio/virtio_pci.c4
-rw-r--r--include/linux/virtio_config.h3
9 files changed, 38 insertions, 16 deletions
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 9b77b6623ff8..89088d6538fd 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -126,7 +126,7 @@ static void status_notify(struct virtio_device *vdev)
126 * sorted out, this routine is called so we can tell the Host which features we 126 * sorted out, this routine is called so we can tell the Host which features we
127 * understand and accept. 127 * understand and accept.
128 */ 128 */
129static void lg_finalize_features(struct virtio_device *vdev) 129static int lg_finalize_features(struct virtio_device *vdev)
130{ 130{
131 unsigned int i, bits; 131 unsigned int i, bits;
132 struct lguest_device_desc *desc = to_lgdev(vdev)->desc; 132 struct lguest_device_desc *desc = to_lgdev(vdev)->desc;
@@ -153,6 +153,8 @@ static void lg_finalize_features(struct virtio_device *vdev)
153 153
154 /* Tell Host we've finished with this device's feature negotiation */ 154 /* Tell Host we've finished with this device's feature negotiation */
155 status_notify(vdev); 155 status_notify(vdev);
156
157 return 0;
156} 158}
157 159
158/* Once they've found a field, getting a copy of it is easy. */ 160/* Once they've found a field, getting a copy of it is easy. */
diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c
index d027d299602f..e486a0c26267 100644
--- a/drivers/misc/mic/card/mic_virtio.c
+++ b/drivers/misc/mic/card/mic_virtio.c
@@ -84,7 +84,7 @@ static u64 mic_get_features(struct virtio_device *vdev)
84 return features; 84 return features;
85} 85}
86 86
87static void mic_finalize_features(struct virtio_device *vdev) 87static int mic_finalize_features(struct virtio_device *vdev)
88{ 88{
89 unsigned int i, bits; 89 unsigned int i, bits;
90 struct mic_device_desc __iomem *desc = to_micvdev(vdev)->desc; 90 struct mic_device_desc __iomem *desc = to_micvdev(vdev)->desc;
@@ -107,6 +107,8 @@ static void mic_finalize_features(struct virtio_device *vdev)
107 iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)), 107 iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)),
108 &out_features[i / 8]); 108 &out_features[i / 8]);
109 } 109 }
110
111 return 0;
110} 112}
111 113
112/* 114/*
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index 627737ee7632..e1a10232a943 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -217,7 +217,7 @@ static u64 rproc_virtio_get_features(struct virtio_device *vdev)
217 return rsc->dfeatures; 217 return rsc->dfeatures;
218} 218}
219 219
220static void rproc_virtio_finalize_features(struct virtio_device *vdev) 220static int rproc_virtio_finalize_features(struct virtio_device *vdev)
221{ 221{
222 struct rproc_vdev *rvdev = vdev_to_rvdev(vdev); 222 struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
223 struct fw_rsc_vdev *rsc; 223 struct fw_rsc_vdev *rsc;
@@ -235,6 +235,8 @@ static void rproc_virtio_finalize_features(struct virtio_device *vdev)
235 * to the remote processor once it is powered on. 235 * to the remote processor once it is powered on.
236 */ 236 */
237 rsc->gfeatures = vdev->features; 237 rsc->gfeatures = vdev->features;
238
239 return 0;
238} 240}
239 241
240static void rproc_virtio_get(struct virtio_device *vdev, unsigned offset, 242static void rproc_virtio_get(struct virtio_device *vdev, unsigned offset,
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index f5575ccdbb65..dd65c8b4c7fe 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -93,7 +93,7 @@ static u64 kvm_get_features(struct virtio_device *vdev)
93 return features; 93 return features;
94} 94}
95 95
96static void kvm_finalize_features(struct virtio_device *vdev) 96static int kvm_finalize_features(struct virtio_device *vdev)
97{ 97{
98 unsigned int i, bits; 98 unsigned int i, bits;
99 struct kvm_device_desc *desc = to_kvmdev(vdev)->desc; 99 struct kvm_device_desc *desc = to_kvmdev(vdev)->desc;
@@ -112,6 +112,8 @@ static void kvm_finalize_features(struct virtio_device *vdev)
112 if (__virtio_test_bit(vdev, i)) 112 if (__virtio_test_bit(vdev, i))
113 out_features[i / 8] |= (1 << (i % 8)); 113 out_features[i / 8] |= (1 << (i % 8));
114 } 114 }
115
116 return 0;
115} 117}
116 118
117/* 119/*
diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index c792b5fe0bc9..789275fb577f 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -752,7 +752,7 @@ out_free:
752 return rc; 752 return rc;
753} 753}
754 754
755static void virtio_ccw_finalize_features(struct virtio_device *vdev) 755static int virtio_ccw_finalize_features(struct virtio_device *vdev)
756{ 756{
757 struct virtio_ccw_device *vcdev = to_vc_device(vdev); 757 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
758 struct virtio_feature_desc *features; 758 struct virtio_feature_desc *features;
@@ -760,7 +760,7 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev)
760 760
761 ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); 761 ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL);
762 if (!ccw) 762 if (!ccw)
763 return; 763 return 0;
764 764
765 features = kzalloc(sizeof(*features), GFP_DMA | GFP_KERNEL); 765 features = kzalloc(sizeof(*features), GFP_DMA | GFP_KERNEL);
766 if (!features) 766 if (!features)
@@ -793,6 +793,8 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev)
793out_free: 793out_free:
794 kfree(features); 794 kfree(features);
795 kfree(ccw); 795 kfree(ccw);
796
797 return 0;
796} 798}
797 799
798static void virtio_ccw_get_config(struct virtio_device *vdev, 800static void virtio_ccw_get_config(struct virtio_device *vdev,
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 224f85442f3f..e1673a511d17 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -212,7 +212,9 @@ static int virtio_dev_probe(struct device *_d)
212 if (device_features & (1ULL << i)) 212 if (device_features & (1ULL << i))
213 __virtio_set_bit(dev, i); 213 __virtio_set_bit(dev, i);
214 214
215 dev->config->finalize_features(dev); 215 err = dev->config->finalize_features(dev);
216 if (err)
217 goto err;
216 218
217 if (virtio_has_feature(dev, VIRTIO_F_VERSION_1)) { 219 if (virtio_has_feature(dev, VIRTIO_F_VERSION_1)) {
218 add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); 220 add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK);
@@ -354,6 +356,7 @@ EXPORT_SYMBOL_GPL(virtio_device_freeze);
354int virtio_device_restore(struct virtio_device *dev) 356int virtio_device_restore(struct virtio_device *dev)
355{ 357{
356 struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); 358 struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
359 int ret;
357 360
358 /* We always start by resetting the device, in case a previous 361 /* We always start by resetting the device, in case a previous
359 * driver messed it up. */ 362 * driver messed it up. */
@@ -373,14 +376,14 @@ int virtio_device_restore(struct virtio_device *dev)
373 /* We have a driver! */ 376 /* We have a driver! */
374 add_status(dev, VIRTIO_CONFIG_S_DRIVER); 377 add_status(dev, VIRTIO_CONFIG_S_DRIVER);
375 378
376 dev->config->finalize_features(dev); 379 ret = dev->config->finalize_features(dev);
380 if (ret)
381 goto err;
377 382
378 if (drv->restore) { 383 if (drv->restore) {
379 int ret = drv->restore(dev); 384 ret = drv->restore(dev);
380 if (ret) { 385 if (ret)
381 add_status(dev, VIRTIO_CONFIG_S_FAILED); 386 goto err;
382 return ret;
383 }
384 } 387 }
385 388
386 /* Finally, tell the device we're all set */ 389 /* Finally, tell the device we're all set */
@@ -389,6 +392,10 @@ int virtio_device_restore(struct virtio_device *dev)
389 virtio_config_enable(dev); 392 virtio_config_enable(dev);
390 393
391 return 0; 394 return 0;
395
396err:
397 add_status(dev, VIRTIO_CONFIG_S_FAILED);
398 return ret;
392} 399}
393EXPORT_SYMBOL_GPL(virtio_device_restore); 400EXPORT_SYMBOL_GPL(virtio_device_restore);
394#endif 401#endif
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index aec1daee9ada..5219210d31ce 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -152,7 +152,7 @@ static u64 vm_get_features(struct virtio_device *vdev)
152 return readl(vm_dev->base + VIRTIO_MMIO_HOST_FEATURES); 152 return readl(vm_dev->base + VIRTIO_MMIO_HOST_FEATURES);
153} 153}
154 154
155static void vm_finalize_features(struct virtio_device *vdev) 155static int vm_finalize_features(struct virtio_device *vdev)
156{ 156{
157 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev); 157 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
158 158
@@ -164,6 +164,8 @@ static void vm_finalize_features(struct virtio_device *vdev)
164 164
165 writel(0, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES_SEL); 165 writel(0, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES_SEL);
166 writel(vdev->features, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES); 166 writel(vdev->features, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES);
167
168 return 0;
167} 169}
168 170
169static void vm_get(struct virtio_device *vdev, unsigned offset, 171static void vm_get(struct virtio_device *vdev, unsigned offset,
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index dd6df979862b..9be59d9f2f19 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -112,7 +112,7 @@ static u64 vp_get_features(struct virtio_device *vdev)
112} 112}
113 113
114/* virtio config->finalize_features() implementation */ 114/* virtio config->finalize_features() implementation */
115static void vp_finalize_features(struct virtio_device *vdev) 115static int vp_finalize_features(struct virtio_device *vdev)
116{ 116{
117 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 117 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
118 118
@@ -124,6 +124,8 @@ static void vp_finalize_features(struct virtio_device *vdev)
124 124
125 /* We only support 32 feature bits. */ 125 /* We only support 32 feature bits. */
126 iowrite32(vdev->features, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES); 126 iowrite32(vdev->features, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES);
127
128 return 0;
127} 129}
128 130
129/* virtio config->get() implementation */ 131/* virtio config->get() implementation */
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 1fa5faa26440..7979f850e7ac 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -47,6 +47,7 @@
47 * vdev: the virtio_device 47 * vdev: the virtio_device
48 * This gives the final feature bits for the device: it can change 48 * This gives the final feature bits for the device: it can change
49 * the dev->feature bits if it wants. 49 * the dev->feature bits if it wants.
50 * Returns 0 on success or error status
50 * @bus_name: return the bus name associated with the device 51 * @bus_name: return the bus name associated with the device
51 * vdev: the virtio_device 52 * vdev: the virtio_device
52 * This returns a pointer to the bus name a la pci_name from which 53 * This returns a pointer to the bus name a la pci_name from which
@@ -68,7 +69,7 @@ struct virtio_config_ops {
68 const char *names[]); 69 const char *names[]);
69 void (*del_vqs)(struct virtio_device *); 70 void (*del_vqs)(struct virtio_device *);
70 u64 (*get_features)(struct virtio_device *vdev); 71 u64 (*get_features)(struct virtio_device *vdev);
71 void (*finalize_features)(struct virtio_device *vdev); 72 int (*finalize_features)(struct virtio_device *vdev);
72 const char *(*bus_name)(struct virtio_device *vdev); 73 const char *(*bus_name)(struct virtio_device *vdev);
73 int (*set_vq_affinity)(struct virtqueue *vq, int cpu); 74 int (*set_vq_affinity)(struct virtqueue *vq, int cpu);
74}; 75};