Highlighted
mmirg
1 Nickel

No backlight control when resuming from suspend-to-ram

I'm having difficulty resuming my Precision 5510 after suspending.  I have currently replaced the default Ubuntu installation with Gentoo on my laptop.  I'm currently using the Intel GPU for primary graphics output and the Nvidia through bumblebee as needed.

I'm able to put the laptop to sleep either with a lid trigger or by calling pm-suspend (I'm using openRC instead of systemd so I'm still using pm-utils to suspend.)  The machine goes to sleep reliably and will wake up but with odd behavior of the backlight upon resuming.  Adjusting the backlight with the hotkeys, a slider widget or by directly echoing values into /sys/class/backlight/intel_backlight/brightness will not adjust the backlight.  The hotkeys will still trigger the OSD to react as if brightness is being lowered.  However, once I hit the bottom of the brightness scale or echo "0" into the sysfs node, the backlight will turn off and can be turned on again.

Unfortunately, there's a second side effect that I've seen from this odd suspend behavior.  Once I have suspended and resumed the computer, I won't be able to use the hotkeys to adjust brightness after rebooting the computer.  Echoing into sysfs or using GUI widget slider will adjust the backlight but the hotkeys will not react or trigger events in X (including when I test with xev).  However, the backlight and keys still work because I am able to adjust the backlight during POST and the bootloader, it is only after the kernel initializes that I lose control.  I am yet to be able to isolate how it is that I regain hotkey usage again, but after some combination of suspends, resumes and reboots, I'm usually able to get things working again, but it's a frustrating procedure since I can't reproduce it reliably.

Does anyone have any thoughts on what might be going on here or how I might be able to properly re-initialize the backlight?  This seems to be the only problem that I am still having and it is quite vexing.  This doesn't seem to happen with systemd based suspend and resume, but I'm yet to test it exhaustively.  Has anyone else encountered a similar issue?

I'm on the most recent BIOS and am booting using legacy boot instead of EFI should that be relevant.  I've also tried the different quirks available to pm-utils to no avail and have also tried passing "acpi_osi=Linux/!Windows 2012 and acpi_backlight=vendor/native/video in all combinations but to no avail.  vbetool stops functioning after I resume from suspend and will respond to any attempted usage with "Real mode call failed".

0 Kudos
16 Replies
gregbunk
2 Bronze

RE: No backlight control when resuming from suspend-to-ram

Similar problems here.  It will also spontaneously reboot after resume from time to time.

I believe that the BIOS is corrupting itself on resume.  You can check this by running dmidecode as root before the first suspend, then after resume.  You will note that it works perfectly before a resume, but that the tables are corrupted after resume.

0 Kudos
mmirg
1 Nickel

RE: No backlight control when resuming from suspend-to-ram

Yes, I noticed that and saw your other thread on this issue as well.  I just received my laptop so it came with a newer BIOS revision than the 1.2 version that you previously mentioned, does suspend and resume work properly for you with the older firmware?  Since I effectively can't get the USB-C port to do anything (save for charge my Nexus 6P), I guess the Thunderbolt improvements in the newer BIOS revisions are largely moot from a user standpoint.  

0 Kudos
gregbunk
2 Bronze

RE: No backlight control when resuming from suspend-to-ram

Suspend and resume is more stable with the older BIOS, though it still corrupts itself and will spontaneously reboot on resume.  That said, I very, very rarely (never?) saw a resume that left me with a blank screen, and that is very common with 1.2.10.

Neither is fully stable.  

0 Kudos
MortenS
1 Copper

RE: No backlight control when resuming from suspend-to-ram

I see same problem with brightness after resume not working.

In /sys/class/backlight/intel_backlight I can still turn on off display with the bl_power or by setting brightness to 0. All other values (up to 12 supported) just gives full brightness. This i with bios 1.2.10 on Linux 4.7.2-1-ARCH on Arch Linux.

My Dell Precision 5510 is an intel i5-6440HQ without discrete graphic (No Nvidia).

In a bug reported 2013-07-26 I found a reference to a temporary workaround:
https://bugzilla.kernel.org/show_bug.cgi?id=60635
https://bugs.freedesktop.org/show_bug.cgi?id=97486

On my PC: after fresh poweron:

$ sudo intel_reg read 0xc2000

(0x000c2000): 0x00000001

After suspend/resume where brightness is not working the value of the register had changed to 0's. Running the following solved the problem an it is possible to adjust the brightness:

$ sudo intel_reg write  0xc2000 0x00000001

A patch for the kernel is discussed here: https://patchwork.freedesktop.org/patch/109407/

But as it is not yet finalized it could take until kernel 4.9 before we see it in the Linux kernel.

pdimarco
1 Copper

RE: No backlight control when resuming from suspend-to-ram

So I actually only ran into this problem once, I usually am unable to resume from sleep because of other issues mentioned on this board. But one peculiarity I did see when I hit it was I was able to adjust brightness by some means but not others. So my normal means is:

"xbacklight -inc 10" and "xbacklight -dec 10"

But those weren't working. But when I did this via xrandr, that did work. Something like:

"xrandr --output eDP1 --brightness 0.7

Of course I can't recreate because I usually have to reboot Smiley Sad. Though I saw this on Dell Precision 5510 with nvidia quadro 1000m and bios 1.2.14.

0 Kudos
mmirg
1 Nickel

RE: No backlight control when resuming from suspend-to-ram

Thanks for finding and sharing that patch.  I can confirm that the patch seems to fix my suspend and resume issues with respect to the backlight.  I'm able to consistently resume and still have my screen on and can control my backlight.

0 Kudos
cregganna
1 Copper

RE: No backlight control when resuming from suspend-to-ram

Indeed - this was the issue with my Dell Precision 5510 currently running Ubuntu 16.04.1 (But was present on the as-delivered 14.04). My BIOS is currently: "DMI: Dell Inc. Precision 5510/08R8KJ, BIOS 1.2.14 08/31/2016". I'm currently on kernel 4.6.0-040600-generic.

Unfortunately Suspend does not complete if I'm connected to the WD15 docking station but this is at least some progress - Honestly it is frustrating that these issues exist on a box that is being sold pre-installed with Ubuntu OS.

Following MortenS's reply I wrote a script for:

/usr/lib/pm-utils/sleep.d/97fixbacklight - (Don't forget to chmod 755)

======================8<======================
#!/bin/sh
# From patchwork.freedesktop.org/.../
# and en.community.dell.com/.../19985320
# Suspend Resume fails to restore PWM_GRANUALITY
# Tony.Jewell@Cregganna.Com

#. "${PM_FUNCTIONS}"

INTEL_REG=/usr/bin/intel_reg
ADDR="0x000c2000"
SAVE_FILE=/var/lib/pm-utils/save_intel_reg_pwm_granuality

[ -x "$INTEL_REG" ] || exit 0

case "$1" in
        hibernate|suspend)
		echo "$0: Saving Intel Register PWM_GRANUALITY"
		"$INTEL_REG" read "$ADDR" \
			| (read addr value && echo "$value") \
			>"$SAVE_FILE"
	sync
	;;
	thaw|resume)
		value=`cat "$SAVE_FILE" 2>/dev/null`
		if [ -n "$value" ]
		then
			echo "$0: Restoring Intel Register PWM_GRANUALITY $value"
			"$INTEL_REG" write "$ADDR" "$value"
			rm "$SAVE_FILE"
		fi
	;;
esac
======================8<======================
hsahmed
1 Copper

RE: No backlight control when resuming from suspend-to-ram

Thanks CREGGANNA for your script. I have modified it slightly to make it work with systems using systemd instead of pm-utils for sleep/hibernate

Save the following script as /usr/lib/systemd/system-sleep/fixbacklight (and chmod 755)

#!/bin/sh
# From patchwork.freedesktop.org/.../
# and en.community.dell.com/.../19985320
# Suspend Resume fails to restore PWM_GRANUALITY
# Based on script by Tony.Jewell@Cregganna.Com

INTEL_REG=/usr/bin/intel_reg
ADDR="0x000c2000"
SAVE_FILE=/var/lib/systemd/save_intel_reg_pwm_granuality

[ -x "$INTEL_REG" ] || exit 0

case "$1" in
        pre)
		echo "$0: Saving Intel Register PWM_GRANUALITY"
		"$INTEL_REG" read "$ADDR" \
			| (read addr value && echo "$value") \
			>"$SAVE_FILE"
	sync
	;;
	post)
		value=`cat "$SAVE_FILE" 2>/dev/null`
		if [ -n "$value" ]
		then
			echo "$0: Restoring Intel Register PWM_GRANUALITY $value"
			"$INTEL_REG" write "$ADDR" "$value"
			rm "$SAVE_FILE"
		fi
	;;
esac
cregganna
1 Copper

RE: No backlight control when resuming from suspend-to-ram

Thanks HSAHMED - on my system I think that would go in:

/lib/systemd/system-sleep/fixbacklight

not in

/usr/lib/systemd/system-sleep/fixbacklight