The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    Optimus,battery life and Linux

    Discussion in 'Linux Compatibility and Software' started by Gunjunkie, Feb 27, 2011.

  1. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Since optimus is not supported, I assume battery life will suffer running linux. The intel video will be running, but will the nvidia card be powered off? I should also note, machine is an xps15 with no switching in bios.
     
  2. User Retired 2

    User Retired 2 Notebook Nobel Laureate NBR Reviewer

    Reputations:
    4,127
    Messages:
    7,860
    Likes Received:
    10
    Trophy Points:
    0
    The NVidia gpu will switch off when unused, which in your Linux setup will be 100% of the time. Your notebook will use the same amount of battery as if it had integrated graphics only.
     
  3. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    If you can't switch it to integrated only in the BIOS your nvidia card will be powered on in linux by default if it uses optimus, until you use the acpi_call module to power it down. You can find lots of examples if you search for "nvidia optimus acpi_call".
     
  4. User Retired 2

    User Retired 2 Notebook Nobel Laureate NBR Reviewer

    Reputations:
    4,127
    Messages:
    7,860
    Likes Received:
    10
    Trophy Points:
    0
    You can disconnect the x16 pcie port that the NVidia GPU is attached to in grub2 prior to booting Linux. That is equivalent to running with integrated only. Use
    Code:
    setpci -s 0:0.0 54.b=0:2
    Confirm by noting the NVidia gpu is no longer in the 'lspci -tv' output.
     
  5. Thaenatos

    Thaenatos Zero Cool

    Reputations:
    1,581
    Messages:
    5,346
    Likes Received:
    126
    Trophy Points:
    231
    My non optimus nvidia didnt have a choice for IGP only and always reverted to the nvidia card over the intel. I would think the same would happen with optimus cards until you run the script to disable the card. Not sure, just a hunch.
     
  6. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    I did try, before writing to script, but it didn't take.
    Code:
    git clone http://github.com/mkottman/acpi_call.git
    
    cd acpi_call
    
    make
    
    sudo insmod acpi_call.ko
    
    ./test_off.sh
     
  7. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
  8. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Hmm, the m11xr2 has the option in bios for switching. Wonder if it matters that mine does not.

    I was doing the commands in my previous post and the output was similar to this (not mine)

    Code:
    # ./test_off.sh
    Trying \_SB.PCI0.P0P1.VGA._OFF: failed
    Trying \_SB.PCI0.P0P2.VGA._OFF: failed
    Trying \_SB_.PCI0.OVGA.ATPX: failed
    Trying \_SB_.PCI0.OVGA.XTPX: failed
    Trying \_SB.PCI0.P0P3.PEGP._OFF: failed
    Trying \_SB.PCI0.P0P2.PEGP._OFF: failed
    Trying \_SB.PCI0.P0P1.PEGP._OFF: failed
    Trying \_SB.PCI0.MXR0.MXM0._OFF: failed
    Trying \_SB.PCI0.PEG1.GFX0._OFF: failed
    Trying \_SB.PCI0.PEG1.GFX0.DOFF: failed
    Trying \_SB.PCI0.XVR0.Z01I.DGOF: failed
    Trying \_SB.PCI0.PEGR.GFX0._OFF: failed
    Trying \_SB.PCI0.PEG.VID._OFF: failed
    Trying \_SB.PCI0.P0P2.DGPU._OFF: failed
    Trying \_SB.PCI0.P0P4.DGPU.DOFF: failed
    Trying \_SB.PCI0.IXVE.IGPU.DGOF: failed
    Trying \_SB.PCI0.RP00.VGA._PS3: failed
    Trying \_SB.PCI0.RP00.VGA.P3MO: failed
    Trying \_SB.PCI0.GFX0.DSM._T_0: failed
    Trying \_SB.PCI0.LPC.EC.PUBS._OFF: failed
    Trying \_SB.PCI0.P0P2.NVID._OFF: failed
    and the one line should be,
    Code:
    Trying \_SB.PCI0.PEG1.GFX0._OFF: works!
    if working.

    Also, don't know if it matters, but I'm using kernel
    2.6.35-27-generic #48+kamal~mjgbacklight1-Ubuntu
     
  9. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    So I did this and pasted
    Code:
    sudo /sbin/rmmod /usr/local/lib/m11xr2hack.ko
    sudo /sbin/insmod /usr/local/lib/m11xr2hack.ko
    into /etc/rc.local, but it didn't take at restart? I did kinda struggle through, so I'm sure I missed something.
     
  10. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    What distro are you on?
     
  11. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    ubuntu 10.10 64 bit
     
  12. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    Do those commands work if you run them on their own?

    Does the module show up in lsmod | grep m11xr2hack

    Is your /etc/rc.local executable? chmod a+x /etc/rc.local

    I'm not even sure the status of rc.local in recent ubuntu since it's been switched to upstart from sysvinit. I think it still gets executed but I'm not sure when.
     
  13. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    I get "no such directory".

    module shows
    Code:
    ~$ lsmod | grep m11xr2hack
    m11xr2hack              1737  0
    
    Am I supposed to remove the acpi_call folder?
    It was working before the reboot. Was showing 3:40 battery life before and 5:25 after.
     
  14. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    You get no such directory on which one?
     
  15. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Code:
    mt@mt-XPS-L501X:~$ sudo /sbin/rmmod /usr/local/lib/m11xr2hack.ko
    ERROR: Module m11xr2hack does not exist in /proc/modules
    mt@mt-XPS-L501X:~$ sudo /sbin/insmod /usr/local/lib/m11xr2hack.ko
    mt@mt-XPS-L501X:~$ 
    
     
  16. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    OK maybe it's because the first one has a bad exit status so it could be killing the rest of your init script. I think if the exit status results in failure the rest of the script won't run.

    Try removing the first line from your rc.local with the rmmod and reboot -- let me know if that works.
     
  17. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Same thing as my previous post
     
  18. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    In /etc/rc.local you removed this line?
    sudo /sbin/rmmod /usr/local/lib/m11xr2hack.ko

    The only thing in your /etc/rc.local should be this:
    /sbin/insmod /usr/local/lib/m11xr2hack.ko

    After a reboot you should be able to do an lsmod | grep m11 and see that module loaded.
     
  19. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Correct.
    Code:
    mt@mt-XPS-L501X:~$ lsmod | grep m11 
    m11xr2hack              1737  0 
    mt@mt-XPS-L501X:~$ 
    
    
     
  20. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    OK so what is the problem at this point?

    Do you need to add the setpci commands to turn the card off? From the other thread:

    Code:
    echo 0 >/sys/bus/pci/devices/0000:01:00.0/enable
    echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove
    Again, I have no optimus system so I'm flying blind here I'm sorry. :D
     
  21. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    I believe so, because I did no such thing. No problem, I appreciate your help.
     
  22. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    Does that mean it's working? :)

    If not, maybe you need to use a different PCI ID. You can find it in your lspci -nn
     
  23. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Didn't get it yet. Removed the acpi_call.c and replaced with the hack file, but nothing. Did not do this before, yet it worked. Think I will start over.
     
  24. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    This is the output of
    Code:
    chmod a+x /etc/rc.local
    chmod: changing permissions of `/etc/rc.local': Operation not permitted
     
  25. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    Yeah that has to be done as root. So add sudo to the beginning of the command.

    I think it may already be executable, from what you posted earlier, but you can find out with ls -l /etc/rc.local

    It should say something like this:
    Code:
    -rwxr-xr-x 1 root root 306 Nov 30  2009 /etc/rc.local
     
  26. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    I believe its working. Thanks for helping out a novice.

    So when a new kernel is installed, is this correct?

    make clean
    make
    mv m11xr2hack.ko /usr/local/lib
    chmod 0400 /usr/local/lib/m11xr2hack.ko

    Acutally I left out,
    And rebuild your initrd after placing that blacklist file in modprobe.d:

    /sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --install $(uname -r)

    Not sure on this.
     
  27. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    That first part should be right.

    The second part for updating the initrd is done with:
    Code:
    sudo update-initramfs -ut
    from man update-initramfs:
    -t Allows to take over an custom initramfs with a newer one.
    -u This mode updates an existing initramfs.

    If it's for a different kernel specify -k kernelversion. For instance update-initramfs -utk 2.6.37.2

    The new-kernel-pkg is for redhat I think. Been ages since I used it so IDK.
     
  28. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Hmm, still not taking after reboot. So if I go
    Code:
    mt@mt-XPS-L501X:~$ cd acpi_call
    mt@mt-XPS-L501X:~/acpi_call$ sudo insmod m11xr2hack.ko
    mt@mt-XPS-L501X:~/acpi_call$ lsmod | grep m11
    m11xr2hack              1737  0
    mt@mt-XPS-L501X:~/acpi_call$
    
    Then it seems to load. I'm going to clear my head and try tomorrow. Thanks for your patience!
     
  29. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    Did you copy the new module to /usr/local/lib ?

    If you run the init script by itself after rmmod does the module load?
    Code:
    sudo rmmod /usr/local/lib/m11xr2hack.ko
    sudo /etc/rc.local
    lsmod | grep m11
    
    Maybe paste in your /etc/rc.local file contents so we can take a look.
     
  30. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Code:
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    exit 0
    echo 0 >/sys/bus/pci/devices/0000:01:00.0/enable
    echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove
    /sbin/insmod /usr/local/lib/m11xr2hack.ko
    
    Code:
    mt@mt-XPS-L501X:~$ sudo rmmod /usr/local/lib/m11xr2hack.ko
    mt@mt-XPS-L501X:~$ sudo /etc/rc.local
    mt@mt-XPS-L501X:~$ lsmod | grep m11
    mt@mt-XPS-L501X:~$
    
     
  31. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    Move the first line (exit 0) to the end of the script. ;)
     
  32. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Made the change to etc/rc.local, same. How do I copy the module
    output
    Code:
    mt@mt-XPS-L501X:~$ sudo rmmod /usr/local/lib/m11xr2hack.ko
    ERROR: Module m11xr2hack does not exist in /proc/modules
    mt@mt-XPS-L501X:~$
    
    I see that there are errors, just don't know how to correct them. Post #28 is the only way I can seem to load the module.
     
  33. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    I just meant did you copy the module from the build directory (acpi_call) to /usr/local/lib/

    Code:
    sudo cp ~/acpi_call/m11xr2hack.ko /usr/local/lib/m11xr2hack.ko
    If you run the script now, does it work once that file has been copied?
     
  34. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    I checked usr/local/lib and the m11xr2hack.ko file is there. Is it supposed to have an X icon over the upper right corner of the file? If I click on it, says "the file is of an unknown type".
     
  35. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    Yeah that X icon is because it's owned by root and you don't have privileges for the file as a normal user. I'm not sure what's going wrong this time, I've lost track. Can you try running the script and see if the module loads?
     
  36. timberwolf

    timberwolf Notebook Consultant

    Reputations:
    131
    Messages:
    288
    Likes Received:
    0
    Trophy Points:
    30
    If you want to keep the rmmod you could do the following to hide the error from being displayed and always get a good return code.

    Code:
    if /sbin/rmmod /usr/local/lib/m11xr2hack.ko 2>/dev/null ;then :;fi
     
  37. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Code:
    sudo gedit /usr/local/lib/m11xr2hack.ko
    If I do the above, shouldn't there be something in the file? It's empty. Also, when the lid is opened and resuming from suspend, there's a warning about ignoring a bad line starting with echo. Flashes too quick to see all of it. Sorry I seem so dense, but I'm just not getting it.
     
  38. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    The .ko file is a kernel module, which is a binary file. You can't open it in anything but a hex editor.
     
  39. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Ok :eek: It works, but the script isn't running at startup. What files do I need to check to make sure the correct information is there?
     
  40. ALLurGroceries

    ALLurGroceries  Vegan Vermin Super Moderator

    Reputations:
    15,730
    Messages:
    7,146
    Likes Received:
    2,343
    Trophy Points:
    331
    Does it work if you run the script manually?

    Try adding some time for it at the beginning by adding this to the top of the rc.local file (as the first line):
    Code:
    sleep 15
    The problem may be the order since ubuntu is using upstart now which runs all your startup stuff in parallel, this command may be executed too soon. This will add 15 seconds of time for it to wait until it runs the rest of the script at startup.
     
  41. Gunjunkie

    Gunjunkie Notebook Enthusiast

    Reputations:
    23
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    15
    Yes, if I run
    Code:
    :~$ cd acpi_call
    :~/acpi_call$ sudo insmod m11xr2hack.ko
    
    I'm done with this for a while. You've been extremely patient with me and I appreciate it. I'll get it eventually. Thanks!