Re: svn commit: r303076 - head/sys/dev/fb

2016-07-22 Thread John Baldwin
On Wednesday, July 20, 2016 09:29:39 AM Roger Pau Monné wrote:
> Author: royger
> Date: Wed Jul 20 09:29:39 2016
> New Revision: 303076
> URL: https://svnweb.freebsd.org/changeset/base/303076
> 
> Log:
>   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 
> 0xfe001d2fa4f0
>   vpanic() at vpanic+0x182/frame 0xfe001d2fa570
>   kassert_panic() at kassert_panic+0x126/frame 0xfe001d2fa5e0
>   __mtx_lock_flags() at __mtx_lock_flags+0x15b/frame 0xfe001d2fa630
>   vesa_bios_save_restore() at vesa_bios_save_restore+0x78/frame 
> 0xfe001d2fa680
>   vga_suspend() at vga_suspend+0xa3/frame 0xfe001d2fa6b0
>   isavga_suspend() at isavga_suspend+0x1d/frame 0xfe001d2fa6d0
>   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.

This panics a box without VESA (a dumb VGA) since vesa_init_done doesn't get set
to true if VESA fails to find anything during its probe, so the mutex can be
initialized twice.  I think it is better to just revert this change and use
MTX_SYSINIT to initialize the mutex instead.

vga0:  at port 0x3d0-0x3db iomem 0xb8000-0xb on isa0
panic: lock "VESA lock" 0x81c64af0 already initialized
cpuid = 0
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0x824ec7a0
kdb_backtrace() at kdb_backtrace+0x39/frame 0x824ec850
vpanic() at vpanic+0x181/frame 0x824ec8d0
kassert_panic() at kassert_panic+0x17d/frame 0x824ec960
lock_init() at lock_init+0x186/frame 0x824ec9a0
_mtx_init() at _mtx_init+0x90/frame 0x824ec9e0
vesa_late_load() at vesa_late_load+0x2d/frame 0x824eca00
vga_init() at vga_init+0x65/frame 0x824eca20
vga_attach_unit() at vga_attach_unit+0x4b/frame 0x824eca50
isavga_attach() at isavga_attach+0x6c/frame 0x824eca90
DEVICE_ATTACH() at DEVICE_ATTACH+0x44/frame 0x824ecab0

https://reviews.freebsd.org/D7290 is a suggested patch that works in my
test case.

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r303076 - head/sys/dev/fb

2016-07-20 Thread Roger Pau Monné
Author: royger
Date: Wed Jul 20 09:29:39 2016
New Revision: 303076
URL: https://svnweb.freebsd.org/changeset/base/303076

Log:
  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 0xfe001d2fa4f0
  vpanic() at vpanic+0x182/frame 0xfe001d2fa570
  kassert_panic() at kassert_panic+0x126/frame 0xfe001d2fa5e0
  __mtx_lock_flags() at __mtx_lock_flags+0x15b/frame 0xfe001d2fa630
  vesa_bios_save_restore() at vesa_bios_save_restore+0x78/frame 
0xfe001d2fa680
  vga_suspend() at vga_suspend+0xa3/frame 0xfe001d2fa6b0
  isavga_suspend() at isavga_suspend+0x1d/frame 0xfe001d2fa6d0
  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.
  
  Sponsored by: Citrix Systems R
  MFC after:3 days
  PR:   209203
  Reviewed by:  dumbbell
  Differential revision:https://reviews.freebsd.org/D7196

Modified:
  head/sys/dev/fb/vesa.c

Modified: head/sys/dev/fb/vesa.c
==
--- head/sys/dev/fb/vesa.c  Wed Jul 20 07:33:48 2016(r303075)
+++ head/sys/dev/fb/vesa.c  Wed Jul 20 09:29:39 2016(r303076)
@@ -134,6 +134,7 @@ static vi_fill_rect_t   vesa_fill_rect;
 static vi_bitblt_t vesa_bitblt;
 static vi_diag_t   vesa_diag;
 static int vesa_bios_info(int level);
+static int vesa_late_load(int flags);
 
 static video_switch_t vesavidsw = {
vesa_probe,
@@ -1141,7 +1142,7 @@ vesa_configure(int flags)
 * initialization for now and try again later.
 */
if (adp == NULL) {
-   vga_sub_configure = vesa_configure;
+   vga_sub_configure = vesa_late_load;
return (ENODEV);
}
 
@@ -1909,6 +1910,17 @@ vesa_bios_info(int level)
 static int
 vesa_load(void)
 {
+
+   return (vesa_late_load(0));
+}
+
+/*
+ * To be called from the vga_sub_configure hook in case the VGA adapter is
+ * not found when VESA is loaded.
+ */
+static int
+vesa_late_load(int flags)
+{
int error;
 
if (vesa_init_done)
@@ -1918,7 +1930,7 @@ vesa_load(void)
 
/* locate a VGA adapter */
vesa_adp = NULL;
-   error = vesa_configure(0);
+   error = vesa_configure(flags);
 
if (error == 0)
vesa_bios_info(bootverbose);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"