From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id B0A9913888F for ; Wed, 14 Oct 2015 04:59:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 71CA0E07FE; Wed, 14 Oct 2015 04:59:22 +0000 (UTC) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 07F6FE07D1 for ; Wed, 14 Oct 2015 04:59:20 +0000 (UTC) Received: by padcn9 with SMTP id cn9so11476700pad.2 for ; Tue, 13 Oct 2015 21:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=M1bKfRICsp/0uGmp3i/l+CXpzYj5+3IWaRsN9xrQejk=; b=tjjnx90JFpvTa++B+wIGctSYut8dK48s6EHkOyWHFWYSeUo9xwFR5s9S74388Wb6LB 0gji6SCbqsg4dYIxYRV1K6zIVcraxrN4KGQZPgEoW9eaMar4B5GdAkhuygTmiZ7ory4R GT9/0BrR7BTKmz8OcDD9O9dvGS4zvHQFoHIWvc+QcPDv0aESYMtmmFvr+0K/1OD8PWLT wy+lkGUqumiD8aTmPMNCaE94/E9nFJWnRwIHs8/aKO4DbGk6Pn8EMs51f8Ego1Mz4TOw Tm5WrP7YOrgPCy9ORxh6DVBAZGbQJZvw2nuPrZcKd0eTV+L1BzdRVE5lrJaK2Q3lQ0x/ aOwg== X-Received: by 10.66.163.228 with SMTP id yl4mr1529667pab.112.1444798760095; Tue, 13 Oct 2015 21:59:20 -0700 (PDT) Received: from [192.168.247.60] (76-10-186-17.dsl.teksavvy.com. [76.10.186.17]) by smtp.googlemail.com with ESMTPSA id ya10sm6850098pbc.69.2015.10.13.21.59.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Oct 2015 21:59:19 -0700 (PDT) Subject: Re: [gentoo-user] pm-suspend problem To: gentoo-user@lists.gentoo.org References: <20151012214600.GD3729@ca.inter.net> <20151012220800.GA958@apio.adsroot.itcs.umich.edu> <20151012224816.GF3729@ca.inter.net> <20151014003912.GA1122@ca.inter.net> <561DCB84.40504@gmail.com> <20151014040003.GD1122@ca.inter.net> From: Daniel Frey X-Enigmail-Draft-Status: N1110 Message-ID: <561DE127.3080907@gmail.com> Date: Tue, 13 Oct 2015 21:59:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 In-Reply-To: <20151014040003.GD1122@ca.inter.net> Content-Type: multipart/mixed; boundary="------------030506040505010009060800" X-Archives-Salt: d9ebd73c-e31b-46a8-864d-41489eac3a6f X-Archives-Hash: 2a5f505089899be00be7acc3d59c2df3 This is a multi-part message in MIME format. --------------030506040505010009060800 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 10/13/2015 09:00 PM, Philip Webb wrote: > 151013 Daniel Frey wrote: >> On 10/13/2015 05:39 PM, Philip Webb wrote: >>> but doesn't wake up when the power button or a key is pressed ; >>> I can power off & restart normally afterwards. >>> 'dmesg' + 'syslog' simply show an immediate restart after the suspend. >> There was a kernel change some time back >> that disabled usb wake-up on all USB hubs. >> Userspace needs to explicitly enable them or device wakeup will not work. >> I wrote a script some time back to do that, >> but it can probably be done with a udev rule. > > Don't be coy ! -- can you post your script here ? > what would such a udev rule look like ? > Hah - sorry about that. Most people apparently use udev to do that. I wrote my script first and used it instead. I never really looked into udev as my script [kludge?] still works, I just tried it. I posted it in the Docs, Tips & Tricks forum [1] some time back & it's also on pastebin [2]. Use at your own risk! I've attached it here as well, hopefully we're allowed to do that on this list. The forum post lists how to use it. Wow, 18,000 views to the forum post. I wonder if that's good or bad? It requires root, so you may want to put it in /sbin/. Run it with no options and it'll display a usage page. All it does is do some searching in the /sys/devices tree and tries to find appropriate items to show. Dan [1] https://forums.gentoo.org/viewtopic-t-933934-highlight-usbwakeup.html [2] http://pastebin.com/cYstsSSa --------------030506040505010009060800 Content-Type: text/plain; charset=UTF-8; name="usbwakeup" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="usbwakeup" #!/bin/bash # This script attempts to read /sys/devices/ and identify usb ports and devices # that can be toggled to enable wakeup from sleep. # # Version: 2.0 # Date written: August 20, 2012 # # Copyright (C) 2012 danomac @ gentoo forums # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # Return code documentation # # 1: No parameter / unknown parameter specified # 2: Multiple actions requested, can only process one at a time # 3: Effective user ID not root (root is required) # # 7: No action requested # 8: Quiet and verbose requested at the same time! Use one or the other. # 9: Kernel Dmesg` option requested with action other than list # # Internal errors: # # 10: toggleall() - first parameter missing (internal error) # 11: toggleusbdevice() - first parameter not specified (internal error) # 12: toggleusbdevice() - second parameter not specified (internal error) # 13: toggleusbdevice() - third parameter needed but not specified! (internal error) function listusbwakeup () { # If quiet option is set, notify user it's being ignored if $QUIET; then echo "Quiet option set; ignoring..."; echo ""; fi # Initialize counter (to total items found later) COUNT=0 echo "Listing USB hubs/devices and their wakeup status..." # If verbose output is requested, switch to full detail view if $VERBOSE then echo " USB ID :: Device* :: Status Device full path Vendor :: Device Description ---------------------------------" else echo " USB ID :: Device* :: Status :: Device Description ----------------------------------------------------" fi # Search for all wakeup files under /sys/devices for i in `find /sys/devices -type f -name wakeup`; do # Extract the directory name where wakeup file resides DEVDIRNAME=`dirname $i` # Extract the actual device name (remove the power directory) DEVNAME=`dirname $DEVDIRNAME` # Now remove the directory path, leaving only the device's proper name (usb4, 4-1, etc) DEVPROPERNAME=`basename $DEVNAME` # Check for a product name. If none is found we most likely aren't interested in it. if [ -e $DEVDIRNAME/../product ] then # We found one! Find other relevant information, if none found use a placeholder. if [ -e $DEVDIRNAME/../product ]; then PRODUCT=`cat $DEVDIRNAME/../product`; else PRODUCT="No product name"; fi if [ -e $DEVDIRNAME/../manufacturer ]; then VENDOR=`cat $DEVDIRNAME/../manufacturer`; else VENDOR="No vendor name"; fi if [ -e $DEVDIRNAME/../idVendor ]; then IDVENDOR=`cat $DEVDIRNAME/../idVendor`; else IDVENDOR="No VendorID"; fi if [ -e $DEVDIRNAME/../idProduct ]; then IDPRODUCT=`cat $DEVDIRNAME/../idProduct`; else IDPRODUCT="No Product ID"; fi # If verbose output is selected, switch to full detail view if $VERBOSE then echo "$IDVENDOR:$IDPRODUCT :: $DEVPROPERNAME :: `cat $i`" echo " $DEVNAME" echo " $VENDOR :: $PRODUCT" echo "" else echo "$IDVENDOR:$IDPRODUCT :: $DEVPROPERNAME :: `cat $i` :: $PRODUCT" fi # Increment our totals counter COUNT=`expr $COUNT + 1` fi done; # Need to format the output differently for normal mode by adding an extra blank line if ! $VERBOSE; then echo ""; fi echo "*Use the Device column to identify hubs/devices to be toggled." # If there's no results indiciate so if [ $COUNT -eq 0 ] then echo "" echo " NO USB hubs/devices found, or none are toggle-able!" else # Hey, we have results, show the total found echo "" echo "$COUNT USB hubs/devices listed." fi # If the dmesg hints were requested, show them if $KERNELDMESG then echo " Hints from dmesg (use this to try to identify your keyboard and mouse, you may need to reboot to see anything relevant, see help for more info): " dmesg | grep ^input fi } function toggleusbdevice () { # toggleusbdevice (enabledevice:boolean, enableall:boolean, devname:string) # First parameter is boolean. True to enable device; False to # disable device. # Second parameter is boolean. True to enable all relevant devices found, # false to enable one device, specified in parameter 3. # Third parameter is the name of the device from the Device column of list # output # Make sure both parameters are passed to this function! if [ -z "$1" ]; then exit 11; fi if [ -z "$2" ]; then exit 12; fi # If specifying a single device to be changed, make sure parameter 3 # exists! if ! $2 then if [ -z "$3" ]; then exit 13; fi fi # Verbose detail is used throughout this function. Echo extra detail if # requested if $VERBOSE; then echo "Starting to parse wakeup devices found..."; fi # Search for all wakeup files under /sys/devices for i in `find /sys/devices -type f -name wakeup`; do # Extract the directory name where wakeup file resides DEVDIRNAME=`dirname $i` # Extract the actual device name (remove the power directory) DEVNAME=`dirname $DEVDIRNAME` # Now remove the directory path, leaving only the device's proper name (usb4, 4-1, etc) DEVPROPERNAME=`basename $DEVNAME` # Are we updating one specific device or all of them? if ! $2 then # Update individual device if $VERBOSE; then echo "Is this device ($DEVPROPERNAME) the same as the requested device ($3)?"; fi # Check for a product name. If none is found we most likely aren't interested in it. if [ "$DEVPROPERNAME" == "$3" ] then if $VERBOSE; then echo "YES! Attempting to change."; fi if $1 then if $VERBOSE || ! $QUIET; then echo "Attempting to enable device ($DEVPROPERNAME)..."; fi # Enable device echo "enabled" > $i if $VERBOSE || ! $QUIET then if [ $? -ne 0 ]; then echo "Failed."; else echo "Success!"; fi fi exit 0 else # Disable device if $VERBOSE || ! $QUIET; then echo "Attempting to disable device ($DEVPROPERNAME)..."; fi # Enable device echo "disabled" > $i if $VERBOSE || ! $QUIET then if [ $? -ne 0 ]; then echo "Failed."; else echo "Success!"; fi fi exit 0 fi else if $VERBOSE; then echo "...no."; fi fi else # Update all devices if $VERBOSE; then echo "Does this device ($DEVPROPERNAME) look like a USB hub/device?"; fi # Check for a product name. If none is found we most likely aren't interested in it. if [ -e $DEVDIRNAME/../product ] then # If verbose output is selected, switch to full detail view if $VERBOSE; then echo "YES!"; fi if $1 then if $VERBOSE || ! $QUIET; then echo "Attempting to enable device ($DEVPROPERNAME)..."; fi # Enable device echo "enabled" > $i if $VERBOSE || ! $QUIET then if [ $? -ne 0 ]; then echo "Failed."; else echo "Success!"; fi fi else # Disable device if $VERBOSE || ! $QUIET; then echo "Attempting to disable device ($DEVPROPERNAME)..."; fi # Enable device echo "disabled" > $i if $VERBOSE || ! $QUIET then if [ $? -ne 0 ]; then echo "Failed."; else echo "Success!"; fi fi fi else if $VERBOSE; then echo "...no."; fi fi fi done; # If updating only one device and we get this far it wasn't found. if ! $2; then echo "Device not found."; fi } function showhelp () { # If quiet option is passed notify user it's being ignored if $QUIET; then echo "Quiet option set; ignoring..."; fi echo " $0: a script that lists and toggles wakeup on usb hubs Usage: $0 [options] [action] [parameters] Actions: -l : list available usb hubs/devices that can be toggled and their current status (enabled/disabled) -a : enable wakeup on all discovered usb hubs/devices Use caution with this; it's better to identify individual hubs/devices rather than enable them all. You might find your computer woke itself unintentionally. -x : disable wakeup on all discovered usb hubs/devices -e : enable wakeup on specific hub/device (requires parameter, see below.) -d : disable wakeup on specific hub/device (requires parameter, see below.) -h : this screen Options: -q : Quiet mode for all but help and list actions -v : Enable verbose output -k : Try to show hints from dmesg (list action only) This dmesg option will show lines starting with input in order to try to identify devices. It is usually presented as /sys/devices/*/usb?/*/input/input?. If nothing useful is displayed, try rebooting as relevant information can be out of the buffer if the PC has been on for some time. Parameters: Both -e and -d actions require a parameter to search for, use -l to list. The parameter needed is in the Device column. Sample output of $0 -l: Listing USB devices and their wakeup status... USB ID :: Device* :: Status :: Device Description ---------------------------------------------------- 1d6b:0001 :: usb4 :: enabled :: UHCI Host Controller 046d:c508 :: 4-1 :: enabled :: USB Receiver 046d:c221 :: 4-2.1 :: enabled :: Gaming Keyboard The identifier needed for the parameter is usb4, 4-1, or 4-2.1. No arguments will show this screen. " } # Start of "main" routine # Make sure user is root (script will not work as user) if [ $EUID -ne 0 ]; then echo "This script must be run as root."; exit 3; fi # Initialize variables: # QUIET=quiet mode (no echo) - default false. Toggled with -q option. # KERNELDMESG=dmesg list option in list mode. Default false, toggled with # -k option # ACTION=default 0; used to make sure more than one action are not # specified at the same time. # VERBOSE=default false. Extra detail in some actions. QUIET=false KERNELDMESG=false VERBOSE=false ACTION=0 # Show help if no arguments provided at all if [ $# -eq 0 ]; then showhelp; exit 1; fi # Process arguments passed, setting environment appropriately. while getopts “hkqvlaxe:d:” OPTION do case $OPTION in h) # Help action # Make sure multiple actions are not chosen. if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi ACTION=1 ;; q) # Quiet option QUIET=true ;; k) # Kernel dmesg in list mode option KERNELDMESG=true ;; v) # Verbose option VERBOSE=true ;; l) # List action # Make sure multiple actions are not chosen. if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi ACTION=2 ;; a) # Enable all USB hubs/devices action # Make sure multiple actions are not chosen. if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi ACTION=3 ;; x) # Disable all USB hubs/devices action # Make sure multiple actions are not chosen. if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi ACTION=4 ;; e) # Enable specific hub/device via find command action # Make sure multiple actions are not chosen. if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi ACTION=5 # Save arguments passed for later ENABLEUSB=$OPTARG ;; d) # Disable specific hub/device via find command action # Make sure multiple actions are not chosen. if [ $ACTION -ne 0 ]; then echo "You can only declare one action at a time."; echo ""; showhelp; exit 2; fi ACTION=6 # Save arguments passed for later DISABLEUSB=$OPTARG ;; ?) # Unknown parameter showhelp exit 1 ;; esac done # Some sanity checks # Quiet and verbose can't be set at the same time if $QUIET && $VERBOSE; then echo "You can't specify quiet (-q) and verbose (-v) at the same time."; echo ""; exit 8; fi # Kernel DMESG can only be used with the list action if $KERNELDMESG && (( $ACTION != 2 )); then echo "The hints from dmesg option (-k) can only be used with the list (-l) action."; echo ""; exit 9; fi # Make sure an action was selected! if (($ACTION == 0 )); then echo "You haven't requested an action!"; exit 7; fi # We seem to be safe, so actually perform the request case $ACTION in 1) # help action showhelp exit ;; 2) # list action listusbwakeup exit ;; 3) # enable all devices toggleusbdevice true true exit ;; 4) # disable all devices toggleusbdevice false true exit ;; 5) # enable one device toggleusbdevice true false $ENABLEUSB exit ;; 6) # disable one device toggleusbdevice false false $DISABLEUSB exit ;; esac --------------030506040505010009060800--