aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-10-07 10:39:42 -0400
committerMichael S. Tsirkin <mst@redhat.com>2014-12-09 05:05:23 -0500
commite16e12be34648777606a2c03a3526409b38f0e63 (patch)
tree36298911ba8eed0a4805c2c30a56d92520d23432 /drivers/s390
parentd4024af56f7c6cdb7e721994204fb07b2cda8be9 (diff)
virtio: use u32, not bitmap for features
It seemed like a good idea to use bitmap for features in struct virtio_device, but it's actually a pain, and seems to become even more painful when we get more than 32 feature bits. Just change it to a u32 for now. Based on patch by Rusty. Suggested-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/kvm/kvm_virtio.c2
-rw-r--r--drivers/s390/kvm/virtio_ccw.c23
2 files changed, 10 insertions, 15 deletions
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index 643129070c51..fcd312d0c018 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -106,7 +106,7 @@ static void kvm_finalize_features(struct virtio_device *vdev)
106 memset(out_features, 0, desc->feature_len); 106 memset(out_features, 0, desc->feature_len);
107 bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8; 107 bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;
108 for (i = 0; i < bits; i++) { 108 for (i = 0; i < bits; i++) {
109 if (test_bit(i, vdev->features)) 109 if (__virtio_test_bit(vdev, i))
110 out_features[i / 8] |= (1 << (i % 8)); 110 out_features[i / 8] |= (1 << (i % 8));
111 } 111 }
112} 112}
diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index bda52f18e967..1dbee95838fe 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -701,7 +701,6 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev)
701{ 701{
702 struct virtio_ccw_device *vcdev = to_vc_device(vdev); 702 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
703 struct virtio_feature_desc *features; 703 struct virtio_feature_desc *features;
704 int i;
705 struct ccw1 *ccw; 704 struct ccw1 *ccw;
706 705
707 ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); 706 ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL);
@@ -715,19 +714,15 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev)
715 /* Give virtio_ring a chance to accept features. */ 714 /* Give virtio_ring a chance to accept features. */
716 vring_transport_features(vdev); 715 vring_transport_features(vdev);
717 716
718 for (i = 0; i < sizeof(*vdev->features) / sizeof(features->features); 717 features->index = 0;
719 i++) { 718 features->features = cpu_to_le32(vdev->features);
720 int highbits = i % 2 ? 32 : 0; 719 /* Write the feature bits to the host. */
721 features->index = i; 720 ccw->cmd_code = CCW_CMD_WRITE_FEAT;
722 features->features = cpu_to_le32(vdev->features[i / 2] 721 ccw->flags = 0;
723 >> highbits); 722 ccw->count = sizeof(*features);
724 /* Write the feature bits to the host. */ 723 ccw->cda = (__u32)(unsigned long)features;
725 ccw->cmd_code = CCW_CMD_WRITE_FEAT; 724 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT);
726 ccw->flags = 0; 725
727 ccw->count = sizeof(*features);
728 ccw->cda = (__u32)(unsigned long)features;
729 ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT);
730 }
731out_free: 726out_free:
732 kfree(features); 727 kfree(features);
733 kfree(ccw); 728 kfree(ccw);