public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
To: virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: Marcelo Tosatti <marcelo-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>,
	kvm-devel
	<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH] kvm guest balloon driver
Date: Wed, 9 Jan 2008 14:20:02 +1100	[thread overview]
Message-ID: <200801091420.03107.rusty@rustcorp.com.au> (raw)
In-Reply-To: <4783A245.90002-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

On Wednesday 09 January 2008 03:18:13 Avi Kivity wrote:
> Marcelo Tosatti wrote:
> > Do you have any suggestion on how to retrieve the IRQ of the virtio
> > device, or some other notification mechanism?

Unfortunately, irqs are logically assigned to virtio queues, not devices.  Yet
configuration info is per-device.

> One way would be to send a "look at config" queue message, but it seems
> that it is a fairly generic operation.  Maybe virtio can add support for
> it, with a new callback.

This is the first time we've had to do this, but I don't think it's the last,
so we should consider it carefully.

Chatted with Anthony, and this is what we came up with:
===
virtio: configuration change callback

Various drivers want to know when their configuration information
changes: the balloon driver is the immediate user, but the network
driver may one day have a "carrier" status as well.

This introduces that callback, and adds it to the virtio PCI
implementation.

Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
---
 drivers/virtio/virtio_pci.c |   10 ++++++++++
 include/linux/virtio.h      |    3 +++
 include/linux/virtio_pci.h  |    3 +++
 3 files changed, 16 insertions(+)

diff -r 7494c7702462 drivers/virtio/virtio_pci.c
--- a/drivers/virtio/virtio_pci.c	Wed Jan 09 11:00:21 2008 +1100
+++ b/drivers/virtio/virtio_pci.c	Wed Jan 09 11:18:19 2008 +1100
@@ -184,6 +184,16 @@ static irqreturn_t vp_interrupt(int irq,
 	/* It's definitely not us if the ISR was not high */
 	if (!isr)
 		return IRQ_NONE;
+
+	/* Configuration change?  Tell driver if it wants to know. */
+	if (isr & VIRTIO_PCI_ISR_CONFIG) {
+		struct virtio_driver *drv;
+		drv = container_of(vp_dev->vdev.dev.driver,
+				   struct virtio_driver, driver);
+
+		if (drv->config_changed)
+			drv->config_changed(&vp_dev->vdev);
+	}
 
 	spin_lock(&vp_dev->lock);
 	list_for_each_entry(info, &vp_dev->virtqueues, node) {
diff -r 7494c7702462 include/linux/virtio.h
--- a/include/linux/virtio.h	Wed Jan 09 11:00:21 2008 +1100
+++ b/include/linux/virtio.h	Wed Jan 09 11:18:19 2008 +1100
@@ -98,12 +98,15 @@ void unregister_virtio_device(struct vir
  * @probe: the function to call when a device is found.  Returns a token for
  *    remove, or PTR_ERR().
  * @remove: the function when a device is removed.
+ * @config_changed: optional function to call when the device configuration
+ *    changes; may be called in interrupt context.
  */
 struct virtio_driver {
 	struct device_driver driver;
 	const struct virtio_device_id *id_table;
 	int (*probe)(struct virtio_device *dev);
 	void (*remove)(struct virtio_device *dev);
+	void (*config_changed)(struct virtio_device *dev);
 };
 
 int register_virtio_driver(struct virtio_driver *drv);
diff -r 7494c7702462 include/linux/virtio_pci.h
--- a/include/linux/virtio_pci.h	Wed Jan 09 11:00:21 2008 +1100
+++ b/include/linux/virtio_pci.h	Wed Jan 09 11:18:19 2008 +1100
@@ -45,6 +45,9 @@
  * a read-and-acknowledge. */
 #define VIRTIO_PCI_ISR			19
 
+/* The bit of the ISR which indicates a device configuration change. */
+#define VIRTIO_PCI_ISR_CONFIG		0x2
+
 /* The remaining space is defined by each driver as the per-driver
  * configuration space */
 #define VIRTIO_PCI_CONFIG		20

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

  parent reply	other threads:[~2008-01-09  3:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08 15:33 [PATCH] kvm guest balloon driver Marcelo Tosatti
2008-01-08 15:42 ` Anthony Liguori
     [not found]   ` <478399D5.9030707-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2008-01-08 16:10     ` Marcelo Tosatti
2008-01-08 16:14       ` Anthony Liguori
     [not found]         ` <4783A14A.3080605-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2008-01-08 16:36           ` Avi Kivity
     [not found]             ` <4783A68E.80901-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-08 16:43               ` Anthony Liguori
2008-01-08 16:18       ` Avi Kivity
     [not found]         ` <4783A245.90002-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-09  3:20           ` Rusty Russell [this message]
2008-01-09 10:06     ` Andrea Arcangeli
     [not found]       ` <20080109100621.GL6958-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-09 11:14         ` Marcelo Tosatti

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=200801091420.03107.rusty@rustcorp.com.au \
    --to=rusty-8n+1lvoiyb80n/f98k4iww@public.gmane.org \
    --cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=marcelo-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.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