From patchwork Thu Jul 6 23:48:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9829235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1FAAA60317 for ; Thu, 6 Jul 2017 23:50:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F59D2851E for ; Thu, 6 Jul 2017 23:50:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03AC72858E; Thu, 6 Jul 2017 23:50:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 683E1285C8 for ; Thu, 6 Jul 2017 23:50:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTGVP-000860-Jz; Thu, 06 Jul 2017 23:48:19 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTGVO-00085u-5Y for xen-devel@lists.xenproject.org; Thu, 06 Jul 2017 23:48:18 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 03/8A-01994-14CCE595; Thu, 06 Jul 2017 23:48:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFIsWRWlGSWpSXmKPExsVybKJssq7Dmbh Ig31/pC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oymJ1dYC7abVlx4Kd7A+FK9i5GLQ0hgCZPE xL/rWboYOTlYBBwktkyZx9zFyMHBKBAj8eCHNUiYUSBMYvLlJawQJVoSX48+YAOx2QQMJf4+2 cQGUi4BZC/5zAESFhGwlGj62cMOYjMLzGGUWDohAsQWFnCWOHDzNiOIzSvgJbF44zSwkaICuh KH/v1hg4gLSpyc+YQFoldLYvn0bSwTGPlmIUnNQpJawMi0ilG9OLWoLLVI10IvqSgzPaMkNzE zR9fQwFQvN7W4ODE9NScxqVgvOT93EyMwnBiAYAfjwWbnQ4ySHExKorwV5nGRQnxJ+SmVGYnF GfFFpTmpxYcYZTg4lCR4JU4D5QSLUtNTK9Iyc4CBDZOW4OBREuFNqwVK8xYXJOYWZ6ZDpE4x6 nJsWL3+C5MQS15+XqqUOO8ckBkCIEUZpXlwI2BRdolRVkqYlxHoKCGegtSi3MwSVPlXjOIcjE rCvKIngabwZOaVwG16BXQEE9ARio0xIEeUJCKkpBoYmXkuHd48Ib72n9FsL99rtkLK2dd05Sq LlsV8+Xx8scSDup1Prr2aJsHS+lz3fcXtjXtnqDvke20vulHMFfHt0cLSl5NM7qtlqoUtY1Z4 tMTh2eQCM1GZKVMfM/dE+dboddmInOvpt6jzFLww0SRM7FQao+ftl+1/rjZusrLceuX5zk9TU 9WvKrEUZyQaajEXFScCAHOVvRStAgAA X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-15.tower-206.messagelabs.com!1499384895!87769822!1 X-Originating-IP: [198.145.29.99] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43721 invoked from network); 6 Jul 2017 23:48:16 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.99) by server-15.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 6 Jul 2017 23:48:16 -0000 Received: from [10.149.184.130] (162-198-228-33.lightspeed.wlfrct.sbcglobal.net [162.198.228.33]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 139F221C9B; Thu, 6 Jul 2017 23:48:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 139F221C9B Date: Thu, 6 Jul 2017 16:48:12 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-X260 To: xen-devel@lists.xenproject.org, qemu-devel@nongnu.org Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Cc: peter.maydell@linaro.org, sstabellini@kernel.org, owen.smith@citrix.com, paul.durrant@citrix.com, kraxel@redhat.com, anthony.perard@citrix.com Subject: [Xen-devel] [PATCH v3] xenfb: remove xen_init_display "temporary" hack X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Initialize xenfb properly, as all other backends, from its own "initialise" function. Remove the dependency of vkbd on vfb: use qemu_console_lookup_by_index to find the principal console (to get the size of the screen) instead of relying on a vfb backend to be available (which adds a dependency between the two). Signed-off-by: Stefano Stabellini Reviewed-by: Paul Durrant --- Note that this patch conflicts with Owen's series (http://marc.info/?l=qemu-devel&m=149908803419893&w=2). However it should be very easy to rebase one on top of the other. Changes in v3: - use qemu_console_lookup_by_index to find the console from xenfb_mouse_event - remove con from struct common and add it to struct XenFB - remove in->c.con check from input_initialise Changes in v2: - remove xen_init_display from xen_backend.h - handle cases where vkbd is missing diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index e76c0d8..df8b78f 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -46,7 +46,6 @@ struct common { struct XenDevice xendev; /* must be first */ void *page; - QemuConsole *con; }; struct XenInput { @@ -61,6 +60,7 @@ struct XenInput { struct XenFB { struct common c; + QemuConsole *con; size_t fb_len; int row_stride; int depth; @@ -71,7 +71,6 @@ struct XenFB { int fbpages; int feature_update; int bug_trigger; - int have_console; int do_resize; struct { @@ -80,6 +79,7 @@ struct XenFB { int up_count; int up_fullscreen; }; +static const GraphicHwOps xenfb_ops; /* -------------------------------------------------------------------- */ @@ -306,10 +306,18 @@ static void xenfb_mouse_event(void *opaque, int dx, int dy, int dz, int button_state) { struct XenInput *xenfb = opaque; - DisplaySurface *surface = qemu_console_surface(xenfb->c.con); - int dw = surface_width(surface); - int dh = surface_height(surface); - int i; + QemuConsole *con = qemu_console_lookup_by_index(0); + DisplaySurface *surface; + int dw, dh, i; + + if (!con) { + xen_pv_printf(&xenfb->c.xendev, 0, "No QEMU console available"); + return; + } + + surface = qemu_console_surface(con); + dw = surface_width(surface); + dh = surface_height(surface); trace_xenfb_mouse_event(opaque, dx, dy, dz, button_state, xenfb->abs_pointer_wanted); @@ -344,11 +352,6 @@ static int input_initialise(struct XenDevice *xendev) struct XenInput *in = container_of(xendev, struct XenInput, c.xendev); int rc; - if (!in->c.con) { - xen_pv_printf(xendev, 1, "ds not set (yet)\n"); - return -1; - } - rc = common_bind(&in->c); if (rc != 0) return rc; @@ -608,7 +611,7 @@ static int xenfb_configure_fb(struct XenFB *xenfb, size_t fb_len_lim, */ static void xenfb_guest_copy(struct XenFB *xenfb, int x, int y, int w, int h) { - DisplaySurface *surface = qemu_console_surface(xenfb->c.con); + DisplaySurface *surface = qemu_console_surface(xenfb->con); int line, oops = 0; int bpp = surface_bits_per_pixel(surface); int linesize = surface_stride(surface); @@ -642,7 +645,7 @@ static void xenfb_guest_copy(struct XenFB *xenfb, int x, int y, int w, int h) xen_pv_printf(&xenfb->c.xendev, 0, "%s: oops: convert %d -> %d bpp?\n", __FUNCTION__, xenfb->depth, bpp); - dpy_gfx_update(xenfb->c.con, x, y, w, h); + dpy_gfx_update(xenfb->con, x, y, w, h); } #ifdef XENFB_TYPE_REFRESH_PERIOD @@ -728,7 +731,7 @@ static void xenfb_update(void *opaque) surface = qemu_create_displaysurface(xenfb->width, xenfb->height); break; } - dpy_gfx_replace_surface(xenfb->c.con, surface); + dpy_gfx_replace_surface(xenfb->con, surface); xen_pv_printf(&xenfb->c.xendev, 1, "update: resizing: %dx%d @ %d bpp%s\n", xenfb->width, xenfb->height, xenfb->depth, @@ -877,16 +880,7 @@ static int fb_initialise(struct XenDevice *xendev) if (rc != 0) return rc; -#if 0 /* handled in xen_init_display() for now */ - if (!fb->have_console) { - fb->c.ds = graphic_console_init(xenfb_update, - xenfb_invalidate, - NULL, - NULL, - fb); - fb->have_console = 1; - } -#endif + fb->con = graphic_console_init(NULL, 0, &xenfb_ops, fb); if (xenstore_read_fe_int(xendev, "feature-update", &fb->feature_update) == -1) fb->feature_update = 0; @@ -972,42 +966,3 @@ static const GraphicHwOps xenfb_ops = { .gfx_update = xenfb_update, .update_interval = xenfb_update_interval, }; - -/* - * FIXME/TODO: Kill this. - * Temporary needed while DisplayState reorganization is in flight. - */ -void xen_init_display(int domid) -{ - struct XenDevice *xfb, *xin; - struct XenFB *fb; - struct XenInput *in; - int i = 0; - -wait_more: - i++; - main_loop_wait(true); - xfb = xen_pv_find_xendev("vfb", domid, 0); - xin = xen_pv_find_xendev("vkbd", domid, 0); - if (!xfb || !xin) { - if (i < 256) { - usleep(10000); - goto wait_more; - } - xen_pv_printf(NULL, 1, "displaystate setup failed\n"); - return; - } - - /* vfb */ - fb = container_of(xfb, struct XenFB, c.xendev); - fb->c.con = graphic_console_init(NULL, 0, &xenfb_ops, fb); - fb->have_console = 1; - - /* vkbd */ - in = container_of(xin, struct XenInput, c.xendev); - in->c.con = fb->c.con; - - /* retry ->init() */ - xen_be_check_state(xin); - xen_be_check_state(xfb); -} diff --git a/hw/xenpv/xen_machine_pv.c b/hw/xenpv/xen_machine_pv.c index 79aef4e..31d2f25 100644 --- a/hw/xenpv/xen_machine_pv.c +++ b/hw/xenpv/xen_machine_pv.c @@ -94,9 +94,6 @@ static void xen_init_pv(MachineState *machine) /* config cleanup hook */ atexit(xen_config_cleanup); - - /* setup framebuffer */ - xen_init_display(xen_domid); } static void xenpv_machine_init(MachineClass *mc) diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h index 852c2ea..8a6fbcb 100644 --- a/include/hw/xen/xen_backend.h +++ b/include/hw/xen/xen_backend.h @@ -55,8 +55,6 @@ extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */ extern struct XenDevOps xen_usb_ops; /* xen-usb.c */ #endif -void xen_init_display(int domid); - /* configuration (aka xenbus setup) */ void xen_config_cleanup(void); int xen_config_dev_blk(DriveInfo *disk);