From patchwork Mon Mar 11 19:23:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 1054827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44J7dD2R9yz9sBp for ; Tue, 12 Mar 2019 06:36:16 +1100 (AEDT) Received: from localhost ([127.0.0.1]:39123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Qic-0001Vu-2h for incoming@patchwork.ozlabs.org; Mon, 11 Mar 2019 15:36:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Qae-00042z-4x for qemu-devel@nongnu.org; Mon, 11 Mar 2019 15:28:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3QW5-0005Tr-9u for qemu-devel@nongnu.org; Mon, 11 Mar 2019 15:23:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59712) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3QW4-0005TR-Tt for qemu-devel@nongnu.org; Mon, 11 Mar 2019 15:23:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35D92155AC for ; Mon, 11 Mar 2019 19:23:16 +0000 (UTC) Received: from gimli.home (ovpn-116-24.phx2.redhat.com [10.3.116.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id E204F5D70E; Mon, 11 Mar 2019 19:23:13 +0000 (UTC) From: Alex Williamson To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2019 13:23:13 -0600 Message-ID: <155233219352.8141.477971660133647548.stgit@gimli.home> In-Reply-To: <155233206671.8141.2579745444621332750.stgit@gimli.home> References: <155233206671.8141.2579745444621332750.stgit@gimli.home> User-Agent: StGit/0.19-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 11 Mar 2019 19:23:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/3] vfio/display: delay link up event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann Kick the display link up event with a 0.1 sec delay, so the guest has a chance to notice the link down first. Signed-off-by: Gerd Hoffmann Reviewed-by: Liam Merwick [update for redefined macro] Signed-off-by: Alex Williamson --- hw/vfio/display.c | 30 +++++++++++++++++++++++++----- include/hw/vfio/vfio-common.h | 1 + 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 212ad1674ec1..a3d9c8f5beac 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -37,6 +37,23 @@ _reg->offset + offsetof(typeof(*_ptr), _fld))) +static void vfio_display_edid_link_up(void *opaque) +{ + VFIOPCIDevice *vdev = opaque; + VFIODisplay *dpy = vdev->dpy; + int fd = vdev->vbasedev.fd; + + dpy->edid_regs->link_state = VFIO_DEVICE_GFX_LINK_STATE_UP; + if (pwrite_field(fd, dpy->edid_info, dpy->edid_regs, link_state)) { + goto err; + } + trace_vfio_display_edid_link_up(); + return; + +err: + trace_vfio_display_edid_write_error(); +} + static void vfio_display_edid_update(VFIOPCIDevice *vdev, bool enabled, int prefx, int prefy) { @@ -49,6 +66,7 @@ static void vfio_display_edid_update(VFIOPCIDevice *vdev, bool enabled, .prefy = prefy ?: vdev->display_yres, }; + timer_del(dpy->edid_link_timer); dpy->edid_regs->link_state = VFIO_DEVICE_GFX_LINK_STATE_DOWN; if (pwrite_field(fd, dpy->edid_info, dpy->edid_regs, link_state)) { goto err; @@ -80,11 +98,8 @@ static void vfio_display_edid_update(VFIOPCIDevice *vdev, bool enabled, goto err; } - dpy->edid_regs->link_state = VFIO_DEVICE_GFX_LINK_STATE_UP; - if (pwrite_field(fd, dpy->edid_info, dpy->edid_regs, link_state)) { - goto err; - } - trace_vfio_display_edid_link_up(); + timer_mod(dpy->edid_link_timer, + qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 100); return; err: @@ -150,6 +165,9 @@ static void vfio_display_edid_init(VFIOPCIDevice *vdev) vdev->display_yres = dpy->edid_regs->max_yres; } + dpy->edid_link_timer = timer_new_ms(QEMU_CLOCK_REALTIME, + vfio_display_edid_link_up, vdev); + vfio_display_edid_update(vdev, true, 0, 0); return; @@ -168,6 +186,8 @@ static void vfio_display_edid_exit(VFIODisplay *dpy) g_free(dpy->edid_regs); g_free(dpy->edid_blob); + timer_del(dpy->edid_link_timer); + timer_free(dpy->edid_link_timer); } static void vfio_display_update_cursor(VFIODMABuf *dmabuf, diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 5f7f709b95f1..b65a2f051886 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -151,6 +151,7 @@ typedef struct VFIODisplay { struct vfio_region_info *edid_info; struct vfio_region_gfx_edid *edid_regs; uint8_t *edid_blob; + QEMUTimer *edid_link_timer; struct { VFIORegion buffer; DisplaySurface *surface;