LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 11-15-2012, 04:35 PM   #1
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,181

Rep: Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018
How-to switch between Graphics Processors using VGA Switcheroo


Caveat emptor

I do not own a laptop with hybrid graphics, so I can't check what I wrote below (a few months ago, in fact) for accuracy. For that reason I was reluctant to post this how-to on LQ. But as I see that some people still have problems using switcheroo, I eventually decided to release it.

The intended audience is people owning a laptop including hybrid graphics, i.e. integrated in the CPU (mostly Intel integrated) + discrete graphical processor (nVidia or ATI).

It is a "Request For Comments, Corrections and Enhancements" intended to feed a future "How to Switch Between Integrated vs Discrete Graphic Processor with Slackware" to be included In SlackDocs.

Introduction

Some laptops include two graphic processors: one integrated in the CPU (mostly provided by Intel) and one dedicated (ATI or nVidia)

Users should be able to choose which processor to use: the integrated one if they want less power consumption/increased battery life or the discrete one for better graphic performance.

In some models a BIOS set up allows to switch on/off each processor. Of course switching off a processor decreases power usage.

In some models a physical switch, called a multiplexer or MUX can be used to choose which processor to use.

To check that your laptop do have hybrid graphics type in a terminal:
Code:
lspci -vnn | grep '\''[030[02]\]'
As many lines in the output, as many processors. So if you get only one, you can stop reading this

PS Please somebody owning this kind of laptop check that 'lspci' shows both cards even if one is switched off in the BIOS and give us feedback.


What is Switcheroo and what can it do for you?


Switcheroo, or more accurately VGA switcheroo, is a kernel driver written by Dave Airlie to allow Linux users to switch between graphic processors on a running system.

This driver is built-in kernels shipped in Slackware 13.37 and 14.

It allows users to do three things:
- get information about their graphical processors’ state (ON or OFF) and the power used by it
- switch each processor ON/OFF
- switch to integrated or dedicated processors, either immediately or delayed. Here "delayed" means: "at next Xsession" (after an X restart)

In the recent kernels (kernel version > 2.6.37) it allows to choose which processor will be used at next reboot, acting as a "software MUX" (this is a guess, to be checked if possible by users, see the MGID and MIDS commands below).

The delayed switching between GPU is useful if you plan to switch at next X restart whilst X is running, as in that case immediate switching would kill X.

Some typical use cases:

1) You don't want to play games but would like to save power to increase battery life => make sure the integrated processor is ON, switch to it if needed then switch OFF the dedicated GPU
2) You want to play games : make sure the discrete processor is ON, then switch to it.


How can I use Switcheroo?


First, you will need a hybrid graphic which allows switcheroo's usage (of course). You can check that with following command (typed as root):
Code:
grep switcheroo /var/log/messages
The output should be a line like this one:
Code:
 Jul  4 12:44:00 darkstar kernel: [    8.609135] VGA switcheroo: detected switching method \_SB_.PCI0.GFX0.ATPX handle
And, KMS (kernel mode setting) should be enabled for the ATI or nVidia card. Hopefully, this is done by default in Slackware.

You communicate with Switcherooo through its interface, which is the following pseudo file:
Code:
/sys/kernel/debug/vgaswitcheroo/switch
either by reading it with the 'cat' command or by writing to it with the 'echo' command. We will detail these commands later.

Please note that this file is owned by root: all commands should be typed as root.

First, we need to mount the debug file system, which is needed to populate the /sys/kernel/debug pseudo directory (otherwise it would stay empty).

You can do that on the fly with following command:
Code:
mount -t debugfs debugfs /sys/kernel/debug
To have it mounted at start-up, append following line to your /etc/fstab:
Code:
none    /sys/kernel/debug    debugfs    defaults    0 0
The commands

1) Acronyms used in display and setting commands
IGD: Integrated Graphic Device (mostly Intel)
DIS: denotes DIScrete graphic device (nVidia or ATI)
OFF - power off the unused device
ON - power on the unused device
DIGD - delayed switch to integrated device (at next X startup)
DDIS - delayed switch to discrete device at next X startup)
IGD - immediate switch to integrated device
DIS - immediate switch to discrete device
MIGD - mux switch to integrated device (if I am right, at next reboot)
MDIS - mux switch to discrete device (if I am right, at next reboot)

WARNING. DO NOT TRY TO USE MGID OR MGIS COMMAND for a kernel version < 2.6.38 (as the kernels installed by default on Slackware 13.37).
I have one report that after doing that it is not possible to get a working screen anymore.

2) to query the state of the graphic processors:
Code:
cat /sys/kernel/debug/vgaswitcheroo/switch
The output will look like this one:
Code:
0:IGD:+:Pwr:0000:00:02.0
1:DIS: :Pwr:0000:01:00.0
The '+' in the first line means that at the moment the active GPU is the Integrated Graphic Device.

2) Available commands
The general form of the commands is:
Code:
echo <switcheroo_command> > /sys/kernel/debug/vgaswitcheroo/switch
where <switcheroo_command> can be one of the following:
OFF ON DIGD DDIS IDG DIS MIGD MDIS
and the ">" sign after <switcheroo_command> should be typed litteraly.

The immediate switching commands (IDG / IDS) shouldn't be used under X, use the delayed ones instead (DIDG / DDIS)

Note. In Slackware 13.37, MIGD and MDIS commands are not available in the 2.6.37.6 kernels, but they are available in 2.6.38.4 provided in /testing

What if I own an Optimus laptop?

For the time being, you will need to use bumblebee, SlackBuilds for it are provided by jgeboski see here. To know more see Nvidia Optimus on The Slackware Documentation Project.

Last news about Optimus support at time of writing are in Phoronix.

REFERENCES
http://rosinstrument.com/pb/m/16575.htm
http://www.x.org/wiki/RadeonFeature see note #4 after the Feature Matrix about MUXed and MUX-less.
http://nouveau.freedesktop.org/wiki/Optimus
/usr/src/linux-<version>/drivers/gpu/vga/vga_switcheroo.c

Last edited by Didier Spaier; 11-20-2012 at 05:45 AM. Reason: Mentioned the article about Nvidia Optimus on SlackDocs
 
Old 11-15-2012, 05:40 PM   #2
Darth Vader
Member
 
Registered: May 2008
Location: Romania
Distribution: DARKSTAR Linux 2008.1
Posts: 599

Rep: Reputation: 109Reputation: 109
I would like to add that the best possible advice is to not enable the discrete graphics card for any reason, particularly if you use suspend and hibernate. Read: there is great stability issues.

Also, the power management support offered by the ATI and NVIDIA open source drivers are below critical and the risk of getting a heater ... err, fried laptop is very high.

If you still have dual graphics, use vga-switcheroo to deactivate discrete graphics card. Your laptop will work cooler and the battery will last longer.

But, you should remember to activate it again, before shutdown/reboot to make happy your BIOS.

Last edited by Darth Vader; 11-15-2012 at 05:43 PM.
 
Old 11-16-2012, 12:52 PM   #3
Martinus2u
Member
 
Registered: Apr 2010
Distribution: Slackware
Posts: 345

Rep: Reputation: 56
fwiw, my company laptop (lenovo) has Nvidia Optimus 3100. I haven't bothered with bumblebee. I switch to discrete graphics in the BIOS before booting Linux, and use the Nvidia binary driver. It seems to work well. Only once I had a panic after resuming, but that could have been due to any other reason.

I should add, I specifically use the installation for 3D graphics, otherwise I would switch to internal graphics in the BIOS and use the i915 driver. That configuration also works.

With a standard kernel I can see no way to get the Optimus configuration going.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bad screen resolution when switch from NVIDIA graphics card to motherboard graphics crs17 Linux - Hardware 9 11-15-2012 09:06 AM
Debian, KVM Switch, DVI-VGA adapter n10sity Linux - Hardware 1 05-25-2010 06:51 PM
switch between DVI and VGA on monitor linuxhippy Linux - General 3 02-13-2010 12:07 PM
SIS 6215 VGA Graphics Card anjanesh Fedora 0 07-17-2005 09:32 AM
download switcheroo? Hosiah Linux - Security 4 07-04-2005 10:46 AM


All times are GMT -5. The time now is 12:59 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration