qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Owen smith <owen.smith@citrix.com>
To: qemu-devel@nongnu.org
Cc: stefano.stabellini@eu.citrix.com,
	Owen smith <owen.smith@citrix.com>,
	xen-devel@lists.xen.org
Subject: [Qemu-devel] [PATCH v2 3/5] xenfb: Add option to use a grant ref for shared page
Date: Wed, 17 Sep 2014 15:30:40 +0100	[thread overview]
Message-ID: <1410964242-3341-4-git-send-email-owen.smith@citrix.com> (raw)
In-Reply-To: <1410964242-3341-1-git-send-email-owen.smith@citrix.com>

Adds "page-gref" to the frontend location to specify the grant
reference of the shared page. Adds the DEVOPS_FLAG_NEED_GNTDEV to
both vfb and vkbd device flags. "page-ref" is checked first to
avoid breaking existing frontends.

"page-gref"
    Value: <uint32_t>
    Grant reference to use to map the shared ring. Only used if
    "page-ref" is not set.

Signed-off-by: Owen smith <owen.smith@citrix.com>
---
 hw/display/xenfb.c | 44 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 10 deletions(-)

diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index 69471e9..829036f 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -54,6 +54,7 @@
 struct common {
     struct XenDevice  xendev;  /* must be first */
     void              *page;
+    int               page_gref;
     QemuConsole       *con;
 };
 
@@ -96,22 +97,38 @@ static int common_bind(struct common *c)
 {
     uint64_t mfn;
 
-    if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &mfn) == -1)
-	return -1;
-    assert(mfn == (xen_pfn_t)mfn);
+    if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &mfn) == -1) {
+        if (xenstore_read_fe_int(&c->xendev, "page-gref", &c->page_gref) == -1) {
+            return -1;
+        }
+    }
 
     if (xenstore_read_fe_int(&c->xendev, "event-channel", &c->xendev.remote_port) == -1)
 	return -1;
 
-    c->page = xc_map_foreign_range(xen_xc, c->xendev.dom,
-				   XC_PAGE_SIZE,
-				   PROT_READ | PROT_WRITE, mfn);
+    if (c->page_gref) {
+        c->page = xc_gnttab_map_grant_ref(c->xendev.gnttabdev,
+                                          c->xendev.dom, c->page_gref,
+                                          PROT_READ | PROT_WRITE);
+    } else {
+        assert(mfn == (xen_pfn_t)mfn);
+        c->page = xc_map_foreign_range(xen_xc, c->xendev.dom,
+                                       XC_PAGE_SIZE,
+                                       PROT_READ | PROT_WRITE, mfn);
+    }
     if (c->page == NULL)
 	return -1;
 
     xen_be_bind_evtchn(&c->xendev);
-    xen_be_printf(&c->xendev, 1, "ring mfn %"PRIx64", remote-port %d, local-port %d\n",
-		  mfn, c->xendev.remote_port, c->xendev.local_port);
+    if (c->page_gref) {
+        xen_be_printf(&c->xendev, 1,
+                      "ring gref %d, remote-port %d, local-port %d\n",
+                      c->page_gref, c->xendev.remote_port, c->xendev.local_port);
+    } else {
+        xen_be_printf(&c->xendev, 1,
+                      "ring mfn %"PRIx64", remote-port %d, local-port %d\n",
+                      mfn, c->xendev.remote_port, c->xendev.local_port);
+    }
 
     return 0;
 }
@@ -120,8 +137,13 @@ static void common_unbind(struct common *c)
 {
     xen_be_unbind_evtchn(&c->xendev);
     if (c->page) {
-	munmap(c->page, XC_PAGE_SIZE);
-	c->page = NULL;
+        if (c->page_gref) {
+            xc_gnttab_munmap(c->xendev.gnttabdev, c->page, 1);
+        } else {
+            munmap(c->page, XC_PAGE_SIZE);
+        }
+        c->page = NULL;
+        c->page_gref = 0;
     }
 }
 
@@ -954,6 +976,7 @@ static void fb_event(struct XenDevice *xendev)
 
 struct XenDevOps xen_kbdmouse_ops = {
     .size       = sizeof(struct XenInput),
+    .flags      = DEVOPS_FLAG_NEED_GNTDEV,
     .init       = input_init,
     .initialise = input_initialise,
     .connected  = input_connected,
@@ -963,6 +986,7 @@ struct XenDevOps xen_kbdmouse_ops = {
 
 struct XenDevOps xen_framebuffer_ops = {
     .size       = sizeof(struct XenFB),
+    .flags      = DEVOPS_FLAG_NEED_GNTDEV,
     .init       = fb_init,
     .initialise = fb_initialise,
     .disconnect = fb_disconnect,
-- 
2.1.0

  parent reply	other threads:[~2014-09-17 14:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-17 14:30 [Qemu-devel] [PATCH v2 0/5] xenfb: Add support for Windows PV frontend Owen smith
2014-09-17 14:30 ` [Qemu-devel] [PATCH v2 1/5] xenfb: Unregister keyboard event handler correctly Owen smith
2014-09-26 15:10   ` Stefano Stabellini
2014-09-17 14:30 ` [Qemu-devel] [PATCH v2 2/5] xenfb: Activate mouse event handler Owen smith
2014-09-26 15:12   ` Stefano Stabellini
2014-09-17 14:30 ` Owen smith [this message]
2014-09-17 16:42   ` [Qemu-devel] [Xen-devel] [PATCH v2 3/5] xenfb: Add option to use a grant ref for shared page Ian Campbell
2014-09-26 15:17   ` [Qemu-devel] " Stefano Stabellini
2014-09-17 14:30 ` [Qemu-devel] [PATCH v2 4/5] xenfb: Add "feature-no-abs-rescale" Owen smith
2014-09-26 15:25   ` Stefano Stabellini
2014-09-17 14:30 ` [Qemu-devel] [PATCH v2 5/5] xenfb: Add "feature-no-console" Owen smith
2014-09-26 15:42   ` Stefano Stabellini

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=1410964242-3341-4-git-send-email-owen.smith@citrix.com \
    --to=owen.smith@citrix.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.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).