diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-10-23 11:07:47 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2014-12-09 05:05:26 -0500 |
commit | b3bb62d11950eb6ac87403cacd667f84fa9495bc (patch) | |
tree | f3aee72f5e622722d19c484c7f5925990e97cffb /drivers/virtio | |
parent | c102659d690d382171bd2e40f35c5c811f0cdcac (diff) |
virtio: add legacy feature table support
virtio-blk has some legacy feature bits that modern drivers
must not negotiate, but are needed for old legacy hosts
(that e.g. don't support virtio-scsi).
Allow a separate legacy feature table for such cases.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 3e78f4bcfa8e..f9ad99c8b352 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -113,6 +113,13 @@ void virtio_check_driver_offered_feature(const struct virtio_device *vdev, | |||
113 | for (i = 0; i < drv->feature_table_size; i++) | 113 | for (i = 0; i < drv->feature_table_size; i++) |
114 | if (drv->feature_table[i] == fbit) | 114 | if (drv->feature_table[i] == fbit) |
115 | return; | 115 | return; |
116 | |||
117 | if (drv->feature_table_legacy) { | ||
118 | for (i = 0; i < drv->feature_table_size_legacy; i++) | ||
119 | if (drv->feature_table_legacy[i] == fbit) | ||
120 | return; | ||
121 | } | ||
122 | |||
116 | BUG(); | 123 | BUG(); |
117 | } | 124 | } |
118 | EXPORT_SYMBOL_GPL(virtio_check_driver_offered_feature); | 125 | EXPORT_SYMBOL_GPL(virtio_check_driver_offered_feature); |
@@ -161,6 +168,7 @@ static int virtio_dev_probe(struct device *_d) | |||
161 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); | 168 | struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); |
162 | u64 device_features; | 169 | u64 device_features; |
163 | u64 driver_features; | 170 | u64 driver_features; |
171 | u64 driver_features_legacy; | ||
164 | unsigned status; | 172 | unsigned status; |
165 | 173 | ||
166 | /* We have a driver! */ | 174 | /* We have a driver! */ |
@@ -177,7 +185,22 @@ static int virtio_dev_probe(struct device *_d) | |||
177 | driver_features |= (1ULL << f); | 185 | driver_features |= (1ULL << f); |
178 | } | 186 | } |
179 | 187 | ||
180 | dev->features = driver_features & device_features; | 188 | /* Some drivers have a separate feature table for virtio v1.0 */ |
189 | if (drv->feature_table_legacy) { | ||
190 | driver_features_legacy = 0; | ||
191 | for (i = 0; i < drv->feature_table_size_legacy; i++) { | ||
192 | unsigned int f = drv->feature_table_legacy[i]; | ||
193 | BUG_ON(f >= 64); | ||
194 | driver_features_legacy |= (1ULL << f); | ||
195 | } | ||
196 | } else { | ||
197 | driver_features_legacy = driver_features; | ||
198 | } | ||
199 | |||
200 | if (driver_features & device_features & (1ULL << VIRTIO_F_VERSION_1)) | ||
201 | dev->features = driver_features & device_features; | ||
202 | else | ||
203 | dev->features = driver_features_legacy & device_features; | ||
181 | 204 | ||
182 | /* Transport features always preserved to pass to finalize_features. */ | 205 | /* Transport features always preserved to pass to finalize_features. */ |
183 | for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) | 206 | for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) |