[Pm-utils] chvt is a quirk (at least with current nvidia binary drivers)

Victor Lowther victor.lowther at gmail.com
Sun Jun 29 15:47:28 PDT 2008


So how about we treat like one?  It is a shame that it is so prevalent
that its absence is more notable than its presence...

Anyways, I would like to see if we can do without chvt and the attendant
time-eating console switching with other drivers that handle kernel
modesetting correctly.  To test them, make sure you are using kernel
suspend/resume on a system that 98smart-kernel-video approves of and see
if --quirk-no-chvt does the Right Thing, or if it makes your box
explode.

pm/HOWTO.hooks                  |    2 +-
pm/module.d/uswsusp             |    2 +-
pm/sleep.d/90chvt               |   20 --------------------
pm/sleep.d/98smart-kernel-video |   15 +++++++++++++--
pm/sleep.d/99video              |   23 ++++++++++++++++++++---
pm/sleep.d/Makefile.am          |    1 -
6 files changed, 35 insertions(+), 28 deletions(-)
delete mode 100755 pm/sleep.d/90chvt

diff --git a/pm/HOWTO.hooks b/pm/HOWTO.hooks
index 816ebba..7ee8298 100644
--- a/pm/HOWTO.hooks
+++ b/pm/HOWTO.hooks
@@ -65,7 +65,7 @@ does that should be in this range.

90 - 99: reserved for critical suspend hooks. 
The hooks in this range should not be messed with unless you know what
-you are doing.  They start with 90chvt and end with 99video
+you are doing.

At or before 50, you can assume that all services are still enabled.

diff --git a/pm/module.d/uswsusp b/pm/module.d/uswsusp
index 4647824..cc6ec5c 100755
--- a/pm/module.d/uswsusp
+++ b/pm/module.d/uswsusp
@@ -3,7 +3,6 @@
# disable processing of 99video
before_hooks()
{
- disablehook 90chvt "disabled by uswsusp"
disablehook 99video "disabled by uswsusp"
}

@@ -25,6 +24,7 @@ get_quirks()
vga-mode3)    ;; # no-op
save-pci)          OPTS="$OPTS --pci_save" ;;
none)    QUIRK_NONE="true" ;;
+         no-chvt)           ;; # no-op
*) continue ;;
esac
done
diff --git a/pm/sleep.d/90chvt b/pm/sleep.d/90chvt
deleted file mode 100755
index 47a2c85..0000000
--- a/pm/sleep.d/90chvt
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-# Ensure we eare in text mode by switching to an unused vt.
-# Also avoids lots of ghastly suspend/resume errors due to trying
-# to suspend/resume while running in X.
-
-. "${PM_FUNCTIONS}"
-
-case "$1" in
- hibernate|suspend)
- fgconsole |savestate console
- chvt 63
- ;;
- thaw|resume) 
- state_exists console || exit 1
- chvt $(restorestate console) 
- deallocvt 63
- ;;
- *)
- ;;
-esac
diff --git a/pm/sleep.d/98smart-kernel-video
b/pm/sleep.d/98smart-kernel-video
index 04f80f6..1c9675c 100755
--- a/pm/sleep.d/98smart-kernel-video
+++ b/pm/sleep.d/98smart-kernel-video
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright 2008 Victor Lowther <victor.lowther at gmail.com
+# Copyright 2008 Victor Lowther <victor.lowther at gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
@@ -15,11 +15,22 @@
smart_kernel_video() 
{
         # If we are using an ATI or nVidia binary driver, no quirks
required.
- [ -d /sys/module/nvidia -o -d /sys/module/fglrx ] && return 0;
+        # If we are using an nVidia binary driver, no quirks required,
+        # and we actually do not need to change virtual terminals.
+        [ -d /sys/module/nvidia ] && {
+     add_parameters "--quirk-no-chvt"
+     return 0
+ }
+ 
+ # if we are running an fglrx binary driver, we also do not need
+ # any quirks.  
+ # TODO: Does it also handle suspend/resume in X correctly?
+ [ -d /sys/module/fglrx ] && return 0;

local kernel_rev="$(uname -r |awk -F '[_-]' '{print $1}')"
         # Intel at or after kernel 2.6.26 is also quirk-free.
# FIXME: a more accurate way of testing this?
+ # TODO: Does it also handle suspend/resume in X correctly?
[ -d /sys/module/i915 ] && \
    [ "$kernel_rev" \> "2.6.26" -o "$kernel_rev" = "2.6.26" ] && \
    return 0;
diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video
index b927a1b..070e241 100755
--- a/pm/sleep.d/99video
+++ b/pm/sleep.d/99video
@@ -27,6 +27,7 @@ for opt in $PM_CMDLINE; do
vbestate-restore)  QUIRK_VBESTATE_RESTORE="true" ;;
vga-mode3)    QUIRK_VGA_MODE_3="true" ;;
none)    QUIRK_NONE="true" ;;
+         no-chvt)           QUIRK_NO_CHVT="true" ;;
*) continue ;;
esac
done
@@ -133,6 +134,20 @@ resume_video()
return 0  # avoid spurious hook exit failure message.
}

+mabye_switch_to_vt63()
+{
+    [ $QUIRK_NO_CHVT ] && return
+    fgconsole |savestate console
+    chvt 63
+}
+
+mabye_switch_from_vt63()
+{
+    [ $QUIRK_NO_CHVT ] && return
+    chvt $(restorestate console) 
+    deallocvt 63
+}
+
help() {
echo  # first echo makes it look nicer.
echo "Video quirk handler options:"
@@ -151,17 +166,19 @@ help() {
}

case "$1" in
- suspend) suspend_video ;;
- hibernate)
+ suspend) mabye_switch_to_vt63; 
+          suspend_video ;;
+ hibernate) mabye_switch_to_vt63;
if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then
suspend_video
fi
;;
- resume) resume_video ;;
+ resume) resume_video; mabye_switch_from_vt63 ;;
thaw)
if [ "${HIBERNATE_RESUME_POST_VIDEO}" = "yes" ]; then
resume_video
fi
+ mabye_switch_from_vt63
;;
help) help ;;
esac
diff --git a/pm/sleep.d/Makefile.am b/pm/sleep.d/Makefile.am
index d47b799..96685e8 100644
--- a/pm/sleep.d/Makefile.am
+++ b/pm/sleep.d/Makefile.am
@@ -9,7 +9,6 @@ sleep_SCRIPTS = \
55NetworkManager \
65alsa \
75modules \
- 90chvt \
90clock \
94cpufreq \
95led \


-- 
Victor Lowther
Ubuntu Certified Professional



More information about the Pm-utils mailing list