Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e16e12be authored by Michael S. Tsirkin's avatar Michael S. Tsirkin
Browse files

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: default avatarDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>


parent d4024af5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -355,7 +355,7 @@ static inline bool use_multiport(struct ports_device *portdev)
	 */
	if (!portdev->vdev)
		return 0;
	return portdev->vdev->features[0] & (1 << VIRTIO_CONSOLE_F_MULTIPORT);
	return __virtio_test_bit(portdev->vdev, VIRTIO_CONSOLE_F_MULTIPORT);
}

static DEFINE_SPINLOCK(dma_bufs_lock);
+4 −4
Original line number Diff line number Diff line
@@ -137,14 +137,14 @@ static void lg_finalize_features(struct virtio_device *vdev)
	vring_transport_features(vdev);

	/*
	 * The vdev->feature array is a Linux bitmask: this isn't the same as a
	 * the simple array of bits used by lguest devices for features.  So we
	 * do this slow, manual conversion which is completely general.
	 * Since lguest is currently x86-only, we're little-endian.  That
	 * means we could just memcpy.  But it's not time critical, and in
	 * case someone copies this code, we do it the slow, obvious way.
	 */
	memset(out_features, 0, desc->feature_len);
	bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;
	for (i = 0; i < bits; i++) {
		if (test_bit(i, vdev->features))
		if (__virtio_test_bit(vdev, i))
			out_features[i / 8] |= (1 << (i % 8));
	}

+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ static void mic_finalize_features(struct virtio_device *vdev)
	bits = min_t(unsigned, feature_len,
		sizeof(vdev->features)) * 8;
	for (i = 0; i < bits; i++) {
		if (test_bit(i, vdev->features))
		if (__virtio_test_bit(vdev, i))
			iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)),
				 &out_features[i / 8]);
	}
+1 −1
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ static void rproc_virtio_finalize_features(struct virtio_device *vdev)
	 * Remember the finalized features of our vdev, and provide it
	 * to the remote processor once it is powered on.
	 */
	rsc->gfeatures = vdev->features[0];
	rsc->gfeatures = vdev->features;
}

static void rproc_virtio_get(struct virtio_device *vdev, unsigned offset,
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ static void kvm_finalize_features(struct virtio_device *vdev)
	memset(out_features, 0, desc->feature_len);
	bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;
	for (i = 0; i < bits; i++) {
		if (test_bit(i, vdev->features))
		if (__virtio_test_bit(vdev, i))
			out_features[i / 8] |= (1 << (i % 8));
	}
}
Loading