You are not logged in.

#1 2012-01-06 21:00:20

Yurlungur
Member
From: USA
Registered: 2012-01-06
Posts: 116

[SOLVED] Laptop mode tools forcing restart

Hi there. Sorry if this is in the wrong section. I wasn't sure whether it belonged in laptop issues or in applications issues. I'm running Arch on a Thinkpad T420 laptop and when I updated my kernel to 3.1.7-Arch, I found that when I shut down my computer, computer would completely power down and then power on again. This is similar to the problems reported in the following threads:
https://bbs.archlinux.org/viewtopic.php … 7#p1028777
https://bbs.archlinux.org/viewtopic.php?id=102178&p=1.

After some tinkering, I found that the problem disappeared if I removed laptop-mode from my daemons in rc.conf. However, if I allowed laptop-mode to turn on at boot and later disabled laptop mode tools from the command line with

# /etc/rc.d/laptop-mode stop

the problem persisted. By playing around with the configuration for laptop mode tools, I found that the pm-runtime script was causing the problems. I disabled it by editing the /etc/laptop-mode/conf.d/runtime-pm.conf file to look like this:

# Control Runtime Power Management ?
CONTROL_RUNTIME_PM=0

# Enable debug mode for this module
# Set to 1 if you want to debug this module
DEBUG=0

This solved the problem. I'm now running pm-utils and laptop-mode-tools together. Hopefully pm-utils is taking care of any job that runtime-pm did for laptop mode tools.

Maybe my workaround will help someone?


Lenovo Thinkpad T420; Intel sandy bridge i7 2.7GHz; integrated graphics card; 4GB RAM; wifi; Arch; Xmonad WM

Offline

#2 2012-01-11 17:17:07

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,130

Re: [SOLVED] Laptop mode tools forcing restart

Thanks! This worked for me. (I've only tested once but my issue was so consistent it is certainly looking good.)

What seems odd is that according to /etc/laptop-mode/conf.d/runtime-pm.conf:

# If you enable this setting, laptop mode tools will automatically set the
# Runtime Power Management framework of the Linux Kernel.
# This setting does not hurt, so there are no AC vs. battery settings:
# if CONTROL_RUNTIME_PM is set to 1, the powersave mode is always enabled.
# Set to 0 to disable.
#
# Default is "auto"

Which suggests that the framework is always enabled, even on AC. Can anybody say what the framework does exactly? Or give a pointer to documentation? I don't know what the "Runtime Power Management framework" of the kernel does exactly.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2012-01-11 21:48:01

Yurlungur
Member
From: USA
Registered: 2012-01-06
Posts: 116

Re: [SOLVED] Laptop mode tools forcing restart

Hey! Glad I was able to help! I was kinda wondering if I was the only one with this problem.

I think the reason we only had the problem on battery power is because laptop mode tools itself is set by default to run only when on battery power. The default settings for when LMT runs are in /etc/laptop-mode/laptop-mode.conf here's what my defaults were:

###############################################################################
# When to enable laptop mode
# --------------------------
#
# "Laptop mode" is the mode in which laptop mode tools makes the computer
# consume less power. This includes the kernel "laptop_mode" feature, which
# allows your hard drives to spin down, as well as various other settings which
# can be tweaked by laptop mode tools. You can enable or disable all of these
# settings using the CONTROL_... options further down in this config file.
###############################################################################


#
# Enable laptop mode when on battery power.
#
ENABLE_LAPTOP_MODE_ON_BATTERY=1


#
# Enable laptop mode when on AC power.
#
ENABLE_LAPTOP_MODE_ON_AC=0


#
# Enable laptop mode when the laptop's lid is closed, even when we're on AC
# power? (ACPI-ONLY)
#
ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=0

A quick google search revealed this and this about the "runtime power management framework of the linux kernel." It seems to control when to power down what piece of hardware to save power... for instance, spinning down hard-drives. The first article says that if things turn off in the wrong order, then the framwork cancels the shutdown. A quick lsmod showed that my computer no longer runs the module runtime_pm when I'm on battery power, so pm-utils doesn't call the framework (I think).

So I guess there's two possibilities:
1) Laptop Mode Tools has a bug, which is giving the wrong commands to the runtime power management framework on shutdown.
2) There's a bug in the framework or the shutdown script so that when we shut down, the framework thinks hardware is shutting off in the wrong order, and forces a restart.

I guess we could test this by trying to call the framework manually... or using another script. If there's an issue with (1), then we have to report the bug upstream... If there's an issue with (2), then we might be able to fix it ourselves? I'm not sure.

We can also probably just leave the runtime_pm module off. I already have cpu-frequency scaling from another module, and suspend works fine... so I'm not sure how important this framework really is or how much battery life it'll really save.

I'm really ignorant as far as the inner workings of the kernel, so I may have gotten all of this completely wrong. If someone understands it better, please speak up.


Lenovo Thinkpad T420; Intel sandy bridge i7 2.7GHz; integrated graphics card; 4GB RAM; wifi; Arch; Xmonad WM

Offline

#4 2012-01-12 16:05:21

cstart
Member
From: Texas - USA
Registered: 2009-01-28
Posts: 3

Re: [SOLVED] Laptop mode tools forcing restart

Thanks! Shutdown and reboot are finally working normally my Lenovo X220.

Offline

#5 2012-02-03 00:47:56

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,130

Re: [SOLVED] Laptop mode tools forcing restart

Thanks for doing the research. I know zilch about the innards of the kernel. I guess if it was a bug in the script we might stand a chance. A bug in the framework is certainly not something I would have any idea about. But maybe you're right and it is really a non-issue. (Somebody more knowledgeable would be welcome to chip in at this point!)

I'm sure you're right about the laptop-mode being disabled on AC. I guess that would be easy to test, too.

I'm wondering: is this issue specific to lenovo laptops? (But not in all cases, I'd guess: something-about-lenovo + something further?)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2012-02-09 01:00:15

zencatnine
Member
Registered: 2012-02-09
Posts: 1

Re: [SOLVED] Laptop mode tools forcing restart

I had the same problem as this on a Lenovo x220 (running Gentoo, but the same should apply to Arch if it's a kernel issue). The problem turned out to be the watchdog timer in the kernel not being configured. Once the module iTCO_wdt was inserted, shutting down worked fine.



(btw, for those unaware, the watchdog timer watches the system to see if it has crashed, and initiates a reboot if it thinks it has done so.)

Offline

#7 2012-02-09 01:11:55

Yurlungur
Member
From: USA
Registered: 2012-01-06
Posts: 116

Re: [SOLVED] Laptop mode tools forcing restart

@zencatnine: Thanks for the info!

@cfr: Sorry for my slow replies. I've been quite busy with other things. If this zencatnine is right, then we can probably try building a custom kernel with the iTCO_wdt module. This seems like an extremely likely candidate to me. I've never done this, so I guess I'll have to spend some time with the Arch Wiki learning how to build a custom kernel. Gentoo, of course, makes building a custom kernel easy during install. wink


Lenovo Thinkpad T420; Intel sandy bridge i7 2.7GHz; integrated graphics card; 4GB RAM; wifi; Arch; Xmonad WM

Offline

#8 2012-02-12 20:45:41

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,130

Re: [SOLVED] Laptop mode tools forcing restart

Obviously not, but it is not then possible to just load the relevant module? Some modules have to be actually built into the kernel somehow? (You can tell just how much I know about kernels, can't you?! To me, a module is an extra bit I load or don't load...)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#9 2012-02-13 00:37:44

Yurlungur
Member
From: USA
Registered: 2012-01-06
Posts: 116

Re: [SOLVED] Laptop mode tools forcing restart

Ah, yeah... so when you load a kernel module at boot, you're pulling it out of the kernel. However, the kernel build has to know it exists... I ran into this in Gentoo when I built a kernel that didn't have NTFS support. Even after installling the module, I couldn't call the module effectively at boot, it just wouldn't run. I thus had to rebuild the kernel with support included.

That said, it's worth a try just calling the module... For some (incredibly stupid) reason I hadn't thought of that. I'll play around with that and report back. smile


Lenovo Thinkpad T420; Intel sandy bridge i7 2.7GHz; integrated graphics card; 4GB RAM; wifi; Arch; Xmonad WM

Offline

#10 2012-02-15 09:11:29

Yurlungur
Member
From: USA
Registered: 2012-01-06
Posts: 116

Re: [SOLVED] Laptop mode tools forcing restart

Ok, so, I've played around with it a little bit. I added iTCO_wdt to the modules on boot in rc.conf:

MODULES=(iTCO_wdt thinkpad_acpi thinkpad_ec acpi-cpufreq)

and an lsmod call shows the module is running

# lsmod | grep wdt
iTCO_wdt               11885  0 
iTCO_vendor_support     1961  1 iTCO_wdt

However, with RUNTIME_CONTROL enabled, and the power chord unplugged, my computer still reboots on shutdown. At this point, I'm not sure whether to look for another solution, or what. It's possible there's something else wrong with the watchdog timer? Is there way to look at its configuration?


Lenovo Thinkpad T420; Intel sandy bridge i7 2.7GHz; integrated graphics card; 4GB RAM; wifi; Arch; Xmonad WM

Offline

#11 2012-02-20 03:18:03

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,130

Re: [SOLVED] Laptop mode tools forcing restart

Just out of curiosity, I ran:

$ lsmod | grep iT   
iTCO_wdt               11885  0 
iTCO_vendor_support     1961  1 iTCO_wdt

So it seems the module is loaded automatically in any case (since I haven't added it explicitly in rc.conf).

Edit: What's the relationship between the watchdog mentioned above and the one in /extra? The former is part of the kernel and the latter is something totally different? I went looking for documentation and am getting (more) confused...

Edit: Any connection with nmi_watchdog? (laptop-mode-tools seems to disable this on battery by default?)

Last edited by cfr (2012-02-20 03:38:21)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#12 2012-04-02 20:17:36

bkadoctaj
Member
Registered: 2010-05-02
Posts: 52

Re: [SOLVED] Laptop mode tools forcing restart

Yay, just as for cstart, my shutdown finally works correctly when unplugged from the power adapter!!  big_smile

Thanks for tinkering with laptop mode configs Yurlungur!  S4!t was driving me crazy lol...

No more f%^kn "Power down." followed by a blinking cursor at shutdown!!!

Offline

#13 2012-04-21 20:27:15

Yurlungur
Member
From: USA
Registered: 2012-01-06
Posts: 116

Re: [SOLVED] Laptop mode tools forcing restart

cfr: sorry for not getting back to you earlier. I was super busy studying for the physics GREs.

The inner workings of runtime power management is still a magic box to me, but I figured out how to turn it off at shutdown so you can still use it to save power. Apparently when we turn on runtime power anagement, we tell the kernel to control the following devices

pci, spi, i2c

I have no idea what they do but they're apparently inter-hardware interfaces? Wikipedia articles:

http://en.wikipedia.org/wiki/PCI_bus
http://en.wikipedia.org/wiki/I2C
http://en.wikipedia.org/wiki/PCI_bus

Anyway, we can tell the kernel to control their behavior. By looking at some other  owersaving scripts, I figured out the command to toggle powersaving on and off: Turning on runtime power management for pci:

echo auto > /sys/bus/pci/devices/*/power/control

Turning off runtime power management for pci:

echo on > /sys/bus/pci/devices/*/power/control

So, to disable runtime power management before shutting down, put the following lines at the start of your /etc/rc.shutdown file:

# A script to act as a workaround for the bug in the runtime power
# management module, which causes thinkpad laptops to restart after
# shutting down.

# Bus list for the runtime power management module. Probably shouldn't
# touch this.
buslist="pci spi i2c"

for bus in $buslist; do                                                             
    for i in /sys/bus/$bus/devices/*/power/control; do                              
        echo on > $i
    done
done

(alternatively, make it a script write a function in .bashrc that calls it before shutting down, whatever works.)

you can turn runtime power management on in laptop-mode tools now. smile

Does anyone know if rc.shutdown is ever modified by pacman? If so that might dictate your decision on where to put the little script...

Also, I should probably edit the wiki concerning laptop mode tools...


Lenovo Thinkpad T420; Intel sandy bridge i7 2.7GHz; integrated graphics card; 4GB RAM; wifi; Arch; Xmonad WM

Offline

#14 2012-05-25 17:25:22

bazenga
Member
Registered: 2009-12-14
Posts: 15

Re: [SOLVED] Laptop mode tools forcing restart

rc.shutdown might get overwritten on update, it's probably best to add a shutdown hook.

Create a file in /etc/rc.d/functions.d/ with the following content:

# A script to act as a workaround for the bug in the runtime power
# management module, which causes thinkpad laptops to restart after
# shutting down.

disable_power_management() {
  # Bus list for the runtime power management module. Probably shouldn't
  # touch this.
  buslist="pci i2c"

  for bus in $buslist; do
    for i in /sys/bus/$bus/devices/*/power/control; do
      echo on > $i
    done
  done
}

add_hook shutdown_poweroff disable_power_management

Offline

#15 2012-05-25 20:07:05

Yurlungur
Member
From: USA
Registered: 2012-01-06
Posts: 116

Re: [SOLVED] Laptop mode tools forcing restart

Oh. Good point. Thanks!


Lenovo Thinkpad T420; Intel sandy bridge i7 2.7GHz; integrated graphics card; 4GB RAM; wifi; Arch; Xmonad WM

Offline

#16 2012-05-27 00:43:25

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,130

Re: [SOLVED] Laptop mode tools forcing restart

Thanks! I'm trying this now.

I suspect that bus="pci" would be sufficient because all the instances under i2c on my machine are already set to 'auto' even with laptop-mode-tools not managing runtime pm and I can shut down OK. But it seems wise to include everything?

By the way, how did the physics GRE go? I remember the GRE - though not, I'm pleased to say, in physics...

By the way, I still don't really understand why this doesn't affect shutdown on AC. I just altered the runtime pm configuration and restarted /etc/rc.d/laptop-mode while on AC and, low and behold, the pm control for the pci devices all changed from "on" to "auto" so it looks as if runtime pm management does get enabled on AC even though laptop-mode isn't enabled... [I'm not sure this matters. I haven't tried poweroff on battery yet but so long as it works, it works. I'm just curious...]

Last edited by cfr (2012-05-27 00:52:03)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#17 2012-05-28 22:10:39

Yurlungur
Member
From: USA
Registered: 2012-01-06
Posts: 116

Re: [SOLVED] Laptop mode tools forcing restart

cfr wrote:

I suspect that bus="pci" would be sufficient because all the instances under i2c on my machine are already set to 'auto' even with laptop-mode-tools not managing runtime pm and I can shut down OK. But it seems wise to include everything?

You're probably right. I think only the ones that change to auto when laptop mode tools turns on are the problem children. I kind of carpet-bombed the problem. wink

By the way, how did the physics GRE go? I remember the GRE - though not, I'm pleased to say, in physics...

It was pretty painful, but at least it's over. smile I got my score back a day or two ago. I got a 66th percentile, which is exactly what I got on all the practice tests... From what the admissions people at my school tell me, that's good enough that they'd look at my application if I applied, but its not stellar.

By the way, I still don't really understand why this doesn't affect shutdown on AC. I just altered the runtime pm configuration and restarted /etc/rc.d/laptop-mode while on AC and, low and behold, the pm control for the pci devices all changed from "on" to "auto" so it looks as if runtime pm management does get enabled on AC even though laptop-mode isn't enabled... [I'm not sure this matters. I haven't tried poweroff on battery yet but so long as it works, it works. I'm just curious...]

Huh... I dunno... maybe because if you're on auto while on AC, what that actually means is that the bus isn't shut off? On the other hand, if its on auto on battery, the bus gets shut off? Just a theory. We could test it by setting the bus to off while on AC?


Lenovo Thinkpad T420; Intel sandy bridge i7 2.7GHz; integrated graphics card; 4GB RAM; wifi; Arch; Xmonad WM

Offline

#18 2012-06-23 22:51:25

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,130

Re: [SOLVED] Laptop mode tools forcing restart

Forgot to say that I did try this and it seemed to work here, too. Thanks very much!

I like the hypothesis about the bus on AC vs. battery and auto - that seems to make sense. (Presumably the default is for it to be just "on" whether on AC or battery...)

Glad you survived the GRE!


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#19 2012-07-25 09:30:50

fdservices
Member
From: France
Registered: 2012-02-06
Posts: 413

Re: [SOLVED] Laptop mode tools forcing restart

I have just installed arch on a new Toshiba L850, one day BEFORE the new install media was released, So I am pretty proud of myself, I can tell you.

My problem is exactly as described here, whenever I shutdown, the laptop reboots after about five seconds, that is on battery or AC power, from the command line after logging out, or from kde, in fact always.

I do get the POWER OFF signal, but then it restarts anyway.

I installed the "fix" above and now I can shutdown correctly on battery, but not on AC power.

Have you any more ideas to try?


Andrew

Offline

#20 2012-07-25 15:42:51

Yurlungur
Member
From: USA
Registered: 2012-01-06
Posts: 116

Re: [SOLVED] Laptop mode tools forcing restart

Hi Andrew,

It's extremely strange to me that the computer won't shut down on AC. This might not be a power management issue for you... Other related problems I looked into when I was trying to figure out my problem were solved in
this thread,
and
this thread.


Lenovo Thinkpad T420; Intel sandy bridge i7 2.7GHz; integrated graphics card; 4GB RAM; wifi; Arch; Xmonad WM

Offline

#21 2012-07-25 16:15:00

fdservices
Member
From: France
Registered: 2012-02-06
Posts: 413

Re: [SOLVED] Laptop mode tools forcing restart

Yes, it looks as though it might be two problems, one of which is solved above.

I will check on the links and come back with any results

Andrew

Offline

#22 2012-07-25 16:21:25

fdservices
Member
From: France
Registered: 2012-02-06
Posts: 413

Re: [SOLVED] Laptop mode tools forcing restart

I already tried the wakealarm fix, but it did nothing for me sad

I will check the other link now

Andrew

Offline

#23 2012-10-03 13:05:45

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [SOLVED] Laptop mode tools forcing restart

bazenga wrote:

rc.shutdown might get overwritten on update, it's probably best to add a shutdown hook.

Create a file in /etc/rc.d/functions.d/ with the following content:

# A script to act as a workaround for the bug in the runtime power
# management module, which causes thinkpad laptops to restart after
# shutting down.

disable_power_management() {
  # Bus list for the runtime power management module. Probably shouldn't
  # touch this.
  buslist="pci i2c"

  for bus in $buslist; do
    for i in /sys/bus/$bus/devices/*/power/control; do
      echo on > $i
    done
  done
}

add_hook shutdown_poweroff disable_power_management

It seems this workaround stopped working recently but it used to work.
Is there anyone experiencing the same problem?

Offline

#24 2012-10-03 17:52:22

bazenga
Member
Registered: 2009-12-14
Posts: 15

Re: [SOLVED] Laptop mode tools forcing restart

It's still working for me, have you recently switched to systemd or something?

Offline

#25 2012-10-03 19:14:06

qiuwei
Member
Registered: 2009-12-18
Posts: 245

Re: [SOLVED] Laptop mode tools forcing restart

bazenga wrote:

It's still working for me, have you recently switched to systemd or something?

Yes, I think so. I haven't completely switched to systemd.
Is there any workaround with systemd?

Offline

Board footer

Powered by FluxBB