alicelinux

A lightweight musl + clang/llvm + libressl + busybox distro
git clone https://codeberg.org/emmett1/alicelinux
Log | Files | Refs | README | LICENSE

pm-utils-1.4.1-bugfixes-1.patch (7908B)


      1 Submitted By:            Douglas R. Reno <renodr at linuxfromscratch dot org>
      2 Date:                    2023-04-10
      3 Initial Package Version: 1.4.1
      4 Origin:                  Debian (https://sources.debian.org/patches/pm-utils/1.4.1-19/)
      5 Upstream Status:         Defunct
      6 Description:             Fixes several bugs and quirks inside of pm-utils. In
      7                          particular, it does the following:
      8                          - Checks hibernate_mode in the uswsusp module (so that
      9                            the proper operation is performed)
     10                          - Fixes incorrect argument ordering in the XFS Buffer
     11                            module
     12                          - Fixes a typo in, and turns off, the ALPM module.
     13                            This fixes data corruption problems on SSDs by not
     14                            touching SATA Link Power Management.
     15                          - Bypasses a problem where failing to enable the
     16                            Suspend LED will cause Suspend to fail, since some
     17                            older ThinkPads (and newer laptops) do not have a
     18                            suspend LED.
     19                          - Fixes an incorrect path in the intel-audio-powersave
     20                            module, which results in malformed audio when coming
     21                            out of Suspend.
     22                          - Waits for the bluetooth USB module to be unused
     23                            prior to performing any operations
     24                          - Fixes the wireless adapter hook to work with newer
     25                            drivers.
     26                          - Adds support for the kernel's suspend mechanism.
     27                            The kernel has supported that since 3.6.
     28                          The names of the patches from Debian are:
     29                          - 05-uswsusp-hibernate.mode.patch
     30                          - 01_xfs_buffer_arguments.patch
     31                          - 03-fix-alpm-typo.patch
     32                          - 04-ignore-led-failure.patch
     33                          - 12-fix-intel-audio-powersave-hook.patch
     34                          - 13-49bluetooth-sync.patch
     35                          - 14-disable-sata-alpm.patch
     36                          - 17-fix-wireless-hook.patch
     37                          - 28-suspend-hybrid.patch
     38 
     39 diff -Naur pm-utils-1.4.1.orig/pm/module.d/uswsusp pm-utils-1.4.1/pm/module.d/uswsusp
     40 --- pm-utils-1.4.1.orig/pm/module.d/uswsusp	2010-07-04 09:42:51.000000000 -0500
     41 +++ pm-utils-1.4.1/pm/module.d/uswsusp	2023-04-10 10:57:52.719618092 -0500
     42 @@ -87,7 +87,11 @@
     43  	HIBERNATE_MODULE="uswsusp"
     44  	do_hibernate()
     45  	{
     46 -		s2disk
     47 +		if [ -n "$HIBERNATE_MODE" ]; then
     48 +         s2disk -P "shutdown method=$HIBERNATE_MODE"
     49 +      else
     50 +         s2disk
     51 +      fi
     52  	}
     53  fi
     54  
     55 diff -Naur pm-utils-1.4.1.orig/pm/pm-functions.in pm-utils-1.4.1/pm/pm-functions.in
     56 --- pm-utils-1.4.1.orig/pm/pm-functions.in	2010-07-04 09:50:13.000000000 -0500
     57 +++ pm-utils-1.4.1/pm/pm-functions.in	2023-04-10 11:17:39.945509643 -0500
     58 @@ -312,8 +312,28 @@
     59  	{
     60  		[ -n "${HIBERNATE_MODE}" ] && \
     61  		grep -qw "${HIBERNATE_MODE}" /sys/power/disk && \
     62 +		HIBERNATE_MODE_SAVE=$(cat /sys/power/disk) && \
     63 +		HIBERNATE_MODE_SAVE="${HIBERNATE_MODE_SAVE##*[}" && \
     64 +		HIBERNATE_MODE_SAVE="${HIBERNATE_MODE_SAVE%%]*}" && \
     65  		echo -n "${HIBERNATE_MODE}" > /sys/power/disk
     66  		echo -n "disk" > /sys/power/state
     67 +		RET=$?
     68 +		echo -n "$HIBERNATE_MODE_SAVE" > /sys/power/disk
     69 +		return "$RET"
     70 +	}
     71 +fi
     72 +
     73 +# For kernels that support suspend to both (hybrid suspend).
     74 +# The kernel supports this since version 3.6.
     75 +if [ -z "$SUSPEND_HYBRID_MODULE" ] && \
     76 +	[ -f /sys/power/disk ] && \
     77 +	grep -r disk /sys/power/state && \
     78 +	grep -q suspend /sys/power/disk; then
     79 +	SUSPEND_HYBRID_MODULE="kernel"
     80 +	do_suspend_hybrid()
     81 +	{
     82 +		HIBERNATE_MODE="suspend"
     83 +		do_hibernate
     84  	}
     85  fi
     86  
     87 diff -Naur pm-utils-1.4.1.orig/pm/power.d/intel-audio-powersave pm-utils-1.4.1/pm/power.d/intel-audio-powersave
     88 --- pm-utils-1.4.1.orig/pm/power.d/intel-audio-powersave	2010-07-04 09:50:13.000000000 -0500
     89 +++ pm-utils-1.4.1/pm/power.d/intel-audio-powersave	2023-04-10 11:01:36.180650779 -0500
     90 @@ -20,9 +20,9 @@
     91  
     92  audio_powersave() {
     93      [ "$INTEL_AUDIO_POWERSAVE" = "true" ] || exit $NA
     94 -    for dev in /sys/module/snd_*/parameters/power_save; do
     95 +    for dev in /sys/module/snd_*; do
     96  	[ -w "$dev/parameters/power_save" ] || continue
     97 -	printf "Setting power savings for $s to %d..." "$dev##*/" "$1"
     98 +	printf "Setting power savings for $s to %d..." "${dev##*/}" "$1"
     99  	echo $1 > "$dev/parameters/power_save" && echo Done. || echo Failed.
    100      done
    101  }
    102 diff -Naur pm-utils-1.4.1.orig/pm/power.d/sata_alpm pm-utils-1.4.1/pm/power.d/sata_alpm
    103 --- pm-utils-1.4.1.orig/pm/power.d/sata_alpm	2010-07-04 09:50:13.000000000 -0500
    104 +++ pm-utils-1.4.1/pm/power.d/sata_alpm	2023-04-10 11:04:34.514823624 -0500
    105 @@ -2,7 +2,8 @@
    106  
    107  . "${PM_FUNCTIONS}"
    108  
    109 -SATA_ALPM_ENABLE=${SATA_ALPM_ENABLE:-true}
    110 +SATA_ALPM_ENABLE=${SATA_ALPM_ENABLE:-false}
    111 +# Disable due to causing disk errors and corruptions, especially on SSDs.
    112  
    113  help() {
    114  cat <<EOF
    115 @@ -28,7 +29,7 @@
    116      [ "${kv%-*}" \< "2.6.33" ] && exit $NA  # avoid fs corruption
    117      for f in /sys/class/scsi_host/host*; do
    118  	[ -w "$f/link_power_management_policy" ] || continue
    119 -	printf "Setting SATA APLM on %s to %s..." "${f##*/}" "$1"
    120 +	printf "Setting SATA ALPM on %s to %s..." "${f##*/}" "$1"
    121  	echo "$1" > "$f/link_power_management_policy" && echo Done. || \
    122  	    echo Failed.
    123      done
    124 @@ -41,4 +42,4 @@
    125      *) exit $NA;;
    126  esac
    127  
    128 -exit 0
    129 \ No newline at end of file
    130 +exit 0
    131 diff -Naur pm-utils-1.4.1.orig/pm/power.d/wireless pm-utils-1.4.1/pm/power.d/wireless
    132 --- pm-utils-1.4.1.orig/pm/power.d/wireless	2010-07-04 09:50:13.000000000 -0500
    133 +++ pm-utils-1.4.1/pm/power.d/wireless	2023-04-10 11:05:47.029574861 -0500
    134 @@ -20,7 +20,7 @@
    135      # Skip if not a wireless card.
    136      [ -d "/sys/class/net/$1/wireless" ] || return 1
    137      # Also don't do anything if the device is disabled
    138 -    [ "$(cat /sys/class/net/$1/device/enable)" = "1" ] || return 1
    139 +    [ "$(cat /sys/class/net/$1/device/enable* 2> /dev/null)" != "0" ] || return 1
    140      driver="$(readlink "/sys/class/net/$1/device/driver")"
    141      driver=${driver##*/}
    142      case $driver in
    143 @@ -76,4 +76,4 @@
    144      *) exit $NA ;;
    145  esac
    146  
    147 -exit 0
    148 \ No newline at end of file
    149 +exit 0
    150 diff -Naur pm-utils-1.4.1.orig/pm/power.d/xfs_buffer pm-utils-1.4.1/pm/power.d/xfs_buffer
    151 --- pm-utils-1.4.1.orig/pm/power.d/xfs_buffer	2010-07-04 09:50:13.000000000 -0500
    152 +++ pm-utils-1.4.1/pm/power.d/xfs_buffer	2023-04-10 10:59:02.677001751 -0500
    153 @@ -59,7 +59,7 @@
    154  xfs_battery() {
    155      state_exists xfs_buffer_default || \
    156  	read_values |savestate xfs_buffer_default
    157 -    write_values "$XFS_AGE_BUFFER" "$XFS_BUFD" "$XFS_SYNCD"
    158 +    write_values "$XFS_AGE_BUFFER" "$XFS_SYNCD" "$XFS_BUFD"
    159  }
    160  
    161  case $1 in
    162 @@ -69,4 +69,4 @@
    163      *) exit $NA ;;
    164  esac
    165  
    166 -exit 0
    167 \ No newline at end of file
    168 +exit 0
    169 diff -Naur pm-utils-1.4.1.orig/pm/sleep.d/49bluetooth pm-utils-1.4.1/pm/sleep.d/49bluetooth
    170 --- pm-utils-1.4.1.orig/pm/sleep.d/49bluetooth	2010-07-04 09:42:51.000000000 -0500
    171 +++ pm-utils-1.4.1/pm/sleep.d/49bluetooth	2023-04-10 11:03:29.040005143 -0500
    172 @@ -12,6 +12,14 @@
    173  	if grep -q enabled /proc/acpi/ibm/bluetooth; then
    174  		savestate ibm_bluetooth enable
    175  		echo disable > /proc/acpi/ibm/bluetooth
    176 +
    177 +      # Wait for up to 2 seconds for the module to actually get unused
    178 +      TIMEOUT=20
    179 +      while [ $TIMEOUT -ge 0 ]; do
    180 +         [ `cat /sys/module/btusb/refcnt` = 0 ] && break
    181 +         TIMEOUT=$((TIMEOUT-1))
    182 +         sleep 0.1
    183 +      done
    184  	else
    185  		savestate ibm_bluetooth disable
    186  	fi
    187 diff -Naur pm-utils-1.4.1.orig/pm/sleep.d/95led pm-utils-1.4.1/pm/sleep.d/95led
    188 --- pm-utils-1.4.1.orig/pm/sleep.d/95led	2010-07-04 09:42:51.000000000 -0500
    189 +++ pm-utils-1.4.1/pm/sleep.d/95led	2023-04-10 11:00:12.602386132 -0500
    190 @@ -14,3 +14,4 @@
    191  	*) exit $NA
    192  		;;
    193  esac
    194 +exit 0 # To allow ThinkPads to work