linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	cornelia.huck@de.ibm.com,
	virtualization@lists.linux-foundation.org
Subject: [PATCH v3 16/16] virtio_pci_modern: support devices with no config
Date: Wed, 14 Jan 2015 19:28:21 +0200	[thread overview]
Message-ID: <1421256142-11512-17-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1421256142-11512-1-git-send-email-mst@redhat.com>

Virtio 1.0 spec lists device config as optional.
Set get/set callbacks to NULL. Drivers can check that
and fail gracefully.

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

diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index 9c000e9a..b877705 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -425,6 +425,21 @@ static void del_vq(struct virtio_pci_vq_info *info)
 	free_pages_exact(info->queue, vring_pci_size(info->num));
 }
 
+static const struct virtio_config_ops virtio_pci_config_nodev_ops = {
+	.get		= NULL,
+	.set		= NULL,
+	.generation	= vp_generation,
+	.get_status	= vp_get_status,
+	.set_status	= vp_set_status,
+	.reset		= vp_reset,
+	.find_vqs	= vp_modern_find_vqs,
+	.del_vqs	= vp_del_vqs,
+	.get_features	= vp_get_features,
+	.finalize_features = vp_finalize_features,
+	.bus_name	= vp_bus_name,
+	.set_vq_affinity = vp_set_vq_affinity,
+};
+
 static const struct virtio_config_ops virtio_pci_config_ops = {
 	.get		= vp_get,
 	.set		= vp_set,
@@ -655,9 +670,11 @@ int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
 						&vp_dev->device_len);
 		if (!vp_dev->device)
 			goto err_map_device;
-	}
 
-	vp_dev->vdev.config = &virtio_pci_config_ops;
+		vp_dev->vdev.config = &virtio_pci_config_ops;
+	} else {
+		vp_dev->vdev.config = &virtio_pci_config_nodev_ops;
+	}
 
 	vp_dev->config_vector = vp_config_vector;
 	vp_dev->setup_vq = setup_vq;
-- 
MST


  parent reply	other threads:[~2015-01-14 17:29 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-14 17:27 [PATCH v3 00/16] virtio-pci: towards virtio 1.0 guest support Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 01/16] virtio_pci: drop virtio_config dependency Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 02/16] virtio/9p: verify device has config space Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 03/16] virtio/blk: " Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 04/16] virtio/console: " Michael S. Tsirkin
2015-01-20 10:40   ` Amit Shah
2015-01-20 11:09     ` Michael S. Tsirkin
2015-01-21  6:14       ` Amit Shah
2015-01-21  6:44         ` Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 05/16] virtio/net: " Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 06/16] virtio/scsi: " Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 07/16] virtio/balloon: " Michael S. Tsirkin
2015-01-14 17:27 ` [PATCH v3 08/16] mn10300: drop dead code Michael S. Tsirkin
2015-01-23 23:08   ` Bjorn Helgaas
2015-01-14 17:27 ` [PATCH v3 09/16] pci: add pci_iomap_range Michael S. Tsirkin
2015-01-23 23:08   ` Bjorn Helgaas
2015-01-14 17:27 ` [PATCH v3 10/16] s390: " Michael S. Tsirkin
2015-01-16 10:11   ` Sebastian Ott
2015-01-21  0:43     ` Rusty Russell
2015-01-14 17:28 ` [PATCH v3 11/16] virtio_pci: move probe/remove code to common Michael S. Tsirkin
2015-01-14 17:28 ` [PATCH v3 12/16] virtio-pci: define layout for virtio 1.0 Michael S. Tsirkin
2015-01-14 17:28 ` [PATCH v3 13/16] virtio_pci: modern driver Michael S. Tsirkin
2015-01-14 17:28 ` [PATCH v3 14/16] virtio_pci: macros for PCI layout offsets Michael S. Tsirkin
2015-01-14 17:28 ` [PATCH v3 15/16] virtio_pci_modern: reduce number of mappings Michael S. Tsirkin
2015-01-14 17:28 ` Michael S. Tsirkin [this message]
2015-01-15 21:18 ` [PATCH v3 00/16] virtio-pci: towards virtio 1.0 guest support Gerd Hoffmann
2015-01-15 21:32   ` Michael S. Tsirkin
2015-01-16  8:32     ` Gerd Hoffmann
2015-01-16  8:45       ` Michael S. Tsirkin
2015-01-16 13:27         ` Gerd Hoffmann
2015-01-19 10:54           ` Gerd Hoffmann
2015-01-20 16:38             ` Michael S. Tsirkin
2015-01-19 11:07       ` Gerd Hoffmann
2015-01-19 22:11         ` Michael S. Tsirkin
2015-01-20 16:32         ` Michael S. Tsirkin
2015-01-21 11:31           ` Gerd Hoffmann
2015-01-21 11:36             ` Michael S. Tsirkin
2015-01-21 13:43               ` Gerd Hoffmann
2015-01-21 14:19                 ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421256142-11512-17-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).