From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS2ce-0004aH-PG for qemu-devel@nongnu.org; Thu, 11 Sep 2014 07:33:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XS2cZ-0001pC-BG for qemu-devel@nongnu.org; Thu, 11 Sep 2014 07:33:08 -0400 Received: from smtp.ctxuk.citrix.com ([185.25.65.24]:50036 helo=SMTP.EU.CITRIX.COM) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS2cY-0001oJ-Vw for qemu-devel@nongnu.org; Thu, 11 Sep 2014 07:33:03 -0400 From: Owen Smith Date: Thu, 11 Sep 2014 11:33:01 +0000 Message-ID: <6624BC057AF4E240B6D036F5CC505B12041F0045@AMSPEX01CL02.citrite.net> References: <1410356546-22264-1-git-send-email-owen.smith@citrix.com> <1410356546-22264-3-git-send-email-owen.smith@citrix.com> In-Reply-To: Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/3] xenfb: Add option to use grant ref for shared page. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefano Stabellini Cc: "qemu-devel@nongnu.org" , "xen-devel@lists.xen.org" > -----Original Message----- > From: Stefano Stabellini [mailto:stefano.stabellini@eu.citrix.com] > Sent: 11 September 2014 02:01 > To: Owen Smith > Cc: qemu-devel@nongnu.org; xen-devel@lists.xen.org; Stefano Stabellini > Subject: Re: [PATCH 2/3] xenfb: Add option to use grant ref for shared pa= ge. >=20 > On Wed, 10 Sep 2014, Owen smith wrote: > > The vkbd device should be able to use a grant reference to map the > > shared page. > > > > Signed-off-by: Owen smith > > --- > > hw/display/xenfb.c | 39 +++++++++++++++++++++++++++++---------- > > 1 file changed, 29 insertions(+), 10 deletions(-) > > > > diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index > > 2c39753..c4375c8 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,36 @@ static int common_bind(struct common *c) { > > uint64_t mfn; > > > > - if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &mfn) =3D=3D -= 1) > > - return -1; > > - assert(mfn =3D=3D (xen_pfn_t)mfn); > > - > > if (xenstore_read_fe_int(&c->xendev, "event-channel", &c- > >xendev.remote_port) =3D=3D -1) > > return -1; > > > > - c->page =3D xc_map_foreign_range(xen_xc, c->xendev.dom, > > - XC_PAGE_SIZE, > > - PROT_READ | PROT_WRITE, mfn); > > + if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &mfn) =3D=3D -= 1) { > > + if (xenstore_read_fe_int(&c->xendev, "page-gref", &c->page_gre= f) > =3D=3D -1) { > > + return -1; > > + } > > + c->page =3D xc_gnttab_map_grant_ref(c->xendev.gnttabdev, > > + c->xendev.dom, > > + c->page_gref, > > + PROT_READ | PROT_WRITE); > > + } else { > > + assert(mfn =3D=3D (xen_pfn_t)mfn); > > + > > + c->page =3D xc_map_foreign_range(xen_xc, c->xendev.dom, > > + XC_PAGE_SIZE, > > + PROT_READ | PROT_WRITE, mfn); > > + } >=20 > This is an extension of the protocol. It should be documented somewhere. > At least in the commit message and somewhere under docs/misc or > xen/include/public/io/fbif.h. >=20 V2 will contain a better commit message, and I'll add a patch to the header= s to document the changes. The same protocol extension docs should be in xen/include/public/io/fbif.h= =20 and xen/include/public/io/kdbif.h, as this change covers the vfb and vkbd, = or=20 would it be better to change the patch to only affect the vkbd? >=20 > > if (c->page =3D=3D 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, lo= cal- > port %d\n", > > + c->page_gref, c->xendev.remote_port, c->xendev.l= ocal_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 +135,13 @@ static void common_unbind(struct common *c) { > > xen_be_unbind_evtchn(&c->xendev); > > if (c->page) { > > - munmap(c->page, XC_PAGE_SIZE); > > + if (c->page_gref) { > > + xc_gnttab_munmap(c->xendev.gnttabdev, c->page, 1); > > + } else { > > + munmap(c->page, XC_PAGE_SIZE); > > + } > > c->page =3D NULL; > > + c->page_gref =3D 0; > > } > > } > > > > @@ -954,6 +974,7 @@ static void fb_event(struct XenDevice *xendev) > > > > struct XenDevOps xen_kbdmouse_ops =3D { > > .size =3D sizeof(struct XenInput), > > + .flags =3D DEVOPS_FLAG_NEED_GNTDEV, > > .init =3D input_init, > > .initialise =3D input_initialise, > > .connected =3D input_connected, > > -- > > 2.1.0 > >