Created attachment 56262 [details] Kernel config Trying to setup script, that switches video cards, I ran into the situation when I left with a black screen not possible to do anything with the system. Here is an example: # cat /sys/kernel/debug/vgaswitcheroo/switch 0:IGD:+:Pwr:0000:01:05.0 1:DIS: :Pwr:0000:02:00.0 # echo IGD > /sys/kernel/debug/vgaswitcheroo/switch # cat /sys/kernel/debug/vgaswitcheroo/switch 0:IGD:+:Off:0000:01:05.0 1:DIS: :Pwr:0000:02:00.0 I think that this behaviour is buggy and this should not happen. Environment: # lspci | grep -i vga 01:05.0 VGA compatible controller: ATI Technologies Inc RS780M/RS780MN [Radeon HD 3200 Graphics] 02:00.0 VGA compatible controller: ATI Technologies Inc M93 [Mobility Radeon HD 4500 Series] # uname -a Linux garik-laptop 2.6.39-rc5+ #8 SMP Sat Apr 30 18:36:12 MSD 2011 x86_64 AMD Athlon(tm) Neo Processor MV-40 AuthenticAMD GNU/Linux
From which kernel is this a regression? 2.6.38, I assume?
This is a regression from linux 2.6.37 actually. I had black screen since 2.6.38rc4, I suppose.
Do you have a guess, why this is happening (for example, any error messages from the kernel) ? Can you login via ssh when the system freezes with a black screen? Do you think the system completely froze, or are, for example, the sysrq-keys still working? Is there anything in the dmesg that gives a clue? If there is nothing in the logs, can you try netconsole?
@Florian Mickler: System is not frozen, only screen is black, because active graphical card gets turned off. I can log into the system via ssh and turn graphics on. If I do `echo IGD > /sys/kernel/debug/vgaswitcheroo/switch` just after system boot, I get following new lines in dmesg: [ 1230.530299] fbcon: Remapping primary device, fb0, to tty 1-63 [ 1230.570734] radeon: switched off [ 1230.591094] [drm] Disabling audio support [ 1230.718090] radeon 0000:01:05.0: PCI INT A disabled
Created attachment 57042 [details] dmesg output This is a full dmesg output after sending IGD to vgaswitcheroo/switch.
Am I understanding correctly that in your opinion the `echo IGD > /sys/.../switch` should be ignored if already on IGD? I.e. nothing should happen?
Either ignored, or DIS card should be turned off, not IGD. I don't know what exactly should happen as there is seems no official docs for vga_switcheroo, only various tutorials and wikis. For example ubuntu tutorial (https://help.ubuntu.com/community/HybridGraphics) says: echo IGD > /sys/kernel/debug/vgaswitcheroo/switch Connects integrated graphics with outputs. -- absolutely nothing is said if some card should be turned on / off.
Hm.. according to the original commit description "ON" / "OFF" is used to turn the not-in-use-card on/off... What was the behavior before v2.6.38-rc4? I don't know if this was an intended change in behavior or an unintended side effect of some other change. Dave Airlie can probably tell though... p.s.: Anyway, I presume working around that in userspace is not the issue? (i.e. maybe doing something like this: IGDINUSE=`grep IGD /sys/kernel/debug/vgaswitcheroo/switch | awk -F":" '{ $3 }'` if [ "x$IGDINUSE" != "x+" ]; then echo IGD > /sys/kernel/debug/vgaswitcheroo/switch fi )
> What was the behavior before v2.6.38-rc4? On 2.6.37.6 nothing happens if card is already active: # cat /sys/kernel/debug/vgaswitcheroo/switch 0:+:Pwr:0000:01:05.0 1: :Pwr:0000:02:00.0 # echo IGD > /sys/kernel/debug/vgaswitcheroo/switch # cat /sys/kernel/debug/vgaswitcheroo/switch 0:+:Pwr:0000:01:05.0 1: :Pwr:0000:02:00.0 > Anyway, I presume working around that in userspace is not the issue? You are right. I wrote simple script for this already. Thanks.
Created attachment 57582 [details] Proposed fix Can you test this patch? I don't have any switcheroo setup, but it makes sense and compiles.
I've tested the patch. It works just fine. It seems that with this patch vga_switcheroo works the same way as before 2.6.38. Thank you, Florian.
Patch : https://bugzilla.kernel.org/attachment.cgi?id=57582 Handled-By : Florian Mickler <florian@mickler.org>
A patch referencing this bug report has been merged in v2.6.39: commit a67b8887ced9d54cab7759bdb19deafed37481eb Author: Florian Mickler <florian@mickler.org> Date: Sun May 15 16:32:50 2011 +0200 vga_switcheroo: don't toggle-switch devices