Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Aug 2016 23:52:09 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r303807 - stable/11/sys/dev/fb
Message-ID:  <201608062352.u76Nq9aN044732@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Sat Aug  6 23:52:09 2016
New Revision: 303807
URL: https://svnweb.freebsd.org/changeset/base/303807

Log:
  MFC 303076,303225: Use MTX_SYSINIT for the VESA lock.
  
  303076:
  vesa: fix panic on suspend
  
  Fix the following panic seen when migrating a FreeBSD guest on Xen:
  
  panic: mtx_lock() of destroyed mutex @ /usr/src/sys/dev/fb/vesa.c:541
  cpuid = 0
  KDB: stack backtrace:
  db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe001d2fa4f0
  vpanic() at vpanic+0x182/frame 0xfffffe001d2fa570
  kassert_panic() at kassert_panic+0x126/frame 0xfffffe001d2fa5e0
  __mtx_lock_flags() at __mtx_lock_flags+0x15b/frame 0xfffffe001d2fa630
  vesa_bios_save_restore() at vesa_bios_save_restore+0x78/frame 0xfffffe001d2fa680
  vga_suspend() at vga_suspend+0xa3/frame 0xfffffe001d2fa6b0
  isavga_suspend() at isavga_suspend+0x1d/frame 0xfffffe001d2fa6d0
  bus_generic_suspend_child() at bus_generic_suspend_child+0x44/frame
  [...]
  
  This is caused because vga_sub_configure (which is called if the VGA adapter
  is attached after VESA tried to initialize), points to vesa_configure, which
  doesn't initialize the VESA mutex. In order to fix it, make sure
  vga_sub_configure points to vesa_load, so that all the needed vesa
  components are properly initialized.
  
  303225:
  Use MTX_SYSINIT for the VESA lock.
  
  vesa_init_done isn't a reliable guard for the mutex init.  If
  vesa_configure() doesn't find valid VESA info it will not set
  vesa_init_done, but the lock will remain initialized.  Revert r303076
  and use MTX_SYSINIT to deterministically init the lock.
  
  PR:		209203
  Approved by:	re (gjb)

Modified:
  stable/11/sys/dev/fb/vesa.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/fb/vesa.c
==============================================================================
--- stable/11/sys/dev/fb/vesa.c	Sat Aug  6 20:27:12 2016	(r303806)
+++ stable/11/sys/dev/fb/vesa.c	Sat Aug  6 23:52:09 2016	(r303807)
@@ -79,6 +79,7 @@ struct adp_state {
 typedef struct adp_state adp_state_t;
 
 static struct mtx vesa_lock;
+MTX_SYSINIT(vesa_lock, &vesa_lock, "VESA lock", MTX_DEF);
 
 static int vesa_state;
 static void *vesa_state_buf;
@@ -1914,8 +1915,6 @@ vesa_load(void)
 	if (vesa_init_done)
 		return (0);
 
-	mtx_init(&vesa_lock, "VESA lock", NULL, MTX_DEF);
-
 	/* locate a VGA adapter */
 	vesa_adp = NULL;
 	error = vesa_configure(0);
@@ -1954,7 +1953,6 @@ vesa_unload(void)
 	}
 
 	vesa_bios_uninit();
-	mtx_destroy(&vesa_lock);
 
 	return (error);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608062352.u76Nq9aN044732>