From owner-svn-src-head@FreeBSD.ORG Wed Apr 29 12:53:42 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6082EC83; Wed, 29 Apr 2015 12:53:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 34A461BB7; Wed, 29 Apr 2015 12:53:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3TCrg6c088052; Wed, 29 Apr 2015 12:53:42 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3TCrgL4088051; Wed, 29 Apr 2015 12:53:42 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201504291253.t3TCrgL4088051@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: Roger Pau Monné Date: Wed, 29 Apr 2015 12:53:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r282216 - head/sys/dev/vt/hw/vga X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Apr 2015 12:53:42 -0000 Author: royger Date: Wed Apr 29 12:53:41 2015 New Revision: 282216 URL: https://svnweb.freebsd.org/changeset/base/282216 Log: vt_vga: add a timeout while waiting for vertical retrace On one of my systems FreeBSD will fail to boot because vt_vga gets stuck waiting for the vertical retrace if there's no monitor attached. Fix this by adding a timeout and exiting if the vertical retrace times out. Sponsored by: Citrix Systems R&D Reviewed by: emaste, dumbbell Differential Revision: https://reviews.freebsd.org/D2397 Modified: head/sys/dev/vt/hw/vga/vt_vga.c Modified: head/sys/dev/vt/hw/vga/vt_vga.c ============================================================================== --- head/sys/dev/vt/hw/vga/vt_vga.c Wed Apr 29 12:37:45 2015 (r282215) +++ head/sys/dev/vt/hw/vga/vt_vga.c Wed Apr 29 12:53:41 2015 (r282216) @@ -1035,11 +1035,12 @@ vga_initialize_graphics(struct vt_device REG_WRITE1(sc, VGA_GC_DATA, 0xff); } -static void +static int vga_initialize(struct vt_device *vd, int textmode) { struct vga_softc *sc = vd->vd_softc; uint8_t x; + int timeout; /* Make sure the VGA adapter is not in monochrome emulation mode. */ x = REG_READ1(sc, VGA_GEN_MISC_OUTPUT_R); @@ -1060,10 +1061,16 @@ vga_initialize(struct vt_device *vd, int * code therefore also removes that guarantee and appropriate measures * need to be taken. */ + timeout = 10000; do { + DELAY(10); x = REG_READ1(sc, VGA_GEN_INPUT_STAT_1); x &= VGA_GEN_IS1_VR | VGA_GEN_IS1_DE; - } while (x != (VGA_GEN_IS1_VR | VGA_GEN_IS1_DE)); + } while (x != (VGA_GEN_IS1_VR | VGA_GEN_IS1_DE) && --timeout != 0); + if (timeout == 0) { + printf("Timeout initializing vt_vga\n"); + return (ENXIO); + } /* Now, disable the sync. signals. */ REG_WRITE1(sc, VGA_CRTC_ADDRESS, VGA_CRTC_MODE_CONTROL); @@ -1194,6 +1201,8 @@ vga_initialize(struct vt_device *vd, int */ sc->vga_curfg = sc->vga_curbg = 0xff; } + + return (0); } static int @@ -1235,7 +1244,8 @@ vga_init(struct vt_device *vd) vd->vd_width = VT_VGA_WIDTH; vd->vd_height = VT_VGA_HEIGHT; } - vga_initialize(vd, textmode); + if (vga_initialize(vd, textmode) != 0) + return (CN_DEAD); sc->vga_enabled = true; return (CN_INTERNAL);