mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] minor virtio 1.0 fixups
@ 2014-12-11 17:01 Michael S. Tsirkin
  2014-12-11 17:01 ` [PATCH 1/3] virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore Michael S. Tsirkin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-12-11 17:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: cornelia.huck, Rusty Russell, virtualization

Here are some fixup patches on top of my latest pull request.
Will include in the next pull request.

Michael S. Tsirkin (3):
  virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore
  virtio_config: fix virtio_cread_bytes
  virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACY

 drivers/virtio/virtio_pci_common.h |  1 -
 include/linux/virtio_config.h      |  5 ++++-
 drivers/virtio/virtio.c            | 37 +++++++++++++++++++++++--------------
 3 files changed, 27 insertions(+), 16 deletions(-)

-- 
MST


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore
  2014-12-11 17:01 [PATCH 0/3] minor virtio 1.0 fixups Michael S. Tsirkin
@ 2014-12-11 17:01 ` Michael S. Tsirkin
  2014-12-11 17:23   ` Cornelia Huck
  2014-12-11 17:01 ` [PATCH 2/3] virtio_config: fix virtio_cread_bytes Michael S. Tsirkin
  2014-12-11 17:01 ` [PATCH 3/3] virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACY Michael S. Tsirkin
  2 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-12-11 17:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: cornelia.huck, Rusty Russell, virtualization, virtualization

virtio 1.0 devices require that drivers set VIRTIO_CONFIG_S_FEATURES_OK
after finalizing features.
virtio core missed doing this on restore, fix it up.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/virtio/virtio.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index f226658..b9f70df 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -162,6 +162,27 @@ static void virtio_config_enable(struct virtio_device *dev)
 	spin_unlock_irq(&dev->config_lock);
 }
 
+static int virtio_finalize_features(struct virtio_device *dev)
+{
+	int ret = dev->config->finalize_features(dev);
+	unsigned status;
+
+	if (ret)
+		return ret;
+
+	if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1))
+		return 0;
+
+	add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK);
+	status = dev->config->get_status(dev);
+	if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) {
+		dev_err(&dev->dev, "virtio: device refuses features: %x\n",
+			status);
+		return -ENODEV;
+	}
+	return 0;
+}
+
 static int virtio_dev_probe(struct device *_d)
 {
 	int err, i;
@@ -170,7 +191,6 @@ static int virtio_dev_probe(struct device *_d)
 	u64 device_features;
 	u64 driver_features;
 	u64 driver_features_legacy;
-	unsigned status;
 
 	/* We have a driver! */
 	add_status(dev, VIRTIO_CONFIG_S_DRIVER);
@@ -208,21 +228,10 @@ static int virtio_dev_probe(struct device *_d)
 		if (device_features & (1ULL << i))
 			__virtio_set_bit(dev, i);
 
-	err = dev->config->finalize_features(dev);
+	err = virtio_finalize_features(dev);
 	if (err)
 		goto err;
 
-	if (virtio_has_feature(dev, VIRTIO_F_VERSION_1)) {
-		add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK);
-		status = dev->config->get_status(dev);
-		if (!(status & VIRTIO_CONFIG_S_FEATURES_OK)) {
-			dev_err(_d, "virtio: device refuses features: %x\n",
-			       status);
-			err = -ENODEV;
-			goto err;
-		}
-	}
-
 	err = drv->probe(dev);
 	if (err)
 		goto err;
@@ -372,7 +381,7 @@ int virtio_device_restore(struct virtio_device *dev)
 	/* We have a driver! */
 	add_status(dev, VIRTIO_CONFIG_S_DRIVER);
 
-	ret = dev->config->finalize_features(dev);
+	ret = virtio_finalize_features(dev);
 	if (ret)
 		goto err;
 
-- 
MST


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] virtio_config: fix virtio_cread_bytes
  2014-12-11 17:01 [PATCH 0/3] minor virtio 1.0 fixups Michael S. Tsirkin
  2014-12-11 17:01 ` [PATCH 1/3] virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore Michael S. Tsirkin
@ 2014-12-11 17:01 ` Michael S. Tsirkin
  2014-12-11 17:01 ` [PATCH 3/3] virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACY Michael S. Tsirkin
  2 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-12-11 17:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: cornelia.huck, Rusty Russell, virtualization, virtualization

virtio_cread_bytes is implemented incorrectly in case length happens to
be 2,4 or 8 bytes: transports and devices will assume it's an integer
value that has to be converted to LE format.

Let's just do multiple 1-byte reads: this also makes life easier
for transports who only need to implement 1,2,4 and 8 byte reads.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/linux/virtio_config.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 7979f85..a61cd37 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -305,7 +305,10 @@ static inline void virtio_cread_bytes(struct virtio_device *vdev,
 				      unsigned int offset,
 				      void *buf, size_t len)
 {
-	vdev->config->get(vdev, offset, buf, len);
+	int i;
+
+	for (i = 0; i < len; i++)
+		vdev->config->get(vdev, offset + i, buf + i, 1);
 }
 
 static inline void virtio_cwrite8(struct virtio_device *vdev,
-- 
MST


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACY
  2014-12-11 17:01 [PATCH 0/3] minor virtio 1.0 fixups Michael S. Tsirkin
  2014-12-11 17:01 ` [PATCH 1/3] virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore Michael S. Tsirkin
  2014-12-11 17:01 ` [PATCH 2/3] virtio_config: fix virtio_cread_bytes Michael S. Tsirkin
@ 2014-12-11 17:01 ` Michael S. Tsirkin
  2 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-12-11 17:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: cornelia.huck, Rusty Russell, virtualization, virtualization

Legacy drivers use virtio_pci_common.h too, we should not
define VIRTIO_PCI_NO_LEGACY there.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/virtio/virtio_pci_common.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h
index d840dad..38d99ad 100644
--- a/drivers/virtio/virtio_pci_common.h
+++ b/drivers/virtio/virtio_pci_common.h
@@ -27,7 +27,6 @@
 #include <linux/virtio.h>
 #include <linux/virtio_config.h>
 #include <linux/virtio_ring.h>
-#define VIRTIO_PCI_NO_LEGACY
 #include <linux/virtio_pci.h>
 #include <linux/highmem.h>
 #include <linux/spinlock.h>
-- 
MST


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore
  2014-12-11 17:01 ` [PATCH 1/3] virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore Michael S. Tsirkin
@ 2014-12-11 17:23   ` Cornelia Huck
  0 siblings, 0 replies; 5+ messages in thread
From: Cornelia Huck @ 2014-12-11 17:23 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: linux-kernel, Rusty Russell, virtualization

On Thu, 11 Dec 2014 19:01:31 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> virtio 1.0 devices require that drivers set VIRTIO_CONFIG_S_FEATURES_OK
> after finalizing features.
> virtio core missed doing this on restore, fix it up.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/virtio/virtio.c | 37 +++++++++++++++++++++++--------------
>  1 file changed, 23 insertions(+), 14 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-11 17:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-11 17:01 [PATCH 0/3] minor virtio 1.0 fixups Michael S. Tsirkin
2014-12-11 17:01 ` [PATCH 1/3] virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore Michael S. Tsirkin
2014-12-11 17:23   ` Cornelia Huck
2014-12-11 17:01 ` [PATCH 2/3] virtio_config: fix virtio_cread_bytes Michael S. Tsirkin
2014-12-11 17:01 ` [PATCH 3/3] virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACY Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®